From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Alex Magnum <magnum11200(at)gmail(dot)com> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Creating Report for PieChart |
Date: | 2015-10-14 00:57:44 |
Message-ID: | 20151014005744.GA7843@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Oct 14, 2015 at 01:56:11AM +0200, Alex Magnum wrote:
> Hello,
> I need to process some statistics for a pie chart (json) where I only want to
> show a max of 8 slices. If I have more data points like in below table I need
> to combine all to a slice called others. If there are less or equal 8 i use
> them as is.
>
> I am currently doing this with a plperl function which works well but was just
> wondering out of curiosity if that could be done withing an sql query.
>
> Anyone having done something similar who could point me in the right direction?
I think you want the HAVING clause, e.g. HAVING COUNT(*) > 8.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription +
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Mead | 2015-10-14 01:14:13 | Re: Creating Report for PieChart |
Previous Message | Alex Magnum | 2015-10-13 23:56:11 | Creating Report for PieChart |