Re: Newbie SQL question (Top 10 values)
Date: 1996/01/16
Message-ID: <Pine.SUN.3.91.960116101414.20843D-100000_at_seatimes>#1/1
On Mon, 15 Jan 1996, RAC wrote:
> Rob Weeks <rweeks_at_kodak.com> wrote:
>
> >How in the heck do I write a query that either returns the top 10% or
> >top ten values of a specific field (sales information for instance)? In
>
> You can get the top ten values by (1) sorting in descending order the
> field that you want to see and (2) adding an additional where clause
> stating "and rownum < 11" For example, you query might look like
>
rownum is checked prior to the sort. This solution will select the first 10 rows found, then sort those into descending order. You will need to do this in two passes. First pass is to create a view that sorts the rows into the order you want. The second pass is to select the first 10 rows from that view.
+----------------------------------------------------+ | Steve Butler Voice: 206-464-2998 | | The Seattle Times Fax: 206-382-8898 | | PO Box 70 Internet: sbut-is_at_seatimes.com | | Seattle, WA 98111 Packet: KG7JE_at_N6EQZ.WA | +----------------------------------------------------+All standard and non-standard disclaimers apply. All other sources are annonymous. Received on Tue Jan 16 1996 - 00:00:00 CET