select a.index, min(a.column1 || a.column2 || b.column1 || b.column2)
from table a, table b
where a.index = b.index
and a.column1 <> b.column1
and a.column2 <> b.column2;
its not pretty - but hey, you didn't ask for beauty...
Soans,
If that works, then dont forget to add the group by clause
select a.index, min(a.column1 || a.column2 || b.column1 || b.column2)
from table a, table b
where a.index = b.index
and a.column1 <> b.column1
and a.column2 <> b.column2
group by a.index;
Here's what I came up with. Is there better efficient and elegant code out there?
Thanks
----------------------------------------------------------
TYPE testCur IS REF CURSOR;
cur testCur;
stmt_str VARCHAR2(200);
testrecord table%ROWTYPE;
v_record varchar2(2000);
prev_index varchar2(25);
BEGIN
--sql query to execute
stmt_str := 'select * from table order by index';
OPEN cur FOR stmt_str;
LOOP
FETCH cur INTO testrecord;
IF prev_index<>testrecord.index THEN
--process the record and reset v_record for the next index
htp.p(prev_index);
htp.p(substr(v_record,2,length(v_record)));htp.p('<br>');
v_record:='';
ELSE
v_record:=v_record||'|'||testrecord.column1||'|'||testrecord.column2||'|'||testrecord.column3||'|';
END IF;
prev_index:=testrecord.index;
EXIT WHEN cur%NOTFOUND;
END LOOP;
--process the last record
htp.p(prev_index);
htp.p(substr(v_record,2,length(v_record)));htp.p('<br>');
CLOSE cur;
EXCEPTION
when others then
htp.p('message');
END;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.