rollup 的汇总行和下面的总和不相等 是什么原因呢???

如果这都不算爱 2008-02-19 01:39:42
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
...全文
203 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
longlyqq 2008-02-22
  • 打赏
  • 举报
回复
怎么解决的?
  • 打赏
  • 举报
回复
自己解决了!
  • 打赏
  • 举报
回复
我现在知道是distinct引起的问题,因为l.userid有重复,
但是这里我需要用distinct来区分用户,计算用户数。。。
根据我的需求我需要怎么改才能得到我要的统计结果呢?
  • 打赏
  • 举报
回复
调整下格式:
-----------------------------------------------------------------------
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

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧