美文网首页
distinct()函数 去重

distinct()函数 去重

作者: 蔺蔺蔺赫赫 | 来源:发表于2019-07-19 15:24 被阅读0次

distinct()函数 去重

        8.0之前先排序 再去重 效率低

      select distinct(列) from 表名;

        想要在数据库中加入主键  必须确定库中的数据

        有无重复 否则会合并造成数据丢失

        select count(name) from world.city;不去重查看城市名的个数

       4079

        select count(distinct(name)) from world.city;去重查看城市名的个数

        3998

    统计酒表中物品卖出的总价

    select sum(价格*卖出数量) from 酒表;

    统计多个表中物品卖出的总价

        select sum(单价*数量) from (select 牌子,单价,数量 from 酒表

        union all

        select 牌子,单价,数量 from 进料表

        union all

        select 牌子,单价,数量 from 食品表);

    先生成一个临时表 再从临时表中进行统计

相关文章

  • sql 函数 单词整理

    distinct —— 去重函数 select distinct depart from teacher; b...

  • distinct()函数 去重

    distinct()函数 去重 8.0之前先排序 再去重 效率低 select distinct...

  • BI-SQL丨DISTINCT

    DISTINCT函数 在SQL中,DISTINCT函数也是常见函数之一,通常可以用来进行对表或者列进行去重操作。 ...

  • Django ORM去重

    distinct()具有去重功能是没有必要怀疑的,distinct()函数有一个隐藏特性,当使用distinct(...

  • Oracle数据库学习

    Select/条件和排序/单行函数(7.14) 条件查找 去重SELECT DISTINCT department...

  • 常见函数

    switch-case语句: 多重if语句: 分组函数:image.png distinct去重:image.pn...

  • MySQL

    in(a,b)包含not 非like "%a%" 模糊查找distinct 去重,如 count(distinct...

  • mysql distinct去重

    在使用distinct时发现,select distinct name from t1;会去掉重复的id记录。但是...

  • MySQL去重distinct

    在MySQL中需要查询表中不重复的记录时,可以使用distinct关键字过滤重复记录。 语法: select di...

  • 温故知新-MYSQL-语法

    查询数据 SELECT SELECT DISTINCT 去重查询 基础用法: SELECT DISTINCT la...

网友评论

      本文标题:distinct()函数 去重

      本文链接:https://www.haomeiwen.com/subject/nfmrlctx.html