context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE teachers (id INT, name VARCHAR(255)); CREATE TABLE courses (id INT, name VARCHAR(255), start_date DATE); CREATE TABLE teacher_courses (teacher_id INT, course_id INT, completed DATE);
What is the percentage of teachers who have completed at least one professional development course in the last 6 months?
SELECT 100.0 * COUNT(DISTINCT tc.teacher_id) / (SELECT COUNT(DISTINCT t.id) FROM teachers t) as pct_completed FROM teacher_courses tc JOIN courses c ON tc.course_id = c.id WHERE c.start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE mining_workforce (region VARCHAR(20), num_workers INT); INSERT INTO mining_workforce (region, num_workers) VALUES ('West', 1200), ('East', 1500), ('North', 1700), ('South', 1300);
What's the total number of workers in the mining industry across all regions?
SELECT SUM(num_workers) FROM mining_workforce;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation(city VARCHAR(20), material VARCHAR(20), quantity INT); INSERT INTO waste_generation VALUES('New York City', 'Plastic', 15000), ('New York City', 'Paper', 20000), ('New York City', 'Glass', 10000);
What is the total waste generation by material type in New York City in 2021?
SELECT material, SUM(quantity) as total_waste FROM waste_generation WHERE city = 'New York City' AND YEAR(event_date) = 2021 GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2)); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'Northern'), (2, 'Jane Smith', 'Southern'); INSERT INTO transactions (transaction_id, client_id, amount) VALUES (1, 1, 1000.00), (2, 1, 2000.00), (3, 2, 500.00);
What is the average transaction amount for clients in the Northern region?
SELECT AVG(t.amount) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.region = 'Northern';
gretelai_synthetic_text_to_sql
CREATE TABLE Drill_Core (ID int, Sample_ID int, Depth decimal(10,2), Rock_Type varchar(50), Assay_Date date, Gold_Grade decimal(10,2)); INSERT INTO Drill_Core (ID, Sample_ID, Depth, Rock_Type, Assay_Date, Gold_Grade) VALUES (1, 1001, 1.23, 'Quartz', '2022-02-18', 12.5), (2, 1001, 1.89, 'Mica', '2022-02-18', 2.3), (3, 1001, 2.34, 'Feldspar', '2022-02-18', 4.8), (4, 1001, 2.91, 'Quartz', '2022-02-18', 14.1), (5, 1001, 3.45, 'Mica', '2022-02-18', 1.9), (6, 1001, 4.02, 'Feldspar', '2022-02-18', 4.5);
What is the average gold grade for each rock type at sample ID 1001?
SELECT Sample_ID, Rock_Type, AVG(Gold_Grade) as Avg_Gold_Grade FROM Drill_Core WHERE Sample_ID = 1001 GROUP BY Sample_ID, Rock_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE educational_programs (program_id INT, organization_id INT, location VARCHAR(255), start_date DATE, end_date DATE, beneficiaries INT); INSERT INTO educational_programs VALUES (1, 1, 'Country A', '2020-01-01', '2021-12-31', 500); INSERT INTO educational_programs VALUES (2, 1, 'Country A', '2021-01-01', '2022-12-31', 700); INSERT INTO educational_programs VALUES (3, 2, 'Country B', '2021-01-01', '2022-12-31', 1000); INSERT INTO educational_programs VALUES (4, 2, 'Country B', '2020-01-01', '2021-12-31', 800);
What is the number of educational programs provided by each organization, for refugees in South Asia, in the last 2 years, and the total number of beneficiaries?
SELECT organization_id, COUNT(*) as number_of_programs, SUM(beneficiaries) as total_beneficiaries FROM educational_programs WHERE location IN ('Country A', 'Country B') AND start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_churn (churn_id INT, churn_date DATE, subscriber_id INT, region VARCHAR(50), churn_reason VARCHAR(50));
Which regions have the highest and lowest broadband subscriber churn rates?
SELECT region, COUNT(churn_id) as churn_count FROM subscriber_churn WHERE YEAR(churn_date) = YEAR(current_date) - 1 GROUP BY region ORDER BY churn_count ASC, churn_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ListeningData (listen_id INT, listen_date DATE, song_id INT, genre VARCHAR(255), duration DECIMAL(5,2)); INSERT INTO ListeningData (listen_id, listen_date, song_id, genre, duration) VALUES (1, '2020-01-01', 1, 'Pop', 3.5), (2, '2020-01-02', 2, 'Rock', 4.0), (3, '2020-01-03', 3, 'Pop', 3.2);
What is the average listening duration for each genre?
SELECT genre, AVG(duration) as avg_duration FROM ListeningData GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Community (name VARCHAR(255), members INT);
Add a new community with 1700 members?
INSERT INTO Community (name, members) VALUES ('La Rinconada', 1700);
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE, orbit_status VARCHAR(255));
What is the oldest satellite still in orbit?
SELECT name, launch_date FROM satellites WHERE orbit_status = 'in orbit' ORDER BY launch_date ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Claim_Amount_State (Policy_Type VARCHAR(20), State VARCHAR(20), Claim_Amount INT); INSERT INTO Claim_Amount_State (Policy_Type, State, Claim_Amount) VALUES ('Life', 'New York', 30000), ('Health', 'New York', 7000), ('Auto', 'New York', 8000), ('Life', 'New York', 25000), ('Health', 'New York', 8000);
Identify the top 2 insurance types with the highest average claim amount in the state of New York.
SELECT Policy_Type, AVG(Claim_Amount) AS Average_Claim_Amount FROM Claim_Amount_State WHERE State = 'New York' GROUP BY Policy_Type ORDER BY Average_Claim_Amount DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableUrbanismByYear (id INT PRIMARY KEY, city VARCHAR(50), state VARCHAR(50), initiative VARCHAR(100), year INT); INSERT INTO SustainableUrbanismByYear (id, city, state, initiative, year) VALUES (1, 'Seattle', 'WA', 'Green Roofs Initiative', 2022), (2, 'Austin', 'TX', 'Urban Forest Plan', 2022);
Create a view for sustainable urbanism initiatives by year
CREATE VIEW SustainableUrbanismByYearView AS SELECT * FROM SustainableUrbanismByYear WHERE state IN ('WA', 'TX');
gretelai_synthetic_text_to_sql
CREATE TABLE Bridge (id INT, city_id INT, name VARCHAR, length FLOAT, completion_date DATE); INSERT INTO Bridge (id, city_id, name, length, completion_date) VALUES (1, 1, 'George Washington Bridge', 4760, '1931-10-25'); INSERT INTO Bridge (id, city_id, name, length, completion_date) VALUES (2, 2, 'Golden Gate Bridge', 2737, '1937-05-27'); INSERT INTO Bridge (id, city_id, name, length, completion_date) VALUES (3, 3, 'Lake Pontchartrain Causeway', 38400, '1956-08-30');
What are the names and lengths of all bridges, including those that have not been affected by any disaster?
SELECT b.name, b.length FROM Bridge b LEFT JOIN Disaster d ON b.id = d.bridge_id WHERE d.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTours (TourID int, TourName varchar(255), Price float, Revenue float); INSERT INTO VirtualTours (TourID, TourName, Price, Revenue) VALUES (1, 'Tour A', 10, 500), (2, 'Tour B', 15, 800), (3, 'Tour C', 20, 1200), (4, 'Tour D', 5, 300), (5, 'Tour E', 25, 1500);
Find the top 5 virtual tours by total revenue, for tours priced above the average.
SELECT TourName, Revenue FROM (SELECT TourName, Price, Revenue, AVG(Price) OVER () as AvgPrice, RANK() OVER (ORDER BY Revenue DESC) as RevenueRank FROM VirtualTours) as Subquery WHERE Subquery.Price > Subquery.AvgPrice AND Subquery.RevenueRank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, WorkoutName VARCHAR(20), Category VARCHAR(10)); INSERT INTO Workouts (WorkoutID, WorkoutName, Category) VALUES (1, 'Treadmill', 'Cardio'), (2, 'Yoga', 'Strength'), (3, 'Cycling', 'Cardio'); CREATE TABLE CaloriesBurned (WorkoutID INT, CaloriesBurned INT); INSERT INTO CaloriesBurned (WorkoutID, CaloriesBurned) VALUES (1, 300), (2, 150), (3, 400), (4, 500);
What is the maximum calories burned for any workout in the 'Strength' category?
SELECT MAX(CaloriesBurned) FROM Workouts INNER JOIN CaloriesBurned ON Workouts.WorkoutID = CaloriesBurned.WorkoutID WHERE Workouts.Category = 'Strength';
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT, SiteName TEXT, Country TEXT); INSERT INTO ExcavationSites (SiteID, SiteName, Country) VALUES (1, 'Pompeii', 'Italy'), (2, 'Herculaneum', 'Italy'), (3, 'Gournay-sur-Aronde', 'France'), (4, 'Manching', 'Germany');
What are the names and dates of all excavation sites in France and Germany?
SELECT SiteName, Date FROM ExcavationSites INNER JOIN Dates ON ExcavationSites.SiteID = Dates.SiteID WHERE Country IN ('France', 'Germany');
gretelai_synthetic_text_to_sql
CREATE TABLE performances (id INT, performance_date DATE, performance_type VARCHAR(50)); INSERT INTO performances (id, performance_date, performance_type) VALUES (1, '2021-09-01', 'Dance'), (2, '2021-12-31', 'Theater');
How many dance performances were held in the fall season of 2021?
SELECT COUNT(*) FROM performances WHERE performance_type = 'Dance' AND performance_date BETWEEN '2021-09-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Cultivator X', 'Colorado'); INSERT INTO cultivators (id, name, state) VALUES (2, 'Cultivator Y', 'Colorado'); CREATE TABLE strains (cultivator_id INT, name TEXT, year INT, potency INT); INSERT INTO strains (cultivator_id, name, year, potency) VALUES (1, 'Strain A', 2022, 25); INSERT INTO strains (cultivator_id, name, year, potency) VALUES (1, 'Strain B', 2022, 23); INSERT INTO strains (cultivator_id, name, year, potency) VALUES (2, 'Strain C', 2022, 28);
How many unique strains were produced by each cultivator in Colorado in 2022, and what are their average potencies?
SELECT c.name as cultivator_name, COUNT(DISTINCT s.name) as unique_strains, AVG(s.potency) as average_potency FROM cultivators c INNER JOIN strains s ON c.id = s.cultivator_id WHERE c.state = 'Colorado' AND s.year = 2022 GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT);
Insert a new record for a chemical compound with id 101, name 'Ethyl Acetate', and safety_rating 8
INSERT INTO chemical_compounds (id, name, safety_rating) VALUES (101, 'Ethyl Acetate', 8);
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT, name VARCHAR(255)); INSERT INTO teams (id, name) VALUES (1, 'Team A'), (2, 'Team B'), (3, 'Team C'), (4, 'Team D'); CREATE TABLE athletes (id INT, team_id INT, wellbeing_score INT); INSERT INTO athletes (id, team_id, wellbeing_score) VALUES (1, 1, 80), (2, 2, 85), (3, 1, 75), (4, 3, 90);
What is the average wellbeing score for athletes in each team?
SELECT t.name, AVG(a.wellbeing_score) as avg_wellbeing_score FROM athletes a JOIN teams t ON a.team_id = t.id GROUP BY t.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port A', 'USA'), (2, 'Port B', 'Canada'); CREATE TABLE shipments (shipment_id INT, vessel_id INT, port_id INT, cargo_weight INT); INSERT INTO shipments (shipment_id, vessel_id, port_id, cargo_weight) VALUES (1, 1, 1, 5000), (2, 2, 1, 5500), (3, 1, 2, 4000), (4, 2, 2, 4500);
What is the maximum cargo weight handled by vessels that have visited 'Port B'?
SELECT MAX(cargo_weight) FROM shipments JOIN ports ON shipments.port_id = ports.port_id WHERE ports.port_name = 'Port B';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT); INSERT INTO mines (id, name, location, production_volume) VALUES (1, 'South African Zinc Mine 1', 'South Africa', 11000); INSERT INTO mines (id, name, location, production_volume) VALUES (2, 'South African Zinc Mine 2', 'South Africa', 9000);
What is the maximum production volume for zinc mines in South Africa?
SELECT MAX(production_volume) FROM mines WHERE location = 'South Africa' AND mineral = 'zinc';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales (drug_name TEXT, region TEXT, revenue FLOAT); INSERT INTO drug_sales (drug_name, region, revenue) VALUES ('DrugA', 'US', 5000000), ('DrugB', 'EU', 6000000), ('DrugC', 'US', 7000000), ('DrugD', 'EU', 8000000);
What are the top 3 drugs by sales in the US and the EU?
SELECT drug_name, SUM(revenue) FROM drug_sales WHERE region IN ('US', 'EU') GROUP BY drug_name ORDER BY SUM(revenue) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE savings (customer_id INT, name TEXT, state TEXT, savings DECIMAL(10, 2)); INSERT INTO savings (customer_id, name, state, savings) VALUES (123, 'Jane Doe', 'California', 5000.00);
Update the savings of customer '123' to '6000'?
UPDATE savings SET savings = 6000 WHERE customer_id = 123;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (item_id INT, name TEXT, category TEXT, is_vegetarian BOOLEAN, price FLOAT); INSERT INTO menu (item_id, name, category, is_vegetarian, price) VALUES (1, 'Chickpea Curry', 'Lunch', true, 10.5), (2, 'Chicken Tikka Masala', 'Lunch', false, 13.0), (3, 'Quinoa Salad', 'Starters', true, 7.5);
What is the average price of vegetarian dishes in the lunch category?
SELECT AVG(price) as avg_vegetarian_price FROM menu WHERE is_vegetarian = true AND category = 'Lunch';
gretelai_synthetic_text_to_sql
CREATE TABLE Technologies (id INT, name VARCHAR(50), type VARCHAR(50), continent VARCHAR(50)); INSERT INTO Technologies (id, name, type, continent) VALUES (1, 'Stealth Drone', 'Unmanned Aerial Vehicle', 'Africa'); INSERT INTO Technologies (id, name, type, continent) VALUES (2, 'Artificial Intelligence', 'Software', 'Asia');
What is the name and type of all military technologies developed in 'Africa' in the 'Technologies' table?
SELECT name, type FROM Technologies WHERE continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE country_iot (country VARCHAR(50), num_devices INT); INSERT INTO country_iot (country, num_devices) VALUES ('United States', 5000), ('India', 3000), ('China', 7000), ('Brazil', 4000), ('Germany', 2000);
Find the top 3 countries with the most IoT devices in agriculture
SELECT country, num_devices FROM country_iot ORDER BY num_devices DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT); INSERT INTO districts (id, name) VALUES (1, 'Boyle Heights'), (2, 'East LA'), (3, 'Downtown LA'); CREATE TABLE medical_emergencies (id INT, district_id INT, response_time INT, incident_date DATE); INSERT INTO medical_emergencies (id, district_id, response_time, incident_date) VALUES (1, 1, 7, '2021-01-01'), (2, 1, 8, '2021-02-15'), (3, 1, 6, '2021-03-10');
What is the average response time for medical emergencies in the Boyle Heights district in 2021?
SELECT AVG(response_time) FROM medical_emergencies WHERE district_id = 1 AND YEAR(incident_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty_Members (Faculty_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Title VARCHAR(20), Department VARCHAR(50), Hire_Date DATE, Salary DECIMAL(10, 2));
Insert a new record in the 'Faculty_Members' table with the following details: Faculty_ID = 45, First_Name = 'Órla', Last_Name = 'Ní Dhúill', Title = 'Associate Professor', Department = 'Computer Science', Hire_Date = '2020-07-01', Salary = 85000
INSERT INTO Faculty_Members (Faculty_ID, First_Name, Last_Name, Title, Department, Hire_Date, Salary) VALUES (45, 'Órla', 'Ní Dhúill', 'Associate Professor', 'Computer Science', '2020-07-01', 85000);
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteOrbits (id INT, satellite_name VARCHAR(100), company VARCHAR(100), orbit_altitude FLOAT); INSERT INTO SatelliteOrbits (id, satellite_name, company, orbit_altitude) VALUES (1, 'Starlink 1', 'SpaceX', 550); INSERT INTO SatelliteOrbits (id, satellite_name, company, orbit_altitude) VALUES (2, 'Starlink 2', 'SpaceX', 560);
What is the maximum orbit altitude for SpaceX's Starlink satellites?
SELECT MAX(orbit_altitude) FROM SatelliteOrbits WHERE satellite_name LIKE '%Starlink%' AND company = 'SpaceX';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT PRIMARY KEY, freight_forwarder VARCHAR(50), warehouse VARCHAR(50), status VARCHAR(20), delivery_date DATE);
Delete records from the "shipments" table where the "status" column is "delayed" and the "delivery_date" is older than 30 days
DELETE s FROM shipments s INNER JOIN (SELECT id, delivery_date FROM shipments WHERE status = 'delayed' AND delivery_date < NOW() - INTERVAL 30 DAY) d ON s.id = d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE us_water_usage (id INT, year INT, state TEXT, usage FLOAT);
Identify the top 3 states with the highest water usage in the US?
SELECT state, RANK() OVER (ORDER BY usage DESC) as rank FROM us_water_usage GROUP BY state HAVING rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_annual(country varchar(20), year int, expenditure int); INSERT INTO rd_annual(country, year, expenditure) VALUES('US', 2019, 11000), ('US', 2020, 13000), ('Canada', 2019, 8500), ('Canada', 2020, 9500);
What were the top 2 countries with the highest average R&D expenditure per year?
SELECT country, AVG(expenditure) FROM rd_annual GROUP BY country ORDER BY AVG(expenditure) DESC LIMIT 2
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20), Country VARCHAR(50)); INSERT INTO Members (MemberID, Age, Gender, MembershipType, Country) VALUES (1, 35, 'Female', 'Premium', 'USA'), (2, 45, 'Male', 'Basic', 'Canada'), (3, 28, 'Female', 'Premium', 'USA'), (4, 32, 'Male', 'Premium', 'Mexico'), (5, 48, 'Female', 'Basic', 'USA'), (6, 38, 'Male', 'Elite', 'Canada'), (7, 25, 'Female', 'Basic', 'USA'), (8, 42, 'Male', 'Premium', 'Mexico'), (9, 50, 'Female', 'Elite', 'Canada'), (10, 22, 'Male', 'Basic', 'USA'); CREATE TABLE ClassAttendance (MemberID INT, Class VARCHAR(20), Duration INT, Date DATE); INSERT INTO ClassAttendance (MemberID, Class, Duration, Date) VALUES (1, 'Cycling', 60, '2022-04-01'), (2, 'Yoga', 45, '2022-04-02'), (3, 'Cycling', 60, '2022-04-03'), (4, 'Yoga', 45, '2022-04-04'), (5, 'Pilates', 90, '2022-04-05'), (6, 'Cycling', 60, '2022-04-06'), (7, 'Yoga', 45, '2022-04-07'), (8, 'Cycling', 60, '2022-04-08'), (9, 'Yoga', 45, '2022-04-09'), (10, 'Pilates', 120, '2022-04-10');
What is the total duration of all 'Pilates' classes attended by members from the USA?
SELECT SUM(Duration) FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE Members.Country = 'USA' AND ClassAttendance.Class = 'Pilates';
gretelai_synthetic_text_to_sql
CREATE SCHEMA news;CREATE TABLE NewsSourceA (title varchar(255), type varchar(10));CREATE TABLE NewsSourceB (title varchar(255), type varchar(10));INSERT INTO NewsSourceA (title, type) VALUES ('Article1', 'news'), ('Opinion1', 'opinion');INSERT INTO NewsSourceB (title, type) VALUES ('Article2', 'news'), ('Opinion2', 'opinion');
What is the total number of news articles and opinion pieces published by NewsSourceA and NewsSourceB?
SELECT COUNT(*) FROM ( (SELECT title, type FROM news.NewsSourceA) UNION (SELECT title, type FROM news.NewsSourceB) ) AS combined
gretelai_synthetic_text_to_sql
CREATE TABLE player_achievements (player_id INT, achievement_name VARCHAR(255), achievement_date DATE); CREATE VIEW top_players AS SELECT player_id, COUNT(*) as total_achievements FROM player_achievements GROUP BY player_id ORDER BY total_achievements DESC;
Show the top 3 players and their total achievements
SELECT * FROM top_players;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_waste_generation_australia(location VARCHAR(50), date DATE, waste_quantity INT); INSERT INTO daily_waste_generation_australia(location, date, waste_quantity) VALUES ('Sydney', '2022-08-01', 5000), ('Sydney', '2022-08-02', 5500), ('Sydney', '2022-08-03', 6000), ('Melbourne', '2022-08-01', 4000), ('Melbourne', '2022-08-02', 4500), ('Melbourne', '2022-08-03', 5000);
What is the average waste generation per day in kilograms for commercial areas in Sydney for the month of August?
SELECT AVG(waste_quantity/1000.0) FROM daily_waste_generation_australia WHERE location = 'Sydney' AND date BETWEEN '2022-08-01' AND '2022-08-31';
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, sector VARCHAR(255), time_to_resolution INT); INSERT INTO incidents (id, sector, time_to_resolution) VALUES (1, 'healthcare', 120), (2, 'healthcare', 180);
What is the average time to resolution for incidents in the healthcare sector?
SELECT AVG(time_to_resolution) FROM incidents WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), MaxSpeed FLOAT, LoadingCapacity FLOAT); INSERT INTO Vessels (VesselID, VesselName, MaxSpeed, LoadingCapacity) VALUES (1, 'Ocean Titan', 33.5, 75000), (2, 'Sea Giant', 31.3, 45000), (3, 'Marine Unicorn', 34.8, 62000), (4, 'Sky Wanderer', 30.2, 80000), (5, 'River Princess', 28.0, 40000), (6, 'Lake Explorer', 36.0, 10000);
Determine the minimum loading capacity for vessels with a maximum speed greater than 30 knots
SELECT MIN(LoadingCapacity) FROM Vessels WHERE MaxSpeed > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE acidification_data (sample_id INT, location VARCHAR(255), level FLOAT);
What is the maximum ocean acidification level recorded in the 'acidification_data' table?
SELECT MAX(level) FROM acidification_data;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_response (id INT, location TEXT, year INT, ongoing BOOLEAN); INSERT INTO disaster_response (id, location, year, ongoing) VALUES (1, 'Haiti', 2022, TRUE), (2, 'Philippines', 2021, FALSE);
What is the name and location of ongoing disaster response projects in Haiti as of 2022?
SELECT name, location FROM disaster_response WHERE location = 'Haiti' AND year = 2022 AND ongoing = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name TEXT, region TEXT, participants INT); INSERT INTO carbon_offset_programs (id, name, region, participants) VALUES (1, 'Program A', 'west', 500); INSERT INTO carbon_offset_programs (id, name, region, participants) VALUES (2, 'Program B', 'east', 350); INSERT INTO carbon_offset_programs (id, name, region, participants) VALUES (3, 'Program C', 'west', 600);
Delete the carbon offset program 'Program B'
DELETE FROM carbon_offset_programs WHERE name = 'Program B';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryExpenditure (expenditure_id INT, country VARCHAR(50), region VARCHAR(50), year INT, expenditure FLOAT); INSERT INTO MilitaryExpenditure (expenditure_id, country, region, year, expenditure) VALUES (1, 'China', 'Asia-Pacific', 2020, 2500000000), (2, 'India', 'Asia-Pacific', 2020, 7000000000), (3, 'Japan', 'Asia-Pacific', 2020, 4500000000), (4, 'USA', 'North America', 2020, 7250000000);
Calculate the total military expenditure for the Asia-Pacific region in 2020.
SELECT SUM(expenditure) FROM MilitaryExpenditure WHERE region = 'Asia-Pacific' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country) VALUES (1, 'Esther Mwangi', 'Kenya'), (2, 'Yusuf Kibira', 'Uganda'), (3, 'Alex Nguyen', 'Canada'); CREATE TABLE VolunteerPrograms (ProgramID INT, ProgramName TEXT); INSERT INTO VolunteerPrograms (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Environment'); CREATE TABLE VolunteerAssignments (AssignmentID INT, VolunteerID INT, ProgramID INT); INSERT INTO VolunteerAssignments (AssignmentID, VolunteerID, ProgramID) VALUES (1, 1, 2), (2, 2, 2);
What is the total number of volunteers from Kenya and Uganda who participated in environmental programs?
SELECT COUNT(DISTINCT Volunteers.VolunteerID) AS TotalVolunteers FROM Volunteers INNER JOIN VolunteerAssignments ON Volunteers.VolunteerID = VolunteerAssignments.VolunteerID INNER JOIN VolunteerPrograms ON VolunteerAssignments.ProgramID = VolunteerPrograms.ProgramID WHERE Volunteers.Country IN ('Kenya', 'Uganda') AND VolunteerPrograms.ProgramName = 'Environment';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name TEXT, category TEXT, price DECIMAL(5,2), capacity INT); INSERT INTO events (id, name, category, price, capacity) VALUES (1, 'Play', 'theater', 50.00, 600), (2, 'Concert', 'music', 20.00, 200), (3, 'Musical', 'theater', 75.00, 800), (4, 'Ballet', 'dance', 120.00, 350), (5, 'Recital', 'dance', 80.00, 400); CREATE TABLE event_attendance (event_id INT, attendees INT); INSERT INTO event_attendance (event_id, attendees) VALUES (1, 550), (2, 180), (3, 750), (4, 300), (5, 420);
Find the total revenue for all events in the 'theater' category with a capacity greater than 300.
SELECT SUM(price * attendees) FROM events JOIN event_attendance ON events.id = event_attendance.event_id WHERE events.category = 'theater' AND capacity > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_per_person (country VARCHAR(20), usage FLOAT); INSERT INTO water_usage_per_person (country, usage) VALUES ('South Africa', 120);
What is the average water usage per person in South Africa?
SELECT AVG(usage) FROM water_usage_per_person WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE AnimalPopulation(Year INT, Species VARCHAR(20), Animals INT); INSERT INTO AnimalPopulation VALUES (2017, 'Tiger', 10), (2018, 'Tiger', 12), (2019, 'Tiger', 15), (2017, 'Lion', 20), (2018, 'Lion', 22), (2019, 'Lion', 25), (2017, 'Elephant', 25), (2018, 'Elephant', 28), (2019, 'Elephant', 30), (2017, 'Giraffe', 15), (2018, 'Giraffe', 18), (2019, 'Giraffe', 20);
What is the number of animals of each species in the animal population as of 2019?
SELECT Species, Animals FROM AnimalPopulation WHERE Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Memberships (ID INT PRIMARY KEY, MembershipType VARCHAR(50), StartDate DATE, EndDate DATE, Revenue DECIMAL(10,2));
What is the total revenue generated from memberships in the past year, grouped by membership type?
SELECT MembershipType, SUM(Revenue) FROM Memberships WHERE StartDate >= DATEADD(year, -1, GETDATE()) GROUP BY MembershipType;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (id INT, aircraft_model_id INT, accident_date DATE); CREATE TABLE AircraftModels (id INT, name VARCHAR(50)); CREATE VIEW AccidentsPerModel AS SELECT aircraft_model_id, COUNT(*) as num_accidents FROM Accidents GROUP BY aircraft_model_id;
How many accidents have occurred for each aircraft model?
SELECT AircraftModels.name, AccidentsPerModel.num_accidents FROM AircraftModels JOIN AccidentsPerModel ON AircraftModels.id = AccidentsPerModel.aircraft_model_id;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (id INT, project VARCHAR(50), location VARCHAR(50)); INSERT INTO climate_mitigation_projects (id, project, location) VALUES (1, 'Carbon Capture', 'Latin America'), (2, 'Energy Efficiency', 'Caribbean'), (3, 'Public Transportation', 'Latin America');
How many climate mitigation projects have been implemented in Latin America and the Caribbean?
SELECT COUNT(*) FROM climate_mitigation_projects WHERE location IN ('Latin America', 'Caribbean');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (event_id INT, year INT, country VARCHAR(50)); INSERT INTO defense_diplomacy (event_id, year, country) VALUES (123, 2018, 'United States'), (123, 2018, 'Canada'), (456, 2018, 'Germany'), (456, 2018, 'France'), (789, 2018, 'United Kingdom'), (789, 2018, 'France'), (321, 2018, 'Brazil'), (321, 2018, 'Argentina');
Which defense diplomacy events involved the most countries in 2018?
SELECT event_id, COUNT(DISTINCT country) FROM defense_diplomacy WHERE year = 2018 GROUP BY event_id ORDER BY COUNT(DISTINCT country) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, sector VARCHAR(20), esg_score FLOAT); INSERT INTO investments (id, sector, esg_score) VALUES (1, 'Education', 75.00), (2, 'Healthcare', 70.00), (3, 'Renewable Energy', 65.00);
Delete all investments with ESG scores less than 70.
DELETE FROM investments WHERE esg_score < 70;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, OfficeLocation VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, OfficeLocation) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Downtown'), (4, 'Suburbs'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, CaseType VARCHAR(255)); INSERT INTO Cases (CaseID, AttorneyID, CaseType) VALUES (1, 1, 'Civil'), (2, 1, 'Criminal'), (3, 2, 'Civil'), (4, 3, 'Civil'), (5, 4, 'Criminal');
How many civil cases were handled by attorneys from the 'Downtown' office location?
SELECT COUNT(*) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE OfficeLocation = 'Downtown' AND CaseType = 'Civil';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Email VARCHAR(50), DonationAmount DECIMAL(10,2));
What is the total donation amount per donor, for donors who have donated more than once?
SELECT DonorID, SUM(DonationAmount) FROM Donors GROUP BY DonorID HAVING COUNT(DonorID) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), content TEXT, language VARCHAR(10), publish_date DATE); INSERT INTO articles (id, title, content, language, publish_date) VALUES (1, 'Artículo 1', 'Contenido 1', 'es', '2020-01-01'), (2, 'Article 2', 'Content 2', 'en', '2020-01-15'), (3, 'Artículo 3', 'Contenido 3', 'es', '2020-02-01');
What is the total word count of articles published in Spanish?
SELECT SUM(word_count) as total_word_count FROM articles WHERE language = 'es';
gretelai_synthetic_text_to_sql
CREATE TABLE professors(id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, gender VARCHAR(10)); INSERT INTO professors VALUES (1, 'Alice', 'Arts and Humanities', 80000.0, 'Female'); INSERT INTO professors VALUES (2, 'Bob', 'Science', 85000.0, 'Male'); INSERT INTO professors VALUES (3, 'Charlie', 'Arts and Humanities', 78000.0, 'Female');
What is the average salary of female professors in the College of Arts and Humanities?
SELECT AVG(salary) FROM professors WHERE department = 'Arts and Humanities' AND gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesDataOrganic (sale_id INT, product_id INT, sale_revenue FLOAT, is_organic BOOLEAN); INSERT INTO SalesDataOrganic (sale_id, product_id, sale_revenue, is_organic) VALUES (1, 1, 75, true), (2, 2, 30, false), (3, 3, 60, false), (4, 4, 120, true), (5, 5, 45, false);
Identify the top 3 beauty products with the highest sales revenue, excluding products labeled 'organic'.
SELECT product_id, sale_revenue FROM SalesDataOrganic WHERE is_organic = false GROUP BY product_id, sale_revenue ORDER BY sale_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions_table (asset_name VARCHAR(20), network VARCHAR(20), transactions_value FLOAT); INSERT INTO transactions_table (asset_name, network, transactions_value) VALUES ('BNB', 'Binance Smart Chain', 100000), ('ETH', 'Binance Smart Chain', 200000);
What is the total value of transactions for all digital assets in the 'Binance Smart Chain' network?
SELECT SUM(transactions_value) FROM transactions_table WHERE network = 'Binance Smart Chain';
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (metric_id INT PRIMARY KEY, name TEXT, description TEXT); INSERT INTO diversity_metrics (metric_id, name, description) VALUES (1, 'Gender diversity', 'Percentage of employees who identify as female or male'); INSERT INTO diversity_metrics (metric_id, name, description) VALUES (2, 'Racial diversity', 'Percentage of employees who identify as a race other than Caucasian');
Get the name and description of all diversity metrics in the "diversity_metrics" table
SELECT name, description FROM diversity_metrics;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (id INT, type VARCHAR(50), country VARCHAR(50), purchase_date DATE);
Insert a new record into the 'equipment' table for a new shovel from 'Canada' with ID 123
INSERT INTO equipment (id, type, country, purchase_date) VALUES (123, 'shovel', 'Canada', CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE data_scientists (id INT, name VARCHAR(50), salary FLOAT, department VARCHAR(50)); INSERT INTO data_scientists (id, name, salary, department) VALUES (1, 'Fiona', 95000, 'big_data'), (2, 'George', 100000, 'big_data'), (3, 'Hannah', 90000, 'big_data'), (4, 'Iris', 85000, 'big_data');
What is the maximum salary for data scientists in the "big_data" department of the "data_analytics" company?
SELECT MAX(salary) FROM data_scientists WHERE department = 'big_data';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_date DATE); INSERT INTO transactions (id, transaction_date) VALUES (1, '2022-01-01'), (2, '2022-01-08'), (3, '2022-01-15'), (4, '2022-01-22'), (5, '2022-01-29'), (6, '2022-12-25');
Show all transactions that were made on a holiday.
SELECT * FROM transactions WHERE transaction_date IN (DATE('2022-01-01'), DATE('2022-01-17'), DATE('2022-02-21'), DATE('2022-05-30'), DATE('2022-07-04'), DATE('2022-12-25'));
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget INT);
Delete all records in the 'rural_infrastructure' table where the budget is less than 50000.
DELETE FROM rural_infrastructure WHERE budget < 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_expenditures (destination_country VARCHAR(50), visitor_country VARCHAR(50), avg_daily_expenditure FLOAT); INSERT INTO daily_expenditures (destination_country, visitor_country, avg_daily_expenditure) VALUES ('Egypt', 'Europe', 75.0);
What is the average expenditure per day for tourists visiting Egypt from Europe?
SELECT avg_daily_expenditure FROM daily_expenditures WHERE destination_country = 'Egypt' AND visitor_country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, visitors INT, continent VARCHAR(255)); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('New Zealand', 2019, 4000000, 'Oceania');
Delete records of tourists who visited New Zealand in 2019 from the tourism_stats table.
DELETE FROM tourism_stats WHERE country = 'New Zealand' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE college (college_name TEXT); INSERT INTO college (college_name) VALUES ('College of Science'), ('College of Arts'), ('College of Business'); CREATE TABLE research_grants (grant_id INTEGER, college_name TEXT, grant_amount INTEGER); INSERT INTO research_grants (grant_id, college_name, grant_amount) VALUES (1, 'College of Science', 50000), (2, 'College of Business', 75000), (3, 'College of Arts', 30000), (4, 'College of Science', 100000);
What is the total amount of research grants awarded to each college?
SELECT college_name, SUM(grant_amount) FROM research_grants GROUP BY college_name;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id int, product_name varchar(50), is_circular boolean);CREATE TABLE sales (sale_id int, product_id int, sale_date date, units_sold int);
What is the number of units of each product sold through circular supply chains in the last month?
SELECT products.product_id, products.product_name, SUM(sales.units_sold) as total_units_sold FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.is_circular = true AND sales.sale_date >= DATEADD(month, -1, GETDATE()) GROUP BY products.product_id, products.product_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, vessel_name VARCHAR(50), speed FLOAT); INSERT INTO vessel_performance (id, vessel_name, speed) VALUES (1, 'VesselA', 15.5), (2, 'VesselB', 18.2), (3, 'VesselC', 17.3);
How many vessels are there in the 'vessel_performance' table?
SELECT COUNT(*) FROM vessel_performance;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerators (GeneratorID INT, WasteType VARCHAR(20), GeneratedTonnes DECIMAL(5,2), Location VARCHAR(50));CREATE TABLE RecyclingPlants (PlantID INT, WasteType VARCHAR(20), RecycledTonnes DECIMAL(5,2), Location VARCHAR(50));CREATE VIEW RecyclingRates AS SELECT WasteType, AVG(RecycledTonnes/GeneratedTonnes) AS RecyclingRate FROM WasteGenerators WG INNER JOIN RecyclingPlants RP ON WG.WasteType = RP.WasteType GROUP BY WasteType;
What are the recycling rates for plastic and metal waste types?
SELECT WasteType, RecyclingRate FROM RecyclingRates WHERE WasteType IN ('plastic', 'metal');
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_housing (id INT, property_id INT, number_of_units INT, city VARCHAR(50)); INSERT INTO affordable_housing (id, property_id, number_of_units, city) VALUES (1, 101, 12, 'New York'), (2, 102, 8, 'Los Angeles');
Insert a new property 'Green Heights' into the 'affordable_housing' table located in 'Portland' with 10 units.
INSERT INTO affordable_housing (property_id, number_of_units, city) VALUES (103, 10, 'Portland');
gretelai_synthetic_text_to_sql
CREATE TABLE salaries (id INT, gender TEXT, sector TEXT, salary FLOAT); INSERT INTO salaries (id, gender, sector, salary) VALUES (1, 'Male', 'Technology', 60000), (2, 'Female', 'Education', 55000), (3, 'Male', 'Technology', 65000), (4, 'Female', 'Healthcare', 50000);
What is the minimum salary for male workers in the technology sector?
SELECT MIN(salary) FROM salaries WHERE gender = 'Male' AND sector = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists oil_production (id INT PRIMARY KEY, well_id INT, year INT, production REAL); INSERT INTO oil_production (id, well_id, year, production) VALUES (1, 1, 2019, 1000), (2, 2, 2019, 2000), (3, 3, 2018, 1500), (4, 1, 2020, 1200); CREATE TABLE if not exists oil_wells (id INT PRIMARY KEY, well_name TEXT, region TEXT); INSERT INTO oil_wells (id, well_name, region) VALUES (1, 'Well A', 'North Sea'), (2, 'Well B', 'North Sea'), (3, 'Well C', 'Barents Sea');
What is the total production from oil wells in the 'North Sea'?
SELECT SUM(production) FROM oil_production JOIN oil_wells ON oil_production.well_id = oil_wells.id WHERE oil_wells.region = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE missouri_river_basin(state VARCHAR(20), sector VARCHAR(20), consumption NUMERIC(10,2)); INSERT INTO missouri_river_basin VALUES ('Nebraska', 'Residential', 2345.67), ('Missouri', 'Residential', 3456.78), ('Kansas', 'Residential', 4567.89), ('Iowa', 'Residential', 5678.90);
What is the total water consumption by residential sector in the Missouri river basin, excluding Missouri and Kansas?
SELECT consumption FROM missouri_river_basin WHERE state NOT IN ('Missouri', 'Kansas') AND sector = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE TravelAdvisories (id INT, country TEXT, issued_date DATE);
List all the travel advisories issued for Asian countries in the past 6 months.
SELECT * FROM TravelAdvisories WHERE country IN ('Asia', 'Central Asia', 'Southeast Asia', 'East Asia') AND issued_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE exploration_projects (project_id INT, project_name VARCHAR(50), region VARCHAR(50)); INSERT INTO exploration_projects (project_id, project_name, region) VALUES (1, 'Project X', 'Africa'), (2, 'Project Y', 'Europe');
How many exploration projects have been initiated in the 'Africa' region?
SELECT COUNT(*) FROM exploration_projects WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (id INT, city VARCHAR(20), co2_emission FLOAT); INSERT INTO Buildings (id, city, co2_emission) VALUES (1, 'Seattle', 340.5), (2, 'Los Angeles', 420.6), (3, 'Seattle', 360.1);
What is the average CO2 emission of buildings in the city of Seattle?
SELECT AVG(co2_emission) FROM Buildings WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE budget (state VARCHAR(20), service VARCHAR(20), amount INT); INSERT INTO budget (state, service, amount) VALUES ('Florida', 'Education', 40000), ('Florida', 'Healthcare', 70000), ('Georgia', 'Healthcare', 60000), ('Georgia', 'Education', 50000);
What is the budget allocated for healthcare services in 'Florida' and 'Georgia'?
SELECT amount FROM budget WHERE state IN ('Florida', 'Georgia') AND service = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_biomass (id INT, farm_id INT, biomass INT, system_type TEXT); INSERT INTO farm_biomass (id, farm_id, biomass, system_type) VALUES (1, 1, 3000, 'Recirculating'), (2, 1, 3000, 'Flow-through'), (3, 2, 2000, 'Recirculating'), (4, 2, 2000, 'Hybrid'), (5, 3, 4000, 'Flow-through'); CREATE TABLE pacific_farms_ras (id INT, farm_id INT, farm_name TEXT, region TEXT, system_type TEXT); INSERT INTO pacific_farms_ras (id, farm_id, farm_name, region, system_type) VALUES (1, 1, 'FarmA', 'Pacific', 'Recirculating'), (2, 2, 'FarmB', 'Pacific', 'Recirculating'), (3, 3, 'FarmC', 'Atlantic', 'Flow-through'), (4, 4, 'FarmD', 'Pacific', 'Hybrid');
What is the number of farms in the Pacific region using recirculating aquaculture systems and their total biomass?
SELECT pacific_farms_ras.region, SUM(farm_biomass.biomass) as total_biomass FROM farm_biomass JOIN pacific_farms_ras ON farm_biomass.farm_id = pacific_farms_ras.farm_id WHERE pacific_farms_ras.region = 'Pacific' AND pacific_farms_ras.system_type = 'Recirculating' GROUP BY pacific_farms_ras.region;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), cause VARCHAR(50), donation_date DATE); INSERT INTO donors (id, name, cause, donation_date) VALUES (1, 'John Doe', 'Education', '2022-04-01'), (2, 'Jane Smith', 'Health', '2022-04-15'), (3, 'Alice Johnson', 'Environment', '2022-05-05');
What is the number of unique donors by month in 2022?
SELECT EXTRACT(MONTH FROM donation_date) as month, COUNT(DISTINCT name) as unique_donors FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, type VARCHAR(20), region VARCHAR(20), cost FLOAT); INSERT INTO Infrastructure (id, type, region, cost) VALUES (1, 'Bridge', 'Midwest', 25000.0), (2, 'Road', 'Midwest', 15000.0), (3, 'Bridge', 'Midwest', 30000.0);
Which infrastructure types have the highest average maintenance costs in the Midwest?
SELECT type, AVG(cost) as avg_cost FROM Infrastructure WHERE region = 'Midwest' GROUP BY type ORDER BY avg_cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE TicketSales (TicketID INT, EventType VARCHAR(10), Revenue DECIMAL(10,2)); CREATE TABLE MerchandiseSales (MerchandiseID INT, ProductType VARCHAR(10), Revenue DECIMAL(10,2));
Show the total revenue for each sport from ticket sales and merchandise for the last financial year.
SELECT EventType, SUM(Revenue) FROM TicketSales WHERE EventDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY EventType UNION ALL SELECT ProductType, SUM(Revenue) FROM MerchandiseSales WHERE SaleDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY ProductType;
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain_transparency (element VARCHAR(10), supplier VARCHAR(20), transparency INT); INSERT INTO supply_chain_transparency VALUES ('Lanthanum', 'Supplier A', 8), ('Lanthanum', 'Supplier B', 7), ('Europium', 'Supplier A', 9), ('Europium', 'Supplier C', 6);
Find the supply chain transparency for Lanthanum and Europium
SELECT element, AVG(transparency) AS avg_transparency FROM supply_chain_transparency GROUP BY element;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_application (id INT, name VARCHAR(50), description TEXT, algorithm_id INT); INSERT INTO creative_application (id, name, description, algorithm_id) VALUES (1, 'AI Drawer', 'An application that generates...', 2);
Which creative applications use the AI algorithm named 'Lime'?
SELECT creative_application.name FROM creative_application INNER JOIN safe_algorithm ON creative_application.algorithm_id = safe_algorithm.id WHERE safe_algorithm.name = 'Lime';
gretelai_synthetic_text_to_sql
CREATE TABLE reverse_logistics(id INT, item VARCHAR(255), date DATE); INSERT INTO reverse_logistics VALUES(1, 'ABC', '2022-02-15'), (2, 'DEF', '2022-03-01');
Remove reverse logistics records from last month
DELETE FROM reverse_logistics WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, organization VARCHAR(255), operation VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO peacekeeping_operations (id, organization, operation, start_date, end_date) VALUES (1, 'African Union', 'Operation Freedom', '2002-10-01', '2003-04-30');
What is the total number of peacekeeping operations conducted by the 'African Union'?
SELECT COUNT(*) FROM peacekeeping_operations WHERE organization = 'African Union';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkerTrainings (WorkerID INT, Training VARCHAR(50)); INSERT INTO CommunityHealthWorkerTrainings (WorkerID, Training) VALUES (1, 'Cultural Competency'), (2, 'Mental Health First Aid'), (3, 'Crisis Prevention'), (4, 'Cultural Competency'), (5, 'Motivational Interviewing'), (6, 'Cultural Competency'), (7, 'Mental Health First Aid'), (8, 'Crisis Prevention'), (9, 'Motivational Interviewing'), (10, 'Cultural Competency'), (11, 'Motivational Interviewing'), (12, 'Language Access'), (13, 'Crisis Prevention'), (14, 'Cultural Competency'), (15, 'Mental Health First Aid');
Which community health workers did not receive any trainings related to motivational interviewing?
SELECT WorkerID FROM CommunityHealthWorkerTrainings WHERE Training NOT LIKE '%Motivational Interviewing%';
gretelai_synthetic_text_to_sql
CREATE TABLE natural_reserves (country TEXT, visitors INT); INSERT INTO natural_reserves (country, visitors) VALUES ('Brazil', 15000000), ('Indonesia', 12000000), ('China', 18000000), ('India', 11000000);
Which countries have more than 10 million tourists visiting their natural reserves?
SELECT country FROM natural_reserves WHERE visitors > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (restaurant_name TEXT, daily_revenue NUMERIC, date DATE); INSERT INTO revenue (restaurant_name, daily_revenue, date) VALUES ('ABC Bistro', 600, '2022-02-14'), ('DEF Diner', 400, '2022-02-14'), ('GHI Grill', 300, '2022-02-14'), ('JKL Bistro', 550, '2022-02-14');
Which restaurants had a daily revenue above $500 on Valentine's Day 2022?
SELECT restaurant_name FROM revenue WHERE daily_revenue > 500 AND date = '2022-02-14';
gretelai_synthetic_text_to_sql
CREATE TABLE school_exam_results (student_id INT, school_id INT, exam_id INT, pass INT); INSERT INTO school_exam_results VALUES (1, 1, 1, 1), (2, 1, 1, 0), (3, 2, 1, 1);
What is the percentage of students who passed the open pedagogy exam in each school?
SELECT school_id, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER() as pass_percentage FROM school_exam_results WHERE pass = 1 GROUP BY school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (id INT, name VARCHAR, facility_type VARCHAR); INSERT INTO facilities (id, name, facility_type) VALUES (1, 'Rural General Hospital', 'hospital'), (2, 'Urban Community Clinic', 'clinic'); CREATE TABLE state_codes (id INT, state VARCHAR, region VARCHAR); INSERT INTO state_codes (id, state, region) VALUES (1, 'Texas', 'South'), (2, 'California', 'West');
List the number of hospitals and clinics in each state, sorted by the total number of rural healthcare facilities.
SELECT state_codes.region, COUNT(facilities.id), SUM(facilities.id) FROM facilities INNER JOIN state_codes ON facilities.id = state_codes.id AND facilities.facility_type IN ('hospital', 'clinic') GROUP BY state_codes.region ORDER BY SUM(facilities.id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales(store VARCHAR(20), sale_date DATE, garment_id INT); INSERT INTO Sales(store, sale_date, garment_id) VALUES ('Eco_Friendly', '2021-11-01', 1), ('Eco_Friendly', '2021-11-02', 2), ('Sustainable_Outlet', '2021-11-01', 3);
How many garments were sold in each store during the month of November 2021?
SELECT store, COUNT(*) FROM Sales WHERE MONTH(sale_date) = 11 AND YEAR(sale_date) = 2021 GROUP BY store;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT PRIMARY KEY, country VARCHAR(50), impact_score INT, operation_date DATE); INSERT INTO environmental_impact (id, country, impact_score, operation_date) VALUES (1, 'Canada', 75, '2020-01-01'), (2, 'Mexico', 85, '2019-05-05'), (3, 'Canada', 65, '2021-03-15');
What's the average environmental impact score for mining operations in each country, in the last 2 years?
SELECT country, AVG(impact_score) as avg_score FROM environmental_impact WHERE operation_date >= DATEADD(year, -2, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE VRUsers (PlayerID INT, VRDevice VARCHAR(20)); INSERT INTO VRUsers (PlayerID, VRDevice) VALUES (1, 'Oculus'); INSERT INTO VRUsers (PlayerID, VRDevice) VALUES (2, 'HTC Vive');
List all VR devices used by players in the 'VRUsers' table.
SELECT DISTINCT VRDevice FROM VRUsers;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_type VARCHAR(50), location VARCHAR(50)); CREATE TABLE Attendance (attendee_id INT, event_id INT); INSERT INTO Events (event_id, event_type, location) VALUES (1, 'Dance', 'Chicago'), (2, 'Theater', 'Los Angeles'), (3, 'Dance', 'San Francisco'); INSERT INTO Attendance (attendee_id, event_id) VALUES (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3);
What is the average number of attendees for dance events in Chicago and San Francisco?
SELECT AVG(cnt) FROM (SELECT COUNT(DISTINCT A.attendee_id) AS cnt FROM Attendance A INNER JOIN Events E ON A.event_id = E.event_id WHERE E.event_type = 'Dance' AND E.location IN ('Chicago', 'San Francisco')) AS subquery
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTourRevenue(id INT, country TEXT, revenue FLOAT); INSERT INTO VirtualTourRevenue(id, country, revenue) VALUES (1, 'United States', 5000.0), (2, 'Canada', 3000.0);
What is the total revenue generated from virtual tours in the United States and Canada?
SELECT SUM(revenue) FROM VirtualTourRevenue WHERE country IN ('United States', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Buildings (project_name TEXT, city TEXT, completion_date DATE); INSERT INTO Sustainable_Buildings (project_name, city, completion_date) VALUES ('Solar Panel Installation', 'Seattle', '2022-06-01'), ('Green Roof Construction', 'New York', '2021-12-15');
What are the names and completion dates of all sustainable building projects in the city of Seattle?
SELECT project_name, completion_date FROM Sustainable_Buildings WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO ArtSales (id, category, price) VALUES (1, 'Modern Art', 5000.00), (2, 'Contemporary Art', 7500.00), (3, 'Modern Art', 8000.00);
What is the total revenue generated from art sales in the 'Modern Art' category?
SELECT SUM(price) FROM ArtSales WHERE category = 'Modern Art';
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'); CREATE TABLE civic_tech_issues (id INT, city_id INT, status VARCHAR(255)); INSERT INTO civic_tech_issues (id, city_id, status) VALUES (1, 1, 'open'), (2, 1, 'closed'), (3, 2, 'open'), (4, 3, 'closed'), (5, NULL, 'open');
List all civic tech issues, their status, and the city they are associated with
SELECT cti.id, cti.status, cities.name as city_name FROM civic_tech_issues cti LEFT JOIN cities ON cti.city_id = cities.id;
gretelai_synthetic_text_to_sql
CREATE TABLE russian_fleet(model VARCHAR(255), flight_time INT);CREATE TABLE chinese_fleet(model VARCHAR(255), flight_time INT);
What is the average flight time for each aircraft model in the Russian and Chinese fleets, grouped by the manufacturer?
SELECT 'Russian' as Manufacturer, AVG(flight_time) as Avg_Flight_Time FROM russian_fleet GROUP BY Manufacturer UNION ALL SELECT 'Chinese' as Manufacturer, AVG(flight_time) as Avg_Flight_Time FROM chinese_fleet GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (assistance_id INT, assistance_name VARCHAR(50), year INT, location VARCHAR(50), description TEXT);
Insert a new record in the humanitarian_assistance table for an operation named 'Natural Disaster Relief in Caribbean' in 2021
INSERT INTO humanitarian_assistance (assistance_id, assistance_name, year, location, description) VALUES (2, 'Natural Disaster Relief in Caribbean', 2021, 'Caribbean', 'Description of the natural disaster relief operation');
gretelai_synthetic_text_to_sql