context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE imagery (id INT, field_name VARCHAR(20), filename VARCHAR(30)); INSERT INTO imagery (id, field_name, filename) VALUES (1, 'north_field', 'img101.jpg'), (2, 'west_field', 'img102.jpg'), (3, 'west_field', 'img103.jpg'), (4, 'east_field', 'img104.jpg'); | List all unique satellite image filenames for the 'west_field' from the 'imagery' table? | SELECT DISTINCT filename FROM imagery WHERE field_name = 'west_field'; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_plans (plan_name TEXT, launch_date DATE, speed INT); | What is the average speed of broadband plans launched in 2021? | SELECT AVG(speed) FROM broadband_plans WHERE launch_date >= '2021-01-01' AND launch_date < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE non_profit (id INT, name TEXT); INSERT INTO non_profit (id, name) VALUES (1, 'UNICEF'), (2, 'World Food Programme'), (3, 'Oxfam'); CREATE TABLE projects (id INT, non_profit_id INT, project_type TEXT, project_date DATE); INSERT INTO projects (id, non_profit_id, project_type, project_date) VALUES (1, 1, 'Dis... | How many disaster relief projects were conducted by each non-profit in the last two years? | SELECT n.name, COUNT(p.id) as num_projects FROM non_profit n INNER JOIN projects p ON n.id = p.non_profit_id WHERE p.project_type = 'Disaster Relief' AND p.project_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY n.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE agriculture_water_usage (state VARCHAR(20), year INT, usage FLOAT); INSERT INTO agriculture_water_usage (state, year, usage) VALUES ('Arizona', 2018, 6.7); | Delete the record of water usage in the agricultural sector in Arizona in 2018. | DELETE FROM agriculture_water_usage WHERE state = 'Arizona' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrganicProduce (country VARCHAR(50), volume_sold INT); INSERT INTO OrganicProduce (country, volume_sold) VALUES ('USA', 1200), ('Mexico', 800), ('Brazil', 600), ('China', 500), ('India', 400); | What are the top 3 countries with the most organic produce sold by volume? | SELECT country, SUM(volume_sold) AS total_volume FROM OrganicProduce GROUP BY country ORDER BY total_volume DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteDeployments (id INT, country VARCHAR(255), year INT, success BOOLEAN); INSERT INTO SatelliteDeployments VALUES (1, 'China', 2010, true), (2, 'USA', 2012, false), (3, 'China', 2015, true), (4, 'India', 2008, true), (5, 'India', 2014, true), (6, 'India', 2017, true); | How many successful satellite deployments occurred in India before 2015? | SELECT COUNT(*) FROM SatelliteDeployments WHERE country = 'India' AND success = true AND year < 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_pd (teacher_id INT, tier INT, courses_completed INT); INSERT INTO teacher_pd (teacher_id, tier, courses_completed) VALUES (1, 1, 2), (2, 3, 3), (3, 2, 1), (4, 1, 5), (5, 3, 4); | What is the maximum number of professional development courses completed by a teacher in each tier? | SELECT tier, MAX(courses_completed) FROM teacher_pd GROUP BY tier; | gretelai_synthetic_text_to_sql |
CREATE TABLE Chemicals (ChemicalID INT PRIMARY KEY, ChemicalName VARCHAR(50), Department VARCHAR(50), QuantityInStock INT, ReorderLevel INT); INSERT INTO Chemicals (ChemicalID, ChemicalName, Department, QuantityInStock, ReorderLevel) VALUES (5, 'Ethanol', 'Manufacturing', 600, 500); INSERT INTO Chemicals (ChemicalID, C... | What is the total quantity of chemicals in the Manufacturing department that have a quantity in stock above the reorder level? | SELECT SUM(Chemicals.QuantityInStock) FROM Chemicals WHERE Chemicals.Department = 'Manufacturing' AND Chemicals.QuantityInStock > Chemicals.ReorderLevel; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id VARCHAR(10), port_name VARCHAR(20)); INSERT INTO port VALUES ('P1', 'A'), ('P2', 'B'); CREATE TABLE handling (handling_id INT, port_id VARCHAR(10), cargo_weight INT, handling_date DATE); INSERT INTO handling VALUES (1, 'P1', 5000, '2022-01-01'), (2, 'P1', 6000, '2022-02-01'), (3, 'P1', 7000, ... | What is the total cargo weight handled at each port in June 2022? | SELECT port.port_name, SUM(handling.cargo_weight) FROM port INNER JOIN handling ON port.port_id = handling.port_id WHERE handling_date BETWEEN '2022-06-01' AND '2022-06-30' GROUP BY port.port_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Department (id INT, name VARCHAR(255)); INSERT INTO Department (id, name) VALUES (1, 'Water and Sewage'); CREATE TABLE Project (id INT, name VARCHAR(255), department_id INT, cost DECIMAL(10, 2)); INSERT INTO Project (id, name, department_id, cost) VALUES (1, 'Project X', 1, 500000.00), (2, 'Project Y', 1, ... | Find the total cost of all projects in the Water and Sewage department | SELECT SUM(cost) FROM Project WHERE department_id = (SELECT id FROM Department WHERE name = 'Water and Sewage'); | gretelai_synthetic_text_to_sql |
CREATE TABLE operators (operator_id INT, operator_name TEXT); INSERT INTO operators (operator_id, operator_name) VALUES (1, 'Operator X'), (2, 'Operator Y'); CREATE TABLE wells (well_id INT, operator_id INT, year INT, location TEXT); INSERT INTO wells (well_id, operator_id, year, location) VALUES (1, 1, 2020, 'Arctic')... | Retrieve the number of wells drilled by each operator in the Arctic region | SELECT o.operator_name, COUNT(w.well_id) AS num_wells_drilled FROM wells w JOIN operators o ON w.operator_id = o.operator_id WHERE w.location = 'Arctic' GROUP BY o.operator_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE riders (rider_id INT, name VARCHAR(255), address VARCHAR(255)); INSERT INTO riders (rider_id, name, address) VALUES (1, 'John Smith', '456 Elm St'); | Update rider 'John Smith's' name to 'Jack Smith' | UPDATE riders SET name = 'Jack Smith' WHERE name = 'John Smith'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (species VARCHAR(50), animal_count INT); | List the names of all the animals that are not present in the 'animal_population' table but are in the 'animal_relocation' table. | SELECT species FROM animal_relocation WHERE species NOT IN (SELECT species FROM animal_population); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (Id INT PRIMARY KEY, Name VARCHAR(100), Age INT, DonationAmount DECIMAL(10, 2)); INSERT INTO Donors (Id, Name, Age, DonationAmount) VALUES (1, 'John Doe', 35, 500.00); INSERT INTO Donors (Id, Name, Age, DonationAmount) VALUES (3, 'Mariam K Touré', 45, 800.00); INSERT INTO Donors (Id, Name, Age, Dona... | What is the total amount donated by donors from South America? | SELECT SUM(Donations.Amount) FROM Donations JOIN Donors ON Donations.DonorId=Donors.Id JOIN Countries ON Donors.Name=Countries.Name WHERE Countries.Continent = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE update_health_cause (cause_id INT, cause_name VARCHAR(50), donation_amount DECIMAL(10, 2)); INSERT INTO update_health_cause (cause_id, cause_name, donation_amount) VALUES (2, 'Health', 30000.00); | Update the 'Health' cause donation amount to 35000.00. | UPDATE update_health_cause SET donation_amount = 35000.00 WHERE cause_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, fan_name VARCHAR(20)); INSERT INTO fans (fan_id, fan_name) VALUES (1, 'Jim Brown'), (2, 'Jake White'), (3, 'Jane Smith'); CREATE TABLE sales (sale_id INT, fan_id INT, game_id INT, quantity INT); INSERT INTO sales (sale_id, fan_id, game_id, quantity) VALUES (1, 1, 1, 2), (2, 1, 2, 1), (3, ... | Find the top 3 ticket buyers for baseball games. | SELECT fans.fan_name, SUM(sales.quantity) FROM fans JOIN sales ON fans.fan_id = sales.fan_id JOIN games ON sales.game_id = games.game_id WHERE games.game_type = 'Baseball' GROUP BY fans.fan_name ORDER BY SUM(sales.quantity) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_funding (id INT, region VARCHAR(255), funding FLOAT, year INT); | What is the total conservation funding per region for the last 3 years? | SELECT region, SUM(funding) as total_funding, EXTRACT(YEAR FROM date_trunc('year', current_date)) - sequence AS years_ago FROM conservation_funding, generate_series(1, 3) sequence GROUP BY region, sequence ORDER BY years_ago DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rate_history (city_id INT, measurement_date DATE, material VARCHAR(50), recycling_rate FLOAT); INSERT INTO recycling_rate_history (city_id, measurement_date, material, recycling_rate) VALUES (1, '2021-01-01', 'Plastic', 0.3), (1, '2021-01-01', 'Paper', 0.6), (1, '2021-01-01', 'Glass', 0.5), (1, '... | What is the change in recycling rate for each material over time in CityA? | SELECT material, LAG(recycling_rate) OVER (PARTITION BY material ORDER BY measurement_date) as previous_recycling_rate, recycling_rate, measurement_date FROM recycling_rate_history WHERE city_id = 1 ORDER BY measurement_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives(id INT, name TEXT, country TEXT, status TEXT, budget INT); INSERT INTO initiatives(id, name, country, status, budget) VALUES (1, 'Clean Water Access', 'Indonesia', 'completed', 50000), (2, 'Road Construction', 'Indonesia', 'in progress', 100000); | List all the community development initiatives in Indonesia that have been completed and their budgets. | SELECT name, budget FROM initiatives WHERE country = 'Indonesia' AND status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (ProgramName varchar(100), Budget decimal(10,2)); INSERT INTO LanguagePreservation (ProgramName, Budget) VALUES ('Rosetta Stone', 150000.00), ('Endangered Languages Project', 250000.00), ('Talking Dictionaries', 120000.00); | What is the average budget for language preservation programs? | SELECT AVG(Budget) FROM LanguagePreservation; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (project_name VARCHAR(50), country VARCHAR(50), solar_capacity INT); INSERT INTO renewable_energy (project_name, country, solar_capacity) VALUES ('Project4', 'Canada', 18000), ('Project5', 'Canada', 21000), ('Project6', 'Canada', 24000); | What is the maximum installed capacity of solar panels for all renewable energy projects in Canada? | SELECT MAX(solar_capacity) FROM renewable_energy WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floors (id INT, region TEXT, point TEXT, depth INT); INSERT INTO ocean_floors (id, region, point, depth) VALUES (1, 'Philippine Sea', 'Philippine Trench', 10592); | What is the average depth of the Philippine Trench? | SELECT AVG(depth) FROM ocean_floors WHERE point = 'Philippine Trench'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(255), launch_date DATE); | Which country has launched the most satellites in the month of January? | SELECT country, COUNT(*) AS launched_satellites FROM satellites WHERE EXTRACT(MONTH FROM launch_date) = 1 GROUP BY country ORDER BY launched_satellites DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_dev_brazil (initiative VARCHAR(50), budget FLOAT, year INT); INSERT INTO community_dev_brazil (initiative, budget, year) VALUES ('Education', 5000000, 2010), ('Healthcare', 8000000, 2010), ('Education', 6000000, 2015), ('Healthcare', 9000000, 2015); | What was the combined investment in community development initiatives in Brazil from 2010 to 2015? | SELECT SUM(budget) FROM community_dev_brazil WHERE year BETWEEN 2010 AND 2015 AND initiative IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE yearly_visitor_count (destination VARCHAR(50), year INT, visitor_count INT); | Identify destinations that experienced a continuous increase in visitor count for at least 3 years? | SELECT a.destination FROM yearly_visitor_count a JOIN yearly_visitor_count b ON a.destination = b.destination AND a.year = b.year + 1 JOIN yearly_visitor_count c ON a.destination = c.destination AND a.year = c.year + 2 WHERE a.visitor_count > b.visitor_count AND b.visitor_count > c.visitor_count GROUP BY a.destination; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, order_id INT, item_type VARCHAR(50), destination_country VARCHAR(50), quantity INT); INSERT INTO shipments (id, order_id, item_type, destination_country, quantity) VALUES (1, 1001, 'Electronics', 'USA', 50), (2, 1002, 'Furniture', 'Canada', 80), (3, 1003, 'Electronics', 'Mexico', 75), (4... | What is the total quantity of items shipped to each country, for items of type 'Electronics'? | SELECT destination_country, SUM(quantity) as total_quantity FROM shipments WHERE item_type = 'Electronics' GROUP BY destination_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists vulnerabilities (vulnerability_id INT, discovered_date DATE, cvss_score INT); INSERT INTO vulnerabilities (vulnerability_id, discovered_date, cvss_score) VALUES (1, '2021-04-01', 8), (2, '2021-04-15', 6), (3, '2021-05-01', 9); | Which vulnerabilities were found in the last quarter and have a CVSS score above 7? | SELECT vulnerability_id, discovered_date, cvss_score FROM vulnerabilities WHERE discovered_date >= DATEADD(quarter, -1, GETDATE()) AND cvss_score > 7; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA FoodService;CREATE TABLE Restaurants (restaurant_id INT, name VARCHAR(50), category VARCHAR(50), revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, category, revenue) VALUES (1, 'Cafe Azure', 'dining', 500000.00), (2, 'Bistro Blanc', 'takeout', 350000.00); | What is the total revenue for each restaurant in the "dining" category? | SELECT category, SUM(revenue) as total_revenue FROM Restaurants WHERE category = 'dining' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_observations (species VARCHAR(255), observation_count INT); | How many times has each species been observed? | SELECT species, COUNT(*) FROM species_observations GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE cuisine (cuisine_id INT PRIMARY KEY, cuisine_name VARCHAR(255));CREATE TABLE dishes (dish_id INT PRIMARY KEY, dish_name VARCHAR(255), cuisine_id INT, calories INT, FOREIGN KEY (cuisine_id) REFERENCES cuisine(cuisine_id)); | Find the top 3 most caloric dishes per cuisine category | SELECT c.cuisine_name, d.dish_name, d.calories FROM dishes d JOIN cuisine c ON d.cuisine_id = c.cuisine_id WHERE (c.cuisine_id, d.calories) IN (SELECT cuisine_id, MAX(calories) FROM dishes GROUP BY cuisine_id) GROUP BY c.cuisine_id, d.dish_name, d.calories LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE planets (id INT PRIMARY KEY, name VARCHAR(50), distance_to_sun FLOAT); INSERT INTO planets (id, name, distance_to_sun) VALUES (1, 'Mercury', 0.39), (2, 'Venus', 0.72), (3, 'Earth', 1), (4, 'Mars', 1.52); | What are the names of the planets closest to the sun? | SELECT name FROM planets ORDER BY distance_to_sun ASC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE usage (id INT, subscriber_id INT, plan_id INT, usage_time DECIMAL(10,2)); CREATE TABLE mobile_plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2)); CREATE TABLE regions (id INT, name VARCHAR(255)); | What is the average usage time for mobile plans in each region? | SELECT regions.name AS region, AVG(usage_time) FROM usage JOIN mobile_plans ON usage.plan_id = mobile_plans.id JOIN regions ON subscribers.region = regions.id GROUP BY regions.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (shipment_id INT, warehouse_id INT, shipped_date DATE, delivered_date DATE, late_flag BOOLEAN); INSERT INTO shipments (shipment_id, warehouse_id, shipped_date, delivered_date, late_flag) VALUES (1, 1, '2022-02-21', '2022-02-23', true), (2, 2, '2022-02-22', '2022-02-24', false), (3, 3, '2022-02-23... | What is the percentage of packages that were delivered late, for each warehouse, in the last week? | SELECT warehouse_id, AVG(late_flag) * 100.0 as pct_late_deliveries FROM shipments WHERE shipped_date BETWEEN DATEADD(day, -7, GETDATE()) AND GETDATE() GROUP BY warehouse_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (incident_id INT, incident_date DATE, mitigation_team VARCHAR(255)); INSERT INTO security_incidents (incident_id, incident_date, mitigation_team) VALUES (1, '2021-03-22', 'Incident Response Team A'), (2, '2021-04-15', 'Incident Response Team B'), (3, '2021-05-09', 'Incident Response Team... | How many security incidents were mitigated by each team in the last month? | SELECT mitigation_team, COUNT(*) AS incident_count FROM security_incidents WHERE incident_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY mitigation_team; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, year INT, quarter INT, country VARCHAR(255), equipment_type VARCHAR(255)); | Insert a new military project with the Saudi Arabia and 'Cyber Security' equipment type in Q3 2022 | INSERT INTO projects (year, quarter, country, equipment_type) VALUES (2022, 3, 'Saudi Arabia', 'Cyber Security'); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (id INT, animal_name VARCHAR(50)); CREATE TABLE endangered_species (id INT, animal_name VARCHAR(50), endangered_status VARCHAR(50)); | What is the number of animals in the 'community_education' table that belong to endangered species? | SELECT COUNT(*) FROM community_education ce INNER JOIN endangered_species es ON ce.animal_name = es.animal_name WHERE endangered_status = 'Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(255), budget DECIMAL(10, 2)); | Insert a new movie 'Movie C' with genre 'Action' and budget 7000000 into the database. | INSERT INTO movies (title, genre, budget) VALUES ('Movie C', 'Action', 7000000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_farms (id INT, species VARCHAR(50), biomass FLOAT); INSERT INTO marine_farms (id, species, biomass) VALUES (1, 'Tuna', 2500.0), (2, 'Salmon', 1000.0); | What is the total biomass of marine fish species? | SELECT SUM(biomass) FROM marine_farms WHERE species IN ('Tuna', 'Salmon'); | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT PRIMARY KEY, company_name VARCHAR(255), location VARCHAR(255), ethical_certification VARCHAR(255), last_audit_date DATE); | Insert data into suppliers for 'Seoul Ethical Manufacturing Co.' located in Seoul, South Korea with ethical certification and last audit date | INSERT INTO suppliers (id, company_name, location, ethical_certification, last_audit_date) VALUES (1, 'Seoul Ethical Manufacturing Co.', 'Seoul, South Korea', 'Ethically Certified', '2021-12-11'); | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (id INT, date DATE, circular_supply_chain BOOLEAN, amount DECIMAL(10,2)); | What is the total revenue generated from circular supply chain initiatives, by quarter, in the past two years? | SELECT DATEPART(quarter, date) as quarter, SUM(amount) as total_revenue FROM revenue WHERE circular_supply_chain = TRUE AND date >= DATEADD(year, -2, GETDATE()) GROUP BY DATEPART(quarter, date); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainability_initiatives (sustainability_initiative_id INT, name VARCHAR(50), description TEXT, start_date DATE, end_date DATE); | Insert a new record into the sustainability_initiatives table for a local farm partnership | INSERT INTO sustainability_initiatives (name, description, start_date, end_date) VALUES ('Local Farm Partnership', 'Partnership with local farms to source ingredients', '2021-01-01', '2023-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE city_charging_points (city VARCHAR(255), num_charging_points INT); | Show the top 5 cities with the most electric vehicle charging points | CREATE VIEW city_charging_points AS SELECT charging_stations.city, SUM(charging_stations.num_charging_points) as num_charging_points FROM charging_stations GROUP BY charging_stations.city; SELECT city, num_charging_points FROM city_charging_points ORDER BY num_charging_points DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE units (id INT, city VARCHAR, inclusive_housing BOOLEAN, rent DECIMAL); | What is the maximum rent for inclusive housing units in Seoul? | SELECT MAX(rent) FROM units WHERE city = 'Seoul' AND inclusive_housing = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE permafrost_data (measurement_id INT, measurement_date DATE, thickness FLOAT, location VARCHAR(50)); | Show the change in permafrost thickness for each year, along with the number of measurements taken. | SELECT YEAR(measurement_date) AS year, AVG(thickness) AS avg_thickness_change, COUNT(*) AS total_measurements FROM permafrost_data WHERE location LIKE '%Arctic%' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (habitat_id INT, habitat_name VARCHAR(50), habitat_status VARCHAR(50)); INSERT INTO habitats (habitat_id, habitat_name, habitat_status) VALUES (1, 'Habitat A', 'protected'), (2, 'Habitat B', 'unprotected'), (3, 'Habitat C', 'forest'); CREATE TABLE animal_habitats (animal_id INT, habitat_id INT); I... | What is the total number of animals in 'forest' habitats? | SELECT COUNT(*) FROM animal_habitats INNER JOIN habitats ON animal_habitats.habitat_id = habitats.habitat_id WHERE habitats.habitat_name = 'forest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases_by_crime (id INT, crime_type VARCHAR(50), restorative_justice BOOLEAN, case_closed_date DATE); | What is the number of cases and the percentage of cases resolved through restorative justice, by type of crime? | SELECT crime_type, COUNT(*) number_of_cases, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY NULL) AS percentage_restorative_justice FROM cases_by_crime WHERE restorative_justice = TRUE GROUP BY crime_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE AthleteWellbeing (AthleteID INT, AthleteName VARCHAR(50), InjuryStatus VARCHAR(20)); INSERT INTO AthleteWellbeing (AthleteID, AthleteName, InjuryStatus) VALUES (1, 'Athlete1', 'Injured'), (2, 'Athlete2', 'Healthy'); | Update the athlete's injury status in the AthleteWellbeing table. | UPDATE AthleteWellbeing SET InjuryStatus = 'Healthy' WHERE AthleteID = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_name TEXT, donation_amount FLOAT, donation_date DATE, state TEXT); INSERT INTO Donations (id, donor_name, donation_amount, donation_date, state) VALUES (1, 'John Doe', 250, '2022-01-01', 'NY'), (2, 'Jane Smith', 125, '2022-01-02', 'CA'); | What is the maximum donation amount and the state for that donation? | SELECT state, MAX(donation_amount) FROM Donations; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation_rwanda (id INT, country VARCHAR(255), project VARCHAR(255), cost FLOAT, year INT); INSERT INTO agricultural_innovation_rwanda (id, country, project, cost, year) VALUES (1, 'Rwanda', 'New Seed Variety', 3000000, 2020), (2, 'Rwanda', 'Drip Irrigation', 4000000, 2021), (3, 'Rwanda', 'P... | What was the total cost of agricultural innovation projects in Rwanda in 2020 and 2021? | SELECT SUM(cost) FROM agricultural_innovation_rwanda WHERE country = 'Rwanda' AND year IN (2020, 2021); | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums (MuseumID int, MuseumName varchar(50), Country varchar(50), Website varchar(100)); INSERT INTO Museums (MuseumID, MuseumName, Country, Website) VALUES (1, 'Sydney Opera House', 'Australia', 'https://www.sydneyoperahouse.com'); INSERT INTO Museums (MuseumID, MuseumName, Country, Website) VALUES (2, ... | List all museums in Oceania with their respective websites. | SELECT MuseumName, Website FROM Museums WHERE Country = 'Oceania' | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), RegionID INT, JoinDate DATE, MembershipType VARCHAR(50), MembershipFee DECIMAL(5,2)); | How many members joined in each region in the last month? | SELECT r.RegionName, COUNT(m.MemberID) AS NewMembers FROM Regions r INNER JOIN Members m ON r.RegionID = m.RegionID WHERE m.JoinDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY r.RegionName; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (garment_id INT, material VARCHAR(255), organic BOOLEAN); INSERT INTO materials (garment_id, material, organic) VALUES (1, 'cotton', TRUE); INSERT INTO materials (garment_id, material, organic) VALUES (2, 'polyester', FALSE); INSERT INTO materials (garment_id, material, organic) VALUES (3, 'silk'... | What is the percentage of organic cotton used in garments manufactured in Europe? | SELECT (COUNT(CASE WHEN organic THEN 1 END)/COUNT(*))*100 FROM materials WHERE material = 'cotton' AND garment_id IN (SELECT garment_id FROM garments WHERE manufacture_location LIKE 'Europe%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), HireDate DATE, TerminationDate DATE); INSERT INTO Employees (EmployeeID, EmployeeName, Department, HireDate, TerminationDate) VALUES (1, 'John Doe', 'IT', '2022-01-01', '2022-06-30'), (2, 'Jane Smith', 'IT', '2022-02-01', NULL), (... | Determine the number of new hires in each department, and the number of employees who have left the company, in the last 6 months. | SELECT Department, COUNT(CASE WHEN TerminationDate IS NULL AND HireDate >= DATEADD(MONTH, -6, GETDATE()) THEN 1 ELSE NULL END) AS NewHires, COUNT(CASE WHEN TerminationDate IS NOT NULL AND TerminationDate >= DATEADD(MONTH, -6, GETDATE()) THEN 1 ELSE NULL END) AS EmployeesLeft FROM Employees GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue_by_quarter (restaurant_name VARCHAR(255), revenue DECIMAL(10, 2), quarter INT, year INT); INSERT INTO revenue_by_quarter (restaurant_name, revenue, quarter, year) VALUES ('Taco Time', 12000, 1, 2022), ('Taco Time', 15000, 2, 2022), ('Taco Time', 13000, 3, 2022); | What is the total revenue for 'Taco Time' in Q1 2022? | SELECT SUM(revenue) FROM revenue_by_quarter WHERE restaurant_name = 'Taco Time' AND quarter = 1 AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); INSERT INTO users (id, country, followers) VALUES (1, 'United States', 1000), (2, 'Canada', 2000), (3, 'Australia', 5000), (4, 'India', 7000); CREATE VIEW region_users AS SELECT id, country, followers, CASE WHEN country IN ('Australia', 'New Zealand') TH... | What is the maximum number of followers for users in the Asia-Pacific region? | SELECT MAX(users.followers) AS max_followers FROM users JOIN region_users ON users.id = region_users.id WHERE region_users.region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_projects (project_type VARCHAR(255), project_status VARCHAR(255), budget INT); INSERT INTO rural_infrastructure_projects (project_type, project_status, budget) VALUES ('Bridge', 'Under Construction', 2000000), ('Road', 'Completed', 1500000); | List the total budget for rural infrastructure projects by project type and project status, and calculate the average budget per project in the 'rural_infrastructure_projects' table. | SELECT project_type, project_status, SUM(budget) AS total_budget, AVG(budget) AS average_budget_per_project FROM rural_infrastructure_projects GROUP BY project_type, project_status; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (id INT, title VARCHAR(100), positive_representation BOOLEAN, country VARCHAR(50), air_date DATE); INSERT INTO tv_shows (id, title, positive_representation, country, air_date) VALUES (1, 'Show1', TRUE, 'USA', '2022-01-01'), (2, 'Show2', FALSE, 'USA', '2022-01-05'), (3, 'Show3', TRUE, 'USA', '2022-... | What is the percentage of TV shows with positive representation of racial and ethnic minorities in the United States in the last 90 days? | SELECT (COUNT(*) * 100 / (SELECT COUNT(*) FROM tv_shows WHERE air_date >= DATEADD(day, -90, GETDATE()))) AS percentage FROM tv_shows WHERE positive_representation = TRUE AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farms (id INT, country VARCHAR(50), region VARCHAR(50), area_ha FLOAT); INSERT INTO organic_farms (id, country, region, area_ha) VALUES (1, 'USA', 'North America', 12345.6); INSERT INTO organic_farms (id, country, region, area_ha) VALUES (2, 'Canada', 'North America', 7890.1); INSERT INTO organic_f... | What is the total organic farming area in 'North America'? | SELECT SUM(area_ha) FROM organic_farms WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE aquaculture_farms (id INT, name VARCHAR(255)); INSERT INTO aquaculture_farms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'); CREATE TABLE fish_biomass (id INT, farm_id INT, species VARCHAR(255), biomass DECIMAL(5,2)); INSERT INTO fish_biomass (id, farm_id, species, biomass) VALUES (1, 1, 'Tilapia', 120.5),... | Calculate the total biomass of salmon in all farms. | SELECT SUM(biomass) FROM fish_biomass WHERE species = 'Salmon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE e_commerce (id INT, salesperson VARCHAR(50), completed_orders INT, total_orders INT, order_date DATE); INSERT INTO e_commerce (id, salesperson, completed_orders, total_orders, order_date) VALUES (1, 'Sophia Lee', 10, 15, '2022-01-01'); INSERT INTO e_commerce (id, salesperson, completed_orders, total_orders... | What is the number of 'completed_orders' and total orders for each salesperson per day, for the 'e-commerce' database, ordered by salesperson and day? | SELECT salesperson, order_date, SUM(completed_orders) OVER (PARTITION BY salesperson ORDER BY order_date) as completed_orders, SUM(total_orders) OVER (PARTITION BY salesperson ORDER BY order_date) as total_orders FROM e_commerce; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, diagnosis VARCHAR(20), location VARCHAR(20)); INSERT INTO patients (id, age, diagnosis, location) VALUES (1, 65, 'diabetes', 'rural Texas'); | What is the average age of patients diagnosed with diabetes in rural areas of Texas? | SELECT AVG(age) FROM patients WHERE diagnosis = 'diabetes' AND location = 'rural Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfectiousDiseases (Id INT, Disease TEXT, Region TEXT, Date DATE); INSERT INTO InfectiousDiseases (Id, Disease, Region, Date) VALUES (1, 'Measles', 'Region A', '2022-01-01'); INSERT INTO InfectiousDiseases (Id, Disease, Region, Date) VALUES (2, 'Mumps', 'Region A', '2022-01-02'); INSERT INTO InfectiousDise... | Delete all records of infectious diseases reported in Region C. | DELETE FROM InfectiousDiseases WHERE Region = 'Region C'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists gaming; | Create a new table named 'tournaments' with columns 'id', 'name', 'location', 'start_date', 'end_date' | CREATE TABLE gaming.tournaments (id INT, name VARCHAR(100), location VARCHAR(100), start_date DATE, end_date DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (date DATE, temperature FLOAT); | What is the average temperature per month for each year in the 'arctic_weather' table? | SELECT EXTRACT(YEAR FROM date) AS year, EXTRACT(MONTH FROM date) AS month, AVG(temperature) AS avg_temperature FROM arctic_weather GROUP BY year, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE containers (id INT, port VARCHAR(255), handled_date DATE); INSERT INTO containers (id, port, handled_date) VALUES (1, 'XYZ', '2022-03-02'), (2, 'ABC', '2022-03-03'), (3, 'DEF', '2022-03-04'), (4, 'XYZ', '2022-03-05'), (5, 'ABC', '2022-03-06'); | How many containers were handled by each port in the month of March 2022? | SELECT port, COUNT(*) FROM containers WHERE handled_date BETWEEN '2022-03-01' AND '2022-03-31' GROUP BY port; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(50)); CREATE TABLE digital_divide_initiatives (id INT, country_id INT, initiatives INT); INSERT INTO countries (id, name) VALUES (1, 'Brazil'), (2, 'India'), (3, 'China'), (4, 'South Africa'); INSERT INTO digital_divide_initiatives (id, country_id, initiatives) VALUES (1, 1,... | List the number of digital divide initiatives in each country, sorted by the total number in descending order. | SELECT countries.name, SUM(digital_divide_initiatives.initiatives) as total_initiatives FROM countries INNER JOIN digital_divide_initiatives ON countries.id = digital_divide_initiatives.country_id GROUP BY countries.name ORDER BY total_initiatives DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element TEXT, quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 100), (2016, 'Dysprosium', 150), (2017, 'Dysprosium', 200), (2018, 'Dysprosium', 250), (2019, 'Dysprosium', 300), (2020, 'Dysprosium', 350), (2015, 'Neodymium', 500), (2016, 'Neod... | What is the total REE production in 2020? | SELECT SUM(quantity) FROM production WHERE year = 2020 AND element IN ('Dysprosium', 'Neodymium'); | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(255), country VARCHAR(255)); INSERT INTO peacekeeping_operations (id, operation_name, country) VALUES (1, 'Operation One', 'France'), (2, 'Operation Two', 'Germany'), (3, 'Operation Three', 'France'), (4, 'Operation Four', 'Germany'), (5, 'Operation F... | List all peacekeeping operations that involve more than one country | SELECT operation_name FROM peacekeeping_operations WHERE country IN ( SELECT country FROM peacekeeping_operations GROUP BY country HAVING COUNT(DISTINCT country) > 1 ); | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name TEXT, focus TEXT); INSERT INTO Restaurants (id, name, focus) VALUES (1, 'Bean Scene', 'Sustainability'), (2, 'Cafe Delirium', 'Coffee'), (3, 'Eco Brew', 'Sustainability'); CREATE TABLE Menu (id INT, name TEXT, type TEXT, plant_based BOOLEAN, restaurant_id INT); CREATE TABLE Orders... | What is the total quantity of plant-based orders in each restaurant with a sustainability focus, in the last month? | SELECT Restaurants.name, SUM(Orders.quantity) as total_quantity FROM Orders JOIN Menu ON Orders.menu_id = Menu.id JOIN Restaurants ON Menu.restaurant_id = Restaurants.id WHERE Restaurants.focus = 'Sustainability' AND Menu.plant_based = 1 AND Orders.order_date >= CURRENT_DATE - INTERVAL '1 month' GROUP BY Restaurants.na... | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), recyclable BOOLEAN); INSERT INTO materials (id, name, category, recyclable) VALUES (1, 'Plastic', 'Packaging', FALSE), (2, 'Aluminum', 'Metals', TRUE), (3, 'Glass', 'Packaging', TRUE), (4, 'Paper', 'Paper', TRUE); | What is the number of recyclable and non-recyclable materials for each category, and the percentage of recyclable materials for each category? | SELECT category, SUM(CASE WHEN recyclable THEN 1 ELSE 0 END) as recyclable_count, SUM(CASE WHEN NOT recyclable THEN 1 ELSE 0 END) as non_recyclable_count, 100.0 * AVG(CASE WHEN recyclable THEN 1.0 ELSE 0.0 END) as recyclable_percentage FROM materials GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, is_ethical BOOLEAN, category VARCHAR(20), quantity INT); INSERT INTO products (product_id, is_ethical, category, quantity) VALUES (1, true, 'Clothing', 10), (2, false, 'Electronics', 20), (3, true, 'Clothing', 30); | What is the average quantity of ethically sourced products in the clothing category? | SELECT AVG(products.quantity) FROM products WHERE products.is_ethical = true AND products.category = 'Clothing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (id INT, region VARCHAR(20), investment FLOAT, date DATE); INSERT INTO network_investments (id, region, investment, date) VALUES (1, 'western', 500000, '2021-01-01'); INSERT INTO network_investments (id, region, investment, date) VALUES (2, 'eastern', 600000, '2021-01-05'); | What is the total network investment for the 'western' region in the last 2 years? | SELECT SUM(investment) FROM network_investments WHERE region = 'western' AND date BETWEEN DATE_SUB(NOW(), INTERVAL 2 YEAR) AND NOW(); | gretelai_synthetic_text_to_sql |
CREATE TABLE district (name VARCHAR(20), income FLOAT); INSERT INTO district (name, income) VALUES ('North', 45000.0), ('East', 50000.0), ('West', 40000.0), ('South', 55000.0), ('South', 58000.0), ('South', 56000.0); | What is the maximum income in the "South" district? | SELECT MAX(income) FROM district WHERE name = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name TEXT, production_qty FLOAT, operator_id INT); INSERT INTO wells (well_id, well_name, production_qty, operator_id) VALUES (1, 'Well A', 1000, 1), (2, 'Well B', 1500, 1), (3, 'Well C', 800, 2); CREATE TABLE operators (operator_id INT, operator_name TEXT); INSERT INTO operators (... | Which operators have the lowest average production quantity per well? | SELECT o.operator_name, AVG(w.production_qty) as avg_production FROM wells w JOIN operators o ON w.operator_id = o.operator_id GROUP BY o.operator_name ORDER BY avg_production ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE counties (id INT, name TEXT, state TEXT); INSERT INTO counties (id, name, state) VALUES (1, 'County A', 'California'), (2, 'County B', 'Texas'); CREATE TABLE patients (id INT, name TEXT, age INT, county_id INT, has_heart_disease BOOLEAN); INSERT INTO patients (id, name, age, county_id, has_heart_disease) V... | What is the prevalence of heart disease in each county, and what is the population of each county? | SELECT counties.name, counties.state, COUNT(patients.id), SUM(CASE WHEN patients.has_heart_disease = true THEN 1 ELSE 0 END) FROM patients RIGHT JOIN counties ON patients.county_id = counties.id GROUP BY counties.name, counties.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (dish_id INT, dish_name TEXT, category TEXT, rating FLOAT); INSERT INTO dishes (dish_id, dish_name, category, rating) VALUES (1, 'Spicy Quinoa', 'Vegan', 4.25), (2, 'Tofu Stir Fry', 'Vegan', 4.50), (3, 'Chickpea Curry', 'Vegan', 4.75), (4, 'Beef Burrito', 'Non-Veg', 4.20), (5, 'Chicken Alfredo', 'No... | What is the maximum rating received by a 'Non-Veg' dish? | SELECT category, MAX(rating) FROM dishes WHERE category = 'Non-Veg' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE books (id INT PRIMARY KEY, title TEXT, year INT, genre TEXT, author TEXT); INSERT INTO books (id, title, year, genre, author) VALUES (1, 'Book1', 2020, 'Fantasy', 'Aisha Khan'), (2, 'Book2', 2019, 'Mystery', 'Jamal Smith'); | Insert new records about books with diverse authors and genres. | INSERT INTO books (id, title, year, genre, author) VALUES (3, 'Book3', 2021, 'Sci-Fi', 'Maria Rodriguez'), (4, 'Book4', 2020, 'Romance', 'Jose Hernandez'); | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(100), publication_state VARCHAR(20)); | What is the total number of news articles published in each state of the United States in the "articles" table? | SELECT publication_state, COUNT(*) AS num_articles FROM articles GROUP BY publication_state; | gretelai_synthetic_text_to_sql |
CREATE TABLE city (name VARCHAR(255), population INT); CREATE TABLE pet_ownership (city VARCHAR(255), resident_id INT, has_pet BOOLEAN); INSERT INTO city (name, population) VALUES ('New York', 8406000), ('Los Angeles', 3971883), ('Chicago', 2695598), ('Houston', 2351031), ('Phoenix', 1660272); INSERT INTO pet_ownership... | How many residents in each city have a pet? | SELECT city, SUM(has_pet) FROM pet_ownership JOIN city ON pet_ownership.city = city.name GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE bus_trips (trip_id INT, trip_date DATE, trip_start_time TIME, trip_end_time TIME, vehicle_type VARCHAR(20)); | What is the daily trip frequency for autonomous buses? | SELECT trip_date, vehicle_type, COUNT(*) AS daily_trips FROM bus_trips WHERE vehicle_type = 'Autonomous Bus' GROUP BY trip_date, vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_practices2 (product_id INT, brand VARCHAR(255), quantity_sold INT); | Insert a new record into the 'labor_practices2' table for a brand with the name 'BrandT', a product_id of 5, and a quantity_sold of 650. | INSERT INTO labor_practices2 (product_id, brand, quantity_sold) VALUES (5, 'BrandT', 650); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (attendee_id INT, program VARCHAR(50), year INT, score INT); | which community education programs had the lowest attendance in 2020? | SELECT program, MIN(score) FROM community_education WHERE year = 2020 GROUP BY program ORDER BY MIN(score) LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousDrivingStudies (StudyID INT, StudyName TEXT, Participants INT); | Which autonomous driving research studies have more than 20 participants? | SELECT StudyName, Participants FROM AutonomousDrivingStudies HAVING Participants > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (drug_name VARCHAR(255), trial_cost FLOAT, approval_year INT, primary_sponsor VARCHAR(255)); INSERT INTO clinical_trials (drug_name, trial_cost, approval_year, primary_sponsor) VALUES ('DrugA', 12000000, 2020, 'Pfizer'), ('DrugB', 15000000, 2020, 'Merck'), ('DrugC', 9000000, 2020, 'AstraZen... | What is the average cost of clinical trials per drug that were approved by the FDA in 2020? | SELECT AVG(trial_cost) FROM clinical_trials WHERE approval_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT, platform VARCHAR(50), target_age INT, start_date DATE, end_date DATE, ad_spend DECIMAL(10, 2)); | Find the total ad spend on Instagram campaigns targeting the age group 25-34 in Q2 2022. | SELECT SUM(ad_spend) FROM campaigns WHERE platform = 'Instagram' AND target_age BETWEEN 25 AND 34 AND start_date BETWEEN '2022-04-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AnimalPopulation (AnimalID int, AnimalName varchar(50), Population int); INSERT INTO AnimalPopulation (AnimalID, AnimalName, Population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 5000); CREATE TABLE HabitatPreservation (AnimalID int, HabitatSize int); INSERT INTO HabitatPreservation (AnimalID, HabitatSize... | What is the total number of animals in the 'AnimalPopulation' and 'HabitatPreservation' tables? | (SELECT Population FROM AnimalPopulation) UNION (SELECT HabitatSize FROM HabitatPreservation) | gretelai_synthetic_text_to_sql |
CREATE TABLE otas (ota_id INT, hotel_id INT, bookings INT, revenue FLOAT); CREATE TABLE hotels (hotel_id INT, name TEXT, category TEXT); INSERT INTO otas (ota_id, hotel_id, bookings, revenue) VALUES (1, 1, 100, 1000), (2, 2, 150, 2250), (3, 3, 75, 1500); INSERT INTO hotels (hotel_id, name, category) VALUES (1, 'Hotel A... | What is the total revenue generated by hotels in the 'Luxury' category from OTA bookings? | SELECT SUM(otas.revenue) FROM otas INNER JOIN hotels ON otas.hotel_id = hotels.hotel_id WHERE hotels.category = 'Luxury'; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, author_id INT, year INT, title VARCHAR(255)); INSERT INTO publications (id, author_id, year, title) VALUES (1, 1, 2019, 'Machine Learning Algorithms'), (2, 1, 2020, 'Deep Learning'), (3, 2, 2019, 'Quantum Physics'), (4, 3, 2020, 'Data Visualization'), (5, 3, 2021, 'Natural Language Pr... | What is the average number of academic publications per year by each author? | SELECT author_id, AVG(total_publications) FROM (SELECT author_id, COUNT(*) as total_publications FROM publications GROUP BY author_id, year) as subquery GROUP BY author_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, Country VARCHAR(255), SpendingAmount DECIMAL(10,2)); | What are the average defense spending amounts for each country in the past 5 years, and the corresponding year? | SELECT Country, Year, AVG(SpendingAmount) as AvgSpending FROM Budget WHERE Year BETWEEN EXTRACT(YEAR FROM CURRENT_DATE)-5 AND EXTRACT(YEAR FROM CURRENT_DATE) GROUP BY Country, Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, policy_holder_id INT, policy_type VARCHAR(20), policy_start_date DATE); | Delete policy records with a policy_type of 'Home' and a policy_start_date older than 10 years from the 'policy' table. | DELETE FROM policy WHERE policy_type = 'Home' AND policy_start_date < DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE art_history (id INT PRIMARY KEY, era VARCHAR(50), start_year INT, end_year INT); INSERT INTO art_history (id, era, start_year, end_year) VALUES (2, 'Baroque', 1600, 1750); CREATE TABLE auctions (id INT PRIMARY KEY, date DATE, art_piece_id INT, sold_price DECIMAL(5,2)); INSERT INTO auctions (id, date, art_p... | What is the average sale price of art pieces from the Baroque era? | SELECT AVG(a.sold_price) as average_price FROM auctions a JOIN art_pieces ap ON a.art_piece_id = ap.id JOIN artists ar ON ap.artist_id = ar.id JOIN art_history ah ON ar.style = ah.era WHERE ah.era = 'Baroque'; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_preferences (product_id INT, product_name VARCHAR(255), preference_score FLOAT); | What are the top 5 most preferred cosmetic products by consumers? | SELECT product_name, preference_score FROM consumer_preferences ORDER BY preference_score DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE textile_emissions (id INT, country VARCHAR(50), region VARCHAR(50), co2_emissions INT); INSERT INTO textile_emissions (id, country, region, co2_emissions) VALUES (1, 'Egypt', 'Africa', 6000), (2, 'Ethiopia', 'Africa', 4000), (3, 'South Africa', 'Africa', 7000), (4, 'USA', 'North America', 8000); | What is the average CO2 emissions for textiles sourced from Africa? | SELECT AVG(co2_emissions) as avg_co2_emissions FROM textile_emissions WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Location VARCHAR(50)); INSERT INTO Employees (EmployeeID, Location) VALUES (1, 'NYC'), (2, 'LA'), (3, 'NYC'), (4, 'NYC'), (5, 'LA'); | Show the number of employees in each location, ordered by the number of employees. | SELECT Location, COUNT(*) FROM Employees GROUP BY Location ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research (project_id INT, project_name VARCHAR(100), partner VARCHAR(50)); INSERT INTO genetic_research VALUES (1, 'Genome Mapping', 'Public'); INSERT INTO genetic_research VALUES (2, 'DNA Sequencing', 'Private'); INSERT INTO genetic_research VALUES (3, 'Gene Therapy', 'Public-Private'); | Identify the genetic research projects that have not received private funding and list the funding sources for each. | SELECT project_name, partner AS funding_source FROM genetic_research WHERE partner <> 'Private' UNION SELECT project_name, 'No Private Funding' FROM genetic_research WHERE partner = 'Private'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_name VARCHAR, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations (id, donor_name, donation_amount, donation_date) VALUES (1, 'John Doe', 100, '2021-01-01'); | Which donors have not donated in the last 6 months? | SELECT donor_name FROM donations WHERE donation_date < CURDATE() - INTERVAL 6 MONTH EXCEPT SELECT donor_name FROM donations WHERE donation_date >= CURDATE() - INTERVAL 6 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (donation_id INT, donor_id INT, cause TEXT); CREATE TABLE Donors (donor_id INT, donor_name TEXT, country TEXT); | How many donors have donated to environmental causes in France? | SELECT COUNT(DISTINCT donor_id) FROM Donations JOIN Donors ON Donations.donor_id = Donors.donor_id WHERE cause = 'environment' AND country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE flu_vaccinations (id INT, patient_id INT, region TEXT, vaccine_date DATE); INSERT INTO flu_vaccinations (id, patient_id, region, vaccine_date) VALUES (1, 456, 'Ontario', '2021-02-03'); | How many flu vaccinations were administered by region in Canada in Q1 2021? | SELECT region, COUNT(*) as num_vaccinations FROM flu_vaccinations WHERE vaccine_date >= '2021-01-01' AND vaccine_date < '2021-04-01' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (id INT PRIMARY KEY, name VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (6, 'Artemis III', 'NASA', '2024-07-01'); CREATE TABLE Research_Projects (id INT PRIMARY KEY, name VARCHAR(100), field VARCHAR(100), start_dat... | Show the spacecraft involved in research projects that have not yet started and their respective principal investigators. | SELECT s.name AS spacecraft_name, r.name AS research_project, a.name AS principal_investigator FROM Spacecraft s INNER JOIN Research_Projects r ON s.id = r.id INNER JOIN Astronauts a ON r.principal_investigator_id = a.id WHERE r.start_date > CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE Cities (CityName VARCHAR(50), Population INT); INSERT INTO Cities (CityName, Population) VALUES ('CityA', 600000), ('CityB', 300000), ('CityC', 700000); | List the names of cities and their population counts from 'Cities' table where the population is greater than 500,000? | SELECT CityName, Population FROM Cities WHERE Population > 500000 | 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.