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:
This is the interest rate by territory and date:
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. :)