pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bernd von den Brincken <bvdb@asa.de>
To: pgsql-sql@postgresql.org
Subject: Named column in a Function fails at ORDER BY (PgSQL 7.1)
Date: Wed, 03 Apr 2002 21:15:44 +0200
Message-ID: <5.1.0.14.2.20020403211109.01cf5e40@pop.kundenserver.de> (raw)

Hello,
on the occasion of a subselect I found a behavior in PostgreSQL 7.1 that I 
consider faulty, but would like to hear comments before complaining to the 
hackers:

It seems that pgsql can not use a named result column in a function for 
ORDER BY. The same named result column can be used in an ORDER BY clause a) 
directly, _without_ the function or b) _with_ the same function but with 
the _original_ column name.

Here is the example - this fails with "ERROR: Attribute 'max_date' not found":

	SELECT content, datetime AS max_date
  			FROM cftext
			ORDER by date_part('hour', max_date)

Whereas this works both:
a) 	SELECT content, datetime AS max_date
  			FROM cftext
			ORDER by  max_date

b)	SELECT content, datetime AS max_date
  			FROM cftext
			ORDER by date_part('hour', datetime)

Now in this example the alternative works fine, but if you use a Sub-SELECT 
there is no alternative to a named result column. I posted the simple 
example here to focus on the issue.
- Thanks for any hints -
// Bernd vdB




view thread (2+ messages)  latest in thread

Message-ID: <5.1.0.14.2.20020403211109.01cf5e40@pop.kundenserver.de>
Permalink:  ../5.1.0.14.2.20020403211109.01cf5e40@pop.kundenserver.de/
Also on:    postgresql.org/message-id/5.1.0.14.2.20020403211109.01cf5e40@pop.kundenserver.de

 · 

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: bvdb@asa.de
  Subject: Re: Named column in a Function fails at ORDER BY (PgSQL 7.1)
  In-Reply-To: <5.1.0.14.2.20020403211109.01cf5e40@pop.kundenserver.de>

* 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