请问大家,如何对oracle子查询出来的结果进行判断,例如,
select p.* from user p where (select count(*) from user q group by q.class)>2;
就是如何对红色区域进行判断,我写的>2会报错,因为返回的是多个结果,所以大于2肯定不对,大家有什么解决方法?谢谢!
select p.* from user p where (select count(*) from user q group by q.class)>2;
就是如何对红色区域进行判断,我写的>2会报错,因为返回的是多个结果,所以大于2肯定不对,大家有什么解决方法?谢谢!
解决方案 »
- 如何实现以下查询结果-结贴两次,双倍给分
- long raw ;如何在存储过程里 进行 insert?
- 为什么我的建的表字段是char却只能插入数字
- 处理大字段时遇到问题:UTL_RAW.CAST_TO_RAW 提示 ora-06553: pls-306 "wrong number or types of arguments in call to ,请高人指点1,
- 如何设置ORACLE数据库的编码(ZHS16GBK)修改成UTF-8
- 学Oracle该怎么入手?
- 请教oracle的最佳存储容量
- 为什么我电脑不能装ORACLE呢?
- 请问有没有人成功安装过scounix5.05+oracle8.1.7的,高手解答!!!
- oracle 11gr2安装时如何才能选择下面的rac
- oracle 问题
- Oracle 行转列、列转行的问题
select p.* from user p where exists (select q.class,count(*) from user q where q.class=p.class group by q.class having count(*)>2)
select t.* from peopleexaminfo t where t.healthsn in (select p.healthsn from peopleexaminfo p where
(select count(*) from peopleexaminfo x where x.result=1 group by x.healthsn having count(*)>2))
你那语句有几个地方都有语法错误
1.你的group by 分组了,但是你的查询字段里没有
select x.healthsn,count(*) from peopleexaminfo x where x.result=1 group by x.healthsn having count(*)>2
2.你的这个红色区域的子查询和外层有什么关系呢?不然你用where有什么作用?
应该是select count(*) from (select count(*) t from peopleexaminfo x where x.result=1 group by x.healthsn ) t where t>2
p.healthsn=x.healthsn and
(select count(*) from peopleexaminfo x where x.result=1 group by x.healthsn having count(*)>2))
好像应该加上这部分
要不你可以试验下,
你可以假想下,如果你按id分组了,现在id有1和2,按照count(1)统计,统计分别为4,5.
你说就依照select count(1) from table group by id;
你说oracle 怎么显示呢?