Skip to content

2372. Calculate the Influence of Each Salesperson 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SELECT
  Salesperson.salesperson_id,
  Salesperson.name,
  SUM(IFNULL(Sales.price, 0)) AS total
FROM Salesperson
LEFT JOIN Customer
  USING (salesperson_id)
LEFT JOIN Sales
  USING (customer_id)
GROUP BY 1;