<!--- Calculate totals for each major ---->
<cfset stCount = StructNew()>
<cfloop query="summary">
<cfif NOT StructKeyExists(stCount,summary.major)>
<cfset stCount[summary.major] = 0>
</cfif>
<cfset stCount[summary.major] = stCount[summary.major] +
summary.tstuds>
</cfloop>
<cfdump var="#stCount#">
Pascal
PS1: If ID is your PK, "distinct", "count(id)" and "GROUP BY" are just
overhead
PS2: Need I repeat?? CFQUERYPARAM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> -----Original Message-----
> From: James Watkins [mailto:[EMAIL PROTECTED]
> Sent: 18 November 2004 23:28
> 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>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:184845
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54