Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    11

    Unanswered: display different number of rows

    i have a table displaying location, cost, inner_num and rownum ordered by the descending order of the cost.

    the question is:
    display locations of the highest 10 costs. if the cost of 11th row is the same as 11th, then display 11 rows.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    http://www.dbforums.com/oracle/16374...rent-rows.html

    what is the problem with previously provided response?

    Post DDL for tables.
    Post DML for test data.

    Post expected/desired results.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Are you unwilling to read the answers to the other versions of your question?

    As may others (in this and other forums) have already answered:

    Look up the rank() (or dense_rank()) function in the manual. Read the chapter about analytical functions.

    http://www.dbforums.com/oracle/16374...rent-rows.html
    http://forums.devshed.com/oracle-dev...ws-585702.html

  4. #4
    Join Date
    Jan 2009
    Posts
    11

    categorise data

    thx everybody. this is solved

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You should post solutions so others can benefit.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Jan 2009
    Posts
    11
    SELECT location,cost, rk
    FROM (SELECT location, cost, rank() OVER(ORDER BY cost DESC) rk FROM eletab)
    WHERE rk <= 10
    ORDER BY 2
    Last edited by madara79; 01-29-09 at 08:58.

Posting Permissions

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