频道栏目
首页 > 资讯 > DB2 > 正文

DB2 sql上期(月、季、年)上月月末,上季末,上年末(统计中常用到)

13-02-25        来源:[db:作者]  
收藏   我要投稿
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; 
 
相关TAG标签
上一篇:JSON对象与JSON字符串相互转换
下一篇:jQuery Mobile 加载对话框页面时同名javascript函数冲突、覆盖问题
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站