小编Fut*_*Fan的帖子

有没有办法在 SQL 查询的条件 case 语句中使用 distinct 关键字?

我有一个 SQL 语句,我想在这样的条件 case 语句中使用 distinct 关键字...

SELECT
  case when <condition> then distinct t.myfield
  else
  null
  end as my_field
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试运行查询,则会收到“缺少表达式”错误。

有什么建议?

提前致谢

sql sql-server

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

sql ×1

sql-server ×1