Subject RE: [firebird-support] The greater/lesser of a number of values
Author Sasha Matijasic
>
> Does Firebird provide functions for determining the greater/lesser of
> two or more values?
>
No. Version 2.1 will introduce these functions, maxvalue and minvalue.

>
> If there aren't any functions like these, I would appreciate it if
> someone could suggest a different approach to solving this problem.
>

You can solve this by writing and UDF function that will take 3 arguments
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