Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/WITH LVLs as ( select max(_nextInstallationId) as "Current LVL", CONCAT( _realmId ,',', _coordinateX,',',_coordinateY) as Coordinate , max(_realmId) as "realmId"from aavegotchi_polygon.RealmDiamond_evt_InstallationUpgraded awhere (CAST("_nextInstallationId" as int) >= 56 AND CAST("_nextInstallationId" as int) <= 64 )group by 2),owners as (select "Current LVL",(select output_owner_ as "Owner"from aavegotchi_polygon.RealmDiamond_call_ownerOfwhere call_successAND _tokenId = "realmId"group by 1 order by max(call_block_time) desc limit 1)as "Owners"from LVLs)select CASEWHEN owners."Current LVL" LIKE '56' THEN 'Lvl 1'WHEN owners."Current LVL" LIKE '57' THEN 'Lvl 2'WHEN owners."Current LVL" LIKE '58' THEN 'Lvl 3'WHEN owners."Current LVL" LIKE '59' THEN 'Lvl 4'WHEN owners."Current LVL" LIKE '60' THEN 'Lvl 5'WHEN owners."Current LVL" LIKE '61' THEN 'Lvl 6'WHEN owners."Current LVL" LIKE '62' THEN 'Lvl 7'WHEN owners."Current LVL" LIKE '63' THEN 'Lvl 8'WHEN owners."Current LVL" LIKE '64' THEN 'Lvl 9'ELSE owners."Current LVL"END AS "FUD Harvester lvls", count(owners."Current LVL") as totalPerLvl , "Owners"from ownersgroup by 1,3