I get this error:
Msg 147, Level 15, State 1, Line 3
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
The following code can be correct if only one student has the max grant:
select top (1) name
from student s
order by grant desc;
if you have two or more student with the same grant, you should write as below:
select * from
(
select
id,
name,
Dens_Rank() over (order by grant desc) student_rank
)temp where temp.student_rank=1