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
 SQL Server Development (2000)
 Data Retrieval

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-07-30 : 11:48:12
SureshBabu writes "Hi,

I have a table T1 which has various fields.

some important fields are as follows

tno - transaction number
tdate - transaction date
tstatus - transaction status(1,2,3,4,5,6,7,8)

Transaction status may take value from 1 to 8 and for each state there is a particular tdate is there. It may be on the same date (but different time) or on a different date. My requirement is i want to find out the time differnece (using datediff) between these transaction status for a particular transaction no. Could you please help me on this??

Regards
Suresh"

JasonGoff
Posting Yak Master

158 Posts

Posted - 2004-07-30 : 11:52:21
[code]
SELECT DATEDIFF(hh,A.Time1,B.Time2)
FROM (SELECT tno,tdate,tstatus FROM T1 WHERE tstatus=1) AS A
INNER JOIN (SELECT tno,tdate,tstatus FROM T1 WHERE tstatus=2) AS B
ON A.tno=B.tno
[/code]
Go to Top of Page
   

- Advertisement -