三九宝宝网宝宝百科宝宝知识

DB2数据日期字段为varchar字段想取出月份进行比较

01月07日 编辑 39baobao.com

with t1(m, d) as ( select '2013/01/13', 10000 from sysibm.sysdummy1 union all select '2013/01/03', 5000 from sysibm.sysdummy1 union all select '2013/02/03', 5000 from sysibm.sysdummy1 union all select '2013/04/03', 5000 from sysibm.sysdummy1 union all select '2013/11/03', 5000 from sysibm.sysdummy1),t2(m,d) as ( select case when substr(m,6,2) in ('01','02','03') then '1-3月' when substr(m,6,2) in ('04','05','06') then '4-6月' when substr(m,6,2) in ('07','08','09') then '7-9月' else '10-12月' end, d from t1)select m, sum(d) from t2group by m...

推荐阅读
图文推荐