• 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

     
  • 相关阅读:
    R-CNN学习笔记
    Numpy和Pandas
    用python解决打标签时将xml文件的标签名打错
    爬虫Ⅱ:scrapy框架
    爬虫Ⅰ:爬虫的基础知识
    Linux学习笔记
    MySql笔记Ⅱ
    MySql笔记Ⅰ
    Qt数据库报错:“Unable to execute statement”
    Qt数据库报错“out of memory Error opening database“
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317162.html
Copyright © 2020-2023  润新知