Query editor
WITH focal AS (SELECTrow_number() OVER () AS focal_id,seller,collection_address,cast(token_id AS varchar) AS token_id,cast(sale_time_actual AS timestamp) AS sale_time_actual,cast(first_listing_created_at AS timestamp) AS first_listing_created_at,cast(total_price AS double) AS focal_sale_price,cast(seller_buy_price AS double) AS buy_price,coalesce(cast(royalty_fee_amount AS double), 0) AS royalty_fee_amountFROM dune.lyng2789.dataset_dune_sales_with_first_listing_20251101_20251231_has_listing_match),trades AS (SELECTcast(block_date AS timestamp) AS block_time,tx_hash,nft_contract_address AS collection_address,cast(token_id AS varchar) AS token_id,trade_seller,trade_buyer,cast(amount_original AS double) AS amount_original,currency_symbolFROM query_7696977WHERE amount_original IS NOT NULLAND amount_original > 0),prior_window_trades AS (SELECTf.focal_id,f.seller,f.collection_address AS focal_collection_address,f.first_listing_created_at,t.*FROM focal fJOIN trades tON (t.trade_seller = f.sellerOR t.trade_buyer = f.seller)AND t.block_time >= f.first_listing_created_at - interval '90' dayAND t.block_time < f.first_listing_created_at),prior_sales AS (SELECTp.focal_id,p.seller,p.focal_collection_address,p.first_listing_created_at,p.block_time AS sale_time,p.tx_hash,p.collection_address,p.token_id,p.trade_seller,p.trade_buyer,p.amount_original,p.currency_symbol,