首页 > 解决方案 > How to check if BOTH valus are null

问题描述

I have table A

lets say it has 2 columns where the values can either be null or a number. I want to select only rows that have at least one of the columns not null:

x1   x2
NULL NULL (don't include)
6    NULL (include)
NULL 6    (include)
6    6    (include)

标签: sql

解决方案


You can use coalesce()

where coalesce(col1,col2) is not null

推荐阅读