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

 

posted @ 2020-04-30 17:34  博客YS  阅读(1318)  评论(0编辑  收藏  举报