Search Postgresql Archives

Re: Top N within groups?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martijn van Oosterhout wrote:
On Fri, Jul 11, 2008 at 01:24:28PM +1000, Klint Gore wrote:
> [thinking out loud]
> Can someone familiar with the source for DISTINCT ON comment on how hard > it would be to add another parameter to return more than one row?
From a programming point of view, it wouldn't be too hard. However,
deciding what syntax to use is a another question entirely. I think
your suggestion of FOR isn't good (ambiguous syntax, 'for' could be a
column name), but I can't think of a better one.
'for' is a reserved key word so can't be a column name.

http://www.postgresql.org/docs/8.3/interactive/sql-keywords-appendix.html

postgres=# create table foo (for int);
ERROR:  syntax error at or near "for"

The worst I think you could get would be
 select distinct on ("for") for 4 "for" from table4 for update;

but even then, I think the parser could work out what you want.

klint.

--
Klint Gore
Database Manager
Sheep CRC
A.G.B.U.
University of New England
Armidale NSW 2350

Ph: 02 6773 3789 Fax: 02 6773 3266
EMail: kgore4@xxxxxxxxxx



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux