I'm having a problem with the below script and I don't even know if this is possible. I would like to insert a case statement within my where clause to control rates but have received this error when I fire off the sql:
invalid relational operator (its pointing to 'THEN' in my case statement).
Can someone point out where I've gone wrong. THANKS!!!
SELECT X.TOTAL_COVRG_RATE
FROM PS_RATE_SCHED_COVG X
WHERE X.RATE_SCHEDULE_ID = (CASE WHEN 'LTD1' THEN 'LTD1'
WHEN 'LTD2' THEN 'LTD1'
WHEN 'LTDF' THEN 'LTDF'
WHEN 'LTDG' THEN 'LTDF'
END)
AND X.PLAN_TYPE = '31'
AND X.EFFDT = (SELECT MAX(XX.EFFDT)
FROM PS_RATE_SCHED_COVG XX
WHERE XX.RATE_SCHEDULE_ID = X.RATE_SCHEDULE_ID
AND XX.PLAN_TYPE = X.PLAN_TYPE
AND XX.EFFDT <= GETDATE()))
invalid relational operator (its pointing to 'THEN' in my case statement).
Can someone point out where I've gone wrong. THANKS!!!
SELECT X.TOTAL_COVRG_RATE
FROM PS_RATE_SCHED_COVG X
WHERE X.RATE_SCHEDULE_ID = (CASE WHEN 'LTD1' THEN 'LTD1'
WHEN 'LTD2' THEN 'LTD1'
WHEN 'LTDF' THEN 'LTDF'
WHEN 'LTDG' THEN 'LTDF'
END)
AND X.PLAN_TYPE = '31'
AND X.EFFDT = (SELECT MAX(XX.EFFDT)
FROM PS_RATE_SCHED_COVG XX
WHERE XX.RATE_SCHEDULE_ID = X.RATE_SCHEDULE_ID
AND XX.PLAN_TYPE = X.PLAN_TYPE
AND XX.EFFDT <= GETDATE()))