-2

The table is this enter image description here

The row_number in this is wrong, I want to to compute it in order to group the dates by real weeks (from monday to sunday), i.e. 1 for the first 4 rows, 2 for rows from 5 to 8, 3 for rows from 9 to 13 and so on. Maybe this can be solve with rank, but notice the desired column not always is determined by the change in year_week. The resulting table would be: enter image description here

The Student
  • 109
  • 4
  • From the terminology perspective you are describing `rank` and not `row_number`. Have a look: https://stackoverflow.com/questions/7747327/sql-rank-versus-row-number – PM 77-1 Jul 01 '22 at 16:31
  • Ok, with the name of the desired column I didn't want to meaning the function to solve the problem. Thanks! – The Student Jul 01 '22 at 16:47

1 Answers1

0

Just for close the answer... After some searching I found this problem can ve solve with the function CONDITIONAL_CHANGE_EVENT(), this is not implemented in all SQL lenguages, but can be explicited. Check Is there any alternative to Vertica's conditional_true_event in RedShift? for more information.

The Student
  • 109
  • 4