分组 with cube/rollup

goodluckylw 2003-08-06 12:20:17
分组 with cube/rollup
为什么在oracle 中使用 以上选项总出错
...全文
10 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuxuan 2003-08-08
  • 打赏
  • 举报
回复
为什么不贴出Oracle的写法,看错在那里

给两个例子:
select a,b,sum(c) from xxx group by rollup(a,b);

select a,b,sum(c) from xxx group by cube(a,b);

Oracle817以上调试通过
csusmart 2003-08-06
  • 打赏
  • 举报
回复
关注中!

你是在哪里用的?
wwl007 2003-08-06
  • 打赏
  • 举报
回复
语法写出来
看看
select (case when t.fund_code is null then ' '
else t.recevied_date end) recevied_date,
(case when t.fund_code is null and t.recevied_date is null then '总计'
when t.fund_code is null then '合计'
else min(tt.fund_name)||to_char(to_date(min(t.trade_date),'yyyymmdd'),'yyyy-mm-dd')||'日交易' end) last_date,
sum(decode(t.operation_flag,'1',t.recevied_money)),
sum(decode(t.operation_flag,'1',0,t.recevied_money)),
sum(decode(t.operation_flag,'1',t.recevied_money))-sum(decode(t.operation_flag,'1',0,t.recevied_money)),
(case when t.fund_code is null then '1' else '0' end) BOLD
from fundrecevied_book t,
(select t0.fund_code fund_code,
t1.fund_name fund_name
from par_fund_team t0,par_fund t1
where t0.big_fund_code='PX_fundcode'
and t1.fund_code=t0.fund_code
and substr(t1.fund_kind,1,1)='2') tt
where t.fund_code=tt.fund_code
and t.recevied_date between 'PX_startdate' AND 'PX_enddate'
and t.operation_flag in ('1','2')
group by rollup(t.recevied_date,t.fund_code)

beckhambobo 2003-08-06
  • 打赏
  • 举报
回复
楼主是用sql server中用到:
CUBE 运算符生成的结果集是多维数据集。多维数据集是事实数据的扩展,事实数据即记录个别事件的数据。扩展建立在用户打算分析的列上。这些列被称为维。多维数据集是一个结果集,其中包含了各维度的所有可能组合的交叉表格。

select id,sal1,sal2 from tab1
union
select id,sum(sal1),sum(sal2) from tab1 group by id
union
select null,sum(sql1),sum(sal2) from tab1
gladness 2003-08-06
  • 打赏
  • 举报
回复
把sql帖出来,错误号等等
hdkkk 2003-08-06
  • 打赏
  • 举报
回复
版本不对吧?

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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