FAQ

Peter Schaefer writes:
codiak=> CREATE VIEW interp AS select DISTINCT ON id id from interp;
What version are you using? The current development sources don't like
the above at all:

regression=> CREATE VIEW interp AS select DISTINCT ON id id from interp;
ERROR: Relation 'interp' does not exist
regression=> create table interp (id int);
CREATE
regression=> CREATE VIEW interp AS select DISTINCT ON id id from interp;
ERROR: Relation 'interp' already exists
regression=> CREATE VIEW interp1 AS select DISTINCT ON id id from interp;
ERROR: DISTINCT not supported in views

The reason for the last point is that DISTINCT requires sorting, and
the current implementation method for views doesn't allow a view to
specify an ordering. (CREATE VIEW ... SELECT ... ORDER BY doesn't
work either.)

You can work around this to some extent by using GROUP BY:

regression=> CREATE VIEW interp1 AS select id from interp group by id;
CREATE

although I think there may be some restrictions on grouped views too.

regards, tom lane

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
grouppgsql-bugs @
categoriespostgresql
postedOct 13, '99 at 8:38a
activeOct 14, '99 at 7:41a
posts3
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Peter Schaefer: 2 posts Tom Lane: 1 post

People

Translate

site design / logo © 2023 Grokbase