Oracle分组后计数
2015-12-24 17:04
483 查看
select
to_char(t.djrq,'yyyy') Year,
to_char(t.djrq,'mm') Month,
to_char(t.djrq,'dd') Day,
substr(t.jg,1,6) AreaCode,
sum(case when t.stable in ('jh','jhbl') then 1 else 0 end) TotalMarriageCount,
sum(case when t.stable in ('lh','lhbl') then 1 else 0 end) TotalDivorceCount
from psn_mz_hunyin t
group by
to_char(t.djrq,'yyyy'),
to_char(t.djrq,'mm'),
to_char(t.djrq,'dd'),
substr(t.jg,1,6)
to_char(t.djrq,'yyyy') Year,
to_char(t.djrq,'mm') Month,
to_char(t.djrq,'dd') Day,
substr(t.jg,1,6) AreaCode,
sum(case when t.stable in ('jh','jhbl') then 1 else 0 end) TotalMarriageCount,
sum(case when t.stable in ('lh','lhbl') then 1 else 0 end) TotalDivorceCount
from psn_mz_hunyin t
group by
to_char(t.djrq,'yyyy'),
to_char(t.djrq,'mm'),
to_char(t.djrq,'dd'),
substr(t.jg,1,6)
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- SQL中的三值逻辑
- SQL Server 作业批量停止
- 结束SQL阻塞的进程
- 动态生成SQL Server视图作业
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- 我是运营,我没有假期
- Oracle 10g R2不能使用EM的问题
- SQL Server 语句操纵数据库
- 表空间操作
- PreparedStatement中in子句的处理
- SQL(结构化查询语句)
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法