Lib/Repo/Def/Module.php
function getSalesOrdersPvForPeriod($dsFrom, $dsTo)
    {
        $tsFrom = $this->_toolPeriod->getTimestampFrom($dsFrom);
        $tsTo = $this->_toolPeriod->getTimestampTo($dsTo);
        /* aliases and tables */
        $asSummary = 'summary';
        $asPv = 'pps';
        $tblPv = $this->resource->getTableName(PvSale::ENTITY_NAME);
        // SELECT FROM prxgt_pv_sale pps
        $query = $this->conn->select();
        $query->from([$asPv => $tblPv], [$asSummary => 'SUM(' . PvSale::A_TOTAL . ')']);
        // where
        $whereFrom = $asPv . '.' . PvSale::A_DATE_PAID . '>=' . $this->conn->quote($tsFrom);
        $whereTo = $asPv . '.' . PvSale::A_DATE_PAID . '<=' . $this->conn->quote($tsTo);
        $query->where("$whereFrom AND $whereTo");
        // $sql = (string)$query;
        $result = $this->conn->fetchOne($query);
        return $result;
    }
function getSalesOrdersPvForPeriod($dsFrom, $dsTo)
    {
        $tsFrom = $this->_toolPeriod->getTimestampFrom($dsFrom);
        $tsTo = $this->_toolPeriod->getTimestampTo($dsTo);
        /* aliases and tables */
        $asSummary = 'summary';
        $asPv = 'pps';
        $tblPv = $this->resource->getTableName(PvSale::ENTITY_NAME);
        // SELECT FROM prxgt_pv_sale pps
        $query = $this->conn->select();
        $query->from([$asPv => $tblPv], [$asSummary => 'SUM(' . PvSale::A_TOTAL . ')']);
        // where
        $whereFrom = $asPv . '.' . PvSale::A_DATE_PAID . '>=' . $this->conn->quote($tsFrom);
        $whereTo = $asPv . '.' . PvSale::A_DATE_PAID . '<=' . $this->conn->quote($tsTo);
        $query->where("$whereFrom AND $whereTo");
        // $sql = (string)$query;
        $result = $this->conn->fetchOne($query);
        return $result;
    }
SELECT
SUM(pps.total)
FROM `prxgt_pv_sale` AS `pps`
WHERE (pps.date_paid >= '2016-01-01 08:00:00')
AND (pps.date_paid <= '2017-01-01 07:59:59')

@param string $dsFrom
@param string $dsTo