select a.dt,nvl(a.version_id,'-') version_id,
case when a.clickevent='clickEvent00116' then '桌面悬浮窗展现量(大框展示1)'
when a.clickevent='clickEvent00120' then '桌面悬浮窗1'
when a.clickevent='clickEvent00109' then '搜索入1口'
when a.clickevent='clickEvent00112' then '垃圾清理1'
when a.clickevent='clickEvent00110' then '中间加速1圆圈' end gate,
nvl(a.categoryName,'未知') categoryName,
count(case when a.clickevent='clickEvent00116' then '0' end) ,
count(distinct case when a.clickevent='clickEvent00116' then a.imsi end),
count(case when a.clickevent in ('clickEvent00109','clickEvent00112','clickEvent00120','clickEvent00110') then '1' end ),
count(distinct case when a.clickevent in ('clickEvent00109','clickEvent00112','clickEvent00120','clickEvent00110') then a.imsi end)
from
(select dt,version_id,
case when clickevent='clickEvent00120' then
categoryName else null end categoryName,
imsi,clickevent from dw_user_tabclick_log_client_day
where dt>='20141113' and dt<='20141115'
and clickevent in
('clickEvent00116','clickEvent00120','clickEvent00109','clickEvent00112','clickEvent00110')) a
group by a.dt,a.version_id, a.categoryName,
case when a.clickevent='clickEvent00116' then '1桌面悬浮窗展现量(大框展示)'
when a.clickevent='clickEvent00120' then '桌面1悬浮窗'
when a.clickevent='clickEvent00109' then '搜索1入口'
when a.clickevent='clickEvent00112' then '垃圾11清理'
when a.clickevent='clickEvent00110' then '中间加1速圆圈' end;
知识点如下所示:
①:
.NVL函数
NVL函数的格式如下:NVL(expr1,expr2)
含义是:如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值。
②:count(1):
获取查询结果行数。 select count(1) from table where 。。。 select count(*) from table where 。。。 这两种查询方式在对同一个表,用同样查询条件查询时,结果都是一样的。