select date_1, SUM(amount*c.price) AS sum_by_day
from
(
select *, max (date_2) as lastDate
from tran_test AS t
INNER JOIN cur_test AS c
ON t.currency = c.currency AND date_1 >= date_2
GROUP BY date_1;
) as t
INNER JOIN cur_test AS c
ON t.currency = c.currency AND lastdate = date_2
GROUP BY date_1;