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: Is this possible in SQL?

Re: Is this possible in SQL?

From: Ted Chyn <tedchyn_at_yahoo.com>
Date: 19 Jul 2002 23:57:34 -0700
Message-ID: <44a19320.0207192257.1bf5511b@posting.google.com>


dreamer33334_at_yahoo.com (Joe Imbrogo) wrote in message news:<65dcbf17.0207191718.1923e6be_at_posting.google.com>...
> Let us assume there is a view A with data as follows...
>
> X Y Z
> -----------------------
> 12 2 2
> 14 2 3
> 17 2 9
> 19 3 12
> 21 3 16
> 25 4 21
>
> I need get the value of X for every unique value of Y, where Z is the
> lowest in its range.
>
> For example, the result for the above example would be
>
> X Y
> -------------
> 12 2
> 19 3
> 25 4
>
> I know this is very easy to do in PL/SQL, but I wanted to take up the
> challenge of doing this is a regular SQL statment. However, I could
> not make much progress.
>
> Any help on this would be greatly appreciated.
>
> Thanks,
> Joe

joe, here it is

SQL> select * from test;

        C1 C2 C3
---------- ---------- ----------

        12          2          2
        14          2          3
        17          2          9
        19          3          1
        21          3         16
        25          4         21

6 rows selected.
 1 select min( c1),c2
 2 from test x
 3* group by c2
QL> /

  MIN(C1) C2
--------- ----------

       12          2
       19          3
       25          4

ted Received on Sat Jul 20 2002 - 01:57:34 CDT

Original text of this message

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