Query editor
/*-- @title: ENS - Yearly Balance Sheet Table-- @description: Generates a yearly balance sheet table for a comprehensive view of ENS's financial position from 2019.-- @author: Steakhouse Financial-- @notes: N/A-- @version:- 2.0 - 2024-02-19 - Added comment header, updated final query to retrieve data for year 2024- 1.0 - ????-??-?? - Initial version*/with entries as (select * from dune.steakhouse.result_ens_accounting_main),items as (select '1' as rk, '<b>Assets</b>' as item, year(ts) as period, sum(case when cast(account as varchar) like '1%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '111' as rk, ' <i>Cash</i>' as item, year(ts) as period, sum(case when cast(account as varchar) like '111%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '112' as rk, ' <i>Money Markets</i>' as item, year(ts) as period, sum(case when cast(account as varchar) like '112%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '110' as rk, ' Cash & cash equivalents' as item, year(ts) as period, sum(case when cast(account as varchar) like '11%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '12' as rk, ' ETH' as item, year(ts) as period, sum(case when cast(account as varchar) like '12%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '13' as rk, ' ETH Investments' as item, year(ts) as period, sum(case when cast(account as varchar) like '13%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '2' as rk, '<b>Liabilities</b>' as item, year(ts) as period, sum(case when cast(account as varchar) like '2%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '21' as rk, ' Unearned earnings' as item, year(ts) as period, sum(case when cast(account as varchar) like '2%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '3' as rk, '<b>Capital buffer</b>' as item, year(ts) as period, sum(case when cast(account as varchar) like '3%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '31' as rk, ' Issued as payment' as item, year(ts) as period, sum(case when cast(account as varchar) like '31%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '32' as rk, ' Retained earnings' as item, year(ts) as period, sum(case when cast(account as varchar) like '32%' then amount end) as amountfrom entriesgroup by year(ts)union allselect '321' as rk, ' <i>Operating revenues</i>' as item, year(ts) as period, sum(case when cast(account as varchar) like '321%' then amount end) as amountfrom entries