>
> You can (must) use a Where clause if you refer to soh.OrderDate
> directly


Good grief! You're right. I thought a WHERE was forbidden in a grouped
query and only HAVING was allowed. A working sample is below (although
monthly totals would start and end on month boundaries, this sample just
proves the WHERE and grouping work) -- Greg

SELECT COUNT(Id) As Count, SUM(CAST([Send] AS BIGINT)) AS SendTotal,
SUM(CAST([Recv] AS BIGINT)) As RecvTotal, SUM(Elapsed) AS ElapsedTotal,
  DATEPART(YEAR,[Time]) AS LogYear, DATEPART(MONTH,[Time]) AS LogMonth
 FROM [Visit]
 WHERE [Time] BETWEEN '2012-07-29' AND '2013-03-02'
 GROUP BY DATEPART(YEAR,[Time]), DATEPART(MONTH,[Time])
 ORDER BY LogYear DESC, LogMonth DESC

Reply via email to