Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Very complicated SQL
Message
De
16/02/2014 11:27:55
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01594412
Message ID:
01594456
Vues:
33
>
>;with cteInvoiceDetails as (select *, row_number() over (partition by InvoiceNo order by InvoiceDate DESC) as Rn)
>select * from cte c1 where Rn = 1 and NoStatus = 7 and 
>exists (select 1 from cte c2 where c2.InvoiceNo = c1.InvoiceNo and c2.Rn = 2 and NoStatus = 3) -- so, the previous row has status 3 and therefore this row may be deleted
>
Interesting approach, thanks
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform