Jim, The loop you have only appends all the totals to the one variable. So you are probably getting a total for all variables. What you need to do is within the loop dynamically set the variable to each majorcode and append to that variable instead of to the one variables. I think if you used the query loop option you would have much better success with this.
<cfloop query="queryname"> This way you can set which major code it is on by record reference and the total to that variable. HTH Mark -----Original Message----- From: James Watkins [mailto:[EMAIL PROTECTED] Sent: Thursday, November 18, 2004 3:28 PM To: CF-Talk Subject: Counting and looping I am trying to count individual id's in each major but can't see to get the thing right. Any help would be appreciated: (Oracle SQL) <CFQUERY NAME="summary" DATASOURCE="NGTbanner" > SELECT distinct majr_code1 major, id, count(id) tstuds, last_name, first_name, styp_code stype, camp_code, total_credit_hours chrs, ests_code rstatus, sysdate, decode(camp_code,'1','Clarkesville','2','Blairsville','3','Currahee','9' ,'Internet') camp from as_student_enrollment_summary where term_code_key = '#term#' and levl_code = '50' and registered_ind = 'Y' and camp_code like '#campus#' Group by majr_code1, id, last_name, first_name, styp_code, camp_code, total_credit_hours, ests_code, sysdate order by #sort# </CFQUERY> <!--- Calculate totals for each major ----> <cfset numamount="0"> <cfset numend="#summary.recordcount#"> <cfloop from="1" to="#numend#" index="i"> <cfset numamount=numamount+#summary.tstuds[i]#> </cfloop> Jim Watkins VP Technology & Institutional Services 706 781-2305 - Blairsville 706 754-7850 - Clarkesville [EMAIL PROTECTED] http://www.northgatech.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184830 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

