0

I would like to use a 'CASE WHEN THEN ElSE' in a IN statement. But it does not work like you se it below.

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)
Zeb
  • 21
  • 8

2 Answers2

1
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')
)
ASh
  • 34,632
  • 9
  • 60
  • 82
0
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')
             )
M.Ali
  • 67,945
  • 13
  • 101
  • 127