How does MySql customize the function to manipulate the raw data to which each group of Group By belongs?

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

The result of

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 after

Select 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)


uses a clumsy method: first concatenate the time into a string Concat (time, column) as newColumn, and then MAX to get the maximum value, and then use sub to get the content after the time

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c0e4-4460c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c0e4-4460c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?