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 2005 Forums
 Transact-SQL (2005)
 Querry for process a number of records(SQL 2005)

Author  Topic 

myhelp12
Starting Member

1 Post

Posted - 2009-03-07 : 01:35:56
I have sql table with the following fields
PointId,TempValue,DateAndTime

From this table I have to select the records within specifed time interval(say 10 minute) and create one record with average of TempValue,
the last DateandTime for a particular PointId. Again select the next set of records within the time interval, store it as the next record in the result set and so on.
I need to perform the above operation for each PointId.

Sample of records are given below

S001 -74 2008-12-18 15:43:59.000
S002 -22 2008-12-18 15:43:59.000
S001 -75 2008-12-18 15:45:59.000
S002 -25 2008-12-18 15:45:59.000
S001 -78 2008-12-18 15:47:59.000
S002 -21 2008-12-18 15:47:59.000
S001 -79 2008-12-18 15:49:59.000
S002 -20 2008-12-18 15:49:59.000
S001 -78 2008-12-18 15:51:59.000
S002 -18 2008-12-18 15:51:59.000
S001 -76 2008-12-18 16:01:59.000
S002 -20 2008-12-18 16:01:59.000

How can I write a stored procedure for this. I'm new to SQL.
Can anyone help me?

Thanks in advance

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-07 : 09:52:55
Please post expected output as well so we can give a good solution.
Go to Top of Page
   

- Advertisement -