Siva Academy

Youtube.com/SivaAcademy  Oracle SQL  |  PLSQL  |  SQL PLSQL Interview Questions  |  PLSQL Scenario based Interview Questions  |  Subscriber Questions & Answers

  |  SQL practical Question  |  SQL Performance Tuning  |  New Features  |  

  Trigger     |    View  

Wednesday, September 11, 2019

sql to get combination of all the given values




create table t1(c varchar2(1));

insert into t1 values('A');
insert into t1 values('B');
insert into t1 values('C');

create table t2(c varchar2(1));

insert into t2 values('D');
insert into t2 values('E');
insert into t2 values('F');

commit;

----------------------------------------------------

with t as (select c from t1 union select c from t2)
select a1.c||'-'||a2.c output
from t a1, t a2
where a1.c < a2.c;

----------------------------------------------------

with t as (select c from t1 union select c from t2)
select distinct least(a1.c,a2.c), greatest(a1.c,a2.c) output
from t a1, t a2
where a1.c <> a2.c
order by 1;

----------------------------------------------------

No comments:

Post a Comment