{"ok": true, "database": "cftracker", "query_name": "bill_lobbying_money", "rows": [], "truncated": false, "columns": ["legislature", "bill", "organization", "position", "paid_by_state", "candidate", "given_by", "contributions", "total", "first_gift", "last_gift"], "query": {"sql": "with p as (\n  select case when instr(:bill, ':') > 0 then cast(substr(:bill, 1, instr(:bill, ':') - 1) as integer) end as leg,\n         upper(replace(substr(:bill, instr(:bill, ':') + 1), ' ', '')) as bill\n),\nleg as (\n  select coalesce((select leg from p),\n                  (select max(legislature) from org_positions where bill = (select bill from p))) as legislature\n),\norgs as (\n  select principal, positions as position from org_positions\n  where legislature = (select legislature from leg) and bill = (select bill from p)\n),\nmoney as (\n  select pc.principal, sc.candidate_name, pc.link_type,\n         count(*) as contributions, sum(sc.amount) as total, min(sc.date) as first_gift, max(sc.date) as last_gift\n  from principal_contributions pc\n  join state_contributions sc on sc.receipt_id = pc.receipt_id\n  where pc.principal in (select principal from orgs) and sc.candidate_name is not null\n  group by pc.principal, sc.candidate_name, pc.link_type\n)\nselect (select legislature from leg) as legislature, (select bill from p) as bill,\n       o.principal as organization, o.position,\n       (select round(sum(vs.paid), 2) from vendor_summary vs where vs.principal = o.principal) as paid_by_state,\n       m.candidate_name as candidate, m.link_type as given_by, m.contributions, m.total, m.first_gift, m.last_gift\nfrom orgs o\nleft join money m on m.principal = o.principal\norder by o.position, m.total desc\nlimit 1000", "params": {"bill": ""}}, "error": null, "private": false, "allow_execute_sql": false, "query_ms": 1.31758299539797, "source": "FEC, Nebraska Accountability and Disclosure Commission, Clerk of the Legislature, Open States", "source_url": "https://www.fec.gov/data/", "license": "Public records"}