Order by with column ordinal and collate - fails to parse

From: Tim Kane <tim(dot)kane(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Order by with column ordinal and collate - fails to parse
Date: 2013-06-20 14:05:35
Message-ID: CADVWZZJd5veDpEi_kgzBJ3uRNuE23Zs=x=az_PewssBfmA7TSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I seem to be having problems constructing a query that combines the use of
distinct, order by, and collate key words.

For instance:

# select distinct(value) from properties order by 1 collate "C";
ERROR: collations are not supported by type integer
LINE 1: ... distinct(value) from properties order by 1 collate "C...
^
# select distinct(value) from properties order by distinct(value) collate
"C";
ERROR: syntax error at or near "distinct"
LINE 1: ...ct distinct(value) from properties order by distinct(v...
^
# select distinct(value) as foo from properties order by foo collate "C";
ERROR: column "foo" does not exist
LINE 1: ...tinct(value) as foo from properties order by foo collat...

Am I just being a numpty here? I can work around it with a subquery, but
this seems like a bug to me. Particularly the first example where my
ordinal field reference is treated as an integer literal. I should note
that the field 'value' is of type 'text' (not integer).

Any input appreciated. Thanks :)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alan Hodgson 2013-06-20 14:22:45 Re: Postgres DB crashing
Previous Message Adrian Klaver 2013-06-20 13:52:23 Re: Exporting Data