Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve transaction report 2

Status
Not open for further replies.

soushi01

Technical User
Dec 27, 2010
31
MY
Hi

I currently do transaction report by cash , criteria is any "transaction by 'cash' " must display in report.
other transaction like Cheque no need display [hammer] [hairpull]

table_collection
IC-------- Item------------ Receipt--- Mode_Of_Payment----- Transaction_STATUS ------ COLLECTED_DATE
T123----- Addidas-------- rc01------- Cheque------------------ Cancel----------------- 12-dec-2012
T123----- Addidas-------- rc01------- Cancel Transcation------ Cancel---------------- 12-dec-2012
B567----- Nike------------- rc02------- Cash--------------------- Cancel---------------- 12-dec-2012
B567----- Nike------------- rc02------- Cancel Transcation------ Cancel---------------- 12-dec-2012
C890----- New Balance--- rc03------- Cancel Transcation------ Cancel--------------- 12-dec-2012
C890----- New Balance--- rc03------- Cheque------------------ Cancel--------------- 12-dec-2012
D112----- Reebok---------- rc04------- Cash------------------ Active--------------- 12-dec-2012

Expected output
IC--------- Item----------- Receipt--- Mode_Of_Payment------- Transaction_STATUS------ COLLECTED_DATE
B567------ Nike----------- rc02------- Cash----------------------------- Cancel-------------- 12-dec-2012
B567------ Nike----------- rc02------- Cancel Transcation------------ Cancel------------- 12-dec-2012
D112------ Reebok---------- rc04------- Cash------------------------- Active------------------ 12-dec-2012

thanks
 
I guess you want something like:

[tt]SELECT *
FROM table_collection
WHERE IC IN (SELECT IC FROM table_collection WHERE Mode_Of_Payment = 'Cash')
[/tt]
i.e. all rows for a transaction where cash has been involved at least once.
 
Another way:
Code:
SELECT T.*
FROM table_collection T INNER JOIN (
SELECT DISTINCT IC FROM table_collection WHERE Mode_Of_Payment='Cash'
) C ON T.IC=C.IC

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yeah, thats a part of the beaty of SQL, the same problem can be solved in completely different ways. (Somewhat confusing for beginners?)

Note that my solution is Core SQL-99 compliant!
( a great time saver when writing "portable" SQL.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top