Created
January 26, 2010 19:09
-
-
Save ebot/287109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Select e.EncounterNo, e.EncntrStartDate, EncntrType, EncntrClass, IpOpInd | |
From Encounters as e | |
Left Outer Join #valid_encounters as ve on e.EncntrOwnerId = ve.EncntrOwnerId | |
Where e.EncntrStartDate >= '1/1/2000' and e.EncntrStartDate < '1/1/2010' | |
AND ve.EncntrOwnerId is null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create Table #valid_encounters | |
(EncntrOwnerId bigint, | |
EncounterNo varchar(254), | |
EncntrStartDate smalldatetime) | |
Insert Into #valid_encounters | |
Select EncntrOwnerId, EncounterNo, EncntrStartDate | |
From DocTypes as dt | |
Inner Join Documents as d on dt.DocType = d.DocType | |
Inner Join DocsOwners as do on d.DocId = do.DocId | |
Inner Join Encounters as e on do.OwnerId = e.EncntrOwnerId | |
Where EncntrStartDate >= '1/1/2000' and EncntrStartDate < '1/1/2010' | |
AND DocTypeName = 'ACCTHSTY' | |
Group By EncntrOwnerId,EncounterNo, EncntrStartDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment