zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-153题

    153. View the Exhibits and examine the structures of the PRODUCTS and SALES tables.

    Which two SQL statements would give the same output? (Choose two.)

    A. SELECT prod_id FROM products

    INTERSECT

    SELECT prod_id FROM sales;
    B. SELECT prod_id FROM products

    MINUS

    SELECT prod_id FROM sales;

    C. SELECT DISTINCT  p.prod_id

    FROM products p JOIN sales s

    ON p.prod_id=s.prod_id;

    D. SELECT DISTINCT p.prod_id

    FROM products p JOIN sales s

    ON p.prod_id <> s.prod_id;

    Answer: AC

    答案解析:

    A:所有的产品和已卖出的产品相交,即返回已经卖出去的产品的id。

    sh@TEST0924> SELECT prod_id FROM products
      2  INTERSECT
      3  SELECT prod_id FROM sales;
     
       PROD_ID
    ----------
            13
            14
            15
            16
    ...
           148
     
    72 rows selected.默认升序排列。
     

    B:所有的产品和已卖出去的产品相减,即返回没有卖出去的产品。

    sh@TEST0924> SELECT prod_id FROM products
      2  MINUS
      3  SELECT prod_id FROM sales;
     
    no rows selected
     
     

    C:返回已卖出去的产品的id

    sh@TEST0924> SELECT DISTINCT  p.prod_id
      2   FROM products p JOIN sales s
      3  ON p.prod_id=s.prod_id;
     
       PROD_ID
    ----------
            22
            25
     
    ...
           139
     
    72 rows selected.
     
    D答案:会把所有的都显示出来
    sh@TEST0924> SELECT DISTINCT p.prod_id
      2  FROM products p JOIN sales s
      3  ON p.prod_id <> s.prod_id;
     
     
       PROD_ID
    ----------
            13
            14
    ...
           148
     
    72 rows selected.
     
     
    INTERSECT Example The following statement combines the results with the INTERSECT operator, which returns only those unique rows returned by both queries

    返回共同有的唯一的行

    MINUS Example The following statement combines results with the MINUS operator, which returns only unique rows returned by the first query but not by the second

    返回第一个有,第二个表无的行

    官方参考:http://docs.oracle.com/cd/E11882_01/server.112/e41084/queries004.htm#i2054381

     
  • 相关阅读:
    案例十:shell编写nginx服务启动程序
    Linux在实际中的应用
    案例九:shell脚本自动创建多个新用户,并设置密码
    数据架构的演变
    第一个Struts2程序
    关于eclipse导入Tomact报404的问题
    单选框 RadioButton
    EditText编辑框
    Button控件的三种点击事件
    1319: 同构词
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317162.html
Copyright © 2011-2022 走看看