Subject | Re: [firebird-support] The greater/lesser of a number of values |
---|---|
Author | Ivan Prenosil |
Post date | 2008-01-31T21:51:51Z |
> SELECT MAX_VAL(Rating1, Rating2, Rating3) - MIN_VAL(Rating1, Rating2,SELECT
> Rating3) AS RatingDiff
> FROM Candidate
>
> If there aren't any functions like these, I would appreciate it if
> someone could suggest a different approach to solving this problem.
CASE WHEN Rating1>Rating2 AND Rating1>Rating3 THEN Rating1 WHEN Rating2>Rating3 THEN Rating2 ELSE Rating3 END -
CASE WHEN Rating1<Rating2 AND Rating1<Rating3 THEN Rating1 WHEN Rating2<Rating3 THEN Rating2 ELSE Rating3 END as RatingDiff
FROM Candidate
Ivan
http://www.volny.cz/iprenosil/interbase/