PL/SQlL All the rows that have only one of the same value in as certain field

Hello expert,

Need to find the rows in a table that only have a value once in the
 parent_company_id field.

Tried
SELECT employer_id,
   employer_name,
  employer_category_code,
   parent_company_id,
  alternate_name
from ccm_employer
GROUP BY  parent_company_id, employer_id
HAVING COUNT(*) > 1

But it returns

ORA-00979: not a GROUP BY expression
00979. 00000 -  "not a GROUP BY expression"
*Cause:    
*Action:
Error at Line: 2 Column: 3

How can I get the needed result?

Thanks.

Allen in Dallas
LVL 1
Allen PittsBusiness analystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Try something like this:
SELECT employer_id,
    employer_name,
   employer_category_code,
    parent_company_id,
   alternate_name
from (
SELECT employer_id,
    employer_name,
   employer_category_code,
    parent_company_id,
   alternate_name,
count(*) over(partition by parent_company_id, employer_id order by parent_company_id, employer_id)tot_count
 from ccm_employer 
) where tot_count=1

Open in new window

awking00Information Technology SpecialistCommented:
select e.employer_id, e.employer_name, e.employer_category_code, e.parent_company_id, e.alternate_name
from ccm_employer e,
(select parent_company_id, count(*)
 from ccm_employer
 group by parent_company_id
 having count(*) = 1) x
where e.parent_company_id = x.parent_company_id;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.