Skip site navigation (1) Skip section navigation (2)

Re: BUG #5018: Window function alias

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5018: Window function alias
Date: 2009-08-27 13:19:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Marko Tiikkaja wrote:
> I came across this:
> => SELECT lead(foo) OVER(ORDER BY foo) AS foo FROM (VALUES(0)) bar(foo);
> ERROR:  window functions not allowed in window definition
> Changing the *column alias* to something else gives the expected answer. Is
> this really the desired behaviour?

It makes sense if you refer another column:

SELECT foo*2 AS col1, lead(foo) OVER(ORDER BY col1) AS foo
FROM (VALUES(0), (1)) bar(foo);

I'm not sure what the SQL spec says about that, but it seems OK to me.

  Heikki Linnakangas

In response to


pgsql-bugs by date

Next:From: Tom LaneDate: 2009-08-27 14:29:37
Subject: Re: BUG #5018: Window function alias
Previous:From: Ashesh VashiDate: 2009-08-27 11:31:03
Subject: Re: BUG #5015: MySQL migration wizard does not start

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group