| DB2 group by with date functions |
|
 |
|
 |
|
 |
|
 |
Group: bit.listserv.ibmmain · Group Profile
Author: Lindy MayfieldLindy Mayfield Date: Jun 16, 2008 14:06
I seem to have forgotten how to do this, and I cannot seem to find the
answer in the docs or via Google.
I want to group by using two columns which are year() and month(), but
the result set isn't grouping.
For example:
Select Year(Expdate), Month(Expdate) ,
Category, Sum(Expamt)
from EXP.EXPENSES
group by expdate, category
order by 1 desc, 2 desc, 3
Gives:
2008 6 Adjustments 12.68
2008 6 Car 10.50
2008 6 Car 18.50
What is the syntax for the group columns when they are functions?
Thanks!
Lindy
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to listserv@ bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
|