From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joseph Shraibman <jks@selectacast.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: possible bug with group by?
Date: Wed, 24 May 2000 19:07:47 -0400
Message-ID: <13008.959209667@sss.pgh.pa.us> (raw)
In-Reply-To: <392C5819.2FD488A8@selectacast.net>
References: <392C5819.2FD488A8@selectacast.net>
Joseph Shraibman <jks@selectacast.net> writes:
> playpen=> select a, b, case when c is null then 'not set' else 'set' end
> as z from tablea group by a, b, z;
> ERROR: Unable to identify an operator '<' for types 'unknown' and 'unknown'
> You will have to retype this query using an explicit cast
It's not GROUP BY's fault, it's just the oft-repeated issue about
quoted string literals not having any definite type in Postgres.
The parser postpones assigning a type until it sees the literal used
in a context where a type can be determined --- and in a case like
this, it never can. You need to force the issue with a cast, eg
select a, b,
case when c is null then 'not set'::text else 'set'::text end as z
from tablea group by a, b, z;
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, jks@selectacast.net
Subject: Re: possible bug with group by?
In-Reply-To: <13008.959209667@sss.pgh.pa.us>
References: <392C5819.2FD488A8@selectacast.net> <13008.959209667@sss.pgh.pa.us>
* 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