Re: ordering error in query?

From: ljb <lbayuk(at)mindspring(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ordering error in query?
Date: 2002-06-27 01:01:38
Message-ID: afdo5i$mqn$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

smarie(at)ekno(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff MacDonald 2002-06-27 01:02:26 Re: Advocacy Idea.
Previous Message Martijn van Oosterhout 2002-06-26 23:28:47 Re: Strange behaviour of SELECT ... IN