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 |
            +---------------------+
  • 相关阅读:
    弄清变量名字空间
    Perl中文编码的处理
    了解魔符的含义
    Log::Minimal 小型可定制的log模块
    Perl – 文件测试操作符
    在源代码中使用Unicode字符
    editplus乱码charset的奇怪问题
    ASP.NET程序中常用代码汇总(一)
    ASP.NET程序中常用代码汇总(三)
    ASP.NET程序中常用代码汇总(二)
  • 原文地址:https://www.cnblogs.com/xlwu/p/13639583.html
Copyright © 2011-2022 走看看