What should be the query for this?

Hello world

My version of DB is

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

The table creation script.

CREATE TABLE COUNTRY_SAMPLE 
   ( COUNTRY_ID NUMBER(4,0), 
      COUNTRY_SHORT_NAME VARCHAR2(10 BYTE), 
      COUNTRY_FULL_NAME VARCHAR2(20 BYTE))
  ;

The INSERT commands.

Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (1,'IND','INDIA');
Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (2,'PAK','PAKISTAN');
Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (3,'ENG','ENGLAND');
Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (4,'AUS','AUSTRALIA');

So, how pair these countries, so that they will appear something like this

IND, PAK

IND, ENG.

IND, AUS

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

PAK, ENG

PAK, AUS

PAK, IND

and so on...

Kind regards

BS2012.

Cross join?

SQL > select a.country_short_name
2, b.country_short_name
3 country_sample one
4 cross
5 join country_sample b
where the 6 a.country_short_name! = b.country_short_name
7.

COUNTRY_SH COUNTRY_SH
---------- ----------
IND PAK
ENG IND
AUS IND
IND PAK
PAK ENG
PAK AUS
ENG IND
PAK ENG
ENG AUS
AUS IND
AUS PAK
AUS ENG

12 selected lines.

Tags: Database

Similar Questions

Maybe you are looking for