WITH daily_sales AS (
SELECT
DATE_TRUNC('day', block_timestamp) AS sale_date,
sales_amount,
purchaser,
seller,
mint,
succeeded
FROM solana.nft.fact_nft_sales
WHERE program_id = 'TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp'
AND block_timestamp >= DATEADD(day, -30, CURRENT_TIMESTAMP)
AND succeeded = TRUE
)
SELECT
sale_date,
ARRAY_AGG(sales_amount) AS daily_sales_amounts,
ARRAY_AGG(purchaser) AS daily_purchasers,
ARRAY_AGG(seller) AS daily_sellers,
ARRAY_AGG(mint) AS daily_mints
FROM daily_sales
GROUP BY sale_date
ORDER BY sale_date DESC;