mucrypto2023-09-01 07:42 AM
    Updated 2023-09-02
    with resps as
    (select defillama.get('/protocols', {}) as resp),

    m_list as (
    select
    value:parentProtocol::string as multiple_projects,
    value:description::string as description,
    value:category::string as category,
    value:name::string as name,
    value:tvl as tvl
    from resps,
    lateral flatten (input => resp:data)
    where category = 'Lending'
    and multiple_projects is not null)

    select
    name,
    sum(tvl) as total_tvl
    from m_list
    where name in (select distinct(name) from m_list)
    group by 1
    Run a query to Download Data