Re: SQL Query to get sum of same invoice numbers ...
you select the SUM() of what ever field(s) you want to sum up.... and GROUP BY the rest of the fields...
so if I have a table with NAME, MEAL, TOTAL and I want to see the sum of everything I bought: select NAME, sum(TOTAL) as TOTAL from MyTABLE group by NAME
If I want to see the sum of all the different things, broken out by those things: select NAME, MEAL, sum(TOTAL) as TOTAL from MyTABLE group by NAME, MEAL
What you're looking for is an AGGREGATE function (sum, min, max, etc)...
Re: SQL Query to get sum of same invoice numbers ...
Originally Posted by techgnome
you select the SUM() of what ever field(s) you want to sum up.... and GROUP BY the rest of the fields...
so if I have a table with NAME, MEAL, TOTAL and I want to see the sum of everything I bought: select NAME, sum(TOTAL) as TOTAL from MyTABLE group by NAME
If I want to see the sum of all the different things, broken out by those things: select NAME, MEAL, sum(TOTAL) as TOTAL from MyTABLE group by NAME, MEAL
What you're looking for is an AGGREGATE function (sum, min, max, etc)...