Max value of a groupby query
Hi,
I have this table named Sales with this data
Table: Sales
------------------
Salesman Amount
--------------------
Ben 1
Steve 2
Ben 3
then i do this query
select Salesman, sum(amount) as Total
from Sales
group by Salesman
the results are
---------------------
Salesman Amount
---------------------
Ben 4
Steve 2
The query i want is one that gives me the maximum amount of sales (4).
I have tried this, but it is wrong
select max(Total) from
(select Salesman, sum(amount) as Total
from Sales
group by Salesman)
I am using microsoft SQL Server 2005
thanks in advance!
|