请找到我的以下查询。它是正确的还是需要修改的内容才能获得更好的优化结果。
select id,count(Accountid) from CustomerAccount
where status='Active'
group by id
having count(*)>( select min(maxxount) from(
select id,count(accountid) as maxxount
from CustomerAccount
group by id)A)
答案 0 :(得分:1)
使用此查询:
select id,count(Accountid) from CustomerAccount
where status='Active'
group by id
having count(*) >1