In this paper we introduce generalized projections (GPs), an extension of duplicateeliminating projections, that capture aggregations, groupbys, duplicate-eliminating projections (distinct), and duplicate-preserving projections in a common uni ed framework. Using GPs we extend well known and simple algorithms for SQL queries that use distinct projections toderive algorithmsfor queries using aggregations like sum, max, min, count, and avg. We develop powerful query rewrite rules for aggregate queries that unify and extend rewrite rules previously known in the literature. We then illustrate the power of our approach by solving a very practical and important problem in data warehousing: how to answer an aggregate query on base tables using materialized aggregate views (summary tables).