looking for duplicates in table
-
Wednesday, January 30, 2013 9:21 AM
Hello there,
I ran into another (I hope the last) problem. I need to find and work with duplicates (Yes, I were watching How Do I videos by beth Massi), but only in table.
Lets say we have one table Table1 with properties Name and Number.
Data in it:
Expected output:
As you can see, I want to find duplicates, then I want to delete one of them and also the one which left update with value from deleted record. For example sum numbers like it is shown in pictures above.
To have table still up to date, it should be done in Table1Set_Inserted part of code I think. It is the place where I was trying to make it work.
I hope you can help me, because I were trying many forms of code, also trying to use lambda expression but there is still nothing working as expected.
Many thanks in advance
- Edited by eMCeee89 Wednesday, January 30, 2013 9:21 AM
All Replies
-
Wednesday, January 30, 2013 5:40 PMTry to use T-SQL
Norman
-
Friday, February 01, 2013 10:40 AMNot the answer I was expecting but thanks anyway ;)
-
Friday, February 08, 2013 3:40 AM
Looking at this it seems that there is either a schema/normalization problem, or you just need to create another table to handle the aggregated data you want to see in a particular screen. Each row entered in the database should (in theory) be a valuable input, and is the support for whatever you are trying to roll up. Having a dashboard to show summary data is great, but deleting as you aggregate is not a good idea.
-
Friday, February 08, 2013 4:21 AM
I have an idea for you, but it does use T-SQL:
If you leave the data as it is in your first screenshot, meaning that you only add records and don't delete the "duplicates", you can create a SQL view to show the aggregated data. The SQL code for the view would be something like this:
SELECT [Name], SUM([Number]) AS Number FROM Table1Set GROUP BY Name
Then add the view to your data source and use that as the source of the grid. This is of course readonly, but it may do what you need. You would just need another grid or detail screen to add/edit/delete the individual entries.
Mark

