Solved

T-SQL Select

Posted on 2013-01-25
7
200 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 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Table where row act as column 11 70
ODBC settings not showng in FileMaker External Data Sources 6 23
Related to SQL Query 5 21
Can a Trigger trigger a Trigger? 4 18
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

733 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