Sample data
+----+------------+-------+------------+
| ID | first_name | sales | sale_date |
+----+------------+-------+------------+
| 1 | Lindsey | 32.02 | 2007-03-12 |
| 2 | Nicole | 26.53 | 2007-03-12 |
| 3 | Britney | 11.25 | 2007-03-12 |
| 4 | Ashley | 18.96 | 2007-03-12 |
| 5 | Lindsey | 9.16 | 2007-03-11 |
| 6 | Nicole | 1.52 | 2007-03-11 |
| 7 | Britney | 43.21 | 2007-03-11 |
| 8 | Ashley | 8.05 | 2007-03-11 |
| 9 | Lindsey | 17.62 | 2007-03-10 |
| 10 | Nicole | 24.19 | 2007-03-10 |
| 11 | Britney | 3.40 | 2007-03-10 |
| 12 | Ashley | 15.21 | 2007-03-10 |
| 13 | Lindsey | 0.00 | 2007-03-09 |
| 14 | Nicole | 31.99 | 2007-03-09 |
+----+------------+-------+------------+
I try to find biggest total sales produce by any of this girl
I can find the biggest total sales by using this query
select first_name, sum(sales) as total
from cookie_sales
group by first_name
order by total desc limit 1;
I wonder is there a way to find same value using aggregate max
function
If i using something like this
select first_name, max(sum(sales)) from cookie_sales group by first_name;
I will get 1111 Mysql error (Invalid use of group function )
Is there a way?