我创建了一个可以工作的案例子查询,但是我确定必须有一个更简单的方法来做到这一点?有没有更好的方法来创建此案例查询
查询的目的是当billgrp_desc像'30%',然后从tbm.billgrp表中显示billgrp_desc。从hbm.matter表
否则显示matter_code时billgrp_desc不喜欢'30%”
查询低于:
select
case
when bllgrp_desc like '30%' then 'billgrp_desc'
end
from tbm.billgrp
union
select
case
when exists (select billgrp_desc
from tbm.billgrp
where billgrp_desc not like '30%') then 'matter_code'
end
from hbm.matter
一个字段是这只是一个大的查询的一部分吗?如果是的话,最好提供完整的查询。 –