public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: dfgpostgres <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: How can I get a query-based subtotal in a select using group by rollup ?
Date: Wed, 7 Aug 2024 18:42:46 -0700
Message-ID: <CAKFQuwbq-SUyW11qvtALAPP+rkW-pEByNV_dQ_mS9GbC3QrKGA@mail.gmail.com> (raw)
In-Reply-To: <CAAcmDX-cZmNu9jHzu7XT__VCsGGF-yC0D7T653-cN8p3NZhUVA@mail.gmail.com>
References: <CAAcmDX-cZmNu9jHzu7XT__VCsGGF-yC0D7T653-cN8p3NZhUVA@mail.gmail.com>
On Wednesday, August 7, 2024, dfgpostgres <[email protected]> wrote:
>
> (select
> domain_name,
> sum(total_tests) as total_tests,
> sum(tests_completed) as tests_completed,
> sum(tests_passed) as tests_passed,
> sum(tests_failed) as tests_failed,
> (select count(*) from dispatch_tracker where
> regression_name=rt.regression_name and domain_name=rt.domain_name and
> dispatch_status='Y') as dispatched
> from
> regr.dispatch_tracker rt where rt.regression_name='2024_08_
> 02_10_32_53_soundwave__er_common_regression__CL2017473_z1_soundwave_adm'
> group by rollup(rt.domain_name) order by rt.domain_name ASC NULLS LAST)
> d;
>
Either add regression_name to the group by as the error hints at you, or
since you are already grouping implicitly by that (by virtue of the where
clause filter) and domain_name just count the number of dispatch_status=Y
in the group: count(*) filter (where dispatch_status = ‘Y’)
The option that avoids the subquery is arguably better. Though I’d
probably still include the regression_name in the output anyway - why hide
what you are filtering on.
David J.
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How can I get a query-based subtotal in a select using group by rollup ?
In-Reply-To: <CAKFQuwbq-SUyW11qvtALAPP+rkW-pEByNV_dQ_mS9GbC3QrKGA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox