SQL语句,如何统计一列中的值重复出现的次数,查询出的结果按次数的倒序排列?

2025-02-24 01:27:29
推荐回答(5个)
回答1:

select 重复字段, count(重复字段) from 表 group by 重复字段 order by 重复字段 desc

回答2:

SELECT 字段,COUNT(*) FROM 表名 GROUP BY 1 ORDER BY 2 DESC

回答3:

试试吧。
select 列名, count(*) from 表名 group by 列名 order by count(*) desc;

回答4:

这样就可以了
SELECT 字段,COUNT(*) a FROM 表名 GROUP BY 1 t order by COUNT(*)desc

回答5:

select 重复字段, count(重复字段) from 表 group by 重复字段 order by count(*) desc