Hive中count统计数量的多种使用方式
其他环境没有试,Hive上肯定是可以的。可以在count里使用case when、distinct等处理,满足日常数据统计需求。selectpt_day,count(*),count(uid),count(identifier),count(distinct uid),count(distinct identifier),
·
其他环境没有试,Hive上肯定是可以的。
可以在count里使用case when、distinct等处理,满足日常数据统计需求。
其中,count(*),count(uid),count(identifier)三都统计得到的值是相同的。
可以在count里使用case when、distinct等处理,满足日常数据统计需求。
select
pt_day,
count(*),
count(uid),count(identifier),
count(distinct uid),count(distinct identifier),
count(case when appkey='CSIos' then identifier else null end),count(case when appkey='CSAndroid' then identifier else null end),
count(distinct case when appkey='CSIos' then identifier else null end),count(distinct case when appkey='CSAndroid' then identifier else null end),
count(case when appkey in ('CSIos','CSAndroid') then identifier else null end),
count(distinct case when appkey in ('CSIos','CSAndroid') then identifier else null end)
from bi_all_access_log
where pt_day between '2017-11-01' and '2017-11-14'
group by pt_day
order by pt_day;
说明:其中,count(*),count(uid),count(identifier)三都统计得到的值是相同的。
更多推荐
所有评论(0)