以下是用于根据特定条件检索记录的查询。当我单独使用查询时,我得到了结果,但是当我添加一个联合时,它给了我错误,因为命令没有正确结束。
select ltrim(rtrim(LV_ID)) || '|' || ltrim(rtrim(EXPS_TYP_CD)) || '|'
from sysadm.OM_CDM_PC_HNDSHAKE
where ltrim(rtrim(PROC_ID)) in 'B3_HNDSHK_OTC' and RUN_ID = 'ME-BD10'
and FISCAL_YEAR=2012 and ACCOUNTING_PERIOD=8 and BUS_DAY_NO=10
and ltrim(rtrim(LV_ID)) not in (' ','0','002','BEAD0')
order by ltrim(rtrim(LV_ID)) || '|' || ltrim(rtrim(EXPS_TYP_CD)) || '|'
union
select ltrim(rtrim(LV_ID)) || '|' || ltrim(rtrim(EXPS_TYP_CD)) || '|'
from sysadm.OM_CDM_PC_HNDSHAKE
where ltrim(rtrim(PROC_ID)) in 'B3_HNDSHK_OTC' and RUN_ID = 'ME-BD10'
and FISCAL_YEAR=2012 and ACCOUNTING_PERIOD=8 and BUS_DAY_NO=10
and ltrim(rtrim(LV_ID)) is null
order by ltrim(rtrim(LV_ID)) || '|' || ltrim(rtrim(EXPS_TYP_CD)) || '|'