shadilThe Octorand Universe - holders
    Updated 2022-05-24
    with gen1 as (
    SELECT ASSET_ID from flipside_prod_db.algorand.asset
    where ASSET_NAME ilike 'Octorand #%'
    and ASSET_DELETED = FALSE
    and CLOSED_AT is NULL
    GROUP BY ASSET_ID
    ),
    gen2 as (
    SELECT ASSET_ID from flipside_prod_db.algorand.asset
    where asset_name ilike '%Octo Prime Gen2%'
    and ASSET_DELETED = FALSE
    and CLOSED_AT is NULL
    GROUP BY ASSET_ID
    ),
    gen2_holders as (
    SELECT ADDRESS, sum(amount)
    from flipside_prod_db.algorand.account_asset
    where asset_id in (SELECT * from gen2)
    and amount > 0
    and ASSET_CLOSED = FALSE
    GROUP BY ADDRESS
    ),
    gen1_holdres as (
    SELECT ADDRESS
    from flipside_prod_db.algorand.account_asset
    where asset_id in (SELECT * from gen1)
    and amount > 0
    GROUP BY ADDRESS
    ), -- How many Gen2 holders hold an Oct Prime Gen1?
    gen1_and_2_holdres as (
    SELECT ADDRESS
    from gen1_holdres
    where address in (SELECT address from gen2_holders)
    GROUP BY ADDRESS
    )

    Run a query to Download Data