Re: How to use 'Top' in oracle?

From: Basavaraj <nospam_at_indya.com>
Date: Tue, 26 Sep 2000 15:09:31 +0530
Message-ID: <39D06ED3.31EE486D_at_indya.com>


Hi,

If using Oracle 8.1.6, the function RANK can also help you. Here is the syntax for RANK

RANK and DENSE_RANK



The RANK and DENSE_RANK functions allow you to rank items in a group, for example, finding the top 3 products sold in California last year. There are two
functions that perform ranking, as shown by the following syntax:

RANK() OVER (
  [PARTITION BY <value expression1> [, ...]]   ORDER BY <value expression2> [collate clause] [ASC|DESC]

     [NULLS FIRST|NULLS LAST] [, ...]
   )

DENSE_RANK() OVER (
  [PARTITION BY <value expression1> [, ...]]   ORDER BY <value expression2> [collate clause] [ASC|DESC]   [NULLS FIRST|NULLS LAST] [, ...]
  )

Ciao,
Basavaraj
mhwang wrote:

> I want to get the first 3 products order by these prices.
> But i get an error when using : "Select top 3 product_name from product
> order by product_price".
> How can i do it ?
>
> Any suggestions are appriciated.
> Ming at 9.25
Received on Tue Sep 26 2000 - 11:39:31 CEST

Original text of this message