Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Very complicated SQL
Message
De
15/02/2014 14:06:28
 
 
À
15/02/2014 12:32:29
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:
01594421
Vues:
44
So what is the Relational filed between InvoiceDetail and Status when There is Nostatus field in InvoiceDetail.
Assuming Invoiceno, itself to be the relational filed try this SQL.

SELECT MAX(Invoiceno) as InvoiceNo FROM Invoicedetail GROUP BY ;
Invoiceno INTO CURSOR MAXINVOICE READWRITE && This Will Create a Cursor with all the latest (Last) Invoices

*Alter This Cursor and add a filed Status7 and Status3.
Alter Table MAXINVIOCE Add Column Status7 N(2) Add Column Status3 N(2)

*Update Status7 and Status3 of All invoices in MAXINVOICE as per your need and delete.

Regards













>I have a very specific operation I need to apply on a table to fix some data and remove some records.
>
>There is a master table Invoice. Then, I have child records in InvoiceDetail.
>
>We need to rollback a procedure that was done a few months ago because the requirements have been reversed.
>
>Basically, the InvoiceDetail records contain many records related to an Invoice and they have a NoStatus field.
>
>For every Invoice, I need to remove the last InvoiceDetail record if its NoStatus=7 but only if the previous InvoiceDetail record has NoStatus=3.
>
>I have been looking at various alternatives but I haven't found one that was conclusive so far.
>
>Anyone would have an idea of what kind of approach could be used here?
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform