如何获得多行天数的持续时间总和?

how can I get sum of duration in days which is having multiple rows?

我有一个 table 如下所示,

ID  |  duty |  startDate  |  Enddate


01  | yes  | 2011-10-15  | 2011-12-15

01  | yes  | 2012-01-10  |  2012-05-25

03  | yes  | 2012-02-23  | 2012-03-25

01  | no   | 2012-05-25  |2012-06-06

01  | yes  | 2012-07-10  | 2012-12-03

02  | yes  | 2012-08-21  | 2012-12-10

我需要得到以下结果,

ID | duty | duration (in days)

01 | yes  | xxx

02 | yes  | yyy

03 | yes  | zzz

01 | no   | iii 

我会尝试如下操作:

SELECT ID, duty, SUM(DATEDIFF(dd, startDate, endDate)) as duration 
FROM [Table] 
GROUP BY ID, duty

DATEDIFF 文档:http://msdn.microsoft.com/en-us/library/ms189794.aspx

不知道 GROUP BY 是否如您所愿