pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aymeric Levaux <aymeric@javablackbelt.com>
To: pgsql-sql@postgresql.org
Subject: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
Date: Sun, 04 Nov 2007 17:49:02 +0100
Message-ID: <472DF7FE.1050504@javablackbelt.com> (raw)

On pgsql 8.2, if you do the following query, everything is fine:

SELECT DISTINCT tag FROM logs ORDER BY tag;

But if you'd like to do a case insensitive order by like this:

SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag);

or

SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag);

You get the following error message :
for SELECT DISTINCT, ORDER BY expressions must appear in select list.

It is weird as the order by column appears in the select.

Any thoughts?

-- 
Aymeric Levaux
<http://www.javablackbelt.com;

view thread (2+ messages)  latest in thread

Message-ID: <472DF7FE.1050504@javablackbelt.com>
Permalink:  ../472DF7FE.1050504@javablackbelt.com/
Also on:    postgresql.org/message-id/472DF7FE.1050504@javablackbelt.com

 · 

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: aymeric@javablackbelt.com
  Subject: Re: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails
  In-Reply-To: <472DF7FE.1050504@javablackbelt.com>

* 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