Query editor
with parents as (SELECT "from" as breeder, hash, block_time, date_trunc('day', block_time) AS day,-- data,bytearray_to_uint256(SUBSTRING(data FROM 37 FOR 32)) as parent_1, bytearray_to_uint256(SUBSTRING(data FROM 69 FOR 32)) as parent_2FROM polygon.transactionsWHERE to = 0xdc0479cc5bba033b3e7de9f178607150b3abce1fAND SUBSTRING(data FROM 1 FOR 4) = 0xd2df3a9eAND success--AND block_time > cast('2023-05-01' as timestamp)),babies as (SELECT bytearray_to_uint256(SUBSTRING(data FROM 1 FOR 32)) AS baby, tx_hash--, block_time, date_trunc('day', block_time) AS dayFROM polygon.logsWHERE topic0 = 0x9224d149facb2ec112bf239305994586c3a09a1776770edcaf18f1ec3a4596b1--AND tx_hash IN (SELECT hash FROM breeds)AND bytearray_to_uint256(SUBSTRING(data FROM 37 FOR 32)) = cast(2 as uint256)),one_column as (selectparent_1 from parents punion allselectparent_2 from parents p),organized as (selectdistinct(parent_1) as parents,count(parent_1) as breed_ctfrom one_columngroup by 1)selectdistinct(breed_ct) as "# Breeds",count(breed_ct) as "# Unicorns",cast(count(breed_ct) as double)/cast((sum(count(breed_ct)) Over ()) as double) as "% Population"from organizedgroup by 1order by 1 desc--b.baby--from parents p--left join babies b--on p.hash = b.tx_hash--group by 1,2,3--order by 2 desc