zl程序教程

您现在的位置是:首页 >  其它

当前栏目

hive中窗口分析函数

函数 分析 窗口 hive
2023-09-14 08:57:20 时间

分组统计

1. groups sets(field1,field2,field3, (field1,field2)) 样例如下:

    select dt,tenantCode,nvl(platform,'all') as platform,
    count(1) as uv_one
    from(
    select tenantCode,platform,dt,deviceId,count(deviceId) as pv from
    dw_stg.tmp_tg_user_behavior_day a
    group by tenantCode,platform,dt,deviceId
    having tenantCode is not null 
    and deviceId is not null
    --and count(deviceId) = 1 --浏览量为1的访客数
    )aa group by tenantCode,platform,dt
    grouping sets((dt,tenantCode), (dt,tenantCode,platform))

结果显示如下: