Hello,
I am trying to write a query to pull patients that have received a service within 90 days of their first services. I have tried running the below code and some other variations and have not been able to get the count. Any help would be great.
select bth.PatID,
from billing_table bth
where bth.date_of_service BETWEEN '2018-10-01' AND '2019-09-30'
and bth.primary_guarantor IN ('422')
and bth.PatID in
(
Select
count(bth.date_of_service)
from billing_table bth
where bth.date_of_service > Dateadd(day,-90, date_of_service)
and bth.PATID is not null
Group by bth.PATID
having count(bth.date_of_service) >1
)
order by bth.PATID
I am trying to write a query to pull patients that have received a service within 90 days of their first services. I have tried running the below code and some other variations and have not been able to get the count. Any help would be great.
select bth.PatID,
from billing_table bth
where bth.date_of_service BETWEEN '2018-10-01' AND '2019-09-30'
and bth.primary_guarantor IN ('422')
and bth.PatID in
(
Select
count(bth.date_of_service)
from billing_table bth
where bth.date_of_service > Dateadd(day,-90, date_of_service)
and bth.PATID is not null
Group by bth.PATID
having count(bth.date_of_service) >1
)
order by bth.PATID