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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to sum a cloumn with a condition 1

Status
Not open for further replies.

LyndonOHRC

Programmer
Sep 8, 2005
603
US
I am using a JetSQL/ODBC connection.

This query works but I need another column that is conditional. The column I need is Sum(Amount) Where Instrument='ACH' as ACHSales. But I don't know how to integrate that into the query.

Code:
Select Format(TransactionDate,'yyyy/mm/dd') as mTransactionDate, Track, Sum(Amount) as TotalSales, Instrument
	From Receipt
	Group By Format(TransactionDate,'yyyy/mm/dd'), Track
	Order By Format(TransactionDate,'yyyy/mm/dd') desc,Track
Thanks

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Select Format(TransactionDate,'yyyy/mm/dd') as mTransactionDate, Track, Sum(Amount) as TotalSales, Instrument[!], Sum(IIf(Instrument='ACH',Amount,0)) AS ACHSales[/!]
From Receipt
Group By Format(TransactionDate,'yyyy/mm/dd'), Track
Order By Format(TransactionDate,'yyyy/mm/dd') desc,Tr

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you very much!

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top