Posted by David Portas on 10/12/05 13:03
Don't assume it is obvious what is wrong. It helps to say exactly what
error message you got and also to post enough code to reproduce the
problem - at least a CREATE TABLE statement.
In this case you missed the GROUP BY:
SELECT location, machinename, SUM(hours)
FROM tbl
WHERE date >= '20050101'
AND date < '20060101'
GROUP BY location, machinename ;
It is usually easier to specify date ranges as >= and < unless you are
sure that the DATETIMEs will never contain times other than midnight.
--
David Portas
SQL Server MVP
--
Navigation:
[Reply to this message]
|