SELECT dr_id ,ds FROM study WHERE ds <= ‘20210621‘ AND ds > ‘20210520‘and dr_id=‘193589‘;
查出结果是:8条记录
用 group by dr_id=193589,有8人
SELECT dr_id
,COUNT(DISTINCT ds) AS online_30d
FROM alihealth_dw.dwd_alihosp_dr_online_df
WHERE ds <= ‘20210621‘
AND ds > ‘20210520‘
AND is_online_1d = ‘Y‘
and dr_id=‘193589‘
GROUP BY dr_id;