Page 1 of 1

How to use Boolean data type

Posted: Thu Apr 17, 2014 2:43 am
by Jess.mic
Can we use case statement on boolean datatype??

For e.g

case when COALESCE(test.Flag,'T') like 't%' or '%T%' then 1 else 0 end ;

here flag is a column in test table with boolean datatype.
I was trying to this in my etl and I was getting error.

Thanks;

Re: How to use Boolean data type

Posted: Thu Apr 17, 2014 3:51 am
by JimKnicely
Hi,

You don't need the LIKE. Try testing against the column only in the WHERE clause. It's a boolean ;)

Code: Select all

vertica=> create table test(c1 boolean);
CREATE TABLE

vertica=> insert into test values (true);
 OUTPUT 
--------
      1
(1 row)

vertica=> select (case when c1 then 'true' else 'false' end) c1 from test;
  c1  
------
 true
(1 row)