title: how to do cumulative sums in oracle
body: <p>I am new to SQL and I wanted to do a report which shows the daily number of tickets per shift and also the to-date total.</p>
  
  <p>Here's the query I have which shows the first 5 columns below:</p>
  
  <pre><code>    SELECT 
      TO_CHAR(DTTM,'YYYY-MM-DD') as "DATE"
      ,COUNT(CASE WHEN TO_CHAR(DTTM, 'HH24:MI') BETWEEN '14:00' AND '22:00' THEN TKTNUM ELSE NULL END) AS "DAYS"
      ,COUNT(CASE WHEN TO_CHAR(DTTM, 'HH24:MI') BETWEEN '06:00' AND '14:00' THEN TKTNUM ELSE NULL END) AS "MIDS"
      ,COUNT(CASE WHEN TO_CHAR(DTTM, 'HH24:MI') NOT BETWEEN '06:00' AND '22:00' THEN TKTNUM ELSE NULL END) AS "SWINGS"
      ,COUNT(TKTNUM) AS "TOTAL"
      FROM TKTHISTORY
      GROUP BY TO_CHAR(DTTM,'YYYY-MM-DD')
      ORDER BY TO_CHAR(DTTM,'YYYY-MM-DD')
  
  DATE        DAYS    MIDS    SWINGS  TOTAL   
  2019-08-01  8       13      1       22      22
  2019-08-02  19      5       3       27      49
  2019-08-03  23      6       6       35      84
  2019-08-04  7       9       13      29      113
  2019-08-05  4       17      2       23      136
  2019-08-06  10      5       16      31      167
  2019-08-07  3       12      11      26      193
  </code></pre>
  
  <p>The 6th column should be the cumulative sum for the dates. I tried browsing the internet and read about "over" and "partition by" but I still can't figure out how to use it :(</p>