title: Dealing with overlapping conditions in CASE statement
body: <pre><code>SELECT (CASE WHEN ymd BETWEEN CURRENT_DATE -4 AND CURRENT_DATE -1 THEN '3day total' 
  WHEN ymd BETWEEN CURRENT_DATE -11 AND CURRENT_DATE -1 THEN '10day total' 
  WHEN ymd BETWEEN CURRENT_DATE -31 AND CURRENT_DATE -1 THEN '30day total' END) AS 'Period',
  SUM(cost) cost
  FROM table
  WHERE ymd BETWEEN CURRENT_DATE -31 AND CURRENT_DATE -1
  GROUP BY 1
  </code></pre>
  
  <p>The result actually seems to give me Period buckets of days 1-3, days 4-10 and days 11-30. I believe this is because there are overlapping conditions and SQL stops processing the CASE statement as soon as the first condition is met.</p>
  
  <p>What I want are the totals for each bucket (ie 3 day sum, 10 day sum and 30 day sum).</p>
  
  <p>Is there a way to do this without adding additional fields?</p>
  
  <p>PS - the syntax is a bit different then traditional sql because it's vsql (vertica).</p>