Query to find distinct record

This should be easy.
I have a SQL table with the data as follows:

Part#     Rev     Status
P123       A          O
P123       B          A
P123       C          O
P123       D          O
P124       C          A
P127       A          O
P128       A          O
P128       B          A
P129       F           O
P130       F           A
P134       A           O
P134       B           O
A=Active Part
O=Obsolete Part

I need to write a query that only pulls the part numbers that are obsolete (no active status regardless of rev).

The correct results would be
P127
P129
P134
kstahlAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
select Part#
from yourtable
group by Part#
having min(Status) = 'O'
   and max(status) = 'O'
0
 
rheitzmanCommented:
SELECT DISTINCT Part# FROM yourtable WHERE Status='O'

Options:
ORDER BY 1
ORDER BY Part#

0
 
kstahlAuthor Commented:
Perfect....thank you!
0
All Courses

From novice to tech pro — start learning today.