문제
입력 코드
1.
SELECT V.customer_id, COUNT(V.visit_id) AS count_no_trans
FROM Visits AS V
LEFT JOIN Transactions AS T
ON V.visit_id = T.visit_id
WHERE T.transaction_id IS NULL
GROUP BY V.customer_id
2.
SELECT customer_id, COUNT(visit_id) AS count_no_trans
FROM Visits
WHERE visit_id NOT IN(
SELECT DISTINCT visit_id
FROM Transactions
)
GROUP BY customer_id
코드 설명
#SELECT #COUNT #LEFT JOIN #JOIN #NULL #GROUP BY #NOT IN #DISTINCT
문제 출처
'SQL' 카테고리의 다른 글
#84. [LeetCode / MySQL] 1661. Average Time of Process per Machine (0) | 2023.09.10 |
---|---|
#83. [LeetCode / MySQL] 197. Rising Temperature (0) | 2023.09.09 |
#81. [LeetCode / MySQL] 1068. Product Sales Analysis I (0) | 2023.09.07 |
#80. [LeetCode / MySQL] 1378. Replace Employee ID With The Unique Identifier (0) | 2023.09.06 |
#79. [LeetCode / MySQL] 1683. Invalid Tweets (0) | 2023.09.05 |