Re: Problem with SQL!!

From: Peter Rak <po080016_at_pop.ke.sanet.sk>
Date: 1996/11/06
Message-ID: <32807E76.80_at_pop.ke.sanet.sk>#1/1


Hi,

Try

select col2,min(col1) from tab group by col2;                 

                Peter.

Simon Mercer wrote:
>
> Dear All,
>
> It's before coffee break and so this may be a stupid question, but
> I have a table with something like the following values;
>
> column1 | column2
> 0 100
> 1 100
> 2 100
> 3 200
> 4 200
>
> - where column1 is the primary key.
>
> All I want to get is, for each value in column2, the lowest value
> in column1;
>
> 0 | 100
> 3 | 200
>
> I know I could use a procedural language to get the result, but SQL must
> surely be able to do this - it looks so simple!
>
> Any suggestions? Please mail me a copy because I might miss it in the
> newsgroup.
>
> Thanks,
>
> Simon
>
> --
> Dr. Simon Mercer
> Ressourcenzentrum des Deutschen Genomprojekts
> +49 30 326 39111 (fax)
> mailto:mercer_at_rzpd.de
Received on Wed Nov 06 1996 - 00:00:00 CET

Original text of this message