So I'm writing a procedure in PL/SQL that has the logic below:
SELECT
...
FROM
...
WHERE
CASE
WHEN travel_time IS NULL THEN NULL
WHEN travel_time = 0 THEN NULL
ELSE miles/(travel_time/60)
END >
CASE
WHEN (SUBSTR(id, 2, 3) BETWEEN '099' AND '200')
THEN 60
ELSE 45
END;
In the result set, I'm getting records where the result of the first and second case statement are both 60.
So basically, if the result of the first case statement is GREATER THAN the result of the second case statement, the record is supposed to show up, but I'm getting records that are GREATER THAN OR EQUAL TO. I'm sure I could just change the second case statement to give 61 rather than 60, and I'm sure it would work. But shouldn't this logic work without having to do that?
Thanks!
Edited by: jjmiller on Mar 26, 2010 7:24 AM