Select all rows where a column value occurs more than once
Your query seems correct (although it may not be the most efficient).

There are many ways to write this type of query. For example, you could use EXISTS to avoid counting in the correlated subquery:

select * from table_name t1 
where exists 
      (select 1 from table_name t2 
       where t1.account_id = t2.account_id and t1.id &lt;&gt; t2.id) 
 ;


Another method is to use a subquery or CTE and window aggregate:

select id, account_id, plan_id, active
from 
  ( select *, 
           count(1) over (partition by account_id) as occurs
    from table_name
  ) AS t 
where occurs &gt; 1 ;


Or use a subquery to find the accounts that have more than one occurrences and then join to the table:

select t.*
from 
  ( select account_id
    from table_name
    group by account_id
    -- having count(1) &gt; 1          
    having min(id) &lt;&gt; max(id)      -- variation with same result 
  ) as c
  join table_name as t 
  on t.account_id = c.account_id ;