We help IT Professionals succeed at work.
Get Started

Modify SQL Question

223 Views
Last Modified: 2021-04-21
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; 

Open in new window

Can someone help me with this?
Comment
Watch Question
Business Intelligence Specialist
Commented:
This problem has been solved!
Unlock 1 Answer and 25 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE