See below DDL:
create table Test (RevObjId int, LegalPartyId int, IsPrimary int)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (10, 20, 0)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (10, 21, 0)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (10, 22, 1)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (11, 20, 1)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (11, 21, 0)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (12, 30, 1)
insert into Test (RevObjId, LegalPartyId, IsPrimary) values (13, 40, 0)
I am looking for the result below:
RevObjId LegalPartyId IsPrimary RowNumber
10 22 1 1
10 20 0 2
10 21 0 3
11 20 1 5
11 21 0 6
12 30 1 7
13 40 0 9
When I use the following query:
select RevObjId,
LegalPartyId,
IsPrimary,
row_number() over(partition by RevObjId order by RevObjId asc,IsPrimary desc,LegalPartyId asc) as RowNumber
from test;
I get the line numbers in the sequence, each line is incremented by one, the line numbers get reset after changing the section. How to change the line number to the next odd number when changing the section (by RevObjId)? Here is my SQL Fiddle
http://sqlfiddle.com/#!6/01d5c/22
We need gaps between line numbers because I need to generate a report in the following format.

Here is the support question I asked:
How to convert each row to column in T-SQL?