Aephiah4wk - Crossover Collections by Buyers
    -- forked from h4wk / Crossover Collections by Buyers @ https://flipsidecrypto.xyz/h4wk/q/WAljeK5IaPK2/crossover-collections-by-buyers

    with gen3_mint_tx as (
    select
    block_timestamp,
    tx_id,
    instruction:accounts[6] as mint,
    instruction:accounts[5] as minter
    from solana.core.fact_events
    where succeeded = TRUE and block_timestamp > '2023-07-05'
    and program_id = 'CSGrdwbJ5z58tLGKjjcmiNMj8bG1Zazthk3cXMrbSZoX'
    and instruction:accounts[13] = '8Rt3Ayqth4DAiPnW9MDFi63TiQJHmohfTWLMQFHi4KZH'
    )
    , gen3_mints as (
    select distinct mint, minter from gen3_mint_tx
    )

    , base2 as (select a.minter,
    b.mint,
    ifnull(label, project_name) as labels,
    initcap(labels) as project_names
    from gen3_mints a
    left join solana.core.fact_nft_sales b
    on a.minter = b.purchaser
    left join solana.core.dim_nft_metadata c
    on b.mint = c.mint
    left join solana.core.dim_labels d
    on b.mint = d.address
    where labels is not null),

    base3 as (select project_names,
    count(distinct(minter)) as nft_buyers_count,
    count(distinct mint) as nft_buying_count
    from base2
    -- where
    -- project_names != 'Mad Lads'
    Run a query to Download Data