Выбрать ряд с максимальным значением из подзапроса

Использую Microsoft SQL Server Managment Studio

Вот код запроса

Select  Sections.[Section Type], Sum(Equipment.price)
FROM MRP
INNER JOIN Equipment ON Equipment.UserId=MRP.Id
INNER JOIN Sections ON MRP.[Section Type]=Sections.[Section Type]
GROUP BY Sections.[Section Type]
GO

Нужно найти ряд с максимальным элементом из

Sum(Equipment.price)

Из этого

Картинка запроса

Получить вот такое

Картинка запорса ответа


Ответы (1 шт):

Автор решения: Максим

Вот ответ


Select TOP 1 Sections.[Section Type], Sum(Equipment.price) 
FROM MRP
INNER JOIN Equipment ON Equipment.UserId=MRP.Id
INNER JOIN Sections ON MRP.[Section Type]=Sections.[Section Type]
GROUP BY Sections.[Section Type]
Order by Sum(Equipment.price) DESC
→ Ссылка