$strSQL=
"SELECT sum((NOBEDOCCBFW+NOBEDOCCNEW-NOBEDRETURN- NOBEDUNACKNOWLEDGE)) as ipdinward_pretotal,
(SELECT sum((NOBEDOCCBFW+NOBEDOCCNEW-NOBEDRETURN- NOBEDUNACKNOWLEDGE))
FROM DNHOSPITAL_TEST.dbo.HN_STAT_WARD_HEADER
WHERE StatDate BETWEEN '".$year."-".$month."-1' AND '".$year."-".$month."-".$date."') as ipdinward_total
FROM DNHOSPITAL_TEST.dbo.HN_STAT_WARD_HEADER
WHERE StatDate BETWEEN '".($year-1)."-".$month."-1' AND '".($year-1)."-".$month."-".$dd."' ";
$objExec = odbc_exec($conn,$strSQL) or die ("Error SQL [".$strSQL."]");
while($objResult = odbc_fetch_object($objExec))
{
$ipdinward_pretotal=$objResult->ipdinward_pretotal;
$ipdinward_total=$objResult->ipdinward_total;
if($ipdinward_total!=0&&$ipdinward_pretotal!=0)
{
$ipdinward= (($ipdinward_total-$ipdinward_pretotal)*100)/$ipdinward_pretotal;
echo "<td span class=border>".(number_format($ipdinward_total, 0))."<br>"
.(number_format($ipdinward, 2))."</td>";
}else{
echo "<td span class=border>".(number_format($ipdinward, 0))."</td>";
}
}
Echo
SELECT sum((NOBEDOCCBFW+NOBEDOCCNEW-NOBEDRETURN- NOBEDUNACKNOWLEDGE)) as ipdinward_pretotal,
(SELECT sum((NOBEDOCCBFW+NOBEDOCCNEW-NOBEDRETURN- NOBEDUNACKNOWLEDGE))
FROM DNHOSPITAL_TEST.dbo.HN_STAT_WARD_HEADER
WHERE StatDate BETWEEN '2019-1-1' AND '2019-1-31') as ipdinward_total
FROM DNHOSPITAL_TEST.dbo.HN_STAT_WARD_HEADER
WHERE StatDate BETWEEN '2018-1-1' AND '2018-1-31'
Notice: Undefined variable: ipdinward in