Abaixo está uma instrução que descreve uma tarefa de geração de SQL, combinada com uma entrada que fornece mais contexto sobre os esquemas de tabela disponíveis. Escreva o código SQL que responda adequadamente à solicitação
 ###Instrução: Quantas consultas cada terapeuta tem, agrupadas por especialidade?
 ###Tabelas: 
CREATE TABLE therapists (id INT, name VARCHAR(50), specialty VARCHAR(50), years_of_experience INT); INSERT INTO therapists (id, name, specialty, years_of_experience) VALUES (1, 'Dr. Sarah Lee', 'CBT', 10); INSERT INTO therapists (id, name, specialty, years_of_experience) VALUES (2, 'Dr. Carlos Alvarez', 'Psychodynamic', 15); INSERT INTO therapists (id, name, specialty, years_of_experience) VALUES (3, 'Dr. Mei Chen', 'EMDR', 8); CREATE TABLE appointments (patient_id INT, therapist_id INT, appointment_date DATE, appointment_time TIME, appointment_duration INT); INSERT INTO appointments (patient_id, therapist_id, appointment_date, appointment_time, appointment_duration) VALUES (3, 1, '2023-02-15', '14:00:00', 60); INSERT INTO appointments (patient_id, therapist_id, appointment_date, appointment_time, appointment_duration) VALUES (4, 2, '2023-03-01', '09:30:00', 90); INSERT INTO appointments (patient_id, therapist_id, appointment_date, appointment_time, appointment_duration) VALUES (5, 3, '2023-01-20', '11:00:00', 60);
SELECT specialty, COUNT(*) as num_appointments FROM appointments JOIN therapists ON appointments.therapist_id = therapists.id GROUP BY specialty;