1. A method executable by at least one processor in a database system, comprising: receiving, by the at least one processor, a query that specifies an aggregate on distinct values of at least one attribute, the query further specifying grouping on plural grouping sets, the plural grouping sets having at least a first grouping set and a second grouping set; identifying, by the at least one processor, distinct values of the at least one attribute and storing the distinct values of the at least one attribute in a first table; computing, by the at least one processor, aggregates for groups specified by the first grouping set using the first table; and computing, by the at least one processor, aggregates for groups specified by the second grouping set using the first table.