sumithra
sumithra

Reputation: 1

How to write nested query?

I need to display the count of present status for a particular name

Select count(*) from employees where status='Present';

This query returns me entire present count. What should I do to get status for a particular name?

Upvotes: 0

Views: 394

Answers (3)

Try this:

select name, count(*)
  from employees
  where name = 'abc' and
        status = 'Present';

Share and enjoy.

Upvotes: 0

user435076
user435076

Reputation: 1

select count(1) from employees where status='Present' group by name

Upvotes: -1

JohnoBoy
JohnoBoy

Reputation: 565

Do you mean this?

select status, count(*)
from   employees
group by status

Or

select name, count(*)
from   employees
where status = 'Present'
group by name

Upvotes: 2

Related Questions