Leetcode Problem 1581. Customer Who Visited but Did Not Make Any Transactions

1581. Customer Who Visited but Did Not Make Any Transactions

Leetcode Solutions

Identifying Customers with Visits but No Transactions

Algorithm

  1. Perform a LEFT JOIN between the Visits and Transactions tables on the visit_id column.
  2. Use a WHERE clause to filter for records where transaction_id is NULL from the Transactions table.
  3. Group the results by customer_id.
  4. Use the COUNT function to count the number of visits without transactions for each customer.
  5. Select the customer_id and the count as count_no_trans.
  6. Return the result set.
Visitsintvisit_idPKintcustomer_idTransactionsinttransaction_idPKintvisit_idFKintamounthas

Identifying Customers with Visits but No Transactions Using Subquery

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Code Diffs Compare
Full Screen
Copy Answer Code
Loading...