Skip to content
Advertisement

SQL bringing two tables into a existing table

I have two different tables and I want to bring over the data onto a single existing table that has columns for the inputs.

WHERE ODS_SALE_LARGE contains CUST_NM,CUST_STREET_AD,CUST_POSTAL_CD,CUST_NO,CUST_CITY_NM,CUST_STATE_CD, CUST_PHONE_NO,CUST_BIRTH_DT

and ODS_CUSTOMER has CUST_ID,CUST_NO,CUST_INCOME_AM

How do I bring these two tables together?

Advertisement

Answer

You don’t need to join ods_customer with itself. Just join it with ods_sales_large.

The join should be on the CUST_NM columns, since that’s the only thing in common between the two input tables.

You can’t reference customer table in the SELECT query, since that’s the table you’re inserting into, not where you’re selecting from.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement