What is the best way to convert an int or null to boolean value in an SQL query?

前端 未结 10 1375
情话喂你
情话喂你 2021-02-06 21:07

What is the best way to convert an int or null to boolean value in an SQL query, such that:

  • Any non-null value is TRUE in the results
  • Any
10条回答
  •  轮回少年
    2021-02-06 21:49

    The syntax works, but I had to figure out how to place it in my query. If OK, I'd like to share an example on how to fit into an extended query:

    select count(*) as count, inventory,
    CASE WHEN inventory = 0 THEN 'empty' ELSE 'not empty' END as InventoryStatus
    from mytable group by count, inventory
    

提交回复
热议问题