我发现很难理解以下SQL查询背后的逻辑。 有人可以解释模型来理解这样的查询。
1)查找资产比某个分支更大的所有分支 在布鲁克林。
select distinct T.branch_name
from branch as T, branch as S
where T.assets > S.assets and
S.branch_city = 'Brooklyn'
2)查找在所有分支机构拥有帐户的所有客户 布鲁克林。
select distinct S.customer_name
from depositor as S
where not exists (
(select branch_name
from branch
where branch_city = 'Brooklyn')
except
(select R.branch_name
from depositor as T, account as R
where T.account_number = R.account_number and
S.customer_name = T.customer_name ))