with sample_data as ( select 1 id, 1 num, 'Hello' val from dual union all select 1 id, 2 num, 'Goodbye' val from

dual union all select 2 id, 2 num, 'Hey' val from dual union all select 2 id, 4 num, 'What''s up?' val from dual union all select 3 id, 5 num, 'See you' val from dual) select id, max(num), max(val) keep (dense_rank last order by num) from sample_data group by id; -----------------------------------------DROP TABLE TEST1; DROP TABLE TEST2; CREATE TABLE TEST1 ( ID CREATE TABLE TEST2 ( ID INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO TEST1 TEST1 TEST1 TEST1 TEST1 TEST2 TEST2 TEST2 TEST2 TEST2 VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES INTEGER ,key INTEGER ,key (130, (130, (130, (120, (120, (130, (130, (130, (120, (120, VARCHAR(50),VALUE1 VARCHAR(50)); VARCHAR(50),VALUE2 VARCHAR(50)); 'STREET1'); 'STREET2'); 'STREET3'); 'STREET5'); 'STREET6'); 'ZIP1'); 'ZIP2'); 'ZIP3'); 'ZIP4'); 'ZIP5');

'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN', 'HANSEN',

select t1.id, t1.key, t1.value1, t2.value2 from (select rownum rn, id, key, value1 from test1) t1 inner join (select rownum rn, id, key, value2 from test2) t2 using (rn)

Sign up to vote on this title
UsefulNot useful