with cte_quartal as ( select employee_id, employee_id emp_id, last_name, to_char(hire_date, 'Q') quartal from hr.employees ) select * from cte_quartal pivot ( count(employee_id) for quartal in ( '1' q1, '2' q2, '3' q3, '4' q4) )