Results 1 to 5 of 5

Thread: Solve this Query

  1. #1
    Join Date
    Jun 2007
    Posts
    3

    Solve this Query

    Hello friends,

    I want to find only fifth row from a table please give me better solution.

    thanks in adavance

    regards
    Harsh

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Do you have any sequence column in the table?

  3. #3
    Join Date
    Jun 2007
    Posts
    1

    Answer

    Select Top 5 From Table_name
    Order By Column_name Desc

  4. #4
    Join Date
    Jun 2007
    Posts
    4

    Just don't

    Relational Database Law (Or should be):

    Never assume the order of the rows after insertion or retrival unless bound by an ordering clause.

    And even with an ordering clause, you have to be extremely careful.

    Select top 5 from table_name

    If connecting through an app, burn through the first 4 results, and tada. If its a t-sql query, cursor through the result set and burn the first 4 lines.

    but again, be careful. If you are ordering, moeedkreated's statement works.

  5. #5
    Join Date
    Jul 2007
    Posts
    5
    run this query

    select top 1 * from (select top 5 * from Table_Name order by Column_Name desc) Table_Name

    This will give you the fifth row

Posting Permissions

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