Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Need help in SQL query for frequency statistics

Author  Topic 

spikeic
Starting Member

2 Posts

Posted - 2004-08-02 : 20:12:42
I'm looking for an SQL query that returns the number of occurrences in a time period. For instance, lets say I have the following table:

Sequence Name Time(in seconds)

1 John 44
2 Mark 67
3 Dave 68
4 Brad 92
5 Tony 100


I want a query that returns the number of occurrences in a 15-second period, starting with the first time. I want the following result:


Sequence StartTime Count
1 44 1
2 59 2
3 74 0
4 89 2
5 104

I'm assuming this is a basic statistical (time series) way of gathering data. I'm hoping someone has already developed a query for this. HELP!

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-08-02 : 20:21:48
I think you need a join to a sequence table to make this happen.

Take a look at this article. It gives you an idea of how to do what you want here.

http://www.sqlteam.com/item.asp?ItemID=5741

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -