[英]DB2 SQL count in join or where clause
這可能是一個業余問題,但我是業余愛好者! ; o)
我有幾個表:帳戶表,官員表,位置表,Web表...官員表沒有給我每個帳戶的官員人數。
我只需要檢索擁有20多名職員的帳戶。 我應該使用COUNT嗎? 如果是這樣,怎么辦?
非常感謝您的幫助。 謝謝。
拍
更新:
select a.id, a.eff-date, l.address, l.city, c.phonenumber
from Account a
left outer join location l on a.id = l.id
left outer join contact c on a.id = c.id
where a.id in (
select a.id
from Account a
inner join Officer ao on a.id = ao.id
group by a.id
having count(*) > 20
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.