sql - Conditional RowNumber -
i trying put conditional numbering depending on result rownum column.
when rownum 1 have new column brand new increment 1.
in picture in column roomnum 5 should replaced 2, 9 3m 13 4, etc. doing wrong in query?
select case when rownum < 2 row_number() on ( partition scheme order scheme asc ) else null end roomnum, case when rownum > 1 null else scheme end scheme ,rownum
you need partition whether or not roomnm
null
. resulting value have case
:
select (case when roomnum not null row_number() on (partition scheme, (case when roomnum not null 1 else 0 end) order roomnum ) end) roomnum
Comments
Post a Comment