Multiple aggs,sums in 1 query

From: Dorian Hoxha <dorian(dot)hoxha(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Multiple aggs,sums in 1 query
Date: 2013-11-22 14:41:26
Message-ID: CANsFX04074WyMDC=559fr8Ef_O9h1Dn=LL+HLX3hAHu5o8fApQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have: create table tbl (a,b,c,d,e,f,g,h);

And i need to select in 1 query ,or the most performant way:

top 5(a)
top 5(b)
top 5(c): for each top5(c): top 5(d)
count(f) GROUP BY f

I can make these in separate queries but that means that postgresql would
read the table multiple-times?

Is it possible/doable/sane ?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2013-11-22 14:46:00 Re: PG replication across DataCenters
Previous Message Mike Kienenberger 2013-11-22 13:46:25 Browsing postgres database using the Eclipse QuantumDB plugin