djburnheim
Technical User
Hi use the following query to find a maximum..I'm now trying to workout out how to find the time that the maximum occured which is stored in the idrecord.IntialStart column.
Query to find max
SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'})
I thought the query to find the time that it occured would be something like:-
SELECT idrecord.IntialStart
FROM agerecord, idrecord
WHERE (SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'})) = (SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'}))
And this does seem to return the right time but it returned it for every row in the table. I added Distinct to the query and it seemed to make everything hang.
Any suggestions?
thanks
Dave
Query to find max
SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'})
I thought the query to find the time that it occured would be something like:-
SELECT idrecord.IntialStart
FROM agerecord, idrecord
WHERE (SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'})) = (SELECT (agerecord.Secondstart -idrecord.Intialstart) + int2interval(agerecord.Length)
FROM agerecord, idrecord
WHERE agerecord.id = idrecord.id
AND ((idrecord.Intialstart Between {ts '2003-06-02 00:00:00'} And {ts '2003-06-03 00:00:00'}))
And this does seem to return the right time but it returned it for every row in the table. I added Distinct to the query and it seemed to make everything hang.
Any suggestions?
thanks
Dave