context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Satellites (id INT, name VARCHAR(100), manufacturer VARCHAR(100), launch_country VARCHAR(100), launch_date DATE); INSERT INTO Satellites (id, name, manufacturer, launch_country, launch_date) VALUES (4, 'Sat4', 'SpaceTech', 'India', '2021-01-01'); INSERT INTO Satellites (id, name, manufacturer, launch_country, launch_date) VALUES (5, 'Sat5', 'EuroSpace', 'India', '2022-02-14');
List all satellites launched by India?
SELECT name, manufacturer, launch_date FROM Satellites WHERE launch_country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE City_Budget(City VARCHAR(20), Department VARCHAR(20), Budget INT); INSERT INTO City_Budget(City, Department, Budget) VALUES('Vancouver', 'Transportation', 35000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('Vancouver', 'Public Services', 60000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('Ottawa', 'Transportation', 28000000); INSERT INTO City_Budget(City, Department, Budget) VALUES('Ottawa', 'Public Services', 55000000);
What is the total budget allocated to public services for each city?
SELECT City, SUM(Budget) FROM City_Budget WHERE Department = 'Public Services' GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure_projects (id INT PRIMARY KEY, country VARCHAR(50), project_name VARCHAR(100), start_date DATE, end_date DATE, budget DECIMAL(10, 2));
What was the total budget for rural infrastructure projects in 2020, grouped by country?
SELECT country, SUM(budget) as total_budget FROM rural_infrastructure_projects WHERE YEAR(start_date) = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterFunding (id INT PRIMARY KEY, city VARCHAR(255), funding FLOAT); CREATE VIEW UnderfundedCities AS SELECT city, funding FROM DisasterFunding WHERE funding < (SELECT AVG(funding) FROM DisasterFunding); CREATE TABLE DisasterPreparedness (id INT PRIMARY KEY, city VARCHAR(255), preparedness INT);
Which cities have insufficient disaster funding and low disaster preparedness?
SELECT uc.city, uc.funding, dp.preparedness FROM UnderfundedCities uc JOIN DisasterPreparedness dp ON uc.city = dp.city WHERE dp.preparedness < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, PlayerName varchar(50), GameID int); INSERT INTO Players (PlayerID, PlayerName, GameID) VALUES (1, 'Player1', 1), (2, 'Player2', 1), (3, 'Player3', 2), (4, 'Player4', 2), (5, 'Player5', 3);
How many players are registered for each game?
SELECT G.GameName, COUNT(P.PlayerID) as PlayerCount FROM Games G JOIN Players P ON G.GameID = P.GameID GROUP BY G.GameName;
gretelai_synthetic_text_to_sql
CREATE TABLE donor_transactions (donor_id INT, donation_amount FLOAT); INSERT INTO donor_transactions (donor_id, donation_amount) VALUES (5, 200.00), (6, 300.00), (7, 100.00), (8, 400.00);
What is the average donation amount for donors from 'Africa'?
SELECT AVG(donation_amount) FROM donor_transactions JOIN donor_profiles ON donor_transactions.donor_id = donor_profiles.id WHERE donor_profiles.region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_name TEXT, monthly_cost FLOAT, data_allowance INT);
How many subscribers have more than 10GB data allowance?
SELECT COUNT(*) FROM mobile_plans WHERE data_allowance > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorAge (DonorID INT, DonorAge INT); INSERT INTO DonorAge (DonorID, DonorAge) SELECT DonorID, FLOOR(DATEDIFF('year', DonorBirthDate, CURRENT_DATE)/365) as DonorAge FROM Donors; ALTER TABLE Donors ADD COLUMN DonorAge INT; UPDATE Donors SET DonorAge = (SELECT DonorAge FROM DonorAge WHERE Donors.DonorID = DonorAge.DonorID);
What is the total donation amount by each donor's age group?
SELECT CASE WHEN D.DonorAge BETWEEN 18 AND 24 THEN '18-24' WHEN D.DonorAge BETWEEN 25 AND 34 THEN '25-34' WHEN D.DonorAge BETWEEN 35 AND 44 THEN '35-44' WHEN D.DonorAge BETWEEN 45 AND 54 THEN '45-54' WHEN D.DonorAge >= 55 THEN '55+' ELSE 'Unknown' END as AgeGroup, SUM(D.DonationAmount) as TotalDonationAmount FROM Donors D GROUP BY AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE appointments (id INT, patient_id INT, healthcare_center_id INT, appointment_date TIMESTAMP, appointment_type TEXT); INSERT INTO appointments (id, patient_id, healthcare_center_id, appointment_date, appointment_type) VALUES (1, 1, 1, '2021-06-10 14:30:00', 'Mental Health'), (2, 2, 1, '2021-05-15 09:00:00', 'Physical Therapy');
What is the total number of mental health appointments in Australia over the past year?
SELECT COUNT(*) FROM appointments WHERE appointment_date >= DATEADD(year, -1, CURRENT_TIMESTAMP) AND appointment_type = 'Mental Health' AND healthcare_center_id IN (SELECT id FROM healthcare_centers WHERE country = 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (facility_id INT, location VARCHAR(255), health_equity_score INT); INSERT INTO mental_health_facilities (facility_id, location, health_equity_score) VALUES (1, 'Urban', 85), (2, 'Rural', 75), (3, 'Urban', 90), (4, 'Rural', 80), (5, 'Rural', 78), (6, 'Urban', 95);
What is the minimum health equity score for mental health facilities in rural areas?
SELECT MIN(health_equity_score) as min_score FROM mental_health_facilities WHERE location = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtGallery (event_id INT, event_name VARCHAR(50), event_date DATE, age_group VARCHAR(20));
What is the distribution of audience members by age group, for events held at the 'Art Gallery' in the past year?
SELECT age_group, COUNT(*) FROM ArtGallery WHERE event_date >= DATEADD(year, -1, GETDATE()) GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyDailyCount (Date TEXT, Count INT); INSERT INTO PolicyDailyCount (Date, Count) VALUES ('2022-01-01', 50); INSERT INTO PolicyDailyCount (Date, Count) VALUES ('2022-01-02', 60);
How many policy records were inserted per day in the last week?
SELECT Date, Count FROM PolicyDailyCount WHERE Date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices (country VARCHAR(50), price DECIMAL(5,2)); INSERT INTO carbon_prices (country, price) VALUES ('European Union', 25.87), ('United States', 10.21);
What is the minimum carbon price in the European Union and United States?
SELECT MIN(price) FROM carbon_prices WHERE country IN ('European Union', 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255)); INSERT INTO organizations (id, name) VALUES (1, 'WFP'), (2, 'UNICEF'), (3, 'CARE'); CREATE TABLE donations (id INT, organization_id INT, program VARCHAR(255), amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, organization_id, program, amount, donation_date) VALUES (1, 1, 'Food Security', 5000, '2021-01-01'), (2, 1, 'Health', 7000, '2021-02-01'), (3, 2, 'Food Security', 3000, '2021-03-01'), (4, 2, 'Health', 6000, '2021-04-01'), (5, 3, 'Food Security', 4000, '2021-05-01');
What's the total amount of donations by each organization for the 'Food Security' program in 2021?
SELECT organization_id, SUM(amount) as total_donations FROM donations WHERE program = 'Food Security' AND YEAR(donation_date) = 2021 GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_name VARCHAR(50), budget INTEGER, technology_for_social_good BOOLEAN);
What is the maximum budget for any project in 'projects' table?
SELECT MAX(budget) FROM projects;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, name VARCHAR(255), approval_date DATE);CREATE TABLE rd_expenditures (expenditure_id INT, drug_id INT, amount INT, year INT);
What are the total R&D expenditures for each drug that has been approved by the FDA, including the drug name and approval date?
SELECT d.name, d.approval_date, SUM(re.amount) as total_expenditures FROM drugs d JOIN rd_expenditures re ON d.drug_id = re.drug_id GROUP BY d.name, d.approval_date;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), hire_date DATE, country VARCHAR(50), salary INT); INSERT INTO employees (id, first_name, last_name, hire_date, country, salary) VALUES (5, 'Hong', 'Li', '2022-01-15', 'China', 50000);
What is the total number of employees hired in the Asia Pacific region in Q1 2022, and what is the average salary for those employees?
SELECT COUNT(e.id), AVG(e.salary) FROM employees e WHERE e.hire_date >= '2022-01-01' AND e.hire_date < '2022-04-01' AND e.country IN (SELECT region FROM regions WHERE region_name = 'Asia Pacific');
gretelai_synthetic_text_to_sql
CREATE TABLE safety_protocols (site VARCHAR(10), protocol VARCHAR(20), review_date DATE); INSERT INTO safety_protocols VALUES ('A', 'P1', '2020-06-01'), ('A', 'P2', '2019-08-15'), ('B', 'P3', '2021-02-03'), ('B', 'P4', '2020-11-28'), ('B', 'P5', '2018-04-22');
List the safety protocols for site 'B' in descending order of last review date.
SELECT protocol, review_date FROM safety_protocols WHERE site = 'B' ORDER BY review_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousDrivingResearch (project_id INT, project_name VARCHAR(100), budget DECIMAL(10,2), country VARCHAR(50)); INSERT INTO AutonomousDrivingResearch (project_id, project_name, budget, country) VALUES (1, 'Project A', 5000000, 'US'), (2, 'Project B', 3000000, 'US');
List all autonomous driving research projects and their respective budgets in the US.
SELECT * FROM AutonomousDrivingResearch WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE innovation_projects (id INT PRIMARY KEY, project_name VARCHAR(100), budget INT, category VARCHAR(50), start_date DATE, end_date DATE, status VARCHAR(20));
What's the total budget for agricultural innovation projects in the 'innovation_projects' table?
SELECT SUM(budget) FROM innovation_projects WHERE category = 'agricultural innovation';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers_2 (subscriber_id INT, data_usage FLOAT, region VARCHAR(20)); INSERT INTO mobile_subscribers_2 (subscriber_id, data_usage, region) VALUES (4, 25.3, 'Central'), (5, 34.5, 'Central'), (6, 19.2, 'Central');
Add new mobile subscribers with their respective data usage in the Central region.
INSERT INTO mobile_subscribers SELECT * FROM mobile_subscribers_2 WHERE region = 'Central';
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (id INT, name VARCHAR(255), category VARCHAR(255), production_capacity FLOAT, region VARCHAR(255));
What is the maximum production capacity for each chemical category, for chemical manufacturing in the Africa region?
SELECT category, MAX(production_capacity) as max_capacity FROM chemicals WHERE region = 'Africa' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Climate (Id INT, Station VARCHAR(20), Temperature DECIMAL(5,2), Precipitation DECIMAL(5,2), Measurement_Date DATE); INSERT INTO Climate (Id, Station, Temperature, Precipitation, Measurement_Date) VALUES (1, 'Station1', 5.0, 0.5, '2021-02-02'), (2, 'Station2', 10.0, 0.2, '2021-02-02');
What is the average temperature in each climate station's latest measurement?
SELECT Station, AVG(Temperature) OVER (PARTITION BY Station ORDER BY Measurement_Date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as Avg_Temperature FROM Climate WHERE Measurement_Date = (SELECT MAX(Measurement_Date) FROM Climate);
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id integer, incident text, resolved_date date, timestamp timestamp); INSERT INTO incidents (id, incident, resolved_date, timestamp) VALUES (1, 'Phishing', '2022-06-01', '2022-06-05 10:00:00'), (2, 'Malware', '2022-07-02', '2022-07-03 11:00:00'), (3, 'Phishing', '2022-06-03', '2022-06-06 12:00:00'), (4, 'Insider Threat', '2022-07-04', '2022-07-05 13:00:00'), (5, 'Phishing', '2022-06-05', '2022-06-07 14:00:00');
What is the average time taken to resolve a phishing incident for each month in the last year?
SELECT DATE_PART('month', timestamp) as month, AVG(DATEDIFF(day, timestamp, resolved_date)) as avg_time_to_resolve FROM incidents WHERE incident = 'Phishing' AND timestamp >= DATEADD(year, -1, CURRENT_TIMESTAMP) GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk_assessments (id INT, region VARCHAR(255), assessment VARCHAR(255)); INSERT INTO geopolitical_risk_assessments (id, region, assessment) VALUES (1, 'Africa', 'High'), (2, 'Europe', 'Medium'), (3, 'Americas', 'Low');
What is the geopolitical risk assessment for the African continent?
SELECT assessment FROM geopolitical_risk_assessments WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE MenuSales (restaurant_id INT, menu_item_id INT, sale_date DATE, quantity_sold INT); INSERT INTO MenuSales (restaurant_id, menu_item_id, sale_date, quantity_sold) VALUES (1, 101, '2021-08-01', 5), (1, 102, '2021-08-01', 12), (1, 103, '2021-08-01', 3), (1, 101, '2021-08-02', 2), (1, 102, '2021-08-02', 8), (1, 103, '2021-08-02', 7), (2, 101, '2021-08-01', 3), (2, 102, '2021-08-01', 7), (2, 103, '2021-08-01', 10), (2, 101, '2021-08-02', 6), (2, 102, '2021-08-02', 4), (2, 103, '2021-08-02', 1);
What is the total quantity of menu items sold in the past month for each restaurant?
SELECT restaurant_id, SUM(quantity_sold) as total_quantity_sold FROM menusales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE GROUP BY restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE factory_production (factory_id INT, year INT, garments_produced INT);
Which factories produced the most garments in 2022?
SELECT factory_id, SUM(garments_produced) AS total_garments_produced FROM factory_production WHERE year = 2022 GROUP BY factory_id ORDER BY total_garments_produced DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE production (well_id INT, date DATE, quantity FLOAT, state VARCHAR(2)); INSERT INTO production (well_id, date, quantity, state) VALUES (1, '2021-01-01', 100.0, 'TX'), (1, '2021-01-02', 120.0, 'TX'), (2, '2021-01-01', 150.0, 'OK');
Get the daily production for the past week for wells in the Permian Basin
SELECT well_id, date, quantity FROM production p JOIN wells w ON p.well_id = w.id WHERE w.state = 'TX' AND p.date >= DATEADD(day, -7, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Art (ArtID INT, ArtistID INT, ArtCategory VARCHAR(50), ArtLocation VARCHAR(50)); INSERT INTO Art (ArtID, ArtistID, ArtCategory, ArtLocation) VALUES (1, 1, 'Painting', 'Japan'), (2, 1, 'Sculpture', 'India'), (3, 2, 'Painting', 'China'), (4, 2, 'Drawing', 'Vietnam'), (5, 3, 'Music', 'North Korea'), (6, 3, 'Theater', 'Indonesia'), (7, 4, 'Dance', 'Malaysia'), (8, 4, 'Art', 'Thailand');
Insert a new artwork by 'ArtistI' from Mexico in the 'Painting' category.
INSERT INTO Art (ArtID, ArtistID, ArtCategory, ArtLocation) VALUES (9, 9, 'Painting', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, menu_id INT, customer_id INT, dietary_restrictions VARCHAR(50)); INSERT INTO orders (order_id, menu_id, customer_id, dietary_restrictions) VALUES (1, 1, 101, 'Vegan'), (2, 2, 102, 'Vegetarian'), (3, 3, 103, 'None'), (4, 4, 104, 'Dairy-free');
Find the most common dietary restriction among customer orders.
SELECT dietary_restrictions, COUNT(*) AS num_orders FROM orders GROUP BY dietary_restrictions ORDER BY num_orders DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE packages (package_id INT, warehouse_location VARCHAR(20)); INSERT INTO packages (package_id, warehouse_location) VALUES (1, 'Warehouse A'), (2, 'Warehouse A'), (3, 'Warehouse C');
Update the warehouse location for package with ID 5 to 'Warehouse B'
UPDATE packages SET warehouse_location = 'Warehouse B' WHERE package_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Orders (order_id INT PRIMARY KEY, customer_id INT, menu_id INT, order_date DATETIME, quantity INT);
Delete all orders with a menu_id of 5678 and a quantity greater than 50.
DELETE FROM Orders WHERE menu_id = 5678 AND quantity > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50)); INSERT INTO ports (port_id, port_name) VALUES (1, 'Port of Long Beach'), (2, 'Port of Los Angeles'), (3, 'Port of Oakland');
List all ports in the 'ports' table that have an even port ID.
SELECT port_name FROM ports WHERE MOD(port_id, 2) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceLaunches (LaunchID INT, Country VARCHAR(50), SatelliteID INT, LaunchYear INT); INSERT INTO SpaceLaunches (LaunchID, Country, SatelliteID, LaunchYear) VALUES (1, 'Algeria', 101, 2002), (2, 'Nigeria', 201, 2007), (3, 'South Africa', 301, 1990), (4, 'Egypt', 401, 1998), (5, 'Kenya', 501, 2018);
What is the total number of satellites launched by African countries since 2000?
SELECT Country, COUNT(SatelliteID) AS TotalSatellites FROM SpaceLaunches WHERE LaunchYear >= 2000 AND Country LIKE 'Africa%' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE viscose (id INT, country VARCHAR(50), quantity INT); INSERT INTO viscose (id, country, quantity) VALUES (1, 'China', 5000), (2, 'India', 3000);
Which country sources the most sustainable viscose?
SELECT country, SUM(quantity) as total_quantity FROM viscose GROUP BY country ORDER BY total_quantity DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(50), incident_time TIMESTAMP, impact_value INT); INSERT INTO security_incidents (id, country, incident_time, impact_value) VALUES (1, 'USA', '2022-01-01 10:00:00', 5000), (2, 'Canada', '2022-01-02 15:30:00', 7000), (3, 'USA', '2022-01-03 08:45:00', 6000);
Find the three most recent security incidents for each country, and their total impact value.
SELECT country, incident_time, impact_value, ROW_NUMBER() OVER (PARTITION BY country ORDER BY incident_time DESC) as rn FROM security_incidents WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE military_weapon_systems (system_id INT PRIMARY KEY, system_name VARCHAR(100), system_type VARCHAR(50), manufacturer VARCHAR(100)); INSERT INTO military_weapon_systems (system_id, system_name, system_type, manufacturer) VALUES (1, 'Patriot Missile System', 'Air Defense Missile System', 'Raytheon'), (2, 'Tomahawk Cruise Missile', 'Missile', 'Raytheon'), (3, 'Aegis Ballistic Missile Defense System', 'Shipboard Missile Defense System', 'Lockheed Martin');
Get the 'system_name' and 'system_type' for all records in the 'military_weapon_systems' table where 'manufacturer' is 'Raytheon'
SELECT system_name, system_type FROM military_weapon_systems WHERE manufacturer = 'Raytheon';
gretelai_synthetic_text_to_sql
CREATE TABLE retaining_walls (wall_name TEXT, wall_height INT, wall_state TEXT); INSERT INTO retaining_walls (wall_name, wall_height, wall_state) VALUES ('RW1', 12, 'New York'), ('RW2', 15, 'New York'), ('RW3', 18, 'New York'), ('RW4', 10, 'New York');
What is the maximum height of all retaining walls in New York?
SELECT MAX(wall_height) FROM retaining_walls WHERE wall_state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (category VARCHAR(20), project_cost INT); INSERT INTO Projects (category, project_cost) VALUES ('Bridge', 5000000), ('Bridge', 6000000), ('Road', 3000000), ('Road', 4000000), ('Water Treatment', 6500000), ('Dams Safety', 7500000), ('Transit System', 9000000);
What is the maximum and minimum project cost for each category?
SELECT category, MAX(project_cost) AS max_cost, MIN(project_cost) AS min_cost FROM Projects GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_equipment (equipment_id INT, equipment_type TEXT, model TEXT, year INT);
Insert a new record into the "agricultural_equipment" table with a "equipment_type" of "tractor", "model" of "Massey Ferguson 7624", and "year" of 2018
INSERT INTO agricultural_equipment (equipment_type, model, year) VALUES ('tractor', 'Massey Ferguson 7624', 2018);
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(255), location VARCHAR(255), PRIMARY KEY (id)); CREATE TABLE Efficiency (id INT, project_id INT, year INT, efficiency FLOAT, PRIMARY KEY (id), FOREIGN KEY (project_id) REFERENCES Projects(id)); INSERT INTO Projects (id, name, location) VALUES (1, 'Wind Farm A', 'USA'), (2, 'Solar Farm B', 'California'); INSERT INTO Efficiency (id, project_id, year, efficiency) VALUES (1, 1, 2020, 0.35), (2, 1, 2021, 0.37), (3, 2, 2020, 0.20), (4, 2, 2021, 0.22);
Which renewable energy projects had an increase in energy efficiency from 2020 to 2021?
SELECT P.name, E.year, E.efficiency FROM Projects P INNER JOIN Efficiency E ON P.id = E.project_id WHERE P.location IN ('USA', 'California') AND E.year = 2021 AND EXISTS (SELECT 1 FROM Efficiency E2 WHERE E2.project_id = E.project_id AND E2.year = 2020 AND E2.efficiency < E.efficiency);
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR, location VARCHAR, patients_served INT); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (1, 'John Doe', 'Urban', 50); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (2, 'Jane Smith', 'Urban', 75);
What is the total number of patients served by community health workers in urban areas?
SELECT location, SUM(patients_served) as total_patients FROM community_health_workers WHERE location = 'Urban' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE NutritionData (SupplierID INT, Certification TEXT); INSERT INTO NutritionData (SupplierID, Certification) VALUES (1, 'Organic'), (2, 'Non-GMO');
Update nutrition data for 'Green Earth' to reflect new certifications.
UPDATE NutritionData SET Certification = 'Biodynamic' WHERE SupplierID = (SELECT SupplierID FROM Suppliers WHERE SupplierName = 'Green Earth');
gretelai_synthetic_text_to_sql
CREATE TABLE TemperateRainforest (id INT, species VARCHAR(255), diameter FLOAT, height FLOAT, volume FLOAT); INSERT INTO TemperateRainforest (id, species, diameter, height, volume) VALUES (1, 'Redwood', 5.6, 120, 23.4); INSERT INTO TemperateRainforest (id, species, diameter, height, volume) VALUES (2, 'DouglasFir', 3.9, 90, 17.2);
What is the minimum diameter of trees in the 'TemperateRainforest' table?
SELECT MIN(diameter) FROM TemperateRainforest;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists public_bicycles (id INT, city VARCHAR(255), bikes INT); INSERT INTO public_bicycles (id, city, bikes) VALUES (1, 'Amsterdam', 15000), (2, 'Utrecht', 12000), (3, 'Rotterdam', 8000), (4, 'The Hague', 6000);
What is the number of public bicycles available in each city in the Netherlands?
SELECT city, bikes FROM public_bicycles;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donor_country TEXT, donation_date DATE, donation_amount DECIMAL); INSERT INTO donations (id, donor_id, donor_country, donation_date, donation_amount) VALUES (1, 1, 'United Kingdom', '2020-01-01', 50.00), (2, 2, 'Canada', '2019-01-01', 100.00), (3, 3, 'United Kingdom', '2020-12-31', 25.00);
What is the total amount of donations made by donors from the United Kingdom in the year 2020?
SELECT SUM(donation_amount) FROM donations WHERE donor_country = 'United Kingdom' AND YEAR(donation_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE operational_satellites (id INT, name VARCHAR(255), mass FLOAT); INSERT INTO operational_satellites (id, name, mass) VALUES (1, 'Operational Satellite 1', 1500.0), (2, 'Operational Satellite 2', 500.0);
What is the total mass of operational satellites in orbit?
SELECT SUM(mass) FROM operational_satellites;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, language VARCHAR(255), likes INT); INSERT INTO posts (id, language, likes) VALUES (1, 'English', 10), (2, 'Spanish', 20), (3, 'French', 30), (4, 'Spanish', 40);
What is the total number of likes received by posts in Spanish?
SELECT SUM(likes) FROM posts WHERE language = 'Spanish';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, Age int, Gender varchar(10), GamePreference varchar(20)); INSERT INTO Players (PlayerID, Age, Gender, GamePreference) VALUES (1, 25, 'Male', 'VR'); INSERT INTO Players (PlayerID, Age, Gender, GamePreference) VALUES (2, 30, 'Female', 'Non-VR'); CREATE TABLE Games (GameID int, GameName varchar(20), Genre varchar(10), VR boolean); INSERT INTO Games (GameID, GameName, Genre, VR) VALUES (1, 'Game1', 'Action', false); INSERT INTO Games (GameID, GameName, Genre, VR) VALUES (2, 'Game2', 'Adventure', true);
What is the average age of players who play VR games, and how many VR games have been published?
SELECT AVG(Players.Age) AS AvgAge, COUNT(Games.GameID) AS VRGameCount FROM Players INNER JOIN Games ON Players.GamePreference = 'VR' AND Games.VR = true;
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_id INT, state_name VARCHAR(100)); INSERT INTO states (state_id, state_name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'); CREATE TABLE community_health_workers (worker_id INT, state_id INT, cultural_competency_score INT); INSERT INTO community_health_workers (worker_id, state_id, cultural_competency_score) VALUES (1, 1, 85), (2, 1, 90), (3, 2, 80), (4, 3, 95), (5, 1, 92);
What is the average cultural competency score of community health workers for each state, ordered from highest to lowest?
SELECT state_id, AVG(cultural_competency_score) as avg_score FROM community_health_workers GROUP BY state_id ORDER BY avg_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE military_patents (id INT, patent_date DATE, country VARCHAR(255)); INSERT INTO military_patents (id, patent_date, country) VALUES (1, '2018-06-20', 'USA'); INSERT INTO military_patents (id, patent_date, country) VALUES (2, '2019-03-12', 'Russia');
What are the top 5 countries with the most military technology patents in the last 5 years?
SELECT country, COUNT(*) AS num_patents FROM military_patents WHERE patent_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY country ORDER BY num_patents DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE nodes_transactions (node_id INT, transaction_date DATE, transactions INT); INSERT INTO nodes_transactions (node_id, transaction_date, transactions) VALUES (1, '2021-01-01', 20), (1, '2021-01-02', 25), (1, '2021-01-03', 30), (2, '2021-01-01', 35), (2, '2021-01-02', 40), (2, '2021-01-03', 45), (3, '2021-01-01', 50), (3, '2021-01-02', 55), (3, '2021-01-03', 60), (4, '2021-01-01', 65), (4, '2021-01-02', 70), (4, '2021-01-03', 75);
How many transactions were processed by each node on each day in the 'nodes_transactions' table?
SELECT node_id, transaction_date, SUM(transactions) FROM nodes_transactions GROUP BY node_id, transaction_date;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (practice_id INT, description TEXT, category VARCHAR(20));
Add a new record to the "sustainable_practices" table with an ID of 6, a description of 'Recycling initiatives in housekeeping', and a category of 'Waste'
INSERT INTO sustainable_practices (practice_id, description, category) VALUES (6, 'Recycling initiatives in housekeeping', 'Waste');
gretelai_synthetic_text_to_sql
CREATE TABLE compliance (id INT PRIMARY KEY, vessel_id INT, act TEXT, FOREIGN KEY (vessel_id) REFERENCES vessels(id));
Delete all compliance records for the 'Maritime Safety Act' from the database.
DELETE FROM compliance WHERE act = 'Maritime Safety Act';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (MissionID INT, LaunchingSpaceAgency VARCHAR);
What is the total number of space missions that have been launched by each space agency?
SELECT LaunchingSpaceAgency, COUNT(*) FROM SpaceMissions GROUP BY LaunchingSpaceAgency;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), event VARCHAR(50), stipend DECIMAL(5,2)); INSERT INTO artists (id, name, event, stipend) VALUES (1, 'Pablo Picasso', 'Art of the Americas', 3000), (2, 'Frida Kahlo', 'Art of the Americas', 2500);
Add a new artist 'Yayoi Kusama' to the 'Women in Art' event.
INSERT INTO artists (id, name, event, stipend) VALUES (3, 'Yayoi Kusama', 'Women in Art', 4000);
gretelai_synthetic_text_to_sql
CREATE TABLE green_cars (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, horsepower INT, is_electric BOOLEAN, is_sports BOOLEAN);
What is the average horsepower of sports cars in the 'green_cars' table by manufacturer?
SELECT make, AVG(horsepower) as avg_horsepower FROM green_cars WHERE is_sports = TRUE GROUP BY make;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT, country VARCHAR(50), production FLOAT); INSERT INTO wind_turbines (id, country, production) VALUES (1, 'Germany', 4.5), (2, 'Germany', 5.2), (3, 'France', 4.8);
What is the average energy production per wind turbine in Germany, ordered by production amount?
SELECT AVG(production) as avg_production FROM (SELECT production FROM wind_turbines WHERE country = 'Germany' ORDER BY production DESC) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoption (region VARCHAR(255), score INT); INSERT INTO hotel_tech_adoption
What are the average hotel tech adoption scores by region?
SELECT region, AVG(score) FROM hotel_tech_adoption GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists materials (id INT PRIMARY KEY, name VARCHAR(255), source VARCHAR(255), price DECIMAL(10,2)); INSERT INTO materials (id, name, source, price) VALUES (1, 'cotton', 'sustainably sourced', 2.50), (2, 'polyester', 'recycled', 3.25), (3, 'hemp', 'organic', 4.75);
What is the average price of sustainably sourced cotton per kilogram?
SELECT AVG(price) FROM materials WHERE name = 'cotton' AND source = 'sustainably sourced';
gretelai_synthetic_text_to_sql
CREATE TABLE Indigenous_Communities ( id INT PRIMARY KEY, name VARCHAR(50), population INT, region VARCHAR(50), language VARCHAR(50) ); INSERT INTO Indigenous_Communities (id, name, population, region, language) VALUES (1, 'Sami', 80000, 'Northern Scandinavia', 'Northern Sami'); INSERT INTO Indigenous_Communities (id, name, population, region, language) VALUES (2, 'Inuit', 65000, 'Greenland', 'Greenlandic (Kalaallisut)'); INSERT INTO Indigenous_Communities (id, name, population, region, language) VALUES (3, 'Inuit', 15000, 'Canada', 'Inuktitut');
Which indigenous communities in Canada and Greenland speak an Inuit language?
SELECT name, region FROM Indigenous_Communities WHERE country IN ('Canada', 'Greenland') AND language LIKE 'Inukt%'
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (Patient_ID INT, Patient_Name VARCHAR(50), Income FLOAT, Training_Completion_Date DATE); INSERT INTO Patients (Patient_ID, Patient_Name, Income, Training_Completion_Date) VALUES (1, 'John Doe', 50000, '2021-01-01'); INSERT INTO Patients (Patient_ID, Patient_Name, Income, Training_Completion_Date) VALUES (2, 'Jane Smith', 60000, '2021-02-15'); CREATE TABLE Training_Courses (Course_ID INT, Course_Name VARCHAR(50), Course_Type VARCHAR(50)); INSERT INTO Training_Courses (Course_ID, Course_Name, Course_Type) VALUES (1, 'Mental Health Parity', 'Online');
What is the average income of patients who have completed mental health parity training?
SELECT AVG(Income) FROM Patients INNER JOIN Training_Courses ON Patients.Patient_ID = Training_Courses.Course_ID WHERE Course_Type = 'Mental Health Parity' AND Training_Completion_Date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE city_employees (employee_id INT, first_name VARCHAR(30), last_name VARCHAR(30), department VARCHAR(50), hire_date DATE);
Delete records in the "city_employees" table where the "department" is "Parks and Recreation"
DELETE FROM city_employees WHERE department = 'Parks and Recreation';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, cause VARCHAR(255)); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (1, 500, '2022-01-01', 'Education'); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (2, 250, '2022-01-15', 'Health'); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (3, 750, '2022-03-01', 'Environment'); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (4, 100, '2022-03-05', 'Environment');
What is the total donation amount for each cause, with a grand total row?
SELECT cause, SUM(donation_amount) AS total_donation_amount FROM donations GROUP BY cause WITH ROLLUP;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, completed_year INT, capacity_mw FLOAT); INSERT INTO projects (id, name, completed_year, capacity_mw) VALUES (1, 'Hydro Project 1', 2012, 200.5); INSERT INTO projects (id, name, completed_year, capacity_mw) VALUES (2, 'Hydro Project 2', 2005, 150.3);
What is the total installed capacity (in MW) of all hydro power projects that were completed after the year 2010?
SELECT SUM(capacity_mw) FROM projects WHERE type = 'hydro' AND completed_year > 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Farmers (id INT, name VARCHAR(50), Organic_Produce_id INT); INSERT INTO Sustainable_Farmers (id, name, Organic_Produce_id) VALUES (1, 'Nutty Acres', 3), (2, 'Peanut Paradise', 4);
List all suppliers who supply items in the 'Nuts' category with a calorie count higher than 250?
SELECT s.name FROM Sustainable_Farmers s JOIN Organic_Produce o ON s.Organic_Produce_id = o.id WHERE o.calories > 250 AND o.category = 'Nuts';
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, organic_source TEXT, product_id INT); INSERT INTO ingredients VALUES (1, 'Jojoba Oil', 'Mexico', 1), (2, 'Shea Butter', 'Ghana', 2), (3, 'Aloe Vera', 'Mexico', 3), (4, 'Rosehip Oil', 'Chile', 4), (5, 'Cocoa Butter', 'Ghana', 5); CREATE TABLE products (product_id INT, product_name TEXT, price FLOAT); INSERT INTO products VALUES (1, 'Lipstick A', 12.99), (2, 'Foundation B', 18.50), (3, 'Mascara C', 9.99), (4, 'Eyeshadow D', 14.99), (5, 'Blush E', 11.99);
Which countries source the most organic ingredients for cosmetic products?
SELECT organic_source, COUNT(*) as ingredient_count FROM ingredients JOIN products ON ingredients.product_id = products.product_id WHERE organic_source IS NOT NULL GROUP BY organic_source ORDER BY ingredient_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), department VARCHAR(20));
How many employees are currently in the 'employees' table?
SELECT COUNT(*) FROM employees;
gretelai_synthetic_text_to_sql
CREATE TABLE malicious_ip (ip_address VARCHAR(15), incident_id INT); INSERT INTO malicious_ip (ip_address, incident_id) VALUES ('192.168.0.10', 1), ('192.168.0.11', 2), ('192.168.0.12', 3), ('192.168.0.13', 4), ('192.168.0.14', 5);
List all unique IP addresses associated with malicious activities and the corresponding number of related incidents in the last 6 months.
SELECT ip_address, COUNT(*) as incident_count FROM malicious_ip JOIN incidents ON malicious_ip.incident_id = incidents.incident_id WHERE incidents.incident_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY ip_address;
gretelai_synthetic_text_to_sql
CREATE TABLE gaming_facts (player_id INT, country VARCHAR(50), total_spending FLOAT); INSERT INTO gaming_facts (player_id, country, total_spending) VALUES (1, 'USA', 450.25), (2, 'Canada', 520.35), (3, 'France', 405.12), (4, 'Germany', 350.56);
What is the total spending by players from Europe in the 'gaming_facts' table?
SELECT SUM(total_spending) as total_europe_spending FROM gaming_facts WHERE country IN ('France', 'Germany');
gretelai_synthetic_text_to_sql
CREATE TABLE MakeupSales (sale_id INT, product_name TEXT, sale_amount FLOAT, sale_date DATE, country TEXT); INSERT INTO MakeupSales (sale_id, product_name, sale_amount, sale_date, country) VALUES (1, 'Lipstick', 25.00, '2021-01-10', 'USA'); INSERT INTO MakeupSales (sale_id, product_name, sale_amount, sale_date, country) VALUES (2, 'Mascara', 30.00, '2021-03-15', 'Canada'); INSERT INTO MakeupSales (sale_id, product_name, sale_amount, sale_date, country) VALUES (3, 'Eyeshadow', 40.00, '2021-02-01', 'Mexico');
list the top 3 countries with the highest sales of makeup in Q1 of 2021
SELECT country, SUM(sale_amount) AS total_sales FROM MakeupSales WHERE sale_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY country ORDER BY total_sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE loans (loan_number INT, amount DECIMAL(10, 2), status VARCHAR(10), created_at TIMESTAMP);
Update the amount column to 10000 for all records in the loans table where the loan_number is 102
UPDATE loans SET amount = 10000 WHERE loan_number = 102;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO movies (id, title, release_year, views, country, genre) VALUES (1, 'Movie1', 2010, 10000, 'India', 'Action'), (2, 'Movie2', 2015, 15000, 'India', 'Drama'), (3, 'Movie3', 2020, 20000, 'India', 'Comedy'); CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO tv_shows (id, title, release_year, views, country, genre) VALUES (1, 'TVShow1', 2005, 20000, 'India', 'Action'), (2, 'TVShow2', 2018, 25000, 'India', 'Drama'), (3, 'TVShow3', 2021, 30000, 'India', 'Comedy'); CREATE TABLE genres (id INT, name VARCHAR(50)); INSERT INTO genres (id, name) VALUES (1, 'Action'), (2, 'Drama'), (3, 'Comedy'), (4, 'Romance'), (5, 'Sci-Fi');
What is the number of unique genres for movies and TV shows in India?
SELECT COUNT(DISTINCT genre) FROM movies WHERE country = 'India' UNION SELECT COUNT(DISTINCT genre) FROM tv_shows WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_funding (funding_id INT, funding_year INT, funding_city VARCHAR(20), funding_amount INT); INSERT INTO legal_aid_funding (funding_id, funding_year, funding_city, funding_amount) VALUES (1, 2020, 'New York', 50000), (2, 2019, 'Los Angeles', 75000);
What is the total funding allocated for legal aid clinics by city and year?
SELECT funding_city, funding_year, SUM(funding_amount) as total_funding FROM legal_aid_funding GROUP BY funding_city, funding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE campaign_contributions (contributor_id INT, contributor_name VARCHAR(255), amount DECIMAL(10,2), contribution_date DATE);
Who are the top 3 contributors in 'campaign_contributions' table?
SELECT contributor_name, SUM(amount) AS total_contributions FROM campaign_contributions GROUP BY contributor_name ORDER BY total_contributions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (id INT, name VARCHAR(50), daily_tx_volume INT); INSERT INTO dapps (id, name, daily_tx_volume) VALUES (1, 'App1', 1000), (2, 'App2', 2000), (3, 'App3', 3000);
What is the 3-month moving average of daily transaction volume for each decentralized application?
SELECT name, AVG(daily_tx_volume) OVER (PARTITION BY name ORDER BY id ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) as moving_avg FROM dapps;
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, name VARCHAR(255), city VARCHAR(255), price FLOAT); INSERT INTO tours (id, name, city, price) VALUES (1, 'Eco-Friendly Bike Tour', 'Paris', 80.00), (2, 'Green Paris Walking Tour', 'Paris', 60.00);
What is the average price of eco-friendly tours in Paris?
SELECT AVG(price) FROM tours WHERE city = 'Paris' AND name LIKE '%eco-friendly%';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(20), destination VARCHAR(20), expenditure DECIMAL(10,2)); INSERT INTO tourism_stats (visitor_country, destination, expenditure) VALUES ('Germany', 'Berlin', 400.00), ('Germany', 'Berlin', 450.00), ('Germany', 'Munich', 350.00), ('Germany', 'Hamburg', 300.00);
What is the average expenditure by tourists from Germany in Berlin, Munich, and Hamburg combined?
SELECT AVG(expenditure) FROM (SELECT expenditure FROM tourism_stats WHERE visitor_country = 'Germany' AND destination IN ('Berlin', 'Munich', 'Hamburg')) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT);
List the total number of menu items with a sustainability_rating of 5
SELECT COUNT(*) FROM menu_items WHERE sustainability_rating = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage (country VARCHAR(50), project_name VARCHAR(100), start_date DATE, end_date DATE); INSERT INTO cultural_heritage (country, project_name, start_date, end_date) VALUES ('Greece', 'Ancient Ruins Restoration', '2021-01-01', '2022-12-31');
Update the name of a cultural heritage preservation project in Greece.
UPDATE cultural_heritage SET project_name = 'Classical Architecture Preservation' WHERE country = 'Greece' AND project_name = 'Ancient Ruins Restoration';
gretelai_synthetic_text_to_sql
CREATE TABLE shared_ev (vehicle_id INT, trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, start_latitude DECIMAL(9,6), start_longitude DECIMAL(9,6), end_latitude DECIMAL(9,6), end_longitude DECIMAL(9,6), distance DECIMAL(10,2));
What is the maximum distance traveled by a single electric vehicle in a shared fleet in Los Angeles?
SELECT MAX(distance) FROM (SELECT vehicle_id, MAX(distance) AS distance FROM shared_ev WHERE start_longitude BETWEEN -118.6 AND -117.8 AND start_latitude BETWEEN 33.6 AND 34.4 GROUP BY vehicle_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE PolarBears (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO PolarBears (id, name, region) VALUES (1, 'Polar Bear 1', 'Arctic Circle'); INSERT INTO PolarBears (id, name, region) VALUES (2, 'Polar Bear 2', 'Canadian Arctic');
Find the number of polar bears in each region and the total count
SELECT region, COUNT(*) as num_polar_bears, SUM(*) OVER () as total_count FROM PolarBears;
gretelai_synthetic_text_to_sql
CREATE TABLE news_headlines (id INT, headline VARCHAR(255), source VARCHAR(255), published_date DATE, country VARCHAR(255));
What is the distribution of articles published by hour of the day in the 'news_headlines' table?
SELECT HOUR(published_date) as hour_of_day, COUNT(*) as articles_published FROM news_headlines GROUP BY hour_of_day;
gretelai_synthetic_text_to_sql
CREATE TABLE Income (ID INT, FamilySize INT, Income INT, HealthInsurance BOOLEAN); INSERT INTO Income (ID, FamilySize, Income, HealthInsurance) VALUES (1, 4, 80000, TRUE); INSERT INTO Income (ID, FamilySize, Income, HealthInsurance) VALUES (2, 2, 50000, FALSE);
What is the maximum income of families with health insurance coverage in New York?
SELECT MAX(Income) FROM Income WHERE HealthInsurance = TRUE AND State = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE prison_releases (id INT, offense_type TEXT, release_date DATE, length_of_stay INT);
What is the average length of stay in prison for individuals who were released in the past year, broken down by the type of offense?
SELECT offense_type, AVG(length_of_stay) FROM prison_releases WHERE release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY offense_type;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, connection_type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers (id, connection_type, region) VALUES (1, 'broadband', 'suburban'), (2, 'broadband', 'suburban'), (3, 'dialup', 'suburban'); CREATE TABLE connection_speeds (subscriber_id INT, speed INT); INSERT INTO connection_speeds (subscriber_id, speed) VALUES (1, 550), (2, 500), (3, 100);
What is the minimum connection speed for broadband customers in the 'suburban' region?
SELECT MIN(speed) FROM connection_speeds JOIN subscribers ON connection_speeds.subscriber_id = subscribers.id WHERE subscribers.connection_type = 'broadband' AND subscribers.region = 'suburban';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT); INSERT INTO Spacecraft (id, name, manufacturer, mass) VALUES (1, 'Starship', 'AstroCorp', 1000), (2, 'Falcon9', 'SpaceX', 500);
What is the average mass of spacecraft manufactured by 'AstroCorp'?
SELECT AVG(mass) FROM Spacecraft WHERE manufacturer = 'AstroCorp';
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterVolunteers (DisasterID INT, VolunteerID INT); INSERT INTO DisasterVolunteers (DisasterID, VolunteerID) VALUES (1, 1), (2, 2);
Which disaster types have no volunteers assigned?
SELECT d.DisasterType FROM Disasters d LEFT JOIN DisasterVolunteers dv ON d.DisasterID = dv.DisasterID WHERE dv.VolunteerID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, state VARCHAR(20)); CREATE TABLE workout_data (id INT, user_id INT, date DATE, calories INT);
What is the total calories burned by users living in California on Mondays?
SELECT SUM(calories) FROM workout_data w JOIN users u ON w.user_id = u.id WHERE u.state = 'California' AND DAYOFWEEK(w.date) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_figures (drug_name TEXT, region TEXT, sales_value NUMERIC); INSERT INTO sales_figures (drug_name, region, sales_value) VALUES ('Vaxo', 'United States', 1500000), ('Curely', 'Canada', 1200000);
What is the average sales figure for the drug 'Vaxo' in the US?
SELECT AVG(sales_value) FROM sales_figures WHERE drug_name = 'Vaxo' AND region = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE reserves (country VARCHAR(255), ree_reserves INT); INSERT INTO reserves (country, ree_reserves) VALUES ('China', 44000), ('USA', 1400), ('Australia', 3800), ('India', 690), ('Brazil', 220), ('Russia', 200);
What are the total REE reserves for each country, excluding China?
SELECT country, SUM(ree_reserves) FROM reserves WHERE country NOT IN ('China') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE space_exploration (agency VARCHAR(10), mission_date DATE); INSERT INTO space_exploration (agency, mission_date) VALUES ('NASA', '1961-04-12'), ('ESA', '1975-10-10');
What is the earliest date of space exploration missions for NASA and ESA?
SELECT agency, MIN(mission_date) FROM space_exploration;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, total_assets DECIMAL(10,2)); CREATE TABLE investments (client_id INT, investment_type VARCHAR(20)); INSERT INTO clients VALUES (1,50000),(2,80000),(3,60000),(4,90000); INSERT INTO investments VALUES (1,'US Equities'),(1,'International Equities'),(2,'US Equities'),(3,'Bonds'),(4,'International Equities');
What is the total assets of clients who have invested in both US Equities and International Equities?
SELECT SUM(clients.total_assets) FROM clients INNER JOIN investments investments_1 ON clients.client_id = investments_1.client_id INNER JOIN investments investments_2 ON clients.client_id = investments_2.client_id WHERE investments_1.investment_type = 'US Equities' AND investments_2.investment_type = 'International Equities';
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, contributor VARCHAR(50), amount INT, region VARCHAR(20)); INSERT INTO funding (funding_id, contributor, amount, region) VALUES (1, 'Foundation A', 200000, 'Asia'), (2, 'Foundation B', 300000, 'Asia');
Who are the top 5 contributors to criminal justice reform in Asia by funding amount?
SELECT contributor FROM funding WHERE region = 'Asia' GROUP BY contributor ORDER BY SUM(amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(50), category VARCHAR(50), sourcing VARCHAR(50), price DECIMAL(5,2), month_sold INT); INSERT INTO menu (menu_id, menu_name, category, sourcing, price, month_sold) VALUES (22, 'Local Apple Pie', 'Desserts', 'Local', 5.99, 1), (23, 'Imported Chocolate Cake', 'Desserts', 'Imported', 8.99, 1);
What is the minimum price of a menu item in the 'Desserts' category from the 'Local' sourcing type?
SELECT MIN(price) FROM menu WHERE category = 'Desserts' AND sourcing = 'Local';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists engineering; USE engineering; CREATE TABLE if not exists bioprocess (id INT PRIMARY KEY, location VARCHAR(255), efficiency DECIMAL(4,2)); INSERT INTO bioprocess (id, location, efficiency) VALUES (1, 'Germany', 85.25), (2, 'Germany', 87.68), (3, 'USA', 82.34), (4, 'USA', 83.56);
What is the maximum bioprocess efficiency achieved in Germany?
SELECT MAX(efficiency) FROM engineering.bioprocess WHERE location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE city (city_id INT, city_name VARCHAR(20)); INSERT INTO city (city_id, city_name) VALUES (1, 'New York'), (2, 'Los Angeles'); CREATE TABLE farm_category (category_id INT, category_name VARCHAR(20)); INSERT INTO farm_category (category_id, category_name) VALUES (1, 'Urban Agriculture'), (2, 'Rural Farming'); CREATE TABLE farm (farm_id INT, farm_name VARCHAR(20), city_id INT, category_id INT); INSERT INTO farm (farm_id, farm_name, city_id, category_id) VALUES (1, 'Urban Farm 1', 1, 1), (2, 'Rural Farm 1', 2, 2);
How many farmers are there in the 'Urban Agriculture' category in the city 'New York'?
SELECT COUNT(farm_id) FROM farm WHERE city_id = (SELECT city_id FROM city WHERE city_name = 'New York') AND category_id = (SELECT category_id FROM farm_category WHERE category_name = 'Urban Agriculture');
gretelai_synthetic_text_to_sql
CREATE TABLE bulk_carriers (id INT, name VARCHAR(100), cargo_capacity INT, region VARCHAR(50));
List the names and maximum cargo capacity of bulk carriers in the Mediterranean Sea.
SELECT name, MAX(cargo_capacity) FROM bulk_carriers WHERE region = 'Mediterranean Sea' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE player (player_id INT, name VARCHAR(50), age INT, vr_game VARCHAR(50)); INSERT INTO player (player_id, name, age, vr_game) VALUES (1, 'Keisha Lee', 22, 'Beat Saber'); INSERT INTO player (player_id, name, age, vr_game) VALUES (2, 'Jordan Lee', 24, 'Superhot VR'); INSERT INTO player (player_id, name, age, vr_game) VALUES (3, 'Riley Nguyen', 19, 'Job Simulator');
What is the most popular virtual reality game among players aged 18-24?
SELECT vr_game, COUNT(*) FROM player WHERE age BETWEEN 18 AND 24 GROUP BY vr_game ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE yield_by_month (id INT, month INT, yield INT); INSERT INTO yield_by_month (id, month, yield) VALUES (1, 6, 120), (2, 7, 150), (3, 8, 180), (4, 9, 190);
What is the maximum yield for the month of August?
SELECT MAX(yield) FROM yield_by_month WHERE month = 8;
gretelai_synthetic_text_to_sql