selecting entire row on which one field is the minimum

From: edouard(dot)boucher(at)free(dot)fr
To: pgsql-sql(at)postgresql(dot)org
Subject: selecting entire row on which one field is the minimum
Date: 2003-05-21 01:16:36
Message-ID: 20030521011636.GA18831@comploteur.gibbonie.creolie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

i have a table with 2 fields, let's say A and B, both integers.
i would like to select all the A for which the B are minimum

i'm not sure i am clear, so here is an exemple :

A | B
1 | 5
2 | 2
3 | 3
4 | 2
5 | 2

in this situation, the query should return (2, 4, 5)
as it is very easy to ordre a table, i tought this query would be easy
too, but it is more difficult than it looks like.

thanks for help

Edouard Boucher

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Avi Schwartz 2003-05-21 01:38:01 Re: Functions that return Record Sets
Previous Message Rod Taylor 2003-05-21 01:14:33 Re: selecting entire row on which one field is the minimum