【发布时间】:2021-10-28 20:12:43
【问题描述】:
我试图获得一个输出,当没有空值时,例如'Private' 列中的 '1,2,and3' 'Name' 列返回 'Name Suppressed'
我知道以下查询有效:
case when AM.Private is null then Name1 else 'Name Suppressed' end as Name1, Private
from AM
但我现在有多个列的名称需要隐藏。
我试过了:
select case when AM.Private is null then Name1 or Name2 else 'Name Suppressed' end as Name1, Name2, Private
from AM
和
select case when AM.Private is null then Name 1 then case when AM.Private is null then Name 2 else 'Name Suppressed' end as Name1, Name2, Private
from AM
有谁知道我做错了什么?
【问题讨论】:
-
表格格式的所需结果真的很有帮助。
标签: sql sql-server tsql case