Results 1 to 2 of 2

Thread: Line number

  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: Line number

    Hello everybody.
    I just started with db2 and here is my ?
    i got the table with fields:
    title, year, weight

    and i need to find a book which is ranked 22nd in weight.
    does anybody know how to do it
    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    Copenhagen
    Posts
    220
    If you don't need to do it consistently
    just select all from the table and order
    by weight descending i.e: (SQL)

    Select * from qualifier.tablename
    order by weight desc
    fetch first 22 rows only

    The record you want is in the bottom row.

    If you want to do it permanently, use the
    above code as a subselect and insert into
    a temporary table with a counter (generate
    always as identity) then use a predicate
    (where identycolumn=22)
    Kristian K. Hansen
    Project Supervisor
    National Board of Health

Posting Permissions

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