Search Postgresql Archives

Approach to extract top records from table based upon aggregate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I have a table that contains call records.  I'm looking to get only
records for users who made the most calls over a particular time duration in
an efficient way.  

calls()

time,  duration,   caller_number, dialed_number



-- query to get top 10 callers
  select caller_number, count(1) from calls group by caller_number order by
calls desc limit 10

--my current query to get those callers

select * from call where caller_number in (above query)


It works but I was hoping for something a little more efficient if anyone
has an idea.  

Tahnks



--
View this message in context: http://postgresql.nabble.com/Approach-to-extract-top-records-from-table-based-upon-aggregate-tp5872427.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux