当前位置:Gxlcms > 数据库问题 > 数据库中的distinct关键字(去重)

数据库中的distinct关键字(去重)

时间:2021-07-01 10:21:17 帮助过:4人阅读

关于查询结果集的去重
  • 使用distinct关键字
    1、distinct意为:有区别的,用于去除重复记录。
    2、放在需要去重的字段前,而且必须在所有字段的最前面。
    3、多个字段前加distinct表示联合去重。
  • 单字段去重
    1、不加distinct关键字前:
    技术图片
    2、加distinct关键字后:
SELECT distinct job FROM powernode.emp;

技术图片

  • 多字段联合去重
SELECT distinct DEPTNO, job FROM powernode.emp;

技术图片

  • 与count连用
    统计岗位数量:
SELECT count(distinct job) 
FROM powernode.emp;

技术图片

数据库中的distinct关键字(去重)

标签:ima   tin   使用   image   数据库   nim   必须   img   load   

人气教程排行