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)
 Comparing records in the same table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-03 : 09:57:48
Chance writes "I have a table with 4 fields, Date, Time, Device and Status.

I want to return all the devices with the difference in time of their status.

Example record:

7/28/2001,11:34:22,rmlm001a,OPEN
7/28/2001,11:34:26,rplv001a,OPEN
.
.
.
7/28/2001,12:02:33,rmlm001a,CLOSED
7/28/2001,12:08:13,rplv001a,CLOSED
.
.
.
7/28/2001,14:00:07,rmlm001a,OPEN

and so on...

I would like the reqult of the query to be:

rmlm001a 7/28/2001 Total Open Time = 28:11
rplv001a 7/28/2001 Total Open Time = 33:47

and so on.

I am guessing I have to do some sort of a sub query or use a temp table to compare these values. I am stumped.

Thanks in advance for your help."
   

- Advertisement -