CallID StartTime EndTime Querytime
1692 2012-11-20 11:52:00.000 2012-11-20 11:52:00.300 0.300
1693 2012-11-20 11:52:00.000 2012-11-20 11:52:00.100 0.100
1694 2012-11-20 11:52:00.000 2012-11-20 11:52:00.400 1.5
1695 2012-11-20 11:52:01.000 2012-11-20 11:52:01.400 3
1696 2012-11-20 11:52:01.000 2012-11-20 11:52:01.300 5
我想获得按 StartTime 分组的最大查询时间,如下所示,但我仍然希望显示 CallID。
StartTime MaxQueryTime
2012-11-11 19:04:07.000 0.300
2012-11-11 19:04:10.000 0.200
2012-11-11 19:08:48.000 0.300
2012-11-11 19:08:51.000 0.300
2012-11-11 19:09:27.000 0.100
SELECT StartTime, MAX(Querytime) AS QueryTime
FROM dbo.Calls
GROUP BY StartTime