case with distinct

Started by Merrill Ovesonover 25 years ago2 messagesbugs
Jump to latest
#1Merrill Oveson
merrill@actarg.com

This works:
select
orgid,
case when status = 'y' then '1' else '0' end
from vend

This doesn't:
select distinct
orgid,
case when status = 'y' then '1' else '0' end
from vend

The only difference is the absence of distinct clause.
bug?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Merrill Oveson (#1)
Re: case with distinct

Merrill Oveson <merrill@actarg.com> writes:

This doesn't:
select distinct
orgid,
case when status = 'y' then '1' else '0' end
from vend

Try

select distinct
orgid,
case when status = 'y' then '1'::text else '0'::text end
from vend

7.1 is less picky about unknown-type constants...

regards, tom lane