sql中的行减法 [英] subtraction of rows in sql
本文介绍了sql中的行减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以说出如何在t-sql中将表的一个行值与同一表的其他行值相减
谢谢您
can somebody tell how to subtract one row values of the table with the other row values of the same table in t-sql
thanking you
推荐答案
^ ].
不确定您的意思,但是您可以使用子查询和"IN"运算符或"="运算符:
Not exactly sure what you mean, but you can exclude certain values using a subquery and either the "IN" operator or the "=" operator:
SELECT ID1, SomeCol FROM Table1
WHERE ID1 NOT IN (SELECT ID2 FROM Table2)
您可以根据需要在子查询中放置条件.您也可以使子查询用于同一张表.例如:
You could put where conditions on the subquery if you want. You could also make the subquery be for the same table. For example:
SELECT ID1, SomeCol FROM Table1 WHERE ID1 NOT IN
(SELECT T.ID1 FROM Table1 AS T WHERE T.SomeCol = 'SomeVal')
这篇关于sql中的行减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文