Received: from nsx-a.snet.net ([204.60.203.54]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8F2PP723472 for ; Fri, 14 Sep 2001 22:25:25 -0400 (EDT) (envelope-from wweng@kencast.com) Received: from pop.snet.net (pop.snet.net [204.60.6.9]) by nsx-a.snet.net (8.11.1/8.11.1/SNET-mx-1.4/D-1.10/O-1.7) with ESMTP id f8F2PXo05495; Fri, 14 Sep 2001 22:25:33 -0400 (EDT) Received: from monet (167.95.252.64.snet.net [64.252.95.167] (may be forged)) by pop.snet.net (8.11.1/8.11.1/SNET-pop-1.5/D-1.8/O-1.6) with SMTP id f8F01iv24096; Fri, 14 Sep 2001 20:02:03 -0400 (EDT) Reply-To: From: "Wei Weng" To: "Yoann" , Subject: Re: Which SQL query makes it possible to optain the 3 greatest values of an interger list ? Date: Fri, 14 Sep 2001 20:08:09 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Importance: Normal In-Reply-To: <70c8063b.0109120041.5fc5d0d1@posting.google.com> X-Archive-Number: 200109/86 X-Sequence-Number: 4750 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@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Yoann > Sent: Wednesday, September 12, 2001 4:41 AM > To: pgsql-sql@postgresql.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@postgresql.org so that your > message can get through to the mailing list cleanly >