select LEFT("timeline".id,7) AS "timeline_year_month", COUNT(DISTINCT("orderfact".ordernumber)) AS "orderfact_ordernumber" from PUBLIC.orderfact "orderfact", PUBLIC.timeline "timeline" where "orderfact".time_id="timeline".id group by LEFT("timeline".id,7) order by "timeline_year_month", "orderfact_ordernumber"