如何编写嵌套查询?

时间:2010-09-20 09:46:01

标签: oracle

我需要显示特定名称的当前状态计数

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

此查询返回整个当前计数。我该怎么做才能获得特定名称的状态?

3 个答案:

答案 0 :(得分:2)

你是说这个意思吗?

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

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

答案 1 :(得分:0)

试试这个:

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

分享并享受。

答案 2 :(得分:-1)

从员工中选择count(1),其中status ='Present'group by name