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.