purifLottery winners
    Updated 2025-01-08
    with lottery_data as (
    select concat('0x',substr(TOPICS[2], 27,64)) as address,
    (utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as amount
    from berachain.testnet.fact_event_logs
    where CONTRACT_ADDRESS=LOWER('0x390b6323Aed0F1E30f3B7179b8a58E4120bC91ca')
    and topics[0]='0x2b488325d702ee2d61df931482ad57886d64dc3e77c8f507d7e3bdab0c3e314d'
    )

    select address, won_amount,count_win, sum(won_amount) over (order by won_amount) from
    (select address, sum(amount) as won_amount, count(amount) as count_win
    from lottery_data
    group by 1
    order by won_amount desc)
    order by won_amount desc
    QueryRunArchived: QueryRun has been archived