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!

SQL WHERE statement

Status
Not open for further replies.
Mar 6, 2002
5
0
0
US
I need an SQL WHERE statement that gets all records where Year >= 2001 AND NOT records where (Year = 2003 AND Month = 2). I can not figure out how to write this!...and it seems simple enough!!

I've tried WHERE Year >= 2001 AND (Year <> 2003 AND Month <> 2) but it always wants to remove the groupings and give me no 2003 records and no month 2 data. I've also tried AND NOT but that seems to be losing the groupings as well.

Any ideas are appreciated on this one.

Thanks!
 
Try either:
WHERE Year >= 2001 AND (Year <> 2003 OR Month = 2)
or
WHERE Year >= 2001 AND NOT (Year = 2003 AND Month = 2)

 
Oops. I has a typo. It should be
WHERE Year >= 2001 AND (Year <> 2003 OR Month <> 2)
or
WHERE Year >= 2001 AND NOT (Year = 2003 AND Month = 2)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top