May 5, 2004 at 6:14 am
I am trying to find a way to more efficiently run calculations other than through an asp script. I would like to have a dynamic stored procedure executed from an asp page that performs the calculations.
What I have the follwoing columns that are called "amounts", "plsummary" and "uid".
Based on the uid (which is the assigned id to a person) will display their information. I have different headings under "plsummary" like expenses, other expenses, etc and the amounts. I need something that will give me the sum for each plsummary, i.e.
sum(amount) as amount
where plsummary = 'expenses' and uid = uid
and so on for each plsummary...
Then I need various totals from these areas. For example, net contributions would be revenue - expenses. Then income available would be net contributions - general funds, net income available would be income available - other income and distributable income would be net income available - other expenses, which should always be 0.
The dollar amounts need to be rounded to the nearest dollar and formatted as currency in the display. I have tried several ways to no avail and am beginning to get frustrated. I'm sure that this is probably not very difficult, but cn't seem to see the solution.
Thanks in advance!
May 5, 2004 at 7:18 am
Few questions
Do you want the sums (revenue, expenses etc) as well as calculated totals?
Is there a fixed number (and name) of sums and totals?
Do you want the results in rows or columns (pivot)?
Are you rounding up, down or off? Is the rounding before or after summing?
Can you supply example input and how the output is to look
Far away is close at hand in the images of elsewhere.
Anon.
May 5, 2004 at 7:52 am
The output would be:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
An example of the code would be and then it is the same for each plsummary:
<%
strSQL = "SELECT paystat_name, sum(amount) as amount FROM tbl_mdpayst_mymcc where plsummary = 'expenses' and uid = " + Replace(rsExpenses__MMColParam, "'", "''") + "group by paystat_name, paystat_nmbr order by paystat_name"
SET DbObj = Server.CreateObject("ADODB.Connection")
DbObj.Open "Provider=SQLOLEDB.1;server=servername;Database=dbname;uid=uid;pwd=pwd"
SET oRs = DbObj.Execute(strSQL)
%>
When doing overall totals:
<% = round(rsRevTotal.Fields("total")*-1) + round(rsExpTotal.Fields("total")*-1) %>
Basically, I would like to round off before summing. The numbers are not fixed as the data is updated once a month, however the plsummary names are the same. The user is able to click wach of the subcategories in each plsummary area for a drilldown view, which is working fine. The initial display where totals and overall totals is what is giving me problems, since I am working with positve and negative amounts.
May 6, 2004 at 2:13 am
I have been thinking about this and have not come up with a simple answer yet. I am still unsure of what you want. Your asp is showing the details already and the totals are as you calculate.
One thing to do is to put the sql you posted inside a procedure and if necessary include a total.
To produce the list would require several UNION or creation of a temp table to hold each line.
If you truly want to produce the list from the procedure, I suggest creating a template with several tables to define each group of data and the data that defines it.
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply