LEFT JOIN
between the Visits
and Transactions
tables on the visit_id
column.WHERE
clause to filter for records where transaction_id
is NULL
from the Transactions
table.customer_id
.COUNT
function to count the number of visits without transactions for each customer.customer_id
and the count as count_no_trans
.