def iterateSummaryRecords( dbid, fieldNames,query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil )
   
      getSchema(dbid)
      
      slist = ""
      summaryRecord = {}
      doesTotal = {}
      doesAverage = {}
      summaryField = {}
      fieldType = {}
      
      fieldNames.each{ |fieldName|
         fieldType[fieldName] = lookupFieldTypeByName(fieldName)
         isSummaryField = true     
         doesTotal[fieldName] = isTotalField?(fieldName)
         doesAverage[fieldName] = isAverageField?(fieldName)
         if doesTotal[fieldName] 
            summaryRecord["#{fieldName}:Total"] = 0 
            isSummaryField = false
         end   
         if doesAverage[fieldName] 
            summaryRecord["#{fieldName}:Average"] = 0 
            isSummaryField = false
         end
         if isSummaryField
            summaryField[fieldName] = true
            fieldID = lookupFieldIDByName(fieldName)  
            slist << "#{fieldID}."
         end
      }
      slist[-1] = ""
      
      count = 0
      
      iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options) { |record|
         
         summaryFieldValuesHaveChanged = false
         fieldNames.each{ |fieldName| 
            if summaryField[fieldName] and record[fieldName] != summaryRecord[fieldName]   
               summaryFieldValuesHaveChanged = true
               break
            end
         }

         if summaryFieldValuesHaveChanged
         
            summaryRecord["Count"] = count
            fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) 
               end   
               if doesAverage[fieldName]
                  summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count if count > 0
                  summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName])
               end   
            }
            
            yield summaryRecord 
            
            count=0
            summaryRecord = {}
            fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] = 0 
               end   
               if doesAverage[fieldName] 
                  summaryRecord["#{fieldName}:Average"] = 0 
               end   
            }
         end
         
         count += 1
         fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] += record[fieldName].to_i 
               end
               if doesAverage[fieldName] 
                  summaryRecord["#{fieldName}:Average"] += record[fieldName].to_i 
               end
               if summaryField[fieldName]               
                  summaryRecord[fieldName] = record[fieldName]
               end   
         }
      }
      
      summaryRecord["Count"] = count
      fieldNames.each{|fieldName| 
         if doesTotal[fieldName] 
            summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) 
         end   
         if doesAverage[fieldName] 
            summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count
            summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName])
         end   
      }
      yield summaryRecord 
   
   end
def iterateSummaryRecords( dbid, fieldNames,query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil )
   
      getSchema(dbid)
      
      slist = ""
      summaryRecord = {}
      doesTotal = {}
      doesAverage = {}
      summaryField = {}
      fieldType = {}
      
      fieldNames.each{ |fieldName|
         fieldType[fieldName] = lookupFieldTypeByName(fieldName)
         isSummaryField = true     
         doesTotal[fieldName] = isTotalField?(fieldName)
         doesAverage[fieldName] = isAverageField?(fieldName)
         if doesTotal[fieldName] 
            summaryRecord["#{fieldName}:Total"] = 0 
            isSummaryField = false
         end   
         if doesAverage[fieldName] 
            summaryRecord["#{fieldName}:Average"] = 0 
            isSummaryField = false
         end
         if isSummaryField
            summaryField[fieldName] = true
            fieldID = lookupFieldIDByName(fieldName)  
            slist << "#{fieldID}."
         end
      }
      slist[-1] = ""
      
      count = 0
      
      iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, options) { |record|
         
         summaryFieldValuesHaveChanged = false
         fieldNames.each{ |fieldName| 
            if summaryField[fieldName] and record[fieldName] != summaryRecord[fieldName]   
               summaryFieldValuesHaveChanged = true
               break
            end
         }

         if summaryFieldValuesHaveChanged
         
            summaryRecord["Count"] = count
            fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) 
               end   
               if doesAverage[fieldName]
                  summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count if count > 0
                  summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName])
               end   
            }
            
            yield summaryRecord 
            
            count=0
            summaryRecord = {}
            fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] = 0 
               end   
               if doesAverage[fieldName] 
                  summaryRecord["#{fieldName}:Average"] = 0 
               end   
            }
         end
         
         count += 1
         fieldNames.each{|fieldName| 
               if doesTotal[fieldName] 
                  summaryRecord["#{fieldName}:Total"] += record[fieldName].to_i 
               end
               if doesAverage[fieldName] 
                  summaryRecord["#{fieldName}:Average"] += record[fieldName].to_i 
               end
               if summaryField[fieldName]               
                  summaryRecord[fieldName] = record[fieldName]
               end   
         }
      }
      
      summaryRecord["Count"] = count
      fieldNames.each{|fieldName| 
         if doesTotal[fieldName] 
            summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) 
         end   
         if doesAverage[fieldName] 
            summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count
            summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName])
         end   
      }
      yield summaryRecord 
   
   end
(The QuickBase API does not supply a method for this.)
 Loop through summary records, like the records in a QuickBase Summary report.
 Fields with 'Total' and 'Average' checked in the target table will be summed and/or averaged.
 Other fields with duplicate values will be merged into a single 'record'.
 The results will be sorted by the merged fields, in ascending order.
 e.g. -
    iterateSummaryRecords( "vavaa4sdd", ["Customer", "Amount"] ) {|record|
        puts "Customer: #{record['Customer']}, Amount #{record['Amount']}
    }
 would print the total Amount for each Customer, sorted by Customer.