[英]SQL Query Merge 2 Columns Into 1 Column By Eliminating Selected Value
Simply use case
.简单的用
case
。 For your data, this seems to work:对于您的数据,这似乎有效:
select name,
(case when credit_code = 110 then debit_code else credit_code end)
from t;
If both could be 110
, then you would want:如果两者都可以是
110
,那么你会想要:
select name,
(case when credit_code <> 110 then credit_code
when debit_code <> 110 then debit_code
end) as code
from t;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.