From: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Convert boolean field to a 0 or a 1 in a select statement |
Date: | 2015-01-09 17:18:03 |
Message-ID: | 1420823883854-5833422.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
JORGE MALDONADO wrote
> I have a SELECT statement which contains a boolean field. The result of
> this query must display '0' for false or '1' for true. I will be
> generating
> a text file with this information and a zero or a one is required. I have
> tried using the CASE statement without success.
>
> CAST(fce_subdivision as CHAR) AS fce_subdivision_aux,
> CASE CAST(fce_subdivision as CHAR)
> WHEN 'f' THEN '0'
> WHEN 't' THEN '1'
> END
>
> I will very much appreciate your feedback.
>
> Respectfully,
> Jorge Maldonado
One of us is missing something because this is the direct application of
your requirement as stated:
CASE WHEN fce_subdivision THEN '1' ELSE '0' END
David J.
--
View this message in context: http://postgresql.nabble.com/Convert-boolean-field-to-a-0-or-a-1-in-a-select-statement-tp5833411p5833422.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Ravi Kiran | 2015-01-11 14:53:02 | Hash function |
Previous Message | Steve Crawford | 2015-01-09 17:15:37 | Re: Upgrade Ubuntu - PostgresSQL is ok? |