Maybe my brain thinks it is Monday... I can not devise a solution to following SQL puzzle...
I have a primary data table and a lookup table. I am trying to validate that the primary data Year is contained for each and every category in the lookup table. In the example below, I am missing Category AAA for SaleYear 2008.
Sales Data:
ID SaleDate
123 01/01/2010
345 01/10/2009
678 01/20/2008
Lookup Table Data:
Category SaleYear GroupYear
AAA 2010 2010
AAA 2009 2010
BBB 2010 2010
BBB 2009 2010
BBB 2008 2008
CCC 2010 2010
CCC 2009 2010
CCC 2008 2008
I thought of gettting a distinct count of Category then some count query on the primary data and ensuring the coutn matches the distinct count of Category in lookup table... but alas... I can not envision the answer this morning...
Any help is appreciated.
Steve
Steve Medvid
IT Consultant & Web Master
I have a primary data table and a lookup table. I am trying to validate that the primary data Year is contained for each and every category in the lookup table. In the example below, I am missing Category AAA for SaleYear 2008.
Sales Data:
ID SaleDate
123 01/01/2010
345 01/10/2009
678 01/20/2008
Lookup Table Data:
Category SaleYear GroupYear
AAA 2010 2010
AAA 2009 2010
BBB 2010 2010
BBB 2009 2010
BBB 2008 2008
CCC 2010 2010
CCC 2009 2010
CCC 2008 2008
I thought of gettting a distinct count of Category then some count query on the primary data and ensuring the coutn matches the distinct count of Category in lookup table... but alas... I can not envision the answer this morning...
Any help is appreciated.
Steve
Steve Medvid
IT Consultant & Web Master