Re: DB2 group by with date functions
  Home FAQ Contact Sign in
bit.listserv.ibmmain only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: DB2 group by with date functions         

Group: bit.listserv.ibmmain · Group Profile
Author: Lindy Mayfield
Date: Jun 16, 2008 14:18

Thanks John. That's exactly what I thought, then I started doubting myself when I couldn't get it to work.

Select Year(Expdate), Month(Expdate), Category, sum(expamt)
from EXP.EXPENSES
group by Year(Expdate), Month(Expdate), Category
order by 1 desc, 2 desc, 3

---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL "(". SOME SYMBOLS THAT MIGHT BE
LEGAL ARE: FOR WITH FETCH ORDER UNION EXCEPT QUERYNO OPTIMIZE
DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 158 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF'
X'0000009E' X'00000000' SQL DIAGNOSTIC INFORMATION

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@BAMA.UA.EDU] On Behalf Of McKown, John
Sent: 17. kesäkuuta 2008 0:14
To: IBM-MAIN@BAMA.UA.EDU
Subject: Re: DB2 group by with date functions
> -----Original Message-----
> From: IBM Mainframe Discussion List
> [mailto:IBM-MAIN@BAMA.UA.EDU] On Behalf Of Lindy Mayfield
> Sent: Monday, June 16, 2008 4:06 PM
> To: IBM-MAIN@BAMA.UA.EDU
> Subject: DB2 group by with date functions
>

Select Year(Expdate), Month(Expdate) ,
Category, Sum(Expamt)
from EXP.EXPENSES
group by Year(expdate), Month(Expdate), category
order by 1 desc, 2 desc, 3

ref:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAPK10/1.1.
6

--
John McKown
Senior Systems Programmer
HealthMarkets
Keeping the Promise of Affordable Coverage
Administrative Services Group
Information Technology

----------------------------------------------------------------------
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
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Hypergeometric functions and beta functionssci.math ·