I have an issue finding the longest responce time and the shortest responce time.
Three tables:
T1.RESPONCE
resp_id (bigint)
resp_text (text)
resp_created_date (datetime)
resp_closed_date (datetime)
T2.RESP_UPDATE_RELATION
resp_id (bigint)
update_id (bigint)
T3.UPDATES
update_id (bigint)
update_text (text)
update_created_date (datetime)
update_closed_date (datetime)
T2.RESP_UPDATE_RELATION is created for multiple updates per responce
I would like to locate – for each responce – the longest and the fastest update time.
Any clever mysql for that?
Or do I need to include PHP code for this?
———————————– EDIT ——————————–
woke up just now.. and thougth. I have been trying this for a week now, and it seems that I am doing it right. The results are confusing me. So maybe I am not doing it wrongly – but asking the wrong question.
So, above request is slightly wrong!
my real request is:
I would like the result from the last 30 days of
the fastest opening update (update_created_date)
the slowest opening update (update_created_date)
the fastest closing update (update_closed_date)
the slowest closing update (update_closed_date)
Join all three tables on their foreign keys and group by resp_id. You can now select the first and the last update using the
MINandMAXaggregation functions onupdate_created_date/update_closed_date. If you want the query to produce the time difference, you can use theTIMEDIFForTIMESTAMPDIFFfunctions on top.