COALESCE

返回其参数中的第一个非空表达式,当你要在n个字段中选取某一个非空值可以用它,比如下面语句

 

1SQL2005一个不起眼但很实用的函数select Coalesce(null,null,1,2,null)union
2SQL2005一个不起眼但很实用的函数select Coalesce(null,11,12,13,null)union
3SQL2005一个不起眼但很实用的函数select Coalesce(111,112,113,114,null)

 

 

/*---返回结果-----

1
11
111

-----------------*/

而与他等价的case when嵌套需要一大堆代码

 

相关文章:

  • 2022-02-16
  • 2021-06-11
  • 2022-12-23
  • 2021-12-03
  • 2021-06-07
  • 2021-07-23
猜你喜欢
  • 2021-12-12
  • 2021-12-25
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案