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