一般我们使用 union
select c1,c2,c3 from tb1 where XXX
nuion
select c1,c2,c3 from tb1 where XXX
一般是可以的
但是如果where 条件后面加上
order by CLAIM_TIME desc
fetch first 1 rows only
那么就会报很奇怪的错误
所以我们应该改成(外部 再嵌套一层)
select * from (
select CLAIM_TIME from MMVIEW.FHOPEHS
where OPE_CATEGORY='OperationStart' and lot_id='AE00008.04' and CLAIM_TIME<(select CLAIM_TIME from tb where num=3)
order by CLAIM_TIME desc
fetch first 1 rows only)
union
select * from (
select CLAIM_TIME from MMVIEW.FHOPEHS
where OPE_CATEGORY='OperationStart' and lot_id='AE00008.04' and CLAIM_TIME<(select CLAIM_TIME from tb where num=4)
order by CLAIM_TIME desc
fetch first 1 rows only)