select * from c where c.col in (select decode(c2,c1,'1',c3,'3','2') from
(select count(*) c1 from b) a,
(select count(*) c2 from b where col is not null) b,
(select count(*) c3 from b where col is null) c )
//b为a查出来的结果集
such as select * from a where sex='M'
(select count(*) c1 from b) a,
(select count(*) c2 from b where col is not null) b,
(select count(*) c3 from b where col is null) c )
//b为a查出来的结果集
such as select * from a where sex='M'
解决方案 »
- ORACLE图形控制界面工具那有下载
- Oracle 9i 中时间类型的赋值问题!!
- 简单问题,再线等
- 数据备份得问题 可能很简单
- 高分急:怎么在pro*c中执行一条保存在数据库中的sql语句
- 在window 2000 professional 下,为什么不能shutdown Oracle数据库
- 主键和外键的问题
- 如何关闭并开启Oracle 9i的本地服务?
- 求帮助 PL/SQL developer 点击Tables文件夹显示ora 00936
- 两个表各自排序后再按权重合并后排序问题?求指点,谢谢
- 把这10分加上:oracle805的客户端可以连接oracle816的服务器么?如果可以,分别在服务器端和客户端如何设置啊
- 高分求一条sql语句关于子查询
先从表A查找出结果集B,再根据结果集B的情况,比如说字段a全部都有值则得出1,部分有值则得出2,一个值都没则得出3,将值付给变量y,再根据y到另一表C中查找数据,请问这样能在一个SQL语句里面完成吗?如何写?关键是这个变量如何写进去
我上边的加个注释你就明白了
select * from c where c.col in (
//下面的只得到一个值,它作为查询c的条件
select decode(c2,c1,'1',c3,'3','2') from //如果不空的=总数得1 全空的 3 部分 2
(select count(*) c1 from b) a, //共有多少条
(select count(*) c2 from b where col is not null) b, //不空的多少条
(select count(*) c3 from b where col is null) c //孔的多少条
)
//b为a查出来的结果集
such as select * from a where sex='M'
注:对结果集可以相对表一样查询的
所以先从表A查找出结果集B,再根据结果集B的情况就没用了
你可以把具体的表名列名给我,我给你写出来
肯定对的