Link to home
Start Free TrialLog in
Avatar of Malinda Klein
Malinda Klein

asked on

How to add sum and grouping to a complex query

I want to group by invoice number and sum the cost for the attached MYSQL query and resulting report but when I add group by `INV`.`INVOICE_NUMBER`  I get no records found when I try to Select * from (complex query) group by `INV`.`INVOICE_NUMBER`

User generated image
complexquery.txt
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Remove fields that cannot be aggregated in an aggregated query like Billed Dates
So probably it would be
Select [invoice Num],Sum(Cost) as Total Cost from your query Group By [Invoice Num]
ASKER CERTIFIED SOLUTION
Avatar of lenamtl
lenamtl
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Completely opposite point of view..I am a big fan of  offloading everything I can to a single point of interest...in this case the MySQL server..if you can do it in a server why recompile the code