How do I 'subtract' sql tables?

Viewed 58700

Its not really a subtraction I'm looking for. And I know its not a union or intersection... I have been given a long and complex stored procedure that returns a table of active and inactive documents. I have also been given a similar stored procedure that returns another table that contains only the active documents.

How could I get a table of inactive documents using these two store procedures?

We are using SQL Server 2005.

14 Answers
SELECT roll_number FROM profile WHERE(catagory='Attest and Eat' or catagory='Live and Eat') and status='OK' EXCEPT SELECT roll_number from meal_status  WHERE date='29' AND month='1'

You can try this kind of command to subtract a table from another one.

if you are substracting a percentage and updating a table use this

UPDATE `TABLENAME` SET `COLUMNNAME` = (50 / 100) * `COLUMNNAME`;

please note that the (50 / 100) is for 50% so in this case this query will discount 50% from the total value of the row!

Related