我正在尝试创建没有子查询的 sql 查询,这是工作查询:
select * from customers
join
(select idContactOwner, count(*) contacts_count
from contacts GROUP BY idContactOwner HAVING contacts_count>5) k
where customers.id=k.idContactOwner;
这是我正在尝试的,但它不起作用:
select idContactOwner, count(*) counter from contacts A
group by idContactOwner having counter>5 join customers B
on A.idContactOwner=B.id;
这是sql小提琴: