Home > OS >  Is there a way to join these two tables in the desired format?
Is there a way to join these two tables in the desired format?

Time:09-23

I am trying to calculate interest rates for some of my opps and my tables structure looks like below using SQL, I am using redshift.

I am beginner and would appreciate any leads,

This is the user by territory and date table:

enter image description here

This is the interest rate by territory and date:

enter image description here

CodePudding user response:

You have to use JOIN - read more about different type of joins. Sample how to solve this proble:

Select ut.*
, ut.loan * ir.interest_rate
from
user_by_territory_Table as ut join
interest_Rate_table as ir 
on ut.territory = ir.territory
and ut.close_date = ir.close_date

CodePudding user response:

You can also use VIEWS and create a new virtual table (view) that will be more efficient. using view you can also search and manipulate on the output table. :)

  • Related