使用Hive日常工作基本上都会碰到统计PV、UV的需求,有如下日志表格式表:
create table user_log
(
log_time string,
user_id string,
....
)
统计一段时间内的PV、UV可以用如下hive sql:
select count(1) as pv,count(distinct user_id) as uv
from user_log
where log_time>='2018-09-01 00:00:00' and log_time<='2018-09-02 23:59:59'