Hi!
I try to classify rows from table 1 with rules from table2
table1 orders log:
phone, order_date
phonenumber1, 2019-03-15
table2 - communication log:
phone, promo_name, start_date, end_date,
phonenumber1, Best_promo1,2019-03-12, 2019-03-15
phonenumber2, Best_promo1,2019-03-12, 2019-03-15
phonenumber1, Best_promo2,2019-03-15, 2019-03-18
phonenumber1, Best_promo3,2019-03-18, 2019-03-20
I want table3 with data:
phone, order_date, promo_name
phonenumber1, 2019-03-15, Best_promo1
phonenumber1, 2019-03-15, Best_promo2
So, how to match table1 and table2 by phone (table1.phone = table2.phone) AND classify rows by promo dates? (table1.order_date >= table2.start_date and table1.order_date <= table2.end_date