Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select and Update from CTE
Message
De
30/06/2015 15:11:33
 
 
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:
01621599
Message ID:
01621619
Vues:
29
>So, for that parent, which child row (AddDate) do you want to grab?

That would be the same we are deleting. So, the goal is to update the parent from Invoice.AddDate value, but just before we remove the child record. So, basically, we are trying to simulate in time the parent value as if the unnecessary child record would not have been created.

As per verification, in the second line, it was supposed to be 1.
SELECT InvoiceTemp.NoClient,InvoiceTemp.AddDate FROM InvoiceTemp
 WHERE InvoiceTemp.RowNumber=1 AND InvoiceTemp.NoStatus=7 AND
  EXISTS (SELECT InvoiceTemp.Numero FROM InvoiceTemp AS InvoiceTemp2
   WHERE InvoiceTemp2.RowNumber=2 AND InvoiceTemp2.NoStatus=7 AND InvoiceTemp.NoClient=InvoiceTemp2.NoClient)
With that, it works.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform