Subject | The greater/lesser of a number of values |
---|---|
Author | ai_no_kareshi |
Post date | 2008-01-28T13:06:40Z |
Does Firebird provide functions for determining the greater/lesser of
two or more values?
For instance, I have a table that stores three ratings per candidate.
What I want is to calculate, for each record, the difference between
the largest of the three ratings and the smallest of the three ratings.
Suppose there were functions like these and they were called MAX_VAL
and MIN_VAL, my query would look something like this:
SELECT MAX_VAL(Rating1, Rating2, Rating3) - MIN_VAL(Rating1, Rating2,
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.
two or more values?
For instance, I have a table that stores three ratings per candidate.
What I want is to calculate, for each record, the difference between
the largest of the three ratings and the smallest of the three ratings.
Suppose there were functions like these and they were called MAX_VAL
and MIN_VAL, my query would look something like this:
SELECT MAX_VAL(Rating1, Rating2, Rating3) - MIN_VAL(Rating1, Rating2,
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.