Find nth Wor from a table in SQL Server or any row from table
11:29 PM
/***************************
FIND NTH ROW FROM A TABLE IN SQL SERVER OR ANY ROW FROM TABLE
BY: MANGESH SINGH
**********************************/
DECLARE @N INT
DECLARE @COUNT INT
SET @N=1
SELECT @COUNT=COUNT(*) FROM TBLAGENTEMPLOYEE
SELECT * FROM(SELECT ROW_NUMBER() OVER (ORDER BY AGENTEMPLOYEEID DESC) AS EID,* FROM TBLAGENTEMPLOYEE) AS AGENTEMPLOYEE
WHERE EID=@COUNT-@N
/*** WHERE NTH=@N */