I have a table like this -
cdr_pkey as serial, calldate as timestamp, src as text, duration as bigint
I need to find top 10 most frequent numbers in 'src' column, together with the number of occurrence in the table by using SQL query.
I tried by exporting to Excel and run Mode function but the records are around 7 million so it is not so efficient.
PS. I'm using PostreSQL 9.1
select
src as text,
count(*) as total
from t
group by 1
order by total desc
limit 10;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With