with t1 as ( select NUll as col1, '' as col2, 'aaa' as col3 ) --关于COALESCE用法 当col1 为 null时候返回 col2 依次类推 当col2 为 null时 返回col3
--很多朋友会以为这里返回col3 其实不是。那么怎么才能返回想要的结果col3, 搭配nullif函数即可
--select COALESCE(col1, col2, col3) from t1 select COALESCE(nullif(col1,''), nullif(col2,''), nullif(col3,'')) from t1