To make all colors in the ColorsFlavors table
Select cf.Color, Count(*) From ColorsFlavors cf Group By cf.Color
If you have a predefined list in the table (which I will call Colors) and you want to include zeros:
Select c.Color, Coalesce(Count(*), 0) From Colors c Left Outer Join ColorsFlavors cf On c.Color = cf.Color Group By c.Color
If you have a predefined list that someone typed
Select c.Color, Coalesce(Count(*), 0) From ( Select 'green' As Color Union All Select 'blue' Union All Select 'red' Union All Select 'white' Union All Select 'black' ) c Left Outer Join ColorsFlavors cf On c.Color = cf.Color Group By c.Color
With this, you can perfect the aromas!
source share