mercredi 13 mai 2015

MSSQL - Select distinct products that are found in two columns

Suppose I have the following combinations in my dataset:

**ProductA**            **ProductB**
  Apple                   Banana
  Apple                   Orange
  Apple                   Pear
  Banana                  Orange
  Banana                  Pear
  Orange                  Pear

How would I return a complete list of unique products in a single column? Desired output below:

**Products**
Apple
Banana
Orange
Pear

If I do select distinct, I obviously won't get the pear because it's not included in column ProductA.

Any help would be appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire