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 数据表中数据分开???
- oracle8.0.5的备份(EXP80方式),还原到oracle9i中(IMP80方式),会有什么问题么?
- 新手上路!在xp下安装oracle9i的问题!
- 请问如何解决缓clob/blob冲区太小这个问题?
- export的问题
- oracle9i的数据恢复问题
- 一个ORACLE的数据导出问题
- 求助……
- 一个DBMS_PIPE的问题?
- 一个关于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;
看来我只好给自己加分了!