【发布时间】:2017-04-06 22:15:07
【问题描述】:
我正在尝试从 oracle 数据库中选择一个不同的列,我的代码是:
select ID,distinct case when DM='ST1B' then MC else DM end from D_DZDY
但是,它不起作用。如果我删除“distinct”,它会起作用: enter image description here
任何人都可以帮助我解决这个问题吗?非常感谢! :D
【问题讨论】:
-
您使用的
DISTINCT语法错误。请提供一些虚拟数据以及您的预期结果。 -
您在寻找
select distinct ID,case when DM='ST1B' then MC else DM end from D_DZDY;吗? -
如果您有 10 行具有相同的 CASE 值,您希望看到什么 ID?