Re: ordering error in query? - Mailing list pgsql-general

From ljb
Subject Re: ordering error in query?
Date
Msg-id afdo5i$mqn$1@news.hub.org
Whole thread Raw
In response to ordering error in query?  (s <smarie@ekno.com>)
List pgsql-general
smarie@ekno.com wrote:
> ...
> select distinct f.id, '' from foo f;
>
> I need the empty string as the second attribute because the first part
> of the union has a second attribute.  This works on oracle, but
> postgres says:
>
> ERROR:  Unable to identify an ordering operator '<' for type 'unknown'
>         Use an explicit ordering operator or modify the query
>...
> Suggestions?

   select distinct on (f.id) f.id,'' from foo f;
But "distinct on" is non-standard and Oracle probably won't like it.

Weird-looking, but more likely to work:
   select distinct f.id, ''||'' from foo f;
or even:
   select distinct f.id, tolower('') from foo f;
Either of which seems enough to convince PostgreSQL that we're dealing
with a character type.

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Strange behaviour of SELECT ... IN
Next
From: Ben
Date:
Subject: Re: Advocacy Idea.