2021年4月29日星期四

MySQL getting data of max other column for each groups

The table seems

group_id   | time              | data  | others...  1           2020-11-30 12:00:00 13  1           2020-11-30 13:00:00 15  2           2020-11-30 12:30:00 254  3           2021-02-21 18:00:00 25565  ...  

I wanted to get the "data" of "latest time"(which can be different for each group) for each group specified,

so I wrote down like

SELECT group_id, max(time), data  where group_id between (...)  (and others = ...)  group by group_id  

but It's data was not the value of that time (actually seems like the latest record)

How can I get the data of maximum time for each group?

https://stackoverflow.com/questions/67327639/mysql-getting-data-of-max-other-column-for-each-groups April 30, 2021 at 10:58AM

没有评论:

发表评论