Sitemap
 

Oracle Commands - Rollup

Oracle Commands - Rollup

Rollup  : ROLLUP enables a SELECT statement to calculate multiple levels of subtotals across a specified group of dimensions. It also calculates and displays a grand total. ROLLUP is a   extension to the GROUP BY clause, so its syntax is extremely easy to use. The ROLLUP extension is highly efficient, adding minimal overhead to a query.

In Oracle 10g

SELECT ch.channel_desc, t.calendar_month_desc, co.country_name,
TO_CHAR(SUM(s.amount_sold), '9,999,999,999') SALES$
FROM sh.sales s, sh.customers cu, sh.times t, sh.channels ch, sh.countries co
WHERE s.time_id = t.time_id
AND s.cust_id = cu.cust_id
AND s.channel_id = ch.channel_id
AND cu.country_id = co.country_id
AND ch.channel_desc IN ('Direct Sales','Internet')
AND t.calendar_month_desc IN ('2000-09', '2000-10')
AND co.country_name LIKE 'U%'
GROUP BY ROLLUP(ch.channel_desc, t.calendar_month_desc, co.country_name);

 

Results

CHANEL_DESC MONTH_DESC COUN_NAME SALES$
Internet 2000-09 United Kingdom 16,569
Internet 2000-09 United States of America 124,224
Internet 2000-09   140,793
Internet 2000-10 United Kingdom 14,539
Internet 2000-10 United States of America 137,054
Internet 2000-10   151,593
Internet     292,387
Direct Sales 2000-09 United Kingdom 85,223
Direct Sales 2000-09 United States of America 638,201
Direct Sales 2000-09   723,424
Direct Sales 2000-10 United Kingdom 91,925
Direct Sales 2000-10 United States of America 682,297
Direct Sales 2000-10   774,222
Direct Sales     1,497,646
      1,790,032



   
Page  1
 
Earn Money
Make Web Sites
Free Web Tools
Most searched EBooks
Help us to maintain this site free
© Copyright 2004-2007 www.easywebtech.com   
All Rights Reserved.   
Privacy policy
Earn Money with adsense Adsl wifi

technorati technorati