title: oracle sql query to list all the dates of previous month
body: <p>Guys  i have a requirement to list all the dates of the previous month  like below</p>
  
  <pre><code>20101201
  20101202
  20101203
  20101204
  20101205
  ..
  ..
  ..
  ..
  ..
  ..
  ..
  ..
  20101231
  </code></pre>
  
  <p>kindly let me know if any better way to do than this query.</p>
  
  <pre><code>select TO_CHAR(TRUNC(SYSDATE,'MM')-1,'YYYYMMDD')-(level-1) as 
  EACH_DATE from dual A connect by level 
  &lt; (TO_NUMBER(TO_CHAR(TRUNC(SYSDATE,'MM')-1,'DD'))+1)
  </code></pre>
  
  <p>Also please let me know the problem with this query it says <strong>"missing right parenthesis"</strong></p>
  
  <pre><code>SELECT /*+ PARALLEL (A,8) */ /*+ DRIVING_STATE */
     TO_CHAR(TRUNC(TRUNC(SYSDATE,'MM')-1,'MM'),'MONYYYY') "MONTH", TYPE AS "TRAFF",     COLUMN, A_COUN AS "A_COUNT",COST  FROM DATA_P B WHERE  EXISTS  
  (  
    select TO_NUMBER(TO_CHAR(TRUNC(SYSDATE,'MM')-1,'YYYYMMDD')-(level-1))  EACH_DATE 
    from dual A connect by  level &lt; TO_NUMBER(TO_CHAR(TRUNC(SYSDATE,'MM')-1,'DD')+1) 
    WHERE A.EACH_DATE = B.DATE  order by EACH_DATE ASC
   )
  </code></pre>
  
  <p><strong><em>emphasized text</em></strong></p>