Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Please explain this query

Re: Please explain this query

From: N. Shamsundar <shamsundar_at__at_uh.edu>
Date: Thu, 13 Oct 2005 16:48:11 -0500
Message-ID: <dimkn1$7ple$1@masala.cc.uh.edu>


shihab wrote:
> This is the query to findout Nth Max (Highest) value from a table
>
> SELECT sal from emp t
> WHERE &n = (SELECT COUNT(sal)
> FROM (SELECT DISTINCT sal FROM emp)
> WHERE t.sal<=sal);
>
> Can anybody expalin how this query works.....
>
>
> Thanks in advance
> Shihab
>

If you cannot see how it works by inspection alone, get out the old pencil and paper, make up an EMP table with, say, four numbers, and execute the query by hand, with an SQL manual at your side.

N. Shamsundar
University of Houston Received on Thu Oct 13 2005 - 16:48:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US