• OCP-1Z0-051-V9.02-142题


    142. View the Exhibit and examine the structure of the PRODUCTS table.

    Evaluate the following query:

    SQL> SELECT prod_name

    FROM products

    WHERE prod_id IN (SELECT prod_id FROM products                   

    WHERE prod_list_price =                         

    (SELECT MAX(prod_list_price)FROM products                          

    WHERE prod_list_price <                               

    (SELECT MAX(prod_list_price)FROM products)));

    What would be the outcome of executing the above SQL statement? 

    A. It produces an error.

    B. It shows the names of all products in the table.

    C. It shows the names of products whose list price is the second highest in the table.

    D. It shows the names of all  products whose list price is less than the maximum list price.

    Answer: C

     

    答案解析:

    1、首先来运行一下上面的sql语句,是可以出结果的。

    sh@TESTDB> SELECT prod_name FROM products
      2  WHERE prod_id IN (SELECT prod_id FROM products
      3  WHERE prod_list_price =
      4  (SELECT MAX(prod_list_price)FROM products
      5  WHERE prod_list_price <
      6  (SELECT MAX(prod_list_price)FROM products)));
    PROD_NAME
    --------------------------------------------------
    Mini DV Camcorder with 3.5" Swivel LCD
    2、拆分上面sql语句,首先运行子句查询出价格最高的产品的价格
    sh@TESTDB> SELECT MAX(prod_list_price)FROM products;
    MAX(PROD_LIST_PRICE)
    --------------------
                 1299.99
    3、低于价格最高的,即价格次高的产品。按题意,故选C.
    sh@TESTDB> SELECT MAX(prod_list_price)FROM products
      2  WHERE prod_list_price < 1299.99;
    MAX(PROD_LIST_PRICE)
    --------------------
                 1099.99
  • 相关阅读:
    第十三周
    意见评论
    第十二周
    冲刺10
    冲刺9
    冲刺8
    团队冲刺第二十二天-KeepRunningAPP
    找水王
    第十四周总结
    搜狗输入法评价
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317219.html
Copyright © 2020-2023  润新知