WHERE excludeflag1 = 0 AND excludeflag2 = 0 AND warningflag = 1
GROUP BY file1coname, file1statecode, file1datefirstinv;
Find --364Then using the keys that slipped throughtemporary key (file1coname, file1statecode, file1datefirstinv, file2announceddate) join this back to the original matcher table to get the rest of the data we will want in the core table. DROP TABLE matcherportcomasinclude; CREATE TABLE matcherportcomasinclude AS SELECT m.* FROM matcherportcomas AS m INNER JOIN matcherwarningmindates AS mi ON m.file1coname = mi.file1coname AND m.file1statecode = mi.file1statecode AND m.file1datefirstinv = mi.file1datefirstinv AND m.file2announceddate = mi.min WHERE excludeflag1 = 0 AND excludeflag2 = 0 AND warningflag = 1; --366The inner join result should equal the amount in the matcherwarningmindates table but it doesn't. So to find the dirty entries we'll use the query below.
SELECT *, COUNT(*) FROM
(SELECT file1coname, file1statecode, file1datefirstinv FROM matcherportcomasinclude)a
HAVING COUNT(*) > 1;
file1coname | file1statecode | file1datefirstinv | count -------------------------+----------------+-------------------+------- PA Inc | TX | 2007-09-25 | 2 High Sierra Energy L.P. | CO | 2004-12-23 | 2
==Creating Stage Flags Table==