title: Select Row number in postgres
body: <p>How to select row number in postgres.</p>
  <p>I tried this:</p>
  <pre><code>select
      row_number() over (ORDER BY cgcode_odc_mapping_id)as rownum,
      cgcode_odc_mapping_id
    from access_odc.access_odc_mapping_tb
    order by cgcode_odc_mapping_id
  </code></pre>
  <p>and got this error:</p>
  <pre>
  ERROR: syntax error at or near "over"
  LINE 1: select row_number() over (ORDER BY cgcode_odc_mapping_id)as
  </pre>
  <p>I have checked these pages : <a href="https://stackoverflow.com/questions/3397121/how-to-show-row-numbers-in-postgresql-query">How to show row numbers in PostgreSQL query?</a></p>
  <hr />
  <p>This is my query:</p>
  <pre><code> select row_number() over (ORDER BY cgcode_odc_mapping_id)as rownum,cgcode_odc_mapping_id from access_odc.access_odc_mapping_tb order by cgcode_odc_mapping_id 
  </code></pre>
  <p>this is the error:</p>
  <p>ERROR: syntax error at or near &quot;over&quot; LINE 1: select row_number() over (ORDER BY cgcode_odc_mapping_id)as</p>