pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Harald Fuchs <hari.fuchs@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Window function trouble
Date: Thu, 10 Dec 2009 22:02:00 +0100
Message-ID: <puy6la8rw7.fsf@srv.protecting.net> (raw)
References: <pud42mahnr.fsf@srv.protecting.net>
	<pu7hsuafcq.fsf@srv.protecting.net>
	<25983.1260468559@sss.pgh.pa.us>

In article <25983.1260468559@sss.pgh.pa.us>,
Tom Lane <tgl@sss.pgh.pa.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.




view thread (6+ messages)  latest in thread

Message-ID: <puy6la8rw7.fsf@srv.protecting.net>
Permalink:  ../puy6la8rw7.fsf@srv.protecting.net/
Also on:    postgresql.org/message-id/puy6la8rw7.fsf@srv.protecting.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hari.fuchs@gmail.com
  Subject: Re: Window function trouble
  In-Reply-To: <puy6la8rw7.fsf@srv.protecting.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox