Retaining 1 random record among many duplicates
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Retaining 1 random record among many... Expand / Collapse
Author
Message
Posted 6/14/2006 3:31:16 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/14/2006 3:28:00 PM
Posts: 1, Visits: 1
I wanted a query to delete duplicate (retain ANY 1 row) in Teradata table, without creating any volatile table or complex logic. Wanted your inputs in this regard. In oracle we can do this with “row-id”, I was wondering if we can have access to “Primary Index” or “hash value” for a column?

I want a statement like: Delete my.table where primary-key-columns-or-all-column-list not in (Select 1 duplicate row from my.table )

Query to find Duplicates:

Select primary-key-columns-or-all-column-list, count(*)
From my.table
Group by primary-key-columns-or-all-column-list
Having count(*) > 1;


Possible solutions in Teradata:

Do an INSERT-SELECT into another table
with the group-by-all-columns (or EXCEPT logic)
Or utility load into a SET table instead of MULTISET so as to not permit
duplicate rows in the future.

OR

create set table t2 as t1 with data;

T1 is multiset table with duplicate rows.
This sql will create t2 table without duplicate rows of t1 table.



(maheshalways)MP
Post #4376
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 3:01pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.078. 10 queries. Compression Disabled.