Query editor
WITH transactions_to_address AS (SELECT"from" AS other_address,SUM(amount) AS total_outgoing_to_addressFROM tokens.transfersWHERE "to" = 0x914A428404657CA547085Ec0Ee7Ac6f948f99A4EGROUP BY "from"),transactions_from_address AS (SELECT"to" AS other_address,SUM(amount) AS total_incoming_from_addressFROM tokens.transfersWHERE "from" = 0x914A428404657CA547085Ec0Ee7Ac6f948f99A4EGROUP BY "to")SELECTCOALESCE(to_address.other_address, from_address.other_address) AS address,COALESCE(to_address.total_outgoing_to_address, 0) AS total_to_address,COALESCE(from_address.total_incoming_from_address, 0) AS total_from_addressFROM transactions_to_address AS to_addressFULL OUTER JOIN transactions_from_address AS from_addressON to_address.other_address = from_address.other_addressWHERE-- Addresses where 'to' is greater than 'from' (if both exist)COALESCE(to_address.total_outgoing_to_address, 0) > COALESCE(from_address.total_incoming_from_address, 0)-- OR addresses where only 'to' existsOR from_address.total_incoming_from_address IS NULLORDER BY total_to_address DESC;