SQL语句,如何统计一列中的值重复出现的次数,查询出的结果按次数的倒序排列?
来源:百度知道 编辑:UC知道 时间:2024/06/23 02:59:30
select 重复字段, count(重复字段) from 表 group by 重复字段 order by 重复字段 desc
试试吧。
select 列名, count(*) from 表名 group by 列名 order by count(*) desc;
这样就可以了
SELECT 字段,COUNT(*) a FROM 表名 GROUP BY 1 t order by COUNT(*)desc
SELECT 字段,COUNT(*) FROM 表名 GROUP BY 1 ORDER BY 2 DESC
select 重复字段, count(重复字段) from 表 group by 重复字段 order by count(*) desc