I am reporting totals from a Pervasive database. The column in the database is actually a string. What is occuring is that if I have five records with a value of 5.25 in each record but one of the records is -5.25, the result I pull out is showing $26.25 instead of $15.75. Is appears it is converting and adding the strings to an absolute value. I've posted the code below but was curious if anyone had suggestions on how to handle this. Thanks.
//Return DEDUCTION records for year to date...
$s_query_deduction_ytd = "SELECT UPCHKD.EARNDED AS TYPE, Sum(UPCHKD.EEXTEND) AS TOTAL, UPCHKGRP.DESCRIPTION
FROM
(UPEMPL INNER JOIN UPCHKH ON UPEMPL.EMPLOYEE = UPCHKH.EMPLOYEE) INNER JOIN (UPCHKD INNER JOIN UPCHKGRP ON UPCHKD.EARNDED = UPCHKGRP.EARNDED) ON (UPCHKH.PEREND = UPCHKD.PEREND) AND (UPCHKH.EMPLOYEE = UPCHKD.EMPLOYEE)
WHERE
UPEMPL.SSN = '$ss_num' AND
UPCHKH.TRANSDATE > $ytd_date AND
UPCHKH.TRANSDATE <= $mod_date AND
UPCHKD.EARNDED <> 'PRDIR' AND
UPCHKGRP.GROUPING = 2
GROUP BY UPEMPL.SSN, UPCHKD.EMPLOYEE, UPCHKD.EARNDED, UPCHKGRP.DESCRIPTION
ORDER BY UPCHKGRP.DESCRIPTION";
$s_result_deduction_ytd = odbc_exec($connect_soinc, $s_query_deduction_ytd);
$total = odbc_result($s_result_deduction_ytd, 2);
$c_total = '$' . number_format($total, 2, '.', ',');
//Return DEDUCTION records for year to date...
$s_query_deduction_ytd = "SELECT UPCHKD.EARNDED AS TYPE, Sum(UPCHKD.EEXTEND) AS TOTAL, UPCHKGRP.DESCRIPTION
FROM
(UPEMPL INNER JOIN UPCHKH ON UPEMPL.EMPLOYEE = UPCHKH.EMPLOYEE) INNER JOIN (UPCHKD INNER JOIN UPCHKGRP ON UPCHKD.EARNDED = UPCHKGRP.EARNDED) ON (UPCHKH.PEREND = UPCHKD.PEREND) AND (UPCHKH.EMPLOYEE = UPCHKD.EMPLOYEE)
WHERE
UPEMPL.SSN = '$ss_num' AND
UPCHKH.TRANSDATE > $ytd_date AND
UPCHKH.TRANSDATE <= $mod_date AND
UPCHKD.EARNDED <> 'PRDIR' AND
UPCHKGRP.GROUPING = 2
GROUP BY UPEMPL.SSN, UPCHKD.EMPLOYEE, UPCHKD.EARNDED, UPCHKGRP.DESCRIPTION
ORDER BY UPCHKGRP.DESCRIPTION";
$s_result_deduction_ytd = odbc_exec($connect_soinc, $s_query_deduction_ytd);
$total = odbc_result($s_result_deduction_ytd, 2);
$c_total = '$' . number_format($total, 2, '.', ',');