Using CASE with a boolean value - Mailing list pgsql-novice

From Tom Ansley
Subject Using CASE with a boolean value
Date
Msg-id 200205240955.04439.tansley@law.du.edu
Whole thread Raw
Responses Re: Using CASE with a boolean value  ("Joel Burton" <joel@joelburton.com>)
Re: Using CASE with a boolean value  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Hi all,

I'm trying to use a case statement with a boolean value.  i.e.  if the value =
false then output 'NO', if value = true then output 'YES'.  This is what I
came up with

CASE booking.quiz
    WHEN booking.quiz=false THEN 'No'
    WHEN booking.quiz=true THEN 'Yes'
    ELSE 'No'
END

But, it isn't working.  Everything compiles and the rows returned are correct
but it still returns 'true' or 'false' rather than 'YES' or 'NO'.  I've also
tried this

CASE booking.quiz
    WHEN booking.quiz='f' THEN 'No'
    WHEN booking.quiz='t' THEN 'Yes'
    ELSE 'No'
END

and this

CASE booking.quiz
    WHEN booking.quiz='false' THEN 'No'
    WHEN booking.quiz='true' THEN 'Yes'
    ELSE 'No'
END

Anybody got any ideas?  Should the value be cast into a string?

Thanks

Tom Ansley

pgsql-novice by date:

Previous
From: Rory Campbell-Lange
Date:
Subject: Re: auto update dates
Next
From: "Joel Burton"
Date:
Subject: Re: Using CASE with a boolean value