Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select and Update from CTE
Message
From
30/06/2015 15:11:33
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01621599
Message ID:
01621619
Views:
31
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform