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

前端 未结 10 1362
情话喂你
情话喂你 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:45

    SELECT 
        CASE
            WHEN thevalue IS NULL THEN 0
            ELSE 1
        END AS newVal
    FROM .... (rest of select)
    

    I think it goes something like this

    Actually, the ISNULL, may need to be WHEN thevalue IS NULL THEN 0

提交回复
热议问题