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
  • 相关阅读:
    网络受限下,使用Nexus要解决的两个问题
    Nexus远程Maven仓库索引下载教程
    maven--私服的搭建(Nexus的使用)
    maven命令/依赖/聚合
    mybatis常用jdbcType数据类型
    Lombok 安装、入门
    jquery append 动态添加的元素事件on 不起作用的解决方案
    Maximum Sum on Even Positions
    哈密顿
    计算几何基础
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317219.html
Copyright © 2011-2022 走看看