-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Example SQL query
WITH
total as
(
select count(distinct subject_ref) as cnt_pat,
count(distinct encounter_ref) as cnt_enc,
count(distinct documentreference_ref) as cnt_doc
from irae__sample_casedef_post
),
group_by_pat as
(
select subject_ref,
count(distinct encounter_ref) as cnt_enc,
count(distinct documentreference_ref) as cnt_doc
from irae__sample_casedef_post
group by subject_ref
),
group_by_enc as
(
select cnt_enc,
count(distinct subject_ref) as cnt_pat
from group_by_pat
group by cnt_enc
order by cnt_enc
),
cumulative as
(
select E1.cnt_enc,
sum(E2.cnt_pat) as sum_pat
from group_by_enc as E1,
group_by_enc as E2,
total
where E1.cnt_enc >= E2.cnt_enc
group by E1.cnt_enc
order by E1.cnt_enc
)
select cumulative.cnt_enc,
cumulative.sum_pat,
round(cumulative.sum_pat * 100.0 / total.cnt_pat, 2) as prct_pat
from cumulative,
total
Metadata
Metadata
Assignees
Labels
No labels