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
  • 相关阅读:
    C语言内存分析
    算法之快速排序
    单链表逆转
    C程序设计语言之一
    vim插件配置(一)
    makefile示例
    cocos2d基础入门
    Makefile
    Makefile
    GCC编译四阶段
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317219.html
Copyright © 2011-2022 走看看