Query editor
WITH time_period as (select*from (values(current_timestamp - interval '548' day, current_timestamp)) as data(start_time, end_time)), mint_txs AS (SELECT*FROM dune.opensea_team.result_mints_filter_view_by_transactionWHERE filtered_out_with_filter_2_params = falseand block_time between (select start_time from time_period) and (select end_time from time_period)), primary_volumes_and_fees AS (select*, vol_primary_usd / sum(vol_primary_usd) over () AS perc_primary_vol, vol_primary_usd / sum(vol_primary_usd) over (partition by protocol) AS perc_protocol_primary_volfrom (selectprotocol, nft_contract_address, collection AS name, sum(value_usd) AS vol_primary_usd, sum(number_of_items) AS tot_mints, sum(fee_revenue_usd) AS fee_revenue_usdfrom mint_txsgroup by 1,2,3)), secondary_volumes AS (selectrs.contract as nft_contract_address, sum(usd_price_decimal) AS vol_secondary_usdfrom reservoir.sales rswhere trueand rs.order_kind != 'mint'and exists(select 1 from mint_txs a where a.nft_contract_address = rs.contract)and tx_timestamp_dt between (select start_time from time_period) and (select end_time from time_period)group by 1), ranked_collections AS (select*-- , row_number() over (partition by protocol order by vol_primary_usd desc) AS rank_primary-- , row_number() over (partition by protocol order by vol_secondary_usd desc) AS rank_secondaryfrom (selectp.*, COALESCE(s.vol_secondary_usd,0) AS vol_secondary_usdfrom primary_volumes_and_fees pleft join secondary_volumes s on p.nft_contract_address = s.nft_contract_address))