schraudog
asked on
AVG t-sql last 10 rows by datetime?
I have a very simple table with EventCountTime (datetime) and EventCount (smallint).
I would like a query to simply give me the AVG EventCount for the most recent 10 (last in table) entries in the table.
I have tried
select AVG(EventCount) from ( select top 10 EventCount from EventRecord order by EventCountTime desc )
but I get
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
I would like a query to simply give me the AVG EventCount for the most recent 10 (last in table) entries in the table.
I have tried
select AVG(EventCount) from ( select top 10 EventCount from EventRecord order by EventCountTime desc )
but I get
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER