一、题目
二、代码
# Write your MySQL query statement below 先连接表 然后再看
-- select Visits.customer_id,count(Visits.customer_id ) from Visits
-- group by Visits.customer_id
-- select distinct Transactions.visit_id from Transactions
-- select Visits.customer_id, count(Transactions.transaction_id ) from Visits
-- left join Transactions
-- on Visits.visit_id = Transactions.visit_id
-- where transaction_id is null
-- group by customer_id
select table1.customer_id ,count(table1.customer_id ) as count_no_trans from
(
select Visits.customer_id , Transactions.transaction_id from Visits
left join Transactions
on Visits.visit_id = Transactions.visit_id
where transaction_id is null
) as table1
group by table1.customer_id