Re: Support for SQL TOP clause? - Mailing list pgsql-sql

From Richard Broersma Jr
Subject Re: Support for SQL TOP clause?
Date
Msg-id 554372.7292.qm@web31811.mail.mud.yahoo.com
Whole thread Raw
In response to Support for SQL TOP clause?  ("Chinyi Woo" <chinyi.woo@gmail.com>)
List pgsql-sql
--- On Wed, 1/9/08, Chinyi Woo <chinyi.woo@gmail.com> wrote:

> Does Postgresql support query like SELECT *TOP 3* * FROM
> Individual  ? If I use ORDER BY, I have to write non-sql
> code to get the first row in the result set, which I try
> to avoid.

As you have seen, PostgreSQL's implementation of LIMIT predicate can produce the same results as TOP.

This is another way to get these results using neither TOP or Limit, but the query will probably not perform as
quickly.
   SELECT I1.name, ...     FROM Individual AS I1
INNER JOIN Individual AS I2       ON I1.name < I2.name    WHERE --any where criteria you might have GROUP BY I1.name,
...  HAVING COUNT(*) < 3 ORDER BY I1.name;
 

Regards,
Richard Broersma Jr.


pgsql-sql by date:

Previous
From: Reinoud van Leeuwen
Date:
Subject: Re: Support for SQL TOP clause?
Next
From: Gerardo Herzig
Date:
Subject: Re: trigger for TRUNCATE?