rollup 的汇总行和下面的总和不相等 是什么原因呢???
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