sql利用在一條語句中count出不一樣的條件的值

過多繁瑣的sql影響代碼質量,及維護成本,如下爲兩種小技巧處理方式,僅供參考,第二種更美觀點 第一種,用case ---when---方法 select id ,sum(case when type in (1,2) then [count] else 0 end) as sum1 ,sum(case when type in (3) then [count] else 0 end) as sum
相關文章
相關標籤/搜索