Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL JOIN und COUNT in einer einzigen Abfrage

SELECT o.id, o.f_name, o.l_name, COUNT(od.id), COALESCE(SUM(od.qty), 0)
FROM orders o
LEFT JOIN order_details od ON o.id = od.order_id
GROUP BY o.id, o.f_name, o.l_name