更新时间:2022-12-12 08:04:18
; WITH ALL_NAME
AS (SELECT names AS NAMES,
COUNT(names) AS FREQUENCY
FROM test --YOUR_TABLE
GROUP BY names)
SELECT *
FROM ALL_NAME
ORDER BY FREQUENCY DESC
select name ,count(*) as frequency from testing group by name order by frequency desc
Table_1
Col1
A
A
A
B
B
选择col1,count(col1)来自table_1 group by col1
它给我的结果如
A 3
B 2
Table_1
Col1
A
A
A
B
B
select col1,count(col1) from table_1 group by col1
It gives me result like
A 3
B 2