Query editor
-- THE BOUNDARY CASE THAT MATTERS: bought in August, sold in September. Each chunk sees HALF the-- position — August has the buy with no sell, September has the sell with no buy (bought_qty = 0,-- so that row never enters `chunks`). Does the merge still see a CLOSED position, or does the-- wallet look like it is still holding?WITH aug AS (SELECT wallet, token, bought_qty, sold_qty FROM dune.scopix_team.result_rh_t01b_aug),sep AS (SELECT wallet, token, bought_qty, sold_qty FROM dune.scopix_team.result_rh_t01b)SELECTCAST(count(*) AS varchar) AS bought_aug_sold_sep,CAST(count(DISTINCT a.wallet) AS varchar) AS walletsFROM aug a JOIN sep s ON s.wallet = a.wallet AND s.token = a.tokenWHERE a.bought_qty > 0 AND a.sold_qty = 0 AND s.bought_qty = 0 AND s.sold_qty > 0