Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

Here[^].
 
Share this answer
 
Not exactly sure what you mean, but you can exclude certain values using a subquery and either the "IN" operator or the "=" operator:
SQL
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:
SQL
SELECT ID1, SomeCol FROM Table1 WHERE ID1 NOT IN
(SELECT T.ID1 FROM Table1 AS T WHERE T.SomeCol = 'SomeVal')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900