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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to