mysql-dependent-subquery

MySQL query with dependent subquery takes too long

I need an SQL guru to help me speed up my query. I have 2 tables, quantities and prices. quantities records a quantity value between 2 timestamps, 15 minutes apart. prices records a price for a given timestamp, for a given price type and there is a price 5 record for every 5 minutes. I need 2 work out the total price for each period, e...