handle formatted records in query builder
get aggregated fields working for queries