assume that the original data
id type time
1 1 201X-XX-XX XX:XX
21 201X-XX-XX XX:XX
3 1 201X-XX-XX XX:XX
4 2 201X-XX-XX XX:XX
52 201X-XX-XX XX:XX
query statement
Select t.typepart. TimeMAX (t.id), t.*
FROM t
WHERE t.time between "2018-08-01 00t.id 00lv 00lv" 2018-08-03 00t.id 00"
GROUP BY t.type
query is similar to
type max (id) time
13 201X-XX-XX XX:XX
25 201X-XX-XX XX:XX
.
now there is a need to add a startTime and endTime,. The minimum time for this time within the range of "2018-08-02 06 time 00lv 00" AND" 2018-08-02 10 time is startTime, Max time is endTime
The columns afterSelect are all data after GROUP BY, so now I want to: customize a function, such as funMin (time,startTime,endTime) and funMax (time,startTime,endTime), in which all the data in each type group is traversed and determined, and finally the minimum time and maximum time are returned. What should I do?
(values returned by, MAX (id), such as the MAX function, are obtained from all groups of the same type)