您好,我想显示所有客户的名称,这些客户在银行的任何分支机构中只有一个账户余额超过$ 1000的帐户,而在Edina的任何分支机构中只有一笔或多于$ 4000的贷款
select account.cname,
from Account
where account.bal > 1000
UNION
(select loan.cname
from loan
where loan.amt>4000 AND
l.bname )in (
select bname
from branch
where lower(bcity)= 'edina'
);
看起来不错吗?
答案 0 :(得分:1)
您在第一次选择时要使用逗号。 您的in子句没有要与之比较的列
也许是这样的:
select account.cname
from Account
where account.bal > 1000
UNION
select loan.cname
from loan
where loan.amt>4000 AND l.bname
and loan.bname in ( select bname from branch where lower(bcity)= 'edina' )