Patent ID: 8041731

Claim:
A method comprising: receiving a pivoting query on a data table, wherein the pivoting query identifies, in the data table, one or more first columns as pivot columns, one or more second columns as measure columns, zero or more third columns as grouping columns, and one or more functions as aggregating functions; wherein the pivoting query causes selecting a plurality of rows from the data table and outputting, based on the plurality of rows selected from the data table, a result set that comprises one or more resulting pivot value columns, each of the one or more resulting pivot value columns corresponding to a unique value among a plurality of possible stored values in the pivot columns in the data table; in response to receiving the pivoting query on the data table: setting up a staging table that comprises one or more staging pivot value columns, and zero or more staging grouping columns, wherein each of the one or more staging pivot value columns in the staging table corresponds to one of the plurality of possible stored values in the pivot columns in the data table, and wherein the staging table comprises one or more staging rows; for a first particular row selected from the data table, establishing a particular staging row in the one or more staging rows in the staging table; storing, based on stored values in the measure columns in the first particular row selected from the data table, one or more values in the staging pivot value columns for the particular staging row in the staging table; determining that a second particular row selected from the data table corresponds to the particular staging row in the one or more staging rows in the staging table; aggregating, using one or more of the aggregating functions, (a) one or more stored values in the measure columns in the second particular row selected from the data table and (b) the one or more values of the staging pivot value columns for the particular staging row in the staging table; and generating, based on the one or more staging rows in the staging table, the result set; wherein the method is performed by one or more computing devices.