How to display only Even numbered rows from a table?

— Fetching only Even numbered rows.

SELECT [Even].[BusinessEntityID], [Even].[PhoneNumber],
              [Even].[PhoneNumberTypeID], [Even].[ModifiedDate]
                        SELECT [BusinessEntityID], [PhoneNumber],
   Row_Number() OVER(ORDER BY [BusinessEntityID]) AS RN
                                           FROM [Person].[PersonPhone]
) AS [Even]
WHERE [Even].RN % 2 = 0


  • For fetching ODD rows, just replace RN % 2 = 0 with RN % 2 = 1.
  • We can also achieve this by creating a CTE with the sub query above.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.