user2356667 user2356667 - 6 months ago 13
SQL Question

Oracle SQL Joining two tables

I am trying to join two tables from a different schema into one table.... This is my query. I keep getting an error saying that it is missing right parenthesis. Can anyone help me figure this out? I have tried every possible solution that I can think of. I don't believe that it is missing one but it won't work. Here is my query:

create view customers_g2 as
select (
(schema1.INTX.CUST_ID,
schema1.INTX.CUST_NAME,
schema1.INTX.CUST_GENDER,
schema1.INTX.CUST_STATE,
schema1.INTX.COUNTRY_ID)
Join
select (KWEKU.KM_CUSTOMERS_EXT.CUST_ID,
schema2.EXT.CUST_AGE,
schema2.EXT.CUST_EDUCATION,
schema2.EXT.MARRIED,
schema2.EXT.NO_OF_CHILDREN,
schema2.EXT.RACE,
schema2.EXT.INCOME,
schema2.EXT.CHECKING_BAL,
schema2.EXT.SAVINGS_BAL,
schema2.EXT.ASSETS,
schema2.EXT.HOUSES)
from schema1.INTX,schema2.EXT
where schema1.INTX.CUST_ID = schema2.EXT.CUST_ID);

Answer

Try change

create view  customers_g2 as (
                             ^ remove this parenthesis

to

create view  customers_g2 as

UPDATE: Better change the whole thing to

CREATE VIEW  customers_g2 
AS
SELECT i.CUST_ID, 
       i.CUST_NAME,
       i.CUST_GENDER,
       i.CUST_STATE,
       i.COUNTRY_ID,
       e.CUST_AGE, 
       e.CUST_EDUCATION, 
       e.MARRIED, 
       e.NO_OF_CHILDREN, 
       e.RACE, 
       e.INCOME, 
       e.CHECKING_BAL, 
       e.SAVINGS_BAL, 
       e.ASSETS, 
       e.HOUSES
  FROM schema1.INTX i JOIN
       schema2.EXT e ON i.CUST_ID = e.CUST_ID

The only thing that doesn't fit is

KWEKU.KM_CUSTOMERS_EXT.CUST_ID

It's unclear why do you need this field from third schema