sql server fetch first n rows of field Maximization

Examples of the first three lines take the maximum ID

select MAX(A.ID) from (select top 3 ID from Students)AS A

Written and is given ID maximum value for the entire table, not the value of what we need

To join in the sentence order by ID

select MAX(A.ID) from (select top 3 ID from Students order by ID  ) as A

But can not order by ID desc, descending can not get the results.

Also know why, please advice.

 

Guess you like

Origin www.cnblogs.com/ylancf/p/11008974.html
Recommended