Selecting the Top Records from the SQL Server without using the TOP keyword

We would like to use the CTE for this purpose.

Consider the following  table Emp :

1. Column : Empname varchar(30)
2. Column : CreateDdate datetime

WITH CTE AS (
    SELECT Empname , rowno = row_number() OVER(ORDER BY CreateDdate )
    FROM Emp 
 )
 SELECT *
 FROM   CTE
 WHERE  rowno BETWEEN 1 AND 5

This way we can use the CTE for selecting the Top keywords.

Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all