Query editor
SELECT 'supply' tbl, project, version, transaction_type, count(*) n, sum(cast(amount_raw AS double)) raw_sum, sum(amount_usd) usd, count(on_behalf_of) n_obo, count(withdrawn_to) n_wto, count(liquidator) n_liq, count(symbol) n_sym, sum(evt_index) sum_evt, count(distinct tx_hash) n_tx, cast(null AS double) fee_sum FROM lending.supply WHERE blockchain='ethereum' AND block_month >= DATE '2018-01-01' AND block_number <= 26250999 AND project || '/' || version IN ('aave/1','compound/1','radiant/1','uwulend/1','granary/1','fluxfinance/1','strike/1','balancer/v2') GROUP BY 1,2,3,4 UNION ALL SELECT 'borrow', project, version, transaction_type || coalesce('/' || loan_type,''), count(*), sum(cast(amount_raw AS double)),sum(amount_usd),count(on_behalf_of),count(repayer),count(liquidator),count(symbol),sum(evt_index),count(distinct tx_hash),cast(null AS double) FROM lending.borrow WHERE blockchain='ethereum' AND block_month >= DATE '2018-01-01' AND block_number <= 26250999 AND project || '/' || version IN ('aave/1','compound/1','radiant/1','uwulend/1','granary/1','fluxfinance/1','strike/1','balancer/v2') GROUP BY 1,2,3,4 UNION ALL SELECT 'flashloans',project,version,'flashloan',count(*),sum(cast(amount_raw AS double)),sum(amount_usd),count(recipient),cast(null AS bigint),cast(null AS bigint),count(symbol),sum(evt_index),count(distinct tx_hash),sum(fee) FROM lending.flashloans WHERE blockchain='ethereum' AND block_month >= DATE '2018-01-01' AND block_number <= 26250999 AND project || '/' || version IN ('aave/1','compound/1','radiant/1','uwulend/1','granary/1','fluxfinance/1','strike/1','balancer/v2') GROUP BY 1,2,3,4 ORDER BY 1,2,3,4