public inbox for [email protected]  
help / color / mirror / Atom feed
From: Rich Shepard <[email protected]>
To: pgsql-general <[email protected]>
Subject: Re: Syntax error needs explanation [RESOLVED]
Date: Mon, 14 Jul 2025 13:13:17 -0700 (PDT)
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwZWnGB2weH87+z4zn8mTg83rso2Cy4P2=fqqcAM9p5iWg@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAKFQuwZWnGB2weH87+z4zn8mTg83rso2Cy4P2=fqqcAM9p5iWg@mail.gmail.com>

On Mon, 14 Jul 2025, David G. Johnston wrote:

> Yeah, you need both to read up on aggregate queries and correlated
> subqueries which is typically how one makes uses of exists (it's called a
> semi-join in this formulation)

David,

Thanks. I wasn't sure what to read.

> Not tested, but:
>
> select c.industry, count(*)
> from companies as c
> where exists (
> select from enforcement as e
> where e.company_nbr = c.company_nbr
> )
> group by c.industry;

Works as intended.

Many thanks,

Rich






view thread (6+ messages)

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]
  Subject: Re: Syntax error needs explanation [RESOLVED]
  In-Reply-To: <[email protected]>

* 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