March 30, 2006 at 9:22 am
Hi i need some help on deleting duplicates from columns.
I have a table
A | B | C |
1 | 2 | 9 |
2 | 3 | 2 |
1 | 5 | 4 |
4 | 2 | 2 |
1 | 2 | 5 |
and i want the output some what like this
A | B | C |
1 | 9 | |
2 | 3 | 2 |
5 | 4 | |
4 | 2 | |
5 |
If there are any duplicates in a column doesnt matter where ever it is mentioned but it should be mentioned only ones. Ex in column A i have got 3 duplicates (1). I want 1 to be displayed only once in that column no matter where ever it is and the remaining should be left blank. Can anyone please suggest me a way to proceed.
March 30, 2006 at 9:32 am
The results you want are easily generated by three seperate distinct statements.
Select Distinct A From Table
Select Distinct B From Table
Select Distinct C From Table
Unless there is some relation between A, B, and C though, you won't be putting them into a single result. And it looks like there isn't by what you are asking. At the best, you could create a temp table, and insert the results of your disctinct statements into row 1, 2, 3, 4, 5, etc....giving you a single result having the columns with the distinct values, but not really usable in any manner other than three different columns of distinct values....
On another thought, why are these in the same table, if they are not related? It violates entity modeling, and proper table structure.
The reverse of this, deleting the dups could be accomplished by walking the table, and updating the values of previously found values to '' where rownumber is greater than the first occurrance....
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply