nitsAstro Distribution
    Updated 2022-06-16
    with asset_details as
    (SELECT asset_id from algorand.ASSEt
    where asset_name like 'Astro #%' and creator_address = 'NIN73GEWDWBU3HHEPGWGIQZMOITN4PU3YVTKMR3ESI7DCH5ME4E5TLB4XU' and asset_url is not NULL ),
    holding as
    (SELECT address, count(DISTINCT asset_id) as total_assets_held from
    (SELECT * from flipside_prod_db.algorand.account_asset
    where asset_id in (SELECT * from asset_details )
    and asset_closed = 'FALSE' and address!= 'NIN73GEWDWBU3HHEPGWGIQZMOITN4PU3YVTKMR3ESI7DCH5ME4E5TLB4XU')
    GROUP by 1 )
    SELECT distribution, count(DISTINCT address) as number_of_wallets from
    (SELECT *,
    case when closed_at is not NULL then 'a- closed'
    when balance < 1 then 'b- dust accounts'
    when balance>= pow(10,0) and balance< pow(10,2) then 'c- 1-100'
    when balance>= pow(10,2) and balance< pow(10,3) then 'd- 100-1k'
    when balance>= pow(10,3) and balance< pow(10,4) then 'e- 1k-10k'
    when balance>= pow(10,4) and balance< pow(10,5) then 'f- 10k-100k'
    when balance>= pow(10,5) then 'g- 100k+' end as distribution
    from algorand.account
    where address in (SELECT address from holding) )
    GROUP by 1
    limit 1000

    Run a query to Download Data