select a.id
from public.account a
join public.ad ad on ad.account_id = a.id
group by a.id
having bool_or(ad.active) = false
の場合:クエリ以下
CREATE TABLE public.account
(
id bigint NOT NULL DEFAULT nextval('account_id_seq'::regclass),
password text COLLATE pg_catalog."default",
insert_time timestamp with time zone DEFAULT now(),
email_account_id bigint,
phone_number text COLLATE pg_catalog."default",
active boolean NOT NULL DEFAULT true,
CONSTRAINT account_pkey PRIMARY KEY (id),
CONSTRAINT account_email_account_id_fkey FOREIGN KEY (email_account_id)
REFERENCES public.email_account (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)
CREATE TABLE public.ad
(
id bigint NOT NULL DEFAULT nextval('model_id_seq'::regclass),
name text COLLATE pg_catalog."default" NOT NULL,
insert_time timestamp with time zone DEFAULT now(),
ad_url text COLLATE pg_catalog."default",
account_id bigint NOT NULL,
active boolean NOT NULL DEFAULT true,
CONSTRAINT ad_pkey PRIMARY KEY (id),
CONSTRAINT ad_account_id_fkey FOREIGN KEY (account_id)
REFERENCES public.account (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)
サンプルデータと予想される結果を追加してください。 –