[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

sum from two CF queries

Posted on 2003-02-19
5
Medium Priority
?
236 Views
Last Modified: 2013-12-24
I have two queries as such:

<cfquery name="OrderGrab" datasource="eldb">
Select * from Orders, CustomerInfo, Templates, Budgets
where Orders.OrderID = #URL.recordID#
and Orders.CustomerID = CustomerInfo.CustomerID
and Templates.BudgetID = Budgets.BudgetID
and Templates.TemplateID = Orders.TemplateID
</cfquery>

and

<cfquery name="Addons" datasource="eldb">
SELECT *, (AvailableAddons.AddonPrice * OrderAddons.Quantity) as TOTAL
FROM dbo.AvailableAddons
inner join OrderAddons on OrderAddons.AddonID = AvailableAddons.AddonID
WHERE OrderAddons.Quantity >= 1
AND OrderAddons.OrderID = #URL.recordID#
</cfquery>

I want to sum the total of #Addons.TOTAL# and #OrderGrab.BudgetPrice# but don't know how to do it.

I'm brand spanking new to Coldfusion & SQL so hopefully this is an easy question.

Thanks!

0
Comment
Question by:tatortot
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
HamdyHassan earned 200 total points
ID: 7983484


<CFSET sum_addons_total = 0.00 >

<cfoutput query="Addons">

......
......
<CFSET sum_addons_total = #sum_addons_total# + #TOTAL# >
</cfouput>

<cfoutput>
<BR> Sum of Addons Total is #sum_addons_total#
</cfoutput>

0
 

Author Comment

by:tatortot
ID: 7983746
Thanks, your answer got me in the right direction. What I ended up doing was:

<CFSET sum_addons_total = 0.00 >
<CFSET sum_all_total = #OrderGrab.BudgetPrice# >

---------
---------

<cfoutput query="Addons">
<CFSET sum_addons_total = #sum_addons_total# + #TOTAL# >
</cfoutput>
<cfoutput>
<BR> Sum of Addons Total is #sum_addons_total#
</cfoutput>

<cfoutput query="OrderGrab">
<CFSET sum_all_total = #sum_all_total# + #sum_addons_total# >
</cfoutput>

<cfoutput>
<BR> Complete Total is #sum_all_total#
</cfoutput>

Thanks again, Hamdy!! Now I need to figure out how to give you the points (this is my first post).

0
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 7983778
I am happy it's working for you

Good Luck


take a look on
http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

or click "help" at the top of your page
0
 

Author Comment

by:tatortot
ID: 7984171
Well, it seems as though I *should* receive an email so I can accept your answer??

Someone posted a message today stating that email notification was down. I will wait & make sure I get the points to you somehow! :)
0
 

Author Comment

by:tatortot
ID: 7984176
I'm blind... I just noticed: "Accept Comment As Answer" link. Doh!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What You Need to Know when Searching for a Webhost Provider
This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their VPS hosting experience that much smoother.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month11 days, left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question