SQL 中 case then(相当于if) 、distinct(去重)

select TC_OD_SD_NAME,TC_OD_DR_NAME ,count(distinct TC_RX_NO) 总张数,count(distinct(case when TC_OD_SD_NAME like '%儿科%' then TC_RX_NO else null end)) 儿科处方数
from TB_OD_PRESCRIPTION

猜你喜欢

转载自www.cnblogs.com/yuanshuo/p/12810141.html