Choose true if greater than 0 in t-sql

I would like to execute a query as a result of which I have a column with false if the value in the previous column is 0 and true if it is greater than 0:

as an example:

id  count
1   1
2   3
3   0
4   5
5   2

result:

id   count
1    true
2    true
3    false
4    true
5    true
+5
source share
2 answers
select 
    id, 
    case 
        when count > 0 then 'true'
        else 'false'
    end as count
from myTable
+9
source
select id
    , case when count > 0 then cast(1 as bit) else cast(0 as bit) end as count
from myTable
+6
source

All Articles