如何获得计数的滚动视图?

时间:2015-09-09 17:17:30

标签: sql oracle to-date

目标是从指定日期算起三个月内符合条件的任何人。 (BetweenDate -3个月)是棘手的部分。我在距离getDate()不到3个月的年度窗口内开展业务。我需要在距离Y的3个月内三个月之内。有任何想法吗?

CREATE TABLE MONTH3LOOK AS Select 
to_CHAR(DATE_OF_SERVICE_3013,'YYYY-MM') "Date"

,COUNT(DISTINCT case when (regexp_instr(IS_CONCAT,'(2957|29570|29571|29572|29573|29574|29575|29576|29577|29578|29579)')>0)
 and 
 (DATE_OF_SERVICE_3013 between trunc(DATE_OF_SERVICE_3013,'MM') and add_months(trunc(DATE_OF_SERVICE_3013,'MM'),-3))
then USER end) AS Recip


FROM .NET_SERVICE
WHERE DATE_OF_SERVICE_3013 BETWEEN 
TO_DATE('2013-10','YYYY-MM') AND 
TO_DATE('2014-03','YYYY-MM')

group by to_CHAR(DATE_OF_SERVICE_3013,'YYYY-MM')

0 个答案:

没有答案