OCP-1Z0-051 第123题 JOIN中的USING子句,ON子句

一、原题
View the Exhibits and examine the structures of the PRODUCTS, SALES, and CUSTOMERS tables.

You need to generate a report that gives details of the customer's last name, name of the product, and the quantity sold for all customers in ' Tokyo' .
Which two queries give the required result? (Choose two.)
A. SELECT c.cust_last_name,p.prod_name, s.quantity_sold
        FROM sales s JOIN products p
       USING(prod_id)
          JOIN customers c
       USING(cust_id)
     WHERE c.cust_city='Tokyo';

B. SELECT c.cust_last_name, p.prod_name, s.quantity_sold
       FROM products p JOIN sales s JOIN customers c
            ON(p.prod_id=s.prod_id)
            ON(s.cust_id=c.cust_id)
    WHERE c.cust_city='Tokyo';

C. SELECT c.cust_last_name, p.prod_name, s.quantity_sold
        FROM products p JOIN sales s
             ON(p.prod_id=s.prod_id)
          JOIN customers c
             ON(s.cust_id=c.cust_id)
           AND c.cust_city='Tokyo';

D. SELECT c.cust_id,c.cust_last_name,p.prod_id, p.prod_name, s.quantity_sold
        FROM products p JOIN sales s
       USING(prod_id)
          JOIN customers c
      USING(cust_id)
    WHERE c.cust_city='Tokyo';

答案:AC

二、题目翻译
查看PRODUCTS、SALES和CUSTOMERS表的结构
要生成一个报表,显示在Tokyo的客户的last name,product name,和the quantity sold(销售数量)的详细信息。
哪两个给出所需结果?(选择2个)

三、题目解析
B选项不正确,语法错误。
D选项不正确,因为有USING子句,不能使用限定词。

四、测试

SQL> select d.deptno,e.ename
  2  from emp e join dept d
  3  using(deptno);
select d.deptno,e.ename
       *
ERROR at line 1:
ORA-25154: column part of USING clause cannot have qualifier

SQL> select deptno,ename
  2  from emp e join dept d
  3  using(deptno);

    DEPTNO ENAME
---------- ----------
        20 SMITH
        30 ALLEN
        30 WARD
        20 JONES
        30 MARTIN
        30 BLAKE
        10 CLARK
        20 SCOTT
        10 KING
        30 TURNER
        20 ADAMS
        30 JAMES
        20 FORD
        10 MILLER

14 rows selected.

      表连接的用法,详见:
            
http://blog.csdn.net/holly2008/article/details/25704471
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值