LeetCode - 1581. Customer Who Visited but Did Not Make Any Transactions (MySQL)

조민수·2024년 6월 14일
0

LeetCode

목록 보기
35/61

Easy, SQL - SELECT, Nested Query

RunTime : 1233 ms


문제

Write a solution to find the IDs of the users who visited without making any transactions and the number of times they made these types of visits.

Return the result table sorted in any order.

The result format is in the following example.


풀이

  • 어렵진 않았는데 뭔가 좀 헤맸다.
  • 이정돈 5분안에 풀어야지...
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 1
profile
사람을 좋아하는 Front-End 개발자

0개의 댓글