I want to select the last 5 records from a table in SQL Server without arranging the table in ascending or descending order.
In SQL Server, it does not seem possible without using ordering in the query. This is what I have used.
SELECT * FROM ( SELECT TOP 5 * FROM [MyTable] ORDER BY Id DESC /*Primary Key*/ ) AS T ORDER BY T.Id ASC; /*Primary Key*/