Re: Window function trouble

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Window function trouble
Date: 2009-12-10 21:02:00
Message-ID: puy6la8rw7.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In article <25983(dot)1260468559(at)sss(dot)pgh(dot)pa(dot)us>,
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> The SQL standard says the default name for any output column other
> than a simple column reference is implementation-dependent. I think
> our implementation involves looking at the default value for a CASE.

Thanks for the clarification, Tom - so it's not a PostgreSQL bug, but
a misfeature of the SQL standard.

That being said, I still think that PostgreSQL could do better - how
about naming expression columns so that they are distinct from column
names? The current implementation throws an error e.g. for

SELECT adr,
CASE lag(adr) OVER (ORDER BY adr)
WHEN adr THEN NULL
ELSE adr
END,
usr, count(*)
FROM tbl
WHERE host = 'h1'
GROUP BY adr, usr
ORDER BY adr, usr

namely `ORDER BY "adr" is ambiguous' which I find somewhat confusing.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2009-12-10 23:08:07 Re: Window function trouble
Previous Message Tom Lane 2009-12-10 18:09:19 Re: Window function trouble