I am trying to count number of discharge prescription. The case is as follow:
Each prescription cantinas several orders so prescription number may occur several times using count alone. To count prescription numbers (not orders) I used distinct so each prescription number will be counted once. And I need to count only discharge prescription, so I put the other condition: Priority like '% discharge%'. Though this is not working correctly.
I am using this query but it keeps returning 1 which is not correct:
SELECT
Count (distinct
(case when
(PrescNo is not null)
and (Priority like '% discharge%')
then 1 else null end)) as "Discharge Prescription"
FROM Order_DIS
where PrescNo is not null
and ADM_Type='In Patient'
Table contains following column:
I am trying to count number of discharge prescription. The case is as follow:
Each prescription cantinas several orders so prescription number may occur several times using count alone. To count prescription numbers (not orders) I used distinct so each prescription number will be counted once. And I need to count only discharge prescription, so I put the other condition: Priority like '% discharge%'. Though this is not working correctly.
I am using this query but it keeps returning 1 which is not correct:
SELECT
Count (distinct
(case when
(PrescNo is not null)
and (Priority like '% discharge%')
then 1 else null end)) as "Discharge Prescription"
FROM Order_DIS
where PrescNo is not null
and ADM_Type='In Patient'
Table contains following column:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.