私はこのクエリを持っています:
select pa.id,pa.name
from patients pa
where (select count(distinct co.doctorID)
from consults co
where co.patientID=pa.id) = (select count(do.id)
from doctors do);
そこでは、すべての医師と相談した患者を選びます。
私は異なる医師の数を数えており、医師の総数と等しいかどうかを確認しています。
しかし、カウントを使用せずにexists
and/orを使用してこれを行うにはどうすればよいですかin