Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicates are known and now to delete them
Message
From
24/04/2012 17:41:48
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01542530
Message ID:
01542534
Views:
38
>Assuming you want to keep the first entry:
>
>
>;with cte as (select PK, row_number() over (partition by all these fields order by DateFld) as Rn from Client)
>
>delete from cte where Rn > 1
>
>
>This will keep the row with the first date. You can pick any other column in the order by and if you don't care which row to keep you can use
>
>ORDER BY (select 0)

It is not clear how I should integrate this cte syntax into the original SQL. Could you just show me an example? 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform