I want to select rows with max vallues from the following select, but result table name is wrong in subquery (select max(result.Sum) from result):
select *
from 
(select sum(Rooms.n_seats) as 'Sum', DepKinds.title
from Rooms join Departments on Rooms.department = Departments.id
join DepKinds on Departments.kind = DepKinds.id group by DepKinds.title) result where result.Sum = (select max(result.Sum) from result);
So how to select maximum sum and title for those sums?

