ID Name AppointmentDate
-- -------- ---------------
1 Bob 1/1/2010
1 Bob 5/1/2010
2 Henry 5/1/2010
2 Henry 8/1/2011
3 John 8/1/2011
3 John 12/1/2011
我想找回被人最近的预约日期的记录表。所以我需要一个会给出以下结果集的查询。
1 Bob 5/1/2010 (5/1/2010 is most recent)
2 Henry 8/1/2011 (8/1/2011 is most recent)
3 John 8/1/2011 (has 2 future dates but 8/1/2011 is most recent)
谢谢!
可能重复[这](http://stackoverflow.com/questions/189213/sql-selecting-rows-by-most-recent-date) – 2011-06-14 16:04:06
如果您发布代码,XML或数据样本,请** **在文本编辑器中点击这些行,然后单击编辑器工具栏上的“代码示例”按钮(“{}”),以良好地格式化和语法突出显示它! – 2011-06-14 16:04:28
可能你可以按名称使用max(AppointmentDate)组。 – Rahul 2011-06-14 16:04:41