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;
How to use Boolean data type
Moderator: NorbertKrupa
- JimKnicely
- Site Admin
- Posts: 1825
- Joined: Sat Jan 21, 2012 4:58 am
- Contact:
Re: How to use Boolean data type
Hi,
You don't need the LIKE. Try testing against the column only in the WHERE clause. It's a boolean
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)
Jim Knicely
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.