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.
erDiagram
Visits {
int visit_id PK
int customer_id
}
Transactions {
int transaction_id PK
int visit_id FK
int amount
}
Visits ||--o{ Transactions : has