So, I must only run the sproc on companies in the same group, ie all those in group 4. I have to compare 1 vs 2, 1vs3, 1vs4, 2vs3,2vs4, and 3vs 4 or any combination of up to 10 companies in each group.
What is the best way to write a loop for this to run multiple combinations?
SELECT sectorId, COUNT(*) FROM `companies` GROUP BY sectorId HAVING COUNT(*) > 1; Take the sectorId from above and get the company codes. Need something here to work out what combinations to run: CALL GetStats ('AAA', 'BBB'); end loop next sectorcode