latsanCopy of Copy of Copy of Untitled Query
    Updated 2022-12-01
    with temp1 as (
    SELECT
    BLOCK_TIMESTAMP,
    TX_ID,
    CONTRACT_ADDRESS,
    MINT_PRICE,
    CASE
    WHEN mint_price > 0 THEN mint_price
    ELSE 0
    end as mint,
    MINTER,
    TOKEN_ID,
    CURRENCY
    FROM terra.core.fact_nft_mints
    ),
    temp2 as (
    SELECT
    CONTRACT_ADDRESS,
    sales_amount,
    TOKEN_ID
    FROM terra.core.fact_nft_sales
    ), temp3 as (
    SELECT BLOCK_TIMESTAMP,
    TX_ID,
    CONTRACT_ADDRESS,
    MINT_PRICE,
    sales_amount,
    sales_amount - mint ,
    MINTER,
    TOKEN_ID,
    CURRENCY
    FROM temp1
    join temp2 USING (CONTRACT_ADDRESS,token_id)
    )
    SELECT BLOCK_TIMESTAMP::date as da, COUNT (tx_id)
    Run a query to Download Data