CUBE 生成的结果集显示了所选列中值的所有组合的聚合
在cube中不能使用all关键字 cube的分组组合最全,是各个维度值的笛卡尔
concat
1、功能:将多个字符串连接成一个字符串。
在t的结果集中在去查询
SELECT
'2018/08/02' ,
t.appid ,
t.appversion ,
t.appplatform,
t.brand ,
t.devicestyle,
t.ostype ,
count(t.deviceid) cnt
FROM
(
select
appid ,
appplatform,
brand ,
devicestyle,
ostype ,
appversion ,
deviceid ,
min(createdatms) firsttime #第一次访问的时间(最小时间)
from
appstartuplogs
group BY
appid ,
appplatform,
brand ,
devicestyle,
ostype ,
appversion,
deviceid
with cube
)t #子查询
WHERE
t.appid is not NULL #appid不能为空
and t.deviceid is not null #设备id不能为空
#时间戳
and formatbyday(t.firsttime , 0 , 'yyyy/MM/dd') = '2018/08/02'
#六天以前的时间 位于我们要的时间 就是2018/08/02
#and formatbyday(t.firsttime , 0 , 'yyyy/MM/dd') = formatbyday(-6,'yyyy/MM/dd')
group by
t.appid ,
t.appversion ,
t.appplatform,
t.brand ,
t.devicestyle,
t.ostype
order BY
t.appid ,
t.appversion ,
t.appplatform,
t.brand ,
t.devicestyle,
t.ostype