Re: get counts of multiple field values in a jsonb column - Mailing list pgsql-sql

From David G. Johnston
Subject Re: get counts of multiple field values in a jsonb column
Date
Msg-id CAKFQuwZKkv3ZLOfmipU-8JRLKTxhQ4ThFwDJQrX45Fk_MoXUiA@mail.gmail.com
Whole thread Raw
In response to get counts of multiple field values in a jsonb column  (Martin Norbäck Olivers <martin@norpan.org>)
List pgsql-sql
On Sat, Oct 17, 2020 at 8:00 AM Martin Norbäck Olivers <martin@norpan.org> wrote:
I'm looking at all the aggregation functions but can't quite find one that suits this purpose.

I would love to get some input on ways to make this faster.

If you want counts the count function is your goto aggregate function.  What you are missing is performing conditional counting.

SELECT fld, count(*) FILTER (WHERE expression) FROM query GROUP BY fld;


David J.

pgsql-sql by date:

Previous
From: Martin Norbäck Olivers
Date:
Subject: get counts of multiple field values in a jsonb column
Next
From: Rob Sargent
Date:
Subject: Re: get counts of multiple field values in a jsonb column