def applyDeviationToRecords( dbid, numericField, deviationField, 
                                                query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) 
      fieldNames = Array[numericField]
      avg = average( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options )
      fieldNames << "3" # Record ID#
      iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options ){|record|
         result = deviation( [avg[numericField],record[numericField]] )
         clearFieldValuePairList
         addFieldValuePair( deviationField, nil, nil, result.to_s )
         editRecord( dbid, record["3"], fvlist )
      }
   end
def applyDeviationToRecords( dbid, numericField, deviationField, 
                                                query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) 
      fieldNames = Array[numericField]
      avg = average( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options )
      fieldNames << "3" # Record ID#
      iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options ){|record|
         result = deviation( [avg[numericField],record[numericField]] )
         clearFieldValuePairList
         addFieldValuePair( deviationField, nil, nil, result.to_s )
         editRecord( dbid, record["3"], fvlist )
      }
   end
Query records, get the average of the values in a numeric field, calculate each record's deviation
 from the average and put the deviation in a percent field each record.