larrydavid
Programmer
Hello,
I have this statement which is returning correct data:
Then I am trying to get the AVG in this approach:
And I keep getting this:
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ')'.
I've been pulling what little hair I have left for the past couple of hours and cannot figure out what the problem is. If someone could please help me I would really, truly appreciate it.
Thanks,
Larry
I have this statement which is returning correct data:
Code:
SELECT COUNT(*) count FROM CSDBBRDFC001.Hope.dbo.RealTimeProd
WHERE Timestamp >= CONVERT(DATETIME, '2011-02-07 00:00:00', 120) AND
Timestamp <= CONVERT(DATETIME, '2011-02-08 00:00:00', 120)
GROUP BY DATEADD(hour, DATEDIFF(hour, 0, Timestamp), 0)
Then I am trying to get the AVG in this approach:
Code:
SELECT AVG(count) FROM
(
SELECT COUNT(*) count FROM ABCDEFG.Test.dbo.TestData
WHERE Timestamp >= CONVERT(DATETIME, '2011-02-07 00:00:00', 120) AND
Timestamp <= CONVERT(DATETIME, '2011-02-08 00:00:00', 120)
GROUP BY DATEADD(hour, DATEDIFF(hour, 0, Timestamp), 0)
)
And I keep getting this:
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ')'.
I've been pulling what little hair I have left for the past couple of hours and cannot figure out what the problem is. If someone could please help me I would really, truly appreciate it.
Thanks,
Larry