select p.dep_name,count(*) 25岁以上人数 
from t_parent p,t_child c
where p.dep_id = c.dep_id
  and c.age > 25
group by p.dep_name

解决方案 »

  1.   

    select p.dep_name,count(*) 25岁以上人数 
    from t_parent p,t_child c
    where p.dep_id = c.dep_id(+)
      and c.age > 25
    group by p.dep_name
    这个方法无法显示 市场部 0这样的信息,因为c.age为NULL
      

  2.   

    sorry!
    没看清题意试试:select p.dep_name,sum(decode(a.dep_id,null,0,1))
    from t_parent p,(select * from t_child c where c.age > 25) a
    where p.dep_id = a.dep_id(+)
    group by p.dep_name
      

  3.   

    select p.dep_name, count(c.age) agecnt
    from   t_parent p, t_child c
    where  p.dep_id = c.dep_id(+)
      and  25 < c.age(+)
    group  by p.dep_name
    这么写也可以。
      

  4.   

    cyberflying(雁南飞) 的比较好!