哪一个查询可以产生table_c?
我有三列:day、person 和income_per_person。现在我必须使用两个查询,因为我在生成table_b时丢失了“人” 。
table_a使用所有三列:
SELECT day, person, revenue_per_person
FROM purchase_table
GROUP BY day, person
由于 AVG() 和 GROUP BY,table_b仅使用两列:
SELECT day, AVG(revenue) as avg_revenue
FROM purchase_table
GROUP BY day
从table_a和table_b创建的table_c:
SELECT
CASE
WHEN revenue_per_person > avg_revenue THEN 'big spender'
ELSE 'small spender'
END as spending_bucket
FROM ????