sql - How do I identify Interaction in a column and take sum based on values in two other columns? -
i have 3 tables- table 1 customer id | date | score | score factor ------------+------------+-------+------------- 100 | 2014-10-10 | 15 | .25 100 | 2014-12-12 | 25 | .35 100 | 2014-08-08 | 35 | .65 100 | 2014-09-08 | 45 | .55 100 | 2014-01-10 | 15 | .25 100 | 2014-12-12 | 75 | .85 100 | 2014-08-08 | 85 | .65 100 | 2015-09-08 | 45 | .55 200 | 2014-10-10 | 45 | .25 200 | 2014-12-12 | 55 | .35 200 | 2014-08-08 | 35 | .65 200 | 2014-09-08 | 45 | .55 200 | 2014-01-10 | 55 | .25 table 2 score | group# | group label -------+--------+-----------+ 10 | 1 | superior | 15 | 1 | superior | 25 | 1 | superior | 35 | 2 | mediocre | 55 | 2 | mediocre | 65 | 3 | poor | 75 | ...