由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 请大家帮忙看看我写的这个ORACLE查询有什么问题!!跪谢了!
相关主题
请问这两个SQL QUERY有什么错?Select 怎样同时distinct 和order by
再现急求答案,多谢。help about SQL for ACCESS
[转载] what's the equivalent of 'minus' (oracle) in access?如何完成这个sql?
Re: [转载] what's the equivalent of 'minus' (oracle) in access?大家帮我看看这个function 哪里出了问题。 谢谢
aks a simple SQL questionask for help with a simple query!!!
2个table, 一个里面有4万个email, 一个里面有1万6千个email,如何比较?help needed
compare two large tables SQL (转载)求求!waiting online
HelpSQL server 2000有hidden records吗?
相关话题的讨论汇总
话题: bname话题: where话题: select话题: branch话题: account
进入Database版参与讨论
1 (共1页)
a******g
发帖数: 13519
1
查询涉及两个表:account(A#,cname,bname,bal), branch(bname,assets,bcity)
查询要求 print the name of all customers who have an account at every branch
in “Edina” where “James” does not have an account.
我的代码如下(老师说是错误的,结果对但代码表达的意思不对)
SELECT distinct cname
FROM account
WHERE bname
IN
(SELECT bname
FROM branch
WHERE lower(bcity) = 'edina')
MINUS
SELECT distinct cname
FROM account
WHERE bname
IN
(SELECT distinct account.bname
FROM account, branch
WHERE lower(cname) = 'james'
And lower(bcity)='edina');
后来我又换思路,改了一个
M*****r
发帖数: 1536
2
比如,得到满足(branch in “Edina” where “James” does not have an account
)条件的distinct的branch的数目
然后按上面branch的条件和account表join,select account.cname, count(distinct
bname) group by account.cname having count(distinct bname) = 前面的数目

branch

【在 a******g 的大作中提到】
: 查询涉及两个表:account(A#,cname,bname,bal), branch(bname,assets,bcity)
: 查询要求 print the name of all customers who have an account at every branch
: in “Edina” where “James” does not have an account.
: 我的代码如下(老师说是错误的,结果对但代码表达的意思不对)
: SELECT distinct cname
: FROM account
: WHERE bname
: IN
: (SELECT bname
: FROM branch

a******g
发帖数: 13519
3
听起来有点复杂啊,我去试试看。多谢了,楼上的熊猫大侠。
1 (共1页)
进入Database版参与讨论
相关主题
SQL server 2000有hidden records吗?aks a simple SQL question
请问T-SQL中Group By之后怎么找到特定的record2个table, 一个里面有4万个email, 一个里面有1万6千个email,如何比较?
a sql questioncompare two large tables SQL (转载)
请教大虾问题哈,包子谢哈Help
请问这两个SQL QUERY有什么错?Select 怎样同时distinct 和order by
再现急求答案,多谢。help about SQL for ACCESS
[转载] what's the equivalent of 'minus' (oracle) in access?如何完成这个sql?
Re: [转载] what's the equivalent of 'minus' (oracle) in access?大家帮我看看这个function 哪里出了问题。 谢谢
相关话题的讨论汇总
话题: bname话题: where话题: select话题: branch话题: account