Query editor
WITH all_transactions AS (SELECTblock_time,gas_used * gas_price / 1e18 as eth_fee,'Outgoing' as tx_typeFROM ethereum.transactionsWHERE "from" = {{wallet_address}}UNION ALLSELECTblock_time,0 as eth_fee,'Incoming' as tx_typeFROM ethereum.transactionsWHERE "to" = {{wallet_address}}),daily_stats AS (SELECTdate_trunc('day', block_time) as date,SUM(CASE WHEN tx_type = 'Outgoing' THEN eth_fee ELSE 0 END) as daily_fees,COUNT(*) as number_of_transactions,COUNT(CASE WHEN tx_type = 'Outgoing' THEN 1 END) as outgoing_txs,COUNT(CASE WHEN tx_type = 'Incoming' THEN 1 END) as incoming_txsFROM all_transactionsGROUP BY 1),total_stats AS (SELECTNULL as date,SUM(CASE WHEN tx_type = 'Outgoing' THEN eth_fee ELSE 0 END) as daily_fees,COUNT(*) as number_of_transactions,COUNT(CASE WHEN tx_type = 'Outgoing' THEN 1 END) as outgoing_txs,COUNT(CASE WHEN tx_type = 'Incoming' THEN 1 END) as incoming_txsFROM all_transactions)SELECT * FROM daily_statsUNION ALLSELECT * FROM total_statsORDER BY date DESC NULLS FIRST;