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


-- Шаг 1: есть ли source для транзакций?
SELECT COUNT(*) 
FROM back_office.eps_transaction et
JOIN back_office.eps_transaction_source ets
    ON ets.id = et.eps_transaction_source_id



-- Шаг 2: есть ли транзакции с суммой?
SELECT COUNT(*)
FROM back_office.eps_transaction et
JOIN back_office.eps_transaction_source ets
    ON ets.id = et.eps_transaction_source_id
JOIN back_office.transaction t
    ON t.operation_id = ets.operation_id


-- Шаг 3: есть ли incoming_order?
SELECT COUNT(*)
FROM back_office.eps_transaction et
JOIN back_office.eps_transaction_source ets
    ON ets.id = et.eps_transaction_source_id
JOIN back_office.transaction t
    ON t.operation_id = ets.operation_id
JOIN back_office.incoming_order io
    ON io.id = ets.incoming_order_id