Approach to extract top records from table based upon aggregate - Mailing list pgsql-general

From droberts
Subject Approach to extract top records from table based upon aggregate
Date
Msg-id 1446502449172-5872427.post@n5.nabble.com
Whole thread Raw
Responses Re: Approach to extract top records from table based upon aggregate  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Approach to extract top records from table based upon aggregate  (Emanuel Calvo <3manuek@esdebian.org>)
Re: Approach to extract top records from table based upon aggregate  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
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.


pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: Is there bigintarray?
Next
From: "David G. Johnston"
Date:
Subject: Re: Approach to extract top records from table based upon aggregate