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 |
            +---------------------+
  • 相关阅读:
    鼠标移动,背景变色
    datatable 删除行
    GridView新增一行,更新所有行實現
    让层垂直居中于浏览器窗口
    extjs学习笔记(转)
    Extjs中的panel
    JDK和JRE的区别(转)
    EXTJS中form添加按钮触发事件
    web.xml详解
    Oracle数据库中的诊断文件(转)
  • 原文地址:https://www.cnblogs.com/xlwu/p/13639583.html
Copyright © 2011-2022 走看看