context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE africa_events (id INT, event_type VARCHAR(30), event_year INT);INSERT INTO africa_events (id, event_type, event_year) VALUES (1, 'Sustainable Fashion', 2022), (2, 'Fashion Trend', 2021), (3, 'Sustainable Fashion', 2023), (4, 'Fashion Trend', 2020);
What is the count of 'Sustainable Fashion' related events held in 'Africa' in the year 2022?
SELECT COUNT(*) FROM africa_events WHERE event_type = 'Sustainable Fashion' AND event_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE author (author_id INT, author_name VARCHAR(50), region VARCHAR(50)); INSERT INTO author (author_id, author_name, region) VALUES (1, 'Anna Lee', 'Asia'), (2, 'Bob Smith', 'North America'), (3, 'Carla Garcia', 'South America'); CREATE TABLE article (article_id INT, author_id INT, word_count INT); INSERT INTO article (article_id, author_id, word_count) VALUES (1, 1, 1000), (2, 2, 2000), (3, 3, 1500);
What is the total word count for articles written by authors from Asia?
SELECT SUM(word_count) as total_word_count FROM article JOIN author ON article.author_id = author.author_id WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (personnel_id INT, personnel_type TEXT, rank TEXT, current_assignment TEXT);
What is the maximum number of military personnel assigned to any base in the state of Florida?
SELECT MAX(COUNT(*)) FROM military_personnel WHERE current_assignment LIKE 'Florida%';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(50), Type VARCHAR(50), Flag VARCHAR(50)); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (1, 'Aurelia', 'Tanker', 'Panama'); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (2, 'Barracuda', 'Bulk Carrier', 'Marshall Islands'); CREATE TABLE Cargo (Id INT, VesselId INT, CargoType VARCHAR(50), Quantity INT, InspectionDate DATE); INSERT INTO Cargo (Id, VesselId, CargoType, Quantity, InspectionDate) VALUES (1, 1, 'Oil', 5000, '2020-01-01'); INSERT INTO Cargo (Id, VesselId, CargoType, Quantity, InspectionDate) VALUES (2, 2, 'Coal', 8000, '2019-02-01');
What is the total quantity of cargo for each cargo type and vessel flag, grouped by year?
SELECT YEAR(Cargo.InspectionDate) as InspectionYear, Vessels.Flag, Cargo.CargoType, SUM(Cargo.Quantity) as TotalQuantity FROM Cargo JOIN Vessels ON Cargo.VesselId = Vessels.Id GROUP BY YEAR(Cargo.InspectionDate), Vessels.Flag, Cargo.CargoType;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name VARCHAR(255), date DATE); INSERT INTO events (id, name, date) VALUES (1, 'Art Exhibition', '2020-02-01'), (2, 'Music Concert', '2021-03-15'), (3, 'Theatre Performance', '2019-04-01');
Find the earliest date of an event in the 'events' table.
SELECT MIN(date) FROM events;
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (id INT PRIMARY KEY, incident VARCHAR(50), year INT);
Insert a new flight safety record for 'Tire blowout' in 2020
INSERT INTO flight_safety (id, incident, year) VALUES (6, 'Tire blowout', 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), email VARCHAR(50), signup_date DATE, signup_source VARCHAR(20));
Update the email for a specific user
UPDATE users SET email = 'new.email@example.com' WHERE id = 321 AND email = 'jamie@example.com';
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, name VARCHAR(50)); INSERT INTO otas (ota_id, name) VALUES (1, 'Expedia'), (2, 'Booking.com'), (3, 'Hotels.com'), (4, 'Agoda'), (5, 'Orbitz'); CREATE TABLE hotel_ota (hotel_id INT, ota_id INT); INSERT INTO hotel_ota (hotel_id, ota_id) VALUES (1, 1), (1, 2), (2, 2), (3, 3), (3, 4);
List the top 5 OTAs (Online Travel Agencies) with the highest number of hotel listings in the hotels and otas tables.
SELECT o.name, COUNT(ho.hotel_id) as listings_count FROM otas o JOIN hotel_ota ho ON o.ota_id = ho.ota_id GROUP BY o.name ORDER BY listings_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, department VARCHAR(255), incident_date TIMESTAMP); INSERT INTO incidents (id, department, incident_date) VALUES (1, 'finance', '2020-10-15 09:30:00'), (2, 'IT', '2020-11-20 11:00:00');
How many security incidents were there in the finance department in the last quarter?
SELECT COUNT(*) FROM incidents WHERE incident_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) AND department = 'finance';
gretelai_synthetic_text_to_sql
CREATE TABLE WaterUsageMetrics (UsageID INT PRIMARY KEY, Location VARCHAR(255), Usage INT, UsageType VARCHAR(255), Timestamp DATETIME); INSERT INTO WaterUsageMetrics (UsageID, Location, Usage, UsageType, Timestamp) VALUES (3, 'California', 300, 'Agricultural', '2022-01-01 00:00:00');
What is the minimum water usage for agricultural purposes in California in the year 2022?
SELECT UsageType, MIN(Usage) FROM WaterUsageMetrics WHERE Location = 'California' AND UsageType = 'Agricultural' AND YEAR(Timestamp) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Materials (id INT, material VARCHAR, water_consumption INT);
What is the average water consumption for producing garments from different materials?
SELECT material, AVG(water_consumption) as avg_water_consumption FROM Materials GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Continent TEXT, Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, Continent, Amount) VALUES (1, 'DonorG', 'Asia', 1800.00), (2, 'DonorH', 'Asia', 2000.00);
Update DonorG's donation to 2250.00
UPDATE Donors SET Amount = 2250.00 WHERE DonorName = 'DonorG';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founders, funding) VALUES (1, 'AsianFintech', 'Fintech', 'Asia', 12000000);
What is the maximum funding received by startups founded by individuals from Asia in the fintech sector?
SELECT MAX(funding) FROM startups WHERE industry = 'Fintech' AND founders = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_programs (country_name TEXT, budget INTEGER); INSERT INTO conservation_programs (country_name, budget) VALUES ('Costa Rica', 5000000), ('Canada', 10000000), ('Norway', 15000000);
List all countries with marine conservation programs and their budgets.
SELECT country_name, budget FROM conservation_programs;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_plants (name VARCHAR(255), capacity DECIMAL(10,2)); INSERT INTO solar_power_plants (name, capacity) VALUES ('Plant1', 1.5), ('Plant2', 2.5), ('Plant3', 3.5), ('Plant4', 4.5), ('Plant5', 5.5);
What is the total installed capacity (in GW) of solar power plants in the solar_power_plants table?
SELECT SUM(capacity) as total_capacity FROM solar_power_plants;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_name TEXT, country TEXT, approval_date DATE);
How many drugs were approved in 'Canada' in 2020?
SELECT COUNT(DISTINCT drug_name) FROM drug_approval WHERE country = 'Canada' AND EXTRACT(YEAR FROM approval_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (species VARCHAR(255), population INT); INSERT INTO animal_population (species, population) VALUES ('Tiger', 200), ('Elephant', 500), ('Lion', 300);
What is the rank order of the species in the 'animal_population' table by population size?
SELECT species, ROW_NUMBER() OVER (ORDER BY population DESC) as rank FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE country (country_id INT, country_name VARCHAR(255)); INSERT INTO country (country_id, country_name) VALUES (1, 'CountryA'), (2, 'CountryB'); CREATE TABLE co2_emission (year INT, country_id INT, co2_emission INT); INSERT INTO co2_emission (year, country_id, co2_emission) VALUES (2000, 1, 1500), (2000, 2, 2000), (2001, 1, 1600), (2001, 2, 2200), (2002, 1, 1400), (2002, 2, 1800);
What is the total CO2 emission for each country per year?
SELECT country_id, SUM(co2_emission) as total_emission FROM co2_emission GROUP BY country_id, YEAR(year)
gretelai_synthetic_text_to_sql
CREATE TABLE engagement (id INT, age_group VARCHAR(50), engagement_score INT);
What is the distribution of reader engagement by age group?
SELECT age_group, AVG(engagement_score) as avg_engagement_score FROM engagement GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50)); CREATE TABLE SafetyIncidents (ID INT, VesselID INT, Location VARCHAR(50), IncidentType VARCHAR(50)); INSERT INTO Vessels (ID, Name, Type) VALUES (1, 'Ocean Titan', 'Cargo'); INSERT INTO SafetyIncidents (ID, VesselID, Location, IncidentType) VALUES (1, 1, 'Caribbean Sea', 'Collision'); INSERT INTO SafetyIncidents (ID, VesselID, Location, IncidentType) VALUES (2, 1, 'North Sea', 'Fire'); INSERT INTO SafetyIncidents (ID, VesselID, Location, IncidentType) VALUES (3, 2, 'Caribbean Sea', 'Grounding');
Show vessels with safety incidents in both the Caribbean Sea and the North Sea.
SELECT si.VesselID FROM SafetyIncidents si WHERE si.Location IN ('Caribbean Sea', 'North Sea') GROUP BY si.VesselID HAVING COUNT(DISTINCT si.Location) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE material_data (material_name VARCHAR(50), country VARCHAR(50), industry VARCHAR(50)); INSERT INTO material_data (material_name, country, industry) VALUES ('Steel', 'Canada', 'Manufacturing'), ('Aluminum', 'Canada', 'Manufacturing'), ('Plastic', 'Canada', 'Manufacturing'), ('Glass', 'Canada', 'Manufacturing'), ('Copper', 'Germany', 'Manufacturing'), ('Steel', 'Germany', 'Manufacturing'), ('Aluminum', 'Germany', 'Manufacturing');
List all materials used in the manufacturing sector in Canada and Germany.
SELECT DISTINCT material_name FROM material_data WHERE country IN ('Canada', 'Germany') AND industry = 'Manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, volunteer_id INT, name VARCHAR(255)); INSERT INTO volunteers (id, volunteer_id, name) VALUES (1, 1, 'Avery'), (2, 2, 'Brian'), (3, 3, 'Chloe'), (4, 4, 'Dana'), (5, 5, 'Ella'); CREATE TABLE volunteer_hours (id INT, volunteer_id INT, sector VARCHAR(255), num_hours INT); INSERT INTO volunteer_hours (id, volunteer_id, sector, num_hours) VALUES (1, 1, 'Environmental', 100), (2, 1, 'Health', 150), (3, 2, 'Environmental', 75), (4, 2, 'Education', 200), (5, 3, 'Environmental', 125), (6, 3, 'Arts and Culture', 175);
Which volunteers have contributed the most hours in the environmental sector?
SELECT v.name, SUM(vh.num_hours) as total_hours FROM volunteers v JOIN volunteer_hours vh ON v.volunteer_id = vh.volunteer_id WHERE vh.sector = 'Environmental' GROUP BY v.name ORDER BY total_hours DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours_europe (location TEXT, month TEXT, engagement INT); INSERT INTO virtual_tours_europe (location, month, engagement) VALUES ('Paris', 'July', 600), ('London', 'July', 700), ('Berlin', 'July', 500), ('Madrid', 'July', 800), ('Rome', 'July', 900); CREATE TABLE locations_europe (location TEXT, region TEXT); INSERT INTO locations_europe (location, region) VALUES ('Paris', 'Europe'), ('London', 'Europe'), ('Berlin', 'Europe'), ('Madrid', 'Europe'), ('Rome', 'Europe');
What is the average engagement of virtual tours in 'Europe' in the month of 'July'?
SELECT AVG(engagement) FROM virtual_tours_europe vt JOIN locations_europe l ON vt.location = l.location WHERE l.region = 'Europe' AND vt.month = 'July';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_inspections_new (id INT PRIMARY KEY, location VARCHAR(50), inspection_date DATE, passed BOOLEAN);
Identify the number of safety inspections that failed in each location.
SELECT location, COUNT(*) as failed_inspections FROM safety_inspections_new WHERE passed = FALSE GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, num_volunteers INT, total_participants INT); INSERT INTO programs (program_id, num_volunteers, total_participants) VALUES (1, 50, 100), (2, 75, 200), (3, 100, 300);
Which programs had the highest volunteer participation rate in 2021?
SELECT program_id, (num_volunteers / total_participants) * 100 AS participation_rate FROM programs ORDER BY participation_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_fair_trade BOOLEAN); INSERT INTO products (product_id, product_name, is_fair_trade) VALUES (1, 'Fair Trade Bracelet', true), (2, 'Non-Fair Trade Bracelet', false); CREATE TABLE locations (location_id INT, country TEXT); INSERT INTO locations (location_id, country) VALUES (1, 'Egypt'), (2, 'Morocco');
What is the number of fair-trade certified accessories in Egypt?
SELECT COUNT(*) FROM products WHERE is_fair_trade = true INNER JOIN locations ON products.location_id = locations.location_id WHERE country = 'Egypt';
gretelai_synthetic_text_to_sql
CREATE TABLE workout_sessions (id INT, user_id INT, session_duration FLOAT, session_date DATE); CREATE TABLE users (id INT, name VARCHAR(255), age INT);
Find the user with the longest workout session in the current week?
SELECT u.name, MAX(session_duration) as max_duration FROM workout_sessions ws JOIN users u ON ws.user_id = u.id WHERE ws.session_date >= DATE(NOW()) - INTERVAL 1 WEEK GROUP BY u.id ORDER BY max_duration DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, astronaut_name VARCHAR, mission_status VARCHAR); CREATE TABLE Astronauts (id INT, name VARCHAR);
How many space missions were completed by each astronaut?
SELECT a.name, COUNT(sm.id) FROM Astronauts a LEFT JOIN SpaceMissions sm ON a.name = sm.astronaut_name GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_id INT, animal_species VARCHAR(255)); INSERT INTO animal_population (id, animal_id, animal_species) VALUES (1, 101, 'Giraffe'), (2, 102, 'Zebra'), (3, 103, 'Lion'), (4, 104, 'Lion'), (5, 105, 'Elephant');
Determine the number of unique animal species in the animal population data.
SELECT COUNT(DISTINCT animal_species) AS unique_species FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(255), launch_date DATE, decommission_date DATE, orbit VARCHAR(255));
What is the average lifespan (in years) of a satellite in medium Earth orbit?
SELECT AVG(lifespan) FROM (SELECT name, (JULIANDAY(decommission_date) - JULIANDAY(launch_date)) / 365.25 as lifespan FROM satellites WHERE orbit = 'medium Earth orbit') as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (vessel_name TEXT, incident_date DATE); INSERT INTO safety_incidents (vessel_name, incident_date) VALUES ('VesselD', '2020-04-05'); INSERT INTO safety_incidents (vessel_name, incident_date) VALUES ('VesselD', '2020-05-10');
How many safety incidents were recorded for 'VesselD' during Q2 of 2020?
SELECT COUNT(*) FROM safety_incidents WHERE vessel_name = 'VesselD' AND incident_date BETWEEN '2020-04-01' AND '2020-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), LaunchDate DATE, Manufacturer VARCHAR(50), Weight DECIMAL(10,2)); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, Manufacturer, Weight) VALUES (1, 'Sat1', '2022-02-01', 'SpaceCorp', 500.00), (2, 'Sat2', '2022-02-10', 'Galactic', 600.00), (3, 'Sat3', '2022-02-20', 'SpaceCorp', 700.00), (4, 'Sat4', '2022-03-01', 'AstroTech', 800.00);
What is the average weight of satellites launched by each manufacturer?
SELECT Manufacturer, AVG(Weight) AS Avg_Weight FROM Satellites GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID int, CountryName varchar(50)); CREATE TABLE LaunchProjects (ProjectID int, CountryID int, LaunchCost decimal(10,2)); INSERT INTO Countries VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'), (4, 'India'), (5, 'European Union'); INSERT INTO LaunchProjects VALUES (1, 1, 40000000), (2, 1, 50000000), (3, 2, 30000000), (4, 2, 40000000), (5, 3, 60000000), (6, 4, 25000000), (7, 5, 45000000), (8, 5, 55000000);
What are the average launch costs for each country?
SELECT c.CountryName, AVG(lp.LaunchCost) as AverageLaunchCost FROM Countries c INNER JOIN LaunchProjects lp ON c.CountryID = lp.CountryID GROUP BY c.CountryName;
gretelai_synthetic_text_to_sql
CREATE TABLE western_region (region VARCHAR(20), account_type VARCHAR(30), account_balance DECIMAL(10,2)); INSERT INTO western_region (region, account_type, account_balance) VALUES ('Western', 'Financial Wellbeing', 9000.00), ('Western', 'Financial Wellbeing', 10000.00), ('Western', 'Financial Stability', 8000.00);
What is the minimum account balance for financial wellbeing accounts in the Western region?
SELECT MIN(account_balance) FROM western_region WHERE account_type = 'Financial Wellbeing';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (id INT, location VARCHAR(50), pH FLOAT, date DATE);
Update the name of the record with id 5 in the table "ocean_acidification" to 'Increased Levels'
UPDATE ocean_acidification SET location = 'Increased Levels' WHERE id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_depth FLOAT, region VARCHAR(255)); INSERT INTO wells (well_id, well_name, well_depth, region) VALUES (1, 'A1', 3000, 'North Sea'), (2, 'B2', 2500, 'North Sea'), (3, 'C3', 4000, 'Gulf of Mexico');
Update the well depth of well 'C3' in the 'Gulf of Mexico' to 4500 feet.
UPDATE wells SET well_depth = 4500 WHERE well_name = 'C3' AND region = 'Gulf of Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (country VARCHAR(255), region VARCHAR(255), year INT, events INT); INSERT INTO defense_diplomacy (country, region, year, events) VALUES ('Russia', 'Asia-Pacific', 2015, 15), ('Russia', 'Asia-Pacific', 2016, 18), ('Russia', 'Asia-Pacific', 2017, 22);
How many defense diplomacy events were held by Russia in the Asia-Pacific region between 2015 and 2017?
SELECT SUM(events) as total_events FROM defense_diplomacy WHERE country = 'Russia' AND region = 'Asia-Pacific' AND year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, quantity INT); INSERT INTO production VALUES ('Neodymium', 2015, 2200), ('Neodymium', 2016, 2300), ('Neodymium', 2017, 2400), ('Neodymium', 2018, 2500), ('Neodymium', 2019, 2600);
What is the total production quantity of Neodymium in 2018 and 2019?
SELECT SUM(quantity) FROM production WHERE element = 'Neodymium' AND year IN (2018, 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, port_id INT, speed FLOAT); INSERT INTO vessels (id, name, port_id, speed) VALUES (1, 'VesselA', 1, 20.5), (2, 'VesselB', 1, 21.3), (3, 'VesselC', 2, 25.0);
Delete the record of the vessel 'VesselA' from the table 'vessels' if it exists.
DELETE FROM vessels WHERE name = 'VesselA';
gretelai_synthetic_text_to_sql
CREATE TABLE CarbonSequestration (id INT, name VARCHAR(255), region VARCHAR(255), year INT, sequestration FLOAT); INSERT INTO CarbonSequestration (id, name, region, year, sequestration) VALUES (1, 'Boreal Forest', 'Canada', 2020, 6.5);
Calculate the total carbon sequestration in boreal forests in Canada.
SELECT SUM(sequestration) FROM CarbonSequestration WHERE name = 'Boreal Forest' AND region = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(100), Age INT, Genre VARCHAR(50), TicketsSold INT); INSERT INTO Artists (ArtistID, ArtistName, Age, Genre, TicketsSold) VALUES (1, 'Artist A', 35, 'Country', 3000), (2, 'Artist B', 45, 'Jazz', 4000), (3, 'Artist C', 28, 'Pop', 5000), (4, 'Artist D', 50, 'Country', 2500), (5, 'Artist E', 42, 'Country', 1500), (6, 'Artist F', 48, 'Jazz', 6000);
What is the median age of country artists who have sold more than 1000 tickets?
SELECT AVG(Age) FROM (SELECT ArtistName, Age FROM Artists WHERE Genre = 'Country' AND TicketsSold > 1000 ORDER BY Age) AS Subquery ORDER BY Age LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyTypeClaims (PolicyType VARCHAR(20), ClaimDate DATE); INSERT INTO PolicyTypeClaims (PolicyType, ClaimDate) VALUES ('Auto', '2023-01-01'), ('Auto', '2023-02-01'), ('Home', '2023-01-01'), ('Home', '2023-02-01'), ('Life', '2023-01-01'), ('Life', '2023-02-01'), ('Auto', '2023-03-01'), ('Auto', '2023-04-01'), ('Home', '2023-03-01'), ('Home', '2023-04-01'), ('Life', '2023-03-01'), ('Life', '2023-04-01');
What are the top 3 policy types with the highest number of claims in the last 6 months?
SELECT PolicyType, COUNT(*) OVER (PARTITION BY PolicyType) AS ClaimCount, RANK() OVER (ORDER BY COUNT(*) DESC) AS RankClaimCount FROM PolicyTypeClaims WHERE ClaimDate >= DATEADD(month, -6, CURRENT_DATE) GROUP BY PolicyType;
gretelai_synthetic_text_to_sql
CREATE TABLE tb_data (id INT, country TEXT, year INT, cases INT); INSERT INTO tb_data (id, country, year, cases) VALUES (1, 'Mexico', 2018, 500), (2, 'Mexico', 2019, 600);
What is the change in the number of tuberculosis cases between consecutive years, for each country?
SELECT country, year, cases, LAG(cases) OVER (PARTITION BY country ORDER BY year) as prev_year_cases, cases - LAG(cases) OVER (PARTITION BY country ORDER BY year) as change FROM tb_data;
gretelai_synthetic_text_to_sql
CREATE TABLE Production (Id INT, Mine_Site VARCHAR(50), Material VARCHAR(50), Quantity INT, Date DATE); INSERT INTO Production (Id, Mine_Site, Material, Quantity, Date) VALUES (1, 'SiteA', 'Coal', 550, '2020-01-01'); INSERT INTO Production (Id, Mine_Site, Material, Quantity, Date) VALUES (2, 'SiteB', 'Coal', 620, '2020-01-02');
What is the total coal production per mine site in January 2020, only showing sites with production over 600?
SELECT Mine_Site, SUM(Quantity) as Total_Production FROM Production WHERE Material = 'Coal' AND Date >= '2020-01-01' AND Date < '2020-02-01' GROUP BY Mine_Site HAVING Total_Production > 600;
gretelai_synthetic_text_to_sql
CREATE TABLE underwriting (id INT, group VARCHAR(10), name VARCHAR(20), claim_amount DECIMAL(10,2)); INSERT INTO underwriting (id, group, name, claim_amount) VALUES (1, 'High Risk', 'John Doe', 5000.00), (2, 'Low Risk', 'Jane Smith', 2000.00), (3, 'High Risk', 'Mike Johnson', 7000.00);
List the policyholders in the 'High Risk' underwriting group, ordered by claim amount from highest to lowest.
SELECT name, claim_amount FROM underwriting WHERE group = 'High Risk' ORDER BY claim_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(20)); INSERT INTO companies (id, name) VALUES (1, 'ABC Shipping'), (2, 'DEF Marine'), (3, 'GHI Navigation'); CREATE TABLE vessels (id INT, company_id INT); INSERT INTO vessels (id, company_id) VALUES (1, 1), (2, 2), (3, 3), (4, 2), (5, 1);
What is the number of vessels owned by company 'DEF Marine'?
SELECT COUNT(*) FROM vessels WHERE company_id = (SELECT id FROM companies WHERE name = 'DEF Marine');
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, client_id INT, outcome VARCHAR(10)); CREATE TABLE clients (client_id INT, age INT, gender VARCHAR(6), income DECIMAL(10,2)); INSERT INTO cases (case_id, client_id, outcome) VALUES (1, 1, 'Win'), (2, 2, 'Loss'); INSERT INTO clients (client_id, age, gender, income) VALUES (1, 35, 'Female', 50000.00), (2, 45, 'Male', 60000.00);
What is the average income of clients who won their cases?
SELECT AVG(income) FROM clients c JOIN cases cs ON c.client_id = cs.client_id WHERE cs.outcome = 'Win';
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT);
Show all records from the Inventory table where the item_name is 'Oranges' and the quantity is greater than 25
SELECT * FROM Inventory WHERE item_name = 'Oranges' AND quantity > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, vendor_state VARCHAR(2));
Find the total count of defense contracts awarded to vendors based in California
SELECT COUNT(*) FROM defense_contracts WHERE vendor_state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE Research.Species ( id INT, species_name VARCHAR(255), population INT );
Show the species names and their respective populations in descending order in the 'Research' schema's 'Species' table
SELECT species_name, population FROM Research.Species ORDER BY population DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SanFrancisco_Properties (PropertyID INT, Owner VARCHAR(255), Price INT); INSERT INTO SanFrancisco_Properties (PropertyID, Owner, Price) VALUES (1, 'David', 900000), (2, 'Danielle', 800000), (3, 'David', 700000), (4, 'Danielle', 600000);
Determine the total property value owned by a specific individual in San Francisco.
SELECT SUM(Price) FROM SanFrancisco_Properties WHERE Owner = 'David';
gretelai_synthetic_text_to_sql
CREATE TABLE detentions (id INT, region VARCHAR(50), year INT, num_vessels INT); INSERT INTO detentions (id, region, year, num_vessels) VALUES (1, 'Indian Ocean', 2018, 9), (2, 'Indian Ocean', 2019, 12), (3, 'Indian Ocean', 2020, NULL);
How many vessels were detained for maritime safety violations in the Indian Ocean in 2020?
SELECT num_vessels FROM detentions WHERE region = 'Indian Ocean' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, name VARCHAR(30)); INSERT INTO Programs (id, name) VALUES (1, 'Community Education Program 1'), (2, 'Habitat Restoration Program 2'); CREATE TABLE Animals_In_Programs (program_id INT, animal_id INT, species VARCHAR(20)); INSERT INTO Animals_In_Programs (program_id, animal_id, species) VALUES (1, 1, 'Tiger'), (1, 2, 'Elephant'), (2, 3, 'Lion'), (2, 4, 'Zebra');
How many different species are there in 'Community Education Program 1'?
SELECT COUNT(DISTINCT species) FROM Animals_In_Programs WHERE program_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE actor_ip (id INT, threat_actor VARCHAR(255), ip_address VARCHAR(255)); INSERT INTO actor_ip (id, threat_actor, ip_address) VALUES (1, 'APT28', '192.168.1.1'), (2, 'APT33', '10.0.0.1'), (3, 'APT34', '192.168.1.2'), (4, 'APT29', '10.0.0.2'), (5, 'APT35', '192.168.1.3'), (6, 'APT28', '10.0.0.3');
What are the unique IP addresses that have been associated with 'APT35' threat actor?
SELECT DISTINCT ip_address FROM actor_ip WHERE threat_actor = 'APT35';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(20), contact_name VARCHAR(20), contact_phone VARCHAR(15), last_supply DATE);
Delete the record of the supplier 'ABC Corp' from the 'Suppliers' table.
DELETE FROM Suppliers WHERE supplier_name = 'ABC Corp';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_assessment (student_id INT, school_id INT, passed_assessment INT); INSERT INTO mental_health_assessment (student_id, school_id, passed_assessment) VALUES (1, 101, 1), (2, 101, 0), (3, 102, 1), (4, 102, 1), (5, 103, 0);
What is the percentage of students who have passed the mental health assessment in each school?
SELECT school_id, (SUM(passed_assessment)::float / COUNT(student_id)::float) * 100 as pass_percentage FROM mental_health_assessment GROUP BY school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE gold_mines (id INT, worker_role TEXT, productivity FLOAT, extraction_year INT); INSERT INTO gold_mines (id, worker_role, productivity, extraction_year) VALUES (1, 'Engineer', 12.5, 2020), (2, 'Miner', 8.3, 2020), (3, 'Supervisor', 10.8, 2020);
What is the average productivity of workers in the gold mines, categorized by their roles, for the year 2020?
SELECT worker_role, AVG(productivity) FROM gold_mines WHERE extraction_year = 2020 GROUP BY worker_role;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_chatbot BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, ai_chatbot) VALUES (1, 'Hotel A', 'France', TRUE), (2, 'Hotel B', 'France', FALSE), (3, 'Hotel C', 'France', TRUE);
How many hotels in France have adopted AI-based chatbots for customer service?
SELECT COUNT(*) FROM hotels WHERE country = 'France' AND ai_chatbot = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, ProviderID INT); INSERT INTO CommunityHealthWorker (WorkerID, ProviderID) VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 1), (7, 2), (8, 3), (9, 4), (10, 5);
Find the number of community health workers served by each mental health provider.
SELECT ProviderID, COUNT(*) as NumWorkers FROM CommunityHealthWorker GROUP BY ProviderID;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, country TEXT, founding_date DATE, founder_native BOOLEAN); INSERT INTO company (id, name, country, founding_date, founder_native) VALUES (1, 'Sigma Corp', 'Canada', '2015-01-01', TRUE); INSERT INTO company (id, name, country, founding_date, founder_native) VALUES (2, 'Tau Inc', 'Canada', '2018-01-01', FALSE);
What was the average funding amount for startups founded by individuals who identify as Native American or Indigenous in Canada?
SELECT AVG(funding_amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.country = 'Canada' AND company.founder_native = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_fairness (model_name TEXT, fairness_score INTEGER, contributor_ethnicity TEXT); INSERT INTO ai_fairness (model_name, fairness_score, contributor_ethnicity) VALUES ('ModelX', 95, 'Latinx'), ('ModelY', 88, 'Asian'), ('ModelZ', 98, 'African American'), ('ModelW', 76, 'Latinx');
Minimum fairness score for AI models submitted by Latinx contributors?
SELECT MIN(fairness_score) FROM ai_fairness WHERE contributor_ethnicity = 'Latinx';
gretelai_synthetic_text_to_sql
CREATE TABLE videos_channel (id INT, title TEXT, channel TEXT, published_date DATE); INSERT INTO videos_channel (id, title, channel, published_date) VALUES (1, 'Video1', 'ChannelX', '2021-12-31'), (2, 'Video2', 'ChannelY', '2022-01-01');
What's the total number of videos published by 'ChannelX'?
SELECT COUNT(*) FROM videos_channel WHERE channel = 'ChannelX';
gretelai_synthetic_text_to_sql
CREATE TABLE stadiums (id INT, name VARCHAR(50), capacity INT, sport VARCHAR(20));
What is the maximum number of spectators in a rugby stadium?
SELECT MAX(capacity) FROM stadiums WHERE sport = 'Rugby';
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatReports (id INT, type VARCHAR(255), report_count INT);
Find the number of threat reports for each type in the 'ThreatReports' table
SELECT type, SUM(report_count) as total_reports FROM ThreatReports GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, country VARCHAR(50), labor_rights_violations INT);
What is the total number of labor rights violations, by country, for suppliers in the past 6 months?
SELECT country, SUM(labor_rights_violations) as total_violations FROM suppliers WHERE date >= DATEADD(month, -6, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (rid INT, name VARCHAR(255)); CREATE TABLE response_teams (tid INT, rid INT, capacity INT); INSERT INTO regions VALUES (1, 'Northeast'), (2, 'Southeast'); INSERT INTO response_teams VALUES (1, 1, 10), (2, 1, 20), (3, 2, 15);
What is the maximum number of disaster response teams in each region?
SELECT r.name, MAX(rt.capacity) as max_capacity FROM regions r JOIN response_teams rt ON r.rid = rt.rid GROUP BY r.rid;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50));CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), ProductCategory VARCHAR(50), QuantitySold INT); INSERT INTO Regions VALUES (1, 'Northeast'), (2, 'Southeast'); INSERT INTO Products VALUES (1, 'Apples', 'Fruit', 100), (2, 'Bananas', 'Fruit', 150), (3, 'Carrots', 'Vegetable', 200), (4, 'Potatoes', 'Vegetable', 50), (5, 'Bread', 'Bakery', 300);
What is the total quantity of fruits and vegetables sold in each region?
SELECT r.RegionName, p.ProductCategory, SUM(p.QuantitySold) as TotalQuantitySold FROM Regions r JOIN Products p ON r.RegionID = 1 GROUP BY r.RegionName, p.ProductCategory HAVING p.ProductCategory IN ('Fruit', 'Vegetable');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Country VARCHAR(50), Salary DECIMAL(10, 2)); INSERT INTO Employees (EmployeeID, Country, Salary) VALUES (1, 'USA', 50000.00), (2, 'Canada', 60000.00), (3, 'Mexico', 55000.00), (4, 'Brazil', 70000.00); CREATE TABLE Countries (Country VARCHAR(50), Continent VARCHAR(50)); INSERT INTO Countries (Country, Continent) VALUES ('USA', 'North America'), ('Canada', 'North America'), ('Mexico', 'North America'), ('Brazil', 'South America');
What is the total salary paid to employees in each country?
SELECT Country, SUM(Salary) as TotalSalary FROM Employees JOIN Countries ON Employees.Country = Countries.Country GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralHealthFacilities (FacilityID INT, Name VARCHAR(50), Address VARCHAR(100), TotalBeds INT, NumberOfDoctors INT);
Insert a new record for a rural health facility 'Harmony Clinic' with 35 total beds and 5 doctors.
INSERT INTO RuralHealthFacilities (Name, Address, TotalBeds, NumberOfDoctors) VALUES ('Harmony Clinic', '100 Harmony Way', 35, 5);
gretelai_synthetic_text_to_sql
CREATE TABLE PIs (PIID INT, PIName VARCHAR(50)); CREATE TABLE Grants (GrantID INT, PIID INT, GrantAmount DECIMAL(10,2)); INSERT INTO PIs (PIID, PIName) VALUES (1, 'Sophia Garcia'); INSERT INTO Grants (GrantID, PIID, GrantAmount) VALUES (1, 1, 50000); INSERT INTO Grants (GrantID, PIID, GrantAmount) VALUES (2, 1, 75000); INSERT INTO Grants (GrantID, PIID, GrantAmount) VALUES (3, 2, 100000);
Calculate the average grant amount awarded to each principal investigator
SELECT p.PIName, AVG(g.GrantAmount) as AvgGrantAmount FROM PIs p JOIN Grants g ON p.PIID = g.PIID GROUP BY p.PIName;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(50), industry VARCHAR(50), founding_year INT, founder_community VARCHAR(50)); INSERT INTO companies (id, name, industry, founding_year, founder_community) VALUES (1, 'Delta Inc', 'Retail', 2016, 'Latinx'), (2, 'Echo Corp', 'Tech', 2017, 'Asian'), (3, 'Foxtrot LLC', 'Retail', 2018, 'Black'), (4, 'Gamma Inc', 'Healthcare', 2015, 'White');
Which industry has the most companies founded by individuals from underrepresented communities?
SELECT c.industry, COUNT(*) FROM companies c WHERE c.founder_community <> 'White' GROUP BY c.industry ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE trips (age_group varchar(20), city varchar(20), quarter int, trips int); INSERT INTO trips (age_group, city, quarter, trips) VALUES ('Senior Citizens', 'New York City', 1, 150000);
How many public transportation trips were taken by senior citizens in New York City in Q1 2023?
SELECT trips FROM trips WHERE age_group = 'Senior Citizens' AND city = 'New York City' AND quarter = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), PRIMARY KEY(id)); INSERT INTO factories (id, name, location, type) VALUES (20, 'Recycled Plastic Factories', 'China', 'Factory'); CREATE TABLE workers (id INT, name VARCHAR(255), position VARCHAR(255), factory_id INT, PRIMARY KEY(id), FOREIGN KEY (factory_id) REFERENCES factories(id)); INSERT INTO workers (id, name, position, factory_id) VALUES (21, 'Li Wong', 'Mechanic', 20), (22, 'Zhang Li', 'Recycling Technician', 20);
What is the total number of workers in recycled plastic factories?
SELECT COUNT(*) FROM workers WHERE factory_id = (SELECT id FROM factories WHERE name = 'Recycled Plastic Factories' AND type = 'Factory');
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (ticket_id INT, customer_id INT, event_type VARCHAR(50), price DECIMAL(10,2), city VARCHAR(50)); CREATE TABLE customers (customer_id INT, name VARCHAR(50), is_recurring BOOLEAN); INSERT INTO customers (customer_id, name, is_recurring) VALUES (1, 'Michael Johnson', TRUE), (2, 'Sarah Lee', FALSE); INSERT INTO tickets (ticket_id, customer_id, event_type, price, city) VALUES (1, 1, 'Music Concert', 50.00, 'Los Angeles'), (2, 2, 'Music Concert', 75.00, 'Los Angeles');
What is the total number of tickets sold for music concerts in Los Angeles by recurring customers?
SELECT SUM(t.price) AS total_sales FROM tickets t JOIN customers c ON t.customer_id = c.customer_id WHERE c.city = 'Los Angeles' AND c.is_recurring = TRUE AND t.event_type = 'Music Concert';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), donation_date DATE, region TEXT); INSERT INTO donations (donation_id, donation_amount, donation_date, region) VALUES (1, 500, '2021-01-01', 'North America'), (2, 300, '2021-02-03', 'Europe'), (3, 100, '2021-02-04', 'North America'), (4, 200, '2021-03-05', 'Europe');
What is the total donation amount for each region?
SELECT region, SUM(donation_amount) FROM donations GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE north_sea_oil_daily (date DATE, oil_production DECIMAL(10,2));
What is the average daily oil production for the North Sea, broken down by month, for the year 2019?
SELECT EXTRACT(MONTH FROM nsod.date) as month, AVG(nsod.oil_production) FROM north_sea_oil_daily nsod WHERE EXTRACT(YEAR FROM nsod.date) = 2019 GROUP BY EXTRACT(MONTH FROM nsod.date);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'Australia'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'New Zealand'); CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventName VARCHAR(50)); CREATE TABLE VRAdoption (PlayerID INT, VRPurchaseDate DATE);
What is the maximum age of players who have not adopted VR technology and have not participated in esports events?
SELECT MAX(Players.Age) FROM Players LEFT JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID LEFT JOIN VRAdoption ON Players.PlayerID = VRAdoption.PlayerID WHERE EsportsEvents.PlayerID IS NULL AND VRAdoption.PlayerID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (union_id INT, union_name TEXT, advocacy TEXT, workplace_incidents INT); INSERT INTO unions (union_id, union_name, advocacy, workplace_incidents) VALUES (1001, 'United Steelworkers', 'labor rights', 25); INSERT INTO unions (union_id, union_name, advocacy, workplace_incidents) VALUES (1002, 'Transport Workers Union', 'collective bargaining', 30);
What is the total number of unions advocating for labor rights and their total number of workplace incidents?
SELECT u.advocacy, SUM(u.workplace_incidents), COUNT(u.union_id) FROM unions u WHERE u.advocacy = 'labor rights' GROUP BY u.advocacy;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_providers (id INT, name VARCHAR(50), age INT, completed_training_parity BOOLEAN); INSERT INTO mental_health_providers (id, name, age, completed_training_parity) VALUES (1, 'Sarah Lee', 45, true), (2, 'Mohammed Ahmed', 35, false), (3, 'Emily Chen', 50, true);
How many mental health providers have completed training on mental health parity?
SELECT COUNT(*) FROM mental_health_providers WHERE completed_training_parity = true;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50)); INSERT INTO customers VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Alice Johnson'); CREATE TABLE orders (order_id INT, customer_id INT, menu_id INT, order_date DATE); INSERT INTO orders VALUES (1, 1, 1, '2022-01-01'), (2, 2, 3, '2022-01-02'), (3, 3, 2, '2022-01-03'); CREATE TABLE menu (menu_id INT, item_name VARCHAR(50), is_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO menu VALUES (1, 'Veggie Burger', true, 8.99), (2, 'Cheeseburger', false, 7.99), (3, 'Tofu Stir Fry', true, 11.99); CREATE TABLE revenue (order_id INT, revenue DECIMAL(5,2)); INSERT INTO revenue VALUES (1, 8.99), (2, 11.99), (3, 7.99);
Who are the top 5 customers with the highest spending on vegan dishes?
SELECT customers.customer_name, SUM(revenue) as total_spending FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id INNER JOIN menu ON orders.menu_id = menu.menu_id INNER JOIN revenue ON orders.order_id = revenue.order_id WHERE menu.is_vegan = true GROUP BY customers.customer_name ORDER BY total_spending DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'New York'); CREATE TABLE families (id INT, state_id INT, children_under_18 BOOLEAN, income FLOAT); INSERT INTO families (id, state_id, children_under_18, income) VALUES (1, 1, true, 55000), (2, 1, true, 65000), (3, 1, false, 75000), (4, 1, true, 45000);
What is the average income in New York for families with children under 18 years old, and what is the percentage of families with incomes above the state average?
SELECT AVG(families.income) AS avg_income, AVG(families.income > (SELECT AVG(income) FROM families WHERE children_under_18 = true)) * 100 AS pct_above_avg_income FROM families WHERE children_under_18 = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID int, CountryName varchar(50)); CREATE TABLE SafetyInspections (InspectionID int, CountryID int, InspectionScore int); INSERT INTO Countries VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'), (4, 'India'), (5, 'European Union'); INSERT INTO SafetyInspections VALUES (1, 1, 95), (2, 1, 92), (3, 1, 98), (4, 2, 85), (5, 2, 88), (6, 2, 90), (7, 3, 82), (8, 3, 87), (9, 3, 91), (10, 4, 95), (11, 4, 97), (12, 4, 93), (13, 5, 96), (14, 5, 98), (15, 5, 99);
What are the minimum, maximum, and average safety inspection scores for each country?
SELECT c.CountryName, MIN(si.InspectionScore) as MinimumScore, MAX(si.InspectionScore) as MaximumScore, AVG(si.InspectionScore) as AverageScore FROM Countries c INNER JOIN SafetyInspections si ON c.CountryID = si.CountryID GROUP BY c.CountryName;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (worker_id INT, job_title VARCHAR(255), sector VARCHAR(255), salary DECIMAL(10,2)); INSERT INTO workers (worker_id, job_title, sector, salary) VALUES (1, 'Engineer', 'Renewable Energy', 75000.00), (2, 'Technician', 'Renewable Energy', 45000.00), (3, 'Manager', 'Renewable Energy', 90000.00);
What is the average salary of workers in the renewable energy sector, grouped by their job title?
SELECT job_title, AVG(salary) FROM workers WHERE sector = 'Renewable Energy' GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipment (id INT, source_country VARCHAR(255), destination_country VARCHAR(255), items_quantity INT, shipment_date DATE); INSERT INTO Shipment (id, source_country, destination_country, items_quantity, shipment_date) VALUES (1, 'France', 'Brazil', 100, '2021-03-01'), (2, 'France', 'Brazil', 200, '2021-02-01');
What are the total items shipped between France and Brazil, excluding items shipped in March 2021?
SELECT SUM(items_quantity) FROM Shipment WHERE (source_country = 'France' AND destination_country = 'Brazil') OR (source_country = 'Brazil' AND destination_country = 'France') AND shipment_date NOT BETWEEN '2021-03-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation (continent VARCHAR(50), investment INT, year INT); INSERT INTO climate_mitigation (continent, investment, year) VALUES ('Africa', 2000000, 2019), ('Asia', 3000000, 2019), ('Europe', 5000000, 2019);
What is the average investment in climate mitigation for each continent in 2019?
SELECT continent, AVG(investment) as avg_investment FROM climate_mitigation WHERE year = 2019 GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), sport VARCHAR(20), date DATE, attendance INT);
Show the number of fans attending the upcoming ice hockey matches
SELECT attendance FROM matches WHERE sport = 'Ice hockey' AND date > CURDATE() GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_sales(product_name TEXT, quantity INTEGER, is_gluten_free BOOLEAN, sale_date DATE); INSERT INTO cosmetics_sales(product_name, quantity, is_gluten_free, sale_date) VALUES('Gluten-Free Makeup Remover 1', 75, true, '2022-01-05');
How many gluten-free cosmetics were sold in January 2022?
SELECT SUM(quantity) FROM cosmetics_sales WHERE is_gluten_free = true AND sale_date >= '2022-01-01' AND sale_date < '2022-02-01';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, program_id VARCHAR(20)); INSERT INTO volunteers (volunteer_id, program_id) VALUES (1, 'Education'), (2, 'Health'), (3, 'Education'); CREATE TABLE donations (donor_id INT, program_id VARCHAR(20)); INSERT INTO donations (donor_id, program_id) VALUES (1, 'Education'), (2, 'Health'), (4, 'Education');
How many unique volunteers have donated for each program?
SELECT program_id, COUNT(DISTINCT v.volunteer_id) AS unique_volunteer_donors FROM volunteers v JOIN donations d ON v.program_id = d.program_id GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_capacity (country VARCHAR(255), energy_source VARCHAR(255), capacity FLOAT); INSERT INTO energy_capacity (country, energy_source, capacity) VALUES ('Japan', 'Solar', 50000), ('Japan', 'Wind', 20000), ('India', 'Solar', 80000), ('India', 'Wind', 35000), ('Thailand', 'Solar', 30000), ('Thailand', 'Wind', 15000);
What is the total installed capacity of solar and wind energy in Japan, India, and Thailand?
SELECT SUM(capacity) FROM energy_capacity WHERE (country IN ('Japan', 'India', 'Thailand') AND energy_source IN ('Solar', 'Wind'));
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_species (id INT, species VARCHAR(255), biomass FLOAT); INSERT INTO arctic_species (id, species, biomass) VALUES (1, 'polar_bear', 800.0), (2, 'arctic_fox', 3.0);
What is the total biomass of each species in the 'arctic_species' table?
SELECT species, SUM(biomass) as total_biomass FROM arctic_species GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); INSERT INTO products (id, name, category, supplier_id) VALUES (3, 'Rice', 'Grains', 3); CREATE TABLE orders (id INT PRIMARY KEY, product_id INT, order_date DATE, quantity INT, FOREIGN KEY (product_id) REFERENCES products(id)); INSERT INTO orders (id, product_id, order_date, quantity) VALUES (3, 3, '2022-01-07', 50);
What is the total quantity of 'Rice' products ordered?
SELECT SUM(quantity) FROM orders WHERE product_id = (SELECT id FROM products WHERE name = 'Rice');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(100), role VARCHAR(50), salary FLOAT); INSERT INTO mining_operations (id, name, role, salary) VALUES (1, 'John Doe', 'Mining Engineer', 75000.00); INSERT INTO mining_operations (id, name, role, salary) VALUES (2, 'Jane Smith', 'Geologist', 60000.00); INSERT INTO mining_operations (id, name, role, salary) VALUES (3, 'Robert Johnson', 'Manager', 90000.00);
Update the salary of the employee with ID 2 in the 'mining_operations' table to 65000.00.
UPDATE mining_operations SET salary = 65000.00 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerationAsia (country VARCHAR(50), year INT, waste_quantity INT); INSERT INTO WasteGenerationAsia (country, year, waste_quantity) VALUES ('China', 2017, 120000), ('China', 2018, 130000), ('China', 2019, 140000), ('India', 2017, 90000), ('India', 2018, 95000), ('India', 2019, 100000);
What is the waste generation trend in Asia between 2017 and 2019, grouped by year?
SELECT year, AVG(waste_quantity) FROM WasteGenerationAsia WHERE year BETWEEN 2017 AND 2019 GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (ProjectID INT, Contractor VARCHAR(50), Country VARCHAR(50), ProjectName VARCHAR(50), StartDate DATE, EndDate DATE, ProjectValue DECIMAL(10, 2), Status VARCHAR(20)); INSERT INTO DefenseProjects (ProjectID, Contractor, Country, ProjectName, StartDate, EndDate, ProjectValue, Status) VALUES (5, 'Lockheed Martin', 'United States', 'Fighter Jet Production', '2021-01-01', '2023-01-01', 30000000, 'Ongoing'); INSERT INTO DefenseProjects (ProjectID, Contractor, Country, ProjectName, StartDate, EndDate, ProjectValue, Status) VALUES (6, 'Boeing', 'Canada', 'Helicopter Assembly', '2022-01-15', '2024-01-14', 25000000, 'Ongoing');
What is the total value of ongoing defense projects for each country?
SELECT Country, SUM(ProjectValue) AS TotalProjectValue FROM DefenseProjects WHERE Status = 'Ongoing' GROUP BY Country
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_bugs (model_id INT, region VARCHAR(50), bugs INT); INSERT INTO fairness_bugs (model_id, region, bugs) VALUES (1, 'Latin America', 2), (2, 'Europe', 0), (3, 'Latin America', 3), (4, 'North America', 1), (5, 'Africa', 4);
What is the average number of algorithmic fairness bugs in models developed in Latin America?
SELECT AVG(bugs) FROM fairness_bugs WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_missions (id INT, country VARCHAR, population INT);
What is the average population of countries involved in humanitarian assistance missions?
SELECT country, AVG(population) FROM humanitarian_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (report_id INT, report_name VARCHAR(255), shared_with VARCHAR(255), sharing_status VARCHAR(255), report_date DATE); INSERT INTO threat_intelligence (report_id, report_name, shared_with, sharing_status, report_date) VALUES (1, 'Cyber Threat Report', 'NATO', 'Shared', '2020-02-10'); INSERT INTO threat_intelligence (report_id, report_name, shared_with, sharing_status, report_date) VALUES (2, 'Geopolitical Analysis', 'AU', 'Not Shared', '2020-05-25');
List all threat intelligence reports that were shared with NATO allies between January 1, 2020 and December 31, 2020, along with their sharing status.
SELECT report_name, shared_with, sharing_status FROM threat_intelligence WHERE report_date BETWEEN '2020-01-01' AND '2020-12-31' AND shared_with = 'NATO';
gretelai_synthetic_text_to_sql
CREATE TABLE ForeignMilitaryAid (Year INT, Country VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO ForeignMilitaryAid (Year, Country, Amount) VALUES (2005, 'Afghanistan', 5000000), (2006, 'Iraq', 7000000);
Delete all records from the table 'ForeignMilitaryAid' for the year 2005.
DELETE FROM ForeignMilitaryAid WHERE Year = 2005;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, Title VARCHAR(50), Gallery VARCHAR(50)); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (1, 'Starry Night', 'ImpressionistGallery'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (2, 'Sunflowers', 'ImpressionistGallery'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (3, 'Untitled', 'ContemporaryArt'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (4, 'Untitled2', 'ContemporaryArt'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (5, 'Untitled3', 'ContemporaryArt');
How many artworks are in the 'ContemporaryArt' gallery?
SELECT COUNT(*) FROM Artworks WHERE Gallery = 'ContemporaryArt';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, city VARCHAR(255), construction_date DATE, carbon_offset INT);
What is the average carbon offset of green buildings constructed in Q1 2021, grouped by city?
SELECT city, AVG(carbon_offset) FROM green_buildings WHERE construction_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY city;
gretelai_synthetic_text_to_sql