with t1 as (SELECT
Block_timestamp,
TX_SIGNER,
tx_hash,
TRY_PARSE_JSON(REPLACE(tx:receipt[0]:outcome:logs[0], 'EVENT_JSON:')):data[0]:token_ids[0] AS NFT,
tx:actions[0]:FunctionCall:deposit / 1e24 AS Volume
from near.core.fact_transactions
where tx:actions[0]:FunctionCall:method_name = 'nft_buy')
SELECT
date_trunc('day', block_timestamp) as day,
COUNT(DISTINCT TX_SIGNER) as "Total Number of NFT Buyers",
COUNT(DISTINCT tx_hash) as "Total Number of NFT Sales",
COUNT(DISTINCT NFT) as "Total Number of Sold NFTs",
sum(Volume) as "Total Volume of Sold NFTs"
from t1
GROUP by 1
order by 1