I have a fact table that contains sick leave values for employees (Table 1) and I need to slot each value into one of the bands (Table 2)
The problem is that the fact table contains some negative values that represent non-numeric bands. Those values are -6666,-7777,-8888,-9999 and I can't use a between operator for them because they'll also be picked up in the first band in Table 2.
Is it possible to use a case statement to change the operator for those values? Something like this:
SELECT * FROM SickLeave lv
INNER JOIN SickLeaveBands lb
ON
CASE WHEN lb.SickLeave in (-6666,-7777,-8888, -9999)
THEN lb.SickLeave = MinHours
ELSE lb.SickLeave BETWEEN MinHours AND MaxHours
END
I was able to get around this by joining using a union query for the right side of the join, but is there a simpler solution that also avoids using dynamic sql?

