January 22, 2016 at 3:01 am
Hi,
I need help with using COUNT with multiple criteria's.
SELECT DISTINCT CaseStatus, CASE_GROUP_TOTAL = COUNT(CaseStatus)
FROM MCJ
WHERE Case_Group IN ('INPATIENT', 'Outpatient')
GROUP BY CaseStatus, Case_Group
This works however I am unable to tell which one is Inpatient and which one is outpatient without having to go to the data.
Is there anything else I can add to show the breakdown for each Inpatient / Outpatient case status.
Thanks for any help.
January 22, 2016 at 3:17 am
The information you give is quite limited so this is going to require some guesswork. But perhaps this works:
SELECT CaseStatus, Case_Group, COUNT(CaseStatus) AS CASE_GROUP_TOTAL
FROM dbo.MCJ
WHERE Case_Group IN ('INPATIENT', 'Outpatient')
GROUP BY CaseStatus, Case_Group;
(untested)
January 22, 2016 at 3:17 am
If I have understood you correctly, is it as simple as this?....
select CaseStatus, Case_Group, CASE_GROUP_TOTAL = COUNT(*)
from MCJ
WHERE Case_Group IN ('INPATIENT', 'Outpatient')
GROUP BY CaseStatus, Case_Group
January 22, 2016 at 3:37 am
That works perfectly thank you so much.
Also If i wanted to add in more criteria do i just simply add them into the Where statement.
thanks again
January 22, 2016 at 4:10 am
That is correct - just add any additional criteria to the WHERE statement
January 22, 2016 at 4:24 am
thank you 🙂
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply