select decode(grouping(l.nareated), 1, '日期合计', to_char(l.nareated)) nareated,
count(distinct(case
when l.isindex = 0 then
l.userid
else
null
end)) viewpeople, -- 这个字段 汇总行和下面数据行总和不相等
count(distinct(case
when l.ischarge = 1 and l.msid is not null then
l.msid || l.productid
else
null
end)) bookpeople, -- 这个字段 汇总行和下面数据行总和不相等
sum(case
when l.isnewuser = 0 then
1
else
0
end) newusers,
sum(case
when l.isindex = 0 then
1
else
0
end) assces,
count(case
when l.ischarge = 1 and l.msid is not null then
l.userid
else
null
end) downs,
sum(case
when l.ischarge = 1 then
l.price
else
0
end) / 10 moneys
from t_wp_accesslog l, t_declare_dproduct p
where l.productid = p.productid
and l.msid is not null
and l.nareated between to_number('20080217') and to_number('20080218')
group by rollup(l.nareated)
order by nareated desc
-----------------------------------------------------------------------------------
结果如下:
NAREATED VIEWPEOPLE BOOKPEOPLE NEWUSERS ASSCES DOWNS MONEYS
日期合计 9288 3563 10732 24057 9695 19082
20080217 4659 1794 5202 11589 4514 8871.5
20080216 4989 1880 5530 12468 5181 10210.5
count(distinct(case
when l.isindex = 0 then
l.userid
else
null
end)) viewpeople, -- 这个字段 汇总行和下面数据行总和不相等
count(distinct(case
when l.ischarge = 1 and l.msid is not null then
l.msid || l.productid
else
null
end)) bookpeople, -- 这个字段 汇总行和下面数据行总和不相等
sum(case
when l.isnewuser = 0 then
1
else
0
end) newusers,
sum(case
when l.isindex = 0 then
1
else
0
end) assces,
count(case
when l.ischarge = 1 and l.msid is not null then
l.userid
else
null
end) downs,
sum(case
when l.ischarge = 1 then
l.price
else
0
end) / 10 moneys
from t_wp_accesslog l, t_declare_dproduct p
where l.productid = p.productid
and l.msid is not null
and l.nareated between to_number('20080217') and to_number('20080218')
group by rollup(l.nareated)
order by nareated desc
-----------------------------------------------------------------------------------
结果如下:
NAREATED VIEWPEOPLE BOOKPEOPLE NEWUSERS ASSCES DOWNS MONEYS
日期合计 9288 3563 10732 24057 9695 19082
20080217 4659 1794 5202 11589 4514 8871.5
20080216 4989 1880 5530 12468 5181 10210.5
解决方案 »
- 关联删除的SQL,在线等
- 存储过程小问题(来看看)
- 救命:select报ORA-01036: illegal variable name/number
- create tablespace logging问题
- 想用游标修改表中的列,语法错了
- sql模糊匹配如何匹配空值
- cursor不能获得参数(100分)
- 我编译occi程序老是出错,提示我一些类函数没有定义
- dbms_pipe包问题
- oracle的统计查询前10
- 新手提问,关于查询已经创建好的VIEW里面全部字段的问题。(多表的UNION起来的情况很棘手,请有经验的朋友来看一下)
- oracle中,设定varchar2长度为4000,为什么存到980就不行了???
-----------------------------------------------------------------------
NAREATED VIEWPEOPLE BOOKPEOPLE NEWUSERS ASSCES DOWNS MONEYS
日期合计 9288 3563 10732 24057 9695 19082
20080217 4659 1794 5202 11589 4514 8871.5
20080216 4989 1880 5530 12468 5181 10210.5
但是这里我需要用distinct来区分用户,计算用户数
根据我的需求我需要怎么改才能得到我要的统计结果呢?