Solved

T-SQL Select

Posted on 2013-01-25
7
201 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

707 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