SELECT w.waybill_date AS 'Дата поставки',
       SUM(w.total) AS 'Общая сумма (в рублях)',
       SUM(wl.amount) as 'Общее количество заготовок' 
FROM waybill w
JOIN (SELECT waybill_id, SUM(amount) AS amount FROM waybill_lines wl GROUP BY waybill_id)wl USING (waybill_id)
JOIN (SELECT user_id, sel_id FROM external_users) eu USING(user_id)
JOIN (SELECT sel_id, name FROM sellers) s USING(sel_id)
WHERE s.name = '$seller'
GROUP BY waybill_date