zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-题目解析-第14题

    14. Using the CUSTOMERS table,  you need to generate a report that shows 50% of each credit 
          amount in each income level. The report should NOT show any repeated credit amounts in each income  level. 
          Which  query would give the required result? 
    (题意:使用客户表,须要做一个报表,列出每一个收入等级的信用额度的50%,并去除反复值。以下的哪个查询语句能够得到这个结果?)
    A. 
    SELECT  cust_income_level, DISTINCT cust_credit_limit * 0.50    
    AS "50% Credit Limit" 
    FROM customers; 
    B. 
    SELECT DISTINCT cust_income_level, DISTINCT cust_credit_limit * 0.50    
    AS "50% Credit Limit" 
    FROM customers; 
    C. 
    SELECT DISTINCT cust_income_level   ' '  cust_credit_limit * 0.50 
    AS "50% Credit Limit" 
    FROM customers; 
    D. 
    SELECT cust_income_level ' ' cust_credit_limit * 0.50 
    AS "50% Credit Limit" 
    FROM customers; 

    Answer: C

    题目解析:

    这道题是关于distinct的使用方法:
    1.distinct仅仅能放在第一个字段的前面,如Select distinct x,y from t,
    2.当distinct后有多个字段时,表示全部字段的值都同样才视为反复值,如Select distinct x,y from t,
      仅仅有当x,y的值都同样时,才视为反复值去除。

    所以选项AB是语法错误,选项D没有去除反复值,不合题意。
    事实上C也有点错误,正确的写法是:

    SELECT DISTINCT cust_income_level || cust_credit_limit * 0.50 
    AS "50% Credit Limit" 
    FROM customers; 

    语句中的''应该换成连接符||

  • 相关阅读:
    关于hql执行带有case when 的语句问题,另:数据表的倒置
    xslt 转换 xml
    xsd校验xml
    java 调用存储过程
    js return无效,表单自动提交
    bat 启动java程序
    Delphi 窗体拖动,无边框,透明的设置
    installshield实例(三)发布,补丁,升级
    Installshield实例(二)创建自定义界面
    InstallShield 实例(一)检测JDK,MYSQL,创建数据库
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4009505.html
Copyright © 2011-2022 走看看