scott@oracle> select rownum rn, empno, ename from emp;
RN EMPNO ENAME
---------- ---------- ----------
1 7369 SMITH
2 7499 ALLEN
3 7521 WARD
4 7566 JONES
5 7654 MARTIN
6 7698 BLAKE
7 7782 CLARK
8 7788 SCOTT
9 7839 KING
10 7844 TURNER
11 7876 ADAMS
12 7900 JAMES
13 7902 FORD
14 7934 MILLER
14 rows selected.
scott@oracle> select rn, empno, ename from
2 ( select empno, ename, rownum rn from emp )
3 where mod(rn,2)=1;
RN EMPNO ENAME
---------- ---------- ----------
1 7369 SMITH
3 7521 WARD
5 7654 MARTIN
7 7782 CLARK
9 7839 KING
11 7876 ADAMS
13 7902 FORD
Base on Ales solution if we insert one new row,
So what will be the result? Please see below and correct me. Thanks
scott@oracle> select rownum rn, empno, ename from emp;
RN EMPNO ENAME
---------- ---------- ----------
1 7369 SMITH
2 7499 ALLEN
3 7521 WARD
4 7566 JONES
5 7654 MARTIN
6 7698 BLAKE
7 7782 CLARK
8 7788 SCOTT
9 7839 KING
10 7844 TURNER
11 7876 ADAMS
12 7900 JAMES
13 7902 FORD
14 7934 MILLER
15 6666 XYZ (new row)
15 rows selected.
scott@oracle> select rn, empno, ename from
2 ( select empno, ename, rownum rn from emp )
3 where mod(rn,2)=1;
RN EMPNO ENAME
---------- ---------- ----------
1 7369 SMITH
3 7521 WARD
5 7654 MARTIN
7 7782 CLARK
9 7839 KING
11 7876 ADAMS
13 7902 FORD
15 6666 XYZ (new row)
8 rows selected.
Bookmarks