Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping and adding columns in same table

Status
Not open for further replies.

Shelgas

Programmer
Dec 30, 2000
5
US
I have scoured the forms but can't quite find an answer to what I need to do. I have a table with 8 brand columns along with the ID and date and closed/open value. I have to add the values in each column (int,1-4) to the results of another pre-existing grouped/ordered table query. I have managed to get the grouped values from the individual columns and add them to get the numbers for the percent formula.
What I still need to do is get the total of each group of data. This means each column must be grouped, the columns grouped valued must be added together and then added to the pre-existing values.

The results would show something like this:

Very Satisfied 17 (50%)
Satisfied 8 (24%)
Neutral 4 (12%)
Not Satisfied 5 (15%)


What I have for the individual brands looks like this:
Code:
<cfif form.brand IS 7>
  <cfquery name="OBCTotal" dbtype="query">
     SELECT  COUNT(ID) AS total	
     FROM    OtBndCllList
  </cfquery>
     <cfset total = #Total.Total# + #OBCTotal.Total#>
  <cfquery name="OBCSatisfy" dbtype="query">
    SELECT brandX AS X, COUNT(ID) AS Satisfy	
    FROM OtBndCllList
    GROUP BY	brandX
    ORDER BY 	brandX
  </cfquery>

then I am calling it and doing the math like this:
Code:
<cfoutput query="Satisfaction">
	<cfif Satisfaction.Satisfied IS 1>
		<cfset custFB = "#Satisfaction.Satisfaction#">
	</cfif>
</cfoutput>
<cfoutput query="OBCSatisfy">
	<cfif OBCSatisfy.X IS 1>
		<cfset custOBC = "#OBCSatisfy.Satisfy#">
	</cfif>
</cfoutput>
<cfoutput>
#(custFB + custOBC)#&nbsp;(#NumberFormat((custFB + custOBC)/total*100)#%)
</cfoutput>

Not sure how to even approach this one.
 
Don't know why I never got a response on this, but I solved it by doing a query of queries to get just the brand fields, then looped the columnlist and got the values with evaluate(columnlist).
Now I just need figure out how to group the values in order to add them to the pre existing values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top