我创建了一个似乎没有错误执行的查询。我在与一个客户相关的两个不同字段中获得了两列的总数,我只想检索过去一年内的数据。
我已经使用了它,但它似乎抛出了所有存储的数据。
$yearago = (date('Y')-1).date('-m-d');
$sumtotal = $adb->pquery("SELECT
SUM(currentamount),
SUM(newcurrentamount),
(SUM(currentamount) + SUM(newcurrentamount)) as 'Total'
FROM vtiger_addisa, vtiger_isa
WHERE vtiger_addisa.addrelatedclient = $relatedclient
AND vtiger_isa.relatedclient = $relatedclient
AND vtiger_isa.startdate >= $yearago
");
$sumtotal->fetchInto($row);
$clientotal = $row['Total'];
echo $clientotal;
//print_r($sumtotal);