mlhNumber of Sales per category
    WITH traits as (
    select
    block_number as mint_block,
    block_timestamp as mint_time,
    tx_hash as mint_hash,
    contract_address,
    tokenflow_eth.hextoint(topics[1])::integer as tokenID,
    tokenflow_eth.hextoint(substr(data,3,64)) as background,
    tokenflow_eth.hextoint(substr(data,67,64)) as body,
    tokenflow_eth.hextoint(substr(data,131,64)) as accessory,
    tokenflow_eth.hextoint(substr(data,195,64)) as head,
    tokenflow_eth.hextoint(substr(data,259,64)) as glasses
    from ethereum.core.fact_event_logs where block_number > 12000000
    and contract_address = lower('0x4b10701Bfd7BFEdc47d50562b76b436fbB5BdB3B')
    and topics[0]::string = '0x1106ee9d020bfbb5ee34cf5535a5fbf024a011bd130078088cbf124ab3092478'
    order by tokenId desc
    )

    , sales as (
    SELECT tokenID,
    COUNT(DISTINCT tx_id) as num_tx
    FROM ethereum.nft_events
    WHERE contract_address = lower('0x4b10701Bfd7BFEdc47d50562b76b436fbB5BdB3B')
    and event_type = 'sale'
    GROUP BY 1
    )

    , joined as (
    SELECT background, body, accessory, head, glasses, num_tx
    FROM traits t INNER JOIN sales s ON t.tokenID = s.tokenID
    )

    SELECT background, body, accessory, head, glasses,
    SUM(num_tx) as total_sales
    FROM joined
    GROUP BY 1, 2, 3, 4, 5
    Run a query to Download Data