troubleshooting Question

Modify SQL Question

Avatar of bfuchs
bfuchsFlag for United States of America asked on
Microsoft AccessMicrosoft SQL ServerSQL
25 Comments1 Solution224 ViewsLast Modified:
Hi Experts,
I need to modify the sql below to give me a count break down by Patients3.PatientType
SELECT Count(1) AS Expr1
FROM (select distinct PatientsID,  iif(datediff('d', End, nz(next_service,End))>30, 1, 0) as MoreThan30 from (
       SELECT P1.PatientsID, P1.EffectiveFrom, P1.End, (select min(EffectiveFrom) from TmpPatBillingCodes as P2 where P2.PatientsID=P1.PatientsID and P2.EffectiveFrom > P1.End) AS next_service
FROM TmpPatBillingCodes AS P1 INNER JOIN Patients3 ON P1.PatientsID = Patients3.ID
WHERE (((Patients3.FacilityID)<>6488) AND ((P1.EffectiveFrom)<#1/1/2014#) AND ((P1.End)>=#1/1/2013#))

) as x
) AS y; 
Can someone help me with this?
ASKER CERTIFIED SOLUTION
Koen Van Wielink
Business Intelligence Specialist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros