我想總結下面的列。我該怎麼做?獲得列的總和
當我使用
sum(DATEDIFF (HOUR , startDate, endDate)/10.0)
它給出了這樣的輸出:
(No column name)
1.000000
0.300000
1.000000
1.000000
1.000000
1.000000
0.300000
我怎麼能總結此列?
整個查詢:
SELECT SUM(DATEDIFF (HOUR , StartTime , EndTime)/10.0) FROM [y]
INNER JOIN [x] ON [x].UserID = [y].ID
WHERE StartTime BETWEEN '20120709' AND '20120714' AND UserID = 1
GROUP BY StartTime, [y].ID, [y].Name, EndTime
ORDER BY StartTime
您的選擇清單中是否還有其他欄目?你可以給完整的sql查詢.. – 2012-07-17 07:44:59
你有一個GROUP BY子句嗎? – walrii 2012-07-17 07:45:50
總和將在每個GROUP BY列上。這是小組的目的。去掉它? – walrii 2012-07-17 07:49:41