|
-
May 23rd, 2012, 08:21 AM
#1
Thread Starter
Addicted Member
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
Last edited by Teckniel; May 23rd, 2012 at 08:26 AM.
-
May 24th, 2012, 01:34 AM
#2
Thread Starter
Addicted Member
-
May 24th, 2012, 03:32 AM
#3
Re: Help: Sql Query
Moved to the Database Development forum.
-
May 24th, 2012, 05:33 PM
#4
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
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|