Sql boolean 0/1 To represent true or False

In my database, 1 is used to represent true and 0 to represent false. In my column, I was now wondering if anyone can help me write a query that displays if the value is 1, displays true, if it is 0, displays false ?.

+6
source share
2 answers

Try using case

 select case when col = 1 then 'true' when col = 0 then 'false' else 'NN' end as val 
+9
source
 select case when your_bool_column = 1 then 'true' else 'false' end as bool_col from your_table 
+1
source

Source: https://habr.com/ru/post/953302/


All Articles