日期:2014-05-19  浏览次数:20426 次

关于查询排序问题
我的表是这样的
id     title   type----title是文章标题   type是类别
1         哈哈     公告
2         呵呵     新闻
3         嘿嘿     新闻
4         由于     公告
5         威尔     公告
6         噢噢     动态

我现在想要这样的排序,就是按文章的量来排序
比如结果:
第一:公告
第二:新闻
第三:动态

请问select语句该怎么写
请大家指点
谢谢

------解决方案--------------------
select counttype
from ( select counttype = count(type)
from [表] group by type) as tmp
order by tmp.counttype desc
------解决方案--------------------
select type,count(*) from 表 group by type order by count(*) desc