From: | "Wei Weng" <wweng(at)kencast(dot)com> |
---|---|
To: | "Yoann" <yaubi(at)yaubi(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Which SQL query makes it possible to optain the 3 greatest values of an interger list ? |
Date: | 2001-09-15 00:08:09 |
Message-ID: | NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I would use
SELECT id FROM table ORDER BY id LIMIT 0, 3;
in order to get the top 3 results. The key is "Limit" keyword.
==========
Wei Weng
Network Software Engineer
KenCast Inc.
> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Yoann
> Sent: Wednesday, September 12, 2001 4:41 AM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] Which SQL query makes it possible to optain the 3
> greatest values of an interger list ?
>
>
> OO( Sql Problem )Oo.
>
> That is to say a table of 5 inputs of 1 integer field :
>
> Table = { (1); (12); (3); (9); (4) }
>
> We want to obtain a result of 1 input of 3 fields,
> corresponding to the 3 greatest values of Table,
> by descending order :
>
> Result = { (12; 9; 4) }
>
> => Which SQL query makes it possible to obtain Result from Table ?
> We certainly need to use sub-queries, but how ?
>
> Thank you in advance for your help !
>
> Yoann AUBINEAU
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
From | Date | Subject | |
---|---|---|---|
Next Message | Patrik Kudo | 2001-09-15 00:11:36 | Re: Which SQL query makes it possible to optain the 3 greatest |
Previous Message | Carl van Tast | 2001-09-14 22:26:01 | Re: group by weirdness |