Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Unanswered: Help for Newbie!

    I have a table with 10 records: 10, 9, 8, 7 ... and so on. I want to SELECT the top 3 records starting with the second record on the list (which in this case is 9.) So the result should be 9, 8, and 7. What would be the correct SQL statement for this?

    I tried "SELECT TOP 3 * FROM tableXXX WHERE (FieldID<>(SELECT TOP 1 * FROM tableXXX ORDER BY FieldID DESC) ORDER BY FieldID DESC" but sure as heck it didn't work. Can anyone help?

  2. #2
    Join Date
    Oct 2003
    Posts
    311
    drop the * on the 2nd select and only qry for the pkval :

    SELECT Top 3 *
    FROM Contacts
    WHERE idCont <> (SELECT Top 1 idCont FROM Contacts)

  3. #3
    Join Date
    Aug 2004
    Posts
    2
    Thank you, Mike. It works beautifully! The complete statement is:

    SELECT Top 3 *
    FROM tbl_XXX
    WHERE (idXXX <>(SELECT Top 1 idXXX FROM tbl_XXX ORDER BY idXXX DESC))
    ORDER BY idXXX DESC

    Again, thank you. You are great help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •