Query to find certain rows in a table

I have a table that looks like this:

Table

Name               Type               
------------------ ------------------ 
ID                 NUMBER
Parent_ID          NUMBER
Data               DOESN'T_MATTER
Active             NUMBER

Open in new window


The data I have in that table is:

ID		parent_id	data		active
----------------------------------------------------
1		13		value_1		0
2		13		value_2		1
3		24		value_3		0
4		24		value_4		1
5		125		value_5		0
6		125		value_6		0
7		125		value_7		0
8		6		value_8		1
9		6		value_9		1
10		6		value_10	0

Open in new window


I need a query that will give me the the rows where the 'Active' values column associated with that 'Parent ID' are all the same.

So for this example, I want the rows where the 'Parent ID' is 125 because the value in 'Active' columns are all 0.
LVL 3
buttonMASTERAsked:
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.

nociSoftware EngineerCommented:
How about selecting all conflicting parent ID's and then NOT use those:

select id, parent_id from table \
    where parent_id not in (
                              select a.parent_id from table a
                                   left join table b
                                         on  a.parent_id = b.parent_id
                                   where a.active = 0 and b.active != 0
    );

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
buttonMASTERAuthor Commented:
That worked. Thank you!
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
SQL

From novice to tech pro — start learning today.