refer to topic, I have create a sql to get the common filed on user_tab_table:
select SUBSTR (SYS_CONNECT_BY_PATH (COLUMN_NAME , ','), 2) into str
from (select COLUMN_NAME , ROW_NUMBER () over (order by COLUMN_NAME ) RN,
COUNT (*) OVER () cnt
from USER_TAB_COLUMNS
where TABLE_NAME in( 'tb1','tb2')
group by COLUMN_NAME
having COUNT(*) >= 2
)
WHERE rn = cnt
start with RN = 1
connect by RN = prior RN + 1;
so that I got the column string, but after that, I have no idea to apply(or combine) on this sql:
select {result}
from tb1
order by filed2;
union
select {result}
from tb2
order by filed1;
can some one give me some tips on it? thx for help...