在hivesql中查找唯一计数Postgresql查询
我想获得独特的客户数量。我有postgresql查询的参考。能否将此查询转换为HiveSql在hivesql中查找唯一计数Postgresql查询,sql,postgresql,hive,hiveql,Sql,Postgresql,Hive,Hiveql,我想获得独特的客户数量。我有postgresql查询的参考。能否将此查询转换为HiveSql SELECT COUNT(user_id) Total_profiles, COUNT(distinct user_id) FITLER (WHERE age BETWEEN 18 AND 12) as age_less_than_20 FROM customer_profiles WHERE profile_date BETWEEN '2020-01-01' AND
SELECT
COUNT(user_id) Total_profiles,
COUNT(distinct user_id) FITLER (WHERE age BETWEEN 18 AND 12) as age_less_than_20
FROM
customer_profiles
WHERE
profile_date BETWEEN '2020-01-01' AND '2020-12-31'
用例表达式:
SELECT
COUNT(user_id) Total_profiles,
COUNT(distinct case when age BETWEEN 18 AND 12 then user_id else null end) as age_less_than_20
FROM
customer_profiles
WHERE
profile_date BETWEEN '2020-01-01' AND '2020-12-31'
另一种计算不同大小的方法是大小(collect_set()):
用例表达式:
SELECT
COUNT(user_id) Total_profiles,
COUNT(distinct case when age BETWEEN 18 AND 12 then user_id else null end) as age_less_than_20
FROM
customer_profiles
WHERE
profile_date BETWEEN '2020-01-01' AND '2020-12-31'
另一种计算不同大小的方法是大小(collect_set()):
MySQL是如何参与的?MySQL是如何参与的?@GordonLinoff谢谢,fixed@GordonLinoff谢谢,修好了