Simply use 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:
select name,
(case when credit_code <> 110 then credit_code
when debit_code <> 110 then debit_code
end) as code
from t;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.