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: Qual é o número médio de médicos de atenção primária por hospital rural, ordenado por estado?
 ###Tabelas: 
CREATE TABLE primary_care_physicians (physician_id INT, physician_name VARCHAR, specialty VARCHAR, hospital_id INT, state VARCHAR); INSERT INTO primary_care_physicians (physician_id, physician_name, specialty, hospital_id, state) VALUES (1, 'Dr. Narayan', 'Family Medicine', 1, 'New York'); INSERT INTO primary_care_physicians (physician_id, physician_name, specialty, hospital_id, state) VALUES (2, 'Dr. Chen', 'General Practice', 2, 'Pennsylvania'); CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR, rural_county VARCHAR, state VARCHAR); INSERT INTO hospitals (hospital_id, hospital_name, rural_county, state) VALUES (1, 'Rural Hospital A', 'County X', 'New York'); INSERT INTO hospitals (hospital_id, hospital_name, rural_county, state) VALUES (2, 'Rural Hospital B', 'County Y', 'Pennsylvania');
SELECT hospitals.state, AVG(primary_care_physicians.physician_id) AS avg_physicians FROM primary_care_physicians JOIN hospitals ON primary_care_physicians.hospital_id = hospitals.hospital_id WHERE primary_care_physicians.specialty IN ('Family Medicine', 'General Practice') GROUP BY hospitals.state ORDER BY hospitals.state;