将表拆分为正值和负值 [英] Split the Table into positive and negative values
本文介绍了将表拆分为正值和负值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
输入表
-----------
Id值
1 500
2 -250
输出应该是
id positives否定
1 500 NULL
2 NULL -250
Input Table
-----------
Id Value
1 500
2 -250
output should be
id positives negatives
1 500 NULL
2 NULL -250
推荐答案
试试这个
try this
select a.id,
"posit" = case
when a.value > 0 then 'pos'
else null
end ,
"negat" = case
when a.value < 0 then 'neg'
else null
end
from table a ;
这篇关于将表拆分为正值和负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文