Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

SQL Select to Group and Filter Data

I need a SQL that will list products in family have different descriptions.  Every product within the same product family should always have the same description 01 and description 02 values.  I need a SQL that will identify the products with a Family that does not have the same description 01 or description 02.

FamilyID     ProductID    Description01   Description02
A                   12345           Iphone               Apple IPhone            
A                   19332           Phone                Apple
A                   14913           Iphone               Apple IPhone
B                    94444          Ford Card          Ford
B                    98433          Ford Card          Ford

From the example above, I need to report all the products in Product Family A because the Description 01 and Description 02 column data is different.  

Report:

FamilyID     ProductID    Description01   Description02
A                   12345           Iphone               Apple IPhone            
A                   19332           Phone                Apple
A                   14913           Iphone               Apple IPhone
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Is the following SELECT good for you?
SELECT FamilyID, ProductID, Description01, Description02 
FROM TableName
WHERE Description01 <> Description02 

Open in new window

Avatar of tmajor99
tmajor99

ASKER

Thanks but I need I to list products within the SAME family and that have different Description01 or Description02 values.
You have NOT really explained the problem.  As just one example of that, would you want these rows listed in results?:

C                    94444          Ford                   Ford Card
C                    98433          Ford Card          Ford
Let me try to make this request easier.   i just need a report that will list PRODUCTS within the SAME family that have a different DESCRIPTION01.

FamilyID     ProductID    Description01  
A                   12345           Iphone                          
A                   19332           Book              
A                   14913           Iphone              
B                    94444          Ford Card          
B                    98433          Ford Card      

In the example data above, I would only report the Products with Family A because there is a discrepancy in the Description01.  

FamilyID     ProductID    Description01                        
A                   12345           Iphone                          
A                   19332           Book    
A                   14913           Iphone
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial