zoukankan      html  css  js  c++  java
  • MySQL某年查询12个月份的数据

    select
    case month(a.consignment_date) when '1' then sum(a.weight) else 0 end as 1月,
    case month(a.consignment_date) when '2' then sum(a.weight) else 0 end as 2月,
    case month(a.consignment_date) when '3' then sum(a.weight) else 0 end as 3月,
    case month(a.consignment_date) when '4' then sum(a.weight) else 0 end as 4月,
    case month(a.consignment_date) when '5' then sum(a.weight) else 0 end as 5月,
    case month(a.consignment_date) when '6' then sum(a.weight) else 0 end as 6月,
    case month(a.consignment_date) when '7' then sum(a.weight) else 0 end as 7月,
    case month(a.consignment_date) when '8' then sum(a.weight) else 0 end as 8月,
    case month(a.consignment_date) when '9' then sum(a.weight) else 0 end as 9月,
    case month(a.consignment_date) when '10' then sum(a.weight) else 0 end as 10月,
    case month(a.consignment_date) when '11' then sum(a.weight) else 0 end as 11月,
    case month(a.consignment_date) when '12' then sum(a.weight) else 0 end as 12月,
    a.department AS 部门,
    b.dealings_abbreviation AS 供应商
    from bm_shipment_quantity a left join bd_current_unit_alias b on a.supplier=b.id
    where date_format(a.consignment_date, '%Y') IN ('2019','2020','2021','2022','2023','2024','2025','2026','2027','2028')
    GROUP BY a.consignment_date,a.weight

  • 相关阅读:
    判断
    数的读写
    单词长度
    c语言字符串大小写字母转换
    URL超长问题
    使用Loadrunner录制手机端http请求
    NoSql 数据库理解
    .NET, ASP.NET, ADO.NET, C# 区别
    Browser 对象
    装箱与拆箱
  • 原文地址:https://www.cnblogs.com/qijiang123/p/14780094.html
Copyright © 2011-2022 走看看