# Reorder rank upon condition

What i like to do is to rank that when a customer address come more than once ( like 1390 des Rosiers) the first of the group should be a uneven number while respecting the order in NoSeqTrt ?

Hoping that my explication is clear.

Cheers

Donne nous le data pas en image mais comme suivant

Create table sample

Insert into sample
Values

Here is the DDL

CREATE TABLE [dbo].[CUSTOM](
[Noseqtrt] [smallint] NULL,
[RANK] [int] NULL
) ON [PRIMARY]

VALUES (2,'133 Du Croissant-du-Bourg',1,1)
VALUES (2,'1440 des Roses',1,2)
VALUES (2,'1483 de Orchidée',1,3)
VALUES (2,'164 Du Croissant-du-Bourg',1,4)
VALUES (3,'1427 De Orchidée',1, 5)
VALUES (3,'1454 de Orchidee',1,6)
VALUES (4,'1328 de Orchidée',1,7)
VALUES (4,'1340 de Azalée',1,8)
VALUES (4,'1370 de Azalée',1,9)
VALUES (4,'1390 des Rosiers',1,10)
VALUES (4,'1390 des Rosiers',2,11)
VALUES (4,'1411 de Azalée',1,12)
VALUES (4,'1411 de Azalée',2,13)
VALUES (4,'68 du Camélia',1,14)
VALUES (6,'1361 de Ange-Gardien',1,15)
VALUES (7,'7 Montmarquet',1,16)
VALUES (8,'487 de la Seugne',1,17)

hi

please see what i have done .. hope its what you want !!!

please click arrow to the left for drop create sample data
``````drop table custom

CREATE TABLE [dbo].[CUSTOM](
[Noseqtrt] [smallint] NULL,
) ON [PRIMARY]

VALUES (2,'133 Du Croissant-du-Bourg')
VALUES (2,'1440 des Roses')
VALUES (2,'1483 de Orchidée')
VALUES (2,'164 Du Croissant-du-Bourg')
VALUES (3,'1427 De Orchidée')
VALUES (3,'1454 de Orchidee')
VALUES (4,'1328 de Orchidée')
VALUES (4,'1340 de Azalée')
VALUES (4,'1370 de Azalée')
VALUES (4,'1390 des Rosiers')
VALUES (4,'1390 des Rosiers')
VALUES (4,'1411 de Azalée')
VALUES (4,'1411 de Azalée')
VALUES (4,'68 du Camélia')
VALUES (6,'1361 de Ange-Gardien')
VALUES (7,'7 Montmarquet')
VALUES (8,'487 de la Seugne')
``````
``````select
*
, ROW_NUMBER() over(order by  [Noseqtrt] ) as Rank
from CUSTOM
``````

When i see a address twice the first row should be a uneven number.

Cheers

I realize that i need to develop an algo to resolve that.

Thanks for the help

Cheers

hi we can discuss
.. what your thoughts are through LIVE chatting

what do you mean by algo ???

this back and forth on Forum can go on = Many Many Times