Re: Syntax error needs explanation [RESOLVED]
Rich Shepard <rshepard@appl-ecosys.com>
From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general <pgsql-general@postgresql.org>
Date: 2025-07-14T20:13:17Z
Lists: pgsql-general
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