Re: Problem with SQL!!

From: Matt Marrow [LOGICA][dc] <mmarrow_at_diana>
Date: 1996/11/06
Message-ID: <55r11i$djt_at_zeus.mobile.com>#1/1


How about:

SELECT column1,column2
FROM simons_table st1
WHERE st1.column1 <= ALL (SELECT st2.column1

                           FROM   simons_table st2
                           WHERE  st2.column1 = st1.column1)

Hope that helps

Matt

mmarrow_at_pacbell.mobile.com

Simon Mercer (mercer_at_mpimg-berlin-dahlem.mpg.de) 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