Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Query to find distinct record

Posted on 2007-12-06
3
Medium Priority
?
162 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:kstahl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
ID: 20423420
select Part#
from yourtable
group by Part#
having min(Status) = 'O'
   and max(status) = 'O'
0
 
LVL 7

Expert Comment

by:rheitzman
ID: 20423564
SELECT DISTINCT Part# FROM yourtable WHERE Status='O'

Options:
ORDER BY 1
ORDER BY Part#

0
 

Author Closing Comment

by:kstahl
ID: 31413264
Perfect....thank you!
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question