Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get all records except the latest
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01356683
Message ID:
01356735
Vues:
24
>>I need to update all duplicates by FK and Flag = 1 to set flag = 0 except for the latest by Date1 and Date2. I already did it by procedural code, but curious if it's possible to get the records to update by SQL.
>
>Basically you will be updating your table using the PK from ..
>
>selecting TOP 1 PK from (your duplicate selection statement) order by Date1 desc
>
>and
>
>selecting TOP 1 PK from (your duplicate selection statement) order by Date2 desc

Not exactly. I need to update all records which are duplicates except for the top 1. I guess in SQL Server you can use CTE to get all duplicates.

Still a bit tricky.
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