BUG Report - Select distinct on

Поиск
Список
Период
Сортировка
Искать

BUG Report - Select distinct on

От:
Dirk Elmendorf <delmendo@rackspace.com>
Дата:
============================================================================
                         POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name		:	Dirk Elmendorf
Your email address	: delmendo@rackspace.com


System Configuration
---------------------
   Architecture (example: Intel Pentium)  	: Intel Pentium

   Operating System (example: Linux 2.0.26 ELF) 	:RedHat Linux 6.1/ 2.2.12-20
   PostgreSQL version (example: PostgreSQL-6.5.1):   PostgreSQL-7.0
   Compiler used (example:  gcc 2.8.0)		:	egcs-2.9.66


Please enter a FULL description of your problem:
------------------------------------------------
Can not use the select distinct sql statement.






Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
create table test
(
	label text
);

select distinct on label label from test;

ERROR:parser: parse error at or near "label";
select label from test;
label
---------
(0 rows)




If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------


-- 
______________________________________________________________________
Dirk Elmendorf, CTE                                Main: 210-892-4000
Rackspace,Ltd.                                   Direct: 210-892-4005
Weston Center                                       Fax: 210-892-4329
112 East Pecan, Suite 600                Email:delmendo@rackspace.com
San Antonio,  TX 78205                     

Re: BUG Report - Select distinct on

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Dirk Elmendorf  writes:
> select distinct on label label from test;

> ERROR:parser: parse error at or near "label";

The syntax is different in 7.0.  Try

select distinct on (label) label from test;

Sorry about the loss of backwards compatibility, but this lets you
select distinct on expressions and even multiple expressions, which
wasn't possible with the old column-name-only syntax...

			regards, tom lane
FAQ