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

* top?
@ 2002-01-03 23:27 Richard Rowell <rwrowell@bellsouth.net>
  2002-01-03 23:48 ` Re: top? Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Richard Rowell @ 2002-01-03 23:27 UTC (permalink / raw)
  To: pgsql-sql

Just wondering if there was a "TOP" equivilant in Postgres?  
IE 
select top 1 * from froo
(only returns 1 row)

TIA
-- 

_________________________
Richard Rowell
rwrowell@bellsouth.net

If Java had true garbage collection, most programs would delete themselves 
upon execution. - Robert Sewell 




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

* Re: top?
  2002-01-03 23:27 top? Richard Rowell <rwrowell@bellsouth.net>
@ 2002-01-03 23:48 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2002-01-04 01:59   ` Re: top? Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 1 reply; 4+ messages in thread

From: Stephan Szabo @ 2002-01-03 23:48 UTC (permalink / raw)
  To: Richard Rowell <rwrowell@bellsouth.net>; +Cc: pgsql-sql


On Thu, 3 Jan 2002, Richard Rowell wrote:

> Just wondering if there was a "TOP" equivilant in Postgres?
> IE
> select top 1 * from froo
> (only returns 1 row)

select * from froo limit 1;

Usually you'll want to order as well so that you get a meaningfully
chosen row rather than whatever row happens to be scanned first.





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

* Re: top?
  2002-01-03 23:27 top? Richard Rowell <rwrowell@bellsouth.net>
  2002-01-03 23:48 ` Re: top? Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2002-01-04 01:59   ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 0 replies; 4+ messages in thread

From: Christopher Kings-Lynne @ 2002-01-04 01:59 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; Richard Rowell <rwrowell@bellsouth.net>; +Cc: pgsql-sql

> On Thu, 3 Jan 2002, Richard Rowell wrote:
>
> > Just wondering if there was a "TOP" equivilant in Postgres?
> > IE
> > select top 1 * from froo
> > (only returns 1 row)
>
> select * from froo limit 1;
>
> Usually you'll want to order as well so that you get a meaningfully
> chosen row rather than whatever row happens to be scanned first.

Actually I think its essential that he orders it.  I think the 'top' thing
is a microsoft-ism that gets the 'top 10 items' say from a column.  I can't
remember if it's the 10 with the highest values or the ten with the most
common values...

Chris




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

* Re: top?
@ 2002-01-04 14:40 SHELTON,MICHAEL (Non-HP-Boise,ex1) <michael_shelton@non.hp.com>
  0 siblings, 0 replies; 4+ messages in thread

From: SHELTON,MICHAEL (Non-HP-Boise,ex1) @ 2002-01-04 14:40 UTC (permalink / raw)
  To: 'Christopher Kings-Lynne' <chriskl@familyhealth.com.au>; Stephan Szabo <sszabo@megazone23.bigpanda.com>; Richard Rowell <rwrowell@bellsouth.net>; +Cc: pgsql-sql

TOP works exactly like LIMIT.  In MS SQL you get whatever the first n rows
are returned (no particular order guaranteed).  So unless you want garbage
you have to order your results.

Mike

-----Original Message-----
From: Christopher Kings-Lynne [mailto:chriskl@familyhealth.com.au]
Sent: Thursday, January 03, 2002 7:00 PM
To: Stephan Szabo; Richard Rowell
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] top?


> On Thu, 3 Jan 2002, Richard Rowell wrote:
>
> > Just wondering if there was a "TOP" equivilant in Postgres?
> > IE
> > select top 1 * from froo
> > (only returns 1 row)
>
> select * from froo limit 1;
>
> Usually you'll want to order as well so that you get a meaningfully
> chosen row rather than whatever row happens to be scanned first.

Actually I think its essential that he orders it.  I think the 'top' thing
is a microsoft-ism that gets the 'top 10 items' say from a column.  I can't
remember if it's the 10 with the highest values or the ten with the most
common values...

Chris


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org



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


end of thread, other threads:[~2002-01-04 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-01-03 23:27 top? Richard Rowell <rwrowell@bellsouth.net>
2002-01-03 23:48 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-01-04 01:59   ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2002-01-04 14:40 Re: top? SHELTON,MICHAEL (Non-HP-Boise,ex1) <michael_shelton@non.hp.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