This topic is locked

calculations for all records instead of displayed list

5/27/2010 4:05:26 PM
ASPRunnerPro General questions
M
mfred author

I have a need to have the totals in the list to always show the totals of all records in a table rather than simply what is displayed via search. In other words, let's say there is 500 entries spanning 3 months. A client may want to display only the last month of entries but still show the current total of all entries. Is there a way that I can do that with ASPRunner?

A
ann 5/28/2010

Hi,
proceed to the Visual Editor tab. Create PHP Code Snippet. Here is a sample code for MySQL to display the number of entries:

sql = "select count(FieldName) from TableName"

set rstmp=CustomQuery(sql)

Response.Write rstmp(0)

rstmp.close

set rstmp=nothing
M
mfred author 6/24/2010

I actually I needed the total. But I knew what to change. The code is below. I do have one additional factor. They also want this to reflect specific departments. Let's say I want this to show the sums for all entries from the English department. If there a way to refine this based on a criteria in a different field?
Function BudgetQuery1_Snippet1(byref params)

sql = "select sum(Budget_Deduction) from BudgetQuery1"

set rstmp=CustomQuery(sql)

Response.Write rstmp(0)

rstmp.close

set rstmp=nothing

A
ann 6/25/2010

Hi,
you can modify the query in the following way:

sql = "select sum(Budget_Deduction) from BudgetQuery1 where DepartmentFieldName='DepartmentValue'"
M
mfred author 6/25/2010

Thanks. That was helpful. I have just been told of one other thing. Is there a way to display the total based on the department and a session variable. As in Session("AccessLevel"), access level being department managers.
I originally just listed the department totals accress the top of the list, like

NWV Academic Affairs: {$event BudgetQuery1_Snippet1} Â NWV Arts and Kinesiology: {$event BudgetQuery1_Snippet2}

but they now what only specific departmental access levels to see their own depaartment total only.

A
ann 6/28/2010

Hi,
you just need to concat access level at the end. Here is a sample for static permissions:

sql = "select sum(Budget_Deduction) from BudgetQuery1 where DepartmentFieldName='DepartmentValue' AND "& Session("GroupID") &"='department_managers'"
M
mfred author 6/28/2010

Thank you.