Solved

T-SQL Select

Posted on 2013-01-25
7
194 Views
Last Modified: 2013-01-26
I am using T-SQL (SQL Server 2000) and I want to exclude customers who meet two different criteria simultaneously.  For example below:
Select * from Customers
where
State = 'New York'
and
PurchaseDate <'2012-10-01'
The problem is I don't want to exclude all Customers who state = 'New York'
only those customers that meet both criteria do I want to exclude.  Any ideas on how to do this?  Thanks for the help.
0
Comment
Question by:fjkaykr11
  • 4
  • 3
7 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 38821201
You speak of excluding New York but the current SQL selectsd only New York and where the Pruchase date is < 2012-10-01. Please clarify
0
 
LVL 3

Author Comment

by:fjkaykr11
ID: 38821251
sorry I meant to write this with
State <>'New York'
0
 
LVL 3

Author Comment

by:fjkaykr11
ID: 38821264
I think I figured it out.  Please advise if this is correct
Select * from Customers
where not (State = 'New York' and PurchaseDate <'2012-10-01')
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 38821276
Yes, That would have been what I would have suggested - will give you everyone other that those in New York with a purchase date prior to 1 October last year.


Kelvin
0
 
LVL 3

Author Comment

by:fjkaykr11
ID: 38822840
I've requested that this question be closed as follows:

Accepted answer: 0 points for fjkaykr11's comment #a38821264
Assisted answer: 250 points for kelvinsparks's comment #a38821201
Assisted answer: 250 points for kelvinsparks's comment #a38821276

for the following reason:

thanks
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 38821383
That doesn't need a close request - just accept and share the points to my solutions. This closes the question.

Kelvin
0
 
LVL 3

Author Closing Comment

by:fjkaykr11
ID: 38822841
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now