Query editor
WITHlistings_created AS (SELECT * FROM query_5734467),listings_bought_or_accepted AS (SELECT * FROM query_5751525),/*fate_price AS (SELECT priceFROM prices.latestWHERE blockchain = 'avalanche_c'AND contract_address = 0x32f0c28be6a6ac5d3b471278b77f6971a3141348 --Fate),*/fate_listings AS (SELECTlc.*, CASE WHEN lboa.purchase_type IS NOT NULL THEN lboa.purchase_type --'Offer Accepted' or 'Listing Bought'WHEN can.listingID IS NOT NULL THEN 'Listing Cancelled'ELSE 'Listing Active'END AS listing_StatusFROM listings_created lcLEFT JOIN listings_bought_or_accepted lboaON lc.listingID = lboa.listingID/*LEFT JOIN labninety1_pass_otc_avalanche_c.pass_evt_offeraccepted oaON lc.listingID = oa.listingIDLEFT JOIN labninety1_pass_otc_avalanche_c.pass_evt_listingbought lbON lc.listingID = lb.listingID*/LEFT JOIN labninety1_pass_otc_avalanche_c.pass_evt_listingcancelled canON lc.listingID = can.listingIDWHERE lc.token_contract_address = 0x32f0c28be6a6ac5d3b471278b77f6971a3141348 --Fate listings),fate_listings_agg AS (SELECTseller, COUNT(*) AS total_orders_created_count, SUM(token_amount) AS total_token_amount--Overall Listings stats, COUNT_IF(listing_Status = 'Listing Active') AS listing_active_count, SUM(IF(listing_Status = 'Listing Active', token_amount, 0)) AS listing_active_token_amount, COUNT_IF(listing_Status = 'Listing Bought') AS listing_bought_count, SUM(IF(listing_Status = 'Listing Bought', token_amount, 0)) AS listing_bought_token_amount, COUNT_IF(listing_Status = 'Offer Accepted') AS accepted_offer_count, SUM(IF(listing_Status = 'Offer Accepted', token_amount, 0)) AS accepted_offer_token_amount, COUNT_IF(listing_Status = 'Listing Cancelled') AS listing_cancelled_count, SUM(IF(listing_Status = 'Listing Cancelled', token_amount, 0)) AS listing_cancelled_token_amount--Sell Listings stats, COUNT_IF(listing_type = 'Selling' AND listing_Status = 'Listing Active') AS listing_active_count_sell, SUM(IF(listing_type = 'Selling' AND listing_Status = 'Listing Active', token_amount, 0)) AS listing_active_token_amount_sell, COUNT_IF(listing_type = 'Selling' AND listing_Status = 'Listing Bought') AS listing_bought_count_sell, SUM(IF(listing_type = 'Selling' AND listing_Status = 'Listing Bought', token_amount, 0)) AS listing_bought_token_amount_sell, COUNT_IF(listing_type = 'Selling' AND listing_Status = 'Offer Accepted') AS accepted_offer_count_sell, SUM(IF(listing_type = 'Selling' AND listing_Status = 'Offer Accepted', token_amount, 0)) AS accepted_offer_token_amount_sell, COUNT_IF(listing_type = 'Selling' AND listing_Status = 'Listing Cancelled') AS listing_cancelled_count_sell, SUM(IF(listing_type = 'Selling' AND listing_Status = 'Listing Cancelled', token_amount, 0)) AS listing_cancelled_token_amount_sell--Buy Listings stats, COUNT_IF(listing_type = 'Buying' AND listing_Status = 'Listing Active') AS listing_active_count_buy, SUM(IF(listing_type = 'Buying' AND listing_Status = 'Listing Active', token_amount, 0)) AS listing_active_token_amount_buy