Re: Get sum of sums

From: Victor Yegorov <vyegorov(at)gmail(dot)com>
To: Steve Clark <sclark(at)netwolves(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Get sum of sums
Date: 2016-05-03 19:57:57
Message-ID: CAGnEbojZ=BjoSma+xG43qR6FmeSF+T-c7z4qt8CCh+LjVFu+9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2016-05-03 22:48 GMT+03:00 Steve Clark <sclark(at)netwolves(dot)com>:

> select ip_dst as "Receiver" ,sum(bytes) as "RX Bytes" from acct_v9 where
> stamp_inserted >= '2016-04-26' and stamp_inserted <= '2016-04-30' and
> tag=246 group by ip_dst order by "RX Bytes" desc limit 10;

SELECT ip_dst AS "Receiver",
sum(bytes) AS "RX Bytes",
sum(sum(bytes)) OVER () AS "Grand Total"
FROM acct_v9
WHERE stamp_inserted BETWEEN '2016-04-26' AND '2016-04-30'
AND tag=246
GROUP BY ip_dst
ORDER BY "RX Bytes" DESC
LIMIT 10;

I am not sure bout the LIMIT though, I hope window function will be
calculated after the LIMIT is applied.

--
Victor Y. Yegorov

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-05-03 20:08:42 Re: Get sum of sums
Previous Message Steve Clark 2016-05-03 19:48:12 Get sum of sums