How to classify data with many rules


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 ( = AND classify rows by promo dates? (table1.order_date >= table2.start_date and table1.order_date <= table2.end_date

Firs you need to join records by phone_number using

Then use

to compare order_date with promo.

Oh, that was easier than I expected! Thank you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.