在表TABLE中
char char char char
管理番号 输送no 出门时间 入门时间
001 0001
001 0002
管理番号和输送no为主键
现在要检索满足条件的管理番号
检索条件如下:
1.输送no + 入门时间为空
2.输送no + 出门时间不为空
同时满足条件1.2的管理番号
请问高手sql文怎么写?急!!!
char char char char
管理番号 输送no 出门时间 入门时间
001 0001
001 0002
管理番号和输送no为主键
现在要检索满足条件的管理番号
检索条件如下:
1.输送no + 入门时间为空
2.输送no + 出门时间不为空
同时满足条件1.2的管理番号
请问高手sql文怎么写?急!!!
from table
where 输送no=
and 出门时间 is not null
and 入门时间 is null
char char char char
管理番号 输送no 出门时间 入门时间
001 0001
001 0002
管理番号和输送no为主键 字段全为char型
现在要检索满足条件的管理番号
检索条件如下:
1.输送no + 入门时间为空
2.输送no-1 + 出门时间不为空
同时满足条件1.2的管理番号
请问高手sql文怎么写?急!!!
where t1.管理番号=t2.管理番号
and to_number(t1.输送no)=to_number(t2.输送no)-1
and t1.入门时间 is null and t2.出门时间 is not null
from tbname a
where 输送no= 'xxx'
and 出门时间 is not null
and exists(select 1 from tbname b where b.no=lpad(a.no-1,4,'0') and 入门时间 is null )
还有就是您能不能解释一下lpad()这个函数的作用是什么? 谢谢!!
where 输送no= 'xxx' ???