Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 28 Apr 2003 @ 13:42:49 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: Moving through Cursor in Stored Procedure
 
From:   Taha, Sam

Joseph,

One thing I'm not sure about in your problem is are you trying to find duplicate rows (i.e. in a multiset table) or duplicate values in a column?

In either case, I could be over-simplifying your problem, but let me suggest something anyway (in case it might help). Since you want to compare a row/value to the next to see if they're the same, it implies ordering of some kind. And those duplicate rows/values will be deleted from another table. If you use the group by clause in sql, it would aggregate similar values together, then get those having count(*) > 1 and delete those ones from the other table.

Something like this:

delete from t2
where col1 in (
select col1 from (
select col1, count(*) as cnt
from t1
group by 1
having cnt > 1
) as dt1
)

I might be way off.. but if this helps then I think it would be a lot faster than cursor processing.

Sam Taha
Teradata - Canada



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016