In one of my previous ROLLUP posts I showed you how to generate summary information. However, the output of ROLLUP includes the rows produced by the regular GROUP BY operation along with the summary rows.
So, what if you are only interested in totals. Well, Oracle does provide an extension to the GROUP BY clause called GROUPING SETS that you can use to generate summary information at the level you choose without including all the rows produced by the regular GROUP BY operation.
Lets take a look at an example:
| Title | Under | Posted on |
|---|---|---|
| How to run nvision report through portal | PeopleSoft Technical | 08/31/2010 - 4:45am |
| Any1 here who can help? | PeopleSoft Technical | 08/31/2010 - 2:12am |
| How to create matrix layout | PeopleSoft Technical | 08/27/2010 - 2:22am |
| UnCaught C++ Exception | PeopleSoft Technical | 08/10/2010 - 9:05am |
Comments
And what if I'm interested in totals but I want only one row for different years?
for example:
YEAR JAN FEB MAR
------ ----------- ----------- ------------
2000 4496799 4988535 5578521
2001 5029212 5074332 4960311
>> but I want only one row for different years
You can get the total for each month in every year by grouping by year and month. But you will not have one and only one row for each year. To accomplish what you want, you need to look at how to convert rows into columns. Here is a tip on how to do that posted at Oracle's site
http://www.oracle.com/technology/oramag/code/tips2004/050304.html
Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog
select the employee using group by function where department member is greater than 4
Plz help me on the matter
Hello Lepa,
I have been looking for the sample database that contains the orders and region tables you used in this example without success.
I am using 11gr2 and I believe I installed all the sample schemas. Where would I find the tables/data you've been using in your examples ?
Thank you,
John.
Post new comment