Ами ако използвате:
select SUM(WordCount) as 'words per day'
from @WordsCount
group by DateAdded
Не виждам защо групирате и по брой думи...
Освен това, тъй като DateAdded
вероятно е DATETIME
колона, включваща времева част, може да искате да групирате само по дата:
select SUM(WordCount) as 'words per day'
from @WordsCount
group by CAST(DateAdded AS DATE)
Актуализация: ако опитам това, заявката работи добре....
DECLARE @WordsCnt TABLE (WordCount INT, DateAdded DATETIME)
INSERT INTO @wordsCnt(WordCount, DateAdded)
VALUES(96, '2008-11-07 09:16:31.810'),
(32, '2008-11-07 15:26:27.547'),
(25, '2008-11-23 16:05:39.640'),
(62, '2008-12-03 12:33:03.110')
select CAST(DateAdded AS DATE), SUM(WordCount) as 'words per day'
from @WordsCnt
group by CAST(DateAdded AS DATE)
и произвежда резултата:
2008-11-07 128
2008-11-23 25
2008-12-03 62