Don't forget the query attribute of your CFOUTPUT tag. That's why you're
only getting the 1st record returning.
Steve
> -----Original Message-----
> From: Tim [mailto:[EMAIL PROTECTED]]
> Sent: 12 June 2001 16:05
> To: CF-Talk
> Subject: Aggregate functions (AVG())
>
>
> I have a simple query that includes the AVG() function
> to average some fields. The code is:
>
> <CFQUERY NAME="qGetAverage" DATASOURCE="info_survey">
> SELECT overall, AVG(overall) AS OAvg, needs,
> AVG(needs) as NAvg, tech, AVG(tech) AS TAvg,
> equipment, AVG(equipment) AS EAvg, software,
> AVG(software) AS SAvg, location
> FROM main
> WHERE (location = 'Atlanta')
> GROUP BY location, overall, needs, tech, equipment,
> software
> </CFQUERY>
>
> <cfoutput>
> Results for Atlanta; number of responses:
> #qGetAtlanta.RecordCount#
> <br>
> Overall Rating of IT, #qGetAtlanta.OAvg#<br>
> Overall rating of IT support, #qGetAtlanta.NAvg#<br>
> Technical capability, #qGetAtlanta.tavg#<br>
> Equipment availability, #qGetAlanta.eavg#<br>
> Software availability, #qGetAlanta.savg#<br>
> </cfoutput>
>
> However, it is not outputting the average of each
> field. It returns the correct number od records, 4,
> but appears to just output the value in each field of
> the first record.
>
> The four records have field values of 2, 3, 1, 4, 5;
> 5, 4, 3, 5, 4; 2, 4, 3, 2, 1; and 5, 5, 5, 5, 5. The
> output is returning values of 2, 3, 1, 4 and 5, the
> values of the first record's fields. They should be
> 3.5, 4.0, 3.0, 4.0 and 3.75.
>
> Any ideas?
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists