Re: Creating Report for PieChart - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Creating Report for PieChart
Date
Msg-id 20151014005744.GA7843@momjian.us
Whole thread Raw
In response to Creating Report for PieChart  (Alex Magnum <magnum11200@gmail.com>)
List 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@momjian.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                             +


pgsql-general by date:

Previous
From: Alex Magnum
Date:
Subject: Creating Report for PieChart
Next
From: Scott Mead
Date:
Subject: Re: Creating Report for PieChart