我有以下数据
ID Status Order Date
1 to be validated 1 2013/02/18 14:24:55,085000000
1 to be modified 2 2013/02/19 10:37:29,641000000
1 to be validated 3 2013/03/15 14:42:31,913000000
1 in force 4 2013/03/20 09:57:14,839000000
1 in force 5 2013/03/22 15:41:46,683000000
1 in force 6 2013/03/26 09:50:53,312000000
1 in force 7 2013/03/26 10:00:27,461000000
1 in force 8 2013/03/27 11:03:02,981000000
1 in force 9 2013/03/27 16:28:25,405000000
1 closed 10 2013/03/28 16:16:30,152000000
1 closed 11 2013/03/28 16:16:30,199000000
2 pending 1 2013/02/19 10:07:15,177000000
2 pending 2 2013/03/26 11:48:23,800000000
3 to be validated 1 2013/02/20 15:03:23,771000000
3 to be validated 2 2013/02/27 13:45:43,505000000
3 to be modified 3 2013/02/27 13:49:08,845000000
3 refused 4 2013/02/27 13:53:36,543000000
3 refused 5 2013/04/10 12:14:04,946000000
3 refused 6 2013/04/10 12:14:04,961000000
我希望按ID分组,但只获得组中max(顺序)的整行,即
1 closed 11 2013/03/28 16:16:30,199000000
2 pending 2 2013/03/26 11:48:23,800000000
3 refused 6 2013/04/10 12:14:04,961000000
我尝试了一个group by语句,但我不确定哪个聚合函数会产生所需的结果,即获得剩余coulmns的正确值(超出组范围):
SELECT
ID
, STATUS
, MAX(ORDER)
, DATE
FROM
....
GROUP BY
ID
正确的查询应该如何实现预期结果?