I need to get the maximum priority value based on the created time. My query is here,
select
t.id, ocf1.Content Priority, ocf1.created
from
Tickets t inner Join ObjectCustomFieldValues ocf1
on ocf1.ObjectId=t.id
where
ocf1.CustomField=301
and t.queue in (27,50,49,52)
and t.status not in ('rejected','deleted')
and t.created between subdate(now(),interval 1500 minute) and now();
id Priority created
-------------------------------
27344 P4 28/01/13 09:17
27344 Incident 28/01/13 09:18
27345 P4 28/01/13 09:22
27346 P4 28/01/13 09:25
27353 P4 28/01/13 10:08
27353 Incident 28/01/13 10:09
27360 P4 28/01/13 10:38
27360 Incident 28/01/13 10:39
27365 P3 28/01/13 11:52
27376 P4 28/01/13 14:49
Example: Here I need the maximum priority value Incident for the id 27344. The same as for other ids.
are your date really formatted like this:
28/01/13 09:17? and the data type is string. right? If that’s the case, you need to convert it to date time soMAX()will properly work well.