这是我的代码,它没有返回任何内容,我不知道如何处理这个案例...
Select distinct u.semail email, '' blank
FROM user u inner join
group g
on u.hgroup=g.hmy
where u.binactiveuser = 0 and
u.hgroup in (case when @application = 'Test1' then (Select hmy from group where ucode like 'pay%')
else case when @application = 'Test2' then (Select hmy from group where ucode in ('cc','vente','leas'))
else case when @application = 'Voy' then (Select hmy from group where ucode not like 'pay%' and ucode not in ('cc','vente','leas'))
end
end
end)
答案 0 :(得分:0)
我认为OR会起作用......
Select distinct u.semail email, '' blank
FROM user u inner join
group g
on u.hgroup=g.hmy
where u.binactiveuser = 0 and
(
(@application = 'Test1' and u.hgroup in (select hmy from group where ucode like 'pay%'))
or
(@application = 'Test2' and u.hgroup in (Select hmy from group where ucode in ('cc','vente','leas')))
or
(@application = 'Voy' and u.hgroup in (Select hmy from group where ucode not like 'pay%' and ucode not in ('cc','vente','leas')))
)