Leetcode Note: MySQL - Customer Who Visted but Did Not Make Any Transactions

Customer Who Visited but Did Not Make Any Transactions - LeetCode
https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/

  • Go 言語で取り組んだメモ

回答

Simplest - Just a LEFT JOIN - No SUB-Query. - Customer Who Visited but Did Not Make Any Transactions - LeetCode
https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/solutions/865760/simplest-just-a-left-join-no-sub-query/

SELECT
	customer_id,
	COUNT(Visits.visit_id) AS count_no_trans
FROM
	visits
LEFT JOIN Transactions
	ON Visits.visit_id = Transactions.visit_id
WHERE 
	Transactions.visit_id IS NULL
GROUP BY customer_id