title: R: Total in the last 365 days window by month
body: <p>Sorry if i did something wrong in my first time using stackoverflow, and sorry everyone of you that waste time with me. I talked to some users and i can do something different. 
  defaults(today -60 until -365) after that time will have another column called loss, to take the rest of the values.</p>
  
  <p>Thanks everyone who helped me! problem solved!</p>
  
  <pre><code>            CASE
              WHEN TO_DATE(SYSDATE,'DD/MM/YY')-425 &lt;= TO_DATE(TRIM(DT_TRANSACAO),'DD/MM/YY')
              THEN SUM(VL_VENCIDO)
              ELSE 0
              END AS   VL_VENCIDO, ---defaults(today -60 until -365 days ago) 
              CASE
              WHEN TO_DATE(SYSDATE,'DD/MM/YY')-425 &gt; TO_DATE(TRIM(DT_TRANSACAO),'DD/MM/YY')
              THEN SUM(VL_VENCIDO)
              ELSE 0
              END AS   VL_PDD, --loss more than 425 days ago
           ---acumulated loss and defaults
          sum(VL_PDD) over (order by YEAR, MONTH) AS VL_AC_PDD, 
          sum(VL_VENCIDO) over (order by YEAR, MONTH) AS VL_AC_INADI
  </code></pre>
  
  <p>Thanks folks! And sorry again english is not my best skill! </p>