Jump to content

Advanced Sum


Erehwon

Recommended Posts

Greetings - I've got the basics down of adding up data - but I have run across a need for some advanced work that i need some help with/.Given:Customer Amount ----------- ---------A 5.00B 2.00A 3.00B 2.00C 1.00I need to write a query that will sum the totals for client a, client b,client c. Here's the kicker - I don't want the output to be individual lines for those clients rather the totals - as belowOutput:\Customer Amount ----------- ---------A 8.00B 4.00C 1.00Anyone have a suggestion?

Link to comment
Share on other sites

Not so hard I guess :-)Base logic:SELECT Customer,SUM(OrderPrice) FROM OrdersGROUP BY CustomerApplied to my situation:SELECT COMPANY_NAME,SUM(monthly_inv_amt) as BILLEDFROM AGR_Invoice_Amt INNER JOIN AGR_Header ON AGR_Invoice_Amt.AGR_Header_RecID = AGR_Header.AGR_Header_RecID INNER JOIN Company ON AGR_Header.Company_RecID = Company.Company_RecIDWHERE (AGR_Invoice_Amt.Year_Nbr = '2009') AND (AGR_Invoice_Amt.Month_Nbr = '11')GROUP BY company_nameORDER BY BILLED DESCHope this helps someone out there

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...