title: SQL trunc/group/order by dates (day/month/quarter/year) with sum skip dates with no data
body: <p>I involved in project where I need to build histogram by dates. Before me this done in Java code by tons of SQL queries to DB for each rectangles (date subregions).</p>
  
  <p>I try another approach:</p>
  
  <pre>
  select sum(CNT), trunc(DATE, 'MM') from DATA
    where DATE &gt;= TO_DATE('01-01-2012','DD-MM-YYYY')
    and INC_DATE &lt;= TO_DATE('31-12-2012','DD-MM-YYYY')
    group by trunc(DATE, 'MM')
    order by trunc(DATE, 'MM');
  </pre>
  
  <p>and collect data from ResultSet in Java code. But if some month have no data, I miss rectangle in histogram!!!</p>
  
  <p>Is it possible to fix SQL (or may be PL/SQL) expression to include missing dates in result with zero sum?</p>
  
  <p>Or how to build more elegant date sequence generator in Java to find missing dates (aligned to days/months/quarters/years)?</p>