I have a table, lets call it TempAccount, with a column named AccountID. It contains numbers from 1,2,3...and so on.
My requirement is that I should select the maximum value from the top 10 AccountIDs.
I know I can do it by creating a temp table and inserting the top 10 values in it and then select the maximum value out of that table. But I was hoping if there is any direct query I can use to achieve this.
MAX(SELECT TOP 10 AccountID FROM TempAccount)
What is the best way I can achieve this?
Note: I am using SQL Server 2012