fbpx

Write a SQL query to display alternate records from a table?

VijayaTech Labs Blog
Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
For even rows:

SELECT *
FROM (SELECT e.*,MOD(ROWNUM,2) rn FROM employees E)
WHERE rn =0;

For odd rows:

SELECT *
FROM (SELECT e.*,MOD(ROWNUM,2) rn FROM employees E)
WHERE rn =1;

Share this post with your friends

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on skype
Share on telegram
Share on whatsapp
Share on email

Leave a Comment

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

Scroll to Top