Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

count(*) fails while using 12c feature (offset)

Most Wanted!!!!Apr 17 2018 — edited Apr 18 2018

Dear Gurus ,

     Need your guidance , Count(*) fails while using "offset" (12C) ,I understand we give no of rows when using offset (eg: offset 0 rows fetch next 5 rows(here count is 5 but shows null ))  but when using fetch first I get  total record count (eg:fetch first 5 rows only (I get total record count in that table)),

EMPNOENAMEJOBMGRHIREDATESALCOMMDEPTNO
7839KINGPRESIDENT 17-NOV-19815000 10
7698BLAKEMANAGER783901-MAY-19812850 30
7782CLARKMANAGER783909-JUN-19812450 10
7566JONESMANAGER783902-APR-19812975 20
7788SCOTTANALYST756609-DEC-19823000 20
7902FORDANALYST756603-DEC-19813000 20
7369SMITHCLERK790217-DEC-1980800 20
7499ALLENSALESMAN769820-FEB-1981160030030
7521WARDSALESMAN769822-FEB-1981125050030
7654MARTINSALESMAN769828-SEP-19811250140030
7844TURNERSALESMAN769808-SEP-19811500030
7876ADAMSCLERK778812-JAN-19831100 20
7900JAMESCLERK769803-DEC-1981950 30
7934MILLERCLERK778223-JAN-19821300 10

here are the results , kindly correct me if its wrong.

Select Count(*)From Emp

/

  COUNT(*)

----------

        14

Select * From Emp Fetch First 5 Rows Only

/

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

7839 KING PRESIDENT  17-NOV-1981 5000  10

7698 BLAKE MANAGER 7839 01-MAY-1981 2850  30

7782 CLARK MANAGER 7839 09-JUN-1981 2450  10

7566 JONES MANAGER 7839 02-APR-1981 2975  20

7788 SCOTT ANALYST 7566 09-DEC-1982 3000  20

Select Count(*),Count(1),Sum(1) From Emp Fetch First 5 Rows Only

/

  COUNT(*)   COUNT(1)     SUM(1)
---------- ---------- ----------
        14         14         14

Select * From Emp Offset 5 Rows Fetch Next 5 Rows Only

/

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

7902 FORD ANALYST 7566 03-DEC-1981 3000  20

7369 SMITH CLERK 7902 17-DEC-1980 800  20

7499 ALLEN SALESMAN 7698 20-FEB-1981 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-1981 1250 500 30

7654 MARTIN SALESMAN 7698 28-SEP-1981 1250 1400 30

Select count(*), Count(1),Sum(1) From Emp A Offset 1 Rows Fetch Next 5 Rows Only

/

no rows selected

regards,

friend

This post has been answered by Solomon Yakobson on Apr 17 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 16 2018
Added on Apr 17 2018
15 comments
3,658 views