navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Advanced grouping and Sum

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Advanced grouping and Sum
Page: [1]
 
xgd

 

Posts: 59
Joined: 5/1/2007
Status: offline

 
Advanced grouping and Sum - 10/31/2007 14:08:56   
Greetings,
I can't seem to get a hold of this one.
I am trying to use sum and advanced grouping
What I have:
Query:
fp_sQry="SELECT AR1_CustomerMaster.CustomerName, ARO_InvHistoryDetail.SOItemNumber, ARO_InvHistoryDetail.SODescription, Sum(ARO_InvHistoryDetail.SOUnitPrice) AS SumOfSOUnitPrice FROM (ARN_InvHistoryHeader INNER JOIN ARO_InvHistoryDetail ON ARN_InvHistoryHeader.InvoiceNumber = ARO_InvHistoryDetail.InvoiceNumber) INNER JOIN AR1_CustomerMaster ON ARN_InvHistoryHeader.CustomerNumber = AR1_CustomerMaster.CustomerNumber GROUP BY AR1_CustomerMaster.CustomerName, ARO_InvHistoryDetail.SOItemNumber, ARO_InvHistoryDetail.SODescription HAVING (((ARO_InvHistoryDetail.SOItemNumber) Is Not Null)) ORDER BY AR1_CustomerMaster.CustomerName;"

And
<!--#include file="_fpclass/fpdbrgn1.inc"-->

<% 
DIM customer,tempcustomer 
customer=FP_FieldVal(fp_rs,"CustomerName") 
If customer <> tempcustomer then 
tempcustomer=customer 
%>

<td bgcolor="#FFFFCC" colspan=2><%=tempcustomer%></td>  
</tr>
<%end if%>
<tr>
	<td bgcolor="#FFFFFF" >
		<%=FP_FieldVal(fp_rs,"SODescription")%> <%=formatcurrency(FP_FieldVal(fp_rs,"SumofSOUnitPrice"),2)%></td>
</tr>

<!--#include file="_fpclass/fpdbrgn2.inc"-->

This works great and returns what I expect:

CustomerName1
Grouped Product Description1 - Grouped Product Price
Grouped Product Description2 - Grouped Product Price
CustomerName2
Grouped Product Description1 - Grouped Product Price
Grouped Product Description2 - Grouped Product Price
etc....

What I need is:

CustomerName1 - SUM(Grouped Product Price)
Grouped Product Description1 - Grouped Product Price
Grouped Product Description2 - Grouped Product Price
CustomerName2 - SUM(Grouped Product Price)
Grouped Product Description1 - Grouped Product Price
Grouped Product Description2 - Grouped Product Price
etc....


Any guidance will be greatly appreciated,

Thanks,
gd
bernieboy31

 

Posts: 79
Joined: 3/5/2005
From: London, United Kingdom
Status: offline

 
RE: Advanced grouping and Sum - 11/2/2007 2:35:49   
Not that (as yet) clever with asp I tend to do all database calculations within an access query table.

Don't know if this idea helps :)

(in reply to xgd)
William Lee

 

Posts: 1080
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Advanced grouping and Sum - 11/3/2007 12:31:40   

I am thinking of Master/Details pages.

Construct a query that will display only the CustomerName and SumOfSOUnitPrice next to it. This should show the Grandsum for each customer.

In this Master page, hyperlink the customername and the corresponding Grandsum as parameters to the next page:

details.asp?CustomerName=<%=FP_FieldVal(fp_rs,"CustomerName")&GrandSum=<%=FP_FieldVal(fp_rs,"SumOfSOUnitPrice")

The details.asp should have a DRW with query that pulls data based on this CustomerName.

Before the repeat results region, you can response.write the 2 parameters that are passed.

<%=Request("CustomerName")%> - <%=Request("GrandSum")%>

<!--#include file="_fpclass/fpdbrgn1.inc"-->

<% 

	<td bgcolor="#FFFFFF" >
		<%=FP_FieldVal(fp_rs,"SODescription")%> <%=formatcurrency(FP_FieldVal(fp_rs,"SumofSOUnitPrice"),2)%></td>
</tr>

<!--#include file="_fpclass/fpdbrgn2.inc"-->


Hope this helps,

_____________________________

William Lee


(in reply to xgd)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Advanced grouping and Sum
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts