|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
try changing the OR to an AND ...
|
|
#5
|
|||
|
|||
|
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. |
|
#6
|
||||
|
||||
|
Quote:
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*')); |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Query - General - Data Exceptions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|