sql - MySQL checking last updated time on multiple devices -
i check last update date , time (recordtime) every treehugger id (treehuggerid) , below did. output not last update time according below query. please advice. thank you.
select `recordtime`, distinct `treehuggerid` `sensor_treehuggers` `treehuggerid` < 20000 , `treehuggerid` > 10000 order `recordtime` desc
you have select max(recordtime)
every treehuggerid
, don't need distinct
select treehuggerid,max(recordtime) sensor_treehuggers
then @ end
group treehuggerid
like this
select treehuggerid,max(recordtime) sensor_treehuggers treehuggerid between 10000 , 20000 group treehuggerid
Comments
Post a Comment