ML6Demographic
    Updated 2022-08-01
    WITH temp AS (SELECT sum(inner_instruction:instructions[1]:parsed:info:amount::float/1e9) as borrows
    ,inner_instruction:instructions[1]:parsed:info:destination::string
    FROM solana.core.fact_events
    WHERE inner_instruction:instructions[1]:parsed:type::string = 'transfer'
    AND inner_instruction:instructions[1]:parsed:info:source::string = '8UviNr47S8eL6J3WfDxMRa3hvLta1VDJwNWqsDgtN3Cv'
    AND BLOCK_TIMESTAMP >= '2022-01-01'
    group by 2)

    SELECT COUNT(1), '1.Plankton users' FROM temp WHERE borrows > 1 AND borrows < 500
    UNION ALL
    SELECT COUNT(1), '2.Crab users' FROM temp WHERE borrows > 500 AND borrows < 2500
    UNION ALL
    SELECT COUNT(1), '3.Fish users' FROM temp WHERE borrows > 2500 AND borrows < 10000
    UNION ALL
    SELECT COUNT(1), '4.Octopuse users' FROM temp WHERE borrows > 10000 AND borrows < 100000
    UNION ALL
    SELECT COUNT(1), '5.Dolphin users' FROM temp WHERE borrows > 100000 AND borrows < 5000000
    UNION ALL
    SELECT COUNT(1), '6.whale users' FROM temp WHERE borrows > 1000000
    Run a query to Download Data