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

MySql LEFT JOIN mit COUNT

SELECT c.* , s.sales_count<br>
FROM customers c<br>
LEFT JOIN (SELECT customer_id, count(id) as sales_count FROM sales GROUP BY customer_id) s on c.id=s.customer_id<br>
WHERE c.store_id = 1<br>