Created
September 13, 2016 15:31
-
-
Save gordonje/06f17a15f5b6771c2de2c24990f621db to your computer and use it in GitHub Desktop.
joining f460s to filer_links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1,471 uncaptured records | |
SELECT COUNT(DISTINCT cvr."FILER_ID") | |
FROM "CVR_CAMPAIGN_DISCLOSURE_CD" cvr | |
JOIN f460_summary f460 | |
ON cvr."FILING_ID" = f460.filing_id | |
AND cvr."AMEND_ID" = f460.amend_id | |
JOIN "FILER_XREF_CD" x | |
ON x."XREF_ID" = cvr."FILER_ID" | |
LEFT JOIN ( | |
SELECT "FILER_ID_A"::varchar as filer_id | |
FROM "FILER_LINKS_CD" | |
UNION | |
SELECT "FILER_ID_B"::varchar as filer_id | |
FROM "FILER_LINKS_CD" | |
) links | |
ON links.filer_id = cvr."FILER_ID" | |
WHERE links.filer_id IS NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 7 uncaptured records | |
SELECT COUNT(DISTINCT cvr."FILER_ID") | |
FROM "CVR_CAMPAIGN_DISCLOSURE_CD" cvr | |
JOIN f460_summary f460 | |
ON cvr."FILING_ID" = f460.filing_id | |
AND cvr."AMEND_ID" = f460.amend_id | |
JOIN "FILER_XREF_CD" x | |
ON x."XREF_ID" = cvr."FILER_ID" | |
LEFT JOIN ( | |
SELECT "FILER_ID_A" as filer_id | |
FROM "FILER_LINKS_CD" | |
UNION | |
SELECT "FILER_ID_B" as filer_id | |
FROM "FILER_LINKS_CD" | |
) links | |
ON links.filer_id = x."FILER_ID" | |
WHERE links.filer_id IS NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment