?
Solved

T-SQL Select

Posted on 2013-01-25
7
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 2000 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
PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

 
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

762 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