SELECT TOP 1000 [chClientCode]
      ,[nvcClientName]
      ,[chRegionCode]
      ,isnull(chUltimateHeadClientCode,[chClientCode]) as chUltimateHeadClientCode
  FROM [PwCMDM_V1].[Core].[tblClient]

 

Define:

isnull(expression,replacement_value)

 

[*] 使用时候发现一个问题,就是如果expression的长度小于replacement_value 系统会自动截取replacement_value 得到的结果肯定不正确. 所以使用起来还是有局限性的.

最后还是使用 CASE ... WHEN ... THEN... 的方式来实现的. 

SELECT TOP 1000 [chClientCode]
      ,[nvcClientName]
      ,[chRegionCode]
      ,CASE isnull(cl.chUltimateHeadClientCode,'') WHEN '' THEN cl.chClientCode ELSE cl.chUltimateHeadClientCode END as UHCCode
  FROM [PwCMDM_V1].[Core].[tblClient]

 

相关文章:

  • 2021-05-20
  • 2021-06-11
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案