Hi
I think it working almost perfect. My only problem is that I am not able to count the calls because if 3 prices is related to the call the each line appears 3 times and if only 2 then it appears 2 times ....
Do you have an idea how to find out how many prices I have related to each call. I have the same problem with the duration:
SELECT
data_id,Count(data_id) as Calls, Sum(duration) as duration, date,P.currency,
SUM(IF(P.price_type = 'novaout', P.p_minute*duration/60,0)) AS novaoutmin,
SUM(IF(P.price_type = 'clientout', P.p_minute*duration/60,0)) AS clientoutmin,
SUM(IF(P.price_type = 'novarouting', P.p_minute*duration/60,0)) AS novaroutingmin,
SUM(IF(P.price_type = 'clientrouting', P.p_minute*duration/60,0)) AS clientrouting
FROM t_telco_data D
LEFT JOIN t_price P
ON P.dial_string = D.dial_string AND
D.date BETWEEN P.start_date AND P.end_date AND
FIND_IN_SET(D.billing_type,P.billing_type)>0
WHERE
D.date BETWEEN '2006-12-01' AND '2006-12-3'
GROUP BY P.currency
ORDER BY data_id;
Rasmus