日期:2014-05-17  浏览次数:20707 次

求大虾们 一个sql
表数据格式

type name
A car
A car
A bus
B car
B car
B bus


想要一个sql变成这样的格式

type name count
A car 2
A bus 1
B car 2
B bus 1

谢谢了!


------解决方案--------------------
select type,name,count(*) as count from table group by type,name
------解决方案--------------------
探讨

select type,name,count(*) as count from table group by type,name

------解决方案--------------------
简单的分组count