select st.name 医生姓名, dp.name 科室, mc.cname 药品名称, mc.spec 规格, mc.clinunit 门诊单位, sum(cc.qty) 数量
  from cctollworkc cc, cctollworkp cp, medicine mc, staff st, dept dp
  where cc.id = cp.id
    and cc.feeid = mc.medid
    and cp.docid = st.id
    and st.depid = dp.id
    and cp.BalRlTime between sysdate - 1 and sysdate
    and cc.feeid = (select medid from medicine where numcode = '药品编码')
    and cp.ackflag = 20
    and cp.tzflag = 0
    and cp.ccareaid = 1
  group by st.name, dp.name, mc.cname, mc.spec, mc.clinunit