--44878
\COPY portcoipomalocation TO 'portcoipomalocation.txt' WITH DELIMITER AS E'\t' HEADER NULL AS '' CSV
--now join the two ma and ipo tables together on coname, statecode, datefirstinv
DROP TABLE portcoipoma;
CREATE TABLE portcoipoma AS
SELECT ma.*, ipo.file2issuer, ipo.file2issuedate, ipo.principalamt, ipo.proceedsamt, ipo.naiccode, ipo.zipcode, ipo.status, ipo.foundeddate
FROM portcomajoinmasnodupes AS ma JOIN portcoipojoinamt AS ipo ON ma.coname = ipo.coname AND ma.statecode = ipo.statecode AND ma.datefirstinv = ipo.datefirstinv;
--44755
\COPY portcoipoma TO 'portcoipoma.txt' WITH DELIMITER AS E'\t' HEADER NULL AS '' CSV
DROP TABLE portcoipomanodupes;
CREATE TABLE portcoipomanodupes AS
SELECT *
FROM portcoipoma WHERE transactionamt IS NULL OR proceedsamt IS NULL;
--44706
\COPY portcoipomanodupes TO 'portcoipomanodupes.txt' WITH DELIMITER AS E'\t' HEADER NULL AS '' CSV
==Joining geo with portcoipomas==