1. A method for transforming a query in a relational database management system using window aggregation, the query including an outer block and a subquery, the subquery having an aggregation block that employs an aggregation function with an inner select clause, and the outer block including a reference to an object, the method comprising: receiving the query; verifying that the query satisfies a set of preconditions; replacing the subquery with a select operation that employs window aggregation; modifying the outer block to reference the select operation; adding to the select operation a reference to the object; and removing the reference to the object from the outer block.