oracle中使用cube,Oracle的聚合函数group by结合cube的使用

Example 21-4 CUBE

SELECT channel_desc,calendar_month_desc,countries.country_iso_code,TO_CHAR(SUM(amount_sold),‘9,999,999‘) SALES$

FROM sales,customers,times,channels,countries

WHERE sales.time_id=times.time_id AND sales.cust_id=customers.cust_id AND

sales.channel_id= channels.channel_id

AND customers.country_id = countries.country_id

AND channels.channel_desc IN

(‘Direct Sales‘,‘Internet‘) AND times.calendar_month_desc IN

(‘2000-09‘,‘2000-10‘) AND countries.country_iso_code IN (‘GB‘,‘US‘)

GROUP BY CUBE(channel_desc,countries.country_iso_code);

CHANNEL_DESC CALENDAR CO SALES$

-------------------- -------- -- --------------

1,790,032

GB 208,257

US 1,581,775

2000-09 864,217

2000-09 GB 101,792

2000-09 US 762,425

2000-10 925,815

2000-10 GB 106,465

2000-10 US 819,351

Internet 292,387

Internet GB 31,109

Internet US 261,278

Internet 2000-09 140,793

Internet 2000-09 GB 16,569

Internet 2000-09 US 124,224

Internet 2000-10 151,593

Internet 2000-10 GB 14,539

Internet 2000-10 US 137,054

Direct Sales 1,497,646

Direct Sales GB 177,148

Direct Sales US 1,320,497

Direct Sales 2000-09 723,424

Direct Sales 2000-09 GB 85,223

Direct Sales 2000-09 US 638,201

Direct Sales 2000-10 774,222

Direct Sales 2000-10 GB 91,925

Direct Sales 2000-10 US 682,297

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值