Hi!
I need help with cobining two queries into one, if possible.
The queries looks like this:
SELECT route, SUM(volume) AS rested_volume FROM buff WHERE route = 019 AND date = '2010-10-10';
and...
SELECT id.RouteNo, SUM(id.PickVol) AS total_volume
FROM imported_data id
WHERE id.id_date = '2010-10-10'
AND id.LoggCode = 40
AND RouteNo = '019';
I've tried this:
SELECT id.RouteNo, SUM(id.PickVol) AS total_volume, SUM(ROUND(b.volume/1000,2)) AS rested_volume
FROM imported_data id
LEFT JOIN buff b ON id.RouteNo = b.route AND id.id_date = b.date
WHERE id.id_date = '2010-10-10'
AND id.LoggCode = 40
AND RouteNo = '019'
GROUP BY RouteNo;
...but it gives duplicate values. I thinks something is wrong with the join condition but I don't know what. Any ideas?
/rikz