Re: top?

From: "SHELTON,MICHAEL (Non-HP-Boise,ex1)" <michael_shelton(at)non(dot)hp(dot)com>
To: "'Christopher Kings-Lynne'" <chriskl(at)familyhealth(dot)com(dot)au>, Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, Richard Rowell <rwrowell(at)bellsouth(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: top?
Date: 2002-01-04 14:40:26
Message-ID: FB60DFB2C0E24449AC0C21F743B935410150F8B0@xboi02.boi.hp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)familyhealth(dot)com(dot)au]
Sent: Thursday, January 03, 2002 7:00 PM
To: Stephan Szabo; Richard Rowell
Cc: pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org

Browse pgsql-sql by date

  From Date Subject
Next Message Unnikrishnan Menon 2002-01-04 14:55:58 Execute dynamically generated query???
Previous Message Bjrn Lundin 2002-01-04 13:28:05 Re: SQL syntax help needed