尝试使用左联接获取按日期分组的3个字段。按日期分组显示重复的日期。
在MySQL中进行了尝试,并且工作正常,但在BigQuery中却无法正常工作。
SELECT DATE(a.transactionDate) as date,
CASE WHEN b.memberProfileNumber LIKE 'M0%' THEN SUM(a.fromAmount) END AS
col1,
CASE WHEN b.memberProfileNumber NOT LIKE 'M0%' THEN SUM(a.fromAmount) END
AS col2
FROM `fashionpoints*` as a
LEFT JOIN `fashionprofile*` as b
ON a.toAccountId = b.id
WHERE a.fromATC = 'usd' AND
a.type = 'awarding' AND
a.status = 'active'
GROUP BY date
预期输出为DISTINCT Date,实际结果与日期重复。</ p>
预期输出:
实际结果: Actual Result
答案 0 :(得分:0)
您的汇总错误。尝试替换为SUM(CASE WHEN... THEN...ELSE 0 END) as col1/2