如何在SQL Server中减去同一个表中不同列中的两个值 [英] How to subtract two values in SQL server which are in different columns in the same table
本文介绍了如何在SQL Server中减去同一个表中不同列中的两个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql server中减去同一个表中不同列中的两个值
如果我减去列A -B
和BA,并将结果放在新栏目C,D
我尝试了什么:
ABCD
0 1 0 1
1 0 1 0
解决方案
试试这个:
SELECT A,B,AB AS C,BA AS D
FROM YourTable
How to subtract two values in sql server which are in different columns in the same table
if I make subtract column A -B
and B-A, and put the reasult in new columns C,D
What I have tried:
A B C D
0 1 0 1
1 0 1 0
解决方案
Try this:
SELECT A, B, A-B AS C, B-A AS D FROM YourTable
这篇关于如何在SQL Server中减去同一个表中不同列中的两个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文