在同一个查询中统计同一个列的不同值的数量

select  sum(if(color='blue',1,0)) as blue,sum(if(color='red',1,0)) as red from ys;

select  count(color='blue' or null) as blue,count(color='red' or null) as red from ys;

posted on 2014-08-20 21:54  zitong  阅读(225)  评论(0编辑  收藏  举报