Query editor
/*-- @title: Assets by Collateral type-- @author: Steakhouse Financial-- @description: Calculates debt, revenue, and annualized revenues by collateral type over the last rolling 13 months-- @notes: N/A-- @version:- 1.0 - 2024-06-06 - Initial version- 2.0 - 2024-11-04 - Migrate query to pull from (Sky - ALM - Assets Per Type)- 3.0 - 2025-05-05 - Split other crypto as Spark*/withassets as (selectperiod as dt,casewhen ilk like 'RWA%' then 'RWA'when ilk like '%PSM%' then 'PSM'when ilk like 'ETH-%' then 'ETH'when ilk like 'WSTETH-%' then 'STETH'when ilk like 'WBTC-%' then 'WBTC'when ilk like '%SPARK%' THEN 'Spark'else 'Other crypto'end as collateral,SUM(exposure) as asset,-- SUM(exposure) over (partition by period) total_asset,max(period) over (partition by year(period), month(period)) as last_day_of_monthfrom query_3989424 -- Sky - ALM - Assets per type (daily)where period > current_date - interval '13' monthGROUP BY 1, 2)selectdt,collateral,asset,SUM(asset) OVER (PARTITION BY dt) as total_assetfrom assetswhere dt = last_day_of_monthorder by dt desc