context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Sites (SiteID int, SiteName text, Location text, Era text); INSERT INTO Sites (SiteID, SiteName, Location, Era) VALUES (1, 'Pompeii', 'Italy', 'Roman'); CREATE TABLE Artifacts (ArtifactID int, ArtifactName text, SiteID int, Era text); INSERT INTO Artifacts (ArtifactID, ArtifactName, SiteID, Era) VALUES (1,...
Which excavation sites have produced Roman pottery?
SELECT Sites.SiteName FROM Sites INNER JOIN Artifacts ON Sites.SiteID = Artifacts.SiteID WHERE Artifacts.Era = 'Roman' AND Artifacts.ArtifactName = 'Roman Pottery';
gretelai_synthetic_text_to_sql
CREATE TABLE comprehensive_crops (id INT, crop_name VARCHAR(50), area_ha INT); INSERT INTO comprehensive_crops (id, crop_name, area_ha) VALUES (1, 'Corn', 600), (2, 'Soybeans', 550), (3, 'Rice', 450), (4, 'Wheat', 300);
What is the average area, in square kilometers, of farmland dedicated to 'Corn' and 'Soybeans' crops in the 'comprehensive_crops' table?
SELECT AVG(area_sq_km) as avg_area_sq_km FROM (SELECT area_sq_km FROM (SELECT crop_name, SUM(area_ha * 0.01) as area_sq_km FROM comprehensive_crops WHERE crop_name IN ('Corn', 'Soybeans') GROUP BY crop_name) as subquery) as sq_km_subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(255), publication_date DATE, author VARCHAR(255)); INSERT INTO articles (id, title, publication_date, author) VALUES (1, 'Article1', '2022-05-01', 'Journalist1'), (2, 'Article2', '2022-05-03', 'Journalist2'), (3, 'Article3', '2022-05-05', 'Journalist1'), (4, 'Article4', '202...
Who are the journalists with the most articles published in the last month?
SELECT author, COUNT(*) as articles_count FROM articles WHERE publication_date >= NOW() - INTERVAL 1 MONTH GROUP BY author;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Cream 1', 'beauty'), (2, 'Lipstick 1', 'beauty'); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); INSERT INTO users (user_id, user_country) VALUES ...
What was the total revenue from users in Vietnam and Thailand for the 'beauty' product category in Q2 2023?
SELECT SUM(revenue) FROM orders o JOIN products p ON o.product_id = p.product_id JOIN users u ON o.user_id = u.user_id WHERE u.user_country IN ('Vietnam', 'Thailand') AND p.category = 'beauty' AND o.order_date BETWEEN '2023-04-01' AND '2023-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE tv_studios (studio_id INT, studio_name TEXT, country TEXT); INSERT INTO tv_studios (studio_id, studio_name, country) VALUES (1, 'Studio D', 'India'), (2, 'Studio E', 'USA'), (3, 'Studio F', 'UK'); CREATE TABLE tv_shows (show_id INT, title TEXT, rating DECIMAL(2,1), studio_id INT); INSERT INTO tv_shows (sho...
What is the average rating of TV shows produced by companies based in India?
SELECT AVG(tv_shows.rating) FROM tv_shows JOIN tv_studios ON tv_shows.studio_id = tv_studios.studio_id WHERE tv_studios.country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE PublicParticipation (Department VARCHAR(255), Quarter INT, Participation INT, PRIMARY KEY (Department, Quarter)); INSERT INTO PublicParticipation (Department, Quarter, Participation) VALUES ('Interior', 1, 500); INSERT INTO PublicParticipation (Department, Quarter, Participation) VALUES ('Interior', 2, 550...
What is the percentage change in public participation for each department between Q1 and Q2 of 2022?
SELECT Department, Quarter, Participation, (Participation - LAG(Participation, 1) OVER (PARTITION BY Department ORDER BY Quarter))*100.0 / LAG(Participation, 1) OVER (PARTITION BY Department ORDER BY Quarter) as ParticipationPercentageChange FROM PublicParticipation;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (id INT, name TEXT, age INT, gender TEXT); INSERT INTO rural_clinics (id, name, age, gender) VALUES (1, 'Clinic A', 45, 'Male'), (2, 'Clinic B', 35, 'Female'), (3, 'Clinic C', 48, 'Male');
What is the ratio of male to female healthcare providers in the "rural_clinics" table?
SELECT ROUND(COUNT(CASE WHEN gender = 'Male' THEN 1 END)/COUNT(CASE WHEN gender = 'Female' THEN 1 END), 2) FROM rural_clinics;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, city VARCHAR(50), call_date DATE); INSERT INTO emergency_calls (id, city, call_date) VALUES (1, 'New York', '2020-01-01'); INSERT INTO emergency_calls (id, city, call_date) VALUES (2, 'New York', '2020-02-01');
List the number of emergency calls in the city of New York by month for the year 2020.
SELECT MONTH(call_date) AS month, COUNT(*) AS calls FROM emergency_calls WHERE city = 'New York' AND YEAR(call_date) = 2020 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance (visitor_id INT, exhibition_name VARCHAR(255), visit_date DATE); INSERT INTO attendance (visitor_id, exhibition_name, visit_date) VALUES (123, 'Abstraction', '2022-01-04'), (456, 'Abstraction', '2022-01-05'), (789, 'Abstraction', '2022-01-06'), (111, 'Abstraction', '2022-01-07'), (222, 'Abstract...
How many visitors attended the "Abstraction" exhibition on a weekday?
SELECT COUNT(*) AS weekday_visitors FROM attendance WHERE exhibition_name = 'Abstraction' AND EXTRACT(DAY FROM visit_date) BETWEEN 1 AND 5;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (transportation_id INT, transportation_type VARCHAR(20), city VARCHAR(50), country VARCHAR(50), year INT, num_vehicles INT);
How many autonomous buses were added to public transportation fleets in Tokyo in 2021?
SELECT SUM(num_vehicles) FROM public_transportation WHERE transportation_type = 'autonomous bus' AND city = 'Tokyo' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Threat_Intelligence (Threat_ID INT, Threat_Type VARCHAR(50), Threat_Level VARCHAR(50), Reported_Date DATE, Reporting_Agency VARCHAR(50)); CREATE VIEW High_Level_Threats AS SELECT Threat_Type, Threat_Level, Reported_Date FROM Threat_Intelligence WHERE Threat_Level = 'High';
How many high-level threats has each agency reported in the first half of 2022?
SELECT Reporting_Agency, COUNT(*) as Number_of_High_Level_Threats FROM High_Level_Threats WHERE Reported_Date >= '2022-01-01' AND Reported_Date < '2022-07-01' GROUP BY Reporting_Agency;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, title VARCHAR(50), medium VARCHAR(50)); CREATE TABLE Art_Periods (id INT, name VARCHAR(50), start_year INT, end_year INT);
What is the most common medium used in our modern and contemporary art exhibitions?
SELECT Exhibitions.medium, COUNT(Exhibitions.id) as exhibition_count FROM Exhibitions INNER JOIN Art_Periods ON Exhibitions.title = Art_Periods.name WHERE Art_Periods.name IN ('Modern Art', 'Contemporary Art') GROUP BY Exhibitions.medium ORDER BY exhibition_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE City_Transportation (City VARCHAR(20), Transportation VARCHAR(20), Users INT); INSERT INTO City_Transportation (City, Transportation, Users) VALUES ('CityD', 'Public Transportation', 100000); INSERT INTO City_Transportation (City, Transportation, Users) VALUES ('CityD', 'Vehicle Owners', 80000);
What is the number of public transportation users and vehicle owners in CityD?
SELECT City, SUM(CASE WHEN Transportation = 'Public Transportation' THEN Users ELSE 0 END) AS 'Public Transportation Users', SUM(CASE WHEN Transportation = 'Vehicle Owners' THEN Users ELSE 0 END) AS 'Vehicle Owners' FROM City_Transportation WHERE City = 'CityD' GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, severity VARCHAR(255), date_discovered DATE);
List all records from the 'vulnerabilities' table
SELECT * FROM vulnerabilities;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (incident_id INT, sector VARCHAR(50), incident_type VARCHAR(50), incident_date DATE, incident_cause VARCHAR(50)); INSERT INTO security_incidents (incident_id, sector, incident_type, incident_date, incident_cause) VALUES (1, 'Government', 'Data breach', '2022-01-01', 'Insider threat'), (2...
How many security incidents were caused by insider threats in the government sector in the last year?
SELECT sector, incident_type, COUNT(*) as count FROM security_incidents WHERE sector = 'Government' AND incident_cause = 'Insider threat' AND incident_date >= DATEADD(year, -1, GETDATE()) GROUP BY sector, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(50), flag_state VARCHAR(50)); INSERT INTO vessels (id, name, flag_state) VALUES (1, 'MV Apollo', 'India'), (2, 'MV Orion', 'India'), (3, 'MV Sirius', 'India'); CREATE TABLE transactions (id INT, vessel_id INT, port_id INT, timestamp TIMESTAMP); INSERT INTO transactions (id, ve...
List all cargo handling transactions and related vessel information for vessels from India.
SELECT t.id, v.name as vessel_name, t.port_id, t.timestamp FROM transactions t JOIN vessels v ON t.vessel_id = v.id WHERE v.flag_state = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(100), category VARCHAR(50), publication_date DATE, views INT); INSERT INTO articles (article_id, title, category, publication_date, views) VALUES (1, 'News from the Capital', 'Politics', '2022-01-01', 1500), (2, 'Tech Innovations in 2022', 'Technology', '2022-01-02',...
What is the average number of views per article in the "articles" table for each category?
SELECT category, AVG(views) as avg_views FROM articles GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, mobility_impairment BOOLEAN, department VARCHAR(255)); INSERT INTO students (id, mobility_impairment, department) VALUES (1, true, 'art'), (2, false, 'engineering'), (3, true, 'art'), (4, true, 'mathematics'), (5, false, 'art'), (6, true, 'art'); CREATE TABLE accommodations (id INT, stude...
What is the minimum number of accommodations provided to a single student with a mobility impairment in the art department?
SELECT MIN(accommodations) FROM (SELECT student_id, COUNT(*) as accommodations FROM accommodations GROUP BY student_id) as subquery WHERE student_id IN (SELECT id FROM students WHERE mobility_impairment = true AND department = 'art');
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), year_opened INT); INSERT INTO mines (id, name, location, type, year_opened) VALUES (1, 'San Xavier Mine', 'Peru', 'Gold', 1988); INSERT INTO mines (id, name, location, type, year_opened) VALUES (2, 'Cerro Verde Mine', '...
What is the average mining equipment cost for gold mines in Peru?
SELECT AVG(mining_equipment.cost) as avg_cost FROM mining_equipment JOIN mines ON mining_equipment.mine_id = mines.id WHERE mines.location = 'Peru' AND mines.type = 'Gold';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.investors (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), total_funding FLOAT);CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), funding FLOAT, investor_id INT, FOREIGN KEY (inves...
Who are the top 2 investors in biotech startups in France?
SELECT investors.name, SUM(startups.funding) FROM biotech.investors INNER JOIN biotech.startups ON investors.id = startups.investor_id WHERE investors.location = 'France' GROUP BY investors.name ORDER BY SUM(startups.funding) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE CityEnergy (City VARCHAR(50), EnergyCapacity FLOAT, SquareFootage FLOAT, Renewable BOOLEAN); INSERT INTO CityEnergy (City, EnergyCapacity, SquareFootage, Renewable) VALUES ('CityA', 5000, 20000, TRUE), ('CityB', 3000, 10000, FALSE);
Which city has the highest renewable energy capacity per square foot?
SELECT City, EnergyCapacity / SquareFootage AS EnergyCapacityPerSqft FROM CityEnergy WHERE Renewable = TRUE ORDER BY EnergyCapacityPerSqft DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clinicians (id INT PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(50), last_name VARCHAR(50)); INSERT INTO clinicians (first_name, last_name) VALUES ('John', 'Doe'), ('Jane', 'Smith');
Add a new clinician 'Bella' with the last name 'Williams' to the "clinicians" table
INSERT INTO clinicians (first_name, last_name) VALUES ('Bella', 'Williams');
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT PRIMARY KEY, name TEXT, status TEXT, total_spent DECIMAL(10,2));
Update player records with a 'VIP' status who have spent over $500
UPDATE players SET status = 'VIP' WHERE total_spent > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (id INT, organization TEXT, volunteer_hours INT); INSERT INTO volunteer_hours (id, organization, volunteer_hours) VALUES (1, 'Org A', 120), (2, 'Org B', 150), (3, 'Org C', 100), (4, 'Org D', 200), (5, 'Org E', 180), (6, 'Org F', 130);
What is the minimum number of volunteer hours for the top 5 organizations with the most volunteer hours?
SELECT organization, MIN(volunteer_hours) as min_hours FROM volunteer_hours GROUP BY organization ORDER BY min_hours DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('Mumbai', 2019, 0.55), ('Mumbai', 2020, 0.58), ('Mumbai', 2021, 0.62), ('Mumbai', 2022, 0.65);
What is the average recycling rate in Mumbai over the last 3 years?
SELECT AVG(recycling_rate) FROM recycling_rates WHERE city = 'Mumbai' AND year BETWEEN 2019 AND 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, environmental_impact INT); INSERT INTO mine (id, name, location, environmental_impact) VALUES (1, 'Golden Gorge', 'CA', 30), (2, 'Silver Ridge', 'NV', 20), (3, 'Bronze Basin', 'CO', 15);
Determine the environmental impact of each mine
SELECT name, environmental_impact FROM mine;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration_2 (id INT, continent VARCHAR(255), site_name VARCHAR(255), area FLOAT, establishment_year INT); INSERT INTO carbon_sequestration_2 (id, continent, site_name, area, establishment_year) VALUES (1, 'North America', 'Site E', 30000.0, 2000), (2, 'North America', 'Site F', 40000.0, 2001), (...
What is the average area of carbon sequestration sites, in hectares, for each continent, broken down by year of establishment?
SELECT continent, establishment_year, AVG(area) FROM carbon_sequestration_2 GROUP BY continent, establishment_year;
gretelai_synthetic_text_to_sql
CREATE TABLE ny_renewable_projects (project_id INT, project_name VARCHAR(255), installed_capacity FLOAT, completion_date DATE);
What is the total installed capacity (in MW) of renewable energy projects in the state of New York for the year 2020?
SELECT SUM(installed_capacity) FROM ny_renewable_projects WHERE YEAR(completion_date) = 2020 AND state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentMaintenance (id INT, EquipmentType VARCHAR(50), EventDate DATE); INSERT INTO EquipmentMaintenance (id, EquipmentType, EventDate) VALUES (1, 'Tank', '2020-01-01'), (2, 'Helicopter', '2020-01-15'), (3, 'Tank', '2020-03-01'), (4, 'Helicopter', '2020-04-01');
What is the average time between maintenance events for military equipment, per equipment type?
SELECT EquipmentType, AVG(DATEDIFF(EventDate, LAG(EventDate) OVER (PARTITION BY EquipmentType ORDER BY EventDate))) as AverageTimeBetweenEvents FROM EquipmentMaintenance GROUP BY EquipmentType;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes_count (country_name VARCHAR(100), total_athletes INT); INSERT INTO athletes_count VALUES ('USA', 554), ('China', 419), ('Russia', 282), ('Great Britain', 368), ('Germany', 405);
What are the top 3 countries with the most athletes participating in the Olympics?
SELECT country_name, total_athletes FROM athletes_count ORDER BY total_athletes DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Warehouse A', 'EMEA'), (2, 'Warehouse B', 'APAC');
Calculate the average weight of packages shipped from warehouses in the 'APAC' and 'EMEA' regions
SELECT AVG(weight) FROM packages JOIN warehouses ON packages.warehouse_id = warehouses.id WHERE region IN ('APAC', 'EMEA');
gretelai_synthetic_text_to_sql
CREATE TABLE HomeInsurance (PolicyholderName VARCHAR(50), PolicyType VARCHAR(50)); CREATE TABLE AutoInsurance (PolicyHolderName VARCHAR(50), PolicyType VARCHAR(50)); INSERT INTO HomeInsurance VALUES ('Alice', 'Home'), ('Bob', 'Home'), ('Charlie', 'Home'); INSERT INTO AutoInsurance VALUES ('Bob', 'Auto'), ('David', 'Aut...
What are the names and policy types of policyholders who have both home and auto insurance?
SELECT HomeInsurance.PolicyholderName, HomeInsurance.PolicyType FROM HomeInsurance JOIN AutoInsurance ON HomeInsurance.PolicyholderName = AutoInsurance.PolicyHolderName WHERE HomeInsurance.PolicyType = 'Home' AND AutoInsurance.PolicyType = 'Auto';
gretelai_synthetic_text_to_sql
CREATE TABLE game_scores (user_id INT, game_name VARCHAR(10), score INT); INSERT INTO game_scores (user_id, game_name, score) VALUES (11, 'C', 50), (11, 'C', 75), (11, 'D', 100), (12, 'A', 150), (13, 'B', 200), (13, 'C', 250);
Identify the minimum score achieved by user 11 in game 'C'
SELECT MIN(score) FROM game_scores WHERE user_id = 11 AND game_name = 'C';
gretelai_synthetic_text_to_sql
CREATE TABLE production_costs (product_id INT, is_ethically_produced BOOLEAN, cost DECIMAL(5,2)); INSERT INTO production_costs (product_id, is_ethically_produced, cost) VALUES (1, true, 15.00), (2, false, 10.00), (3, true, 20.00);
What is the average cost of production for ethically produced products?
SELECT AVG(cost) FROM production_costs WHERE is_ethically_produced = true;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists wind_farms (farm_id integer, farm_name varchar(255), farm_location varchar(255), capacity_mw integer); INSERT INTO wind_farms (farm_id, farm_name, farm_location, capacity_mw) VALUES (1, 'Farm A', 'Canada', 200), (2, 'Farm B', 'Canada', 250), (3, 'Farm C', 'Canada', 150), (4, 'Farm D', 'Canada...
What is the maximum installed capacity (in MW) of wind farms in Canada and which farm has the highest capacity?
SELECT farm_location, MAX(capacity_mw) as max_capacity FROM wind_farms WHERE farm_location LIKE 'Canada%' GROUP BY farm_location;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists defense; CREATE TABLE if not exists eu_humanitarian_assistance (id INT PRIMARY KEY, country VARCHAR(50), year INT, spending INT); INSERT INTO eu_humanitarian_assistance (id, country, year, spending) VALUES (1, 'Germany', 2019, 1000), (2, 'Germany', 2020, 1200), (3, 'Germany', 2021, 1500), (4...
What is the total spending on humanitarian assistance by EU countries in the last 3 years?
SELECT SUM(spending) FROM defense.eu_humanitarian_assistance WHERE country IN ('Germany', 'France') AND year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT, program VARCHAR(50), location VARCHAR(50), date DATE);
Count the number of occurrences of 'community outreach' programs in 'community_education' table
SELECT COUNT(*) FROM community_education WHERE program = 'community outreach';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID int, EmployeeName varchar(50), Department varchar(50), TrainingProgram varchar(50), TrainingDate date, Country varchar(50)); INSERT INTO EmployeeTraining (EmployeeID, EmployeeName, Department, TrainingProgram, TrainingDate, Country) VALUES (1, 'Fatima Ahmed', 'IT', 'Diversity a...
How many diversity and inclusion training programs were completed by employees in each country in the past year?
SELECT Country, COUNT(*) AS num_diversity_trainings FROM EmployeeTraining WHERE TrainingProgram = 'Diversity and Inclusion' AND TrainingDate >= DATEADD(year, -1, GETDATE()) GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Productivity (mineral TEXT, region TEXT, productivity REAL); INSERT INTO Labor_Productivity (mineral, region, productivity) VALUES ('Gold', 'South America', 2.8); INSERT INTO Labor_Productivity (mineral, region, productivity) VALUES ('Silver', 'South America', 3.1); INSERT INTO Labor_Productivity (mi...
Update the labor productivity of the 'Coal' extraction in the 'South America' region to 3.5.
UPDATE Labor_Productivity SET productivity = 3.5 WHERE mineral = 'Coal' AND region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE members (member_id INT, age INT); CREATE TABLE workouts (workout_id INT, member_id INT, date DATE); INSERT INTO members VALUES (1,25),(2,30),(3,22); INSERT INTO workouts VALUES (1,1,'2022-01-01'),(2,1,'2022-01-02'),(3,2,'2022-01-03'),(4,3,'2022-01-04');
What is the earliest date a member started a workout?
SELECT MIN(date) FROM workouts JOIN members ON workouts.member_id = members.member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer (vol_id INT, vol_name TEXT, org_id INT, vol_email TEXT); INSERT INTO volunteer (vol_id, vol_name, org_id, vol_email) VALUES (1, 'Alice', 1, 'alice@example.com'); INSERT INTO volunteer (vol_id, vol_name, org_id, vol_email) VALUES (2, 'Bob', 1, NULL); INSERT INTO volunteer (vol_id, vol_name, org_id...
Delete all volunteers who have not provided their email address
DELETE FROM volunteer WHERE vol_email IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE PORT_TOTALS (ID INT, PORT_ID INT, TOTAL_CARGO_WEIGHT INT); INSERT INTO PORT_TOTALS VALUES (1, 1, 10000000); INSERT INTO PORT_TOTALS VALUES (2, 2, 7000000);
Present the number of vessels and total cargo weight for each port, ranked in descending order by total cargo weight.
SELECT P.NAME AS PORT, COUNT(DISTINCT V.ID) AS NUM_VESSELS, SUM(PT.TOTAL_CARGO_WEIGHT) AS TOTAL_WEIGHT, RANK() OVER(ORDER BY SUM(PT.TOTAL_CARGO_WEIGHT) DESC) AS RANK FROM PORT_TOTALS PT JOIN PORTS P ON PT.PORT_ID = P.ID JOIN PORT_CALLS PC ON PT.PORT_ID = PC.PORT_ID JOIN VESSELS V ON PC.VESSEL_ID = V.ID GROUP BY P.ID, P...
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, name VARCHAR(255), country VARCHAR(255), salary DECIMAL(5,2)); INSERT INTO employees (employee_id, name, country, salary) VALUES (1, 'John Doe', 'USA', 50000.00), (2, 'Jane Smith', 'Canada', 45000.00), (3, 'Maria Garcia', 'Mexico', 20000.00);
What is the average salary for employees in each country?
SELECT country, AVG(salary) as avg_salary FROM employees GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE FoodSafetyRecords (record_id INT, product_id INT, updated_at TIMESTAMP); INSERT INTO FoodSafetyRecords (record_id, product_id, updated_at) VALUES (1, 1, '2022-01-01 12:00:00'), (2, 2, '2022-01-15 14:00:00'), (3, 3, '2022-02-01 09:00:00');
Which food safety records have been updated in the last 30 days?
SELECT * FROM FoodSafetyRecords WHERE updated_at >= NOW() - INTERVAL '30 days';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT PRIMARY KEY, volunteer_name TEXT); INSERT INTO volunteers (volunteer_id, volunteer_name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');
Update volunteer name
WITH new_name AS (UPDATE volunteers SET volunteer_name = 'Carl' WHERE volunteer_id = 3 RETURNING volunteer_id) SELECT * FROM new_name;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (clinic_id, state) VALUES (1, 'New Mexico'), (2, 'New Mexico'), (3, 'New Mexico'); CREATE TABLE pediatric_care (patient_id INT, clinic_id INT, age INT); INSERT INTO pediatric_care (patient_id, clinic_id, age) VALUES (101, 1, 5), (10...
What is the average age of patients who received pediatric care in rural clinics located in New Mexico?
SELECT AVG(age) FROM pediatric_care d JOIN rural_clinics r ON d.clinic_id = r.clinic_id WHERE r.state = 'New Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_atlantic (name VARCHAR(255), basin VARCHAR(255)); INSERT INTO marine_species_atlantic (name, basin) VALUES ('Species1', 'Atlantic'), ('Species2', 'Pacific'), ('Species3', 'Indian'), ('Species4', 'Atlantic');
How many marine species are found in the Atlantic basin, grouped by species name?
SELECT name, COUNT(*) as num_species FROM marine_species_atlantic WHERE basin = 'Atlantic' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_sanctuaries (sanctuary_id INT, sanctuary_name VARCHAR(50));CREATE TABLE animal_population (population_id INT, animal_id INT, species_id INT, sanctuary_id INT); INSERT INTO wildlife_sanctuaries (sanctuary_id, sanctuary_name) VALUES (1, 'Sanctuary A'), (2, 'Sanctuary B'), (3, 'Sanctuary C'); INSERT ...
What is the maximum number of animals of each species in the wildlife sanctuary?
SELECT s.species_name, MAX(COUNT(ap.animal_id)) AS max_animals FROM animal_population ap JOIN wildlife_sanctuaries ws ON ap.sanctuary_id = ws.sanctuary_id JOIN animal_species s ON ap.species_id = s.species_id GROUP BY s.species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE DonationAmounts (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO DonationAmounts VALUES (1, 1, '2021-04-05', 1500.00), (2, 1, '2021-08-20', 1500.00), (3, 2, '2021-04-12', 1000.00), (4, 3, '2021-08-01', 2000.00), (5, 1, '2021-03-15', 500.00), (6, 1, '2021-09-01', 7...
What is the moving average of donation amounts for each donor, over the last three donations?
SELECT DonorID, DonationDate, DonationAmount, AVG(DonationAmount) OVER (PARTITION BY DonorID ORDER BY DonationDate ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS MovingAvg FROM DonationAmounts;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (year INT, country VARCHAR(255), element_type VARCHAR(255), production_quantity INT);
Insert a new production record for Europium in France in 2023 with 150 tonnes.
INSERT INTO production_data (year, country, element_type, production_quantity) VALUES (2023, 'France', 'Europium', 150);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_model_creators (creator_id INT, creator_name VARCHAR(255), description TEXT);CREATE TABLE explainable_ai_models (model_id INT, model_name VARCHAR(255), creator_id INT);
Who are the top 3 creators of AI models that prioritize explainability and what are their corresponding model names?
SELECT amc.creator_name, eam.model_name FROM ai_model_creators amc INNER JOIN explainable_ai_models eam ON amc.creator_id = eam.creator_id GROUP BY amc.creator_id ORDER BY COUNT(eam.model_id) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE music_platform (id INT, song_title VARCHAR(100), genre VARCHAR(50), length FLOAT, country VARCHAR(50));
What is the average length of songs in the rock genre on the music streaming platform in Canada?
SELECT AVG(length) as avg_length FROM music_platform WHERE genre = 'rock' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicCottonCost (id INT, garment_type VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO OrganicCottonCost (id, garment_type, cost) VALUES (1, 'T-Shirt', 15.50), (2, 'Pants', 30.75), (3, 'Dress', 45.99);
What is the average production cost of garments made from organic cotton per garment type?
SELECT garment_type, AVG(cost) FROM OrganicCottonCost GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (veteran_id INT, job_title VARCHAR(30), hire_date DATE, salary FLOAT);
Add a new view 'veteran_employment_summary' that displays the 'job_title' and average salary for each job title from the 'veteran_employment' table
CREATE VIEW veteran_employment_summary AS SELECT job_title, AVG(salary) FROM veteran_employment GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE platform_daily_production (platform VARCHAR(255), oil_production FLOAT, gas_production FLOAT, date DATE);
Show all platforms in the Beaufort Sea with production figures over 5000 bbl/day.
SELECT platform FROM platform_daily_production WHERE platform IN (SELECT platform FROM beaufort_sea_platforms) AND oil_production > 5000 GROUP BY platform;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (id INT, name VARCHAR(50), sustainable_purchase_date DATE); INSERT INTO Customers (id, name, sustainable_purchase_date) VALUES (1, 'Alice', '2022-01-01'), (2, 'Bob', '2022-02-15'), (3, 'Charlie', '2022-03-05'), (4, 'David', '2022-04-10'), (5, 'Eve', '2022-05-25'), (6, 'Frank', '2022-06-12');
How many unique customers have made sustainable clothing purchases?
SELECT COUNT(DISTINCT id) FROM Customers WHERE EXISTS (SELECT 1 FROM Sales WHERE Customers.id = Sales.customer_id AND material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo'));
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, start_date DATE, end_date DATE);
Update records in the economic_diversification table with id 4 to have a start_date of 2022-01-01
WITH cte AS (UPDATE economic_diversification SET start_date = '2022-01-01' WHERE id = 4) SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, production INT, environmental_impact INT); INSERT INTO mines (id, name, production, environmental_impact) VALUES (1, 'Golden Mine', 1000, 20), (2, 'Silver Mine', 500, 15), (3, 'Bronze Mine', 300, 10), (4, 'Platinum Mine', 800, 30);
What is the environmental impact score of the mine with the highest production?
SELECT environmental_impact FROM mines ORDER BY production DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'HR'), (2, 'IT'), (3, 'Marketing');
What is the total number of employees by department?
SELECT SUM(id) FROM departments;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, donation_date DATE); INSERT INTO donors (id, donation_date) VALUES (1, '2022-01-15'), (2, '2022-02-10'), (3, '2022-02-25'), (4, '2022-03-05');
Show the number of new donors per month in 2022.
SELECT DATE_FORMAT(donation_date, '%Y-%m') as month, COUNT(DISTINCT id) as new_donors FROM donors WHERE YEAR(donation_date) = 2022 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE IngredientSources (ProductID INT, Ingredient VARCHAR(50), SourceCountry VARCHAR(50), PRIMARY KEY (ProductID, Ingredient)); INSERT INTO IngredientSources (ProductID, Ingredient, SourceCountry) VALUES (1, 'Water', 'Canada'), (1, 'Glycerin', 'USA'), (2, 'Water', 'Mexico'), (2, 'Glycerin', 'Canada'); CREATE TA...
Which products have passing safety inspections and use ingredients sourced from the USA and Mexico?
SELECT ProductID FROM IngredientSources WHERE SourceCountry IN ('USA', 'Mexico') GROUP BY ProductID HAVING COUNT(DISTINCT SourceCountry) = 2 INTERSECT SELECT ProductID FROM ProductSafetyRecords WHERE Result = 'Pass';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, name VARCHAR(50), location VARCHAR(50), installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id, name, location, installed_capacity) VALUES (1, 'Project 1', 'Location A', 100.5), (2, 'Project 2', 'Location B', 150.2), (3, 'Project 3', 'Location C', 200.0);
What is the maximum installed capacity for a single renewable energy project in the 'renewable_energy' schema?
SELECT MAX(installed_capacity) FROM renewable_energy_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, site_name VARCHAR(50), location VARCHAR(50), num_artifacts INT, total_funding DECIMAL(10,2));
What was the maximum total funding for excavation sites in Africa?
SELECT MAX(total_funding) as max_funding FROM excavation_sites WHERE location LIKE 'Africa%'
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure (id INT, name VARCHAR(255), type VARCHAR(255), region VARCHAR(255)); INSERT INTO infrastructure (id, name, type, region) VALUES (1, 'Bridge1', 'Bridge', 'Texas'), (2, 'Road1', 'Road', 'Texas'), (3, 'Bridge2', 'Bridge', 'California');
Report the number of bridges and roads in the 'Texas' region
SELECT COUNT(CASE WHEN infrastructure.type = 'Bridge' THEN 1 END), COUNT(CASE WHEN infrastructure.type = 'Road' THEN 1 END) FROM infrastructure WHERE infrastructure.region = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (id INT, model VARCHAR(50), manufacturer VARCHAR(50), production_year INT, records VARCHAR(50));
Delete all records related to the XYZ aircraft model
DELETE FROM aircraft WHERE model = 'XYZ';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (report_id INT, report_date DATE, report_type TEXT); INSERT INTO threat_intelligence (report_id, report_date, report_type) VALUES (1, '2021-01-01', 'Cyber'), (2, '2021-02-01', 'Terrorism');
How many threat intelligence reports were generated each month in 2021?
SELECT DATEPART(YEAR, report_date) as Year, DATEPART(MONTH, report_date) as Month, COUNT(*) as Number_of_Reports FROM threat_intelligence WHERE report_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY DATEPART(YEAR, report_date), DATEPART(MONTH, report_date);
gretelai_synthetic_text_to_sql
CREATE TABLE organization (id INT, name VARCHAR(255)); CREATE TABLE volunteer (id INT, name VARCHAR(255), organization_id INT, volunteer_date DATE);
Which organizations have the most repeat volunteers?
SELECT o.name, COUNT(DISTINCT v.id) as num_volunteers FROM volunteer v JOIN organization o ON v.organization_id = o.id JOIN (SELECT volunteer_id, COUNT(*) as num_volunteers FROM volunteer GROUP BY volunteer_id HAVING COUNT(*) > 1) sub ON v.id = sub.volunteer_id GROUP BY o.id;
gretelai_synthetic_text_to_sql
CREATE TABLE labels (id INT, product VARCHAR(255), is_fragrance_free BOOLEAN, is_vegan BOOLEAN); INSERT INTO labels (id, product, is_fragrance_free, is_vegan) VALUES (1, 'Lotion', true, true), (2, 'Shampoo', false, false), (3, 'Conditioner', true, true), (4, 'Body Wash', false, false), (5, 'Deodorant', true, false);
Determine the number of products with fragrance-free and vegan labels.
SELECT COUNT(*) FROM labels WHERE is_fragrance_free = true AND is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (id INT, location TEXT, energy_consumption INT);INSERT INTO MiningOperations (id, location, energy_consumption) VALUES (1, 'Australia', 12000), (2, 'Brazil', 15000), (3, 'South Africa', 18000);
What is the total amount of energy consumed by the mining operations in the 'MiningOperations' table?
SELECT SUM(energy_consumption) FROM MiningOperations;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission VARCHAR(20), country VARCHAR(20));INSERT INTO space_missions (id, mission, country) VALUES (1, 'Mars-1', 'USA'), (2, 'Moon-1', 'China'), (3, 'Asteroid-1', 'USA'), (4, 'Mars-2', 'India');
How many space missions have been recorded for each country?
SELECT country, COUNT(mission) FROM space_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Cosmic_Conquerors (player_id INT, player_name VARCHAR(50), score INT); INSERT INTO Cosmic_Conquerors (player_id, player_name, score) VALUES (1, 'David Lee', 1500), (2, 'Diana Chen', 1700), (3, 'Ella White', 1200);
What is the maximum score achieved by players named 'David' or 'Diana' in the game 'Cosmic Conquerors'?
SELECT MAX(score) FROM Cosmic_Conquerors WHERE player_name IN ('David', 'Diana');
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_biodiversity (species_id INT, species_name VARCHAR(255), population INT, region VARCHAR(255)); CREATE TABLE iucn_redlist (species_id INT, conservation_status VARCHAR(255));
List the species in the 'arctic_biodiversity' table and their conservation status from the 'iucn_redlist' table, if available.
SELECT a.species_name, r.conservation_status FROM arctic_biodiversity a LEFT JOIN iucn_redlist r ON a.species_id = r.species_id;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(255), year INT, plastic_rate FLOAT); INSERT INTO recycling_rates (country, year, plastic_rate) VALUES ('Germany', 2020, 0.6), ('Austria', 2020, 0.7), ('Switzerland', 2020, 0.8);
What is the recycling rate for plastic in the top 3 recycling countries in 2020?
SELECT r.country, r.plastic_rate as recycling_rate FROM recycling_rates r ORDER BY r.plastic_rate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Development_Fund(farmer_id INT, farmer_name VARCHAR(50), country VARCHAR(50)); INSERT INTO Rural_Development_Fund(farmer_id, farmer_name, country) VALUES (1, 'John Doe', 'China'), (2, 'Jane Smith', 'India');
What is the total number of farmers who received support from the 'Rural Development Fund' in 'Asia'?
SELECT COUNT(*) FROM Rural_Development_Fund WHERE country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE FashionTrends (TrendID INT, TrendName TEXT, Popularity INT, ProductionVolume INT, CO2Emission INT); INSERT INTO FashionTrends (TrendID, TrendName, Popularity, ProductionVolume, CO2Emission) VALUES (1, 'Athleisure', 8000, 7000, 300), (2, 'Denim', 9000, 6000, 250), (3, 'Boho-Chic', 7000, 5000, 200), (4, 'Min...
What is the total CO2 emission for each fashion trend that is popular in Spain and has a production volume greater than 6000?
SELECT FT.TrendName, SUM(FT.CO2Emission) FROM FashionTrends FT INNER JOIN ProductionVolume PV ON FT.TrendID = PV.TrendID WHERE FT.Popularity > 8000 AND PV.ProductionVolume > 6000 GROUP BY FT.TrendName;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, hotel_name VARCHAR(50), region VARCHAR(50), revenue INT);
What is the total revenue generated by the hotels table for each region?
SELECT region, SUM(revenue) FROM hotels GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableProjects (id INT, name VARCHAR(50), type VARCHAR(20), state CHAR(2));CREATE VIEW Funding AS SELECT project_id, amount FROM FundingDetails;
List all renewable energy projects and their corresponding funding amounts from the RenewableProjects and Funding table
SELECT rp.name, rp.type, f.amount FROM RenewableProjects rp INNER JOIN Funding f ON rp.id = f.project_id;
gretelai_synthetic_text_to_sql
CREATE VIEW Count_By_Type AS SELECT project_id, project_name, project_type FROM Water_Infrastructure WHERE year >= 2015; CREATE TABLE Project_Types (project_type VARCHAR(255), type_description VARCHAR(255));
Find the number of projects of each type in the Count_By_Type view
SELECT project_type, COUNT(*) FROM Count_By_Type JOIN Project_Types ON Count_By_Type.project_type = Project_Types.project_type GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT PRIMARY KEY, country_name VARCHAR(50)); INSERT INTO countries (country_id, country_name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Australia'), (4, 'Brazil'); CREATE TABLE cruelty_free_certified (product_id INT, country_id INT, FOREIGN KEY (country_id) REFERENCES countries(country_id...
Which countries do not have any cruelty-free certified products?
SELECT country_name FROM countries WHERE country_id NOT IN (SELECT country_id FROM cruelty_free_certified);
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour (id INT PRIMARY KEY, name VARCHAR(255), language VARCHAR(255), focus VARCHAR(255), user_rating DECIMAL(3,2)); INSERT INTO virtual_tour (id, name, language, focus, user_rating) VALUES (1, 'Tour of the Alhambra', 'Spanish', 'Cultural Heritage', 4.5);
List the virtual tours that are available in Spanish and have a cultural heritage focus, along with their average user rating.
SELECT vt.name, vt.language, vt.focus, AVG(vt.user_rating) as avg_rating FROM virtual_tour vt WHERE vt.language = 'Spanish' AND vt.focus = 'Cultural Heritage' GROUP BY vt.name, vt.language, vt.focus;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (id INT, project VARCHAR(255), location VARCHAR(255), reduction_percentage DECIMAL(5,2), start_year INT, end_year INT);
What is the average CO2 emission reduction achieved by climate mitigation projects in Australia?
SELECT AVG(reduction_percentage) FROM climate_mitigation_projects WHERE location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE drivers (driver_id INT, driver_name VARCHAR(255)); CREATE TABLE trips (trip_id INT, driver_id INT, route_id INT, fare_amount DECIMAL(5,2), trip_date DATE);
What is the average fare per trip for each driver in the past month?
SELECT d.driver_name, AVG(t.fare_amount/COUNT(t.trip_id)) as avg_fare_per_trip FROM drivers d INNER JOIN trips t ON d.driver_id = t.driver_id WHERE t.trip_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY d.driver_name;
gretelai_synthetic_text_to_sql
CREATE TABLE stations_with_species (station_id INT); INSERT INTO stations_with_species (station_id) VALUES (1), (2), (3);
Identify marine research stations without any marine species
SELECT r.station_name FROM research_stations r WHERE r.station_id NOT IN (SELECT s.station_id FROM species_per_region s);
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, country VARCHAR(255), year INT); INSERT INTO patients (id, country, year) VALUES (1, 'Brazil', 2021), (2, 'Argentina', 2022), (3, 'Colombia', 2021); CREATE TABLE therapy (patient_id INT, therapy_type VARCHAR(255)); INSERT INTO therapy (patient_id, therapy_type) VALUES (1, 'Psychotherapy')...
How many patients in Latin America received psychotherapy in 2021?
SELECT country as region, COUNT(*) as patient_count FROM patients JOIN therapy ON patients.id = therapy.patient_id WHERE therapy_type = 'Psychotherapy' AND year = 2021 AND country IN (SELECT country FROM patients WHERE country LIKE 'Latin%');
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, usage FLOAT, purpose VARCHAR(20), date DATE); INSERT INTO water_usage (id, usage, purpose, date) VALUES (1, 300, 'agricultural', '2021-04-01'); INSERT INTO water_usage (id, usage, purpose, date) VALUES (2, 320, 'agricultural', '2021-04-08');
Find the minimum weekly water usage for 'agricultural' purposes in 'Q2 2021' from the 'water_usage' table
SELECT MIN(usage) FROM (SELECT usage FROM water_usage WHERE purpose = 'agricultural' AND date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY WEEK(date)) as weekly_usage;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (lending_id INT, lending_date DATE, lending_amount INT, institution_type TEXT); CREATE TABLE microfinance_institutions (institution_id INT, lending_id INT);
What is the total amount of socially responsible lending provided to microfinance institutions in the last year?
SELECT SUM(srl.lending_amount) FROM socially_responsible_lending srl JOIN microfinance_institutions mfi ON srl.lending_id = mfi.lending_id WHERE srl.lending_date >= DATEADD(year, -1, CURRENT_DATE());
gretelai_synthetic_text_to_sql
CREATE TABLE machine_maintenance_new (id INT PRIMARY KEY, machine_name VARCHAR(50), last_maintenance_date DATE); CREATE TABLE machine_usage_new (id INT PRIMARY KEY, machine_name VARCHAR(50), usage_hours INT);
List all the machines that have not been maintained in the last 60 days and their usage hours.
SELECT m.machine_name, u.usage_hours FROM machine_maintenance_new m RIGHT JOIN machine_usage_new u ON m.machine_name = u.machine_name WHERE m.last_maintenance_date < CURDATE() - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS utilities; CREATE TABLE utilities.projects (id INT, name VARCHAR(100), completed_date DATE); INSERT INTO utilities.projects (id, name, completed_date) VALUES (1, 'Power Line Replacement', '2019-06-30'), (2, 'Substation Expansion', '2021-05-15'), (3, 'Sewer System Upgrade', '2018-12-20');
Count the number of projects in the 'utilities' schema that were completed before 2020-01-01
SELECT COUNT(*) FROM utilities.projects WHERE completed_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (organization_id INT, organization_name VARCHAR(255)); CREATE TABLE initiatives (initiative_id INT, organization_id INT, initiative_type VARCHAR(255), start_date DATE);
What is the number of criminal justice reform initiatives implemented by each organization by year?
SELECT organization_name, YEAR(start_date) as year, COUNT(*) as total_initiatives FROM initiatives JOIN organizations ON initiatives.organization_id = organizations.organization_id WHERE initiative_type = 'Criminal Justice Reform' GROUP BY organization_name, year;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, country VARCHAR(255)); CREATE TABLE treatments (id INT, patient_id INT, type VARCHAR(255), start_date DATE); CREATE TABLE outcomes (id INT, patient_id INT, treatment_id INT, improvement BOOLEAN, follow_up_date DATE); INSERT INTO patients (id, country) VALUES (1, 'USA'), (2, 'USA'), (3, 'U...
What percentage of patients in the USA showed improvement after 3 months of cognitive behavioral therapy?
SELECT 100.0 * COUNT(DISTINCT CASE WHEN outcomes.follow_up_date < treatments.start_date + INTERVAL '3 month' AND outcomes.improvement THEN patients.id END) / COUNT(DISTINCT patients.id) AS percentage FROM patients JOIN treatments ON patients.id = treatments.patient_id JOIN outcomes ON treatments.id = outcomes.treatment...
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_relief_missions (mission_id INT, mission_name VARCHAR(255), organization_id INT); INSERT INTO disaster_relief_missions (mission_id, mission_name, organization_id) VALUES (1, 'Mission A', 1), (2, 'Mission B', 2), (3, 'Mission C', 3), (4, 'Mission D', 1), (5, 'Mission E', 2), (6, 'Mission F', 3); CR...
What is the number of disaster relief missions carried out by each organization, sorted by the number of missions in descending order?
SELECT organization_id, COUNT(mission_id) as num_of_missions FROM disaster_relief_missions INNER JOIN organizations ON disaster_relief_missions.organization_id = organizations.organization_id GROUP BY organization_id ORDER BY num_of_missions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists employment (id INT, industry VARCHAR, number_of_employees INT); INSERT INTO employment (id, industry, number_of_employees) VALUES (1, 'manufacturing', 5000), (2, 'technology', 8000), (3, 'healthcare', 7000), (4, 'retail', 6000), (5, 'education', 9000), (6, 'finance', 10000), (7, 'government',...
What is the number of employees in the 'government' industry?
SELECT SUM(number_of_employees) FROM employment WHERE industry = 'government';
gretelai_synthetic_text_to_sql
CREATE TABLE species_research (id INT, species_id INT, year INT, location VARCHAR(50), observations INT); INSERT INTO species_research (id, species_id, year, location, observations) VALUES (1, 1, 2015, 'Arctic', 350), (2, 1, 2016, 'Antarctic', 400), (3, 2, 2016, 'Arctic', 500); CREATE TABLE species (id INT, name VARCHA...
What species were studied in 2015 and 2016?
SELECT s.name FROM species_research r JOIN species s ON r.species_id = s.id WHERE r.year IN (2015, 2016);
gretelai_synthetic_text_to_sql
CREATE TABLE customer_complaints_data (complaint_id INT, complaint_type VARCHAR(20), complaint_date DATE); INSERT INTO customer_complaints_data (complaint_id, complaint_type, complaint_date) VALUES (1, 'Billing', '2022-01-01'), (2, 'Service', '2022-02-01'), (3, 'Billing', '2022-03-01');
What is the total number of customer complaints by issue type and month?
SELECT DATE_FORMAT(complaint_date, '%Y-%m') AS month, complaint_type, COUNT(*) AS complaint_count FROM customer_complaints_data GROUP BY month, complaint_type;
gretelai_synthetic_text_to_sql
CREATE TABLE AlgoFairness_Table1 (algorithm_id INT, metric VARCHAR(50), value FLOAT); INSERT INTO AlgoFairness_Table1 (algorithm_id, metric, value) VALUES (1, 'Fairness', 0.9); INSERT INTO AlgoFairness_Table1 (algorithm_id, metric, value) VALUES (2, 'Fairness', 0.85); INSERT INTO AlgoFairness_Table1 (algorithm_id, metr...
What is the maximum fairness score for each algorithm in the 'AlgoFairness_Table1' table?
SELECT algorithm_id, MAX(value) as max_fairness FROM AlgoFairness_Table1 WHERE metric = 'Fairness' GROUP BY algorithm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE calls(id INT, subscriber_id INT, type VARCHAR(50), duration INT, roaming_charge FLOAT, date DATE);
What is the total revenue generated from roaming charges for the Latin America region in the last quarter?
SELECT SUM(roaming_charge) FROM calls WHERE type = 'roaming' AND date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND EXTRACT(REGION FROM date) = 'America/Latin';
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (id INT, name VARCHAR(50), restaurant_id INT, price DECIMAL(5,2), category VARCHAR(20)); INSERT INTO MenuItems (id, name, restaurant_id, price, category) VALUES (1, 'Cheeseburger', 1, 7.99, 'Main'); INSERT INTO MenuItems (id, name, restaurant_id, price, category) VALUES (2, 'Fries', 1, 2.99, 'Sid...
How many menu items are there in each category?
SELECT category, COUNT(*) FROM MenuItems GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50), event VARCHAR(50)); INSERT INTO athletes (id, name, age, sport, event) VALUES (1, 'John Doe', 25, 'Athletics', 'Olympics'), (2, 'Jane Smith', 30, 'Swimming', 'Commonwealth Games'), (3, 'Richard Roe', 28, 'Athletics', 'Commonwealth Games'), (4,...
List the names of athletes who have participated in the Olympics but not in the Commonwealth Games.
SELECT name FROM athletes WHERE event = 'Olympics' AND id NOT IN (SELECT id FROM athletes WHERE event = 'Commonwealth Games');
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR); INSERT INTO regions (id, name) VALUES (1, 'Region A'), (2, 'Region B'); CREATE TABLE heritage_sites (id INT, region_id INT, name VARCHAR, preservation_program VARCHAR); INSERT INTO heritage_sites (id, region_id) VALUES (1, 1, 'Heritage Site A', 'Language Preservation'), (2, ...
What is the total number of language preservation programs in each region?
SELECT regions.name, COUNT(heritage_sites.id) AS total_preservation_programs FROM regions INNER JOIN heritage_sites ON regions.id = heritage_sites.region_id WHERE heritage_sites.preservation_program = 'Language Preservation' GROUP BY regions.id;
gretelai_synthetic_text_to_sql
CREATE TABLE nft_trading (id INT, date DATE, country VARCHAR(50), volume DECIMAL(10, 2)); INSERT INTO nft_trading (id, date, country, volume) VALUES (1, '2022-01-01', 'Brazil', 100), (2, '2022-01-02', 'Argentina', 200), (3, '2022-01-03', 'Chile', 300);
What is the average daily trading volume of non-fungible tokens (NFT) in South America?
SELECT AVG(volume) FROM nft_trading WHERE country IN ('Brazil', 'Argentina', 'Chile') AND date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql