I've got a db - that tracks customers and sales numbers. Each customer may have multiple sales, and thus, multiple entries:
sales
id | Name | Amount
1 John 500
2 Mark 500
3 Luke 100
4 John 200
I run a query on this table that sums the amounts and groups by name so its results:
John 700
Mark 500
Luke 100
And then I run a seperate query that sums all of the sales to give me
1300
Surely there is a way to do all of this with just one query - but it's elluding me.
sales
id | Name | Amount
1 John 500
2 Mark 500
3 Luke 100
4 John 200
I run a query on this table that sums the amounts and groups by name so its results:
John 700
Mark 500
Luke 100
And then I run a seperate query that sums all of the sales to give me
1300
Surely there is a way to do all of this with just one query - but it's elluding me.