Say I have
SalesManagerId, SaleAmount, ProductId
I want to summarize the SaleAmount for each ( SalesManagerId , ProductId ) and grab the ProductId with the maximum value of sum(SaleAmount) .
Is this possible in a single request?
Example:
1, 100, 1 1, 200, 1 1, 600, 1 1, 400, 2 2, 100, 3 3, 100, 4 3, 100, 4 2, 500, 6 3, 100, 5
result:
1, 900, 1 2, 500, 6 3, 200, 4
sql tsql
Monogonator
source share