sql分组统计查询 count带条件

SELECT user_id,count(type=1 or null) donate_num,count(type=2 or null) rent_num
FROM ot_dynamic  
GROUP BY user_id

  

原文地址:https://www.cnblogs.com/deepalley/p/12692169.html