Need some small help with some SQL. I am using a VARCHAR value to determine in a case which logic to use in WHERE clause but I am having some issues writing this case statement.
where
(CASE WHEN @p_flag = 'ATA'
THEN (@p_start_ata IS NULL AND @p_end_ata IS NULL) OR (vso.poa_ata between @p_start_ata and @p_end_ata)
ELSE (@p_start_atd IS NULL AND @p_end_atd IS NULL) OR (vso.pol_atd between @p_start_atd and @p_end_atd)
)
Line 93 Incorrect syntax near the keyword ‘IS’.
Its probably a minor error but its frustrating me. Maybe there is a better way of writing this? Thanks!
Like said before you can not use a case statement like you are doing it. So this might be a suggestion: