有表 ,字段如下
id, count, color
1   10    红
2   20    白
3   40    红
4   25    白
5   22    黑
要查出结果
count  color  行数
50      红     2
60      白     2
22      黑     1
请高手帮忙..分数只有这么多了,技术交流第一! 谢谢

解决方案 »

  1.   

    select sum(count) as count,count(*) as 行数,color from 表名 group by color
      

  2.   

    tryselect sum([count]) as [count], color, count(color) as 行数 from yourTable group by color
    不过楼主的
    60      白     2
    这里的60不知道是怎么来的
    还有就是排序看不出规律来,这里就没有排序
      

  3.   

    tryselect sum([count]) as [count], color, count(color) as 行数 from yourTable group by color
    不过楼主的
    60      白     2
    这里的60不知道是怎么来的
    还有就是排序看不出规律来,这里就没有排序
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    错了..是 65
      

  4.   

    tryselect sum([count]) as [count], color, count(color) as 行数 from yourTable group by color
      

  5.   

    select sum([count]) as [count],color,count(id) as '行数' from 表名 group by color