select
e.classification,
e.contract_model_label as eps_model,
et.contract_class_code,
et.contract_model_label as transaction_model,
count(*) as transaction_count
from back_office.eps_transaction et
join ourpension.eps e
on e.id = et.eps_id
where e.service_type = :service_type
and e.periodicity in (1, 2)
and et.oper_date >= to_date(:startDate, 'DD.MM.YYYY')
and et.oper_date <
to_date(:endDate, 'DD.MM.YYYY') + interval '1 day'
group by
e.classification,
e.contract_model_label,
et.contract_class_code,
et.contract_model_label
order by 1, 2, 3, 4;