Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing the last child record from same parent if seque
Message
 
 
À
29/06/2015 11:43:57
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01621484
Message ID:
01621556
Vues:
33
>>I don't understand your question. BTW, the query should be
>>
>>select * from cteRanges where Grp = 0 and RowNumber >=2 and Status = 7
>>
>>The idea is to mark consecutive ranges of the particular status.
>
>Yes, I did added the Status=7. But, that would not work.
>
>The sequence could be as follow:
>
>Created
>Uploaded
>Completed
>Assigned
>Completed
>Completed
>
>So, basically, in that case, only the last one should be removed as the first Completed is followed by a different status. The duplicates are only for those Completed, at the end.

What did select * from cteRanges order by DateCol DESC return? Did you list rows in the opposite order of the date? If yes, then the query I wrote from the top of my head should work. If you provide a quick test scenario with create table and insert rows statements, I would be able to test it.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform