-
Help: Sql Query
Hello.
I have constructed a query that look for a certain status code between to times
My Query is as followed
Code:
SELECT [ID],[NAME], [CELLNUMBER], [RECEIVED], [STATUS] FROM [Ctrack].[dbo].[POSLOG] WHERE CELLNUMBER=(SELECT Cellnumber FROM Ctrack.dbo.MobDat where id='Duy') AND STATUS='18' AND [MTIME] BETWEEN ('1337578200') AND ('1337580000') ORDER BY RECEIVED ASC
What i want todo is get the next 20 records that come right after the result of the query or all grab all the records until it reaches code 143.
my problem is i don't know where to start looking.
Hope anyone can help
Regards Me
-
Re: Help: Sql Query
-
Re: Help: Sql Query
Moved to the Database Development forum.
-
Re: Help: Sql Query
The first thing I would do would be to test out what you have. Does it work? I have always had some doubts about BETWEEN, so I'd want to see that working before going any further.
As for the main question, you state that you want the next 20 records, or all until code 143. What is Code? Do you mean the ID? If so, then all I would be getting form that first query is the ID. You would then perform a second query where ID > whatever you returned from the first query, and either using TOP (20), or where ID > start number And ID < 143