Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude data from a query

Status
Not open for further replies.

smatthews

IS-IT--Management
Jul 27, 2001
108
0
0
US
I am trying to create a query that would eliminate records from the second query if they are selected in the first query.

Here is my query:
select *
from activity
where product_code between 'committee/104' and 'committee/199'
and thru_date >= getdate()
and action_codes = 'm'
UNION ALL
select *
from activity
where product_code between 'committee/104' and 'committee/199'
and thru_date >= getdate()
and action_codes = 'a'

order by product_code

In other words, if the first query finds an 'm' action_code for a specific product_code then I want to eliminate them from the second query. Any help would be greatly appreaciated.

Thanks
 
In fact what your query does is the following:

select *
from activity
where product_code between 'committee/104' and 'committee/199'
and thru_date >= getdate()
and action_codes in ('m','a')
order by product_code

What exactly you want to do?
 
If there is no action code of 'm' for any given product_code retrieved then I want to retrive the records with an 'a' action code.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top