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)
 How to query for row and row +x (sort of)?

Author  Topic 

MuadDBA

628 Posts

Posted - 2005-10-17 : 11:02:30
Hi,

I am hoping y'all can help me with a query I am working on. Here is the table:

CREATE TABLE [dbo].[TrackingHistory] (
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[TrackedTableId] [varchar] (30) NULL ,
[TrackedTable] [varchar] (30) NULL ,
[LocationsId] [varchar] (30) NULL ,
[BoxesId] [varchar] (30) NULL ,
[TransactionDateTime] [datetime] NULL ,
[IsActualScan] [bit] NOT NULL ,
[BatchId] [int] NULL ,
[UserName] [varchar] (30) NULL ,
[FoldersId] [varchar] (30) NULL ,
[TrackingAdditionalField1] [varchar] (50) NULL ,
[TrackingAdditionalField2] [text] NULL
)

This is a history table of all tracking activity in our database. So, the trackedtable field tells what sort of item was tracked (folder, document, box, etc) and the traqckedtableid is the id of the record which was tracked (ie F123456789CR). Locationsid is the id of the location it was tracked to, and transactiondatetime is the date and time it was tracked to that location. The other fields are not necesary for my question.

I have a list of locations, and I want to find items which were tracked to those locations, and where they went immediately after that. I can't wrap my head around a query that will do that, so any help anyone here could provide would be appreciated.

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-10-17 : 14:31:46
Can you post some sample data and desired results?

Nathan Skerl
Go to Top of Page
   

- Advertisement -