zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-140题

    140. Examine the structure of the PRODUCTS table:

    name          Null        Type

    PROD_ID       NOT NULL    NUMBER(4)

    PROD_NAME                VARCHAR2(20)

    PROD_STATUS              VARCHAR2(6)

    QTY_IN_HAND              NUMBER(8,2)

    UNIT_PRICE               NUMBER(10,2)

    You want to display the names of the products that have the highest total value for UNIT_PRICE *

    QTY_IN_HAND.

    Which SQL statement gives the required output?

    A. SELECT prod_name 

    FROM products 

    WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) 

    FROM products);

    B. SELECT prod_name 

    FROM products 

    WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) 

    FROM products 

    GROUP BY prod_name);

    C. SELECT prod_name 
    FROM products 

    GROUP BY prod_name 

    HAVING MAX(unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) 

    FROM products 

    GROUP BY prod_name);

    D. SELECT prod_name 

    FROM products 

    WHERE (unit_price * qty_in_hand) = (SELECT MAX(SUM(unit_price * qty_in_hand)) 

    FROM products) 

    GROUP BY prod_name;

    Answer: A

    答案解析:

    BC都犯了一个错误,都会返回一个错误single-row subquery returns more than one row。

    即是单行子查询返回了多行。该WHERE子句包含一个等于(=) 运算符,该运算符是一个只需要一个值的单行比较运算符。=运算符无法接受子查询中的多个值,因此产生了错误。

    D的查询条件不满足题意。

  • 相关阅读:
    hdu3499---玄学的分层图
    选择合适的最短路--hdu3499
    次小生成树
    poj-1511
    2018SDIBT_国庆个人第六场
    2018SDIBT_国庆个人第五场
    2018SDIBT_国庆个人第四场
    2018SDIBT_国庆个人第三场
    2018SDIBT_国庆个人第二场
    java项目中异常处理情况
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13316849.html
Copyright © 2011-2022 走看看