context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT, VolunteerDate DATE); INSERT INTO VolunteerHours VALUES (1, 4, '2021-01-01'), (1, 6, '2021-02-01'), (2, 8, '2021-03-01'); | What is the average number of hours volunteered per volunteer in 2021? | SELECT AVG(Hours) FROM VolunteerHours WHERE YEAR(VolunteerDate) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, state TEXT, mental_health_score INT); | What is the minimum mental health score of students in each state? | SELECT state, MIN(mental_health_score) FROM students GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name VARCHAR(255)); INSERT INTO menu_items (id, name) VALUES (1, 'Burger'), (2, 'Pizza'), (3, 'Pasta'), (4, 'Salad'), (5, 'Tofu Scramble'); CREATE TABLE food_safety_inspections (id INT, menu_item_id INT, score INT, inspection_date DATE); INSERT INTO food_safety_inspections (id, menu_item_id, score, inspection_date) VALUES (1, 1, 95, '2022-01-01'), (2, 1, 90, '2022-02-01'), (3, 2, 98, '2022-01-01'), (4, 2, 92, '2022-02-01'), (5, 3, 88, '2022-01-01'), (6, 3, 90, '2022-02-01'), (7, 4, 95, '2022-01-01'), (8, 4, 92, '2022-02-01'), (9, 5, 97, '2022-01-01'), (10, 5, 93, '2022-02-01'); | Determine the average food safety score for each menu item | SELECT mi.name, AVG(fsi.score) as avg_score FROM menu_items mi INNER JOIN food_safety_inspections fsi ON mi.id = fsi.menu_item_id GROUP BY mi.id, mi.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing (id INT, individual_id INT, financial_wellbeing_score INT, country VARCHAR(50)); | What is the maximum financial wellbeing score in Central America? | SELECT MAX(financial_wellbeing_score) FROM financial_wellbeing WHERE country LIKE 'Central America%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_temperatures (year INTEGER, ocean VARCHAR(255), temperature FLOAT); | What is the average temperature of the Indian Ocean by year? | SELECT year, AVG(temperature) FROM ocean_temperatures WHERE ocean = 'Indian Ocean' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE element_2017 (element VARCHAR(10), quantity INT, price DECIMAL(5,2)); INSERT INTO element_2017 (element, quantity, price) VALUES ('Dy', 1200, 250.50), ('Tm', 800, 180.25), ('Y', 1500, 150.00); | Which elements were produced in 2017 and their corresponding prices? | SELECT e.element, e.quantity, p.price FROM element_2017 e LEFT JOIN prices p ON e.element = p.element; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguageCountry (LanguageID int, CountryID int); INSERT INTO LanguageCountry (LanguageID, CountryID) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE Countries (CountryID int, CountryName text, HeritageSite BOOLEAN, TraditionalArt BOOLEAN); INSERT INTO Countries (CountryID, CountryName, HeritageSite, TraditionalArt) VALUES (1, 'France', TRUE, TRUE), (2, 'Spain', TRUE, TRUE), (3, 'Peru', TRUE, TRUE); | Which endangered languages are spoken in countries with heritage sites and traditional arts? | SELECT L.LanguageName FROM Languages L JOIN LanguageCountry LC ON L.LanguageID = LC.LanguageID JOIN Countries C ON LC.CountryID = C.CountryID WHERE C.HeritageSite = TRUE AND C.TraditionalArt = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification_data (location VARCHAR(255), acidification_level FLOAT, measurement_date DATE); | Update the ocean acidification level for the most recent measurement in the Atlantic Ocean. | UPDATE ocean_acidification_data SET acidification_level = 3.5 WHERE measurement_date = (SELECT MAX(measurement_date) FROM ocean_acidification_data WHERE location = 'Atlantic Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, policy_holder VARCHAR(50), coverage_amount INT); INSERT INTO policy (policy_id, policy_holder, coverage_amount) VALUES (1, 'John Doe', 400000), (2, 'Jane Smith', 600000); | Delete policy records with a coverage amount over $500,000 | DELETE FROM policy WHERE coverage_amount > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargoes (id INT, name VARCHAR(50), at_sea INT); INSERT INTO cargoes (id, name, at_sea) VALUES (1, 'Electronic Goods', 35), (2, 'Machinery Parts', 42), (3, 'Clothing Items', 20); | Which cargoes have been at sea for more than 45 days but less than 60 days? | SELECT * FROM cargoes WHERE at_sea > 45 AND at_sea < 60; | gretelai_synthetic_text_to_sql |
CREATE TABLE RouteFares (RouteID int, FareType varchar(50)); INSERT INTO RouteFares VALUES (1, 'Standard'); INSERT INTO RouteFares VALUES (1, 'Discounted'); INSERT INTO RouteFares VALUES (2, 'Standard'); INSERT INTO RouteFares VALUES (3, 'Standard'); INSERT INTO RouteFares VALUES (3, 'Discounted'); | List all routes with their respective fare types. | SELECT Routes.RouteName, RouteFares.FareType FROM Routes INNER JOIN RouteFares ON Routes.RouteID = RouteFares.RouteID; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (id INT, species VARCHAR, biomass FLOAT); INSERT INTO fish_stock (id, species, biomass) VALUES (1, 'Tilapia', 500.0), (2, 'Salmon', 800.0), (3, 'Trout', 300.0), (4, 'Bass', 700.0), (5, 'Tilapia', 600.0); | What is the average biomass of fish for each species? | SELECT species, AVG(biomass) FROM fish_stock GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255)); | Add a new record to the 'suppliers' table for a supplier from 'Nairobi, Kenya' | INSERT INTO suppliers (supplier_id, supplier_name, city, country) VALUES (1, 'Mary Muthoni', 'Nairobi', 'Kenya'); | gretelai_synthetic_text_to_sql |
CREATE TABLE flight_safety (id INT PRIMARY KEY, incident VARCHAR(50), year INT); INSERT INTO flight_safety (id, incident, year) VALUES (1, 'Collision with birds', 1999), (2, 'Loss of cabin pressure', 2000), (3, 'Engine failure', 2002), (4, 'Landing gear failure', 2005), (5, 'Hydraulic leak', 2008); | Delete all flight safety records before 2000 | DELETE FROM flight_safety WHERE year < 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralClinics (ClinicID int, ClinicName varchar(50), State varchar(2)); CREATE TABLE HealthcareProfessionals (ProfessionalID int, ProfessionalName varchar(50), ClinicID int); INSERT INTO RuralClinics (ClinicID, ClinicName, State) VALUES (1, 'Rural Clinic A', 'CA'), (2, 'Rural Clinic B', 'CA'), (3, 'Rural Clinic C', 'CA'); INSERT INTO HealthcareProfessionals (ProfessionalID, ProfessionalName, ClinicID) VALUES (1, 'Dr. Smith', 1), (2, 'Dr. Johnson', 2); | Which rural clinics in California have no healthcare professionals? | SELECT RuralClinics.ClinicName FROM RuralClinics LEFT JOIN HealthcareProfessionals ON RuralClinics.ClinicID = HealthcareProfessionals.ClinicID WHERE HealthcareProfessionals.ProfessionalID IS NULL AND RuralClinics.State = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (id INT, equipment_name VARCHAR(50), sale_amount INT, sale_date DATE); INSERT INTO MilitaryEquipmentSales (id, equipment_name, sale_amount, sale_date) VALUES (1, 'Fighter Jet', 45000, '2021-01-01'), (2, 'Tank', 75000, '2021-02-01'); | Update records in the MilitaryEquipmentSales table | UPDATE MilitaryEquipmentSales SET sale_amount = 60000 WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE InventoryExtreme (inventory_id INT, warehouse_id INT, item_name VARCHAR(50), quantity INT, delivery_date DATE); INSERT INTO InventoryExtreme (inventory_id, warehouse_id, item_name, quantity, delivery_date) VALUES (1, 1, 'Box', 10, '2022-01-01'), (2, 2, 'Palette', 20, '2022-02-01'), (3, 3, 'Package', 30, '2022-03-01'); | What is the minimum quantity of items in the inventory for any warehouse? | SELECT MIN(quantity) as min_quantity FROM InventoryExtreme; | gretelai_synthetic_text_to_sql |
CREATE TABLE biodiversity_monitoring_programs (id INT, name TEXT, region TEXT); INSERT INTO biodiversity_monitoring_programs (id, name, region) VALUES (1, 'Arctic Biodiversity Assessment', 'Arctic'); INSERT INTO biodiversity_monitoring_programs (id, name, region) VALUES (2, 'Circumpolar Biodiversity Monitoring Program', 'Arctic'); INSERT INTO biodiversity_monitoring_programs (id, name, region) VALUES (3, 'International Tundra Experiment', 'Arctic'); CREATE TABLE biodiversity_data (program_id INT, station_id INT, year INT, species_count INT); INSERT INTO biodiversity_data (program_id, station_id, year, species_count) VALUES (1, 1, 2015, 50); INSERT INTO biodiversity_data (program_id, station_id, year, species_count) VALUES (1, 2, 2016, 75); INSERT INTO biodiversity_data (program_id, station_id, year, species_count) VALUES (2, 1, 2015, 50); INSERT INTO biodiversity_data (program_id, station_id, year, species_count) VALUES (2, 3, 2017, 100); INSERT INTO biodiversity_data (program_id, station_id, year, species_count) VALUES (3, 2, 2016, 75); | Which biodiversity monitoring programs have collected data at more than 2 arctic research stations? | SELECT program_id, name, COUNT(DISTINCT station_id) as stations_visited FROM biodiversity_data GROUP BY program_id, name HAVING stations_visited > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation (id INT, name VARCHAR(255), location VARCHAR(255), budget FLOAT, project_type VARCHAR(255)); INSERT INTO transportation (id, name, location, budget, project_type) VALUES (1, 'Railway', 'California', 10000000, 'Rail'), (2, 'Airport', 'Texas', 15000000, 'Air'); | What is the maximum budget for each type of transportation project? | SELECT t.project_type, MAX(t.budget) as max_budget FROM transportation t GROUP BY t.project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryPersonnel (Id INT, Country VARCHAR(50), Service VARCHAR(50), Quantity INT);INSERT INTO MilitaryPersonnel (Id, Country, Service, Quantity) VALUES (1, 'Brazil', 'Army', 250000), (2, 'Argentina', 'Navy', 50000), (3, 'Colombia', 'Air Force', 40000), (4, 'Peru', 'Navy', 30000); | What is the total number of military personnel per country in the South American region with service 'Navy'? | SELECT Country, SUM(Quantity) AS TotalPersonnel FROM MilitaryPersonnel WHERE Country IN ('Brazil', 'Argentina', 'Colombia', 'Peru') AND Service = 'Navy' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (restaurant_id INT, cuisine VARCHAR(50), location VARCHAR(50), revenue INT); INSERT INTO Restaurants (restaurant_id, cuisine, location, revenue) VALUES (1, 'Italian', 'New York', 5000), (2, 'Mexican', 'Los Angeles', 7000), (3, 'Italian', 'Chicago', 6000); | What is the total revenue for each cuisine type in New York? | SELECT cuisine, SUM(revenue) AS total_revenue FROM Restaurants WHERE location = 'New York' GROUP BY cuisine; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableFabrics (fabric_id INT, fabric_name VARCHAR(50), source_country VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO SustainableFabrics (fabric_id, fabric_name, source_country, price, quantity) VALUES (1, 'Organic Cotton', 'Guatemala', 3.50, 200), (2, 'Recycled Polyester', 'Belize', 4.25, 150), (3, 'Tencel', 'Honduras', 5.00, 100); | What is the total quantity of sustainable fabrics sourced from Central America? | SELECT SUM(quantity) FROM SustainableFabrics WHERE source_country = 'Central America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutomationEquipment (EquipmentID INT, LastUpdate DATETIME); | How many machines in the 'AutomationEquipment' table have been updated in the past month? | SELECT COUNT(*) FROM AutomationEquipment WHERE LastUpdate >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, country) VALUES (1, 'Adaeze Okonkwo', 30, 'Female', 'Nigeria'); INSERT INTO farmers (id, name, age, gender, country) VALUES (2, 'Chidinma Eze', 35, 'Female', 'Nigeria'); CREATE TABLE trainings (id INT, farmer_id INT, title VARCHAR(50), completion_date DATE); INSERT INTO trainings (id, farmer_id, title, completion_date) VALUES (1, 1, 'Agroecology Course', '2016-03-01'); INSERT INTO trainings (id, farmer_id, title, completion_date) VALUES (2, 2, 'Organic Farming Workshop', '2018-08-15'); | What is the number of women farmers in Nigeria who have participated in agricultural training programs since 2015? | SELECT COUNT(*) FROM farmers f JOIN trainings t ON f.id = t.farmer_id WHERE f.gender = 'Female' AND f.country = 'Nigeria' AND t.completion_date >= '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE europium_production (year INT, production FLOAT); INSERT INTO europium_production (year, production) VALUES (2015, 5000), (2016, 6000), (2017, 7000), (2018, 8000), (2019, 9000), (2020, 10000); | Delete the record of Europium production in 2017 | DELETE FROM europium_production WHERE year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE natural_materials (material_id INT PRIMARY KEY, material_name VARCHAR(50), country_of_origin VARCHAR(50)); INSERT INTO natural_materials (material_id, material_name, country_of_origin) VALUES (1, 'Organic Cotton', 'India'), (2, 'Hemp', 'China'), (3, 'Bamboo', 'China'); | Which natural materials are used by textile manufacturers and their origin? | SELECT * FROM natural_materials; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget_allocation (state VARCHAR(20), service VARCHAR(20), allocation FLOAT); INSERT INTO budget_allocation (state, service, allocation) VALUES ('New York', 'Education', 15000000), ('New York', 'Healthcare', 20000000); | What is the average budget allocation for education and healthcare services in the state of New York? | SELECT AVG(allocation) FROM budget_allocation WHERE state = 'New York' AND service IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, city VARCHAR(20), price DECIMAL(5,2)); INSERT INTO events (id, city, price) VALUES (1, 'Paris', 20.99), (2, 'London', 18.50); | What is the average ticket price for events in Paris and London? | SELECT AVG(price) FROM events WHERE city IN ('Paris', 'London'); | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation_projects (project VARCHAR(50), budget INT); INSERT INTO transportation_projects (project, budget) VALUES ('Railway Project', 2000000), ('Highway Project', 3000000), ('Bridge Project', 1000000); | What is the maximum budget allocated for a single transportation project? | SELECT MAX(budget) FROM transportation_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), certification_date DATE); | Delete all records of green building certifications that were issued before the year 2000. | DELETE FROM green_buildings WHERE certification_date < '2000-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE popular_articles (id INT, title TEXT, author TEXT, views INT); | Delete all records from the "popular_articles" table where the "author" is "John Doe" | DELETE FROM popular_articles WHERE author = 'John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Practices (id INT, name VARCHAR(255), type VARCHAR(255), implementation_location VARCHAR(255), industry VARCHAR(255)); INSERT INTO Practices (id, name, type, implementation_location, industry) VALUES (1, 'Living Wage', 'Fair Labor Practice', 'Bangladesh', 'Denim'); INSERT INTO Practices (id, name, type, implementation_location, industry) VALUES (2, 'Safe Workplace', 'Fair Labor Practice', 'Bangladesh', 'Denim'); | Which fair labor practices are implemented in the denim production in Bangladesh? | SELECT DISTINCT name FROM Practices WHERE implementation_location = 'Bangladesh' AND industry = 'Denim' AND type = 'Fair Labor Practice' | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, director VARCHAR(255)); INSERT INTO movies (id, title, release_year, director) VALUES (1, 'The Shawshank Redemption', 1994, 'Frank Darabont'); | What's the name of the director who directed 'The Shawshank Redemption'? | SELECT director FROM movies WHERE title = 'The Shawshank Redemption'; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (campaign_id INT, campaign_name VARCHAR(255), start_date DATE, end_date DATE, ad_spend DECIMAL(10,2)); CREATE TABLE ad_interactions (interaction_id INT, user_id INT, campaign_id INT, interaction_date DATE); | Find the number of unique users who engaged with ads related to 'sustainable fashion' in the past year, and the total ad spend for those campaigns. | SELECT c.campaign_name, COUNT(DISTINCT ai.user_id) as unique_users, SUM(c.ad_spend) as total_ad_spend FROM campaigns c INNER JOIN ad_interactions ai ON c.campaign_id = ai.campaign_id WHERE ai.interaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND c.campaign_name LIKE '%sustainable fashion%' GROUP BY c.campaign_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ceo (company_id INT, CEO TEXT, employees INT); INSERT INTO ceo (company_id, CEO, employees) VALUES (1, 'male', 20), (2, 'non-binary', 5), (3, 'female', 12), (4, 'male', 30), (5, 'female', 40), (6, 'transgender', 25), (7, 'non-binary', 8), (8, 'queer', 35); | How many companies in the "healthcare" sector have a CEO from the LGBTQ+ community and have more than 10 employees? | SELECT COUNT(*) FROM company JOIN ceo ON company.id = ceo.company_id WHERE company.industry = 'healthcare' AND ceo.CEO IN ('transgender', 'non-binary', 'queer') AND ceo.employees > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (bridge_id INT, bridge_name VARCHAR(50), state VARCHAR(50), construction_year INT); | What are the number of bridges and their average age in Texas that are older than 60 years? | SELECT COUNT(bridges.bridge_id) as number_of_bridges, AVG(bridges.construction_year) as average_age FROM bridges WHERE bridges.state = 'Texas' AND bridges.construction_year < 1962; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists worker_region (worker_id INT, industry TEXT, region TEXT);INSERT INTO worker_region (worker_id, industry, region) VALUES (1, 'construction', 'east'), (2, 'retail', 'west'), (3, 'manufacturing', 'west'); | What is the total number of workers in the 'retail' industry and 'west' region? | SELECT COUNT(*) FROM worker_region WHERE industry = 'retail' AND region = 'west'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours_ca_au (id INT, country VARCHAR(50), engagement_time INT); INSERT INTO virtual_tours_ca_au (id, country, engagement_time) VALUES (1, 'Canada', 500), (2, 'Canada', 600), (3, 'Australia', 700), (4, 'Australia', 800); | What is the average engagement time for virtual tours in Canada and Australia? | SELECT country, AVG(engagement_time) FROM virtual_tours_ca_au WHERE country IN ('Canada', 'Australia') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices (project_id INT, practice VARCHAR(50)); INSERT INTO sustainable_practices VALUES (1001, 'Solar panels'), (1001, 'Green roof'), (1002, 'Rainwater harvesting'), (1003, 'Insulation'); | Which sustainable building practices were implemented in New York projects? | SELECT practice FROM sustainable_practices WHERE project_id IN (SELECT project_id FROM building_projects WHERE state = 'New York'); | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(255), spacecraft_id INT, role VARCHAR(255), country VARCHAR(255)); INSERT INTO astronauts VALUES (4, 'Rakesh Sharma', 1, 'Commander', 'India'); | How many astronauts from India have participated in space missions? | SELECT COUNT(id) as indian_astronauts_count FROM astronauts WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_minority VARCHAR(10)); INSERT INTO Companies (id, name, industry, country, founding_year, founder_minority) VALUES (1, 'GreenTech', 'Renewable Energy', 'USA', 2019, 'Yes'); INSERT INTO Companies (id, name, industry, country, founding_year, founder_minority) VALUES (2, 'SunPower', 'Renewable Energy', 'USA', 2018, 'No'); | What is the percentage of companies founded by underrepresented minorities in each industry? | SELECT industry, ROUND(100.0 * SUM(CASE WHEN founder_minority = 'Yes' THEN 1 ELSE 0 END) / COUNT(*), 2) as minority_percentage FROM Companies GROUP BY industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ID INT, Name VARCHAR(255), Type VARCHAR(255)); INSERT INTO Exhibitions (ID, Name, Type) VALUES (1, 'Modern Art 1', 'Modern'), (2, 'Modern Art 2', 'Modern'); CREATE TABLE Visitors (ID INT, ExhibitionID INT, Age INT, Gender VARCHAR(50)); | What is the distribution of visitors by age group for the modern art exhibitions? | SELECT e.Type, v.AgeGroup, COUNT(v.ID) as VisitorCount FROM Visitors v JOIN (SELECT ExhibitionID, CASE WHEN Age < 18 THEN 'Under 18' WHEN Age BETWEEN 18 AND 35 THEN '18-35' WHEN Age BETWEEN 36 AND 60 THEN '36-60' ELSE 'Above 60' END AS AgeGroup FROM Visitors WHERE ExhibitionID IN (1, 2)) v2 ON v.ID = v2.ID GROUP BY e.Type, v.AgeGroup; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA suburban; CREATE TABLE suburban.trains (id INT, maintenance_cost INT); INSERT INTO suburban.trains (id, maintenance_cost) VALUES (1, 6000), (2, 3000), (3, 4000); | How many trains in the 'suburban' schema have maintenance costs less than $4000? | SELECT COUNT(*) FROM suburban.trains WHERE maintenance_cost < 4000; | gretelai_synthetic_text_to_sql |
CREATE TABLE TimeOnPlatform (PlayerID INT, Platform VARCHAR(10), AvgTime FLOAT); INSERT INTO TimeOnPlatform (PlayerID, Platform, AvgTime) VALUES (1, 'PC', 150.5); | What is the difference in the average time spent on the platform, per player, between PC and console users? | SELECT a.Platform, AVG(a.AvgTime - b.AvgTime) as AvgTimeDifference FROM TimeOnPlatform a, TimeOnPlatform b WHERE a.Platform = 'PC' AND b.Platform = 'Console' GROUP BY a.Platform; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (Id INT, Age INT, Gender VARCHAR(10), Ethnicity VARCHAR(20)); INSERT INTO CommunityHealthWorkers (Id, Age, Gender, Ethnicity) VALUES (1, 45, 'Female', 'Hispanic'), (2, 35, 'Male', 'LGBTQ+'), (3, 50, 'Non-binary', 'African American'), (4, 40, 'Transgender', 'LGBTQ+'), (5, 60, 'Male', 'Native American'), (6, 30, 'Female', 'Native American'); | What is the total number of community health workers who identify as Native American and are aged 50 or above? | SELECT COUNT(*) as CountOfWorkers FROM CommunityHealthWorkers WHERE Ethnicity = 'Native American' AND Age >= 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE mature_forest (tree_id INT, species VARCHAR(50), age INT); | What is the average age of trees in the mature_forest table, grouped by their species? | SELECT species, AVG(age) FROM mature_forest GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT, ArtistID INT, ArtType VARCHAR(50), ArtYear INT); INSERT INTO Artists VALUES (1, 'Sita Das'), (2, 'Hiroshi Tanaka'); INSERT INTO ArtPieces VALUES (1, 1, 'Kantha', 2010), (2, 1, 'Batik', 2015), (3, 2, 'Kasuri', 2005), (4, 2, 'Ukiyo-e', 2020); | What is the total number of traditional textile art pieces per artist? | SELECT Artists.ArtistName, COUNT(ArtPieces.ArtPieceID) AS TotalArtPieces FROM Artists INNER JOIN ArtPieces ON Artists.ArtistID = ArtPieces.ArtistID WHERE ArtPieces.ArtType LIKE '%textile%' GROUP BY Artists.ArtistName; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255), type VARCHAR(255), speed DECIMAL(5,2), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO vessels (id, name, type, speed, latitude, longitude) VALUES (1, 'VesselA', 'Passenger', 18.5, 59.424744, 24.879444); | What is the average speed of vessels with the 'Passenger' type in the Baltic Sea? | SELECT AVG(speed) as avg_speed FROM vessels WHERE type = 'Passenger' AND latitude BETWEEN 55.0 AND 65.0 AND longitude BETWEEN 10.0 AND 30.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), launch_date DATE); INSERT INTO SpaceMissions (id, name, launch_date) VALUES (1, 'Jupiter Orbiter', '2025-01-01'), (2, 'Jupiter Habitat', '2027-04-01'), (3, 'Mars Rover', '2020-07-30'), (4, 'Saturn Probe', '2023-12-15'); | What is the earliest launch date for a mission to Jupiter? | SELECT MIN(launch_date) FROM SpaceMissions WHERE name LIKE '%Jupiter%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellite (id INT, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUES (1, 'Landsat 1', 'Earth Observation', 'Boeing', '1972-07-23'); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUES (2, 'Envisat', 'Earth Observation', 'Astrium', '2002-03-01'); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUES (3, 'ResourceSat 1', 'Earth Observation', 'ISRO', '2003-10-17'); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUES (4, 'Starlink 1', 'Communications', 'SpaceX', '1990-12-21'); | How many satellites were launched by American companies in the 1990s? | SELECT COUNT(s.id) as satellite_count FROM Satellite s INNER JOIN Manufacturer m ON s.manufacturer = m.name WHERE m.country = 'United States' AND s.launch_date BETWEEN '1990-01-01' AND '1999-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (id INT, name TEXT, location TEXT, budget DECIMAL(10,2)); INSERT INTO Accommodations (id, name, location, budget) VALUES (1, 'Ramp', 'Texas', 10000.00), (2, 'Elevator', 'Texas', 20000.00), (3, 'Handrail', 'California', 5000.00), (4, 'Ramp', 'California', 12000.00); | What is the number of disability accommodations in each location, and what is the average budget spent on accommodations in each location? | SELECT location, COUNT(*) as num_accommodations, AVG(budget) as avg_budget_per_accommodation FROM Accommodations GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE FinanceAdaptation (Country TEXT, Investment_Amount NUMERIC); INSERT INTO FinanceAdaptation (Country, Investment_Amount) VALUES ('Indonesia', 2500000), ('Thailand', 3000000), ('Malaysia', 2000000); | What is the total climate finance invested in Southeast Asia for climate adaptation? | SELECT SUM(Investment_Amount) FROM FinanceAdaptation WHERE Country IN ('Indonesia', 'Thailand', 'Malaysia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE MusicSales (SaleID INT, ArtistIndependent BOOLEAN, Genre VARCHAR(10), SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID, ArtistIndependent, Genre, SalesAmount) VALUES (1, true, 'Jazz', 12.99), (2, false, 'Rock', 15.00), (3, true, 'Pop', 19.45); | What is the total revenue generated from digital music sales by independent artists? | SELECT SUM(SalesAmount) FROM MusicSales WHERE ArtistIndependent = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_supply_chain (product_id INT, source VARCHAR(255), quantity INT);CREATE TABLE ethical_suppliers (supplier_id INT, name VARCHAR(255), country VARCHAR(255), fair_trade BOOLEAN);CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(10,2), quantity INT); | What is the total quantity of products in the 'circular_supply_chain' table that are sourced from fair trade suppliers in the 'ethical_suppliers' table and sold in the 'sales' table? | SELECT SUM(s.quantity) FROM sales s JOIN circular_supply_chain c ON s.product_id = c.product_id JOIN ethical_suppliers e ON c.source = e.name WHERE e.fair_trade = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20), square_footage INT, co_owned BOOLEAN); INSERT INTO properties (id, city, square_footage, co_owned) VALUES (1, 'Seattle', 1800, true); INSERT INTO properties (id, city, square_footage, co_owned) VALUES (2, 'Seattle', 1500, false); | What is the average square footage of co-owned properties in Seattle? | SELECT AVG(square_footage) FROM properties WHERE city = 'Seattle' AND co_owned = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(100), source VARCHAR(50), date DATE); INSERT INTO articles (id, title, source, date) VALUES (1, 'Article 1', 'Source A', '2021-02-01'); INSERT INTO articles (id, title, source, date) VALUES (2, 'Article 2', 'Source B', '2021-02-02'); INSERT INTO articles (id, title, source, date) VALUES (3, 'Article 3', 'Source A', '2021-02-03'); INSERT INTO articles (id, title, source, date) VALUES (4, 'Article 4', 'Source C', '2021-01-31'); | What is the total number of articles published in February 2021? | SELECT COUNT(*) as total_articles FROM articles WHERE date BETWEEN '2021-02-01' AND '2021-02-28'; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_paper_dates (id INT, paper_name VARCHAR(255), date DATE); | How many explainable AI research papers have been published in the past 3 years? | SELECT COUNT(*) FROM research_paper_dates WHERE date >= DATEADD(year, -3, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (booking_id INT, team_id INT, number_of_tickets INT, group_booking BOOLEAN); INSERT INTO bookings (booking_id, team_id, number_of_tickets, group_booking) VALUES (1, 1, 10, true); INSERT INTO bookings (booking_id, team_id, number_of_tickets, group_booking) VALUES (2, 2, 5, false); | Which teams have the highest percentage of ticket sales from group bookings? | SELECT teams.team_name, 100.0 * AVG(CASE WHEN bookings.group_booking THEN bookings.number_of_tickets ELSE 0 END) / SUM(bookings.number_of_tickets) as percentage_group_bookings FROM bookings JOIN teams ON bookings.team_id = teams.team_id GROUP BY teams.team_name ORDER BY percentage_group_bookings DESC; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetic;CREATE TABLE if not exists genetic.projects (id INT PRIMARY KEY, name VARCHAR(100), start_date DATE);INSERT INTO genetic.projects (id, name, start_date) VALUES (1, 'ProjectX', '2018-01-01'), (2, 'ProjectY', '2020-05-15'), (3, 'ProjectZ', '2017-08-08'); | What is the number of genetic research projects per year? | SELECT YEAR(start_date) AS year, COUNT(*) AS projects_count FROM genetic.projects GROUP BY year ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArcticMammals(species VARCHAR(255), population_size FLOAT); | What is the average population size of each Arctic mammal species? | SELECT species, AVG(population_size) FROM ArcticMammals GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE ISRO_Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(30), LaunchDate DATETIME, Altitude INT); INSERT INTO ISRO_Spacecraft (SpacecraftID, Name, Manufacturer, LaunchDate, Altitude) VALUES (1, 'Chandrayaan-1', 'ISRO', '2008-10-22', 100000), (2, 'Mangalyaan', 'ISRO', '2013-11-05', 434000), (3, 'Astrosat', 'ISRO', '2015-09-28', 650000), (4, 'Reusable Launch Vehicle - Technology Demonstrator (RLV-TD)', 'ISRO', '2016-05-23', 65000); | What is the maximum altitude reached by a spacecraft built by ISRO? | SELECT MAX(Altitude) FROM ISRO_Spacecraft; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndianRuralHospitals (State VARCHAR(20), HospitalName VARCHAR(50), NumberOfBeds INT); INSERT INTO IndianRuralHospitals (State, HospitalName, NumberOfBeds) VALUES ('State A', 'Hospital A', 50), ('State A', 'Hospital B', 75), ('State B', 'Hospital C', 100), ('State B', 'Hospital D', 125); | What is the maximum number of hospital beds in a rural hospital in India? | SELECT MAX(NumberOfBeds) FROM IndianRuralHospitals WHERE State IN ('State A', 'State B') AND HospitalName IN ('Hospital A', 'Hospital B', 'Hospital C', 'Hospital D'); | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility_initiatives (initiative_id INT, initiative_name VARCHAR(50), region VARCHAR(50), launch_year INT); INSERT INTO accessibility_initiatives (initiative_id, initiative_name, region, launch_year) VALUES (1, 'AccessInit1', 'APAC', 2017), (2, 'AccessInit2', 'EMEA', 2016), (3, 'AccessInit3', 'APAC', 2018), (4, 'AccessInit4', 'AMER', 2019), (5, 'AccessInit5', 'EMEA', 2020), (6, 'AccessInit6', 'AMER', 2017); | What is the total number of accessible technology initiatives in each region? | SELECT region, COUNT(*) as count FROM accessibility_initiatives GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE game_sessions (session_id INT, player_id INT, game_mode VARCHAR(20), map_id INT); CREATE TABLE maps (map_id INT, map_name VARCHAR(20)); | Update the game_mode column in the game_sessions table to 'Battle Royale' for all sessions on the maps table with the name 'Tropic Island' | UPDATE game_sessions SET game_mode = 'Battle Royale' WHERE map_id IN (SELECT map_id FROM maps WHERE map_name = 'Tropic Island'); | gretelai_synthetic_text_to_sql |
CREATE TABLE alert_rules (id INT, rule_name VARCHAR(255)); INSERT INTO alert_rules (id, rule_name) VALUES (1, 'Unusual outbound traffic'), (2, 'Suspicious login'), (3, 'Malware detection'); CREATE TABLE alerts (id INT, rule_id INT, timestamp DATETIME); INSERT INTO alerts (id, rule_id, timestamp) VALUES (1, 1, '2022-01-01 12:34:56'), (2, 2, '2022-02-02 09:10:11'), (3, 1, '2022-03-03 17:22:33'), (4, 3, '2022-04-04 04:44:44'); | How many times has the rule "Unusual outbound traffic" been triggered in the last quarter? | SELECT COUNT(*) FROM alerts WHERE rule_id IN (SELECT id FROM alert_rules WHERE rule_name = 'Unusual outbound traffic') AND timestamp >= DATE_SUB(NOW(), INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns_2021 (campaign_id INT, name VARCHAR(50), budget INT, region VARCHAR(50)); INSERT INTO campaigns_2021 (campaign_id, name, budget, region) VALUES (1, 'Mental Health Matters', 15000, 'Northeast'), (2, 'Break the Stigma', 20000, 'Southwest'), (3, 'Healing Hearts', 12000, 'Midwest'); | How many mental health campaigns were launched in 'Southwest' region in 2021? | SELECT COUNT(*) FROM campaigns_2021 WHERE region = 'Southwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibits (exhibit_id INT, city VARCHAR(50), tickets_sold INT, price DECIMAL(5,2)); INSERT INTO Exhibits (exhibit_id, city, tickets_sold, price) VALUES (1, 'New York', 500, 25.99), (2, 'Los Angeles', 700, 22.49), (3, 'Chicago', 350, 30.00); | Find the top 3 cities with the highest art exhibit revenue. | SELECT city, SUM(tickets_sold * price) as revenue FROM Exhibits GROUP BY city ORDER BY revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Art_Exhibition (exhibition_id INT, gallery_name VARCHAR(255), year INT, attendance INT); | Find the top 3 most attended exhibitions in the 'Art Gallery' in 2019. | SELECT exhibition_id, gallery_name, attendance FROM Art_Exhibition WHERE gallery_name = 'Art Gallery' AND year = 2019 ORDER BY attendance DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName VARCHAR(50), Age INT, Gender VARCHAR(10), ProgramID INT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Age, Gender, ProgramID) VALUES (10, 'Fatima', 27, 'Female', 5), (11, 'Kevin', 36, 'Male', 6), (12, 'Sofia', 24, 'Female', 7), (13, 'Raul', 42, 'Male', 8), (14, 'Xiao', 39, 'Female', 9), (15, 'Hugo', 29, 'Male', 5), (16, 'Aisha', 33, 'Female', 6), (17, 'Katsumi', 45, 'Male', 7), (18, 'Nadia', 37, 'Female', 8), (19, 'Mateo', 28, 'Male', 9); | Which volunteers have participated in more than one program? | SELECT VolunteerName, COUNT(*) FROM Volunteers GROUP BY VolunteerName HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, FavoriteExercise VARCHAR(20)); CREATE TABLE Wearables (DeviceID INT, MemberID INT, Type VARCHAR(20)); INSERT INTO Members (MemberID, Age, FavoriteExercise) VALUES (1, 35, 'Yoga'); INSERT INTO Members (MemberID, Age, FavoriteExercise) VALUES (2, 28, 'Running'); INSERT INTO Wearables (DeviceID, MemberID, Type) VALUES (1, 1, 'Watch'); INSERT INTO Wearables (DeviceID, MemberID, Type) VALUES (2, 1, 'Heart Rate Monitor'); | How many members have a heart rate monitor as their wearable device? | SELECT COUNT(*) FROM Members JOIN Wearables ON Members.MemberID = Wearables.MemberID WHERE Type = 'Heart Rate Monitor'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, country VARCHAR(50), year INT, threat_level FLOAT); INSERT INTO threat_intelligence (id, country, year, threat_level) VALUES (1, 'USA', 2022, 4.5); INSERT INTO threat_intelligence (id, country, year, threat_level) VALUES (2, 'XYZ', 2022, 3.2); | What is the average threat level for country XYZ in 2022? | SELECT AVG(threat_level) FROM threat_intelligence WHERE country = 'XYZ' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE attractions (id INT PRIMARY KEY, name TEXT, type TEXT); | Insert a new record into the "attractions" table for 'Taj Mahal' with type 'monument' | INSERT INTO attractions (id, name, type) VALUES (3, 'Taj Mahal', 'monument'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Space_Missions (mission_date DATE, continent VARCHAR(255), success BOOLEAN); INSERT INTO Space_Missions (mission_date, continent, success) VALUES ('2020-01-01', 'North America', TRUE), ('2020-02-01', 'Asia', FALSE), ('2020-03-01', 'Europe', TRUE), ('2020-04-01', 'North America', TRUE), ('2020-05-01', 'Africa', FALSE); | What is the percentage of successful space missions by continent in 2020? | SELECT continent, (COUNT(success) FILTER (WHERE success = TRUE) * 100.0 / COUNT(*)) AS success_percentage FROM Space_Missions WHERE YEAR(mission_date) = 2020 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue_by_date (date DATE, restaurant VARCHAR(50), revenue INT); INSERT INTO revenue_by_date (date, restaurant, revenue) VALUES ('2022-01-01', 'Restaurant A', 3000), ('2022-01-01', 'Restaurant B', 4000), ('2022-01-01', 'Restaurant C', 5000), ('2022-01-02', 'Restaurant A', 4000), ('2022-01-02', 'Restaurant B', 5000), ('2022-01-02', 'Restaurant C', 6000); | What is the total revenue for each restaurant on a specific date? | SELECT restaurant, SUM(revenue) FROM revenue_by_date WHERE date = '2022-01-01' GROUP BY restaurant; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'), (4, 'VesselD'), (5, 'VesselE'); CREATE TABLE safety_records (id INT, vessel_id INT, inspection_date DATE, result ENUM('PASS', 'FAIL')); | Add new safety record for VesselE with ID 5 | INSERT INTO safety_records (id, vessel_id, inspection_date, result) VALUES (1, 5, '2022-03-14', 'PASS'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Garments (GarmentID INT, GarmentName VARCHAR(50));CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50));CREATE TABLE DiscontinuedGarments (GarmentID INT, ManufacturerID INT, DiscontinuedDate DATE); | List the garments that were discontinued and the manufacturers responsible. | SELECT G.GarmentName, M.ManufacturerName FROM Garments G JOIN DiscontinuedGarments DG ON G.GarmentID = DG.GarmentID JOIN Manufacturers M ON DG.ManufacturerID = M.ManufacturerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, building_name VARCHAR(100), country VARCHAR(50)); INSERT INTO green_buildings (id, building_name, country) VALUES (1, 'Green Building 1', 'Canada'), (2, 'Green Building 2', 'Mexico'); | How many green buildings are there in each country in the green_buildings table? | SELECT country, COUNT(*) FROM green_buildings GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (id INT, name VARCHAR(50)); INSERT INTO Countries (id, name) VALUES (1, 'CountryA'), (2, 'CountryB'); CREATE TABLE CarbonOffsetProjects (id INT, country_id INT, name VARCHAR(50), co2_offset FLOAT); INSERT INTO CarbonOffsetProjects (id, country_id, name, co2_offset) VALUES (1, 1, 'ProjectA', 100), (2, 1, 'ProjectB', 200), (3, 2, 'ProjectC', 300); | What is the average CO2 offset for carbon offset projects in a given country? | SELECT Countries.name, AVG(CarbonOffsetProjects.co2_offset) FROM Countries INNER JOIN CarbonOffsetProjects ON Countries.id = CarbonOffsetProjects.country_id GROUP BY Countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT PRIMARY KEY, project_name VARCHAR(255), project_location VARCHAR(255), project_type VARCHAR(255), capacity_mw FLOAT, carbon_offsets INT); CREATE TABLE states (state_code CHAR(2), state_name VARCHAR(255)); | Show the top 3 states with the highest average carbon offsets for renewable energy projects. | SELECT project_location, AVG(carbon_offsets) AS avg_carbon_offsets FROM renewable_projects GROUP BY project_location ORDER BY avg_carbon_offsets DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, square_footage FLOAT, energy_rating INT); | What is the average square footage of properties in the 'green_buildings' table? | SELECT AVG(square_footage) FROM green_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, year INT, country VARCHAR(50), equipment VARCHAR(50), value FLOAT); INSERT INTO MilitaryEquipmentSales (id, year, country, equipment, value) VALUES (1, 2023, 'Indonesia', 'Helicopters', 8000000); | What is the total value of military equipment sales to Southeast Asian countries in 2023? | SELECT SUM(value) FROM MilitaryEquipmentSales WHERE year = 2023 AND country LIKE 'Southeast%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_data (id INT PRIMARY KEY, name VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO community_data (id, name, population, region) VALUES (1, 'Community A', 500, 'Arctic'); INSERT INTO community_data (id, name, population, region) VALUES (2, 'Community B', 800, 'Non-Arctic'); INSERT INTO community_data (id, name, population, region) VALUES (3, 'Community C', 300, 'Arctic'); | What is the average population size of indigenous communities in the Arctic region? | SELECT region, AVG(population) AS avg_population FROM community_data WHERE region = 'Arctic' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_2020 (id INT, mine VARCHAR(50), year INT, resource VARCHAR(50), quantity INT); INSERT INTO production_2020 (id, mine, year, resource, quantity) VALUES (1, 'Mine A', 2020, 'Coal', 1000), (2, 'Mine B', 2020, 'Iron Ore', 2000), (3, 'Mine A', 2020, 'Iron Ore', 1500); | What is the total amount of coal produced by each mine in 2020? | SELECT mine, SUM(CASE WHEN resource = 'Coal' THEN quantity ELSE 0 END) AS coal_production FROM production_2020 WHERE year = 2020 GROUP BY mine; | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (name VARCHAR(255), year_decommissioned INT, type VARCHAR(255)); | Delete all records of ships that were decommissioned before 2000 from the Ships table. | DELETE FROM ships WHERE year_decommissioned < 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE nonprofits (id INT, organization_name VARCHAR(50), country VARCHAR(50), mission_statement TEXT); INSERT INTO nonprofits (id, organization_name, country, mission_statement) VALUES (1, 'Doctors Without Borders', 'Switzerland', 'Provide medical assistance to people in crisis.'); | List the locations with more than 5 nonprofits and the average governance factor for those locations. | SELECT i.location, AVG(e.governance_factor) as avg_gov_factor FROM impact_investments i LEFT JOIN esg_factors e ON i.id = e.investment_id LEFT JOIN nonprofits n ON i.location = n.country GROUP BY i.location HAVING COUNT(DISTINCT n.id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_facilities (id INT, state VARCHAR(20), type VARCHAR(20)); INSERT INTO recycling_facilities (id, state, type) VALUES (1, 'California', 'recycling'), (2, 'New York', 'recycling'), (3, 'California', 'landfill'), (4, 'Texas', 'recycling'); | What is the percentage of recycling facilities that are in the state of California? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM recycling_facilities)) AS percentage_of_recycling_facilities FROM recycling_facilities WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities.building_energy_consumption (city VARCHAR(50), consumption FLOAT); INSERT INTO smart_cities.building_energy_consumption (city, consumption) VALUES ('Toronto', 4000.0), ('Mumbai', 5000.0), ('Barcelona', 6000.0), ('Rio de Janeiro', 7000.0), ('Melbourne', 8000.0), ('Dublin', 9000.0); | What is the sum of energy consumption for buildings in the 'smart_cities' schema, grouped by city, and only for buildings with consumption > 1500? | SELECT city, SUM(consumption) AS total_consumption FROM smart_cities.building_energy_consumption WHERE consumption > 1500 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), UnderrepresentedCommunity VARCHAR(50), HireDate DATE, TerminationDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, UnderrepresentedCommunity, HireDate, TerminationDate) VALUES (1, 'John', 'Doe', 'Yes', '2018-01-01', '2022-01-01'), (2, 'Jane', 'Doe', 'No', '2019-06-15', NULL), (3, 'Mike', 'Johnson', 'Yes', '2020-03-20', NULL); | What is the retention rate of employees from underrepresented communities in the company? | SELECT COUNT(CASE WHEN TerminationDate IS NULL THEN 1 END) / COUNT(*) AS RetentionRate FROM Employees WHERE UnderrepresentedCommunity = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, investor VARCHAR(255), amount FLOAT, date DATE); INSERT INTO investments (id, investor, amount, date) VALUES (13, 'Green Endeavors', 110000, '2022-01-15'); INSERT INTO investments (id, investor, amount, date) VALUES (14, 'Green Endeavors', 130000, '2022-03-30'); | What was the total investment amount by 'Green Endeavors' in Q1 2022? | SELECT SUM(amount) FROM investments WHERE investor = 'Green Endeavors' AND date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, student_name VARCHAR(255), department VARCHAR(255)); CREATE TABLE published_papers (id INT, paper_title VARCHAR(255), student_id INT, PRIMARY KEY (id, student_id), FOREIGN KEY (student_id) REFERENCES graduate_students(id)); INSERT INTO graduate_students (id, student_name, department) VALUES (1, 'Student1', 'Computer Science'), (2, 'Student2', 'Mathematics'), (3, 'Student3', 'Physics'); INSERT INTO published_papers (id, paper_title, student_id) VALUES (1, 'Paper1', 1), (2, 'Paper2', 2), (3, 'Paper3', 3), (4, 'Paper4', 1), (5, 'Paper5', 1); | Who are the top 5 graduate students with the most published papers? | SELECT gs.student_name, COUNT(pp.id) as paper_count FROM graduate_students gs JOIN published_papers pp ON gs.id = pp.student_id GROUP BY gs.student_name ORDER BY paper_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE FashionTrends (TrendID INT, Name VARCHAR(255), Popularity INT, Category VARCHAR(255)); INSERT INTO FashionTrends (TrendID, Name, Popularity, Category) VALUES (1, 'Floral Prints', 80, 'Top'), (2, 'Stripes', 70, 'Bottom'), (3, 'Sustainable Fabrics', 90, 'General'); | What is the average popularity of sustainable fashion products for each trend category? | SELECT Category, AVG(Popularity) AS AvgPopularity FROM FashionTrends WHERE Category != 'General' GROUP BY Category; | gretelai_synthetic_text_to_sql |
CREATE TABLE geopolitical_risk (id INT, region VARCHAR(30), half INT, year INT, assessment TEXT); INSERT INTO geopolitical_risk (id, region, half, year, assessment) VALUES (1, 'Middle East', 2, 2023, 'High Risk'); INSERT INTO geopolitical_risk (id, region, half, year, assessment) VALUES (2, 'Africa', 2, 2023, 'Medium Risk'); | List all geopolitical risk assessments for the Middle East and Africa region in H2 2023. | SELECT region, assessment FROM geopolitical_risk WHERE region IN ('Middle East', 'Africa') AND half = 2 AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesData (VIN VARCHAR(20), Model VARCHAR(20), SalesRegion VARCHAR(20), SalesYear INT); INSERT INTO SalesData (VIN, Model, SalesRegion, SalesYear) VALUES ('AA11BB2233', 'ModelX', 'Asia', 2021), ('CC22DD3344', 'ModelY', 'Europe', 2021); | How many electric vehicles were sold in Asia in 2021? | SELECT COUNT(*) FROM SalesData WHERE SalesYear = 2021 AND SalesRegion = 'Asia' AND Model LIKE '%Electric%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE support_programs (program_id INT, program_name VARCHAR(50), budget INT, region VARCHAR(50)); INSERT INTO support_programs (program_id, program_name, budget, region) VALUES (1, 'Assistive Technology', 50000, 'Northeast'); | What is the maximum, minimum, and average budget for support programs by region? | SELECT region, MAX(budget) as max_budget, MIN(budget) as min_budget, AVG(budget) as avg_budget FROM support_programs GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupportPrograms (Id INT, Name VARCHAR(100), Description TEXT, Region VARCHAR(50)); INSERT INTO SupportPrograms (Id, Name, Description, Region) VALUES (1, 'Asia-Pacific Bridge Program', 'Assists students with disabilities transition to college in Asia-Pacific', 'Asia-Pacific'); | What support programs were offered in the Asia-Pacific region? | SELECT * FROM SupportPrograms WHERE Region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_stats (state VARCHAR(20), year INT, avg_cost FLOAT); INSERT INTO labor_stats (state, year, avg_cost) VALUES ('California', 2022, 35.4); | What is the average construction labor cost per hour in California in 2022? | SELECT avg_cost FROM labor_stats WHERE state = 'California' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE media.reporters (reporter_id INT, name VARCHAR(100), gender VARCHAR(10), age INT); INSERT INTO media.reporters (reporter_id, name, gender, age) VALUES (1, 'Anne Smith', 'Female', 35), (2, 'Bruce Lee', 'Male', 40), (3, 'Grace Lee', 'Female', 45); | What is the total number of female and male reporters in the 'media' schema? | SELECT gender, COUNT(*) FROM media.reporters GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai_researchers (researcher_name TEXT, num_papers INTEGER); INSERT INTO explainable_ai_researchers (researcher_name, num_papers) VALUES ('Alice', 15), ('Bob', 18), ('Carol', 10); | Who is the researcher with the second-highest number of explainable AI papers? | SELECT researcher_name FROM explainable_ai_researchers ORDER BY num_papers DESC LIMIT 1 OFFSET 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (19, 'India', 'Japan', '2023-04-02', 31), (20, 'India', 'Japan', '2023-08-17', 29); | Increase the age of tourists visiting Japan from India in 2023 by 1. | UPDATE tourism_data SET age = age + 1 WHERE country = 'India' AND destination = 'Japan' AND YEAR(arrival_date) = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(100), country VARCHAR(100), last_login DATE); INSERT INTO users (id, name, country, last_login) VALUES (1, 'John Doe', 'USA', '2022-02-15'), (2, 'Jane Smith', 'USA', '2022-03-15'), (3, 'Alex Brown', 'Canada', '2022-03-16'); | Update all the users' last login date to the current date? | UPDATE users SET last_login = CURRENT_DATE; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.