几个简单sql语句问题,不过是英语版本的,大家帮看看!!在线等!!!

[复制链接]
查看11 | 回复1 | 2011-5-16 06:01:54 | 显示全部楼层 |阅读模式
1.Replacethequerybelowwithanequivalentquerythatissimpler,doesnotuseUNIONanddoesuseanOUTERJOIN:(2marks)
SELECTCode,COUNT(NbrItemsRequested)ASTotalItems
FROMProductASpINNERJOINSalesOrderProductASsop
ONp.PID=sop.PID
GROUPBYCode
HAVINGCOUNT(NbrItemsRequested)2
UNION
SELECTCode,0
FROMProduct
WHEREPIDNOTIN(SELECTPID
FROMSalesOrderProduct);
2.FormulatethreequeriestolisttheorderNumberofevery“Placed”orderthatincludesarequestforoneormoreCookwareitems.(3marks)
i.OnequerythatusesINtwiceanddoesnotuseEXISTS.
ii.OnequerythatusesEXISTSonceandINonce.
iii.OnequerythatusesEXISTStwiceanddoesnotuseIN.
3.Inyourownwords,describetheresultproducedbythequerybelow.(1.5marks)
SELECTCode
FROMProductASp
WHERENOTEXISTS(SELECT*
FROMCustomerASc
WHEREState=\'QLD\'
ANDEXISTS(SELECT*
FROMSalesOrderASso
WHEREso.CID=c.CID
ANDEXISTS(SELECT*
FROMSalesOrderProductASsop
WHEREsop.SOID=so.SOID
ANDsop.PID=p.PID)));
4.Inyourownwords,describetheresultproducedbythequerybelow.(1.5marks)
SELECTCode
FROMProductASp
WHERENOTEXISTS(SELECT*
FROMCustomerASc
WHEREState=\'QLD\'
ANDNOTEXISTS(SELECT*
FROMSalesOrderASso
WHEREso.CID=c.CID
ANDEXISTS(SELECT*
FROMSalesOrderProductASsop
WHEREsop.SOID=so.SOID
ANDsop.PID=p.PID)));
5.Advanced:FormulateanequivalentquerytotheonegiveninQuestion4above.YourquerymustnotuseEXISTSorIN.(1bonusmark)
回复

使用道具 举报

千问 | 2011-5-16 06:01:54 | 显示全部楼层
可以远程的话联系我!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行