Subject | aggregating different field suggestion? |
---|---|
Author | Adam |
Post date | 2005-02-03T00:31:48Z |
Hello all,
I have never had this sort of requirement before. I need to locate
the maximum transaction time in a record.
Select max(t1.starttime), max(t2.starttime), max(t2.endtime), max
(t1.endtime)
from table1 t1
join table2 t2 on t1.id = t2.t1id
where t1.testvalue = :testval
into :val1,:val2,:val3,:val4
The value that is of interest to me is the maximum of the four values
that query returns. This query is run inside a stored procedure, so
the way I am currently doing it is
maxval = :val1;
if (:val2 > :maxval) then maxval = :val2;
if (:val3 > :maxval) then maxval = :val3;
if (:val4 > :maxval) then maxval = :val4;
It does the job but I wondered if there was a better way to implement
this?
Adam
I have never had this sort of requirement before. I need to locate
the maximum transaction time in a record.
Select max(t1.starttime), max(t2.starttime), max(t2.endtime), max
(t1.endtime)
from table1 t1
join table2 t2 on t1.id = t2.t1id
where t1.testvalue = :testval
into :val1,:val2,:val3,:val4
The value that is of interest to me is the maximum of the four values
that query returns. This query is run inside a stored procedure, so
the way I am currently doing it is
maxval = :val1;
if (:val2 > :maxval) then maxval = :val2;
if (:val3 > :maxval) then maxval = :val3;
if (:val4 > :maxval) then maxval = :val4;
It does the job but I wondered if there was a better way to implement
this?
Adam