sql - Conditional RowNumber -


i trying put conditional numbering depending on result rownum column.

when rownum 1 have new column brand new increment 1.

enter image description here

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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -