0
我的CMS将其过去版本的页面存储在同一个表中。我想通过productID
提取每条记录的最新版本。适用于:为每个组选择具有最高值的整个记录
productID version name text price etc etc
ABC123 1.2 Fred Stuff 2.34 ... ...
DEF456 0.3 Jill Other 1.99 ... ...
ABC123 1.3 Fred Stuff 2.99 ... ...
DEF456 0.4 Jill Other 2.50 ... ...
ABC123 1.4 Fred Stuff 3.45 ... ...
我需要得到:
ABC123 1.4 Fred Stuff 3.45 ... ...
DEF456 0.4 Jill Other 2.50 ... ...
(任意顺序)。我在
select distinct(version),* group by productID,max(version) from table;
上进行了试验,但我无法弄清楚如何去做。 “选择最高”的其他答案都是关于计数和总和;我只需要整个记录。
https://stackoverflow.com/questions/4510185/select-max-value-of-each-group –
https://stackoverflow.com/questions/12102200/get-records-with-max-值换各基团的的分组的-SQL结果 –