Tôi sẽ tạo CONCAT
theo cách này:
SELECT
e.name AS Employee,
CONCAT(
CEIL(DATEDIFF(h.date, e.startdate)/365),
' (',
DATE_ADD(e.startdate, INTERVAL FLOOR(DATEDIFF(h.date, e.startdate)/365) YEAR), ' to ',
DATE_ADD(e.startdate, INTERVAL CEIL(DATEDIFF(h.date, e.startdate)/365) YEAR),
')'
) as Year,
COUNT(h.date) AS Holidays_Taken,
SUM(h.hours) AS Hours
FROM employees AS e
LEFT JOIN holidays_taken AS h ON e.id = h.empid
WHERE e.id = 1
GROUP BY Year
DEMO: SQL FIDDLE