Friday, July 10, 2015

Selecting ODD or EVEN rows from a table

NOTE: only '<' can be used with rownum.

Query for even number of rows

select a.* from (select mod(rownum,2) k,m.* from mtl_system_items_b m where rownum<5 a.k="0;<br" a="" where="">
Query for odd number of rows

select a.* from (select mod(rownum,2) k,m.* from mtl_system_items_b m where rownum<5 a.k="0;<br" a="" where="">

No comments:

Post a Comment