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
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
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 这么写也可以。
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
没看清题意试试: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
from t_parent p, t_child c
where p.dep_id = c.dep_id(+)
and 25 < c.age(+)
group by p.dep_name
这么写也可以。