Skip to content

Instantly share code, notes, and snippets.

@gordonje
Created September 9, 2016 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gordonje/5f71e78a05cb3ca50f8e8118ea2e935e to your computer and use it in GitHub Desktop.
Save gordonje/5f71e78a05cb3ca50f8e8118ea2e935e to your computer and use it in GitHub Desktop.
Compare F460 contribution and expenditure schedule and summary sheet totals
-- cases where there's a contribution total on the summary sheet, but not the schedule
select summ.filing_id, summ.amend_id, summ.monetary_contributions, a.combined_total
from f460_summary summ
join f460_schedule_a a
on summ.filing_id = a.filing_id
and summ.amend_id = a.amend_id
where summ.monetary_contributions > 0 and (a.combined_total is null or a.combined_total = 0)
order by 1 desc, 2;
-- cases where there's a contribution total on the schedule but not the summary sheet
select summ.filing_id, summ.amend_id, summ.monetary_contributions, a.combined_total
from f460_summary summ
join f460_schedule_a a
on summ.filing_id = a.filing_id
and summ.amend_id = a.amend_id
where (summ.monetary_contributions = 0 or summ.monetary_contributions is null) and a.combined_total > 0
order by 1 desc, 2;
-- 10 cases where there's a expenditure total on the summary sheet, but not the schedule
select summ.filing_id, summ.amend_id, summ.payments_made, e.combined_total
from f460_summary summ
join f460_schedule_e e
on summ.filing_id = e.filing_id
and summ.amend_id = e.amend_id
where summ.payments_made > 0 and (e.combined_total is null or e.combined_total = 0)
order by 1 desc, 2;
-- cases where there's a expenditure total on the schedule but not the summary sheet
select summ.filing_id, summ.amend_id, summ.payments_made, e.combined_total
from f460_summary summ
join f460_schedule_e e
on summ.filing_id = e.filing_id
and summ.amend_id = e.amend_id
where (summ.payments_made = 0 or summ.payments_made is null) and e.combined_total > 0
order by 1 desc, 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment