From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Aggregate functions on groups
Date: Sat, 31 Aug 2019 07:29:39 -0700 (PDT)
Message-ID: <alpine.LNX.2.20.1908310724190.16819@salmo.appl-ecosys.com> (raw)
In-Reply-To: <CAKqncciB=yzfCpcbANb20NBxxVuQcmWOkUi8=2fYuaKuP-w9fQ@mail.gmail.com>
References: <alpine.LNX.2.20.1908301003500.22705@salmo.appl-ecosys.com>
<CAKqncciB=yzfCpcbANb20NBxxVuQcmWOkUi8=2fYuaKuP-w9fQ@mail.gmail.com>
On Sat, 31 Aug 2019, Morris de Oryx wrote:
> Your tributaries and fish master tables make sense. If I read your code
> right, you're grouping by too many columns. I flattened the data into a
> survey table for this simple example:
Morris,
I'm still learning about postgres groups. My approach is to group on the
column of interest, then add more when psql tells me to do so.
> select tributary,
> common_name,
> scientific_name,
> sum(count_value) as fish_seen,
> count(count_value) as observations_made
>
> from survey
>
> group by 1,2,3 -- The GROUP BY clause can use positions on the select
> list, if you feel like typing less.
I will look more at this approach; at first glance it appears to address one
query but not all those needed.
> But this is not why I'm answering. I'm responding as I wanted to make sure
> that you're aware of the pg-similarity extension:
> https://salsa.debian.org/postgresql/pg-similarity
Thanks for the URL. I'll definintely read about similarity.
Regards,
Rich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rshepard@appl-ecosys.com
Subject: Re: Aggregate functions on groups
In-Reply-To: <alpine.LNX.2.20.1908310724190.16819@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1908301003500.22705@salmo.appl-ecosys.com> <CAKqncciB=yzfCpcbANb20NBxxVuQcmWOkUi8=2fYuaKuP-w9fQ@mail.gmail.com> <alpine.LNX.2.20.1908310724190.16819@salmo.appl-ecosys.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox