zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    ssi服务器端指令
    json格式的转换为json字符串函数
    接口测试基础和jmeter
    【JZOJ6274】梦境
    【JZOJ6275】小L的数列
    【luoguP4721】分治 FFT
    【luoguP3868】猜数字
    中国剩余定理与扩展中国剩余定理
    【JZOJ6277】矩阵游戏
    【JZOJ6271】锻造 (forging)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317219.html
Copyright © 2011-2022 走看看