Загрузка данных


select
    to_char(et.oper_date, 'MM.YYYY') as report_month,
    et.contract_class_code,
    et.contract_model_label,
    count(*) as transaction_count
from back_office.eps_transaction et
join ourpension.eps e
    on e.id = et.eps_id
where e.service_type = 'NPO'
  and e.periodicity in (1, 2)
  and nullif(btrim(et.contract_class_code), '') is not null
  and nullif(btrim(et.contract_model_label), '') is not null
group by
    to_char(et.oper_date, 'MM.YYYY'),
    et.contract_class_code,
    et.contract_model_label
order by min(et.oper_date) desc
limit 20;