select LEFT("timeline".id,7) AS "timeline_year_month", "products".productline AS "products_line", SUM("orderfact".quantityordered) AS "orderfact_quantityordered" from PUBLIC.orderfact "orderfact", PUBLIC.products "products", PUBLIC.timeline "timeline" where "orderfact".productcode="products".productcode AND "orderfact".time_id="timeline".id group by LEFT("timeline".id,7), "products".productline order by "timeline_year_month", "products_line", "orderfact_quantityordered"