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 |
|---|---|---|
| MD5 - SHA checksum of a file. | PeopleSoft Technical | 02/07/2012 - 5:29am |
| nVision Tabular Report through PIA with prompts | PeopleSoft Technical | 02/02/2012 - 10:07pm |
| Can we create an AE to mass update Position - Jobcode data? | PeopleSoft Technical | 01/18/2012 - 3:11am |
| Pay Components on job data can be defaulted and setup based on the rules? | PeopleSoft Functional | 01/05/2012 - 4:58am |
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