zoukankan      html  css  js  c++  java
  • 18 关于查询结果集的去重?

    18 关于查询结果集的去重?
        select distinct job from emp; // distinct 关键字 去除重复记录。
            +-----------+
            | job       |
            +-----------+
            | CLERK     |
            | SALESMAN  |
            | MANAGER   |
            | ANALYST   |
            | PRESIDENT |
            +-----------+
     
        select ename,distinct job from emp;
        这条语句是错误的。
        记住:distinct只能出现在所有字段的最前面
        
        select distinct deptno,job from emp;
            +--------+-----------+
            | deptno | job       |
            +--------+-----------+
            |     20 | CLERK     |
            |     30 | SALESMAN  |
            |     20 | MANAGER   |
            |     30 | MANAGER   |
            |     10 | MANAGER   |
            |     20 | ANALYST   |
            |     10 | PRESIDENT |
            |     30 | CLERK     |
            |     10 | CLERK     |
            +--------+-----------+
        
    案例:统计岗位的数量?
        select count(distinct job) from emp;
            +---------------------+
            | count(distinct job) |
            +---------------------+
            |                   5 |
            +---------------------+
  • 相关阅读:
    如何用Android Studio打多包名APK
    EventBus框架在Android多Pane(Fragment)中的应用
    Android WebView使用深入浅出
    dp和px转换
    android button minheight问题
    Java链式编程接口
    Java多线程共享变量控制
    一致性Hash算法
    ARP (地址解析协议)
    FTP下载导致Zip解压失败的原因
  • 原文地址:https://www.cnblogs.com/xlwu/p/13639583.html
Copyright © 2011-2022 走看看