View previous topic :: View next topic
|
Author |
Message |
ajay_udl
New User
Joined: 10 Oct 2006 Posts: 29
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, sample data and the output from that data would be helpful. . . |
|
Back to top |
|
|
|