Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Regarding summing up two columns and find difference

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ajay_udl

New User


Joined: 10 Oct 2006
Posts: 29

PostPosted: Tue Mar 10, 2009 9:04 am    Post subject: Regarding summing up two columns and find difference
Reply with quote

Hi All,

I'm looking for a sql query.

I have columns like TRAN_LID_AM,TRAN_TYPE_CD and EXT_CM_NO.
The column TRAN_TYPE_CD have values 'D' and 'C'.
The EXT_CM_NO represents card-no and we need to sum up all TRAN_LID_AM with TRAN_TYPE_CD as 'D' and again sum up all TRAN_LID_AM with TRAN_TYPE_CD as 'C'. After which we need to output EXT_CM_NO who are having the summed up value of 'D' minus the summed up value of 'C' as positive.

Regards
Ajay.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 10, 2009 9:36 am    Post subject:
Reply with quote

Hello,

In addition to the rules description, it will help if you post some sample columns with values that demonstrate the rules and the output you want from the posted input. Make sure the sample data includes all possibilities and that the sample output corresponds with the input.
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Wed Mar 11, 2009 1:44 am    Post subject:
Reply with quote

Hope this query will give some basis
Code:
SELECT A.S1 - B.S2
FROM
(SELECT SUM(TRAN_LID_AM) AS S1 FROM TBL1 WHERE
TRAN_TYPE_CD='D') AS A,
(SELECT SUM(TRAN_LID_AM) AS S2 FROM TBL2 WHERE
TRAN_TYPE_CD='C') AS B


I could not unserstand what so you mean by:
After which we need to output EXT_CM_NO
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 11, 2009 2:00 am    Post subject:
Reply with quote

Hello,

Yes, sample data and the output from that data would be helpful. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 4 Fri Sep 22, 2017 4:56 pm
No new posts Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us