设为首页 加入收藏

TOP

DB2 sql上期(月、季、年)上月月末,上季末,上年末(统计中常用到)
2014-11-23 21:58:49 来源: 作者: 【 】 浏览:4
Tags:DB2 sql 上期 (月 上月 月末 季末 年末 统计 中常 用到
DB2 sql上期(月、季、年)上月月末,上季末,上年末(统计中常用到)
SELECT
current timestamp -day(current date) days ,-- 上个月月末 ,能够知道跨年
/*
to_date('2013-02-23','yyyy-mm-dd') -day(current date) days ,-- 上个月月末 ,能够知道跨年 www.2cto.com
*/
CASE WHEN TO_CHAR('2012-06-22','Q') ='1' THEN to_char(year('2012-12-01')-1)||'-12'
when TO_CHAR('2012-06-22','Q') ='2' THEN to_char(year('2012-06-22'))||'-3'
when TO_CHAR('2012-01-01','Q') ='3' THEN to_char(year('2012-12-01'))||'-6'
when TO_CHAR('2012-01-01','Q') ='4' THEN to_char(year('2012-12-01'))||'-9'
END AS tt , -- 上个季月 能够知道跨年
current date - (month(current date) -1 ) month - day(current date) day --上年年末
from sysibm.sysdummy1;
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle更改表空间文件位置 下一篇oracle11g更改字符集AL32UTF8为ZH..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: