I need to create a stored procedure that processes a table looking for rows matching on a particular id with different statuses.
I know the syntax to get the row data but i have never tried comparing 2 rows from the same table before? How is it done? Would i need to use variables to store the data from each? Or some other way?
This question is a based on this one, but on Oracle with some modifications:
First one this table may or may not have many to many, many to one, one to many relations with other tables.
Edit 1:
Table looks like this:
create table Test(
id char32 not null,
column1 varchar2(2048),
column2 varchar2(2048),
...
column30 varchar2(2048)
)
Any difference in any column will result in them being different. Stored procedure will return only a true or false regarding if they are identical or not.
the following form of select will test for dups:
select id ,
column1 ,
column2 ,
...
column30 ,
count(*)
from test
group by id ,
column1 ,
column2 ,
...
column30
having count(*) > 1
;
you can also self join the test table to itself or use MINUS