0

I would like to use a case when to finished an 'in' statement, something like:

Select * from table where date in (case when table.comp = 'LPC' then '01/10','01/07' else '01/10' end) 

So that if the company is LCP I will pull out all records where the date is either 01/10 or 01/07 and any other I just get the records where date is 01/10. The statement doesn't work and the error is at :

then '01/10','01/07'

Is the a way of getting an 'in' statement to work with a select case?

Matt Bartlett
  • 348
  • 1
  • 3
  • 21

1 Answers1

0

So that if the company is LCP I will pull out all records where the date is either 01/10 or 01/07 and any other I just get the records where date is 01/10.

The following expression is a concise (and syntactically valid) way to do what you want:

where date = '01/10' or (table.comp = 'LPC' and date = '01/07')
GMB
  • 216,147
  • 25
  • 84
  • 135