Query editor
WITH deduped AS (SELECT DISTINCT address, protocol, productFROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY LOWER(address) ORDER BY ingestion_ts DESC) AS rnFROM dune.credora_risk.ratings) rankedWHERE rn = 1)SELECT protocol AS label, COUNT(*) AS countFROM dedupedWHERE protocol IS NOT NULLAND product IN ('vaults', 'savings')GROUP BY protocolORDER BY count DESC