How to select row number in postgres.
I tried this:
select row_number() over (ORDER BY cgcode_odc_mapping_id)as rownum, cgcode_odc_mapping_id
SELECT tab.*, row_number() OVER () as rnum FROM tab;
Here's the relevant section in the docs.
P.S. This, in fact, fully matches the answer in the referenced question.