SQL> select a.name,count(distinct b.id),count(distinct c.id) from a,b,c where a.a_id=c.a_id and a.a
_id=b.a_id group by a.name;NAME COUNT(DISTINCTB.ID) COUNT(DISTINCTC.ID)
---------- ------------------- -------------------
li 2 1
zhang 1 2
_id=b.a_id group by a.name;NAME COUNT(DISTINCTB.ID) COUNT(DISTINCTC.ID)
---------- ------------------- -------------------
li 2 1
zhang 1 2
解决方案 »
- 问个简单的sql语句,大家快来拿分哦!
- ORACLE表权限问题
- 关于oracle字符串分割的问题
- 求自增函数
- oracle sql developer本地文件浏览器关了,找不到打开,郁闷,请指点
- 请教函数编译错误
- 求助:oracle表的复制问题(急)
- 表或视图不存在
- 请问怎么把我的一些数据导出到另外一个机器上
- 有关字符串连接??请帮忙
- 一个关于sql的小问题!急....急....急....急....急....急....急....急....
- 在ms-sql 里有这样的语句 select first 6 * from bulletin where del='1' order by issuetime desc可以运行成功,如果换成oracle该怎样替
from
(select A_ID,count(id) from b group by A_ID)x,
(select A_ID,count(id) from c group by A_ID)y,a
where x.A_ID(+)=a.A_ID and y.A_ID(+)=a.A_ID
select a.name,x.n,y.n
from
(select A_ID,count(id) n from b group by A_ID)x,
(select A_ID,count(id) n from c group by A_ID)y,a
where x.A_ID(+)=a.A_ID and y.A_ID(+)=a.A_ID
我没有试,你试试吧
select a.name,count(distinct b.id),count(distinct c.id) from a,b,c where a.a_id=c.a_id and a.a_id=b.a_id group by a.name;
看来我只好给自己加分了!