enumeration - Postgresql numbering groups of rows -


I have the next data table:

  Date of ID another_info 1 2014-02- 01 Lala 1 2014-03-11 Aajask 1 2014-05-13 KKFID 2 2014-02-01 Forever 3 2014-02-01 sfdg 3 2014-06-12 fdsA 4 2015-01-03 Lilo 4 2015-01-07 Kjlk  

I want to attach the column 'sequence_number':

  date of ID sequence_number another_info 1 2014-02-01 1 Lala 1 2014-03- 11 2 AZASK 1 2014-05-13 3 KIGRAF 2 2014-02-01 1 SADA 3 2014-02-01 1 SFDG 3 2014-06-12 2 FDA 4 2015-01-03 1 Lilo 4 2015-01-07 2 Klk  

for each ID, I line Add the number to table ID, date

. ID, "date", other_info, line_number () ID (ORDER according to "id"), from data_table as ID, to

by ID_table ID_table [ EDIT] did not realize that you need to divide by ID

  SELECT id, "date", another_info, row_number () over (according to data order by "date") sequence_number as data_table  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -