Home > Software design >  Using Array in Case Statement SQL
Using Array in Case Statement SQL

Time:12-28

I have been trying to make the below code work:

SELECT [Cell Name]
FROM ******* 

WHERE 

   [Date of maturity year] = (CASE
                             WHEN [Inforce date month] = 12 THEN [Inforce date year]   1
                             ELSE [Inforce date year]
                             END)                   
And [Date of maturity month] in (7,8,9) 

This is currently working but I want to make the second where condition dynamic. I have tried to use the Case statement, but it doesn't work.

[Date of maturity month] in (CASE
                             WHEN [Inforce date month] = 12 THEN (1,2,3)
                             WHEN [Inforce date month] = 3 THEN (4,5,6)
                             WHEN [Inforce date month] = 6 THEN (7,8,9)
                             ELSE (10,11,12)
                             END)

Can someone help me fix this.

CodePudding user response:

[Date of maturity month] - [Inforce date month] % 12 between 1 and 3
  • Related