pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wei Weng <wweng@kencast.com>
To: Yoann <yaubi@yaubi.com>
To: pgsql-sql@postgresql.org
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: <NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com> (raw)
In-Reply-To: <70c8063b.0109120041.5fc5d0d1@posting.google.com>

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
> 



view thread (3+ messages)  latest in thread

Message-ID: <NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com>
Permalink:  ../NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com/
Also on:    postgresql.org/message-id/NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: wweng@kencast.com, yaubi@yaubi.com
  Subject: Re: Which SQL query makes it possible to optain the 3 greatest values of an interger list ?
  In-Reply-To: <NEBBLAIMPMNDAPBMNGJNCENICBAA.wweng@kencast.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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