Customer Visits Without Transactions

2pts
Google

Problem Statement

Marketing analysts want to understand customer bounce rates—instances where a user visits the store but leaves without making a purchase.

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.

Rules:

  • A visit without transaction is defined as a visit_id that exists in the Visits table but does not have a corresponding entry in the Transactions table.
  • Return the customer_id and the count of these visits as count_no_trans.
  • Results must be sorted by customer_id in ascending order.
Tests your understanding of
Basic SQL, Joins, LEFT JOIN, Filtering and Aggregation

Input Tables

visits
visit_id(INTEGER)customer_id(INTEGER)
123
29
554
754
854
129
1330
1930
transactions
transaction_id(INTEGER)visit_id(INTEGER)amount(INTEGER)
25310
312560
919400

Expected Output

customer_id(INTEGER)count_no_trans(INTEGER)
91
231
301
542

Tags

EasyBasic SQLJoinsLEFT JOINFilteringAggregation
10-15 min
74%

Hints