title: Netezza range of dates
body: <p>I want to solve an issue to reduce manual labour in a specific query. Hope i can phrase this correctly to be understood.</p>
  
  <p>In Netezza, I want to generate a (date ) value and run the query for every different value specified.
  What I want to do is <strong>replace all the unions into one query</strong>.</p>
  
  <pre><code>SELECT DISTINCT COUNT(DISTINCT a.x) AS NO_OF_X, a.column1, 'JAN 2019'
  FROM my_table a
  WHERE 1=1  
  AND current_date BETWEEN a.date_from and a.date_to
  
  GROUP BY 2,3  
  
  UNION ALL
  
  SELECT DISTINCT COUNT(DISTINCT a.x) AS NO_OF_X, a.column1, 'DEC 2018'
  FROM my_table a
  WHERE 1=1  
  AND '2018-12-31' BETWEEN a.date_from and a.date_to
  GROUP BY 2,3
  
  UNION ALL
  
  SELECT DISTINCT COUNT(DISTINCT a.x) AS NO_OF_X, a.column1, 'NOV 2018'
  FROM my_table a
  WHERE 1=1  
  AND '2018-11-30' BETWEEN a.date_from and a.date_to
  GROUP BY 2,3 
  </code></pre>
  
  <p>What i want to do is something like this </p>
  
  <pre><code>SELECT DISTINCT COUNT(DISTINCT a.x) AS NO_OF_X, a.column1, last_day( date ) as "MONTH"
  FROM my_table a
  WHERE 1=1  
  AND /*run the query for all last_days in a range */ 
  GROUP BY 2,3 
  </code></pre>
  
  <p>Is this possible? Tried to make a CTE but it is really important to get results for each specific last day of month, because our datawarehouse is designed, to store different time slices for each transaction etc. And i want to get only transactions with time slices on a specific last_day().</p>
  
  <p>Cheers.</p>