将EntryDate(列)转换为NULL,如果Country(列)是Gabon

huangapple go评论76阅读模式
英文:

SQL to convert EntryDate (column) to NULL if Country (column) is Gabon

问题

我正在寻找正确执行以下操作的SQL代码。在国家为Gabon的情况下,我在将现有日期值转换为NULL方面遇到了困难。感谢任何帮助。

CASE 
    WHEN COUNTRY = 'GABON' 
        THEN NULL 
    ELSE ENTRYDATE 
END AS ENTRYDATE
英文:

I am looking for SQL code to do the following correctly. I am struggling converting the existing date value to NULL in the case where the country is Gabon. Any help appreciated.

CASE 
    WHEN COUNTRY = 'GABON' 
        THEN ENTRYDATE IS NULL 
END AS ENTRYDATE

CASE 
    WHEN COUNTRY = 'GABON' 
        THEN ENTRYDATE IS NULL 
END AS ENTRYDATE

答案1

得分: 0

CASE WHEN条件正确格式化。

CASE WHEN COUNTRY = '加蓬' THEN cast(null as Datetime) ELSE ENTRYDATE END AS ENTRYDATE

注意:根据ENTRYDATE列的数据类型进行转换。

英文:

Format CASE WHEN condition properly.

CASE WHEN COUNTRY = 'GABON' THEN  cast(null as Datetime) ELSE ENTRYDATE END AS ENTRYDATE

Note: Cast The data Type Based on ENTRYDATE Column

huangapple
  • 本文由 发表于 2023年7月11日 13:53:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76659013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定