LeetCode 1581. Customer Who Visited but Did Not Make Any Transactions
考点 | 难度 |
---|---|
Database | Easy |
题目
Write an SQL query 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.
答案
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