context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE water_consumption_sectors (sector VARCHAR(50), year INT, consumption INT); INSERT INTO water_consumption_sectors (sector, year, consumption) VALUES ('Agricultural', 2018, 10000000), ('Agricultural', 2019, 11000000), ('Agricultural', 2020, 12000000), ('Industrial', 2018, 8000000), ('Industrial', 2019, 90000... | What is the total water consumption by agricultural and industrial sectors in 2020? | SELECT sector, SUM(consumption) as total_consumption FROM water_consumption_sectors WHERE year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_troops (id INT, country TEXT, mission TEXT, contribution_date DATE, troops INT); INSERT INTO peacekeeping_troops (id, country, mission, contribution_date, troops) VALUES (1, 'France', 'Mission 1', '2018-01-01', 500); | What is the total number of peacekeeping troops contributed by 'France' to all peacekeeping missions in the last 10 years? | SELECT SUM(troops) FROM peacekeeping_troops WHERE country = 'France' AND contribution_date >= DATE_SUB(CURDATE(), INTERVAL 10 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (id INT, state TEXT, year INT, capacity_mwh FLOAT); INSERT INTO energy_storage (id, state, year, capacity_mwh) VALUES (1, 'California', 2019, 500.2), (2, 'California', 2020, 700.3); | What was the total energy storage capacity (MWh) added in California in 2020? | SELECT SUM(capacity_mwh) FROM energy_storage WHERE state = 'California' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Location) VALUES (1, 'Manufacturer A', 'Asia'), (2, 'Manufacturer B', 'Europe'), (3, 'Manufacturer C', 'Africa'); CREATE TABLE Materials (MaterialID INT, Mate... | How many non-sustainable materials are used by manufacturers located in Europe and Africa? | SELECT COUNT(*) FROM ManufacturerMaterials JOIN Materials ON ManufacturerMaterials.MaterialID = Materials.MaterialID WHERE Type = 'Non-Sustainable' AND Manufacturers.Location IN ('Europe', 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (brand_id INT, brand_name TEXT, cruelty_free BOOLEAN, country TEXT); INSERT INTO Brands (brand_id, brand_name, cruelty_free, country) VALUES (1, 'Charlotte Tilbury', TRUE, 'UK'), (2, 'Illamasqua', TRUE, 'UK'), (3, 'Anastasia Beverly Hills', FALSE, 'USA'), (4, 'Mac', FALSE, 'Canada'), (5, 'NYX', TRUE... | Which cruelty-free brands are available in the UK? | SELECT brand_name FROM Brands WHERE country = 'UK' AND cruelty_free = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE tugboats (id INT PRIMARY KEY, name VARCHAR(50)); | Update the name of the tugboat with ID 1 to 'New Tugboat'. | UPDATE tugboats SET name = 'New Tugboat' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), word_count INT, category VARCHAR(255)); INSERT INTO news (title, author, word_count, category) VALUES ('Sample News', 'John Doe', 500, 'Politics'); | What is the total number of articles in the 'politics' category? | SELECT COUNT(*) FROM news WHERE category = 'Politics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT PRIMARY KEY, name VARCHAR(255), vessel_type VARCHAR(255), year_built INT); INSERT INTO vessels (id, name, vessel_type, year_built) VALUES (1, 'ABC Tanker', 'Tanker', 2000), (2, 'DEF Bulker', 'Bulker', 2010), (3, 'GHI Container', 'Container', 2015), (4, 'JKL Trawler', 'Trawler', 2008); | Update the vessels table to change the vessel_type to 'Tug' for the record with an id of 4 | UPDATE vessels SET vessel_type = 'Tug' WHERE id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE Country (Name VARCHAR(50), GDP NUMERIC(18,2), MilitarySpending NUMERIC(18,2)); INSERT INTO Country (Name, GDP, MilitarySpending) VALUES ('United States', 21435000, 770000), ('China', 14300000, 250000), ('India', 2800000, 66000); | Which countries have the highest military spending as a percentage of their GDP? | SELECT Name, MilitarySpending/GDP*100 AS MilitarySpendingPercentage FROM Country ORDER BY MilitarySpendingPercentage DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, GameType VARCHAR(10)); INSERT INTO Players (PlayerID, Age, GameType) VALUES (1, 25, 'Action'), (2, 30, 'RPG'), (3, 22, 'Action'), (4, 18, 'Strategy'); | What is the minimum age of players who play Strategy games? | SELECT MIN(Age) FROM Players WHERE GameType = 'Strategy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT, city VARCHAR(20), capacity INT); CREATE TABLE state (id INT, name VARCHAR(20)); INSERT INTO state (id, name) VALUES (1, 'California'), (2, 'Texas'), (3, 'Florida'); CREATE VIEW warehouse_state AS SELECT * FROM warehouse INNER JOIN state ON warehouse.id = state.id; | Add new records for two warehouses, one in Sacramento and another in San Diego, each with a capacity of 2000 | INSERT INTO warehouse (id, city, capacity) VALUES (6, 'Sacramento', 2000), (7, 'San Diego', 2000); INSERT INTO state (id, name) VALUES (4, 'California'); INSERT INTO warehouse_state (id, city, capacity, name) VALUES (6, 'Sacramento', 2000, 'California'), (7, 'San Diego', 2000, 'California'); | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys_expenses (attorney_id INT, expense_date DATE, amount DECIMAL(10, 2), description VARCHAR(255)); | CREATE a new table named 'attorneys_expenses' to store attorney expense information | CREATE TABLE attorneys_expenses (attorney_id INT, expense_date DATE, amount DECIMAL(10, 2), description VARCHAR(255)); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (1, 30, 'Non-binary', 'USA'); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (2, 25, 'Male', 'Canada'); CREATE TABLE Games (GameID INT, GameName VARCHAR(20),... | What's the average age of players who play RPG games in North America? | SELECT AVG(Players.Age) FROM Players INNER JOIN Games ON Players.Location = Games.GameName WHERE Games.Genre = 'RPG' AND Players.Location IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(50), monthly_fee DECIMAL(10,2), state VARCHAR(50)); INSERT INTO mobile_subscribers (id, name, monthly_fee, state) VALUES (13, 'Ivan Chen', 50, 'MI'); CREATE TABLE broadband_subscribers (id INT, name VARCHAR(50), monthly_fee DECIMAL(10,2), state VARCHAR(50)); INSERT ... | What is the total revenue generated from mobile and broadband subscribers in Michigan? | SELECT SUM(mobile_subscribers.monthly_fee + broadband_subscribers.monthly_fee) FROM mobile_subscribers, broadband_subscribers WHERE mobile_subscribers.state = 'MI' AND broadband_subscribers.state = 'MI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameWon BOOLEAN); | Find the number of players who have never won a game in the 'PlayerGames' table | SELECT COUNT(DISTINCT PlayerID) as PlayersNeverWon FROM PlayerGames WHERE GameWon = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_reviews (product_id INT, is_vegan BOOLEAN, is_cruelty_free BOOLEAN, rating INT); INSERT INTO product_reviews (product_id, is_vegan, is_cruelty_free, rating) VALUES (1, true, true, 4), (2, false, false, 3), (3, true, true, 5); | What is the average rating for vegan and cruelty-free facial creams? | SELECT AVG(rating) FROM product_reviews pr JOIN (SELECT DISTINCT product_id FROM cosmetic_products WHERE product_name LIKE '%facial cream%' AND is_vegan = true AND is_cruelty_free = true) cp ON pr.product_id = cp.product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE BusStops (id INT, city VARCHAR(255), accessible BOOLEAN, install_date DATE); | How many disabled-accessible bus stops were installed in London in 2021? | SELECT COUNT(*) FROM BusStops WHERE city = 'London' AND accessible = TRUE AND YEAR(install_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, price FLOAT, city VARCHAR(20)); INSERT INTO green_buildings (id, price, city) VALUES (1, 750000, 'Seattle'), (2, 850000, 'Seattle'), (3, 650000, 'Portland'); | What is the average property price for green-certified buildings in the city of Seattle? | SELECT AVG(price) FROM green_buildings WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AccidentYears (YearID int, Year int); CREATE TABLE AccidentReports (ReportID int, AccidentYearID int, AccidentDate date); INSERT INTO AccidentYears VALUES (1, 2010), (2, 2011), (3, 2012), (4, 2015), (5, 2019); INSERT INTO AccidentReports VALUES (1, 1, '2010-01-01'), (2, 1, '2011-05-15'), (3, 3, '2012-03-12... | List the total number of accidents in each year? | SELECT ay.Year, COUNT(ar.ReportID) as TotalAccidents FROM AccidentYears ay INNER JOIN AccidentReports ar ON ay.YearID = ar.AccidentYearID GROUP BY ay.Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT, animal_name VARCHAR(50), efforts INT, region VARCHAR(50)); INSERT INTO habitat_preservation VALUES (1, 'Bear', 3000, 'North America'); CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO animal_population VALUES (1,... | Compare the number of animals in 'habitat_preservation' and 'animal_population' tables for species in 'endangered_species' table in North America. | SELECT efforts FROM habitat_preservation WHERE animal_name IN (SELECT animal_name FROM endangered_species WHERE region = 'North America') UNION SELECT population FROM animal_population WHERE animal_name IN (SELECT animal_name FROM endangered_species WHERE region = 'North America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE InclusiveHousingUnits (Id INT, City VARCHAR(50), Units INT); INSERT INTO InclusiveHousingUnits (Id, City, Units) VALUES (1, 'SanDiego', 200), (2, 'Seattle', 400), (3, 'SanDiego', 300), (4, 'SanFrancisco', 600), (5, 'Portland', 700); | List all the inclusive housing units in San Diego, CA. | SELECT * FROM InclusiveHousingUnits WHERE City = 'SanDiego'; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, property_name VARCHAR(255), location VARCHAR(255), sustainability_rating INT); INSERT INTO properties (property_id, property_name, location, sustainability_rating) VALUES (1, 'Green Heights', 'Brooklyn', 85), (2, 'Sunrise Village', 'Seattle', 70), (3, 'EcoHaven', 'Austin', 88); | Create a view named "affordable_properties" that contains all properties with a sustainability rating of at least 80 | CREATE VIEW affordable_properties AS SELECT * FROM properties WHERE sustainability_rating >= 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_impact (region VARCHAR(50) PRIMARY KEY, impact_score INT, year INT); | Insert a new record in the 'drought_impact' table with the following data: region = 'Central Valley', impact_score = 8, year = 2022 | INSERT INTO drought_impact (region, impact_score, year) VALUES ('Central Valley', 8, 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, location VARCHAR(20), volume INT, date DATE); INSERT INTO wells (id, location, volume, date) VALUES (1, 'North Sea', 1000, '2021-10-01'); INSERT INTO wells (id, location, volume, date) VALUES (2, 'North Sea', 2000, '2021-11-01'); INSERT INTO wells (id, location, volume, date) VALUES (3, 'Nor... | Calculate the average production volume for wells in the North Sea in Q4 of 2021 | SELECT AVG(volume) FROM wells WHERE location = 'North Sea' AND QUARTER(date) = 4 AND YEAR(date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE student (id INT, program TEXT, gpa REAL); INSERT INTO student (id, program, gpa) VALUES (1, 'math', 3.8), (2, 'math', 3.9), (3, 'math', 4.0), (4, 'cs', 3.6), (5, 'cs', 3.7); | List the top 5 graduate students with the highest GPAs in the 'math' program. | SELECT * FROM student WHERE program = 'math' ORDER BY gpa DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (drug_name VARCHAR(50), country VARCHAR(50), approval_date DATE); INSERT INTO drug_approval (drug_name, country, approval_date) VALUES ('Drug1', 'India', '2005-01-01'), ('Drug2', 'India', '2008-01-01'), ('Drug3', 'India', '2011-01-01'); | What is the total number of approved drugs in India before 2010? | SELECT COUNT(*) FROM drug_approval WHERE country = 'India' AND approval_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE the_insight (title VARCHAR(255), author VARCHAR(255), topic VARCHAR(255)); | How many unique authors have written articles on 'education' or 'healthcare' in 'the_insight'? | SELECT COUNT(DISTINCT author) AS unique_authors FROM the_insight WHERE topic IN ('education', 'healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE aid (id INT, organization_name TEXT, recipient TEXT, amount FLOAT, aid_date DATE); INSERT INTO aid (id, organization_name, recipient, amount, aid_date) VALUES (1, 'UNHCR', 'Syrian refugees in Jordan', 500000, '2012-01-01'), (2, 'World Food Programme', 'Syrian refugees in Jordan', 700000, '2013-05-10'), (3,... | What is the total amount of humanitarian aid provided to Syrian refugees in Jordan since 2011? | SELECT SUM(amount) FROM aid WHERE recipient = 'Syrian refugees in Jordan' AND EXTRACT(YEAR FROM aid_date) >= 2011; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (initiative VARCHAR(255), sector VARCHAR(255), start_year INT, end_year INT); INSERT INTO conservation_initiatives (initiative, sector, start_year, end_year) VALUES ('Initiative A', 'rural', 2018, 2021), ('Initiative B', 'rural', 2020, 2022), ('Initiative C', 'urban', 2019, 2020), ... | List all water conservation initiatives in the 'rural' sector from 2018 to 2022. | SELECT initiative FROM conservation_initiatives WHERE sector = 'rural' AND start_year BETWEEN 2018 AND 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, country VARCHAR(50), year INT, cost FLOAT, completed BOOLEAN); INSERT INTO rural_infrastructure (id, country, year, cost, completed) VALUES (1, 'Nepal', 2019, 200000, TRUE); | What is the total cost of rural infrastructure projects in Nepal that were completed in 2019? | SELECT SUM(cost) FROM rural_infrastructure WHERE country = 'Nepal' AND year = 2019 AND completed = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE port_la_vessels (vessel_id INT, docking_date DATE, cargo_weight INT); | What is the average cargo weight for vessels that docked in the Port of Los Angeles in the past month? | SELECT AVG(cargo_weight) FROM port_la_vessels WHERE docking_date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy_Advocacy (advocacy_id INT, region VARCHAR(20), budget DECIMAL(10, 2), year INT); INSERT INTO Policy_Advocacy (advocacy_id, region, budget, year) VALUES (1, 'Southeast', 5000, 2020), (2, 'Northwest', 6000, 2019), (3, 'East Coast', 7000, 2020), (4, 'East Coast', 6000, 2019), (5, 'Northeast', 8000, 201... | What was the total budget for policy advocacy in "Northeast" region in 2019? | SELECT SUM(budget) FROM Policy_Advocacy WHERE region = 'Northeast' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryPersonnel (id INT, name VARCHAR(100), location VARCHAR(100)); INSERT INTO MilitaryPersonnel (id, name, location) VALUES (1, 'Person1', 'Asia'); INSERT INTO MilitaryPersonnel (id, name, location) VALUES (2, 'Person2', 'Africa'); | What is the total number of military personnel in 'Africa'? | SELECT COUNT(*) FROM MilitaryPersonnel WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_stories (story_id INT, title VARCHAR(100), description TEXT, reporter_id INT, publish_date DATE); CREATE TABLE news_reporters (reporter_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), hire_date DATE); | List all news stories from the 'news_stories' table that were published after the hire date of the reporter with the 'reporter_id' of 3. | SELECT news_stories.title FROM news_stories INNER JOIN news_reporters ON news_stories.reporter_id = news_reporters.reporter_id WHERE news_stories.publish_date > news_reporters.hire_date AND news_reporters.reporter_id = 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS NationalSecurity; CREATE TABLE IF NOT EXISTS NationalSecurity.National_Security_Events (event_id INT, event_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO NationalSecurity.National_Security_Events (event_id, event_name, start_date, end_date) VALUES (1, 'COVID-19 Pandemic', '... | What is the average duration of national security events for the 'NationalSecurity' schema? | SELECT AVG(DATEDIFF(end_date, start_date)) FROM NationalSecurity.National_Security_Events; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID int, Name varchar(50), Type varchar(50), AverageSpeed float); CREATE TABLE Cargo (CargoID int, VesselID int, MaterialType varchar(50), Tonnage int, TransportDate date); INSERT INTO Vessels VALUES (1, 'Vessel1', 'Transport', 15); INSERT INTO Cargo VALUES (1, 1, 'Non-Hazardous', 100, '2022-... | What is the total tonnage of non-hazardous cargo shipped by each vessel in the last year? | SELECT V.Name, SUM(C.Tonnage) FROM Vessels V INNER JOIN Cargo C ON V.VesselID = C.VesselID WHERE C.TransportDate >= DATEADD(year, -1, GETDATE()) AND C.MaterialType = 'Non-Hazardous' GROUP BY V.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(255), publication_date DATE, topic VARCHAR(50), news_org VARCHAR(50)); INSERT INTO articles (id, title, publication_date, topic, news_org) VALUES (1, 'Article1', '2020-01-01', 'Disinformation', 'Org1'), (2, 'Article2', '2020-02-15', 'Politics', 'Org2'), (3, 'Article3', '2020... | What percentage of articles published in 2020 by news organizations in Africa focused on disinformation? | SELECT (COUNT(*) FILTER (WHERE topic = 'Disinformation'))::DECIMAL / COUNT(*) AS disinformation_percentage FROM articles WHERE YEAR(publication_date) = 2020 AND news_org LIKE '%Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DonationDate DATE, Amount DECIMAL(10,2)); | Insert new records for 3 donors from the 'Donors' table | INSERT INTO Donors (DonorID, FirstName, LastName, DonationDate, Amount) VALUES (101, 'Sophia', 'Lee', '2022-12-31', 500), (102, 'Daniel', 'Kim', '2022-12-31', 750), (103, 'Ava', 'Garcia', '2022-12-31', 1000); | gretelai_synthetic_text_to_sql |
CREATE TABLE co_owners (owner_id INT, name VARCHAR(255), property_id INT); CREATE TABLE properties (property_id INT, sustainable BOOLEAN, address VARCHAR(255), neighborhood VARCHAR(255), city VARCHAR(255)); CREATE TABLE neighborhoods (neighborhood VARCHAR(255), city VARCHAR(255), housing_affordability_index FLOAT); | List the names of co-owners, their properties, and the corresponding neighborhood with sustainable features in the top 3 most affordable cities. | SELECT co_owners.name, properties.address, neighborhoods.neighborhood FROM co_owners INNER JOIN properties ON co_owners.property_id = properties.property_id INNER JOIN neighborhoods ON properties.neighborhood = neighborhoods.neighborhood WHERE properties.sustainable = TRUE AND neighborhoods.city IN (SELECT city FROM ne... | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (name TEXT, description TEXT, year INT); INSERT INTO incidents (name, description, year) VALUES ('SolarWinds Hack', 'Russian cyberespionage campaign.', 2020), ('Colonial Pipeline Ransomware Attack', 'Ransomware attack on a major US pipeline.', 2021), ('Microsoft Exchange Server Hack', 'Chinese st... | Delete all cybersecurity incidents in the incidents table that occurred after the year 2020. | DELETE FROM incidents WHERE year > 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE funds (id INT, category TEXT, region TEXT, amount DECIMAL(10,2)); INSERT INTO funds (id, category, region, amount) VALUES (1, 'Refugee Support', 'Middle East', 250000.00), (2, 'Disaster Response', 'Asia', 300000.00), (3, 'Community Development', 'Africa', 100000.00); | What is the minimum amount of funds spent on community development in Africa? | SELECT MIN(amount) FROM funds WHERE category = 'Community Development' AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure (id INT, type VARCHAR(50), status VARCHAR(20)); | List the unique types of rural infrastructure projects in the 'infrastructure' table, excluding any duplicates. | SELECT DISTINCT type FROM infrastructure; | gretelai_synthetic_text_to_sql |
CREATE TABLE biosensor_technology (id INT, name TEXT, type TEXT); INSERT INTO biosensor_technology (id, name, type) VALUES (1, 'Biosensor1', 'Optical'), (2, 'Biosensor2', 'Electrochemical'), (3, 'Biosensor3', 'Thermal'); | What is the name and type of the first biosensor in the 'biosensor_technology' table? | SELECT name, type FROM biosensor_technology WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE devices (id INT, name VARCHAR(50), user_rating INT, accessibility_rating INT); | Which accessible devices have the highest user ratings? | SELECT name, user_rating FROM devices WHERE accessibility_rating > 6 ORDER BY user_rating DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_centers (center_id INT, country VARCHAR(20), workers_count INT); INSERT INTO health_centers (center_id, country, workers_count) VALUES (1, 'Nepal', 25), (2, 'Bangladesh', 30); | Find the minimum number of healthcare workers in rural health centers in Nepal and Bangladesh. | SELECT MIN(workers_count) FROM health_centers WHERE country IN ('Nepal', 'Bangladesh'); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (id, name, location, depth) VALUES (1, 'MPA 1', 'Pacific Ocean', 123.4), (2, 'MPA 2', 'Atlantic Ocean', 150.0), (3, 'MPA 3', 'Atlantic Ocean', 200.0); | What is the maximum depth of all marine protected areas in the Atlantic Ocean? | SELECT MAX(depth) FROM marine_protected_areas WHERE location = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crime (cid INT, year INT, category VARCHAR(255), location VARCHAR(255)); | What is the total number of crimes reported in each location? | SELECT location, COUNT(*) FROM Crime GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dysprosium_Production (Year INT, Quantity INT); INSERT INTO Dysprosium_Production (Year, Quantity) VALUES (2015, 600), (2016, 650), (2017, 700), (2018, 750), (2019, 800); CREATE TABLE Holmium_Production (Year INT, Quantity INT); INSERT INTO Holmium_Production (Year, Quantity) VALUES (2015, 550), (2016, 600... | What is the difference in total production between Dysprosium and Holmium for all years? | SELECT (SELECT SUM(Quantity) FROM Dysprosium_Production) - (SELECT SUM(Quantity) FROM Holmium_Production); | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_production (year INT, crop VARCHAR(50), quantity INT); INSERT INTO crop_production (year, crop, quantity) VALUES (2020, 'Corn', 10000), (2020, 'Soybean', 8000), (2021, 'Corn', 11000), (2021, 'Soybean', 9000), (2021, 'Rice', 12000); | What is the total quantity of crops produced in 2021 in the 'crop_production' table? | SELECT SUM(quantity) as total_2021_production FROM crop_production WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_changes (id INT, year INT, avg_temp_change FLOAT); INSERT INTO temperature_changes VALUES (1, 2010, 0.12); | What is the minimum temperature change in the Arctic per year? | SELECT year, MIN(avg_temp_change) FROM temperature_changes GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO cultural_sites (id, name, country, visitors) VALUES (1, 'Temple A', 'Japan', 15000), (2, 'Shrine B', 'Japan', 12000), (3, 'Castle C', 'France', 20000); | What is the minimum visitor count for cultural heritage sites in Japan? | SELECT MIN(visitors) FROM cultural_sites WHERE country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, team_id INT, venue VARCHAR(50)); CREATE TABLE ticket_sales (id INT, game_id INT, num_tickets INT); | What is the average number of ticket sales for games played in the Staples Center? | SELECT AVG(ticket_sales.num_tickets) FROM ticket_sales JOIN games ON ticket_sales.game_id = games.id WHERE games.venue = 'Staples Center'; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (id INT, name VARCHAR(255)); CREATE TABLE monuments (id INT, state_id INT, name VARCHAR(255), address VARCHAR(255)); | What is the name and address of each historical monument in the state of New York? | SELECT m.name, m.address FROM monuments m JOIN states s ON m.state_id = s.id WHERE s.name = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseContracts (id INT PRIMARY KEY, year INT, country VARCHAR(50), contract VARCHAR(50), value FLOAT); INSERT INTO DefenseContracts (id, year, country, contract, value) VALUES (1, 2022, 'China', 'Contract C', 15000000); | Which defense contracts were signed with the Chinese government in 2022? | SELECT contract FROM DefenseContracts WHERE year = 2022 AND country = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE env_impact_sites (id INT, site VARCHAR, country VARCHAR, score INT); INSERT INTO env_impact_sites (id, site, country, score) VALUES (1, 'Site1', 'India', 85), (2, 'Site2', 'India', 90), (3, 'Site3', 'Russia', 80), (4, 'Site4', 'Russia', 95); | Which mining sites in India and Russia have the highest environmental impact scores? | SELECT site, score FROM env_impact_sites WHERE country IN ('India', 'Russia') ORDER BY score DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), role VARCHAR(50)); | Insert a new employee named 'Alice' in the 'it' department with the 'employee' role and an id of 4. | INSERT INTO employees (id, name, department, role) VALUES (4, 'Alice', 'it', 'employee'); | gretelai_synthetic_text_to_sql |
CREATE TABLE iot_vulnerabilities (id INT, device_type VARCHAR(255), severity INT); INSERT INTO iot_vulnerabilities (id, device_type, severity) VALUES (1, 'Smart Home', 7), (2, 'Industrial', 2), (3, 'Smart Home', 5); | How many high severity vulnerabilities exist in the database for IoT devices? | SELECT COUNT(*) FROM iot_vulnerabilities WHERE severity >= 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name TEXT, age INT, therapy TEXT, therapy_year INT); INSERT INTO patients (id, name, age, therapy, therapy_year) VALUES (1, 'Alice', 30, 'CBT', 2022), (2, 'Bob', 45, 'DBT', 2021), (3, 'Charlie', 60, 'CBT', 2018), (4, 'David', 50, 'CBT', 2022), (5, 'Eve', 55, 'DBT', 2019); | What's the average age of patients who received therapy in 2022? | SELECT AVG(age) FROM patients WHERE therapy_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE package_shipments_southeast_asia (id INT, package_weight FLOAT, shipped_from VARCHAR(20), shipped_to VARCHAR(20), shipped_date DATE); INSERT INTO package_shipments_southeast_asia (id, package_weight, shipped_from, shipped_to, shipped_date) VALUES (1, 1.5, 'Vietnam', 'Thailand', '2022-04-05'), (2, 2.4, 'Sin... | What is the minimum weight of packages shipped between countries in Southeast Asia in the last week? | SELECT MIN(package_weight) FROM package_shipments_southeast_asia WHERE shipped_from LIKE 'Southeast%' AND shipped_to LIKE 'Southeast%' AND shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE freshwater_fish_farms (id INT, name TEXT, region TEXT, ph FLOAT); INSERT INTO freshwater_fish_farms (id, name, region, ph) VALUES (1, 'Farm X', 'South America', 7.8), (2, 'Farm Y', 'South America', 8.2), (3, 'Farm Z', 'Africa', 7.4); | What is the maximum ph level in freshwater fish farms in the South American region? | SELECT MAX(ph) FROM freshwater_fish_farms WHERE region = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage ( date DATE, usage_category VARCHAR(20), region VARCHAR(20), usage_amount INT ); INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ( '2022-07-01', 'Residential', 'Northeast', 15000), ('2022-07-02', 'Industrial', 'Midwest', 200000), ('2022-07-03', 'Agricultural', 'West'... | Calculate the total water usage for the 'Residential' category between the dates '2022-07-01' and '2022-07-05' in the water_usage table | SELECT SUM(usage_amount) FROM water_usage WHERE usage_category = 'Residential' AND date BETWEEN '2022-07-01' AND '2022-07-05'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT PRIMARY KEY, country VARCHAR(255)); INSERT INTO suppliers (supplier_id, country) VALUES (1, 'Philippines'); CREATE TABLE ethical_labor_practices (supplier_id INT, wage_compliance FLOAT, worker_safety FLOAT); INSERT INTO ethical_labor_practices (supplier_id, wage_compliance, worke... | What is the average ethical labor compliance score for suppliers from the Philippines? | SELECT AVG(elp.wage_compliance + elp.worker_safety) as avg_compliance FROM ethical_labor_practices elp INNER JOIN suppliers s ON elp.supplier_id = s.supplier_id WHERE s.country = 'Philippines'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthProviders (ProviderID INT, HealthEquityMetricScore INT); INSERT INTO MentalHealthProviders (ProviderID, HealthEquityMetricScore) VALUES (1, 80), (2, 85), (3, 70), (4, 90), (5, 95), (6, 88), (7, 89); | List the top 5 mental health providers with the highest health equity metric scores, along with their corresponding scores. | SELECT ProviderID, HealthEquityMetricScore FROM (SELECT ProviderID, HealthEquityMetricScore, ROW_NUMBER() OVER (ORDER BY HealthEquityMetricScore DESC) as Rank FROM MentalHealthProviders) as RankedData WHERE Rank <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE staff_members (id INT, first_name VARCHAR(255), last_name VARCHAR(255)); INSERT INTO staff_members (id, first_name, last_name) VALUES (1, 'John', 'Doe'), (2, 'Jane', 'Smith'), (3, 'Robert', 'Johnson'), (4, 'Mary', 'Williams'), (5, 'Richard', 'Brown'), (6, 'Michael', 'Davis'), (7, 'Michelle', 'Miller'), (8,... | List the top 5 most common last names of staff members in 'human_resources' database. | SELECT last_name, COUNT(*) FROM staff_members GROUP BY last_name ORDER BY COUNT(*) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE corn_yield (id INT, state VARCHAR(20), organic BOOLEAN, yield INT); INSERT INTO corn_yield (id, state, organic, yield) VALUES (1, 'Iowa', 1, 8000), (2, 'Iowa', 1, 9000), (3, 'Iowa', 0, 10000), (4, 'Iowa', 0, 11000), (5, 'Iowa', 0, 12000); | What is the minimum and maximum yield of corn in Iowa, broken down by organic vs. non-organic crops? | SELECT state, MIN(yield) as min_yield, MAX(yield) as max_yield FROM corn_yield WHERE state = 'Iowa' GROUP BY state, organic; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), city VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, date DATE, won BOOLEAN); INSERT INTO teams VALUES (1, 'Celtics', 'Boston'); INSERT INTO teams VALUES (2, '76ers', 'Philadelphia'); INSERT INTO games VALUES (1, 1, '2022-02-15', true); INSERT INTO game... | What is the percentage of wins for each team in the last 5 games, ordered from the highest to the lowest? | SELECT team_id, AVG(won) as win_percentage, RANK() OVER (ORDER BY AVG(won) DESC) as rank FROM games WHERE date >= CURRENT_DATE - INTERVAL '5 days' GROUP BY team_id ORDER BY rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE Producers (ProducerID INT PRIMARY KEY, Name TEXT, ProductionYear INT, RareEarth TEXT, Quantity INT); | What is the total production of Neodymium in 2020, for companies that also produced Lanthanum in the same year? | SELECT SUM(Quantity) FROM Producers p1 WHERE RareEarth = 'Neodymium' AND ProductionYear = 2020 AND EXISTS (SELECT * FROM Producers p2 WHERE p2.ProducerID = p1.ProducerID AND RareEarth = 'Lanthanum' AND ProductionYear = 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (plant_id INT, country_id INT, capacity FLOAT); INSERT INTO renewable_energy VALUES (1, 1, 500), (2, 1, 700), (3, 2, 600), (4, 3, 800), (5, 3, 900); | What is the maximum renewable energy capacity per country? | SELECT country_id, MAX(capacity) as max_capacity FROM renewable_energy GROUP BY country_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, home_location VARCHAR(50), plan_speed DECIMAL(10,2)); INSERT INTO broadband_subscribers (subscriber_id, home_location, plan_speed) VALUES (1, 'Texas', 150), (2, 'California', 75), (3, 'Texas', 120); | List all the broadband subscribers in Texas who have a plan with speeds over 100 Mbps? | SELECT subscriber_id, home_location FROM broadband_subscribers WHERE plan_speed > 100 AND home_location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ads (id INT, category TEXT, revenue DECIMAL(10, 2), timestamp TIMESTAMP); | What was the total revenue generated from 'sports' ads in July 2022? | SELECT SUM(revenue) FROM ads WHERE category = 'sports' AND timestamp BETWEEN '2022-07-01 00:00:00' AND '2022-07-31 23:59:59'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50)); INSERT INTO Countries (CountryID, CountryName) VALUES (1, 'CountryA'), (2, 'CountryB'), (3, 'CountryC'); CREATE TABLE RecycledMaterials (MaterialID INT, MaterialName VARCHAR(50), Weight DECIMAL(5,2), CountryID INT); INSERT INTO RecycledMaterials (Material... | What is the total weight of recycled materials used by each country? | SELECT CountryName, SUM(Weight) as TotalWeight FROM Countries c JOIN RecycledMaterials rm ON c.CountryID = rm.CountryID GROUP BY CountryName; | gretelai_synthetic_text_to_sql |
CREATE TABLE EcoLodging (lodging_id INT, location TEXT, sustainability_rating FLOAT); INSERT INTO EcoLodging (lodging_id, location, sustainability_rating) VALUES (901, 'Eco-resort', 4.6), (902, 'Green hotel', 4.3); CREATE TABLE VisitorReviews (review_id INT, lodging_id INT, rating INT, feedback TEXT); INSERT INTO Visit... | Find the eco-friendly lodging with a sustainability_rating above 4.5 and its corresponding visitor reviews. | SELECT l.lodging_id, l.location, l.sustainability_rating, v.review_id, v.rating, v.feedback FROM EcoLodging l JOIN VisitorReviews v ON l.lodging_id = v.lodging_id WHERE l.sustainability_rating > 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE terbium_mines (mine_name VARCHAR(50), country VARCHAR(20)); INSERT INTO terbium_mines (mine_name, country) VALUES ('T1 Mine', 'China'), ('T2 Mine', 'Mongolia'), ('T3 Mine', 'Russia'); | How many Terbium mines are there in Asia? | SELECT COUNT(*) FROM terbium_mines WHERE country IN ('China', 'Mongolia', 'Russia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name TEXT); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT, is_vegan BOOLEAN); INSERT INTO products (product_id, product_name, brand_id, is_vegan) VALUES (1, 'Product A', 1, TRUE), (2, 'Product B', 1, FALSE), (3, 'Product C', 2, TRUE); | Which brands have the highest percentage of vegan products in the United Kingdom? | SELECT brand_name, AVG(is_vegan) as percentage_vegan FROM brands JOIN products ON brands.brand_id = products.brand_id GROUP BY brand_name ORDER BY percentage_vegan DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE readers (id INT, name VARCHAR(50), age INT); INSERT INTO readers (id, name, age) VALUES (1, 'Alice', 35), (2, 'Bob', 45), (3, 'Charlie', 50); CREATE TABLE preferences (reader_id INT, news_category VARCHAR(50)); INSERT INTO preferences (reader_id, news_category) VALUES (1, 'politics'), (2, 'sports'), (3, 'p... | What is the average age of readers who prefer news on politics in the "readers" and "preferences" tables? | SELECT AVG(readers.age) FROM readers INNER JOIN preferences ON readers.id = preferences.reader_id WHERE preferences.news_category = 'politics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor (id INT, worker_name VARCHAR(50), hours_worked INT, project_type VARCHAR(20), state VARCHAR(20)); INSERT INTO construction_labor (id, worker_name, hours_worked, project_type, state) VALUES (1, 'John Doe', 100, 'Sustainable', 'New York'); INSERT INTO construction_labor (id, worker_name, h... | List all workers who have worked on sustainable projects in the state of New York. | SELECT DISTINCT worker_name FROM construction_labor WHERE project_type = 'Sustainable' AND state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, usage FLOAT, purpose VARCHAR(20), date DATE); INSERT INTO water_usage (id, usage, purpose, date) VALUES (1, 220, 'residential', '2022-01-01'); INSERT INTO water_usage (id, usage, purpose, date) VALUES (2, 250, 'commercial', '2022-01-01'); | List the top 2 water consumers in 'January 2022' from the 'water_usage' table | SELECT purpose, SUM(usage) as total_usage FROM water_usage WHERE date = '2022-01-01' GROUP BY purpose ORDER BY total_usage DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE software (id INT, name VARCHAR(255)); INSERT INTO software (id, name) VALUES (1, 'Product A'), (2, 'Product B'), (3, 'Product C'); CREATE TABLE vulnerabilities (id INT, software_id INT, discovered_on DATE, severity VARCHAR(255)); INSERT INTO vulnerabilities (id, software_id, discovered_on, severity) VALUES... | List the software products with the highest number of high severity vulnerabilities, along with the number of days since the last high severity vulnerability was discovered. | SELECT software.name, COUNT(vulnerabilities.id) as high_severity_vulnerabilities, DATEDIFF(day, vulnerabilities.discovered_on, GETDATE()) as days_since_last_high_severity_vulnerability FROM software LEFT JOIN vulnerabilities ON software.id = vulnerabilities.software_id WHERE vulnerabilities.severity = 'High' GROUP BY s... | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_communities (community_id INT, community_name VARCHAR(50), region_id INT); | Insert a new indigenous community record for the Inuit community in Greenland. | INSERT INTO arctic_communities (community_id, community_name, region_id) VALUES (1, 'Inuit', (SELECT region_id FROM arctic_regions WHERE region_name = 'Greenland')); | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, artist_name VARCHAR(255), country VARCHAR(255), genre VARCHAR(255), tickets_sold INT); INSERT INTO Concerts (id, artist_name, country, genre, tickets_sold) VALUES (1, 'Taylor Swift', 'USA', 'Pop', 10000), (2, 'BTS', 'South Korea', 'K-Pop', 15000), (3, 'Ed Sheeran', 'UK', 'Folk', 12000), (... | What is the total number of concert tickets sold for each genre in the Concerts table? | SELECT genre, SUM(tickets_sold) as total_tickets_sold FROM Concerts GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(50), num_livestock INT); INSERT INTO farmers (id, name, num_livestock) VALUES (1, 'John', 5), (2, 'Jane', 3), (3, 'Doe', 4); | What is the average number of livestock per farmer in the 'rural_development' database? | SELECT AVG(num_livestock) FROM farmers; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions(id INT, name VARCHAR(255), launch_date DATE); INSERT INTO space_missions(id, name, launch_date) VALUES (1, 'Ares I-1', '2009-08-18'); VALUES (2, 'Mars One', '2031-12-15'); | What was the launch date of the first manned mission to Mars? | SELECT launch_date FROM space_missions WHERE name = 'Mars One'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_meetings (meeting_id INT, city VARCHAR(20), year INT, month INT, meetings_held INT); INSERT INTO public_meetings (meeting_id, city, year, month, meetings_held) VALUES (1, 'Los Angeles', 2021, 1, 5); | Determine the number of public meetings held in the city of Los Angeles in each month of the year 2021 | SELECT month, SUM(meetings_held) FROM public_meetings WHERE city = 'Los Angeles' AND year = 2021 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (warehouse_id VARCHAR(10), warehouse_location VARCHAR(20)); INSERT INTO warehouse (warehouse_id, warehouse_location) VALUES ('A', 'New York'); CREATE TABLE customers (customer_id VARCHAR(10), customer_name VARCHAR(20)); INSERT INTO customers (customer_id, customer_name) VALUES ('B', 'Chicago'); C... | What is the total quantity of items shipped from warehouse A to customer B? | SELECT SUM(quantity) FROM shipments WHERE warehouse_id = 'A' AND customer_id = 'B'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (id INT, name VARCHAR(255), last_workshop_date DATE); INSERT INTO teachers (id, name, last_workshop_date) VALUES (1, 'Teacher D', '2021-06-01'), (2, 'Teacher E', '2021-02-15'), (3, 'Teacher F', '2021-01-01'); | How many teachers have undergone professional development in the last 6 months? | SELECT COUNT(*) FROM teachers WHERE last_workshop_date >= DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (SiteID int, SiteName varchar(100), AddedDate date); INSERT INTO HeritageSites (SiteID, SiteName, AddedDate) VALUES (1, 'Angkor Wat', '2022-01-01'), (2, 'Forbidden City', '2021-05-15'), (3, 'Taj Mahal', '2022-03-10'); | How many heritage sites were added in the last year? | SELECT COUNT(*) FROM (SELECT * FROM HeritageSites WHERE AddedDate >= DATEADD(YEAR, -1, GETDATE())) t; | gretelai_synthetic_text_to_sql |
CREATE TABLE tb_cases (id INT, case_number INT, report_date DATE, city TEXT); INSERT INTO tb_cases (id, case_number, report_date, city) VALUES (1, 123, '2022-01-01', 'Chicago'); INSERT INTO tb_cases (id, case_number, report_date, city) VALUES (2, 456, '2022-06-15', 'Chicago'); | How many cases of tuberculosis were reported in Chicago in the past 6 months? | SELECT COUNT(*) FROM tb_cases WHERE report_date >= DATEADD(month, -6, CURRENT_DATE) AND city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE BirdSightings (ID INT, SightingDate DATE, Species VARCHAR(100), Reserve VARCHAR(100), Observations INT); INSERT INTO BirdSightings (ID, SightingDate, Species, Reserve, Observations) VALUES (1, '2022-05-01', 'Snowy Owl', 'Nunavut Wildlife Reserve', 10); INSERT INTO BirdSightings (ID, SightingDate, Species, ... | How many sightings of each bird species were recorded in the last month across all Arctic reserves? | SELECT Species, Reserve, COUNT(Observations) OVER (PARTITION BY Species, Reserve ORDER BY Species, Reserve ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS SightingsCount FROM BirdSightings WHERE SightingDate >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityGardens (state VARCHAR(50), city VARCHAR(50), area_ha INT); INSERT INTO CommunityGardens (state, city, area_ha) VALUES ('California', 'San Francisco', 100), ('California', 'Los Angeles', 200), ('New York', 'New York', 150), ('Texas', 'Houston', 50); | What is the total area (in hectares) of community gardens in the US, disaggregated by state? | SELECT state, SUM(area_ha) FROM CommunityGardens GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_areas (area_id INT, area_name VARCHAR(255));CREATE TABLE educational_institutions (institution_id INT, institution_name VARCHAR(255), area_id INT);CREATE TABLE funding (funding_id INT, institution_id INT, funding_date DATE);INSERT INTO urban_areas (area_id, area_name) VALUES (1, 'City A'), (2, 'City ... | What is the number of educational institutions in urban areas that received funding in the last 3 years? | SELECT COUNT(*) FROM educational_institutions e JOIN funding f ON e.institution_id = f.institution_id JOIN urban_areas u ON e.area_id = u.area_id WHERE u.area_name IN ('City A', 'City B') AND f.funding_date >= DATEADD(year, -3, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name VARCHAR(255), type VARCHAR(255), popularity INT); INSERT INTO dishes (id, name, type, popularity) VALUES (1, 'Burger', 'Non-vegetarian', 70), (2, 'Sandwich', 'Non-vegetarian', 50), (3, 'Pasta', 'Vegetarian', 80), (4, 'Steak', 'Non-vegetarian', 60); CREATE VIEW lunch_menus AS SELECT id ... | Find the most popular non-vegetarian dish across all lunch menus? | SELECT d.name, d.type, d.popularity FROM dishes d JOIN lunch_menus lm ON 1=1 WHERE d.type = 'Non-vegetarian' ORDER BY d.popularity DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA indigenous_systems;CREATE TABLE farmers (id INT, name VARCHAR(50), country VARCHAR(50), area_ha FLOAT);INSERT INTO indigenous_systems.farmers (id, name, country, area_ha) VALUES (1, 'Farmer 1', 'Country A', 30.5), (2, 'Farmer 2', 'Country B', 45.8), (3, 'Farmer 3', 'Country A', 55.2), (4, 'Farmer 4', 'Cou... | Identify the number of farmers in each country, along with the total area of farmland they manage, in the 'indigenous_systems' schema. | SELECT country, COUNT(*), SUM(area_ha) FROM indigenous_systems.farmers GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Region TEXT, DonationAmount DECIMAL(10,2), EventCount INT); INSERT INTO Donors VALUES (1, 'John Smith', 'Sub-Saharan Africa', 750.00, 3), (2, 'Jane Doe', 'Sub-Saharan Africa', 250.00, 7); | Which volunteers have donated more than $500 but have participated in fewer than 5 events in the Sub-Saharan Africa region? | SELECT DonorName FROM Donors WHERE DonationAmount > 500 AND EventCount < 5 AND Region = 'Sub-Saharan Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleSafetyTests (Manufacturer VARCHAR(50), Model VARCHAR(50), Year INT, SafetyRating DECIMAL(3,2)); INSERT INTO VehicleSafetyTests (Manufacturer, Model, Year, SafetyRating) VALUES ('Hyundai', 'Elantra', 2022, 4.5), ('Hyundai', 'Sonata', 2022, 4.9), ('Subaru', 'Outback', 2022, 4.8), ('Subaru', 'Forester'... | What is the safety rating of vehicles by manufacturer and model for 2022? | SELECT Manufacturer, Model, SafetyRating FROM VehicleSafetyTests WHERE Year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation_sector (sector VARCHAR(255), threat_actor VARCHAR(255), attacks INT); INSERT INTO transportation_sector (sector, threat_actor, attacks) VALUES ('Transportation', 'Threat Actor A', 25), ('Transportation', 'Threat Actor B', 35), ('Transportation', 'Threat Actor C', 45), ('Transportation', 'Thr... | What is the maximum number of attacks by a threat actor in the transportation sector? | SELECT MAX(attacks) FROM transportation_sector WHERE sector = 'Transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (sale_id INT, product VARCHAR(255), region VARCHAR(255), quantity INT); INSERT INTO sales_data (sale_id, product, region, quantity) VALUES (1, 'Energy Efficient Fridge', 'region_a', 12), (2, 'Solar Panel', 'region_b', 20); | How many energy efficient appliances were sold in 'region_a' and 'region_b' from the 'sales_data' table? | SELECT SUM(quantity) FROM sales_data WHERE (region = 'region_a' OR region = 'region_b') AND product LIKE '%Energy Efficient%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tencel_sources (brand VARCHAR(50), country VARCHAR(50), year INT); INSERT INTO tencel_sources (brand, country, year) VALUES ('BrandG', 'Germany', 2022), ('BrandH', 'Austria', 2021), ('BrandI', 'China', 2021); | Delete the record of a brand sourcing Tencel from a country in 2021. | DELETE FROM tencel_sources WHERE brand = 'BrandI' AND country = 'China' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability_programs (program_id INT, program_name VARCHAR(50), region VARCHAR(50)); | Determine the number of financial capability programs in each region | SELECT region, COUNT(*) FROM financial_capability_programs GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (name VARCHAR(255), type VARCHAR(50)); CREATE TABLE worker (id INT, name VARCHAR(255), position VARCHAR(50), mine_id INT); | Find the total number of workers in underground and open-pit mines, excluding administrative staff. | SELECT mine.type AS mine_type, COUNT(*) AS worker_count FROM mine INNER JOIN worker ON mine.id = worker.mine_id WHERE mine.type IN ('underground', 'open-pit') AND worker.position NOT IN ('administrator', 'manager') GROUP BY mine.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_union (department VARCHAR(50), salary FLOAT); INSERT INTO research_union (department, salary) VALUES ('Biology', 45000), ('Chemistry', 50000), ('Physics', 42000); | Find the minimum salary in the 'research_union' table for each department. | SELECT department, MIN(salary) AS min_salary FROM research_union GROUP BY department; | 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.