I have two queries that i need to combine.
The first selects a series of patient ids and dates that i need to use in the second.
Here there are: This selects the patients and dates:
order by pat_id, msr_date
This selects the medicine data and uses pat_id and msr_Date from the first query.
count(case mgp_id when 2 then 1 else null end) as [A 11 + A 12],
count(case mgp_id when 23 then 1 else null end) as [N 02 Analgetika],
where ((pmd_StartDate <= msr_Date) or (pmd_StartDateUnknown = 1)) and pmd_EndDate <= msr_Date
group by pat_id
order by pat_id
I want to combine them so that for every pat_id and msr_date i return the result of the second query.
Can someone suggest the syntax?