Query editor
select day, symbol, sum(market_cap) as market_capfrom (select day,case when rank() over (partition by day order by market_cap desc) > 9 then 'Others' else stablecoin end as symbol,market_capfrom (selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'USDT' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=1'))AS ARRAY(JSON))) as a(data)union ALL--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'USDC' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=2'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'UST' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=3'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'BUSD' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=4'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'DAI' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=5'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'FRAX' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=6'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'TUSD' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=7'))AS ARRAY(JSON))) as a(data)union all--selectfrom_unixtime(cast(json_extract_scalar(data, '$.date') as bigint)) as day,'MIM' as stablecoin,cast(json_extract_scalar(data, '$.totalCirculating.peggedUSD') as double) as market_capfrom UNNEST(TRY_CAST(JSON_PARSE(HTTP_GET('https://stablecoins.llama.fi/stablecoincharts/all?stablecoin=10'))AS ARRAY(JSON))) as a(data)