select * from (select a.*, '1' as 参数
from a
where 大于0
union all
select a.*, '0'
from a
where 等于0
) t
where 1=1
${if(len(参数)==0,"","and 参数 = ('"+参数+"')")}
neyhig(提问者) 回复 朝赟丶没有没有改了改了,select * from (select a.*,\'1\'as 拣货量 from a where 拣货量>0 union all select a.* ,\'0\'as from a where 拣货量=0)t where 1=1…这样您看有错嘛?提示未明确定义列
huyajun 回复 neyhig(提问者)with a as(select distinct i.sku 物料编码,
s.descr 物料名称,
i.id LPN,
i.qty 数量,
i.qty - i.qtyallocated - i.qtypicked 可用量,
i.qtyallocated 分配量,
i.qtypicked 拣货量,
case
when i.status = \'OK\' then
\'正常\'
else
\'冻结\'
end 库存状态,
case
when i.status = \'OK\' then
\'合格\'
when i.status = \'HOLD\' and ih.status is not null then
to_char(ihc.description)
else
to_char(ihcloc.description)
end 冻结状态
from lotxlocxid i )
select * from a
where 1=1 ${if(len(kczt)==0,\"\",\"and 库存状态=(\'\"+kczt+\"\')\")}
${if(len(jhl)==0,\"\",\"and 拣货量=(\'\"+jhl+\"\')\")}
${if(len(参数)==0,\"\",\"and case when 拣货量>0 then \'大于0\' when 拣货量=0 then \'等于0\' else \'小于0\' end =\'\"+参数+\"\'\")}