1、关于查询结果集的去重?
    select distinct job from emp; //distinct关键字去除重复记录
    +—————-+
    | job |
    +—————-+
    | CLERK |
    | SALESMAN |
    | MANAGER |
    | ANALYST |
    | PRESIDENT |
    +—————-+
    select ename,distinct job from emp;
    以上sql语句是错误的。
    记住:distinct只能出现在所以字段的最前面,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 |
    +——————————-+