{"ok": true, "database": "cftracker", "query_name": "bill_votes_money", "rows": [], "truncated": false, "columns": ["legislature", "bill", "senator", "district", "final_vote", "from_supporters", "supporting_orgs", "from_opponents", "opposing_orgs", "roll_call"], "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),\nb as (\n  select bill_id, legislature, bill from bills\n  where bill = (select bill from p) and ((select leg from p) is null or legislature = (select leg from p))\n  order by legislature desc limit 1\n),\nfv as (select vote_id, url from bill_final_votes where bill_id = (select bill_id from b)),\norgs as (\n  select principal, clear_position from org_positions\n  where legislature = (select legislature from b) and bill = (select bill from b)\n    and clear_position is not null\n),\nmoney as (\n  select g.person_id,\n         round(sum(case when o.clear_position = 'support' then g.given end), 2) as from_supporters,\n         count(case when o.clear_position = 'support' then 1 end) as supporting_orgs,\n         round(sum(case when o.clear_position = 'oppose' then g.given end), 2) as from_opponents,\n         count(case when o.clear_position = 'oppose' then 1 end) as opposing_orgs\n  from orgs o join senator_org_gifts g on g.principal = o.principal\n  group by g.person_id\n)\nselect (select legislature from b) as legislature, (select bill from b) as bill, l.name as senator, l.district,\n       coalesce(vr.option, case when (select count(*) from fv) = 0 then 'no final vote' end) as final_vote,\n       m.from_supporters, m.supporting_orgs, m.from_opponents, m.opposing_orgs,\n       (select url from fv) as roll_call\nfrom legislators l\nleft join vote_records vr on vr.vote_id = (select vote_id from fv) and vr.person_id = l.person_id\nleft join money m on m.person_id = l.person_id\nwhere (select count(*) from b) = 1\n  and (vr.vote_id is not null or ((select count(*) from fv) = 0 and l.person_id in (\n        select vr2.person_id from votes v2 join vote_records vr2 on vr2.vote_id = v2.vote_id\n        where v2.legislature = (select legislature from b))))\norder by vr.option, coalesce(m.from_supporters, 0) + coalesce(m.from_opponents, 0) desc", "params": {"bill": ""}}, "error": null, "private": false, "allow_execute_sql": false, "query_ms": 1.8078990106005222, "source": "FEC, Nebraska Accountability and Disclosure Commission, Clerk of the Legislature, Open States", "source_url": "https://www.fec.gov/data/", "license": "Public records"}