I would like to use a GROUP BY statement ( such as GROUP BY month) but instead of having 12 months that are being grouped by I would like to put january and Febuary in a group and march, april, may, june, july in a group and the rest in another group or something like this ( make my own groups using one of the columns). Is this a simple statement? I have thought about adding another column, but thought there might be an easier way without having to add a seperate column. I would like to also change the grouping easily without deleting columns and recreating new ones.
Thanks for any insight you my have on this.
Aloha
Jeremy
| Title | Under | Posted on |
|---|---|---|
| what is bursting in xmlp | PeopleSoft Technical | 09/06/2010 - 2:21am |
| Running SQR from Process Scheduler | PeopleSoft Technical | 09/04/2010 - 10:16am |
| 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 |
Hi Jeremy,
No you don't need to create any new columns. You can use the decode function in your SELECT to accomplish what you wrote above.
Here is a simple example:
'JAN', 'GROUP1',
'FEB', 'GROUP1',
'MAR', 'GROUP2',
'APR', 'GROUP2',
'MAY', 'GROUP2',
'JUN', 'GROUP2',
'JUL', 'GROUP2',
'AUG', 'GROUP3',
'SEP' , 'GROUP3',
'OCT', 'GROUP3',
'NOV', 'GROUP3',
'DEC', 'GROUP3') AS month FROM table1
GROUP BY DECODE(DECODE(UPPER(month),
'JAN', 'GROUP1',
'FEB', 'GROUP1',
'MAR', 'GROUP2',
'APR', 'GROUP2',
'MAY', 'GROUP2',
'JUN', 'GROUP2',
'JUL', 'GROUP2',
'AUG', 'GROUP3',
'SEP' , 'GROUP3',
'OCT', 'GROUP3',
'NOV', 'GROUP3',
'DEC', 'GROUP3');
This Should Work.
Post new comment