Re: Syntax error needs explanation [RESOLVED]

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Syntax error needs explanation [RESOLVED]
Date: 2025-07-14 20:13:17
Message-ID: f831272d-ac28-489-cdbe-356c78bb87d5@appl-ecosys.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-07-15 03:09:53 RE: error “server process was terminated by signal 11: Segmentation fault” running pg_create_logical_replication_slot using pgoutput plugin
Previous Message David G. Johnston 2025-07-14 20:07:53 Re: Syntax error needs explanation