This topic is locked

SUM Amount in Report

9/8/2008 1:35:40 AM
PHPRunner General questions
F
fawad112 author

Hi,
I need a little help. Below is the code i m using. I want to display the total amount in the report but i am unable to do it. Please check also check the report image in the link below
[codebox]SELECT

SUM(writerstot),

writerid,

`date`,

`ref`

FROM accountdetails

GROUP BY writerid, `ref`[/codebox]
Total amount image
I want the SUM(writerstot) to be displayed at the bottom of the Total Field.
I am able to do this if i just GROUP by writerid but then it doesn't show values in the Ref field. What should i do to display the total.
Regards

J
Jane 9/8/2008

Please make sure you have checked off Sum option for SUM(writerstot) on the Report: Totalstab.

F
fawad112 author 9/8/2008

sorry but it doesnt help. i want to display the values on the writerstot field and the total of them at the bottom. I have used GROUP BY (writersid) so that the amount and total of the individual should come in the report. any other way ?

F
fawad112 author 9/24/2008

Ok i am using this code in the event BEFORE DISPLAY to display the total this query works fine but it is not displaying anything on the report page.

[codebox]global $conn;
//** Check if specific record exists ****

//global $conn;

$tot= "";

$strSQLExists = "select SUM(writerstot),ref,writerid,date from accountdetails where writerid='".$_SESSION["UserID"]."' GROUP BY writerid";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

$tot.=$data["SUM(writerstot)"];
$smarty->assign('tot',$tot);

echo $tot;[/codebox]

F
fawad112 author 9/24/2008

It is working i was missing something sorry . <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=33371&image=1&table=forumreplies' class='bbc_emoticon' alt=':unsure:' />