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 é a pontuação de diversidade e a média de permanência para minas no Oriente Médio?
 ###Tabelas: 
CREATE TABLE production_data (id INT PRIMARY KEY, mine_id INT, year INT, monthly_production INT);CREATE TABLE reclamation_data (id INT PRIMARY KEY, mine_id INT, year INT, reclamation_cost INT);CREATE TABLE mine_employees (id INT PRIMARY KEY, mine_id INT, employee_id INT, employment_start_date DATE, employment_end_date DATE);CREATE TABLE employee_demographics (id INT PRIMARY KEY, employee_id INT, gender VARCHAR(255), ethnicity VARCHAR(255));CREATE VIEW employee_stats AS SELECT mine_id, AVG(DATEDIFF(employment_end_date, employment_start_date))/365 as avg_tenure FROM mine_employees GROUP BY mine_id;CREATE VIEW diversity_stats AS SELECT mine_id, AVG(CASE WHEN gender = 'Female' THEN 1.0 ELSE 0.0 END) + AVG(CASE WHEN ethnicity = 'Minority' THEN 1.0 ELSE 0.0 END) as diversity_score FROM employee_demographics GROUP BY mine_id;CREATE VIEW operation_duration AS SELECT mine_id, COUNT(DISTINCT year) as operation_years FROM production_data GROUP BY mine_id;
SELECT d.mine_id, d.diversity_score, e.avg_tenure FROM diversity_stats d JOIN employee_stats e ON d.mine_id = e.mine_id WHERE d.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5) AND e.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5);