context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE guardian (article_id INT, title TEXT, author TEXT, category TEXT, publisher TEXT); INSERT INTO guardian (article_id, title, author, category, publisher) VALUES (1, 'Article 1', 'Author 1', 'Technology', 'The Guardian'), (2, 'Article 2', 'Author 2', 'Politics', 'The Guardian');
Find the unique authors who have written for 'The Guardian' in the technology category.
SELECT DISTINCT author FROM guardian WHERE category = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE projects_eastern_europe (id INT, region VARCHAR(50), investment FLOAT); INSERT INTO projects_eastern_europe (id, region, investment) VALUES (1, 'Eastern Europe', 600000); INSERT INTO projects_eastern_europe (id, region, investment) VALUES (2, 'Eastern Europe', 700000);
What is the minimum investment required for any project in Eastern Europe?
SELECT MIN(investment) FROM projects_eastern_europe WHERE region = 'Eastern Europe';
gretelai_synthetic_text_to_sql
CREATE SCHEMA urban_agriculture;CREATE TABLE community_gardens (id INT, name VARCHAR(50), area_ha FLOAT);
How many community gardens in the 'urban_agriculture' schema have an area of more than 0.5 hectares?
SELECT COUNT(*) FROM urban_agriculture.community_gardens WHERE area_ha > 0.5;
gretelai_synthetic_text_to_sql
CREATE TABLE African_Arts (Art_ID INT, Art_Type VARCHAR(50), Artists_Count INT); INSERT INTO African_Arts (Art_ID, Art_Type, Artists_Count) VALUES (1, 'Adire', 50); INSERT INTO African_Arts (Art_ID, Art_Type, Artists_Count) VALUES (2, 'Batik', 75); INSERT INTO African_Arts (Art_ID, Art_Type, Artists_Count) VALUES (3, 'Pottery', 35); INSERT INTO African_Arts (Art_ID, Art_Type, Artists_Count) VALUES (4, 'Weaving', 45);
What are the top 3 art types by the number of artists involved in Africa?
SELECT Art_Type, MAX(Artists_Count) FROM (SELECT Art_Type, Artists_Count FROM African_Arts) GROUP BY Art_Type ORDER BY MAX(Artists_Count) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE VendorType (VendorID INT, VendorType VARCHAR(50)); INSERT INTO VendorType (VendorID, VendorType) VALUES (1, 'Gourmet'), (2, 'Standard'); CREATE TABLE VeganDishes (MenuID INT, VendorID INT, DishName VARCHAR(50), DishType VARCHAR(50), Price DECIMAL(5,2)); INSERT INTO VeganDishes (MenuID, VendorID, DishName, DishType, Price) VALUES (1, 1, 'Tofu Stir Fry', 'Vegan', 14.99), (2, 1, 'Vegan Sushi', 'Vegan', 12.99), (3, 2, 'Vegan Burger', 'Vegan', 9.99);
What is the maximum price of vegan dishes offered by gourmet vendors?
SELECT MAX(Price) FROM VeganDishes WHERE VendorID IN (SELECT VendorID FROM VendorType WHERE VendorType = 'Gourmet') AND DishType = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (id INT, workplace_id INT, member_name TEXT, member_join_date DATE, member_status TEXT); CREATE TABLE workplaces (id INT, name TEXT, location TEXT, sector TEXT, total_employees INT, successful_cb BOOLEAN, cb_year INT); INSERT INTO workplaces (id, name, location, sector, total_employees, successful_cb, cb_year) VALUES (1, 'School A', 'City X', 'education', 50, true, 2020), (2, 'University B', 'City Y', 'education', 3000, true, 2019); INSERT INTO union_members (id, workplace_id, member_name, member_join_date, member_status) VALUES (1, 1, 'John Doe', '2018-01-01', 'active'), (2, 1, 'Jane Smith', '2019-05-15', 'active'), (3, 2, 'Mike Johnson', '2020-03-01', 'active');
What is the total number of union members in the education sector?
SELECT SUM(um.member_status = 'active'::INTEGER) FROM union_members um JOIN workplaces w ON um.workplace_id = w.id WHERE w.sector = 'education';
gretelai_synthetic_text_to_sql
CREATE SCHEMA humanitarian_assistance;CREATE TABLE un_assistance (assistance_amount INT, year INT, region VARCHAR(50));INSERT INTO humanitarian_assistance.un_assistance (assistance_amount, year, region) VALUES (500000, 2015, 'Caribbean'), (700000, 2016, 'Caribbean'), (800000, 2017, 'Caribbean'), (900000, 2018, 'Caribbean'), (600000, 2019, 'Caribbean'), (1000000, 2020, 'Caribbean'), (1200000, 2021, 'Caribbean'), (1500000, 2022, 'Caribbean');
What is the minimum amount of humanitarian assistance provided by the UN in a single year in the Caribbean region?
SELECT MIN(assistance_amount) FROM humanitarian_assistance.un_assistance WHERE region = 'Caribbean';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists esg_factors (id INT PRIMARY KEY, strategy_id INT, factor_type TEXT, factor TEXT);
insert a new investment strategy with associated ESG factors
INSERT INTO investment_strategies (strategy) VALUES ('Impact Bond Strategy'); INSERT INTO esg_factors (strategy_id, factor_type, factor) VALUES (CURRVAL('investment_strategies_id_seq'), 'environmental', 'Low Carbon Footprint');
gretelai_synthetic_text_to_sql
CREATE TABLE user (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), created_at TIMESTAMP); INSERT INTO user (id, name, age, gender, created_at) VALUES (1, 'John Doe', 25, 'Male', '2021-01-01 10:00:00'); CREATE TABLE post (id INT, user_id INT, content TEXT, posted_at TIMESTAMP); INSERT INTO post (id, user_id, content, posted_at) VALUES (1, 1, 'Hello World!', '2021-01-01 10:10:00');
What is the average number of posts per user in the 'social_media' schema?
SELECT AVG(u.count) FROM (SELECT user_id, COUNT(*) as count FROM post GROUP BY user_id) as u;
gretelai_synthetic_text_to_sql
CREATE TABLE PoliceStations (ID INT, Name TEXT, City TEXT, State TEXT, County TEXT);
Insert a new record into the "PoliceStations" table
INSERT INTO PoliceStations (ID, Name, City, State, County) VALUES (5001, 'Cherry Hill Police', 'Baltimore', 'MD', 'Baltimore City');
gretelai_synthetic_text_to_sql
CREATE TABLE procurement.suppliers (supplier_id INT, supplier_name VARCHAR(50), country VARCHAR(50)); INSERT INTO procurement.suppliers (supplier_id, supplier_name, country) VALUES (1, 'Supplier A', 'USA'), (2, 'Supplier B', 'USA'), (3, 'Supplier C', 'Canada'), (4, 'Supplier D', 'Mexico');
How many suppliers are there in the 'procurement' schema for each country?
SELECT country, COUNT(*) as total_suppliers FROM procurement.suppliers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name VARCHAR(50), location VARCHAR(50), year INT, attendance INT);
Which museums had the highest and lowest attendance in the last 3 years?
SELECT name, year, attendance FROM (SELECT name, year, attendance, DENSE_RANK() OVER (ORDER BY attendance DESC) as rank FROM museums WHERE year >= 2019) a WHERE rank <= 1 OR rank >= 9;
gretelai_synthetic_text_to_sql
CREATE TABLE market_trends (element VARCHAR(2), quarter INT, year INT, price DECIMAL(5,2)); INSERT INTO market_trends VALUES ('Dy', 3, 2022, 25.6), ('Y', 3, 2022, 32.1), ('Dy', 3, 2022, 26.0);
Find the average market price of Dysprosium (Dy) and Yttrium (Y) in Q3 2022.
SELECT AVG(price) AS avg_price FROM market_trends WHERE element IN ('Dy', 'Y') AND quarter = 3 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50));CREATE TABLE TicketSales (SaleID INT, TeamID INT, TicketType VARCHAR(50), Price DECIMAL(5,2), SaleDate DATE); INSERT INTO Teams (TeamID, TeamName) VALUES (1, 'Knights'), (2, 'Lions'), (3, 'Titans'); INSERT INTO TicketSales (SaleID, TeamID, TicketType, Price, SaleDate) VALUES (1, 1, 'VIP', 150, '2022-01-01'), (2, 1, 'Regular', 80, '2022-01-01'), (3, 2, 'VIP', 200, '2022-01-05'), (4, 2, 'Regular', 90, '2022-01-05'), (5, 3, 'VIP', 180, '2022-01-07'), (6, 3, 'Regular', 70, '2022-01-07');
Which team has the highest average ticket price for VIP seats in the last 3 months?
SELECT TeamName, AVG(Price) as AvgPrice FROM TicketSales WHERE TicketType = 'VIP' AND SaleDate >= DATEADD(month, -3, GETDATE()) GROUP BY TeamName ORDER BY AvgPrice DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Cuisines (CuisineID INT, CuisineType VARCHAR(50)); CREATE TABLE Meals (MealID INT, CuisineID INT, MealName VARCHAR(50), CalorieCount INT); INSERT INTO Cuisines (CuisineID, CuisineType) VALUES (1, 'American'), (2, 'Italian'); INSERT INTO Meals (MealID, CuisineID, MealName, CalorieCount) VALUES (1, 1, 'Classic Burger', 550), (2, 1, 'Turkey Sandwich', 700), (3, 2, 'Margherita Pizza', 800), (4, 2, 'Spaghetti Bolognese', 1000);
Which cuisine has the most meals with a calorie count above 700?
SELECT CuisineType, COUNT(*) as high_calorie_meals FROM Cuisines C JOIN Meals M ON C.CuisineID = M.CuisineID WHERE CalorieCount > 700 GROUP BY CuisineType ORDER BY high_calorie_meals DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (Date date, Location text, Material text, Quantity integer);CREATE TABLE LandfillCapacity (Location text, Capacity integer);
What is the total waste quantity generated per location and material, and the total landfill capacity for each location, for the first quarter of 2021?
SELECT wg.Location, wg.Material, SUM(wg.Quantity) as TotalWasteQuantity, lc.Capacity as TotalLandfillCapacity FROM WasteGeneration wg JOIN LandfillCapacity lc ON wg.Location = lc.Location WHERE wg.Date >= '2021-01-01' AND wg.Date < '2021-04-01' GROUP BY wg.Location, wg.Material, lc.Capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(100), location VARCHAR(100), production FLOAT, operational_status VARCHAR(50)); INSERT INTO wells (well_id, well_name, location, production, operational_status) VALUES (3, 'Well C', 'Saudi Arabia', 200.3, 'Active'); INSERT INTO wells (well_id, well_name, location, production, operational_status) VALUES (4, 'Well D', 'UAE', 175.5, 'Idle');
What are the active wells in the Middle East, ranked by production in descending order?
SELECT well_id, well_name, production, operational_status, ROW_NUMBER() OVER (PARTITION BY operational_status ORDER BY production DESC) as rank FROM wells WHERE location = 'Saudi Arabia' AND operational_status = 'Active';
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, diameter FLOAT, weight INT, material VARCHAR(255), location VARCHAR(255));
Update the weight of the space debris with ID 123 to 600 kg.
UPDATE space_debris SET weight = 600 WHERE id = 123;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_affordability (property_id INT, size FLOAT, owner_id INT, location VARCHAR(255)); INSERT INTO housing_affordability (property_id, size, owner_id, location) VALUES (1, 800, 1, 'City A'), (2, 900, 1, 'City A'), (3, 1000, 2, 'City B');
What is the minimum and maximum property size for each location in the housing_affordability table?
SELECT location, MIN(size) AS min_size, MAX(size) AS max_size FROM housing_affordability GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(100), department VARCHAR(50), country VARCHAR(50)); INSERT INTO Employees (id, name, department, country) VALUES (1, 'John Doe', 'IT', 'United States'), (2, 'Jane Smith', 'Marketing', 'Canada'), (3, 'Mike Johnson', 'IT', 'France');
List all employees who work in the IT department or are located in France.
SELECT * FROM Employees WHERE department = 'IT' OR country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (name text, new_species integer); INSERT INTO deep_sea_expeditions (name, new_species) VALUES ('Nereus', 3), ('Mariana Snailfish', 1), ('Hadal Snailfish', 2);
Which deep-sea expeditions discovered new species?
SELECT name FROM deep_sea_expeditions WHERE new_species > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE water_temperature (id INT, region VARCHAR(255), date DATE, temperature FLOAT); INSERT INTO water_temperature (id, region, date, temperature) VALUES (1, 'Mediterranean', '2022-08-01', 25.5), (2, 'Mediterranean', '2022-08-15', 27.3), (3, 'Atlantic', '2022-08-30', 22.8);
Calculate the minimum and maximum water temperature in the Mediterranean Sea in the month of August.
SELECT MIN(temperature), MAX(temperature) FROM water_temperature WHERE region = 'Mediterranean' AND date BETWEEN '2022-08-01' AND '2022-08-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Works (id INT, artist_id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, work_id INT, city VARCHAR(20), guest_rating FLOAT, revenue FLOAT); INSERT INTO Exhibitions (id, work_id, city, guest_rating, revenue) VALUES (1, 1, 'Rome', 4.6, 5000), (2, 2, 'Rome', 4.3, 6000), (3, 3, 'Rome', 4.5, 7000);
Calculate the percentage of artworks by each artist in Rome that have a guest rating of 4.5 or higher, and rank them in descending order of percentage.
SELECT a.name, COUNT(e.work_id) as total_works, COUNT(CASE WHEN e.guest_rating >= 4.5 THEN e.work_id END) as high_rating_works, 100.0 * COUNT(CASE WHEN e.guest_rating >= 4.5 THEN e.work_id END) / COUNT(e.work_id) as percentage, RANK() OVER (PARTITION BY a.name ORDER BY 100.0 * COUNT(CASE WHEN e.guest_rating >= 4.5 THEN e.work_id END) / COUNT(e.work_id) DESC) as rank FROM Artists a JOIN Works w ON a.id = w.artist_id JOIN Exhibitions e ON w.id = e.work_id WHERE e.city = 'Rome' GROUP BY a.name, rank ORDER BY percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50), acres INT); INSERT INTO Farmers (id, name, age, location, acres) VALUES (1, 'John Doe', 35, 'USA', 100); INSERT INTO Farmers (id, name, age, location, acres) VALUES (2, 'Jane Smith', 40, 'Canada', 200); CREATE TABLE Crops (id INT, farmer_id INT, crop_name VARCHAR(50), yield INT, sale_price DECIMAL(5,2)); INSERT INTO Crops (id, farmer_id, crop_name, yield, sale_price) VALUES (1, 1, 'Corn', 120, 2.35); INSERT INTO Crops (id, farmer_id, crop_name, yield, sale_price) VALUES (2, 2, 'Soybeans', 80, 1.98);
Find the average yield of crops in the top 50% of farmland.
SELECT AVG(c.yield) as avg_yield FROM Crops c JOIN Farmers f ON c.farmer_id = f.id WHERE f.acres >= (SELECT AVG(acres) FROM Farmers);
gretelai_synthetic_text_to_sql
CREATE TABLE company (company_id INT, company_name TEXT, domain TEXT); CREATE TABLE technology (tech_id INT, tech_name TEXT, company_id INT, accessibility_feature TEXT); INSERT INTO company (company_id, company_name, domain) VALUES (1, 'Helping Hands Inc.', 'technology for social good'), (2, 'Tech for All', 'general'), (3, 'Accessible AI', 'technology for social good'); INSERT INTO technology (tech_id, tech_name, company_id, accessibility_feature) VALUES (1, 'Accessible App', 1, 'Voice Command'), (2, 'General App', 2, ''), (3, 'Accessible Website', 3, 'Screen Reader'), (4, 'General Website', 2, '');
What is the percentage of technologies developed by organizations in the technology for social good domain that have accessibility features?
SELECT (COUNT(*) FILTER (WHERE domain = 'technology for social good')) * 100.0 / COUNT(*) AS percentage FROM company INNER JOIN technology ON company.company_id = technology.company_id WHERE accessibility_feature IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (ID INT, Name TEXT, Region TEXT); INSERT INTO Country (ID, Name, Region) VALUES (1, 'Canada', 'Arctic'); INSERT INTO Country (ID, Name, Region) VALUES (2, 'Russia', 'Arctic'); CREATE TABLE Species (ID INT, Name TEXT, Classification TEXT); INSERT INTO Species (ID, Name, Classification) VALUES (1, 'Polar Bear', 'Mammal'); INSERT INTO Species (ID, Name, Classification) VALUES (2, 'Arctic Fox', 'Mammal'); CREATE TABLE CountrySpecies (CountryID INT, SpeciesID INT); INSERT INTO CountrySpecies (CountryID, SpeciesID) VALUES (1, 1); INSERT INTO CountrySpecies (CountryID, SpeciesID) VALUES (1, 2);
How many species of mammals are found in each arctic country?
SELECT Country.Name, COUNT(DISTINCT Species.ID) as Number_of_Mammal_Species FROM CountrySpecies JOIN Country ON CountrySpecies.CountryID = Country.ID JOIN Species ON CountrySpecies.SpeciesID = Species.ID WHERE Country.Region = 'Arctic' GROUP BY Country.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_savings (id INT, building_id INT, technology VARCHAR(50), energy_savings_kwh FLOAT, year INT);
Calculate the total energy savings (in kWh) for each technology type in the 'energy_savings' table, grouped by year
SELECT technology, EXTRACT(YEAR FROM saving_date) as year, SUM(energy_savings_kwh) FROM energy_savings, generate_series(date_trunc('year', saving_date), date_trunc('year', saving_date + interval '1 year' - interval '1 day'), interval '1 year') as series(saving_date) GROUP BY technology, year;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, region TEXT); CREATE TABLE initiatives (id INT, initiative_type TEXT, region_id INT); INSERT INTO regions (id, region) VALUES (1, 'Americas'), (2, 'Europe'), (3, 'Asia'); INSERT INTO initiatives (id, initiative_type, region_id) VALUES (1, 'Mitigation', 1), (2, 'Adaptation', 2), (3, 'Mitigation', 3);
List all climate mitigation initiatives in the 'americas' region.
SELECT initiatives.initiative_type FROM initiatives INNER JOIN regions ON initiatives.region_id = regions.id WHERE regions.region = 'Americas' AND initiatives.initiative_type = 'Mitigation';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floors (ocean_id INT, ocean_name VARCHAR(255), deepest_point_depth DECIMAL(10,2), PRIMARY KEY(ocean_id)); INSERT INTO ocean_floors (ocean_id, ocean_name, deepest_point_depth) VALUES (1, 'Pacific Ocean', 36102), (2, 'Atlantic Ocean', 8605), (3, 'Indian Ocean', 7258), (4, 'Southern Ocean', 7290), (5, 'Arctic Ocean', 5449);
What is the average depth of the deepest point in each ocean?
SELECT AVG(deepest_point_depth) FROM ocean_floors;
gretelai_synthetic_text_to_sql
CREATE TABLE students_disabilities (student_id INT, has_disability BOOLEAN, completed_support_program BOOLEAN); INSERT INTO students_disabilities (student_id, has_disability, completed_support_program) VALUES (1, TRUE, FALSE), (2, FALSE, FALSE);
What is the percentage of students with disabilities who have not completed a support program?
SELECT (COUNT(*) FILTER (WHERE has_disability = TRUE AND completed_support_program = FALSE)) * 100.0 / (SELECT COUNT(*) FROM students_disabilities WHERE has_disability = TRUE) AS percentage;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_programs (volunteer_id INT, program_id INT); INSERT INTO volunteer_programs (volunteer_id, program_id) VALUES (1, 100), (2, 100), (3, 200); CREATE TABLE donor_programs (donor_id INT, program_id INT); INSERT INTO donor_programs (donor_id, program_id) VALUES (1001, 100), (1002, 100), (1003, 200);
How many unique volunteers and donors have engaged with each program?
SELECT p.name, COUNT(DISTINCT vp.volunteer_id) AS num_volunteers, COUNT(DISTINCT dp.donor_id) AS num_donors FROM programs p LEFT JOIN volunteer_programs vp ON p.id = vp.program_id LEFT JOIN donor_programs dp ON p.id = dp.program_id GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (id INT, name TEXT, region TEXT, co2_emissions FLOAT);
What is the average CO2 emission of buildings in North America?
SELECT AVG(co2_emissions) FROM buildings WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, post_text TEXT);
Insert a new post by user with ID 1 with the text 'Hello World!'
INSERT INTO posts (id, user_id, post_text) VALUES (1, 1, 'Hello World!');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtifactTypes (ArtifactTypeID INT, ArtifactType TEXT); INSERT INTO ArtifactTypes (ArtifactTypeID, ArtifactType) VALUES (1, 'Stone Tool'), (2, 'Pottery'), (3, 'Metal Object'), (4, 'Bone Artifact'); CREATE TABLE Artifacts (ArtifactID INT, ArtifactName TEXT, SiteID INT, ArtifactTypeID INT); INSERT INTO Artifacts (ArtifactID, ArtifactName, SiteID, ArtifactTypeID) VALUES (3, 'Flint Tool', 3, 1), (5, 'Stone Hammer', 2, 1), (6, 'Stone Axe', 1, 1), (7, 'Pottery Jar', 2, 2), (8, 'Bronze Sword', 2, 3), (9, 'Ancient Bone Necklace', 1, 4);
Which excavation sites have at least 5 instances of stone tools?
SELECT Sites.SiteName, COUNT(Artifacts.ArtifactID) AS Quantity FROM Artifacts INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID INNER JOIN ArtifactTypes ON Artifacts.ArtifactTypeID = ArtifactTypes.ArtifactTypeID WHERE ArtifactTypes.ArtifactType = 'Stone Tool' GROUP BY Sites.SiteName HAVING Quantity >= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE PatientDemographics (PatientID INT, Race TEXT); INSERT INTO PatientDemographics (PatientID, Race) VALUES (1, 'American Indian or Alaska Native'); INSERT INTO PatientDemographics (PatientID, Race) VALUES (2, 'Asian'); INSERT INTO PatientDemographics (PatientID, Race) VALUES (3, 'American Indian or Alaska Native');
Find the percentage of patients who identify as American Indian or Alaska Native, from the total number of patients, rounded to two decimal places.
SELECT ROUND(COUNT(*) FILTER (WHERE Race = 'American Indian or Alaska Native') * 100.0 / COUNT(*), 2) as Percentage FROM PatientDemographics;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, genre VARCHAR(10), platform VARCHAR(10), sales FLOAT); CREATE TABLE genres (genre_id INT, genre VARCHAR(10)); CREATE TABLE platforms (platform_id INT, platform VARCHAR(10));
List the genres that have sales in all platforms.
SELECT genre FROM sales GROUP BY genre HAVING COUNT(DISTINCT platform) = (SELECT COUNT(*) FROM platforms);
gretelai_synthetic_text_to_sql
CREATE TABLE football_goals (player_name VARCHAR(50), team VARCHAR(50), goals INT); INSERT INTO football_goals (player_name, team, goals) VALUES ('Sergio Ramos', 'Spain', 23), ('Fernando Torres', 'Spain', 38);
Who is the highest goal scorer for the Spanish national football team?
SELECT player_name, SUM(goals) as total_goals FROM football_goals WHERE team = 'Spain' GROUP BY player_name ORDER BY total_goals DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (id INT, region_name VARCHAR(255)); CREATE TABLE Neighborhoods (id INT, region_id INT, neighborhood_name VARCHAR(255)); CREATE TABLE Incidents (id INT, neighborhood_id INT, incident_type VARCHAR(255), incident_date DATE); INSERT INTO Regions (id, region_name) VALUES (1, 'West'), (2, 'East'), (3, 'North'), (4, 'South'); INSERT INTO Neighborhoods (id, region_id, neighborhood_name) VALUES (1, 1, 'Westside'), (2, 1, 'Northwest'), (3, 2, 'Southeast'), (4, 2, 'Eastside'); INSERT INTO Incidents (id, neighborhood_id, incident_type, incident_date) VALUES (1, 1, 'Fire', '2021-02-01'), (2, 2, 'Theft', '2021-03-01'), (3, 3, 'Fire', '2021-01-01'), (4, 4, 'Vandalism', '2021-04-01');
What is the total number of fire incidents in each neighborhood in the west region, sorted by the total count in descending order?
SELECT neighborhood_id, COUNT(*) as total_fire_incidents FROM Incidents WHERE incident_type = 'Fire' GROUP BY neighborhood_id ORDER BY total_fire_incidents DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Negotiations (Id INT, UnionId INT, Duration INT); INSERT INTO Negotiations (Id, UnionId, Duration) VALUES (1, 2, 120), (2, 2, 180), (3, 2, 90), (4, 2, 210), (5, 2, 150);
What is the minimum, maximum, and average duration of collective bargaining negotiations for Union B?
SELECT MIN(Duration) as MinDuration, MAX(Duration) as MaxDuration, AVG(Duration) as AvgDuration FROM Negotiations WHERE UnionId = 2;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS public_transport;CREATE TABLE IF NOT EXISTS public_transport.fleet (fleet_id SERIAL PRIMARY KEY, vehicle_type TEXT, is_accessible BOOLEAN);INSERT INTO public_transport.fleet (vehicle_type, is_accessible) VALUES ('Bus', true), ('Tram', false), ('Minibus', true), ('Taxi', true), ('Bicycle', false);
Display the number of accessible vehicles in the 'fleet' table
SELECT vehicle_type, is_accessible FROM public_transport.fleet WHERE is_accessible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (ProgramID INT, BudgetAmount DECIMAL(10,2)); CREATE TABLE Outcomes (ProgramID INT, ProgramOutcome VARCHAR(20)); INSERT INTO Budget (ProgramID, BudgetAmount) VALUES (1, 10000.00), (2, 8000.00), (3, 6000.00); INSERT INTO Outcomes (ProgramID, ProgramOutcome) VALUES (1, 'Success'), (2, 'Failure'), (3, 'Success');
What are the budget reports for programs that had successful outcomes?
SELECT Budget.ProgramID, BudgetAmount FROM Budget INNER JOIN Outcomes ON Budget.ProgramID = Outcomes.ProgramID WHERE Outcomes.ProgramOutcome = 'Success';
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTests (Vehicle VARCHAR(50), Year INT); INSERT INTO SafetyTests (Vehicle, Year) VALUES ('Tesla Model S', 2020), ('Tesla Model S', 2021), ('Tesla Model S', 2022), ('Tesla Model 3', 2020), ('Tesla Model 3', 2021), ('Tesla Model 3', 2022), ('Chevrolet Bolt', 2020), ('Chevrolet Bolt', 2021), ('Chevrolet Bolt', 2022), ('Nissan Leaf', 2020), ('Nissan Leaf', 2021), ('Nissan Leaf', 2022);
How many safety tests were conducted on electric vehicles in the last 3 years?
SELECT COUNT(*) FROM SafetyTests WHERE Year >= YEAR(CURRENT_DATE) - 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, SupplierName TEXT, Material TEXT, Quantity INT); INSERT INTO Sales (SaleID, SupplierName, Material, Quantity) VALUES (301, 'GreenFabrics', 'Organic Cotton', 50), (302, 'EcoWeave', 'Organic Cotton', 75), (303, 'StandardTextiles', 'Conventional Cotton', 60), (304, 'StandardTextiles', 'Organic Cotton', 30);
What is the total quantity of organic cotton sold by suppliers?
SELECT SUM(Quantity) FROM Sales WHERE Material = 'Organic Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE Machines (MachineID INT PRIMARY KEY, MachineName VARCHAR(50), Department VARCHAR(50), LastMaintenance DATE, NextMaintenance DATE); INSERT INTO Machines (MachineID, MachineName, Department, LastMaintenance, NextMaintenance) VALUES (3, 'Tester', 'Quality Control', '2022-02-10', '2022-08-10'); INSERT INTO Machines (MachineID, MachineName, Department, LastMaintenance, NextMaintenance) VALUES (4, 'Analyzer', 'Quality Control', '2022-04-15', '2022-10-15');
which machines have not been maintained for more than 6 months in the Quality Control department?
SELECT Machines.MachineName, Machines.Department, Machines.LastMaintenance FROM Machines WHERE Machines.Department = 'Quality Control' AND DATEDIFF(CURDATE(), Machines.LastMaintenance) > 180;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(100));CREATE TABLE Products (product_id INT, brand_id INT, product_name VARCHAR(100), category VARCHAR(50), price DECIMAL(10,2));
List the top 3 cosmetic brands with the highest average mascara price.
SELECT b.brand_name, AVG(p.price) FROM Products p INNER JOIN Brands b ON p.brand_id = b.brand_id WHERE category = 'Mascara' GROUP BY b.brand_name ORDER BY AVG(p.price) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_name VARCHAR(50), city VARCHAR(50), attendee_age INT); INSERT INTO events (event_name, city, attendee_age) VALUES ('Jazz in the Park', 'New York', 35);
What was the average age of attendees who participated in 'Jazz in the Park' events in New York?
SELECT AVG(attendee_age) FROM events WHERE event_name = 'Jazz in the Park' AND city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance(id INT, transaction_id INT, country_continent VARCHAR(50), quarter INT, year INT); INSERT INTO shariah_compliant_finance VALUES (1, 601, 'Africa', 4, 2022); INSERT INTO shariah_compliant_finance VALUES (2, 602, 'Asia', 1, 2022); INSERT INTO shariah_compliant_finance VALUES (3, 603, 'Europe', 2, 2022); INSERT INTO shariah_compliant_finance VALUES (4, 604, 'Africa', 3, 2022);
How many Shariah-compliant finance transactions were made in Q4 2022 by individuals from African countries?
SELECT COUNT(transaction_id) FROM shariah_compliant_finance WHERE quarter = 4 AND year = 2022 AND country_continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE canyons (canyon_name TEXT, location TEXT, max_depth REAL);
List the top 5 deepest underwater canyons and their locations.
SELECT canyon_name, location, max_depth FROM canyons ORDER BY max_depth DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE auto_industry (id INT, company_name VARCHAR(100), country VARCHAR(50), worker_count INT); INSERT INTO auto_industry (id, company_name, country, worker_count) VALUES (1, 'Mercedes-Benz', 'Germany', 150000); INSERT INTO auto_industry (id, company_name, country, worker_count) VALUES (2, 'BMW', 'Germany', 120000);
Who are the top 5 employers in the automotive industry in Germany?
SELECT company_name, worker_count FROM auto_industry WHERE country = 'Germany' ORDER BY worker_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, country_id INT, sale_date DATE, quantity INT); INSERT INTO Sales (id, country_id, sale_date, quantity) VALUES (1, 1, '2021-01-01', 200), (2, 2, '2021-02-15', 300), (3, 1, '2021-03-01', 150), (4, 3, '2021-04-10', 400), (5, 2, '2021-05-25', 250), (6, 1, '2021-06-15', 350);
Get the total quantity of garments sold in the last 3 months, grouped by country.
SELECT c.country, SUM(s.quantity) as total_quantity_sold FROM Sales s JOIN Countries c ON s.country_id = c.id WHERE s.sale_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) GROUP BY c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE conditions (condition_id INT, condition VARCHAR(20), patient_count INT); INSERT INTO conditions (condition_id, condition, patient_count) VALUES (1, 'Depression', 50), (2, 'Anxiety', 75), (3, 'PTSD', 40), (4, 'Bipolar Disorder', 60);
List the top 3 mental health conditions with the highest number of unique patients.
SELECT condition, patient_count FROM conditions ORDER BY patient_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SiteBB (site_id INT, site_name VARCHAR(20), artifact_type VARCHAR(20), quantity INT); INSERT INTO SiteBB (site_id, site_name, artifact_type, quantity) VALUES (1, 'SiteBB', 'Pottery', 15), (2, 'SiteBB', 'Bone Fragments', 8), (3, 'SiteCC', 'Pottery', 8), (4, 'SiteCC', 'Bone Fragments', 15);
Find the excavation sites with an equal quantity of pottery and bone fragments.
SELECT site_name FROM SiteBB WHERE artifact_type = 'Pottery' INTERSECT SELECT site_name FROM SiteBB WHERE artifact_type = 'Bone Fragments';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, annual_production INT); INSERT INTO mines (id, name, location, annual_production) VALUES (1, 'Mine A', 'Country X', 1500), (2, 'Mine B', 'Country Y', 2000), (3, 'Mine C', 'Country Z', 1750);
How many tons of REE were produced by each country in 2019?
SELECT location, SUM(annual_production) as total_production FROM mines WHERE YEAR(timestamp) = 2019 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2021, 'Promethium', 700), (2022, 'Promethium', 800);
What is the total production of Promethium in 2021 and 2022?
SELECT element, SUM(quantity) as total_quantity FROM production WHERE element = 'Promethium' AND year IN (2021, 2022) GROUP BY element
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), JobTitle VARCHAR(50), Department VARCHAR(50), HireDate DATE); INSERT INTO Employees (EmployeeID, Name, JobTitle, Department, HireDate) VALUES (1, 'John Doe', 'Marketing Manager', 'Marketing', '2021-05-01'), (2, 'Jane Smith', 'HR Specialist', 'HR', '2022-03-15'), (3, 'Mike Johnson', 'Sales Representative', 'Sales', '2021-12-20'), (4, 'Emily Lee', 'Data Analyst', 'IT', '2022-06-05');
What is the total number of employees hired in 2021 and 2022, grouped by department?
SELECT Department, COUNT(*) FROM Employees WHERE YEAR(HireDate) IN (2021, 2022) GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name TEXT, category TEXT, yield FLOAT); INSERT INTO strains (id, name, category, yield) VALUES (1, 'Purple Kush', 'Indica', 0.5), (2, 'Northern Lights', 'Indica', 0.6), (3, 'Granddaddy Purple', 'Indica', 0.7), (4, 'Sour Diesel', 'Sativa', 0.6), (5, 'Blue Dream', 'Hybrid', 0.9), (6, 'Green Crack', 'Sativa', 1.0);
What is the minimum yield for strains in the 'Indica' category?
SELECT MIN(yield) FROM strains WHERE category = 'Indica';
gretelai_synthetic_text_to_sql
CREATE TABLE PRODUCT ( id INT PRIMARY KEY, name TEXT, material TEXT, quantity INT, country TEXT, certifications TEXT, is_recycled BOOLEAN ); INSERT INTO PRODUCT (id, name, material, quantity, country, certifications, is_recycled) VALUES (1, 'Organic Cotton Shirt', 'Organic Cotton', 30, 'USA', 'GOTS, Fair Trade', FALSE); INSERT INTO PRODUCT (id, name, material, quantity, country, certifications) VALUES (2, 'Recycled Poly Shoes', 'Recycled Polyester', 25, 'Germany', 'BlueSign'); INSERT INTO PRODUCT (id, name, material, quantity, country, certifications, is_recycled) VALUES (3, 'Bamboo T-Shirt', 'Bamboo', 15, 'China', 'OEKO-TEX', FALSE); INSERT INTO PRODUCT (id, name, material, quantity, country, certifications, is_recycled) VALUES (4, 'Recycled Denim Jeans', 'Recycled Cotton', 40, 'USA', 'GOTS', TRUE);
Update the quantities of all products made from recycled materials to be twice the original amount.
UPDATE PRODUCT SET quantity = quantity * 2 WHERE is_recycled = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE dams (dam_id INT, dam_name VARCHAR(50), state VARCHAR(50), construction_year INT);
What are the top 5 states with the highest number of dams that were constructed after 1990?
SELECT dams.state, COUNT(dams.dam_id) as number_of_dams FROM dams WHERE dams.construction_year > 1990 GROUP BY dams.state ORDER BY number_of_dams DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE territories (id INT, name VARCHAR(255)); INSERT INTO territories (id, name) VALUES (1, 'Northern Territory'), (2, 'Australian Capital Territory'); CREATE TABLE populations_australia (id INT, territory_id INT, drinker BOOLEAN, problem_drinker BOOLEAN); INSERT INTO populations_australia (id, territory_id, drinker, problem_drinker) VALUES (1, 1, true, true);
What percentage of the population in each territory in Australia has a drinking problem?
SELECT t.name, (COUNT(pa.id) * 100.0 / (SELECT COUNT(*) FROM populations_australia WHERE territory_id = t.id)) AS problem_drinker_percentage FROM territories t JOIN populations_australia pa ON t.id = pa.territory_id WHERE pa.drinker = true GROUP BY t.name;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (ticket_type VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO fares (ticket_type, fare) VALUES ('Child', 2.00), ('Adult', 3.00), ('Senior', 2.50);
Update the fare of the 'Adult' ticket type to $3.50 in the 'fares' table
UPDATE fares SET fare = 3.50 WHERE ticket_type = 'Adult';
gretelai_synthetic_text_to_sql
CREATE TABLE soccer_teams (team VARCHAR(255)); CREATE TABLE soccer_games (team VARCHAR(255), games_played INTEGER, games_won INTEGER); INSERT INTO soccer_teams (team) VALUES ('TeamA'), ('TeamB'), ('TeamC'); INSERT INTO soccer_games (team, games_played, games_won) VALUES ('TeamA', 10, 7), ('TeamB', 12, 8), ('TeamC', 15, 10);
Calculate the win percentage for each team in the "soccer_games" table
SELECT s.team, ROUND(100.0 * SUM(sg.games_won) / SUM(sg.games_played), 2) as win_percentage FROM soccer_teams s INNER JOIN soccer_games sg ON s.team = sg.team GROUP BY s.team;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage_systems (country VARCHAR(20), number INT); INSERT INTO energy_storage_systems (country, number) VALUES ('Australia', 100), ('Australia', 200), ('Japan', 300), ('Japan', 400);
What is the total number of energy storage systems in Australia and Japan?
SELECT SUM(number) FROM energy_storage_systems WHERE country IN ('Australia', 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, category, price) VALUES (1, 'fair_trade', 15.99), (2, 'grocery', 5.49), (3, 'fair_trade', 24.99), (4, 'grocery', 12.49);
Find the average price of all products in the 'fair_trade' category and 'grocery' department.
SELECT AVG(price) FROM products WHERE category = 'fair_trade' AND category = 'grocery';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_engineering(dish VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), restaurant VARCHAR(255));
Delete the 'Fish Tacos' dish from the 'Mexican Grill' menu.
DELETE FROM menu_engineering WHERE dish = 'Fish Tacos' AND restaurant = 'Mexican Grill';
gretelai_synthetic_text_to_sql
CREATE TABLE funding_amount_distribution(id INT, startup_id INT, amount INT);
What is the distribution of funding amounts for startups founded by veterans in the AI sector?
SELECT startup_id, AVG(amount), MIN(amount), MAX(amount), STDDEV(amount) FROM startups JOIN funding_rounds ON startups.id = funding_rounds.startup_id JOIN founders ON startups.id = founders.startup_id WHERE industry = 'AI' AND founder_identity = 'Veteran' GROUP BY startup_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT PRIMARY KEY, Name TEXT, CargoWeight FLOAT); INSERT INTO Vessels (ID, Name, CargoWeight) VALUES (1, 'Cargo Ship 1', 5500), (2, 'Cargo Ship 2', 7000), (3, 'Cargo Ship 3', 4800);
What is the maximum cargo weight for vessels that have a cargo weight greater than 5000 tons?
SELECT MAX(CargoWeight) FROM Vessels WHERE CargoWeight > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, equipment_type VARCHAR(20), year_acquired INT, quantity INT); INSERT INTO military_equipment (equipment_id, equipment_type, year_acquired, quantity) VALUES (101, 'Tank', 2015, 15), (102, 'Aircraft', 2018, 25), (103, 'Helicopter', 2017, 30);
Update military equipment records with equipment_id 101 and 102, setting quantity to 20 and 30 respectively
UPDATE military_equipment SET quantity = CASE equipment_id WHEN 101 THEN 20 WHEN 102 THEN 30 ELSE quantity END;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artist_name VARCHAR(50), movement VARCHAR(20));
List the names of the artists who have created artworks from both the 'Fauvism' and 'Cubism' movements.
SELECT artist_name FROM Artworks WHERE artist_name IN (SELECT artist_name FROM Artworks WHERE movement = 'Fauvism') AND movement = 'Cubism';
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_sessions (id INT, patient_id INT, session_date DATE); INSERT INTO therapy_sessions (id, patient_id, session_date) VALUES (1, 1, '2021-02-01'), (2, 2, '2021-03-15'), (3, 3, '2021-01-05'), (4, 4, '2021-04-20'), (5, 5, '2021-02-10'), (6, 6, '2021-03-25'), (7, 7, '2021-01-12'), (8, 8, '2021-04-02');
What is the number of patients who received therapy in each month of 2021?
SELECT DATE_TRUNC('month', session_date) AS month, COUNT(*) FROM therapy_sessions WHERE YEAR(session_date) = 2021 GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, name TEXT, country TEXT, funder TEXT); INSERT INTO infrastructure_projects (id, name, country, funder) VALUES (1, 'Road Construction', 'Kenya', 'World Bank'), (2, 'Water Supply System', 'Tanzania', 'UNDP');
What is the total number of rural infrastructure projects funded by international organizations in Kenya and Tanzania?
SELECT COUNT(DISTINCT infrastructure_projects.id) FROM infrastructure_projects WHERE infrastructure_projects.country IN ('Kenya', 'Tanzania') AND infrastructure_projects.funder IN ('World Bank', 'UNDP');
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, match_name VARCHAR(50), team VARCHAR(50), goals INT); INSERT INTO matches (match_id, match_name, team, goals) VALUES (1, 'Match 1', 'Team A', 2), (2, 'Match 2', 'Team A', 1), (3, 'Match 3', 'Team A', 3), (4, 'Match 4', 'Team B', 1), (5, 'Match 5', 'Team B', 0), (6, 'Match 6', 'Team B', 4);
Find the average number of goals scored in the last 3 matches for each team.
SELECT team, AVG(goals) as avg_goals FROM (SELECT team, goals, ROW_NUMBER() OVER (PARTITION BY team ORDER BY match_id DESC) as rn FROM matches) t WHERE rn <= 3 GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE Temperature (id INT, location VARCHAR(255), date DATE, temperature INT); INSERT INTO Temperature (id, location, date, temperature) VALUES (1, 'France Vineyard', '2017-01-01', 10), (2, 'France Vineyard', '2017-01-02', 12), (3, 'France Vineyard', '2017-01-03', 11), (4, 'France Vineyard', '2018-01-01', 12), (5, 'France Vineyard', '2018-01-02', 14), (6, 'France Vineyard', '2018-01-03', 13);
What is the average temperature trend for vineyards in France over the past 5 years?
SELECT AVG(temperature) FROM Temperature WHERE location = 'France Vineyard' AND date BETWEEN DATE_SUB(CURDATE(), INTERVAL 5 YEAR) AND CURDATE() GROUP BY YEAR(date);
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_training (worker_id INT, received_training BOOLEAN); CREATE TABLE community_health_workers_scores (worker_id INT, score INT); INSERT INTO cultural_competency_training (worker_id, received_training) VALUES (1, TRUE), (2, FALSE), (3, TRUE); INSERT INTO community_health_workers_scores (worker_id, score) VALUES (1, 90), (2, 80), (3, 95);
What is the correlation between cultural competency training and health equity scores for community health workers?
SELECT AVG(s.score) as avg_score, COUNT(*) FILTER (WHERE c.received_training = TRUE) as trained_workers, COUNT(*) FILTER (WHERE c.received_training = FALSE) as untrained_workers FROM cultural_competency_training c JOIN community_health_workers_scores s ON c.worker_id = s.worker_id;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (year INT, sector VARCHAR(20), amount INT); INSERT INTO WasteGeneration (year, sector, amount) VALUES (2018, 'residential', 5000), (2018, 'commercial', 7000), (2019, 'residential', 5500), (2019, 'commercial', 7500), (2020, 'residential', NULL), (2020, 'commercial', NULL);
What is the total waste generation in the residential sector in 2020?
SELECT amount FROM WasteGeneration WHERE year = 2020 AND sector = 'residential';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT PRIMARY KEY, title TEXT, year INT, artist TEXT, streams INT);
What is the maximum number of streams for a song released in the 1990s?
SELECT MAX(streams) FROM songs WHERE year BETWEEN 1990 AND 1999;
gretelai_synthetic_text_to_sql
CREATE TABLE Transport (City VARCHAR(20), Year INT, Category VARCHAR(20), Amount INT); INSERT INTO Transport (City, Year, Category, Amount) VALUES ('Mumbai', 2020, 'Public Transportation', 3000);
What was the budget allocation for public transportation in Mumbai in 2020?
SELECT Amount FROM Transport WHERE City = 'Mumbai' AND Year = 2020 AND Category = 'Public Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO peacekeeping_operations (operation_id, name, location, start_date, end_date) VALUES (1, 'MINUSMA', 'Mali', '2013-07-25', '2024-12-31'), (2, 'MONUSCO', 'Democratic Republic of the Congo', '1999-11-30', '2024-12-31');
Select all peacekeeping operations in the Democratic Republic of the Congo
SELECT * FROM peacekeeping_operations WHERE location = 'Democratic Republic of the Congo';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_initiatives ( id INT PRIMARY KEY, region VARCHAR(255), initiative_name VARCHAR(255), initiative_description TEXT, start_date DATE, end_date DATE); INSERT INTO recycling_initiatives (id, region, initiative_name, initiative_description, start_date, end_date) VALUES (1, 'Africa', 'Plastic Bottle Collection', 'Collecting plastic bottles in schools and parks.', '2020-01-01', '2020-12-31'), (2, 'South America', 'E-Waste Disposal', 'Establishing e-waste drop-off points in major cities.', '2019-06-15', '2021-06-14'), (3, 'Oceania', 'Composting Program', 'Implementing composting programs in households.', '2018-04-22', '2022-04-21'), (4, 'Antarctica', 'Research and Development', 'Researching new waste reduction methods.', '2023-07-04', '2026-07-03');
Insert records for recycling initiatives
INSERT INTO recycling_initiatives (id, region, initiative_name, initiative_description, start_date, end_date) VALUES (1, 'Africa', 'Plastic Bottle Collection', 'Collecting plastic bottles in schools and parks.', '2020-01-01', '2020-12-31'), (2, 'South America', 'E-Waste Disposal', 'Establishing e-waste drop-off points in major cities.', '2019-06-15', '2021-06-14'), (3, 'Oceania', 'Composting Program', 'Implementing composting programs in households.', '2018-04-22', '2022-04-21'), (4, 'Antarctica', 'Research and Development', 'Researching new waste reduction methods.', '2023-07-04', '2026-07-03');
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, vulnerability VARCHAR(255), date DATE); INSERT INTO vulnerabilities (id, vulnerability, date) VALUES (1, 'SQL Injection', '2021-07-01'); INSERT INTO vulnerabilities (id, vulnerability, date) VALUES (2, 'Cross-Site Scripting', '2021-08-15'); INSERT INTO vulnerabilities (id, vulnerability, date) VALUES (3, 'Remote Code Execution', '2021-09-05');
What are the top 5 most common vulnerabilities found in the last 6 months, across all systems and devices?
SELECT vulnerability, COUNT(*) as total FROM vulnerabilities WHERE date >= DATEADD(month, -6, GETDATE()) GROUP BY vulnerability ORDER BY total DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(50), region VARCHAR(20));CREATE TABLE Trainings (id INT PRIMARY KEY, farmer_id INT, year INT);
List all farmers in the Northern region who participated in agricultural trainings in 2021.
SELECT Farmers.name FROM Farmers INNER JOIN Trainings ON Farmers.id = Trainings.farmer_id WHERE Farmers.region = 'Northern' AND Trainings.year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, workshop_name VARCHAR(255), date DATE); INSERT INTO teacher_pd (teacher_id, workshop_name, date) VALUES (1, 'Open Pedagogy', '2022-03-01'); CREATE VIEW spring_2022_pd AS SELECT * FROM teacher_pd WHERE date BETWEEN '2022-01-01' AND '2022-06-30';
What is the count of professional development workshops attended by teachers in 'Spring 2022'?
SELECT COUNT(*) as total_workshops FROM spring_2022_pd;
gretelai_synthetic_text_to_sql
CREATE TABLE Staff (StaffID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50)); INSERT INTO Staff (StaffID, FirstName, LastName, Position) VALUES (1, 'John', 'Doe', 'Manager'), (2, 'Jane', 'Doe', 'Assistant Manager'), (3, 'Bob', 'Smith', 'Coordinator'), (4, 'Alice', 'Johnson', 'Specialist');
Delete the record with ID 4 from the 'Staff' table.
DELETE FROM Staff WHERE StaffID = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE sourcing (id INT, country VARCHAR(20), fabric_type VARCHAR(20), qty INT); INSERT INTO sourcing VALUES (1, 'India', 'organic cotton', 5000), (2, 'Pakistan', 'recycled polyester', 3000);
What is the total quantity of sustainable fabric sourced from India and Pakistan?
SELECT SUM(s.qty) FROM sourcing s WHERE s.country IN ('India', 'Pakistan') AND s.fabric_type IN ('organic cotton', 'recycled polyester');
gretelai_synthetic_text_to_sql
CREATE TABLE CandidateOffers(CandidateID INT, Department VARCHAR(255), Interviewed DATE, Offered DATE);
What is the percentage of candidates who were offered a job in the engineering department after an interview?
SELECT Department, (COUNT(CASE WHEN Offered IS NOT NULL THEN 1 END) / COUNT(*)) * 100 AS Percentage FROM CandidateOffers WHERE Department = 'Engineering' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE gyres (name TEXT, avg_salinity REAL); INSERT INTO gyres (name, avg_salinity) VALUES ('North Atlantic', 35.6), ('South Atlantic', 35.1), ('Indian', 34.7), ('North Pacific', 33.4), ('South Pacific', 33.8);
What is the average sea surface salinity in the 'North Pacific' gyre?
SELECT avg_salinity FROM gyres WHERE name = 'North Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), Game VARCHAR(50), Location VARCHAR(50), PrizePool DECIMAL(10,2)); INSERT INTO EsportsEvents (EventID, EventName, Game, Location, PrizePool) VALUES (1, 'Fortnite World Cup', 'Fortnite', 'New York, USA', 30000000.00); INSERT INTO EsportsEvents (EventID, EventName, Game, Location, PrizePool) VALUES (2, 'PUBG Global Invitational', 'PUBG', 'Berlin, Germany', 2000000.00); INSERT INTO EsportsEvents (EventID, EventName, Game, Location, PrizePool) VALUES (3, 'The International', 'Dota 2', 'Seattle, USA', 25000000.00); INSERT INTO EsportsEvents (EventID, EventName, Game, Location, PrizePool) VALUES (4, 'League of Legends World Championship', 'League of Legends', 'Paris, France', 6600000.00);
What is the average prize pool per game for esports events in North America?
SELECT Game, AVG(PrizePool) AS AvgPrizePool FROM EsportsEvents WHERE Location LIKE '%USA%' GROUP BY Game;
gretelai_synthetic_text_to_sql
CREATE TABLE claim (claim_id INT, claim_state VARCHAR(20), claim_status VARCHAR(20));
Insert a new claim with claim ID 1, claim state 'New York', and claim status 'Open'
INSERT INTO claim (claim_id, claim_state, claim_status) VALUES (1, 'New York', 'Open');
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_emissions (id INT, fabric VARCHAR(255), material_type VARCHAR(255), co2_emissions FLOAT); INSERT INTO fabric_emissions (id, fabric, material_type, co2_emissions) VALUES (1, 'cotton', 'natural', 5.0); INSERT INTO fabric_emissions (id, fabric, material_type, co2_emissions) VALUES (2, 'polyester', 'synthetic', 7.5);
What is the maximum CO2 emissions for each fabric type?
SELECT fabric, MAX(co2_emissions) as max_co2_emissions FROM fabric_emissions GROUP BY fabric;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_sizes (customer_id INT PRIMARY KEY, size VARCHAR(255)); INSERT INTO customer_sizes (customer_id, size) VALUES (1001, 'Medium'), (1002, 'Small'), (1003, 'Large');
Update the customer_sizes table to change the size to 'Plus' for the customer_id 1001
UPDATE customer_sizes SET size = 'Plus' WHERE customer_id = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE policy (policy_id INT, policy_region VARCHAR(20)); INSERT INTO policy (policy_id, policy_region) VALUES (1001, 'Northeast'), (1002, 'Southeast'), (1003, 'Northeast'), (1004, 'Southwest'); CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount INT); INSERT INTO claims (claim_id, policy_id, claim_amount) VALUES (1, 1001, 500), (2, 1002, 1200), (3, 1003, 2500), (4, 1004, 3000);
Determine the number of policies and total claim amount by policy region
SELECT p.policy_region, COUNT(p.policy_id) AS num_policies, SUM(c.claim_amount) AS total_claim_amount FROM policy p JOIN claims c ON p.policy_id = c.policy_id GROUP BY p.policy_region;
gretelai_synthetic_text_to_sql
CREATE TABLE taught_arts(id INT, art_name TEXT, workshop_count INT); INSERT INTO taught_arts VALUES (1, 'Pottery', 10), (2, 'Weaving', 12), (3, 'Basketry', 8), (4, 'Painting', 11);
Which traditional arts are most frequently taught in workshops?
SELECT art_name, workshop_count FROM taught_arts ORDER BY workshop_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, gender VARCHAR(10)); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO attorneys (attorney_id, gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Non-binary'); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3);
What is the total number of cases handled by attorneys who identify as 'Female' or 'Non-binary'?
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.gender IN ('Female', 'Non-binary');
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10), position VARCHAR(20), salary DECIMAL(10,2));
What is the total salary of faculty members in the Chemistry department who are not professors?
SELECT department, SUM(salary) FROM faculty WHERE department = 'Chemistry' AND position != 'Professor' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE attendees (attendee_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), phone_number VARCHAR(15), date_of_birth DATE);
Update the email address for attendee_id 1001
UPDATE attendees SET email = 'john.new_email@example.com' WHERE attendee_id = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE iot_sensors (id INT, name TEXT, country TEXT); INSERT INTO iot_sensors (id, name, country) VALUES (1, 'IS1', 'USA'), (2, 'IS2', 'Canada'); CREATE TABLE humidity (id INT, sensor_id INT, timestamp TIMESTAMP, humidity FLOAT); INSERT INTO humidity (id, sensor_id, timestamp, humidity) VALUES (1, 1, '2021-01-01 12:00:00', 45), (2, 1, '2021-01-01 16:00:00', 38), (3, 1, '2021-01-01 20:00:00', 42), (4, 2, '2021-01-01 12:00:00', 50), (5, 2, '2021-01-01 16:00:00', 48), (6, 2, '2021-01-01 20:00:00', 52);
Delete records with humidity levels below 40 for the 'USA' in the month of January from the humidity table.
DELETE FROM humidity WHERE sensor_id IN (SELECT sensor_id FROM humidity WHERE country = 'USA' AND EXTRACT(MONTH FROM timestamp) = 1 AND humidity < 40) AND EXTRACT(MONTH FROM timestamp) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation_budget (id INT, project_id INT, budget DECIMAL(10,2)); INSERT INTO agricultural_innovation_budget (id, project_id, budget) VALUES (1, 1, 50000.00), (2, 2, 75000.00); CREATE TABLE rural_innovation (id INT, project_name VARCHAR(255), sector VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_innovation (id, project_name, sector, location, start_date, end_date) VALUES (1, 'Precision Agriculture', 'Agriculture', 'Village A, Country X', '2020-01-01', '2022-12-31'), (2, 'Smart Irrigation', 'Agriculture', 'Village D, Country W', '2020-01-01', '2022-12-31');
What is the average budget for agricultural innovation projects in 2022?
SELECT AVG(budget) FROM agricultural_innovation_budget JOIN rural_innovation ON agricultural_innovation_budget.project_id = rural_innovation.id WHERE YEAR(start_date) = 2022 AND YEAR(end_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, name VARCHAR(255), country VARCHAR(255));
Add a new excavation site 'El Argar' in Spain.
INSERT INTO excavation_sites (id, name, country) VALUES (1001, 'El Argar', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(50), Age INT, Game VARCHAR(50), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Game, Country) VALUES (1, 'John Doe', 25, 'Virtual Reality Racers', 'USA'); INSERT INTO Players (PlayerID, Name, Age, Game, Country) VALUES (2, 'Jane Smith', 30, 'Virtual Reality Racers', 'Canada'); INSERT INTO Players (PlayerID, Name, Age, Game, Country) VALUES (3, 'Maria Garcia', 22, 'Virtual Reality Racers', 'USA'); CREATE TABLE Transactions (TransactionID INT, PlayerID INT, Amount DECIMAL(5,2), TransactionDate DATE); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (1, 1, 50.00, '2022-01-01'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (2, 1, 10.00, '2022-01-15'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (3, 2, 55.00, '2022-01-05'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (4, 3, 25.00, '2022-01-20'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (5, 3, 25.00, '2022-01-25');
What is the total amount spent by players from the United States on the game "Virtual Reality Racers" in the last month?
SELECT SUM(Amount) FROM Transactions INNER JOIN Players ON Transactions.PlayerID = Players.PlayerID WHERE Players.Country = 'USA' AND Transactions.TransactionDate >= DATEADD(month, -1, GETDATE()) AND Players.Game = 'Virtual Reality Racers';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Concerts (id, city, price) VALUES (1, 'New York', 50.00), (2, 'Los Angeles', 75.00);
What is the average ticket price for concerts in Los Angeles?
SELECT AVG(price) FROM Concerts WHERE city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE community_education_new_2(id INT, workshop_name VARCHAR(50), workshop_location VARCHAR(50), num_participants INT, species_status VARCHAR(50)); INSERT INTO community_education_new_2(id, workshop_name, workshop_location, num_participants, species_status) VALUES (1, 'Wildlife Conservation Basics', 'Africa', 50, 'Critically Endangered'), (2, 'Endangered Species Protection', 'Asia', 75, 'Endangered'), (3, 'Marine Life Education', 'Europe', 60, 'Vulnerable');
What is the total number of participants in 'community_education' for 'Critically Endangered' species workshops?
SELECT SUM(num_participants) FROM community_education_new_2 WHERE species_status = 'Critically Endangered';
gretelai_synthetic_text_to_sql