日期:2014-05-16  浏览次数:20791 次

group by 和count
select count(type) from product group by type
结果统计出来的是每组的个数(多行结果)
想统计有多少种类型(单一结果)要怎么写?
除了这种写法,单一语句能完成吗?
select count(1) from (select count(type) from product group by type)

------解决方案--------------------
select count(distinct type) from product
------解决方案--------------------
探讨

select count(distinct type) from product