Forum Discussion
JoeCavasin
May 18, 2025Brass Contributor
Distinct Count Subquery, MS Access
Need some help in getting a Distinct Count result in this query. For context, i work in healthcare and of course an not share the actual data behind the query. My goal is to modify the current quie...
ProcessIT
May 18, 2025Copper Contributor
Hi Joe,
If I'm correctly following what you ask, then I thnk you are simply missing the "COUNT() function.
Try this:
SELECT ez_hosp_chg_v.POST_DATE, ez_hosp_chg_v.TX_FIN_CLASS, ez_hosp_chg_v.ACCT_CLASS, Sum(ez_hosp_chg_v.ORIG_AMT) AS SumOfORIG_AMT,
ez_hosp_chg_v.PRIMARY_PLAN_NAME, COUNT(ez_hosp_chg_v.HOSP_ACCT_ID) as HospCount
FROM ez_hosp_chg_v
GROUP BY ez_hosp_chg_v.POST_DATE, ez_hosp_chg_v.TX_FIN_CLASS, ez_hosp_chg_v.ACCT_CLASS, ez_hosp_chg_v.PRIMARY_PLAN_NAME,
ez_hosp_chg_v.HOSP_ACCT_ID
HAVING (((ez_hosp_chg_v.POST_DATE) Between [enter start date] And [enter end date]));