zoukankan      html  css  js  c++  java
  • 可以以数据内容当列名来统计数据

    此SQL语句是来统计库存数量的
    SELECT TOP 100 PERCENT MAX(DISTINCT id) AS id, product_no, color, color2, product_type, SUM(number4) AS number, SUM(CASE WHEN ((product_size = '34' AND product_class = '女鞋') OR (product_size = '38' AND product_class = '男鞋') OR (product_class NOT IN ('女鞋', '男鞋'))) THEN number4 ELSE 0 END) AS size34, SUM(CASE WHEN ((product_size = '35' AND product_class = '女鞋') OR (product_size = '39' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size35, SUM(CASE WHEN ((product_size = '36' AND product_class = '女鞋') OR (product_size = '40' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size36, SUM(CASE WHEN ((product_size = '37' AND product_class = '女鞋') OR (product_size = '41' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size37, SUM(CASE WHEN ((product_size = '38' AND product_class = '女鞋') OR (product_size = '42' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size38, SUM(CASE WHEN ((product_size = '39' AND product_class = '女鞋') OR (product_size = '43' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size39, SUM(CASE WHEN ((product_size = '40' AND product_class = '女鞋') OR (product_size = '44' AND product_class = '男鞋')) THEN number4 ELSE 0 END) AS size40, MAX(price) AS price, MAX(price2) AS price2, MAX(price3) AS price3, MAX(price4) AS price4 FROM dbo.tbl_product_store WHERE (isnum2 = 1) AND (number4 > 0) GROUP BY product_no, color, color2, product_type ORDER BY product_no DESC 
  • 相关阅读:
    Java IO: 读取classpath资源
    Java IO: Reader和Writer
    Java IO: 读写zip文件
    OpenFlow运行机制总结
    OpenFlow流表概述
    Java日志系统(学习总结)
    卷积神经网络重要回顾
    Java Servlet学习笔记
    fragment实例
    Fragment应用
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1857121.html
Copyright © 2011-2022 走看看