select t.* from tlw_vwratifylog t where t.flowsn='7183800'
and t.RatiID >= (select min(a.RatiID) from tlw_vwratifylog a where a.StepName='收件' )
可以,但是:
select t.* from tlw_vwratifylog t where t.flowsn='7183800'
and t.RatiID >= (select max(a.RatiID) from tlw_vwratifylog a where a.StepName='收件' )
就没有数据,why?
and t.RatiID >= (select min(a.RatiID) from tlw_vwratifylog a where a.StepName='收件' )
可以,但是:
select t.* from tlw_vwratifylog t where t.flowsn='7183800'
and t.RatiID >= (select max(a.RatiID) from tlw_vwratifylog a where a.StepName='收件' )
就没有数据,why?
解决方案 »
- tomcat上发布项目报ORA-12505, TNS:listener does not currently know of SID given in conn
- oracle数据类型转换
- 请教查询中去掉不一样的时间格式
- 在线等:如何在创建游标的select语句中使用变量
- 如果在jsp中实现oracle事务。
- 如何取出两个时间间隔范围内的时间
- 安装oracle后修改了机器名称,OracleOraHome92TNSListener服务起不来,不将名称改回去,需要修改哪些文件?
- 如何从表中随机选择一条记录?
- 如何实现oracle中表和主键索引分别存放于不同的表空间
- win2000 server family 在安装Oracle8.1.6时出错!
- 上传一个非常详细的Oracle10G在IBMAIX5L上的安装步骤与大家分享
- 有没有直接在web页面查询表的控件?
select t.* from tlw_vwratifylog t where t.flowsn='7183800' and t.RatiID= max(a.RatiID) and StepName='收件'
同时三个条件都要满足才能有数据!第一个句子只是满足两个条件:
select t.* from tlw_vwratifylog t where t.flowsn='7183800' and StepName='收件'
ID USER_NAME USER_REAL_NAME PWD DEPARTMENT_ID COMPANY_ID STATUS LOGIN GROUP_ID
1 1 admin 超级系统管理员 ?g?g5b4W4W^ @D%3 1 1 1 1 1
2 2 test 测试用 ?g`+c_JLcl+#>G%3 1 1 1 0 1
3 3 lijian lijian 7m`+?gMK)%S1S_[# 1 1 1 1 1
4 4 aaaa admin :s7m/p@Xclcl--JI 1 1 1 1 1
5 6 aaa a b)?g?gF<<Pb;--U( 13 2 1 0 1
6 7 bbb weihu 8/0x?g)%2A+#GE0X 15 2 1 0 1
7 8 lwf 1 ?g?f?dP\6DH=>G-- 2 1 1 0 1
8 9 cxyh 查询帐户 ?g?f?dH?GZH=(84N 2 1 1 0 1
9 10 szyh 设置用户 ?g?f?dBVO>?#8?LP 2 1 1 0 1
10 11 tjyh 添加用户 ;a?f?dR28}6)[#HY 2 1 1 0 1 我按照你的格式在我的表中写了个结构一样的语句:
预期目的查出状态为1,并且ID >= 比部门号为1的最大ID,结果应该为0条记录
select * from userinfo t where t.status='1' and t.id >= (select max(id) from userinfo a where a.department_id= '1')
运行后结果与预期不一致ID USER_NAME USER_REAL_NAME PWD DEPARTMENT_ID COMPANY_ID STATUS LOGIN GROUP_ID
4 aaaa admin :s7m/p@Xclcl--JI 1 1 1 1 1
6 aaa a b)?g?gF<<Pb;--U( 13 2 1 0 1
7 bbb weihu 8/0x?g)%2A+#GE0X 15 2 1 0 1
8 lwf 1 ?g?f?dP\6DH=>G-- 2 1 1 0 1
9 cxyh 查询帐户 ?g?f?dH?GZH=(84N 2 1 1 0 1
10 szyh 设置用户 ?g?f?dBVO>?#8?LP 2 1 1 0 1
11 tjyh 添加用户 ;a?f?dR28}6)[#HY 2 1 1 0 1
同样select * from userinfo t where t.status='1' and t.id >= (select min(id) from userinfo a where a.department_id= '1')
希望结果是4条记录
实际是 全部记录此语句实际就2个条件 t.status='1' and t,id >=后面查出来的数值
你可以把你的子查询语句select max(a.RatiID) from tlw_vwratifylog a where a.StepName='收件'
到底是怎样的值取到,在和前面的主句对照,这样问题就简单了