select dii.drugname1, dii.drugname2, dii.note, count(dii.vn) as cases, "OPD" as type
from drug_interaction_incident dii
join ovst o on o.vn=dii.vn
where o.vstdate between "2012-10-01" and "2013-02-28"
group by dii.drugname1, dii.drugname2
union
select dii.drugname1, dii.drugname2, dii.note, count(dii.vn) as cases, "IPD" as type
from drug_interaction_incident dii
join ipt_order_no i on i.order_no=dii.order_no
where i.rxdate between "2012-10-01" and "2013-02-28"
group by dii.drugname1, dii.drugname2
order by type, cases desc