select
extract(year from t.effective_date) as year,
sum(t.value) as deposit_value
from back_office.transaction t
join back_office.operation o
on o.id = t.operation_id
join back_office.operation_type ot
on ot.id = o.operation_type_id
join back_office.account ca
on ca.id = t.credit_account_id
join back_office.account_type cat
on cat.id = ca.account_type_id
join back_office.account_type_group catg
on catg.id = cat.account_type_group_id
join ourpension.sharer s
on s.id = ca.owner_sharer_id
where s.number = '17_15AVS0000530'
and catg.mnemonics = 'Н'
and ot.code = 'DEPOSIT_ENROLLMENT'
and o.approved is not null
and o.deleted is null
and t.effective_date >= cast('2018-01-01' as date)
and t.effective_date < cast('2020-01-01' as date)
group by extract(year from t.effective_date)
order by year;