I have the following MS SQL Query
select top 10 RegisterTime
from orderNotifications
order by RegisterTime asc
How can I get the max RegisterTime
of that query ?
I have tried this
select max(RegisterTime) in (
select top 10 RegisterTime
from orderNotifications
order by RegisterTime asc
)
But I am getting
Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'in'.
Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'order'.
Make your TOP 10
query a subquery:
SELECT MAX(RegisterTime)
FROM (SELECT TOP 10 RegisterTime
FROM orderNotifications
ORDER BY RegisterTime
)sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With