Forum Discussion

powerbiastra1's avatar
powerbiastra1
Frequent Visitor
3 years ago

Bring together 2 tables

I have two tables with data as below

 

as you can see columns pp and comm combination is matching only for one value

 

so how do I bring these 2 tables together ? A simple full outer join in oracle will do ?

Any other ideas are appreciated, thanks


CREATE TABLE PIGGYBANK(EDATE DATE,COMM VARCHAR2(20),PP VARCHAR2(20), BMONTH NUMBER,
CAMOUNT NUMBER);

INSERT INTO PIGGYBANK VALUES ('17-OCT-2022','ABC_COM','ABC_PP',202211,200);
INSERT INTO PIGGYBANK VALUES ('17-OCT-2022','FL_COM','FL_PP',202211,300);
INSERT INTO PIGGYBANK VALUES ('17-OCT-2022','CA_COM','CA_PP',202211,500);
INSERT INTO PIGGYBANK VALUES ('17-OCT-2022','PEN_COM','PEN_PP',202211,200);
INSERT INTO PIGGYBANK VALUES ('17-OCT-2022','XYZ_COM','XYZ_PP',202211,350);


CREATE TABLE CBANK(CDATE DATE,CLEVEL VARCHAR2(10),COM VARCHAR2(20),PP VARCHAR2(20),
CM NUMBER, PRICE NUMBER);

INSERT INTO CBANK VALUES('17-OCT-2022','C10','ABC_COM','ABC_PP',202211,30);
INSERT INTO CBANK VALUES('17-OCT-2022','C12','ABC_COM','ABC_PP',202211,50);
INSERT INTO CBANK VALUES('17-OCT-2022','C5','ABC_COM','ABC_PP',202211,40);

INSERT INTO CBANK VALUES('17-OCT-2022','C10','npc_COM','npc_PP',202212,32);
INSERT INTO CBANK VALUES('17-OCT-2022','C12','npc_COM','npc_PP',202212,56);
INSERT INTO CBANK VALUES('17-OCT-2022','C5','npc_COM','npc_PP',202212,77);

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerbiastra1,

     

    Would you consider publishing the final expected output of tables that merged together?

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

    • powerbiastra1's avatar
      powerbiastra1
      Frequent Visitor

      Unfortunately my user is not able to  give me that info, so I came up with above sample tables

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi powerbiastra1 ,

         

        What I want is the output after combining the above two sample tables. Would you tell me what its results look like? Take a screenshot in excel as well.🙂 thanks.

         

        Best Regards,
        Gao

        Community Support Team