在 CASE WHEN THEN ELSE 中使用 IN 和逗号
using IN and comma in a CASE WHEN THEN ELSE
我想在 IN 语句中使用 'CASE WHEN THEN ElSE'。但它不像你在下面看到的那样工作。
join notes n
on n.note_id=cp.note_id
and n.stamp_dat>=@date_from
and n.stdnote_code in(case when @country='NO'
then ('81','82','84','85','86','90','91')
else ('86','87') end)
and
(
@country ='NO' and n.stdnote_code in ('81','82','84','85','86','90','91')
OR
@country<>'NO' and n.stdnote_code in ('86','87')
)
join notes n
on n.note_id=cp.note_id
and n.stamp_dat>=@date_from
AND
(
(n.stdnote_code IN ('81','82','84','85','86','90','91') AND @country='NO')
OR
(n.stdnote_code IN ('86','87') AND @country <> 'NO')
)
我想在 IN 语句中使用 'CASE WHEN THEN ElSE'。但它不像你在下面看到的那样工作。
join notes n
on n.note_id=cp.note_id
and n.stamp_dat>=@date_from
and n.stdnote_code in(case when @country='NO'
then ('81','82','84','85','86','90','91')
else ('86','87') end)
and
(
@country ='NO' and n.stdnote_code in ('81','82','84','85','86','90','91')
OR
@country<>'NO' and n.stdnote_code in ('86','87')
)
join notes n
on n.note_id=cp.note_id
and n.stamp_dat>=@date_from
AND
(
(n.stdnote_code IN ('81','82','84','85','86','90','91') AND @country='NO')
OR
(n.stdnote_code IN ('86','87') AND @country <> 'NO')
)