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)
 date duration calc

Author  Topic 

Tim
Starting Member

392 Posts

Posted - 2001-08-06 : 22:06:00
I have records which have the day of the year that a certain event (A,B,C...) ocurred on.

I want a query that gives the number of days since the last occurrence of the same event.

eg:

records are

A 156
B 144
A 186
B 140
A 190
A 166
B 150

I want query that gives:

A 156 NULL
A 166 10
A 186 20
A 190 4
B 140 NULL
B 144 4
B 150 6

Maybe I need a cursor?

*trolls for nr's response*

   

- Advertisement -