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!

SQL Query with count and group by clause.

myinceptionJun 13 2013 — edited Jun 13 2013

Say I have a table with empId and First_name column with the following data:

EmpID          First_Name

===================

10                Jack

20                Harry

So suppose I write this query as

select count(1), empId from Employees

where empId = 50

group by empId;

This will give an error.

I want the count and empId to be displayed as 0 in case there is no matching data. How can I achieve the same?

EDIT

I actually need the empId and the count, using the first_name...like this way:

select count(1), empId from Employees

where First_Name= 'edward'

group by empId;

So in this case, count should be 0, and empId as null.

Message was edited by: adfSonal

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2013
Added on Jun 13 2013
9 comments
4,725 views