subqueries by semi-join like techniquse 21 22 . Likewise thr problem of flattening queries containting views has been a queries is well understood. The problem is more complex when one or more of the views contain aggregation 23. Naturally, this problem is closely related to the problem of commuting group-by and join operators. However, commuting groip-by and join is applicable in the context of single block SQL queries as well 24 25 26 An overviews of the field appears in a recent paper27.