Get MAX value from TOP record number

I have the following MS SQL query

select top 10 RegisterTime
from  orderNotifications
order by RegisterTime asc

How can I get the max of RegisterTimethis request?

I tried this

select max(RegisterTime) in (
    select top 10 RegisterTime
    from  orderNotifications
    order by RegisterTime asc
)

But I get

Msg 156, Level 15, State 1, Line 1 Invalid syntax next to the keyword 'in'.

Msg 156, Level 15, State 1, Line 4 Incorrect syntax next to the keyword 'order'.

+4
source share
1 answer

TOP 10Subquery request :

SELECT MAX(RegisterTime)
FROM (SELECT TOP 10 RegisterTime
      FROM orderNotifications
      ORDER BY RegisterTime
      )sub
+9
source

All Articles