3

我有一张这样的桌子-

cdr_pkey as serial, calldate as timestamp, src as text, duration as bigint

我需要使用 SQL 查询在“src”列中找到前 10 个最常见的数字,以及表中出现的次数。

我尝试通过导出到 Excel 并运行模式功能,但记录约为 700 万,因此效率不高。

PS。我正在使用 PostreSQL 9.1

4

1 回答 1

2
select 
    src as text,
    count(*) as total
from t
group by 1
order by total desc
limit 10;
于 2012-12-10T10:31:52.757 回答