SELECT
current timestamp -day(current date) days ,-- 上个月月末 ,能够知道跨年
CASE WHEN TO_CHAR('2012-01-01','Q') ='1' THEN to_char(year('2012-12-01')-1)||'-12'
when TO_CHAR('2012-01-01','Q') ='2' THEN to_char(year('2012-12-01')-1)||'-3'
when TO_CHAR('2012-01-01','Q') ='3' THEN to_char(year('2012-12-01')-1)||'-6'
when TO_CHAR('2012-01-01','Q') ='4' THEN to_char(year('2012-12-01')-1)||'-9'
END AS tt , -- 上个季月
current date - (month(current date) -1 ) month - day(current date) day --上年年末
from sysibm.sysdummy1;