Interface , Abstract Class , SQL performance , Query optimization , Select nth record using 3 different ways
Anónimo
These are the basic questions asked in every interview from 2+ experienced guys. Answer to Select nth record using different ways: way1: WITH myTableWithRows AS ( SELECT (ROW_NUMBER() OVER (ORDER BY AddressLine1)) as row,* FROM Person.Address ) SELECT * FROM myTableWithRows WHERE row = n Pass the value of n to find nth row. way2: SELECT TOP 1 * FROM (SELECT TOP 200 * FROM Person.Address ORDER BY AddressID ASC) AS T ORDER BY T.AddressID DESC;