3. The method of claim 1 , wherein the first subquery includes a group by clause based on a first set of columns and the second subquery includes a group by clause based on a second set of columns, wherein generating the statement comprises: determining a union of the first set of columns and the second set of columns; and adding a group by clause to the first database query to group the result of the first database query by the union of the first and second set of columns.
3. The method of claim 1 , wherein the first subquery includes a group by clause based on a first set of columns and the second subquery includes a group by clause based on a second set of columns, wherein generating the statement comprises: determining a union of the first set of columns and the second set of columns; and adding a group by clause to the first database query to group the result of the first database query by the union of the first and second set of columns. 4. The method of claim 3 , wherein the first expression is a query with the result table as input and a group by clause based on the first set of columns and the second expression is a query with the result table as input and a group by clause based on the second set of columns.