几个简单英语sql问题,在线等答案!!! 30

1.Replacethequerybelowwithanequivalentquerythatissimpler,doesnotuseUNIONanddoesuseanO... 1. Replace the query below with an equivalent query that is simpler, does not use UNION and does use an OUTER JOIN: (2 marks)
SELECT Code,COUNT(NbrItemsRequested) AS TotalItems
FROM Product AS p INNER JOIN SalesOrderProduct AS sop
ON p.PID = sop.PID
GROUP BY Code
HAVING COUNT(NbrItemsRequested) < 2
UNION
SELECT Code, 0
FROM Product
WHERE PID NOT IN (SELECT PID
FROM SalesOrderProduct);
2. Formulate three queries to list the order Number of every “Placed” order that includes a request for one or more Cookware items. (3 marks)
i. One query that uses IN twice and does not use EXISTS.
ii. One query that uses EXISTS once and IN once.
iii. One query that uses EXISTS twice and does not use IN.
3. In your own words, describe the result produced by the query below. (1.5 marks)
SELECT Code
FROM Product AS p
WHERE NOT EXISTS (SELECT *
FROM Customer AS c
WHERE State = 'QLD'
AND EXISTS (SELECT *
FROM SalesOrder AS so
WHERE so.CID = c.CID
AND EXISTS (SELECT *
FROM SalesOrderProduct AS sop
WHERE sop.SOID = so.SOID
AND sop.PID = p.PID)));
4. In your own words, describe the result produced by the query below. (1.5 marks)
SELECT Code
FROM Product AS p
WHERE NOT EXISTS (SELECT *
FROM Customer AS c
WHERE State = 'QLD'
AND NOT EXISTS (SELECT *
FROM SalesOrder AS so
WHERE so.CID = c.CID
AND EXISTS (SELECT *
FROM SalesOrderProduct AS sop
WHERE sop.SOID = so.SOID
AND sop.PID = p.PID)));
5. Advanced: Formulate an equivalent query to the one given in Question 4 above. Your query must not use EXISTS or IN. (1 bonus mark)
展开
 我来答
libowanghaixia
2011-05-16 · 超过29用户采纳过TA的回答
知道答主
回答量:82
采纳率:0%
帮助的人:0
展开全部
可以远程的话联系我!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式