SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 28th, 2009, 02:13 PM
km1976 km1976 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 19 km1976 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 36 sec
Reputation Power: 0
Query - General - Data Exceptions

I believe I am in the right place for this question. I have a join query built in SQL and need to add some exceptions to it. Problem is, it is a little advanced for me. Hopefully someone can help me with it.

Ok here is the original code:

SELECT SENT_MCR.*, IDX_LOG.*
FROM SENT_MCR LEFT JOIN IDX_LOG ON (Left(SENT_MCR.Patient_Name,11)=Left(IDX_LOG.Patie nt_Name,11)) AND (SENT_MCR.DOS=IDX_LOG.DOS) AND (SENT_MCR.Procedure=IDX_LOG.Procedure);

Now I need to add some exceptions to the Procedure section. What would I need to do so that any procedures beginning with the letters A, Q, and any Procedures that end with the letter F are excluded from the output? These procedures appear in the SENT_MCR file only (if that info makes any difference).

Any help is much appreciated
Sean

Reply With Quote
  #2  
Old September 28th, 2009, 02:20 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2005
Location: Dreamland
Posts: 13,237 mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 5 Months 1 Day 20 h
Reputation Power: 2012
add a WHERE clause after your join ... try something like this.
Code:
SELECT SENT_MCR.*, IDX_LOG.*
FROM SENT_MCR 
LEFT JOIN IDX_LOG 
     ON (Left(SENT_MCR.Patient_Name,11)=Left(IDX_LOG.Patie   nt_Name,11)) 
     AND (SENT_MCR.DOS=IDX_LOG.DOS) 
     AND (SENT_MCR.Procedure=IDX_LOG.Procedure)
WHERE Left(SENT_MCR.Procedure,1) NOT IN ('A','F')
OR Right(SENT_MCR.Procedure,1) <> 'F';
__________________
Come JOIN the party!!!

Quote of the Month:
Pretension: The downside of being better than everyone else is that people tend to assume you're pretentious.

Questions to Ponder:
You can be overwhelmed and underwhelmed, but why can't you be simply whelmed?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
  #3  
Old September 28th, 2009, 02:45 PM
km1976 km1976 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 19 km1976 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 36 sec
Reputation Power: 0
Thank you for the quick response mehere, however this is not resolving my issue. After applying your additions I am still pulling Procedures that begin with A, and Q as well as Procedures ending with F.

Reply With Quote
  #4  
Old September 28th, 2009, 04:33 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2005
Location: Dreamland
Posts: 13,237 mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 5 Months 1 Day 20 h
Reputation Power: 2012
try changing the OR to an AND ...

Reply With Quote
  #5  
Old September 29th, 2009, 09:11 AM
km1976 km1976 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 19 km1976 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 36 sec
Reputation Power: 0
I use this:

WHERE (((Left([SENT_MCR_RAW].[Procedure],1)) Not Like 'A*') AND ((Left([SENT_MCR_RAW].[Procedure],1)) Not Like 'Q*') AND ((Right([SENT_MCR_RAW].[Procedure],1)) Not Like 'F*'));


It appears to be working very well.

Reply With Quote
  #6  
Old September 29th, 2009, 11:40 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
Quote:
Originally Posted by km1976
I use this:

WHERE (((Left([SENT_MCR_RAW].[Procedure],1)) Not Like 'A*') AND ((Left([SENT_MCR_RAW].[Procedure],1)) Not Like 'Q*') AND ((Right([SENT_MCR_RAW].[Procedure],1)) Not Like 'F*'));


It appears to be working very well.
I'm glad you got it working, I just wanted to add that some databases are case sensitive and it may be worth forcing all fields to uppercase just in case your procedures are in lowercase, eg:
Code:
WHERE (((Left(UPPER([SENT_MCR_RAW].[Procedure]),1)) Not Like 'A*') AND ((Left(UPPER([SENT_MCR_RAW].[Procedure]),1)) Not Like 'Q*') AND ((Right(UPPER([SENT_MCR_RAW].[Procedure]),1)) Not Like 'F*'));

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Query - General - Data Exceptions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek