Skip to content
Advertisement

How to find group which is having Status Active? [closed]

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 .

enter image description here

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
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement