1.How to fetch alternate records from a table.Like Even /Odd Records.
Even Record :-
select * from (select rownum rn,employee_id,last_name from employees order by rn) where mod(rn,2)=0
RN EMPLOYEE_ID LAST_NAME
---------- ----------- -------------------------
2 199 Grant
4 201 Hartstein
6 203 Mavris
8 205 Higgins
10 100 King
12 102 De Haan
14 104 Ernst
16 106 Pataballa
18 108 Greenberg
20 110 Chen
22 112 Urman
Odd Record
select * from (select rownum rn,employee_id,last_name from employees order by rn) where mod(rn,2)!=0
RN EMPLOYEE_ID LAST_NAME
---------- ----------- -------------------------
1 198 OConnell
3 200 Whalen
5 202 Fay
7 204 Baer
9 206 Gietz
11 101 Kochhar
13 103 Hunold
15 105 Austin
17 107 Lorentz
19 109 Faviet
21 111 Sciarra
Even Record :-
select * from (select rownum rn,employee_id,last_name from employees order by rn) where mod(rn,2)=0
RN EMPLOYEE_ID LAST_NAME
---------- ----------- -------------------------
2 199 Grant
4 201 Hartstein
6 203 Mavris
8 205 Higgins
10 100 King
12 102 De Haan
14 104 Ernst
16 106 Pataballa
18 108 Greenberg
20 110 Chen
22 112 Urman
Odd Record
select * from (select rownum rn,employee_id,last_name from employees order by rn) where mod(rn,2)!=0
RN EMPLOYEE_ID LAST_NAME
---------- ----------- -------------------------
1 198 OConnell
3 200 Whalen
5 202 Fay
7 204 Baer
9 206 Gietz
11 101 Kochhar
13 103 Hunold
15 105 Austin
17 107 Lorentz
19 109 Faviet
21 111 Sciarra
0 comments:
Post a Comment