Highlighted

CF mathmatics

New Here ,
May 31, 2019

Copy link to clipboard

Copied

Need a bit of assistance.  I have a client who manually creates a report t the end of each year that consists of poundage of every product per customer.  A customer may buy 50K lbs of different products each year.  Is there a way that I can add anywhere from 2 to 1000 different numbers together by outputting the data into a cfset tag or something else?

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

Following the query, use query-of-a-query:

<cfquery name="gcrQoQ" dbType="query">

    SELECT SUM(quantity) as totalQuantity

    FROM gcr

</cfloop>

<cfset quantityOrdered=gcrQoQ.totalQuantity>

Views

173

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CF mathmatics

New Here ,
May 31, 2019

Copy link to clipboard

Copied

Need a bit of assistance.  I have a client who manually creates a report t the end of each year that consists of poundage of every product per customer.  A customer may buy 50K lbs of different products each year.  Is there a way that I can add anywhere from 2 to 1000 different numbers together by outputting the data into a cfset tag or something else?

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

Following the query, use query-of-a-query:

<cfquery name="gcrQoQ" dbType="query">

    SELECT SUM(quantity) as totalQuantity

    FROM gcr

</cfloop>

<cfset quantityOrdered=gcrQoQ.totalQuantity>

Views

174

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 31, 2019 0
Adobe Community Professional ,
Jun 01, 2019

Copy link to clipboard

Copied

Are the numbers coming from a column in a database table? If so, use the cfquery tag to construct a query that reads the values from the database. Then add the values in the query.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2019 0
New Here ,
Jun 01, 2019

Copy link to clipboard

Copied

The numbers would come from a column.  I am not sure how many rows will be returned and I am about 3 weeks into coding cfml again after a 12 year hiatus. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2019 0
Adobe Community Professional ,
Jun 01, 2019

Copy link to clipboard

Copied

No problem. Welcome back to ColdFusion!

It would help if you could write a query that gets all the orders within a period of time, for a given customerID. Bring the query to the forum for discussion.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2019 0
New Here ,
Jun 01, 2019

Copy link to clipboard

Copied

<cfquery name="gcr" datasource="TCN">

SELECT *

FROM purchaseordertable

WHERE BuyerName = 'NFLLC' and Packstyle = '18/8oz. Bags'

ORDER BY packstyle</cfquery>

I want to add all returned values for Quantity.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2019 0
Adobe Community Professional ,
Jun 02, 2019

Copy link to clipboard

Copied

Following the query, use query-of-a-query:

<cfquery name="gcrQoQ" dbType="query">

    SELECT SUM(quantity) as totalQuantity

    FROM gcr

</cfloop>

<cfset quantityOrdered=gcrQoQ.totalQuantity>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2019 1
New Here ,
Jun 02, 2019

Copy link to clipboard

Copied

That worked... Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2019 0