1. A method for performing a query on records in a table with at least a first field, a second field and a third field to obtain an aggregate result on the third field of records for at least one selected combination of the first and the second fields, the method comprising: receiving a query involving a single query statement that includes at least one built-in function corresponding to the second field of the selected combination, wherein the built-in function includes a mathematical formula that selects only a third field of records whose second field is equal to the second field of the selected combination; and executing the query statement to produce the aggregate result.