• mysql基础(2)-excel功能在excel中如何实现?


    1、vlookup功能:

    2、对比两列差异

    需求:对比sale的订单明细号与sale_guang订单明细号的差异

    SELECT * from sale a
    WHERE a.ordernum not in 
    (SELECT b.ordernum from sale_guang b);
    

    3、去除重复值

    需求:去除业务员编码的重复值

    SELECT * FROM sale
    where salesnum not in 
    (SELECT salesnum from sale GROUP BY salesman HAVING COUNT(salesnum)>1)
    

    4、缺失值处理

    需求:用0填充缺失值或则删除有地区名称缺失值的行。

    #用0填充:update sale set city = 0 where city = NULL
    #删除有缺失值的行:delete from sale where city = NULL;
    

    5、多条件筛选

    需求:想知道业务员张爱,在北京区域卖的商品订单金额大于等于6000的信息

    SELECT * from sale 
    where salesman = "张爱" 
    and city = "北京"
    and orderaccount >=6000;
    

    6、模糊筛选数据

    需求:筛选存货名称含有"三星"或则含有"索尼"的信息。

    SELECT * from sale 
    where inventoryname like "%三星%" or 存货名称 like "%索尼%";
    

    7、分类汇总

    需求:北京区域各业务员的利润总额。

    SELECT city,sum(`profit`) from sale
    WHERE city = "北京"
    GROUP BY `city`;
    

    8、条件计算

    需求:存货名称含“三星字眼”并且税费高于1000的订单有几个?这些订单的利润总和和平均利润是多少?

    #有多少个?SELECT COUNT(*) from sale 
    where inventoryname like "%三星%"
    and `tax` > 1000 ;
    
    #这些订单的利润总和和平均利润是多少?SELECT `ordernum`,SUM(profit),AVG(`profit`) from sale 
    where inventoryname like "%三星%"
    and `tax` > 1000 
    GROUP BY `ordernum`;
    

    9、删除数据间的空格

    需求:删除存货名称两边的空格。

    SELECT trim(inventoryname) from sale;

    10、合并与排序列

    需求:计算每个订单号的成本并从高到低排序(成本 = 不含税金额 - 利润)

    SELECT city,ordernum,(Nontaxamount - profit) as cost from sale
    order by cost DESC;
    

      

     

  • 相关阅读:
    一张900w的数据表,16s执行的SQL优化到300ms?
    webpack学习收集
    集合对象的string类型字段进行排序
    react 项目中使用antd的select组件placeholder不生效的解决方法
    React Hook做页面跳转以及携带参数,并且获取携带的值
    eclipse jar包 Source not found
    细说Redis分布式锁🔒
    Spring Boot中有多个@Async异步任务时,记得做好线程池的隔离!
    HDFS基本命令
    斐波那契数(Java)
  • 原文地址:https://www.cnblogs.com/Iceredtea/p/12198012.html
Copyright © 2020-2023  润新知