Subject | RE: [firebird-support] The greater/lesser of a number of values |
---|---|
Author | Sasha Matijasic |
Post date | 2008-01-28T13:34:33Z |
>No. Version 2.1 will introduce these functions, maxvalue and minvalue.
> Does Firebird provide functions for determining the greater/lesser of
> two or more values?
>
>You can solve this by writing and UDF function that will take 3 arguments
> If there aren't any functions like these, I would appreciate it if
> someone could suggest a different approach to solving this problem.
>
and return min or max of them or you can use something like this:
select ...
case
when rating1 > rating2 and rating1 > rating3 then rating1
when ...
end
-
case
when rating1 < rating2 and ...
when ...
end ratingdiff
from ...
Take care of cases when ratings can have the same value and of nulls. In the
end you will get some pretty ugly query but it's the easiest way to do it.
What you should really do is normalize your tables by getting rid of
repeating groups and put ratings in detail table.
Sasha