I realize that this may not the most efficient method but lack of time dictates that I stuck with the known method and not reinvent the wheel. However, I do 4 iterations for each geography. Example given below. As I chug along, the only element that changes is the stfirms2017XX. I usually have all four queries up at one time. From there, change the area value from 000011 to 00001X and so on,. However, as I have been going along the result set does not change. I have the data set in excel and when I run a double check, the values are quite different.
When I close the program and then start again, the result set is correct.
What Is the best way to refresh/set SQL
Text
select count (*) from dbo.stfirms201704 where area = '000011' and ownership ='50' union all select count (*) from dbo.stfirms201704 where area = '000011' and ownership ='50'...