context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE security_incidents (id INT, incident_date DATE, incident_time TIME); | Show the distribution of security incidents by hour of the day | SELECT DATEPART(hh, incident_time) as hour_of_day, COUNT(*) as num_incidents FROM security_incidents GROUP BY DATEPART(hh, incident_time); | gretelai_synthetic_text_to_sql |
CREATE TABLE MonthlyRevenue(id INT, genre VARCHAR(10), region VARCHAR(10), revenue FLOAT, month DATE); | What is the monthly revenue trend for the "rock" genre in the European region for the year 2021? | SELECT DATE_FORMAT(month, '%Y-%m') AS month, SUM(revenue) FROM MonthlyRevenue WHERE genre = 'rock' AND region = 'European' AND YEAR(month) = 2021 GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE parity_violations (city VARCHAR(50), violation_count INT); INSERT INTO parity_violations (city, violation_count) VALUES ('Los Angeles', 20), ('New York City', 15), ('Dallas', 10), ('Miami', 25), ('Chicago', 30), ('Philadelphia', 22), ('Houston', 18), ('Atlanta', 27); | What is the total number of mental health parity violations in each city? | SELECT city, SUM(violation_count) as total_violations FROM parity_violations GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), CulturalCompetencyScore INT); CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), MentalHealthParityScore INT); | Find Health Workers with low scores in both areas | SELECT HealthWorkerName FROM CulturalCompetency WHERE CulturalCompetencyScore < 85 INTERSECT SELECT HealthWorkerName FROM MentalHealthParity WHERE MentalHealthParityScore < 85; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_consumption_houston (customer_id INT, category VARCHAR(20), consumption FLOAT, day INT, month INT, year INT, city VARCHAR(20)); INSERT INTO water_consumption_houston (customer_id, category, consumption, day, month, year, city) VALUES (1, 'industrial', 50, 1, 1, 2020, 'Houston'); INSERT INTO water_con... | What is the average daily water consumption per customer in the industrial category for the year 2020 in the city of Houston? | SELECT AVG(consumption) FROM water_consumption_houston WHERE category = 'industrial' AND year = 2020 AND city = 'Houston' GROUP BY day; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (year INT, capacity INT); INSERT INTO LandfillCapacity (year, capacity) VALUES (2018, NULL), (2019, 11000), (2020, 11500), (2021, 12000), (2022, 12500); | What was the landfill capacity in megatons for 2018? | SELECT capacity FROM LandfillCapacity WHERE year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, author VARCHAR(50), year INT, department VARCHAR(50)); INSERT INTO publications (id, author, year, department) VALUES (1, 'Hannah', 2019, 'Mathematics'), (2, 'Ibrahim', 2018, 'Physics'), (3, 'Kim', 2020, 'Mathematics'), (4, 'Liam', 2019, 'Mathematics'), (5, 'Noor', 2021, 'Mathematics'... | What is the average number of publications per year by graduate students in the Mathematics department? | SELECT AVG(pub_per_year) FROM (SELECT COUNT(*)/COUNT(DISTINCT year) AS pub_per_year FROM publications WHERE department = 'Mathematics' AND author IN (SELECT name FROM students WHERE graduate_student = 'Yes')) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE online_travel_agency (id INT PRIMARY KEY, ota_name VARCHAR(50), hotel_name VARCHAR(50), region VARCHAR(50), bookings INT); INSERT INTO online_travel_agency (id, ota_name, hotel_name, region, bookings) VALUES (1, 'Travelocity', 'Caribbean Resort', 'Caribbean', 60), (2, 'Expedia', 'Mountain Lodge', 'Mountain... | Which online travel agencies have more than 50 bookings for resorts in the Caribbean? | SELECT ota_name, SUM(bookings) FROM online_travel_agency WHERE region = 'Caribbean' GROUP BY ota_name HAVING SUM(bookings) > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients_address (client_id INT, address TEXT); INSERT INTO clients_address (client_id, address) VALUES (1, 'New York'), (2, 'Chicago'), (3, 'San Francisco'); CREATE TABLE socially_responsible_lending_urban (loan_id INT, client_id INT, amount_borrowed INT); INSERT INTO socially_responsible_lending_urban (lo... | What is the average amount borrowed from socially responsible lending for clients living in urban areas? | SELECT AVG(socially_responsible_lending_urban.amount_borrowed) FROM socially_responsible_lending_urban JOIN clients_address ON socially_responsible_lending_urban.client_id = clients_address.client_id WHERE clients_address.address LIKE '%urban%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, species VARCHAR(20), population INT); INSERT INTO animal_population (id, species, population) VALUES (1, 'tiger', 500), (2, 'elephant', 300); CREATE TABLE habitat_preservation (id INT, species VARCHAR(20), efforts INT); INSERT INTO habitat_preservation (id, species, efforts) VALU... | List the total number of animals and preservation efforts for each species in the 'animal_population' and 'habitat_preservation' tables. | SELECT species, SUM(population) AS total_population, SUM(efforts) AS total_efforts FROM animal_population INNER JOIN habitat_preservation ON animal_population.species = habitat_preservation.species GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT, species VARCHAR(20), efforts INT); INSERT INTO habitat_preservation (id, species, efforts) VALUES (1, 'tiger', 100), (2, 'elephant', 150); CREATE TABLE community_education (id INT, animal VARCHAR(20), programs INT); INSERT INTO community_education (id, animal, programs) VALUES... | List the species and the number of education programs for each in the 'community_education' table where the number of programs is greater than the number of preservation efforts for the same species in the 'habitat_preservation' table. | SELECT animal, programs FROM community_education WHERE animal IN (SELECT species FROM habitat_preservation) GROUP BY animal HAVING SUM(programs) > (SELECT SUM(efforts) FROM habitat_preservation WHERE species = community_education.animal); | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodSafetyInspections (location VARCHAR(30), inspection_date DATE); INSERT INTO FoodSafetyInspections (location, inspection_date) VALUES ('Texas', '2021-01-15'),('Texas', '2021-05-20'),('Texas', '2021-12-01'); | How many food safety inspections were conducted in 'Texas' in '2021'? | SELECT COUNT(*) FROM FoodSafetyInspections WHERE location = 'Texas' AND inspection_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE glaciers (id INT, glacier_name VARCHAR, region VARCHAR); | Determine the number of glaciers in the Arctic region. | SELECT COUNT(DISTINCT glacier_name) as glacier_count FROM glaciers WHERE region = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE decentralized_applications (app_name TEXT, country TEXT, daily_transaction_value INTEGER); INSERT INTO decentralized_applications (app_name, country, daily_transaction_value) VALUES ('Uniswap', 'UK', 2000000), ('Compound', 'UK', 1500000), ('MakerDAO', 'UK', 1200000); | Which decentralized applications in the UK have the lowest daily transaction value? | SELECT app_name, MIN(daily_transaction_value) FROM decentralized_applications WHERE country = 'UK' GROUP BY app_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (state VARCHAR(255), year INTEGER, num_permits INTEGER); INSERT INTO building_permits (state, year, num_permits) VALUES ('Oregon', 2020, 3000), ('Oregon', 2019, 2500), ('Florida', 2020, 4000), ('Florida', 2019, 3500), ('California', 2020, 5000), ('California', 2019, 4500); | Identify the number of building permits issued in each state in 2020 | SELECT state, SUM(num_permits) FROM building_permits WHERE year = 2020 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT PRIMARY KEY, astronaut_name VARCHAR(50), country VARCHAR(50)); | How many astronauts are from each country? | SELECT country, COUNT(*) as num_astronauts FROM astronauts GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParityRG (ViolationID INT, Race VARCHAR(255), Gender VARCHAR(255), ViolationDate DATE); INSERT INTO MentalHealthParityRG (ViolationID, Race, Gender, ViolationDate) VALUES (1, 'Hispanic', 'Female', '2022-01-01'), (2, 'African American', 'Male', '2022-02-01'), (3, 'Asian', 'Female', '2022-03-01')... | How many mental health parity violations were reported by race and gender? | SELECT Race, Gender, COUNT(*) as ViolationCount FROM MentalHealthParityRG GROUP BY Race, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT, district_id INT, budget FLOAT, project_type VARCHAR(50)); | Add a new rural infrastructure project with an ID of 7, a budget of 650000, and a project_type of 'Fiber Optics' in district 24. | INSERT INTO projects (project_id, district_id, budget, project_type) VALUES (7, 24, 650000, 'Fiber Optics'); | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, connection_type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers (id, connection_type, region) VALUES (1, 'broadband', 'suburban'), (2, 'broadband', 'suburban'), (3, 'broadband', 'suburban'); CREATE TABLE connection_speeds (subscriber_id INT, speed INT); INSERT INTO connection... | How many broadband customers have a connection speed greater than 500 Mbps in the 'suburban' region? | SELECT COUNT(*) FROM connection_speeds JOIN subscribers ON connection_speeds.subscriber_id = subscribers.id WHERE subscribers.connection_type = 'broadband' AND subscribers.region = 'suburban' AND connection_speeds.speed > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (species VARCHAR(255), dissolved_oxygen FLOAT); CREATE TABLE ocean_health (species VARCHAR(255), dissolved_oxygen FLOAT); INSERT INTO fish_stock (species, dissolved_oxygen) VALUES ('Tilapia', 6.5), ('Salmon', 7.1); INSERT INTO ocean_health (species, dissolved_oxygen) VALUES ('Tilapia', 6.8), ('S... | What is the minimum dissolved oxygen level for each species, grouped by species, from the 'fish_stock' and 'ocean_health' tables? | SELECT f.species, MIN(f.dissolved_oxygen) FROM fish_stock f INNER JOIN ocean_health o ON f.species = o.species GROUP BY f.species; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices (destination_id INT, practice_id INT, year INT, implemented BOOLEAN); CREATE VIEW sustainable_destinations AS SELECT destination_id, COUNT(*) as num_practices FROM sustainable_practices WHERE implemented = TRUE GROUP BY destination_id; CREATE TABLE travel_warnings (destination_id INT,... | Which destinations in Africa have implemented more than 3 sustainable practices and have a travel warning issued? | SELECT d.country FROM destinations d JOIN sustainable_destinations s ON d.id = s.destination_id JOIN current_travel_warnings ctw ON d.id = ctw.destination_id WHERE d.region = 'Africa' AND s.num_practices > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID int, Name varchar(50), Specialty varchar(50), HourlyRate decimal(5,2)); INSERT INTO Attorneys (AttorneyID, Name, Specialty, HourlyRate) VALUES (6, 'Fatima Ahmed', 'Family Law', 400); CREATE TABLE Cases (CaseID int, ClientID int, Category varchar(50), AttorneyID int); INSERT INTO Cases... | What is the maximum hourly rate charged by attorneys who specialize in 'family law'? | SELECT MAX(A.HourlyRate) as MaxHourlyRate FROM Attorneys A INNER JOIN Cases CA ON A.AttorneyID = CA.AttorneyID WHERE A.Specialty = 'Family Law'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (UserID INT, Country VARCHAR(255), Devices INT); INSERT INTO Users (UserID, Country, Devices) VALUES (1, 'USA', 3), (2, 'Canada', 2), (3, 'USA', 1); | What is the average number of devices owned by users in each country? | SELECT Country, AVG(Devices) FROM Users GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE attractions (id INT, name TEXT, country TEXT, wheelchair_accessibility FLOAT); INSERT INTO attractions (id, name, country, wheelchair_accessibility) VALUES (1, 'Taj Mahal', 'India', 3.5), (2, 'Jaipur Palace', 'India', 4.2); | What is the total number of tourist attractions in India with a wheelchair accessibility rating above 3? | SELECT SUM(*) FROM (SELECT * FROM attractions WHERE country = 'India' AND wheelchair_accessibility > 3) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableProjects (ProjectID int, Name varchar(50), ConstructionCost int, CompletionDate date); INSERT INTO SustainableProjects (ProjectID, Name, ConstructionCost, CompletionDate) VALUES (1, 'Green Building', 30000, '2019-06-30'); INSERT INTO SustainableProjects (ProjectID, Name, ConstructionCost, Comple... | Which sustainable building projects have a higher construction cost than the average cost of sustainable projects? | SELECT Name, ConstructionCost FROM SustainableProjects WHERE ConstructionCost > (SELECT AVG(ConstructionCost) FROM SustainableProjects); | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (title VARCHAR(255), publication_date DATE); | Show the number of articles published per month in the 'articles' table for the year 2022. | SELECT EXTRACT(MONTH FROM publication_date) AS month, COUNT(*) AS count FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2022 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE bases (id INT, name VARCHAR(255), type VARCHAR(255));CREATE TABLE maintenance (base_id INT, cost DECIMAL(10,2));INSERT INTO bases (id, name, type) VALUES (1, 'Fort Bragg', 'Army'), (2, 'Naval Base San Diego', 'Navy'), (3, 'Hanscom AFB', 'Air Force');INSERT INTO maintenance (base_id, cost) VALUES (1, 250000... | What is the total maintenance cost for each military base? | SELECT b.name, SUM(m.cost) as total_cost FROM bases b JOIN maintenance m ON b.id = m.base_id GROUP BY b.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE attendee_demographics (attendee_id INT, program_id INT, gender VARCHAR(6)); | Which programs have more female attendees than male attendees? | SELECT program_id, COUNT(CASE WHEN gender = 'female' THEN 1 ELSE NULL END) AS num_females, COUNT(CASE WHEN gender = 'male' THEN 1 ELSE NULL END) AS num_males FROM attendee_demographics GROUP BY program_id HAVING num_females > num_males; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_vehicles (vehicle_id INT, make VARCHAR(50), model VARCHAR(50), fuel_type VARCHAR(10)); | What is the percentage of electric vehicles in the 'green_vehicles' table? | SELECT (COUNT(*) FILTER (WHERE fuel_type = 'electric')) * 100.0 / COUNT(*) FROM green_vehicles; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50)); CREATE TABLE Irrigation (id INT PRIMARY KEY, system VARCHAR(50), cost FLOAT, installation_date DATE, farm_id INT, FOREIGN KEY (farm_id) REFERENCES Farmers(id)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'Juan Garc... | Which farmers in California have irrigation systems installed? | SELECT Farmers.name FROM Farmers INNER JOIN Irrigation ON Farmers.id = Irrigation.farm_id WHERE Farmers.location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (name PRIMARY KEY, region VARCHAR(20)); CREATE TABLE malaria_cases (country VARCHAR(20), year INT, cases INT); INSERT INTO countries (name, region) VALUES ('Nigeria', 'Africa'), ('DRC', 'Africa'), ('Tanzania', 'Africa'), ('Mozambique', 'Africa'), ('Ghana', 'Africa'); INSERT INTO malaria_cases (co... | How many cases of malaria were reported in African countries last year? | SELECT SUM(m.cases) FROM malaria_cases m JOIN countries c ON m.country = c.name WHERE c.region = 'Africa' AND m.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (ClaimID INT, PolicyID INT, Amount INT, Region VARCHAR(10)); INSERT INTO Claims (ClaimID, PolicyID, Amount, Region) VALUES (1, 101, 500, 'North'); INSERT INTO Claims (ClaimID, PolicyID, Amount, Region) VALUES (2, 102, 750, 'South'); INSERT INTO Claims (ClaimID, PolicyID, Amount, Region) VALUES (3, 1... | What is the highest claim amount in the 'West' region? | SELECT MAX(Amount) FROM Claims WHERE Region = 'West'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EventAttendance (event_name VARCHAR(255), attendee_age INT, attendee_gender VARCHAR(50)); INSERT INTO EventAttendance (event_name, attendee_age, attendee_gender) VALUES ('Art in the Park', 35, 'Female'), ('Art in the Park', 40, 'Male'), ('Art in the Park', 45, 'Non-binary'); | What was the average age of attendees at the 'Art in the Park' event? | SELECT AVG(attendee_age) FROM EventAttendance WHERE event_name = 'Art in the Park'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA membership_stats; CREATE TABLE membership_types (member_id INT, membership_type VARCHAR(50)); INSERT INTO membership_types VALUES (1, 'Premium'), (2, 'Basic'), (3, 'Premium'); | How many members have a 'Premium' membership type?' | SELECT COUNT(DISTINCT member_id) FROM membership_stats.membership_types WHERE membership_type = 'Premium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Applications (ApplicationID INT, CandidateName VARCHAR(50), RaceEthnicity VARCHAR(30), JobTitle VARCHAR(30), ApplicationDate DATE); INSERT INTO Applications (ApplicationID, CandidateName, RaceEthnicity, JobTitle, ApplicationDate) VALUES (1, 'Jamal Johnson', 'African American', 'Manager', '2022-01-01'), (2,... | Identify the top 3 candidates who belong to underrepresented racial or ethnic groups, ordered by application date in descending order, for each job title, in the last 30 days. | SELECT JobTitle, CandidateName, ApplicationDate, ROW_NUMBER() OVER (PARTITION BY JobTitle ORDER BY CASE WHEN RaceEthnicity IN ('African American', 'Hispanic', 'Asian', 'Native American', 'Pacific Islander') THEN 1 ELSE 2 END, ApplicationDate DESC) AS Rank FROM Applications WHERE ApplicationDate >= CURDATE() - INTERVAL ... | gretelai_synthetic_text_to_sql |
CREATE TABLE research_projects (id INT, name VARCHAR(50), budget FLOAT, technology VARCHAR(50)); INSERT INTO research_projects VALUES (1, 'ProjectS', 1000000, 'CRISPR'); INSERT INTO research_projects VALUES (2, 'ProjectT', 1200000, 'Genomics'); INSERT INTO research_projects VALUES (3, 'ProjectU', 1500000, 'CRISPR'); | What is the total budget for all genetic research projects working on CRISPR technology? | SELECT SUM(budget) FROM research_projects WHERE technology = 'CRISPR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityMediationCenters (CenterName text, CaseType text, NumCases int); INSERT INTO CommunityMediationCenters VALUES ('CM1', 'Assault', 25, '2022-01-01'), ('CM1', 'Theft', 18, '2022-01-01'); CREATE TABLE LegalAidClinics (ClinicName text, CaseType text, NumCases int); INSERT INTO LegalAidClinics VALUES ('... | What is the total number of cases handled by community mediation centers, legal aid clinics, and restorative justice facilitators, broken down by center/clinic name and case type? | SELECT 'Community Mediation Centers' AS CenterName, CaseType, SUM(NumCases) FROM CommunityMediationCenters GROUP BY CaseType UNION ALL SELECT 'Legal Aid Clinics' AS CenterName, CaseType, SUM(NumCases) FROM LegalAidClinics GROUP BY CaseType UNION ALL SELECT 'Restorative Justice Facilitators' AS CenterName, CaseType, SUM... | gretelai_synthetic_text_to_sql |
CREATE TABLE system_types (id INT, system_type TEXT, severity TEXT); INSERT INTO system_types (id, system_type, severity) VALUES (1, 'Type1', 'High'), (2, 'Type2', 'Medium'), (3, 'Type3', 'Low'); CREATE TABLE system_vulnerabilities (system_id INT, system_type TEXT, vulnerability_id INT, severity TEXT); INSERT INTO syst... | What is the average severity of vulnerabilities associated with each system type? | SELECT system_type, AVG(severity) as avg_severity FROM system_vulnerabilities JOIN system_types ON system_types.system_type = system_vulnerabilities.system_type GROUP BY system_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE EquipmentTypes (id INT, equipment VARCHAR(50));CREATE TABLE ProjectTimelines (id INT, equipment VARCHAR(50), start_year INT, end_year INT);CREATE TABLE ProjectCountries (id INT, project_id INT, country VARCHAR(50));CREATE TABLE ProjectRegions (id INT, project_id INT, region VARCHAR(50)); | Which military equipment types are part of defense projects with timelines extending into 2030, and for which countries and regions are these projects? | SELECT EquipmentTypes.equipment, ProjectCountries.country, ProjectRegions.region, ProjectTimelines.start_year, ProjectTimelines.end_year FROM EquipmentTypes INNER JOIN ProjectTimelines ON EquipmentTypes.equipment = ProjectTimelines.equipment INNER JOIN ProjectCountries ON ProjectTimelines.id = ProjectCountries.project_... | gretelai_synthetic_text_to_sql |
CREATE TABLE BikeSharing (id INT, trips INT, city VARCHAR(50), date DATE); INSERT INTO BikeSharing (id, trips, city, date) VALUES (1, 1500, 'Chicago', '2022-01-01'); INSERT INTO BikeSharing (id, trips, city, date) VALUES (2, 1800, 'Chicago', '2022-01-02'); | What is the maximum number of bike-sharing trips in a single day in the city of Chicago? | SELECT MAX(trips) FROM BikeSharing WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorney_info (attorney_name VARCHAR(20), num_cases INT); INSERT INTO attorney_info (attorney_name, num_cases) VALUES ('John Smith', 3), ('Jane Doe', 2), ('Mike Johnson', 1); | Show the number of cases handled by each attorney in descending order. | SELECT attorney_name, num_cases FROM attorney_info ORDER BY num_cases DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT, country TEXT); INSERT INTO suppliers (supplier_id, supplier_name, country) VALUES (1, 'Supplier 1', 'USA'), (2, 'Supplier 2', 'Canada'), (3, 'Supplier 3', 'Mexico'); CREATE TABLE certifications (certification_id INT, supplier_id INT, certification_type TEXT);... | List all suppliers and their certifications, sorted alphabetically by supplier name and certification type? | SELECT supplier_name, certification_type FROM suppliers JOIN certifications ON suppliers.supplier_id = certifications.supplier_id ORDER BY supplier_name, certification_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE workshops (workshop_id INT, year INT, PRIMARY KEY (workshop_id, year)); INSERT INTO workshops (workshop_id, year) VALUES (1, 2021), (2, 2021), (3, 2021); | How many professional development workshops were held in 2021? | SELECT COUNT(*) FROM workshops WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, age INT, gender TEXT); INSERT INTO users (id, age, gender) VALUES ('1', '25', 'Female'), ('2', '35', 'Male'), ('3', '45', 'Non-binary'); CREATE TABLE likes (user_id INT, article_id INT); INSERT INTO likes (user_id, article_id) VALUES ('1', '123'), ('2', '123'), ('3', '456'); | What is the average age of users who have liked an article? | SELECT AVG(users.age) FROM users JOIN likes ON users.id = likes.user_id GROUP BY users.id HAVING COUNT(*) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales_Data (sale_id INT, sale_date DATE, equipment_type VARCHAR(255), country VARCHAR(255), sale_value FLOAT); INSERT INTO Sales_Data (sale_id, sale_date, equipment_type, country, sale_value) VALUES (1, '2020-04-01', 'Aircraft', 'USA', 10000000), (2, '2020-04-10', 'Armored Vehicles', 'Canada', 3000000), (3... | What is the total value of military equipment sales to each country in Q2 2020, ranked by total sales? | SELECT country, SUM(sale_value) AS total_sales, RANK() OVER (ORDER BY SUM(sale_value) DESC) AS sales_rank FROM Sales_Data WHERE sale_date BETWEEN '2020-04-01' AND '2020-06-30' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE artifacts (site_id INT, artifact_name VARCHAR(255)); INSERT INTO artifacts (site_id, artifact_name) VALUES (1, 'Pottery'), (1, 'Bronze Sword'), (2, 'Clay Figurine'), (3, 'Copper Pendant'); | Which artifacts were found in the top 2 deepest excavation sites? | SELECT a.artifact_name FROM artifacts a JOIN (SELECT site_id FROM excavation_sites WHERE ROW_NUMBER() OVER (ORDER BY depth DESC) <= 2) b ON a.site_id = b.site_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningCompany (Name TEXT, Location TEXT, StartYear INT); INSERT INTO MiningCompany (Name, Location, StartYear) VALUES ('Alpha Mining', 'Australia', 2005), ('Beta Mines', 'China', 2008), ('Gamma Resources', 'USA', 2012); CREATE TABLE ProductionMonthly (Year INT, MiningCompany TEXT, Element TEXT, Quantity IN... | Calculate the average monthly production of Lanthanum for each mining company from 2018 to 2020. | SELECT MiningCompany, AVG(Quantity) FROM ProductionMonthly WHERE Element = 'Lanthanum' AND Year BETWEEN 2018 AND 2020 GROUP BY MiningCompany; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_conservation (id INT, initiative VARCHAR(30), year INT, savings FLOAT); | Insert records into the 'water_conservation' table for the 'Southeast' region with a 'initiative' of 'water recycling' and a 'year' of 2015 | INSERT INTO water_conservation (initiative, year) VALUES ('water recycling', 2015), ('Southeast',); | gretelai_synthetic_text_to_sql |
CREATE TABLE Garment (garment_id INT PRIMARY KEY, garment_name VARCHAR(50), category VARCHAR(50), price DECIMAL(10,2)); INSERT INTO Garment (garment_id, garment_name, category, price) VALUES (1, 'Cotton T-Shirt', 'Tops', 20.00), (2, 'Jeans Pants', 'Bottoms', 40.00); | Insert new garment records into the Garment table with the next available garment_id and the provided information. | INSERT INTO Garment (garment_name, category, price) SELECT 'Silk Skirt' AS garment_name, 'Bottoms' AS category, 50.00 AS price FROM (SELECT 1 UNION ALL SELECT 2) x WHERE NOT EXISTS (SELECT 1 FROM Garment y WHERE y.garment_id = x.x+2); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(255)); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10, 2), DonationDate DATE); | What is the average donation amount for each donor in the last 6 months, and which donor has the highest average donation amount in this period? | SELECT DonorID, DonorName, AVG(DonationAmount) AS AvgDonation, RANK() OVER (ORDER BY AVG(DonationAmount) DESC) AS DonorRank FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE DonationDate >= DATEADD(MONTH, -6, CURRENT_DATE) GROUP BY DonorID, DonorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, founder_gender TEXT, last_funding_date DATE); CREATE TABLE funding_rounds (id INT, company_id INT, size INT); | How many companies have a female founder and have received funding in the last year? | SELECT COUNT(*) FROM companies WHERE founder_gender = 'female' AND last_funding_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timelines (timeline_id INT, city VARCHAR(20), days INT); INSERT INTO project_timelines (timeline_id, city, days) VALUES (1, 'Chicago', 120), (2, 'New York', 150), (3, 'Los Angeles', 180); CREATE TABLE city (city_id INT, city VARCHAR(20)); | What is the minimum project timeline for each city? | SELECT city, MIN(days) as min_days FROM project_timelines JOIN city ON project_timelines.city = city.city GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses(id INT, name VARCHAR(255)); INSERT INTO warehouses VALUES(1, 'A01'), (2, 'A02'); | Insert new warehouse B03 | INSERT INTO warehouses(id, name) VALUES(3, 'B03'); | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT, brand VARCHAR(20), region VARCHAR(20), order_amount DECIMAL(5,2)); INSERT INTO orders (id, brand, region, order_amount) VALUES (1, 'Slow Fashion Brand A', 'Europe', 150.99), (2, 'Fast Fashion Brand B', 'North America', 204.55), (3, 'Slow Fashion Brand C', 'Europe', 125.44); | What is the sum of orders placed with slow fashion brands in Europe? | SELECT SUM(order_amount) FROM orders WHERE brand IN ('Slow Fashion Brand A', 'Slow Fashion Brand C') AND region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT); CREATE TABLE initiatives (initiative_id INT, factory_id INT, description TEXT, start_date DATE, end_date DATE); INSERT INTO factories (factory_id, name, location) VALUES (1, 'Factory A', 'City A'), (2, 'Factory B', 'City A'), (3, 'Factory C', 'City B'),... | What are the common workforce development initiatives between factories located in the same region? | SELECT f1.location, i1.description FROM initiatives i1 JOIN factories f1 ON i1.factory_id = f1.factory_id JOIN initiatives i2 ON i1.description = i2.description JOIN factories f2 ON i2.factory_id = f2.factory_id WHERE f1.location = f2.location GROUP BY f1.location, i1.description HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'Canada'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3, 'Alice... | How many donations were made by the donor with the name 'Sophia Lee'? | SELECT COUNT(*) FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.DonorName = 'Sophia Lee'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), project_type VARCHAR(50)); INSERT INTO renewable_energy_projects (id, project_name, city, country, project_type) VALUES (1, 'Sydney Wind Farm', 'Sydney', 'Australia', 'Wind'); | How many renewable energy projects are there in Sydney, Australia? | SELECT COUNT(*) FROM renewable_energy_projects WHERE city = 'Sydney' AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (name TEXT, type TEXT, location TEXT); INSERT INTO facilities (name, type, location) VALUES ('Facility X', 'Clinic', 'Rural Australia'), ('Facility Y', 'Hospital', 'Rural Australia'), ('Facility Z', 'Clinic', 'Rural Australia'), ('Facility W', 'Hospital', 'Rural New Zealand'), ('Facility V', 'Cl... | What is the most common type of healthcare facility in rural areas of Australia and New Zealand? | SELECT type, COUNT(*) FROM facilities WHERE location LIKE 'Rural%' GROUP BY type ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_region (drug_name TEXT, sale_amount INTEGER, sale_year INTEGER, region TEXT); INSERT INTO sales_region (drug_name, sale_amount, sale_year, region) VALUES ('DrugA', 1000, 2020, 'North'), ('DrugA', 1500, 2020, 'South'), ('DrugB', 2000, 2020, 'East'), ('DrugB', 1200, 2020, 'West'); | What are the sales figures for a given drug in a specific region in the year 2020? | SELECT sale_amount FROM sales_region WHERE drug_name = 'DrugA' AND region = 'North' AND sale_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE EventViewership (EventID INT, EventName VARCHAR(50), HoursWatched DECIMAL(10,2)); | Show the total number of hours watched for each eSports event in 'EventViewership' table | SELECT EventID, SUM(HoursWatched) as TotalHoursWatched FROM EventViewership GROUP BY EventID; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farms (id INT, farm_name VARCHAR(255), country VARCHAR(255), land_area INT); | What is the total area of land (in hectares) used for organic farming in each country? | SELECT country, SUM(land_area) FROM organic_farms GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (fruit text, weight integer, is_local boolean); INSERT INTO Inventory (fruit, weight, is_local) VALUES ('Bananas', 150, false), ('Apples', 200, true), ('Oranges', 120, false); | Find the total weight of non-local fruits in the inventory. | SELECT SUM(weight) FROM Inventory WHERE is_local = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure (project_id INT, state TEXT, project_type TEXT, year INT, investment FLOAT); INSERT INTO infrastructure (project_id, state, project_type, year, investment) VALUES (1, 'Mato Grosso', 'Roads', 2018, 2500000), (2, 'Mato Grosso', 'Bridges', 2019, 3000000), (3, 'Mato Grosso', 'Irrigation', 2020, ... | What is the total investment in rural infrastructure projects in the state of Mato Grosso, Brazil, by project type and year? | SELECT project_type, year, SUM(investment) as total_investment FROM infrastructure WHERE state = 'Mato Grosso' GROUP BY project_type, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, country VARCHAR(50), num_artifacts INT, total_funding DECIMAL(10,2)); | Which countries had more than 1000 artifacts excavated? | SELECT country FROM excavation_sites GROUP BY country HAVING SUM(num_artifacts) > 1000 | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocations (allocation_id INT, allocation_purpose VARCHAR(50), allocation_amount DECIMAL(10, 2)); | Find the total budget for habitat preservation in 'BudgetAllocations' table | SELECT SUM(allocation_amount) as total_budget FROM BudgetAllocations WHERE allocation_purpose = 'Habitat Preservation'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists renewables; CREATE TABLE if not exists renewables.solar_projects (project_id int, name varchar(255), location varchar(255), installed_capacity float); INSERT INTO renewables.solar_projects (project_id, name, location, installed_capacity) VALUES (1, 'Solar Project 1', 'Country A', 50.0), (2, ... | What is the total installed capacity of solar energy projects in the 'renewables' schema? | SELECT SUM(installed_capacity) FROM renewables.solar_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transport (id INT, vehicle_type VARCHAR(10), avg_distance FLOAT); INSERT INTO public_transport (id, vehicle_type, avg_distance) VALUES (1, 'EV_Bus', 75.0), (2, 'Diesel_Bus', 60.0), (3, 'EV_Bus', 80.0); | What is the average distance traveled by electric buses in the 'public_transport' table? | SELECT AVG(avg_distance) FROM public_transport WHERE vehicle_type = 'EV_Bus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (assistance_id INT, provider TEXT, recipient TEXT, amount FLOAT, year INT); INSERT INTO humanitarian_assistance (assistance_id, provider, recipient, amount, year) VALUES (1, 'Canada', 'Syria', 1000000, 2020), (2, 'Canada', 'Afghanistan', 500000, 2021); | Which countries have received humanitarian assistance from Canada in the last 2 years? | SELECT DISTINCT recipient FROM humanitarian_assistance WHERE provider = 'Canada' AND year >= (SELECT YEAR(GETDATE()) - 2) | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (line VARCHAR(10), passenger_type VARCHAR(10), fare FLOAT); | Update the fare for 'child' passengers in the 'green' line. | UPDATE fares SET fare = 2.00 WHERE line = 'green' AND passenger_type = 'child'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeData (EmployeeID INT, Sector VARCHAR(20), WeeklyHours DECIMAL(10, 2)); INSERT INTO EmployeeData (EmployeeID, Sector, WeeklyHours) VALUES (1, 'Technology', 50.00), (2, 'Technology', 40.00), (3, 'Finance', 45.00); | What is the total number of employees in the 'Technology' sector who work more than 45 hours per week? | SELECT SUM(*) FROM EmployeeData WHERE Sector = 'Technology' AND WeeklyHours > 45; | gretelai_synthetic_text_to_sql |
CREATE TABLE Pallets (id INT, warehouse_id INT, stored_date DATE, quantity INT); INSERT INTO Pallets (id, warehouse_id, stored_date, quantity) VALUES (4, 12, '2022-04-15', 350), (5, 12, '2022-06-01', 280), (6, 13, '2022-05-10', 400); CREATE TABLE Warehouses (id INT, name TEXT, city TEXT, state TEXT); INSERT INTO Wareho... | What is the total number of pallets stored in the Rio de Janeiro warehouse in Q2 2022? | SELECT SUM(quantity) FROM Pallets JOIN Warehouses ON Pallets.warehouse_id = Warehouses.id WHERE Warehouses.name = 'Rio de Janeiro Warehouse' AND EXTRACT(QUARTER FROM stored_date) = 2 AND EXTRACT(YEAR FROM stored_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (id, name, department) VALUES (1, 'John Doe', 'IT'), (2, 'Jane Smith', 'HR'), (3, 'Alice Johnson', 'IT'); | How many employees work in the IT and HR departments? | SELECT COUNT(*) FROM employees WHERE department IN ('IT', 'HR'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Tech_Accessibility (continent VARCHAR(50), funding INT); INSERT INTO Tech_Accessibility (continent, funding) VALUES ('Africa', 2000000), ('Asia', 3000000), ('Europe', 5000000), ('North America', 7000000), ('South America', 1000000), ('Australia', 800000); | What is the distribution of technology accessibility funding by continent? | SELECT continent, SUM(funding) as total_funding, COUNT(*) as num_continents, AVG(funding) as avg_funding FROM Tech_Accessibility GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_data (country VARCHAR(255), region VARCHAR(255), dissolved_oxygen FLOAT); INSERT INTO ocean_data (country, region, dissolved_oxygen) VALUES ('Japan', 'Pacific Ocean', 7.1), ('USA', 'Pacific Ocean', 7.0), ('Canada', 'Pacific Ocean', 7.3); | Which country has the highest dissolved oxygen level in the Pacific Ocean? | SELECT country, MAX(dissolved_oxygen) as max_dissolved_oxygen FROM ocean_data WHERE region = 'Pacific Ocean' GROUP BY country ORDER BY max_dissolved_oxygen DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50)); INSERT INTO Teams VALUES (1, 'TeamA'), (2, 'TeamB'); CREATE TABLE TicketSales (SaleID INT, TeamID INT, GameID INT, TicketsSold INT); INSERT INTO TicketSales VALUES (1, 1, 1, 500), (2, 1, 2, 550), (3, 2, 3, 600), (4, 2, 4, 650); | How many tickets were sold per game by each team? | SELECT TeamID, GameID, SUM(TicketsSold) as TotalTicketsSold FROM TicketSales GROUP BY TeamID, GameID; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, district_id INT, mental_health_score INT); INSERT INTO student_mental_health (student_id, district_id, mental_health_score) VALUES (1, 101, 85), (2, 101, 82), (3, 102, 90), (4, 102, 92), (5, 103, 78); | What is the average mental health score per school district, ordered by the highest score first? | SELECT district_id, AVG(mental_health_score) as avg_score FROM student_mental_health GROUP BY district_id ORDER BY avg_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_communication_campaigns (campaign_id INT, region VARCHAR(50), launch_year INT); INSERT INTO climate_communication_campaigns (campaign_id, region, launch_year) VALUES (1, 'Asia Pacific', 2019), (2, 'Asia Pacific', 2020), (3, 'North America', 2020), (4, 'Europe', 2019); | How many climate communication campaigns were launched in Asia Pacific in 2019 and 2020? | SELECT COUNT(*) FROM climate_communication_campaigns WHERE region = 'Asia Pacific' AND launch_year IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE users(user_id INT, user_region TEXT); INSERT INTO users(user_id, user_region) VALUES (1, 'European Union'); CREATE TABLE virtual_tours(tour_id INT, tour_date DATE); CREATE TABLE user_tour_interactions(user_id INT, tour_id INT); | Identify the number of virtual tours engaged by users from the European Union in 2021, grouped by the month of engagement. | SELECT MONTH(vt.tour_date) AS month, COUNT(uti.user_id) AS num_interactions FROM users u INNER JOIN user_tour_interactions uti ON u.user_id = uti.user_id INNER JOIN virtual_tours vt ON uti.tour_id = vt.tour_id WHERE u.user_region = 'European Union' AND YEAR(vt.tour_date) = 2021 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE num_employees (site VARCHAR(20), state VARCHAR(20), num_employees INT); INSERT INTO num_employees (site, state, num_employees) VALUES ('SiteA', 'QLD', 50), ('SiteB', 'NSW', 60), ('SiteC', 'WA', 70); | What is the total number of employees working in mining operations across all states? | SELECT SUM(num_employees) FROM num_employees; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Cuisine varchar(50)); CREATE TABLE Revenues (RevenueID int, RestaurantID int, Revenue decimal(5,2), Date date); INSERT INTO Restaurants (RestaurantID, Name, Cuisine) VALUES (1, 'Big Burger', 'American'); INSERT INTO Revenues (RevenueID, RestaurantID, Revenue... | What is the total revenue for each cuisine type in the last quarter? | SELECT r.Cuisine, SUM(rev.Revenue) as TotalRevenue FROM Restaurants r JOIN Revenues rev ON r.RestaurantID = rev.RestaurantID WHERE rev.Date >= DATEADD(quarter, -1, GETDATE()) GROUP BY r.Cuisine; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_competency_training (id INT, community_health_worker_id INT, hours INT); INSERT INTO cultural_competency_training (id, community_health_worker_id, hours) VALUES (1, 1, 10), (2, 1, 5), (3, 2, 8), (4, 3, 12); | What is the total cultural competency training hours for each community health worker? | SELECT c.name, SUM(ct.hours) as total_hours FROM cultural_competency_training ct JOIN community_health_workers c ON ct.community_health_worker_id = c.id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE district (did INT, name VARCHAR(255)); INSERT INTO district VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE calls (call_id INT, district_id INT, response_time INT, year INT); | List the number of emergency calls in each district in 2021. | SELECT d.name, COUNT(c.call_id) FROM district d JOIN calls c ON d.did = c.district_id WHERE c.year = 2021 AND c.response_time < 60 GROUP BY d.did; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturer_waste (id INT, manufacturer VARCHAR(255), eu_country VARCHAR(255), waste_kg INT); INSERT INTO manufacturer_waste VALUES (1, 'Manufacturer A', 'Germany', 500), (2, 'Manufacturer B', 'France', 600), (3, 'Manufacturer A', 'Germany', 550), (4, 'Manufacturer C', 'Italy', 450); | What is the total quantity of waste generated by each manufacturer in the EU? | SELECT manufacturer, SUM(waste_kg) FROM manufacturer_waste WHERE eu_country IN ('Germany', 'France', 'Italy') GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft(id INT, name VARCHAR(50), destination VARCHAR(50), mass FLOAT); INSERT INTO spacecraft VALUES(1, 'Curiosity Rover', 'Mars', 900.), (2, 'InSight Lander', 'Mars', 360.); | What is the total mass of spacecraft that have landed on Mars? | SELECT SUM(mass) FROM spacecraft WHERE destination = 'Mars'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 35, 'Female', 'Premium'), (2, 45, 'Male', 'Basic'), (3, 28, 'Female', 'Premium'), (4, 32, 'Male', 'Premium'), (5, 48, 'Female', 'Basic'); CREATE TABLE Clas... | How many members attended each type of class in April 2022? | SELECT Class, COUNT(*) as AttendanceCount FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE MONTH(ClassAttendance.Date) = 4 GROUP BY Class; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA infrastructure; CREATE TABLE projects (country VARCHAR(50), project_id INT); INSERT INTO projects (country, project_id) VALUES ('Kenya', 6), ('Nigeria', 7), ('Egypt', 8), ('South Africa', 9), ('Morocco', 10), ('Sudan', 5); | Which African countries have more than 5 rural infrastructure projects? | SELECT country FROM infrastructure.projects WHERE country IN (SELECT country FROM infrastructure.projects GROUP BY country HAVING COUNT(*) > 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE service_budget (state VARCHAR(50), service VARCHAR(50), budget INT, budget_year INT); INSERT INTO service_budget (state, service, budget, budget_year) VALUES ('California', 'Transportation', 12000000, 2022), ('California', 'Healthcare', 15000000, 2022); | What is the total budget allocated for transportation services in California for the year 2022? | SELECT SUM(budget) FROM service_budget WHERE state = 'California' AND service = 'Transportation' AND budget_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor (labor_id INT, permit_id INT, worker_name TEXT, hours_worked INT, wage FLOAT); INSERT INTO construction_labor (labor_id, permit_id, worker_name, hours_worked, wage) VALUES (6, 6, 'Ali Mohammad', 120, 32.0); | What is the sum of wages paid to construction laborers for permits with sustainable practices installed before 2020, excluding those with less than 100 hours worked? | SELECT SUM(wage) FROM construction_labor cl JOIN sustainable_practices sp ON cl.permit_id = sp.permit_id WHERE sp.installation_date < '2020-01-01' GROUP BY permit_id HAVING SUM(hours_worked) > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecruitmentData (Position VARCHAR(20), Source VARCHAR(20), Hires INT); INSERT INTO RecruitmentData (Position, Source, Hires) VALUES ('Software Engineer', 'LinkedIn', 45); INSERT INTO RecruitmentData (Position, Source, Hires) VALUES ('Data Scientist', 'Indeed', 30); | Which recruitment sources have resulted in more than 40 hires for technical positions? | SELECT Source, SUM(Hires) FROM RecruitmentData WHERE Position LIKE '%Technical%' GROUP BY Source HAVING SUM(Hires) > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors(id INT, name TEXT, country TEXT);CREATE TABLE donations(id INT, donor_id INT, amount FLOAT, donation_date DATE); | List the top 3 countries with the highest total donations in the last 12 months, and their respective total donations. | SELECT donors.country, SUM(donations.amount) as total_donations FROM donors JOIN donations ON donations.donor_id = donors.id WHERE donations.donation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND CURDATE() GROUP BY donors.country ORDER BY total_donations DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR, rural_county VARCHAR, state VARCHAR, has_telemedicine BOOLEAN); INSERT INTO hospitals (hospital_id, hospital_name, rural_county, state, has_telemedicine) VALUES (1, 'Rural Hospital A', 'County X', 'New York', true); INSERT INTO hospitals (hospital_id, hosp... | What is the percentage of rural hospitals with telemedicine capabilities, grouped by region? | SELECT regions.region_name, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM hospitals JOIN regions ON hospitals.state = regions.state) AS percentage FROM hospitals JOIN regions ON hospitals.state = regions.state WHERE hospitals.has_telemedicine = true GROUP BY regions.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name TEXT, tags TEXT, price DECIMAL); INSERT INTO dishes (id, name, tags, price) VALUES (1, 'Spicy Tofu', 'spicy', 11.99), (2, 'Chickpea Curry', 'vegan', 10.99), (3, 'Beef Burger', 'none', 15.99), (4, 'Spicy Chicken Sandwich', 'spicy', 14.99); | What is the average price of dishes with the 'spicy' tag? | SELECT AVG(price) FROM dishes WHERE tags LIKE '%spicy%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (threat_type VARCHAR(255), threat_level VARCHAR(255), report_date DATE); | Insert new records into the 'threat_intelligence' table for 'threat_type' 'Cyber' with 'threat_level' 'High' and 'report_date' '2022-04-01' | INSERT INTO threat_intelligence (threat_type, threat_level, report_date) VALUES ('Cyber', 'High', '2022-04-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE loans (id INT, country VARCHAR(50), amount DECIMAL(10,2), date DATE); INSERT INTO loans (id, country, amount, date) VALUES (1, 'USA', 1000.00, '2022-01-01'), (2, 'Canada', 1500.00, '2022-01-05'), (3, 'Mexico', 800.00, '2022-01-10'); | Find the top 3 countries with the highest total loans for socially responsible lending in Q1 2022, partitioned by month. | SELECT country, SUM(amount) as total_loans, EXTRACT(MONTH FROM date) as month FROM loans WHERE date >= '2022-01-01' AND date < '2022-04-01' GROUP BY country, month ORDER BY total_loans DESC, month LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2), location_id INT); INSERT INTO menus (menu_id, item_name, category, price, location_id) VALUES (1, 'Quinoa Salad', 'Vegan', 9.99, 101), (2, 'Tofu Stir Fry', 'Vegan', 12.49, 102); | What is the average revenue per location for vegan menu items? | SELECT AVG(price) FROM menus WHERE category = 'Vegan' GROUP BY location_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing_programs (id INT, country VARCHAR(255), launch_date DATE); | How many financial wellbeing programs were launched in South America in the last 7 years? | SELECT COUNT(*) FROM financial_wellbeing_programs WHERE country IN (SELECT country FROM (SELECT DISTINCT country FROM financial_wellbeing_programs WHERE launch_date >= DATEADD(year, -7, GETDATE())) t) AND launch_date >= DATEADD(year, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE MineSites (SiteID INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), GoldProductionDecimal FLOAT); | What is the average gold production per mine site in Australia? | SELECT Country, AVG(GoldProductionDecimal) AS AverageGoldProduction FROM MineSites WHERE Country = 'Australia' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, name VARCHAR(50), data_plan VARCHAR(50), data_usage FLOAT, region VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id, name, data_plan, data_usage, region) VALUES (1, 'Amy Adams', '2GB', 1500.0, 'San Francisco'); | Update the data plans of mobile subscribers in the San Francisco region with plans offering less than 3GB data to a 3GB plan. | UPDATE mobile_subscribers SET data_plan = '3GB' WHERE region = 'San Francisco' AND data_plan NOT IN ('3GB', 'More than 3GB'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Matches (team_id VARCHAR(10), score INT); INSERT INTO Matches (team_id, score) VALUES ('Team A', 80), ('Team A', 75), ('Team A', 90); | What is the average score of Team A's matches? | SELECT AVG(score) FROM Matches WHERE team_id = 'Team A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Prisons (PrisonID INT, PrisonType VARCHAR(20), State VARCHAR(20), AverageAge DECIMAL(3,1)); INSERT INTO Prisons VALUES (1, 'Maximum Security', 'CA', 45.6); INSERT INTO Prisons VALUES (2, 'Medium Security', 'CA', 39.7); | What is the average age of inmates in maximum security prisons? | SELECT AVG(AverageAge) FROM Prisons WHERE PrisonType = 'Maximum Security'; | 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.