KaskoazulMonkeDAO - voters purchasing after vote
    Updated 2022-04-05
    WITH PURCHASERS AS (
    select block_timestamp as fecha,
    purchaser,
    sales_amount,
    concat_ws('#', 'SMB', token_id) as NFT,
    marketplace,
    tx_id
    from solana.dim_nft_metadata md
    left join solana.fact_nft_sales sale
    on md.mint = sale.mint
    where contract_address = ('9uBX3ASjxWvNBAD1xjbVaKA74mWGZys3RGSF7DdeDD3F') --contract_name = ('Solana Monkey Business')
    and program_id in ('J7RagMKwSD5zJSbRQZU56ypHUtux8LRDkUpAPSKH4WPp', 'M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K')
    and succeeded = 'TRUE'
    order by 4, 1
    ),

    VOTERS AS (
    select block_timestamp as fecha,
    signers[0] as voter,
    case instructions[0]:data
    when 'Yjf5DvKUCfa2bPkYz4AiWs' then 'YES'
    when 'Yjf5DvKUCfa2Rh5YBEg7FM' then 'NO'
    end as vote
    --count(1) as n,
    --sum(ARRAY_SIZE(inner_instructions)) AS total_votes
    from solana.fact_transactions
    where instructions[0]:accounts[6] = 'BD9XQhU1DXA9V4GLdgTq7xdQY5UBnShfq4caTSEL9Lr'
    and succeeded = 'TRUE'
    and instructions[0]:programId = 'Daovoteq2Y28gJyme6TNUXT9TxXrePiouFuHezkiozci'
    --group by 1
    ),

    VOTERS_THAT_PURCHASED as (
    select VOTERS.voter,
    PURCHASERS.tx_id,
    Run a query to Download Data