我有一张这样的表 -
cdr_pkey as serial, calldate as timestamp, src as text, duration as bigint
我需要在'src'列中找到前10个最常见的数字,以及使用SQL查询在表中出现的次数。
我尝试导出到Excel并运行模式功能,但记录大约为700万,因此效率不高。
PS。我正在使用PostreSQL 9.1
答案 0 :(得分:2)
select
src as text,
count(*) as total
from t
group by 1
order by total desc
limit 10;