如何结合两个SQL查询以获得所需的结果?

时间:2019-06-26 17:28:19

标签: sql google-bigquery

我从另一位分析师那里接任该职位,不明白他为什么以他的方式编写自己的代码而不留下任何评论。我需要一些指导来结合此特定查询的结果。

我尝试注释掉某些部分,但这会导致数据混乱。

SELECT ga_dimension1, ga_dimension2 AS cookie_2

--, ga_medium, ga_transactionrevenue, date, ga_source

FROM GA.hc_report

WHERE LOWER(ga_dimension2) <> 'unknown'
) t2

ON t1.ga_dimension1 = t2.ga_dimension1

LEFT JOIN (SELECT id, email FROM `shopify_blendo.shop_customers`) 
t3

ON t2.cookie_2 = t3.id

WHERE t2.cookie_2 IS NOT NULL --AND --ga_transactionrevenue > 0 AND 
t2.cookie_2 = '667118272583'

ORDER BY date DESC, email, total_purchases DESC, source_per_day 
DESC
-- WHERE t1.ga_transactionrevenue > 0 AND t2.cookie_2 IS NULL 
--ORDER BY date DESC


SELECT DISTINCT l1.ga_dimension1 AS l1_dimension1, l2.ga_dimension1 
AS l2_dimension1, l1.date, ga_transactionrevenue, ga_source, 
ga_medium, l1.ga_dimension2, l2.cookie_2
FROM GA.hc_report l1

0 个答案:

没有答案