sum和case
来源:互联网 发布:乔丹各赛季数据统计 编辑:程序博客网 时间:2024/05/22 23:27
近期写SQL统计,用到了SUM,还有case,用得麻溜麻溜的。
自我欣赏一下:
select 所在重点区域,sum(case b when 1 then 1 else 0 end) Builded,sum(case b when 0 then 1 else 0 end) Building,sum(case b when -1 then 1 else 0 end) Willfrom(select 所在重点区域,1 b from sde.station_gh where 建设状况='已建'union allselect 所在重点区域,0 b from sde.station_gh where 建设状况='在建'union allselect 所在重点区域,-1 b from sde.station_gh where 建设状况='拟建') tgroup by 所在重点区域select 监测目标,sum(case b when 1 then 1 else 0 end) Builded,sum(case b when 0 then 1 else 0 end) Building,sum(case b when -1 then 1 else 0 end) Willfrom(select 监测目标,1 b from sde.station_gh where 建设状况='已建'union allselect 监测目标,0 b from sde.station_gh where 建设状况='在建'union allselect 监测目标,-1 b from sde.station_gh where 建设状况='拟建') tgroup by 监测目标
阅读全文
0 0
- sum和case
- count, sum和 if,case when
- Nhibernate Hql查询使用 sum 和 case 组合
- Nhibernate Hql查询使用 sum 和 case 组合
- 使用COALESCE+SUM+CASE
- mysql sum case when
- Oracle 集合函数(count,sum等)和case when的组合使用
- Oracle 集合函数(count,sum等)和case when的组合使用-使用举例
- static case 和Dynamic case
- static case 和Dynamic case
- 巧用case进行分类求和(case & group by & sum)
- sum(case when then)(男女生的个数)
- SQL sum case when then else
- sum(case when ... then end) 使用
- sql case语法和plsql case语法
- 简单Case函数和Case搜索函数。
- scala之case class 和case object
- case when 和 coalesce
- HDU 6166 Senior Pan (2017多校9
- 集合框架(续) java中Collection和collections的区别
- git-分布式版本控制系统学习笔记
- jdbc
- 图像语义分割:从头开始训练deeplab v2系列之一【源码解析】
- sum和case
- 理解RESTFUL架构
- JavaWeb(二)jsp运行原理,九大内置对象
- 网络编程--常用API
- Python的安装环境和IDE
- -------------linux系统调用-----------
- Python 基础
- 扑克牌顺子
- 求后序遍历