Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Subtracting

Author  Topic 

zai
Starting Member

9 Posts

Posted - 2010-09-10 : 09:49:22
Hello all,

I am trying to figure out how to take two working queries and basically combine them.

Query 1:

SELECT [FormID]
FROM [Form].[dbo].[eForm]
Where Status = 'Open' AND Hold_ExtraA = 'Bob' AND Hold = 'No' AND Hold_Media = 'No' AND Hold_Vendor = 'No'

Query 2:

SELECT [FormID]
FROM [Form].[dbo].[eForm]
Where Hold_ExtraA = 'Bob' AND DateRequestDue < GetDate() AND Day(DateRequestDue) != Day(GetDate()) AND ((Hold_Vendor = 'W.Vendor')
OR (Status = 'Open' AND Hold = 'No' AND Hold_Media = 'No' AND Hold_Vendor = 'No'))

What I like to do is build a query that basically substracts the WHERE clause from the first from the second query.

How would I go about doing this?

Much thanks.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-09-10 : 10:35:51
Either use a UNION or just add another OR to your query (you may need to think about the brackets to get them right)..
Go to Top of Page
   

- Advertisement -