Answer the question
In order to leave comments, you need to log in
How to group by value, capturing the date of the last entry?
there is a table with time and current temperature
correspondences cm_stat(ID, DATETIME, CURTIME)
Query
SELECT `cm_stat`.`CURTEMP`, `cm_stat`.`DATETIME`
FROM `cm_stat`
ORDER BY `DATETIME` ASC
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:47:41
)
Array
(
[CURTEMP] => 26
[DATETIME] => 2017-09-22 13:47:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:48:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:48:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:49:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:49:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:50:41
)
Array
(
[CURTEMP] => 26
[DATETIME] => 2017-09-22 13:50:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:47:41
)
Array
(
[CURTEMP] => 26
[DATETIME] => 2017-09-22 13:47:41
)
Array
(
[CURTEMP] => 27
[DATETIME] => 2017-09-22 13:50:41
)
Array
(
[CURTEMP] => 26
[DATETIME] => 2017-09-22 13:50:41
)
Answer the question
In order to leave comments, you need to log in
just group and sort by date (you already have sorting in your query)
in the grouping selection, the most extreme date will be shown, taking into account sorting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question