Q
Problem solve Get help with specific problems with your technologies, process and projects.

Getting alternate rows from a table

How can I get alternane rows (records) from a table? Or, how can I get the 1st, 3rd, 5th... 91st, 97th rows or records from a table?

Suppose T is your table. The way to get your alternate rows is to use the in-line view technique like this:

select a.* from
(select rownum as row_num,T.*
  from T) a
where mod (a.row_num,2) = 1;

For More Information


Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close