==Cleaning mas table==
Check to see if you have bad keys in the table. The row count of the table should match up with count of distinct keys based on targetname, targetstatecode, announceddate.
SELECT COUNT(*)
FROM mas;
--114890
SELECT COUNT(*)
FROM (SELECT DISTINCT targetname, targetstatecode, announceddate FROM mas)a;
--114825
==Creating Stage Flags Table==