我有一个要求,我需要选择最近出现的 unique_customer_id 和 message_id,每个消息 ID 不超过一个客户行。我还需要返回 channel 和 reason_code 的关联数据,但这些数据可以并且将会是重复数据。如果需要,我也可以使用 unique_row_id。如何将这两个字段添加到我当前的查询中?(或以其他方式一起做)
SELECT DISTINCT unique_customer_id, message_id, MAX(date)
FROM Table1
GROUP BY unique_customer_id, message_id