Results 1 to 4 of 4

Thread: Help: Sql Query

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belgium
    Posts
    167

    Exclamation 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.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belgium
    Posts
    167

    Re: Help: Sql Query

    Anyone?

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Help: Sql Query

    Moved to the Database Development forum.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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
  •  



Click Here to Expand Forum to Full Width