snippetsqlMinor
How can i return the max of a sum by each team?
Viewed 0 times
sumcantheeachreturnteammaxhow
Problem
I have a lot of teams and i want to know the maximum of sum total of each team.
This's my query :
Thanks.
This's my query :
SELECT campaign_id,
campaign_identifier,
team,
campaign_name,
Month(time) AS month,
Sum (total) AS Total
FROM campaign
WHERE Year(time) = Year(Now())
AND Month(time) = 12
GROUP BY campaign_identi,
teamThanks.
Solution
If am not wrong this is what you need
select team,max(Total)
from
(
SELECT team,
Sum (total) AS Total
FROM campaign
WHERE Year(time) = Year(Now())
AND Month(time) = 12
GROUP BY campaign_identi,
team
) A
Group by teamCode Snippets
select team,max(Total)
from
(
SELECT team,
Sum (total) AS Total
FROM campaign
WHERE Year(time) = Year(Now())
AND Month(time) = 12
GROUP BY campaign_identi,
team
) A
Group by teamContext
StackExchange Database Administrators Q#124193, answer score: 7
Revisions (0)
No revisions yet.