Decode() 对应 case when函数

case CHARINDEX('/',start_point_name)

when 0 then start_point_name

else substring(start_point_name,1,CHARINDEX('/',start_point_name)-1)

end

注意:sqlserver在用case when判断是否为null时,语法不一样

判断null应该用:

case when identifier is null then airway_point_name else identifier  end,

最简单的办法就是用isnll函数 isnull(idenfier, airway_point_name)

不行!isnull(idenfier, airway_point_name)会将idenfier缩短,本来5个字符,替换后只有4个字符,原因未知,最好不用isnull

 

instr对应CHARINDEX('/',start_point_name)函数,只不过两个参数的含义正好颠倒,也是从1开始计数

 

substr对应substring 参数完全一样,但长度参数不能缺少,不能默认到末尾,只能给一个足够大的长度值。

 

replace函数则完全一样

 

length函数对应 len函数

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-06-08
猜你喜欢
  • 2022-12-23
  • 2021-07-05
  • 2021-06-20
  • 2021-04-10
  • 2021-08-03
  • 2022-02-27
相关资源
相似解决方案