Service/Account/Balance/Validate/A/ProcessOneAsset/A/Repo/Query/GetTransactions.php
public function build(\Magento\Framework\DB\Select $source = null)
    {
        /* this is root query builder (started from SELECT) */
        $result = $this->conn->select();

        /* define tables aliases for internal usage (in this method) */
        $asAcc = self::AS_ACC;
        $asTran = self::AS_TRAN;

        /* FROM prxgt_acc_transaction */
        $tbl = $this->resource->getTableName(self::E_TRAN);    // name with prefix
        $as = $asTran;
        $cols = [
            self::A_ACC_ID_DEBIT => ETran::A_DEBIT_ACC_ID,
            self::A_ACC_ID_CREDIT => ETran::A_CREDIT_ACC_ID,
            self::A_AMOUNT => ETran::A_VALUE
        ];
        $result->from([$as => $tbl], $cols);    // standard names for the variables

        /* LEFT JOIN prxgt_acc_account */
        $tbl = $this->resource->getTableName(self::E_ACC);
        $as = $asAcc;
        $cols = [];
        $cond = "$as." . EAcc::A_ID . "=$asTran." . ETran::A_DEBIT_ACC_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* query tuning */
        $byAsset = "$asAcc." . EAcc::A_ASSET_TYPE_ID . "=:" . self::BND_ASSET_TYPE_ID;
        $byDate = "$asTran." . ETran::A_DATE_APPLIED . ">=:" . self::BND_DATE_FROM;
        $result->where("($byAsset) AND ($byDate)");

        return $result;
    }
public function build(\Magento\Framework\DB\Select $source = null)
    {
        /* this is root query builder (started from SELECT) */
        $result = $this->conn->select();

        /* define tables aliases for internal usage (in this method) */
        $asAcc = self::AS_ACC;
        $asTran = self::AS_TRAN;

        /* FROM prxgt_acc_transaction */
        $tbl = $this->resource->getTableName(self::E_TRAN);    // name with prefix
        $as = $asTran;
        $cols = [
            self::A_ACC_ID_DEBIT => ETran::A_DEBIT_ACC_ID,
            self::A_ACC_ID_CREDIT => ETran::A_CREDIT_ACC_ID,
            self::A_AMOUNT => ETran::A_VALUE
        ];
        $result->from([$as => $tbl], $cols);    // standard names for the variables

        /* LEFT JOIN prxgt_acc_account */
        $tbl = $this->resource->getTableName(self::E_ACC);
        $as = $asAcc;
        $cols = [];
        $cond = "$as." . EAcc::A_ID . "=$asTran." . ETran::A_DEBIT_ACC_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* query tuning */
        $byAsset = "$asAcc." . EAcc::A_ASSET_TYPE_ID . "=:" . self::BND_ASSET_TYPE_ID;
        $byDate = "$asTran." . ETran::A_DATE_APPLIED . ">=:" . self::BND_DATE_FROM;
        $result->where("($byAsset) AND ($byDate)");

        return $result;
    }
SELECT
`trn`.`debit_acc_id` AS `accIdDebit`,
`trn`.`credit_acc_id` AS `accIdCredit`,
`trn`.`value` AS `amount`
FROM
`prxgt_acc_transaction` AS `trn`
LEFT JOIN `prxgt_acc_account` AS `acc` ON
acc.id = trn.debit_acc_id
WHERE
((acc.asset_type_id =:assetTypeId)
AND (trn.date_applied >=:dateFrom))