I have a id which is having more than one Accountid in a table with status Active . I need to find group of active for the particular ID .
Please find my below query .is it correct or something need to modify to get better optimized result .
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)
Advertisement
Answer
Use this query:
select id,count(Accountid) from CustomerAccount where status='Active' group by id having count(*) >1