select
to_char(o.ef_date, 'DD.MM.YYYY') as effective_date,
ot.name,
case
when ot.code = 'PDS_NDFL_REDEMPTION_PAYMENT'
or coalesce(o.cred_mnemonics, '') like '%НДФЛ%'
then null
else o.value
end as value,
o.ef_date,
case
when ot.code = 'PDS_NDFL_REDEMPTION_PAYMENT'
or coalesce(o.cred_mnemonics, '') like '%НДФЛ%'
then o.value
else null
end as ndfl
from operation o
join back_office.operation_type ot
on ot.id = o.operation_type_id
where o.deb_mnemonics is not null
order by o.ef_date, o.id;