Results 1 to 3 of 3

Thread: query help

  1. #1
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,361

    query help

    Query:
    select c1, c2 from t where c2 = (select max(c2) from t)


    Column c2 is int
    The table doesn't have any indexes


    -> Need both c1 and c2 where c2 is max.


    Can you please suggest if this query can be rewritten to make it more efficient without creating any indexes.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,414
    select c1, c2 from (select c1, c2, rank() over (order by c2 desc) rnk from t) where rnk = 1
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,361
    How many times will db2 scan the table using your query?

Posting Permissions

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