This is the final query where I am displaying tenant contracts that are expiring over the next 12 months, is there a better way of doing it or improving this query please?
SELECT DATE_FORMAT(sub.planner_start_date, '%M, %Y') as month_name, GROUP_CONCAT( DISTINCT COALESCE(CONCAT(t.customer_name)), '') as tenant_name
FROM
( SELECT
'2017-01-01' + INTERVAL seq.seq DAY AS planner_start_date
FROM
seq_0_to_999999 AS seq
WHERE
seq.seq <= TIMESTAMPDIFF(DAY, '2017-01-01', '2017-12-31')
) as sub
LEFT JOIN t_customers_contract AS cc ON DATE_FORMAT(cc.renewal_date, '%Y-%m') = DATE_FORMAT(sub.planner_st…