pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: selecting entire row on which one field is the minimum
2+ messages / 2 participants
[nested] [flat]
* Re: selecting entire row on which one field is the minimum
@ 2003-05-21 01:14 Rod Taylor <rbt@rbt.ca>
parent: edouard.boucher@free.fr
0 siblings, 0 replies; 2+ messages in thread
From: Rod Taylor @ 2003-05-21 01:14 UTC (permalink / raw)
To: edouard.boucher@free.fr; +Cc: pgsql-sql
Something like this:
SELECT a FROM table WHERE B = (SELECT min(B) FROM table);
On Tue, 2003-05-20 at 21:16, edouard.boucher@free.fr wrote:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Rod Taylor <rbt@rbt.ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
Attachments:
signature.asc (application/pgp-signature, 186B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
* selecting entire row on which one field is the minimum
@ 2003-05-21 01:16 edouard.boucher@free.fr
0 siblings, 1 reply; 2+ messages in thread
From: edouard.boucher@free.fr @ 2003-05-21 01:16 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-05-21 01:16 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-21 01:16 selecting entire row on which one field is the minimum edouard.boucher@free.fr
2003-05-21 01:14 ` Rod Taylor <rbt@rbt.ca>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox