From wweng@kencast.com Tue Apr 10 02:03:46 2001 Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3A23k850160 for ; Mon, 9 Apr 2001 22:03:46 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f39NP2879718 for ; Mon, 9 Apr 2001 19:25:02 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f39NHu016778 for pgsql-sql@postgresql.org; Mon, 9 Apr 2001 19:17:56 -0400 (EDT) (envelope-from news) From: Wei Weng X-Newsgroups: comp.databases.postgresql.sql Subject: Sorting and then... Date: Mon, 9 Apr 2001 19:22:52 -0400 Organization: KenCast Inc. Lines: 13 Message-ID: <9atfv4$gb0$1@news.tht.net> Reply-To: wweng@pobox.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: scrappy@hub.org User-Agent: KNode/0.4 To: pgsql-sql@postgresql.org X-Archive-Number: 200104/128 X-Sequence-Number: 2475 Suppose I have a table create table test ( id integer, name text ); And I want to get the names of the largest 10 "id"s. How can I do that in sql? Thanks! From rmello@cc.usu.edu Tue Apr 10 02:41:03 2001 Received: from fslc.ser.usu.edu (fslc.ser.usu.edu [129.123.28.122]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3A2f3885627 for ; Mon, 9 Apr 2001 22:41:03 -0400 (EDT) (envelope-from rmello@fslc.usu.edu) Received: (from rmello@localhost) by fslc.ser.usu.edu (8.12.0.Beta5/8.12.0.Beta5/Debian 8.12.0-1) id f3A2ev0a003656; Mon, 9 Apr 2001 20:40:57 -0600 Date: Mon, 9 Apr 2001 20:40:57 -0600 From: Roberto Mello To: wweng@pobox.com Cc: pgsql-sql@postgresql.org Subject: Re: Sorting and then... Message-ID: <20010409204057.A3626@cc.usu.edu> References: <9atfv4$gb0$1@news.tht.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <9atfv4$gb0$1@news.tht.net>; from wweng@kencast.com on Mon, Apr 09, 2001 at 07:22:52PM -0400 X-Archive-Number: 200104/130 X-Sequence-Number: 2477 On Mon, Apr 09, 2001 at 07:22:52PM -0400, Wei Weng wrote: > And I want to get the names of the largest 10 "id"s. How can I do that in > sql? What do you mean by "largest"? Largest id? "largest" text string? If it's the id you can do: select max(id) from ; -Roberto -- +----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+ Roberto Mello - Computer Science, USU - http://www.brasileiro.net http://www.sdl.usu.edu - Space Dynamics Lab, Developer Backup is for whimps! From Michael.Ansley@intec-telecom-systems.com Tue Apr 10 09:23:13 2001 Received: from fileserver002.intecsystems.co.uk ([194.200.14.125]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3A9ND877931 for ; Tue, 10 Apr 2001 05:23:13 -0400 (EDT) (envelope-from Michael.Ansley@intec-telecom-systems.com) Received: from fileserver002.intecsystems.co.uk (unverified) by fileserver002.intecsystems.co.uk (Content Technologies SMTPRS 4.1.5) with ESMTP id ; Tue, 10 Apr 2001 10:30:23 +0100 Received: by fileserver002.intecsystems.co.uk with Internet Mail Service (5.5.2650.21) id <2T32MCC6>; Tue, 10 Apr 2001 10:30:23 +0100 Message-ID: <7F124BC48D56D411812500D0B747251480F51A@fileserver002.intecsystems.co.uk> From: Michael Ansley To: "'Roberto Mello'" , wweng@pobox.com Cc: pgsql-sql@postgresql.org Subject: RE: Sorting and then... Date: Tue, 10 Apr 2001 10:30:22 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative ; boundary="----_=_NextPart_001_01C0C1A0.DDA565CA" X-Archive-Number: 200104/132 X-Sequence-Number: 2479 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0C1A0.DDA565CA Content-Type: text/plain; charset="iso-8859-1" But if you want the largest 10, then you can: SELECT name FROM
ORDER BY id DESC LIMIT 10; assuming that you mean largest numerically. Cheers... MikeA >> -----Original Message----- >> From: Roberto Mello [mailto:rmello@cc.usu.edu] >> Sent: 10 April 2001 03:41 >> To: wweng@pobox.com >> Cc: pgsql-sql@postgresql.org >> Subject: Re: [SQL] Sorting and then... >> >> >> On Mon, Apr 09, 2001 at 07:22:52PM -0400, Wei Weng wrote: >> >> > And I want to get the names of the largest 10 "id"s. How >> can I do that in >> > sql? >> >> What do you mean by "largest"? Largest id? "largest" >> text string? If >> it's the id you can do: >> >> select max(id) from
; >> >> -Roberto >> -- >> +----| http://fslc.usu.edu USU Free Software & GNU/Linux >> Club |------+ >> Roberto Mello - Computer Science, USU - http://www.brasileiro.net >> http://www.sdl.usu.edu - Space Dynamics Lab, Developer >> Backup is for whimps! >> >> ---------------------------(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 >> _________________________________________________________________________ This e-mail and any attachments are confidential and may also be privileged and/or copyright material of Intec Telecom Systems PLC (or its affiliated companies). If you are not an intended or authorised recipient of this e-mail or have received it in error, please delete it immediately and notify the sender by e-mail. In such a case, reading, reproducing, printing or further dissemination of this e-mail is strictly prohibited and may be unlawful. Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free from computer viruses or other defects. The opinions expressed in this e-mail and any attachments may be those of the author and are not necessarily those of Intec Telecom Systems PLC. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. __________________________________________________________________________ ------_=_NextPart_001_01C0C1A0.DDA565CA Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [SQL] Sorting and then...

But if you want the largest 10, then you can:

SELECT name FROM <table> ORDER BY id DESC LIMIT 10;=

assuming that you mean largest numerically.

Cheers...


MikeA



>> -----Original Message-----
>> From: Roberto Mello [mailto:rmello@cc.usu.edu]
>> Sent: 10 April 2001 03:41
>> To: wweng@pobox.com
>> Cc: pgsql-sql@postgresql.org
>> Subject: Re: [SQL] Sorting and then...
>>
>>
>> On Mon, Apr 09, 2001 at 07:22:52PM -0400, Wei W= eng wrote:
>> 
>> > And I want to get the names of the largest= 10 "id"s. How
>> can I do that in
>> > sql?
>>
>>      What do you mean by &q= uot;largest"? Largest id? "largest"
>> text string? If
>> it's the id you can do:
>>
>>      select max(id) from &l= t;table>;
>>
>>      -Roberto
>> --
>> +----| http://fslc.usu.edu USU Free Software & GNU/Linux
>> Club |------+
>>   Roberto Mello - Computer Science, U= SU - http://www.bra= sileiro.net
>>        http://www.sdl.usu.edu = - Space Dynamics Lab, Developer   
>> Backup is for whimps!
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 3: if posting/reading through Usenet, pleas= e send an appropriate
>> subscribe-nomail command to majordomo@postgresq= l.org so that your
>> message can get through to the mailing list cle= anly
>>



_________________________________________________________________________ This e-mail and any attachments are confidential and may also be privileged= and/or copyright
material of Intec Telecom Systems PLC (or its affiliated companies). If yo= u are not an
intended or authorised recipient of this e-mail or have received it in erro= r, please delete
it immediately and notify the sender by e-mail. In such a case, reading, r= eproducing,
printing or further dissemination of this e-mail is strictly prohibited and= may be unlawful.
Intec Telecom Systems PLC. does not represent or warrant that an attachment= hereto is free
from computer viruses or other defects. The opinions expressed in this e-ma= il and any
attachments may be those of the author and are not necessarily those of Int= ec Telecom
Systems PLC.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
__________________________________________________________________________<= BR>
------_=_NextPart_001_01C0C1A0.DDA565CA-- From jdearl@yahoo.com Tue Apr 10 17:42:04 2001 Received: from web10006.mail.yahoo.com (web10006.mail.yahoo.com [216.136.130.42]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3AHg4837107 for ; Tue, 10 Apr 2001 13:42:04 -0400 (EDT) (envelope-from jdearl@yahoo.com) Message-ID: <20010410173213.72791.qmail@web10006.mail.yahoo.com> Received: from [12.18.144.101] by web10006.mail.yahoo.com; Tue, 10 Apr 2001 10:32:13 PDT Date: Tue, 10 Apr 2001 10:32:13 -0700 (PDT) From: Jason Earl Subject: Re: Sorting and then... To: wweng@pobox.com, pgsql-sql@postgresql.org In-Reply-To: <9atfv4$gb0$1@news.tht.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200104/138 X-Sequence-Number: 2485 SELECT name FROM test ORDER BY id DESC LIMIT 10; Take care, Jason --- Wei Weng wrote: > Suppose I have a table > > create table test > ( > id integer, > name text > ); > > And I want to get the names of the largest 10 "id"s. > How can I do that in > sql? > > Thanks! > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the > unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/