【发布时间】:2013-06-27 08:11:57
【问题描述】:
这是表格(后续):
我的问题是,我想为每个插入的cust_name 选择fol_date 的最新数据。我用红色箭头标记的示例结果。有人帮忙吗?
【问题讨论】:
-
注:表名->后续
-
其他回答者发布了他们的解决方案,但他们没有提到这只是greatest-n-per-group的一个常见问题,它已经过良好的测试和高度optimized solutions。我个人更喜欢left join solution of Bill Karwin(original post with lots of other solutions)。如果您需要最后一个
n记录,它会更复杂,但也需要optimized and tested solutions exist。另见标签 [ta
标签: mysql