zoukankan      html  css  js  c++  java
  • group by对已知的参数进行分类统计 子曰

    列中有五类参数,分别为“未售”“已售”“大定”“小定”“保留”,要对每类参数包含的数据进行统计

    关键sql语句:sum(case zhuangtai when '未售' then 1 else 0 end) as 未售

     

    完整sql:

    select project_name, 'zongshu'=count(*),sum(case zhuangtai when '未售' then 1 else 0 end) as 未售,sum(case zhuangtai when '已售' then 1 else 0 end) as 已售,sum(case zhuangtai when '大定' then 1 else 0 end) as 大定,sum(case zhuangtai when '小定' then 1 else 0 end) as 小定,sum(case zhuangtai when '保留' then 1 else 0 end) as 保留 from project_fj,project  where project.id=project_fj.project_id GROUP BY project_name
  • 相关阅读:
    UVA
    UVALive
    找一
    买书最低价格
    NABCD模型分析
    二维数组--首尾
    结对开发---环
    结对开发---二维数组
    电梯设计需求调研报告
    数组求和(2)
  • 原文地址:https://www.cnblogs.com/suixufeng/p/3336133.html
Copyright © 2011-2022 走看看