我希望根据以下条件选择条件:
SELECT income_decile, income, benefits,
COUNT(*) FROM income_dataset WHERE income > 50000 AND benefits < 2000;
GROUP BY income_decile;
如何运行像数据透视表那样对每个类别求和的追随者?
要在 Hive 中实现分组和条件选择,您需要确保查询的结构化、 这是你可以做到的方法,
SELECT
income_decile,
SUM(income) AS total_income,
SUM(benefits) AS total_benefits,
COUNT(*) AS total_count
FROM
income_dataset
WHERE
income > 50000
AND benefits < 2000
GROUP BY
income_decile;