pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Sorting and then...
4+ messages / 4 participants
[nested] [flat]

* Sorting and then...
@ 2001-04-09 23:22  Wei Weng <wweng@kencast.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Wei Weng @ 2001-04-09 23:22 UTC (permalink / raw)
  To: pgsql-sql

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!




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Sorting and then...
@ 2001-04-10 02:40  Roberto Mello <rmello@cc.usu.edu>
  parent: Wei Weng <wweng@kencast.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Roberto Mello @ 2001-04-10 02:40 UTC (permalink / raw)
  To: wweng@pobox.com; +Cc: pgsql-sql

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 <table>;

	-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!



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: Sorting and then...
@ 2001-04-10 09:30  Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Ansley @ 2001-04-10 09:30 UTC (permalink / raw)
  To: 'Roberto Mello' <rmello@cc.usu.edu>; wweng@pobox.com; +Cc: pgsql-sql

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 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 <table>;
>> 
>> 	-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. 
__________________________________________________________________________

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Sorting and then...
@ 2001-04-10 17:32  Jason Earl <jdearl@yahoo.com>
  parent: Wei Weng <wweng@kencast.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Jason Earl @ 2001-04-10 17:32 UTC (permalink / raw)
  To: wweng@pobox.com; pgsql-sql

SELECT name FROM test ORDER BY id DESC LIMIT 10;

Take care,
Jason


--- Wei Weng <wweng@kencast.com> 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/



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-04-10 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-09 23:22 Sorting and then... Wei Weng <wweng@kencast.com>
2001-04-10 02:40 ` Roberto Mello <rmello@cc.usu.edu>
2001-04-10 17:32 ` Jason Earl <jdearl@yahoo.com>
2001-04-10 09:30 RE: Sorting and then... Michael Ansley <Michael.Ansley@intec-telecom-systems.com>

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