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(1) returns null in group by

793965Nov 23 2012 — edited Nov 23 2012
hi gems..good afternoon..

I read that the COUNT() function always returns 0 (zero) if there is no matching rows in the table.

The following code returns the 0 as expected:
SELECT COUNT(1) FROM book_table
             WHERE client_id = 10009
               AND book_id = 5465465
               AND book_sub_id = 'gfdf'
               AND amount = 78686
But when I used the GROUP BY clause with the query, then it returned nothing:
SELECT COUNT(1) FROM book_table
             WHERE client_id = 10009
               AND book_id = 5465465
               AND book_sub_id = 'gfdf'
               AND amount = 78686
group by client_id,book_id,book_sub_id,amount
Why this is happening..please suggest...
This post has been answered by BluShadow on Nov 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2012
Added on Nov 23 2012
8 comments
2,280 views