In this blog I will post all FAQs, code snippets, real time problems and solutions and any other links which I feel every one needs and can take advantage of.
Selecting alternative records in Oracle
Posted 14-10-08 at 09:49 PM by sk_kireeti
Use this logic to select alternative records from a table -
SQL> ed
Wrote file afiedt.buf
1 select * from
2 (select rownum row_num,exec_date from clob_test)
3* where mod(row_num,2)=1
SQL> /
ROW_NUM EXEC_DATE
---------- ---------
1 13-OCT-08
3 13-OCT-08
5 13-OCT-08
7 13-OCT-08
9 13-OCT-08
11 13-OCT-08
6 rows selected.
Here I am forming a new table in a sub query which translats "rownum" into a table column (it is a hidden column for which values are assigned at run-time) and then I am using that column to write my condition.
SQL> ed
Wrote file afiedt.buf
1 select * from
2 (select rownum row_num,exec_date from clob_test)
3* where mod(row_num,2)=1
SQL> /
ROW_NUM EXEC_DATE
---------- ---------
1 13-OCT-08
3 13-OCT-08
5 13-OCT-08
7 13-OCT-08
9 13-OCT-08
11 13-OCT-08
6 rows selected.
Here I am forming a new table in a sub query which translats "rownum" into a table column (it is a hidden column for which values are assigned at run-time) and then I am using that column to write my condition.
Total Comments 0
Comments
Recent Blog Entries by sk_kireeti
- Selecting alternative records in Oracle (14-10-08)
- Oracle SQL to HTML table (14-10-08)
- SQL to select middle record of a table (13-11-07)
- Query to find first and last records of a table (13-11-07)




