SQL syntax for recordset of 10 second time intervals
I've got a SQL Server 2008 table that records an amount (int) and a timestamp for each record. For reporting purposes I want a query that will return a recordset of the total amount at specified time intervals.
For example, starting at 2011-8-9 16:00:00 return the total amount at intervals of 10 seconds through til the current time. Which would produce a recordset like:
85 etc etc.
Or in pseudo-SQL, I want something like:
SELECT SUM(amount) FROM mytable WHERE timestamp >= '2011-8-9 9:00:00' AND timestamp <= GETDATE() ... AT INTERVALS OF 10 SECONDS
Can someone tell me what the correct SQL would be for that?
Thanks in advance!
Microsoft SQL ServerMicrosoft SQL Server 2008ASP.NET