Query editor
WITH dates AS (SELECTcast('2021-10-19 22:00' as timestamp) as start_date,current_timestamp as end_date), prices AS (SELECTdate_trunc('hour', eth.minute) as week_end, date_trunc('hour', eth.minute - INTERVAL '7' DAY) as week_start, concat(cast(row_number() OVER (ORDER BY eth.minute ASC) as varchar),' (',format_datetime(date_trunc('hour', eth.minute - INTERVAL '7' DAY),'yyyy-MM-dd H:mm'),' to ',format_datetime(date_trunc('hour', eth.minute),'yyyy-MM-dd H:mm'),')') as week, (row_number() OVER (ORDER BY eth.minute ASC)) as week_number, concat(format_datetime(date_trunc('hour', eth.minute - INTERVAL '7' DAY),'yyyy-MM-dd H:mm'),' to ',format_datetime(date_trunc('hour', eth.minute),'yyyy-MM-dd H:mm')) as week_period, eth.price / botto.price as eth_to_bottoFROM prices.usd ethJOIN prices.usd bottoON botto.minute = eth.minuteWHERE botto.contract_address = 0x9dfad1b7102d46b1b197b90095b5c4e9f5845bbaAND eth.contract_address = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeAND botto.minute >= (SELECT start_date + INTERVAL '7' DAY FROM dates)AND botto.minute <= (SELECT end_date FROM dates)AND day_of_week(botto.minute) = 2AND HOUR(botto.minute) = 22AND MINUTE(botto.minute) = 0ORDER BY week_end DESC)/*, botto_primary AS (SELECTp.week_end, SUM(bp.amount_original) as sales, SUM(bp.amount_original * 0.85) as revenue, SUM(bp.number_of_items) as quantityFROM superrare.events bpLEFT JOIN prices pON bp.block_time >= p.week_start AND bp.block_time < p.week_endWHERE bp.block_time >= (SELECT start_date FROM dates)AND bp.block_time < (SELECT end_date FROM dates)AND bp.seller IN (0x000a837ddd815bcba0fa91a98a50aa7a3fa62c9c,0x8c9f364bf7a56ed058fc63ef81c6cf09c833e656)--Check collections:AND (--Collection = Genesisbp.nft_contract_address = 0xb932a70a57673d89f4acffbe830e8ed7f75fb9e0AND cast(bp.token_id as varchar) IN (SELECT token_idFROM nft.mintsWHERE tx_from = 0x000a837ddd815bcba0fa91a98a50aa7a3fa62c9cAND collection = 'SuperRare'ORDER by token_id ASC)OR--Collection <> Genesisbp.nft_contract_address IN (SELECT DISTINCT nft_contract_addressFROM nft.mintsWHERE tx_from = 0x000a837ddd815bcba0fa91a98a50aa7a3fa62c9cAND nft_contract_address NOT IN