Calculates average from all numeric values given in the list
listAvg(list [, delimiters] [, multiCharacterDelimiter])
→ returns numeric
list.listAvg([delimiters] [, multiCharacterDelimiter])
,
false
athletes = queryNew('id,name,bestTime', 'integer,varchar,decimal');
queryAddRow(athletes,[{
id: 0,
name: 'Anne',
bestTime: 15.4
},{
id: 1,
name: 'John',
bestTime: 12.8
},{
id: 2,
name: 'Sue',
bestTime: 9.1
}]);
writeOutput('Athlete''s average best time is #NumberFormat(listAvg(ValueList(athletes.bestTime)),'0.00')# seconds.');
Expected Result: Athlete's average best time is 12.43 seconds.
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.