其他环境没有试,Hive上肯定是可以的。
可以在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)三都统计得到的值是相同的。

Logo

大数据从业者之家,一起探索大数据的无限可能!

更多推荐