context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), region_id INT, country VARCHAR(255)); | Show all suppliers from a specific region | SELECT suppliers.name FROM suppliers INNER JOIN regions ON suppliers.region_id = regions.id WHERE regions.name = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2), city VARCHAR(50)); CREATE TABLE policies (policy_id INT, policy_holder_id INT, policy_type VARCHAR(50), issue_date DATE); | What is the total number of claims for each type of insurance, for policyholders residing in the city of New York? | SELECT p.policy_type, COUNT(c.claim_id) FROM claims c JOIN policies p ON c.policy_id = p.policy_id WHERE city = 'New York' GROUP BY p.policy_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, HireDate, Salary) VALUES (1, '2020-01-01', 75000.00), (2, '2019-01-01', 60000.00), (3, '2020-03-01', 80000.00), (4, '2018-04-01', 90000.00), (5, '2020-05-01', 95000.00), (6, '2019-06-01', 65000.00); | What is the maximum salary for employees who were hired in the first quarter of any year? | SELECT MAX(Salary) FROM Employees WHERE QUARTER(HireDate) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (project_id INT, region VARCHAR(20), labor_hours INT); INSERT INTO project VALUES (1, 'Northeast', 500); INSERT INTO project VALUES (2, 'Southwest', 700); INSERT INTO project VALUES (3, 'Midwest', 600); | Identify the top 2 regions with the highest average labor hours per project and their respective averages. | SELECT region, AVG(labor_hours) as avg_labor_hours, RANK() OVER (ORDER BY AVG(labor_hours) DESC) as labor_hours_rank FROM project GROUP BY region HAVING labor_hours_rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (id INT, name TEXT, age INT, state TEXT); INSERT INTO community_health_workers (id, name, age, state) VALUES (1, 'John Doe', 35, 'Florida'); INSERT INTO community_health_workers (id, name, age, state) VALUES (2, 'Jane Smith', 40, 'Florida'); INSERT INTO community_health_workers (id... | What is the median age of community health workers in Florida? | SELECT AVG(age) FROM (SELECT age FROM community_health_workers WHERE state = 'Florida' ORDER BY age) AS subquery ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year_opened INT, total_employees INT); INSERT INTO mines (id, name, location, year_opened, total_employees) VALUES (1, 'Golden Ridge Mine', 'South Africa', 1992, 250); INSERT INTO mines (id, name, location, year_opened, total_employees) V... | What is the minimum labor productivity score for mines in South Africa? | SELECT MIN(labor_productivity.productivity_score) as min_productivity FROM labor_productivity JOIN mines ON labor_productivity.mine_id = mines.id WHERE mines.location = 'South Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO donors (id, name, country) VALUES (1, 'Ravi Sharma', 'India'), (2, 'Siti Nurhaliza', 'Malaysia'), (3, 'John Smith', 'USA'); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10, 2)); INSERT INTO donations ... | Which organizations received donations from donors residing in the Asia-Pacific region, and what are the total donation amounts for each organization? Join the donors, donations, and organizations tables. | SELECT o.name, SUM(donations.amount) as total_donation FROM donors d JOIN donations ON d.id = donations.donor_id JOIN organizations o ON donations.organization_id = o.id WHERE d.country LIKE 'Asia%' GROUP BY o.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE microfinance_loans (id INT, institution VARCHAR(255), country VARCHAR(255), loan_amount FLOAT); | What is the total loan amount disbursed to microfinance institutions in Africa? | SELECT SUM(loan_amount) FROM microfinance_loans WHERE country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, Membership VARCHAR(20)); CREATE TABLE Steps (StepID INT, MemberID INT, Steps INT, Date DATE); INSERT INTO Members (MemberID, Name, Age, Membership) VALUES (1, 'John Doe', 35, 'Platinum'), (2, 'Jane Smith', 28, 'Gold'), (3, 'Mike Johnson', 22, 'Silver'); INS... | What is the average daily step count for all members with a Gold membership in the last week? | SELECT AVG(Steps) FROM Members JOIN Steps ON Members.MemberID = Steps.MemberID WHERE Membership = 'Gold' AND Date >= DATEADD(DAY, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE lolgames (game_id INT, champion VARCHAR(50), deaths INT); INSERT INTO lolgames (game_id, champion, deaths) VALUES (1, 'Ashe', 4); | Determine the average deaths per match by champion in LoL | SELECT champion, AVG(deaths) as avg_deaths_per_match, RANK() OVER (ORDER BY AVG(deaths) DESC) as rank FROM lolgames GROUP BY champion | gretelai_synthetic_text_to_sql |
CREATE TABLE Communities (id INT, community_type VARCHAR(30)); INSERT INTO Communities (id, community_type) VALUES (1, 'Indigenous'), (2, 'Settler'), (3, 'Immigrant'), (4, 'Asian'); CREATE TABLE OnsiteEngagement (id INT, visitor_id INT, community_id INT, year INT); INSERT INTO OnsiteEngagement (id, visitor_id, communit... | What is the total number of visitors from Asian communities who engaged with on-site exhibits in 2021? | SELECT COUNT(DISTINCT OnsiteEngagement.visitor_id) FROM OnsiteEngagement INNER JOIN Communities ON OnsiteEngagement.community_id = Communities.id WHERE Communities.community_type = 'Asian' AND OnsiteEngagement.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (id INT, name TEXT); CREATE TABLE mine (id INT, name TEXT, region_id INT, depth INT); INSERT INTO region (id, name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); INSERT INTO mine (id, name, region_id, depth) VALUES (1, 'Gold Mine 1', 1, 1000), (2, 'Copper Mine 2', 1, 1500), (3, 'Iron Min... | What is the average depth of the mines in the region? | SELECT region.name, AVG(mine.depth) AS avg_depth FROM region JOIN mine ON region.id = mine.region_id GROUP BY region.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (id INT, name VARCHAR(255)); CREATE TABLE players (id INT, name VARCHAR(255), jersey_number INT, team_id INT); INSERT INTO teams (id, name) VALUES (3, 'Los Angeles Lakers'); | Insert a new player 'Lebron James' with jersey number 6 for the 'Los Angeles Lakers' | INSERT INTO players (id, name, jersey_number, team_id) VALUES (4, 'Lebron James', 6, 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_actors (id INT PRIMARY KEY, name VARCHAR(50), target_sector VARCHAR(50), success_count INT); INSERT INTO threat_actors (id, name, target_sector, success_count) VALUES (1, 'APT28', 'Finance', 15), (2, 'APT33', 'Finance', 10), (3, 'Magecart', 'Finance', 20); | Identify the top 3 threat actors with the most successful attacks against financial institutions in the past year, along with the number of successful attacks. | SELECT name, success_count FROM threat_actors WHERE target_sector = 'Finance' ORDER BY success_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE PB_Usage (id INT, system_type VARCHAR(20), country VARCHAR(50), daily_ridership INT); INSERT INTO PB_Usage (id, system_type, country, daily_ridership) VALUES (1, 'Melbourne Bike Share', 'Australia', 5000), (2, 'Brisbane CityCycle', 'Australia', 4000), (3, 'Adelaide Free Bikes', 'Australia', 3000); | What is the average daily ridership of public bicycles in Australia? | SELECT AVG(daily_ridership) as avg_daily_ridership FROM PB_Usage WHERE country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities.building_data (city VARCHAR(255), energy_consumption FLOAT); | What is the average energy consumption of buildings in the 'smart_cities' schema, grouped by city? | SELECT city, AVG(energy_consumption) FROM smart_cities.building_data GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (investment_id INT, investment_amount FLOAT, investment_date DATE, location TEXT); INSERT INTO network_investments (investment_id, investment_amount, investment_date, location) VALUES (1, 300000, '2022-01-10', 'Bogota'); INSERT INTO network_investments (investment_id, investment_amount,... | List all network investments made in the Latin American region in the past 6 months, including the investment amount and location. | SELECT * FROM network_investments WHERE investment_date >= DATEADD(month, -6, CURRENT_DATE) AND location LIKE 'Latin%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonorType VARCHAR(20), DonationAmount NUMERIC(12,2)); INSERT INTO Donations (DonorType, DonationAmount) VALUES ('Individual', 1500.00), ('Corporate', 5000.00), ('Foundation', 3000.00); | What is the total donation amount by donor type? | SELECT DonorType, SUM(DonationAmount) FROM Donations GROUP BY DonorType; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donation_date DATE, amount DECIMAL(10,2), city VARCHAR(50), state VARCHAR(50)); INSERT INTO donations (donor_id, donation_date, amount, city, state) VALUES (1, '2021-01-01', 50.00, 'Los Angeles', 'California'), (2, '2021-01-15', 100.00, 'San Francisco', 'California'), (1, '2021-03-... | What is the total amount donated and number of volunteers for each city in the state of California? | SELECT city, SUM(amount) AS total_donated, COUNT(*) AS num_volunteers FROM (SELECT 'donation' AS type, city, state, amount FROM donations WHERE state = 'California' UNION ALL SELECT 'volunteer' AS type, city, state, 0 AS amount FROM volunteers WHERE state = 'California') AS data GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClinicalTrials (trial_id INT, drug_name VARCHAR(255), trial_status VARCHAR(255)); INSERT INTO ClinicalTrials (trial_id, drug_name, trial_status) VALUES (1, 'DrugG', 'Completed'), (2, 'DrugG', 'Failed'), (3, 'DrugH', 'Failed'), (4, 'DrugI', 'Failed'), (5, 'DrugJ', 'Completed'), (6, 'DrugJ', 'Completed'); | Which drugs were tested in clinical trials and failed, grouped by the number of failures? | SELECT drug_name, COUNT(*) as failure_count FROM ClinicalTrials WHERE trial_status = 'Failed' GROUP BY drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE canada_institutions (institution_id INT, institution_name TEXT); CREATE TABLE loans_canada (loan_id INT, institution_id INT, loan_amount FLOAT, is_socially_responsible BOOLEAN); | What is the total value of socially responsible loans disbursed by financial institutions in Canada? | SELECT SUM(loans_canada.loan_amount) FROM loans_canada JOIN canada_institutions ON loans_canada.institution_id = canada_institutions.institution_id WHERE loans_canada.is_socially_responsible = TRUE AND canada_institutions.institution_id IN (SELECT loans_canada.institution_id FROM loans_canada JOIN canada_institutions O... | gretelai_synthetic_text_to_sql |
CREATE TABLE otas (ota_id INT, ota_name TEXT, booking_date DATE); INSERT INTO otas (ota_id, ota_name, booking_date) VALUES (1, 'OTA Europe', '2022-03-25'), (2, 'OTA Latam', '2022-03-28'), (3, 'OTA Europe', '2022-01-12'); | Number of OTA bookings in 'Europe' in Q1 2022? | SELECT COUNT(*) FROM otas WHERE booking_date >= '2022-01-01' AND booking_date < '2022-04-01' AND ota_name IN (SELECT ota_name FROM otas WHERE ota_name LIKE '%Europe%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_history (id INT, name VARCHAR(50), position VARCHAR(50), start_date DATE); | List the names of all employees who have worked for more than 5 years? | SELECT name FROM employee_history WHERE DATEDIFF(CURRENT_DATE, start_date) > (5 * 365); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_observations (id INT, country VARCHAR(30), species VARCHAR(50), date DATE); INSERT INTO marine_species_observations (id, country, species, date) VALUES (1, 'Indonesia', 'Clownfish', '2021-03-11'); INSERT INTO marine_species_observations (id, country, species, date) VALUES (2, 'Australia', 'B... | Identify the top 3 countries with the most marine species observed in their waters. | SELECT country, COUNT(*) AS total_species FROM marine_species_observations GROUP BY country ORDER BY total_species DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menus (menu_id INT, dish_name VARCHAR(255), is_gluten_free BOOLEAN); INSERT INTO Menus (menu_id, dish_name, is_gluten_free) VALUES (1, 'Spaghetti', false), (2, 'Gluten-Free Pasta', true), (3, 'Chicken Parmesan', false), (4, 'Salmon', true), (5, 'Risotto', false); | What is the percentage of dishes that are gluten-free? | SELECT (COUNT(*) FILTER (WHERE is_gluten_free = true)) * 100.0 / COUNT(*) FROM Menus; | gretelai_synthetic_text_to_sql |
CREATE TABLE destinations (name VARCHAR(255), country VARCHAR(255), continent VARCHAR(255), sustainable_certification BOOLEAN); INSERT INTO destinations (name, country, continent, sustainable_certification) VALUES ('City G', 'Country G', 'Asia', TRUE), ('City H', 'Country H', 'Asia', FALSE), ('City I', 'Country I', 'As... | Find the percentage of destinations in Asia with sustainable tourism certifications | SELECT (COUNT(*) / (SELECT COUNT(*) FROM destinations WHERE continent = 'Asia') * 100) AS percentage FROM destinations WHERE continent = 'Asia' AND sustainable_certification = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE material_production_samerica (material_id INT, material_name VARCHAR(50), production_date DATE, production_cost DECIMAL(10,2)); INSERT INTO material_production_samerica (material_id, material_name, production_date, production_cost) VALUES (1, 'Organic Cotton', '2021-08-05', 500.00), (2, 'Recycled Polyester... | What is the total production cost of sustainable materials in South America in the last year? | SELECT SUM(production_cost) FROM material_production_samerica WHERE material_name IN ('Organic Cotton', 'Recycled Polyester', 'Hemp') AND production_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_healthcare (id INT, issue VARCHAR(255)); INSERT INTO urban_healthcare (id, issue) VALUES (1, 'Lack of medical specialists'); INSERT INTO urban_healthcare (id, issue) VALUES (2, 'Long waiting times'); CREATE TABLE rural_healthcare (id INT, issue VARCHAR(255)); INSERT INTO rural_healthcare (id, issue) ... | What are the total number of healthcare access issues reported in urban and rural areas? | SELECT COUNT(*) FROM urban_healthcare UNION ALL SELECT COUNT(*) FROM rural_healthcare; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, state VARCHAR(2), billing_amount DECIMAL(10,2)); | What is the average billing amount for cases in California? | SELECT AVG(billing_amount) FROM cases WHERE state = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, program_id INT, amount DECIMAL(10, 2)); INSERT INTO donations (id, program_id, amount) VALUES (1, 1, 250.00), (2, 1, 500.00), (3, 2, 1000.00), (4, 2, 300.00), (5, 3, 750.00); CREATE TABLE programs (id INT, name TEXT); INSERT INTO programs (id, name) VALUES (1, 'Feeding the Hungry'), (2, ... | Calculate the total donations for each program, ordered by the total donation amount in descending order. | SELECT programs.id, programs.name, SUM(donations.amount) AS total_donations FROM donations INNER JOIN programs ON donations.program_id = programs.id GROUP BY programs.id, programs.name ORDER BY total_donations DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation (id INT, project_name TEXT, budget INT, start_year INT, location TEXT); INSERT INTO climate_mitigation (id, project_name, budget, start_year, location) VALUES (1, 'Tree Planting', 50000, 2016, 'Africa'); INSERT INTO climate_mitigation (id, project_name, budget, start_year, location) VALU... | What is the average budget of climate mitigation projects in Africa that were implemented after 2015? | SELECT AVG(budget) FROM climate_mitigation WHERE location = 'Africa' AND start_year > 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiations (id INT, contractor_id INT, negotiation_date DATE, amount DECIMAL(10,2)); INSERT INTO contract_negotiations (id, contractor_id, negotiation_date, amount) VALUES (2, 2, '2021-07-16', 2000000.00); | What are the contract negotiations with French companies? | SELECT * FROM contract_negotiations WHERE contractor_id IN (SELECT id FROM contractors WHERE country = 'France'); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_conservation_initiatives (id INT, initiative_name VARCHAR(255), launch_year INT, location VARCHAR(255)); INSERT INTO marine_conservation_initiatives (id, initiative_name, launch_year, location) VALUES (1, 'Initiative 1', 2012, 'Africa'), (2, 'Initiative 2', 2015, 'Asia'), (3, 'Initiative 3', 2018, '... | How many marine conservation initiatives were launched in Africa in the last decade? | SELECT COUNT(*) FROM marine_conservation_initiatives WHERE launch_year >= YEAR(CURRENT_DATE) - 10 AND location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE businesses (id INT, name VARCHAR(255), city VARCHAR(255), category VARCHAR(255), supported BOOLEAN); INSERT INTO businesses (id, name, city, category, supported) VALUES (1, 'Eco-Friendly Cafe', 'New York', 'Food', TRUE), (2, 'Sustainable Clothing Store', 'New York', 'Retail', TRUE); | How many local businesses have benefited from the 'Support Local' program in New York? | SELECT COUNT(*) FROM businesses WHERE city = 'New York' AND supported = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_insecurity (id INT, zip TEXT, cases INT, date DATE); INSERT INTO food_insecurity (id, zip, cases, date) VALUES (1, '12345', 100, '2020-01-01'), (2, '67890', 120, '2020-01-02'); | Identify the top 5 ZIP codes with the highest number of reported food insecurity cases, partitioned by month? | SELECT zip, SUM(cases) OVER (PARTITION BY EXTRACT(MONTH FROM date)) as monthly_cases, DENSE_RANK() OVER (ORDER BY SUM(cases) DESC) as rank FROM food_insecurity WHERE EXTRACT(YEAR FROM date) = 2020 GROUP BY zip, EXTRACT(MONTH FROM date) ORDER BY monthly_cases DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_water_consumption (operation TEXT, date DATE, consumption FLOAT); INSERT INTO daily_water_consumption (operation, date, consumption) VALUES ('Operation A', '2021-01-01', 5000), ('Operation B', '2021-01-01', 6000), ('Operation A', '2021-01-02', 5500), ('Operation B', '2021-01-02', 6500); | What is the daily water consumption of the mining operation with the lowest daily water consumption? | SELECT operation, MIN(consumption) FROM daily_water_consumption GROUP BY operation; | gretelai_synthetic_text_to_sql |
CREATE TABLE designers (designer_id INT, designer_name VARCHAR(255));CREATE TABLE garments (garment_id INT, garment_name VARCHAR(255), designer_id INT, price DECIMAL(10,2), size VARCHAR(10)); | Which designers have the highest and lowest average garment prices for plus-size clothing? | SELECT d.designer_name, AVG(g.price) AS avg_price FROM garments g JOIN designers d ON g.designer_id = d.designer_id WHERE g.size = 'plus-size' GROUP BY d.designer_name ORDER BY avg_price DESC, d.designer_name ASC LIMIT 1; SELECT d.designer_name, AVG(g.price) AS avg_price FROM garments g JOIN designers d ON g.designer_... | gretelai_synthetic_text_to_sql |
CREATE TABLE talk_shows (id INT, title VARCHAR(255), year INT, average_viewership INT); INSERT INTO talk_shows (id, title, year, average_viewership) VALUES (1, 'The Late Show with Stephen Colbert', 2021, 3200000), (2, 'The Tonight Show Starring Jimmy Fallon', 2021, 2800000); | What's the average viewership of late-night talk shows in 2021? | SELECT AVG(average_viewership) FROM talk_shows WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists cities (city_id INT, name TEXT, country TEXT); INSERT INTO cities (city_id, name, country) VALUES (1, 'Sydney', 'Australia'); CREATE TABLE if not exists visit_logs (log_id INT, visitor_id INT, city_id INT, visit_date DATE); INSERT INTO visit_logs (log_id, visitor_id, city_id, visit_date) VALU... | What is the maximum number of visitors in a day for Sydney, Australia, in the last 6 months? | SELECT MAX(visits_per_day) FROM (SELECT visit_date, COUNT(DISTINCT visitor_id) AS visits_per_day FROM visit_logs JOIN cities ON visit_logs.city_id = cities.city_id WHERE cities.name = 'Sydney' AND visit_date >= (CURRENT_DATE - INTERVAL '6 months') GROUP BY visit_date) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE gold_mine (site_id INT, country VARCHAR(50), num_employees INT); INSERT INTO gold_mine (site_id, country, num_employees) VALUES (1, 'Canada', 60), (2, 'USA', 75), (3, 'Mexico', 40), (4, 'Canada', 80), (5, 'USA', 35); | What is the average productivity of workers per mining site, grouped by country, for gold mines that have more than 50 employees? | SELECT country, AVG(productivity) as avg_productivity FROM gold_mine WHERE num_employees > 50 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE japan_cities (name TEXT, population INTEGER); INSERT INTO japan_cities (name, population) VALUES ('Tokyo', 37400068), ('Yokohama', 3668000); | Which cities in Japan have populations over 2 million, and what are their populations? | SELECT name, population FROM japan_cities WHERE population > 2000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE affordable_housing (id INT, property_price FLOAT, size INT); INSERT INTO affordable_housing (id, property_price, size) VALUES (1, 300000, 200), (2, 250000, 180), (3, 350000, 250), (4, 200000, 150); | Find the top 3 largest properties by size in the affordable_housing table. | SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY size DESC) as rn FROM affordable_housing) as t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), policyholder_state VARCHAR(20)); INSERT INTO claims (policyholder_id, claim_amount, policyholder_state) VALUES (1, 500.00, 'California'), (2, 300.00, 'California'); | What is the total claim amount paid to policyholders from 'California'? | SELECT SUM(claim_amount) FROM claims WHERE policyholder_state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS endangered_animals (animal_id INT, animal_name VARCHAR(50), conservation_status VARCHAR(20)); INSERT INTO endangered_animals (animal_id, animal_name, conservation_status) VALUES (1, 'Amur Leopard', 'Critically Endangered'); INSERT INTO endangered_animals (animal_id, animal_name, conservation_... | Which endangered animals have been introduced to new habitats through conservation efforts? | SELECT animal_name FROM endangered_animals e JOIN introductions i ON e.animal_id = i.animal_id JOIN habitats h ON i.habitat_id = h.habitat_id WHERE conservation_status = 'Critically Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RnD (company TEXT, year INTEGER, expenditure INTEGER); INSERT INTO RnD (company, year, expenditure) VALUES ('PharmaCorp', 2022, 8000000); | What is the average R&D expenditure for 'PharmaCorp' in '2022'? | SELECT AVG(expenditure) FROM RnD WHERE company = 'PharmaCorp' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, location VARCHAR(50), followers INT); CREATE TABLE following (user_id INT, following_id INT); | What is the maximum number of followers for users in the 'social_media' database who are female? | SELECT MAX(users.followers) AS max_followers FROM users WHERE users.gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Disease (Name TEXT, Region TEXT, Cases INT); INSERT INTO Disease (Name, Region, Cases) VALUES ('Flu', 'North America', 12500); INSERT INTO Disease (Name, Region, Cases) VALUES ('Malaria', 'Africa', 25000); | What is the total number of flu cases reported in Europe? | SELECT SUM(Cases) FROM Disease WHERE Name = 'Flu' AND Region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Machinery (MachineryID INT, Type VARCHAR(50), Age INT, CO2Emission INT); INSERT INTO Machinery (MachineryID, Type, Age, CO2Emission) VALUES (1, 'Excavator', 8, 50); INSERT INTO Machinery (MachineryID, Type, Age, CO2Emission) VALUES (2, 'Dumper', 12, 70); INSERT INTO Machinery (MachineryID, Type, Age, CO2Em... | What is the total CO2 emission of all Machinery that is older than 10 years? | SELECT SUM(CO2Emission) as TotalCO2Emission FROM Machinery WHERE Age > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Electric_Vehicles (Id INT, Name VARCHAR(50), Horsepower INT, Origin_Country VARCHAR(50)); INSERT INTO Electric_Vehicles (Id, Name, Horsepower, Origin_Country) VALUES (1, 'Model S', 417, 'USA'), (2, 'Model 3', 261, 'USA'), (3, 'e-Tron', 355, 'Germany'); | What is the average horsepower of electric vehicles released in the USA since 2018? | SELECT AVG(Horsepower) FROM Electric_Vehicles WHERE Origin_Country = 'USA' AND YEAR(Release_Date) >= 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours(id INT, name TEXT, country TEXT, duration INT); INSERT INTO virtual_tours (id, name, country, duration) VALUES (1, 'Tokyo Sky Tree Virtual Tour', 'Japan', 60), (2, 'Paris Virtual Tour', 'France', 90); | What is the maximum duration of a virtual tour? | SELECT MAX(duration) FROM virtual_tours; | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), num_workers INT, wage DECIMAL(5,2)); CREATE TABLE Products (product_id INT, name VARCHAR(100), factory_id INT); INSERT INTO Factories VALUES (1,'Factory X','Los Angeles',100,15.00),(2,'Factory Y','Jakarta',250,5.00),(3,'Factory Z','Rome',... | What is the minimum wage in factories that produce the most ethical denim jeans? | SELECT MIN(Factories.wage) FROM Factories JOIN Products ON Factories.factory_id = Products.factory_id WHERE Products.name = 'Eco Denim Jeans'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_name VARCHAR(255), price DECIMAL(5,2)); | Insert a new record into the menu_items table for item_name 'Tofu Stir Fry' with price set to 11.99 | INSERT INTO menu_items (item_name, price) VALUES ('Tofu Stir Fry', 11.99); | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, Title VARCHAR(50), ReleaseYear INT, Genre VARCHAR(20), VR BOOLEAN); INSERT INTO Games (GameID, Title, ReleaseYear, Genre, VR) VALUES (1, 'Star Shooter', 2017, 'Action', true); INSERT INTO Games (GameID, Title, ReleaseYear, Genre, VR) VALUES (2, 'Galactic Explorer', 2018, 'Adventure', tru... | How many VR games were released per year? | SELECT ReleaseYear, COUNT(*) FROM Games WHERE VR = true GROUP BY ReleaseYear; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(50), country VARCHAR(50), launch_date DATE, max_altitude INT); | Determine the maximum altitude reached by a spacecraft from the USA | SELECT MAX(max_altitude) FROM spacecraft WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(255), conservation_status VARCHAR(255), depth FLOAT); INSERT INTO marine_species (id, name, conservation_status, depth) VALUES (1, 'Pacific salmon', 'Vulnerable', 50.0), (2, 'Blue whale', 'Endangered', 500.0), (3, 'Sea anemone', 'Least Concern', 0.01); | What is the average depth of all marine species in the 'marine_species' table, grouped by conservation_status? | SELECT conservation_status, AVG(depth) AS avg_depth FROM marine_species GROUP BY conservation_status; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT, total_waste_kg INT); INSERT INTO districts (district_id, district_name, total_waste_kg) VALUES (1, 'District A', 5000), (2, 'District B', 7000), (3, 'District C', 6000); | What is the total waste generation in kg for the year 2020 across all districts? | SELECT SUM(total_waste_kg) FROM districts WHERE YEAR(districts.date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE CharityEvents (ID INT, EventName VARCHAR(255), EventDate DATE, Attendees INT, EventCause VARCHAR(255)); CREATE TABLE Donations (ID INT, EventID INT, Donor VARCHAR(255), Donation DECIMAL(10,2)); | What is the correlation between the number of attendees and the average donation per attendee for charity fundraising events in the last 12 months, organized by cause? | SELECT e.EventCause, AVG(d.Donation) as AverageDonation, COUNT(e.Attendees) as AttendeesCount, AVG(d.Donation) * COUNT(e.Attendees) as Correlation FROM CharityEvents e JOIN Donations d ON e.ID = d.EventID WHERE e.EventDate >= DATEADD(month, -12, GETDATE()) GROUP BY e.EventCause; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlanetaryTemperature (id INT, planet VARCHAR(50), temperature FLOAT); INSERT INTO PlanetaryTemperature (id, planet, temperature) VALUES (1, 'Uranus', -224); | What is the minimum temperature ever recorded on Uranus? | SELECT MIN(temperature) FROM PlanetaryTemperature WHERE planet = 'Uranus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites(launch_country VARCHAR(255), launch_company VARCHAR(255), launch_date DATE); | Which countries have the highest number of satellite launches in the last decade, and what companies were responsible for these launches? | SELECT launch_country, launch_company, COUNT(*) as Total FROM satellites WHERE launch_date >= DATE_SUB(CURDATE(), INTERVAL 10 YEAR) GROUP BY launch_country, launch_company ORDER BY Total DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program TEXT, volunteer_year INT, volunteer_hours INT); | What is the year-over-year change in the number of volunteers for each program, sorted by the largest positive change? | SELECT program, volunteer_year, (LAG(volunteer_hours, 1) OVER (PARTITION BY program ORDER BY volunteer_year) - volunteer_hours) as year_over_year_change FROM volunteers ORDER BY year_over_year_change DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExplainableAI (model_name TEXT, confidence FLOAT, country TEXT); INSERT INTO ExplainableAI (model_name, confidence, country) VALUES ('ModelA', 0.85, 'Antarctica'); | How many explainable AI models have been developed in Antarctica? | SELECT COUNT(*) FROM ExplainableAI WHERE country = 'Antarctica'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndigenousCommunities (id INT, name VARCHAR(50), region VARCHAR(50), population INT); INSERT INTO IndigenousCommunities (id, name, region, population) VALUES (1, 'Community A', 'Arctic', 500); INSERT INTO IndigenousCommunities (id, name, region, population) VALUES (2, 'Community B', 'Arctic', 700); INSERT ... | What is the minimum population for each indigenous community in the Arctic region and how many communities are there in total? | SELECT region, MIN(population), COUNT(name) FROM IndigenousCommunities GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE residential_buildings (id INT, city TEXT, year INT, efficiency FLOAT); INSERT INTO residential_buildings (id, city, year, efficiency) VALUES (1, 'Building A', 2015, 80.7), (2, 'Building B', 2005, 50.2); | What is the average energy efficiency (in kWh/m2) of residential buildings in 'Mumbai' that were constructed after 2010? | SELECT AVG(efficiency) FROM residential_buildings WHERE city = 'Mumbai' AND year > 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_2 (sale_id INT, product VARCHAR(20), category VARCHAR(20), customer VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO sales_2 (sale_id, product, category, customer, revenue) VALUES (1, 'Software', 'Technology', 'John Smith', 5000.00), (2, 'Laptop', 'Technology', 'Jane Smith', 3000.00), (3, 'Consulting... | What is the total revenue per customer by product category? | SELECT customer, category, SUM(revenue) as total_revenue FROM sales_2 GROUP BY customer, category; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_moisture (date DATE, moisture_level INT); INSERT INTO soil_moisture (date, moisture_level) VALUES ('2021-05-01', 60), ('2021-05-02', 65), ('2021-05-03', 70), ('2021-05-04', 75), ('2021-05-05', 80), ('2021-05-06', 85), ('2021-05-07', 90); | What is the average soil moisture level in the past 3 days? | SELECT AVG(moisture_level) FROM soil_moisture WHERE date >= DATE_SUB(CURDATE(), INTERVAL 3 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE missions (mission_id INT, name VARCHAR(50), space_agency VARCHAR(50), mission_status VARCHAR(10)); | What is the success rate of missions for each space agency? | SELECT space_agency, COUNT(*) FILTER (WHERE mission_status = 'successful') * 100.0 / COUNT(*) AS success_rate FROM missions GROUP BY space_agency; | gretelai_synthetic_text_to_sql |
CREATE TABLE MakeupIngredients (product_id INT, product_name VARCHAR(100), ingredient TEXT, country VARCHAR(50)); INSERT INTO MakeupIngredients VALUES (101, 'Liquid Foundation', 'Aqua, Glycerin, Mica, Iron Oxides', 'UK'), (102, 'Mascara', 'Aqua, Stearic Acid, Kaolin, Iron Oxides', 'UK'), (103, 'Eyeshadow Palette', 'Tal... | List all makeup products with vegan ingredients sold in the UK. | SELECT product_id, product_name FROM MakeupIngredients WHERE country = 'UK' AND ingredient LIKE '%vegan%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA agroecology;CREATE TABLE organic_farms (id INT, name VARCHAR(50), area_ha FLOAT);INSERT INTO agroecology.organic_farms (id, name, area_ha) VALUES (1, 'Farm A', 50.3), (2, 'Farm B', 75.8); | What is the total area (in hectares) of farmland dedicated to organic crops in the 'agroecology' schema? | SELECT SUM(area_ha) FROM agroecology.organic_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_client_data (month_id INT PRIMARY KEY, attorney_id INT, total_clients INT, month DATE); | What is the maximum number of clients an attorney has had in a month? | SELECT attorney_id, MAX(total_clients) FROM monthly_client_data GROUP BY attorney_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE judges (id INT, first_name VARCHAR(20), last_name VARCHAR(20), court_id INT); INSERT INTO judges (id, first_name, last_name, court_id) VALUES (4, 'Fatima', 'Adebayo', 3); CREATE TABLE courts (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO courts (id, name, location) VALUES (3, 'High Court of ... | Change the court id from 3 to 4 for judge with id 4 | UPDATE judges SET court_id = 4 WHERE id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT PRIMARY KEY, name VARCHAR(255), ethnicity VARCHAR(255)); INSERT INTO authors (id, name, ethnicity) VALUES (1, 'Kevin Kwan', 'Asian'); INSERT INTO authors (id, name, ethnicity) VALUES (2, 'Celeste Ng', 'Asian'); CREATE TABLE books (id INT PRIMARY KEY, title VARCHAR(255), author_id INT, publi... | List the names and genres of Asian authors who have published at least one award-winning book. | SELECT a.name, g.genre FROM authors a INNER JOIN books b ON a.id = b.author_id INNER JOIN genres g ON b.genre = g.genre WHERE a.ethnicity = 'Asian' AND b.award = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions_4 (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_type VARCHAR(10), transaction_date DATE, customer_region VARCHAR(20)); INSERT INTO customer_transactions_4 (transaction_id, customer_id, transaction_value, transaction_type, transaction_date, custome... | Find the daily net transaction amount (total transaction value - total withdrawal value) for the past month, grouped by day and ordered by day in descending order for customers in Oceania? | SELECT customer_region, transaction_date, SUM(CASE WHEN transaction_type = 'deposit' THEN transaction_value ELSE -transaction_value END) as daily_net_transaction_amount FROM customer_transactions_4 WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) AND CURRENT_DATE AND customer_region = 'Oceania' GR... | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, signup_date DATE); INSERT INTO volunteers (volunteer_id, signup_date) VALUES (1, '2022-01-05'), (2, '2022-03-30'), (3, '2022-04-15'), (4, '2022-06-10'); | Insert a new volunteer with ID 6 who signed up on 2022-07-15 | INSERT INTO volunteers (volunteer_id, signup_date) VALUES (6, '2022-07-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (launch_year INT, launch_company VARCHAR(50), num_satellites INT); INSERT INTO satellites (launch_year, launch_company, num_satellites) VALUES (2018, 'SpaceX', 200), (2019, 'OneWeb', 300), (2020, 'SpaceX', 600), (2021, 'OneWeb', 400); | What are the total number of satellites launched by each company? | SELECT launch_company, SUM(num_satellites) as total_satellites FROM satellites GROUP BY launch_company ORDER BY total_satellites DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, rating) VALUES (1, 'Hotel A', 'Germany', 4.6), (2, 'Hotel B', 'Germany', 4.4), (3, 'Hotel C', 'Germany', 4.7); | List the hotels in Germany with a rating above 4.5. | SELECT hotel_name FROM hotels WHERE country = 'Germany' AND rating > 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE StreamingData (StreamID INT, SongID INT, StreamDate DATE, Genre VARCHAR(50), SongName VARCHAR(100), StreamCount INT); INSERT INTO StreamingData (StreamID, SongID, StreamDate, Genre, SongName, StreamCount) VALUES (3, 3, '2022-02-01', 'Rock', 'Bohemian Rhapsody', 200); INSERT INTO StreamingData (StreamID, So... | How many streams did the song 'Bohemian Rhapsody' get? | SELECT SUM(StreamCount) FROM StreamingData WHERE SongName = 'Bohemian Rhapsody'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (id INT, name VARCHAR(50), state VARCHAR(50), length FLOAT); INSERT INTO bridges (id, name, state, length) VALUES (1, 'Bridge A', 'Florida', 700.00), (2, 'Bridge B', 'Florida', 500.33), (3, 'Bridge C', 'Texas', 800.00); | What is the maximum bridge length in Florida? | SELECT MAX(length) FROM bridges WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE la_districts (id INT, district_name VARCHAR(255));CREATE TABLE crimes (id INT, district_id INT, crime_date DATE);INSERT INTO la_districts (id, district_name) VALUES (1, 'Hollywood'), (2, 'Downtown'), (3, 'Venice');INSERT INTO crimes (id, district_id, crime_date) VALUES (1, 1, '2022-03-01'), (2, 1, '2022-03... | How many crimes were committed in the last 30 days in each district in Los Angeles? | SELECT d.district_name, COUNT(c.id) crimes_in_last_30_days FROM la_districts d JOIN crimes c ON d.id = c.district_id WHERE c.crime_date >= CURDATE() - INTERVAL 30 DAY GROUP BY d.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Product (ProductID INT, ProductName VARCHAR(50), IsSustainable BOOLEAN); INSERT INTO Product (ProductID, ProductName, IsSustainable) VALUES (101, 'Organic Lipstick', TRUE), (102, 'Natural Mascara', FALSE), (103, 'Vegan Foundation', TRUE); | Insert a new sustainable cosmetic product into the database. | INSERT INTO Product (ProductID, ProductName, IsSustainable) VALUES (104, 'Eco-Friendly Blush', TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, category VARCHAR(20), billing_amount DECIMAL(5,2)); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Criminal Law', 1500.00), (2, 'Civil Law', 3000.00); | What is the maximum billing amount for cases in the 'Civil Law' category? | SELECT MAX(billing_amount) FROM cases WHERE category = 'Civil Law'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_hospitals (hospital_id INT, hospital_name VARCHAR(100), country VARCHAR(50), num_beds INT); INSERT INTO rural_hospitals (hospital_id, hospital_name, country, num_beds) VALUES (1, 'Hospital A', 'Nigeria', 150), (2, 'Hospital B', 'Nigeria', 120), (3, 'Hospital C', 'South Africa', 80), (4, 'Hospital D',... | What is the total number of rural hospitals in Africa and how many of these hospitals have more than 100 beds? | SELECT COUNT(*) AS total_rural_hospitals, COUNT(*) FILTER (WHERE num_beds > 100) AS hospitals_with_more_than_100_beds FROM rural_hospitals WHERE country IN (SELECT name FROM countries WHERE continent = 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_spending (spending_id INT, amount FLOAT, state VARCHAR(50), spend_date DATE); INSERT INTO construction_spending (spending_id, amount, state, spend_date) VALUES (11, 90000, 'New York', '2020-01-01'); INSERT INTO construction_spending (spending_id, amount, state, spend_date) VALUES (12, 110000, ... | What was the average construction spending per month in the state of New York in 2020? | SELECT EXTRACT(MONTH FROM spend_date) AS month, AVG(amount) AS avg_spending FROM construction_spending WHERE state = 'New York' AND YEAR(spend_date) = 2020 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT PRIMARY KEY, Name TEXT, MaxSpeed FLOAT); INSERT INTO Vessels (ID, Name, MaxSpeed) VALUES (1, 'Fishing Vessel 1', 18.5), (2, 'Cargo Ship 1', 22.3), (3, 'Tug Boat 1', 12.8); | What is the average speed of vessels that have a maximum speed greater than 20 knots? | SELECT AVG(MaxSpeed) FROM Vessels WHERE MaxSpeed > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE price_data (element VARCHAR(10), price DECIMAL(5,2)); INSERT INTO price_data VALUES ('Samarium', 18.50), ('Samarium', 19.10), ('Samarium', 17.90), ('Samarium', 18.80), ('Samarium', 19.30); | What is the minimum price of Samarium in the given dataset? | SELECT MIN(price) FROM price_data WHERE element = 'Samarium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (region VARCHAR(50), advisory_count INT); INSERT INTO travel_advisories (region, advisory_count) VALUES ('Asia Pacific', 120), ('Europe', 80), ('Americas', 150); | List all 'travel_advisories' issued for 'Europe' region and their respective advisory counts. | SELECT region, advisory_count FROM travel_advisories WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name TEXT, Birthplace TEXT); INSERT INTO Artists (ArtistID, Name, Birthplace) VALUES (1, 'Claude Monet', 'Paris, France'), (2, 'Jackson Pollock', 'Cody, Wyoming'), (3, 'Frida Kahlo', 'Coyoacán, Mexico'); CREATE TABLE Paintings (PaintingID INT, Title TEXT, ArtistID INT); INSERT INTO P... | What are the names and birthplaces of artists with more than 30 paintings in the 'Paintings' table? | SELECT Artists.Name, Artists.Birthplace FROM Artists INNER JOIN (SELECT ArtistID, COUNT(*) as PaintingCount FROM Paintings GROUP BY ArtistID) as PaintingCounts ON Artists.ArtistID = PaintingCounts.ArtistID WHERE PaintingCounts.PaintingCount > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, city VARCHAR(50), country VARCHAR(50)); INSERT INTO Warehouse (id, city, country) VALUES (1, 'Vancouver', 'Canada'), (2, 'Toronto', 'Canada'); CREATE TABLE Shipment (id INT, quantity INT, warehouse_id INT, destination_country VARCHAR(50)); INSERT INTO Shipment (id, quantity, warehouse_id... | How many items were shipped from each warehouse in Canada? | SELECT Warehouse.city, SUM(Shipment.quantity) FROM Warehouse INNER JOIN Shipment ON Warehouse.id = Shipment.warehouse_id WHERE Warehouse.country = 'Canada' GROUP BY Warehouse.city; | gretelai_synthetic_text_to_sql |
CREATE TABLE canada_data (user_id INT, age INT, data_usage FLOAT); INSERT INTO canada_data (user_id, age, data_usage) VALUES (1, 27, 3.9), (2, 32, 4.3), (3, 45, 3.5), (4, 38, 4.7), (5, 23, 3.2); | What is the average mobile data usage in Canada for users in the age range of 25-40? | SELECT AVG(data_usage) as avg_data_usage FROM canada_data WHERE age BETWEEN 25 AND 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE VisitorStatistics (id INT, country VARCHAR(50), year INT, visitors INT, PRIMARY KEY(id)); INSERT INTO VisitorStatistics (id, country, year, visitors) VALUES (1, 'CountryA', 2021, 10000), (2, 'CountryB', 2022, 15000), (3, 'CountryC', 2021, 12000), (4, 'CountryA', 2022, 11000), (5, 'CountryB', 2021, 14000); | Show the top 3 countries with the highest number of international visitors in 2021 and 2022. | SELECT country, SUM(visitors) AS total_visitors FROM VisitorStatistics WHERE year IN (2021, 2022) GROUP BY country ORDER BY total_visitors DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE TheaterZ (event_id INT, event_name VARCHAR(50), event_date DATE, program VARCHAR(50), revenue INT, grant_donation VARCHAR(50)); | What is the percentage of total revenue from grants and donations for each program offered at 'TheaterZ' in the past two years? | SELECT program, 100.0 * SUM(CASE WHEN grant_donation = 'grant' THEN revenue ELSE 0 END) / SUM(revenue) AS pct_grant_revenue, 100.0 * SUM(CASE WHEN grant_donation = 'donation' THEN revenue ELSE 0 END) / SUM(revenue) AS pct_donation_revenue FROM TheaterZ WHERE event_date >= DATEADD(year, -2, GETDATE()) GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, city VARCHAR(50), has_inclusive_policy BOOLEAN); INSERT INTO properties (property_id, city, has_inclusive_policy) VALUES (1, 'Portland', TRUE), (2, 'Seattle', FALSE), (3, 'Portland', FALSE); | List all properties in Portland with inclusive housing policies. | SELECT property_id, city FROM properties WHERE city = 'Portland' AND has_inclusive_policy = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name VARCHAR(255), raw_materials_cost DECIMAL(10, 2));CREATE TABLE raw_materials_invoices (id INT, factory_id INT, invoice_date DATE, cost DECIMAL(10, 2)); | Get the total amount spent on raw materials for each factory in the past month. | SELECT factories.name, SUM(raw_materials_invoices.cost) AS total_cost FROM factories INNER JOIN raw_materials_invoices ON factories.id = raw_materials_invoices.factory_id WHERE raw_materials_invoices.invoice_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY factories.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), manufacturer VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO military_equipment (id, name, type, manufacturer, year, country) VALUES (1, 'M1 Abrams', 'Tank', 'General Dynamics', 1980, 'USA'), (2, 'F-15 Eagle', 'Fighter... | Select all military equipment manufactured before 1985 | SELECT * FROM military_equipment WHERE year < 1985; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT, name VARCHAR(50), type VARCHAR(20), country VARCHAR(50), continent VARCHAR(20)); INSERT INTO Products (id, name, type, country, continent) VALUES (1, 'Cleanser', 'Skincare', 'Brazil', 'South America'), (2, 'Toner', 'Skincare', 'Canada', 'North America'), (3, 'Moisturizer', 'Skincare', 'Au... | Display the number of products sourced from each continent. | SELECT continent, COUNT(*) as product_count FROM Products GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (id INT, region VARCHAR(50), amount FLOAT, sale_date DATE); INSERT INTO MilitaryEquipmentSales (id, region, amount, sale_date) VALUES (1, 'North America', 15000000, '2022-07-10'); INSERT INTO MilitaryEquipmentSales (id, region, amount, sale_date) VALUES (2, 'Europe', 17000000, '2022-... | Calculate the total military equipment sales amount for each region in Q3 2022. | SELECT region, SUM(amount) FROM MilitaryEquipmentSales WHERE sale_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (org_name VARCHAR(255), mission_location VARCHAR(255)); | Which organizations have been involved in humanitarian assistance missions in Africa? | SELECT org_name FROM humanitarian_assistance WHERE mission_location LIKE '%Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, EventName VARCHAR(50), Budget DECIMAL(10, 2)); | What is the total number of events and total amount spent on each event, for events in the 'Events' table that have a budget greater than 5000? | SELECT EventID, EventName, COUNT(*) AS NumberOfEvents, SUM(Budget) AS TotalAmountSpent FROM Events WHERE Budget > 5000 GROUP BY EventID, EventName; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO hospitals (id, name, location, capacity) VALUES (1, 'Rural General Hospital', 'Springfield', 100); CREATE TABLE clinics (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO clinics (id, name, location, capacity) VALUES (1, 'Ru... | What is the total number of hospitals and clinics in the 'rural_healthcare' schema? | SELECT COUNT(*) FROM hospitals UNION SELECT COUNT(*) FROM clinics; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT PRIMARY KEY, restaurant_id INT, menu_item VARCHAR(255), vendor VARCHAR(255), product VARCHAR(255)); CREATE TABLE orders (order_id INT PRIMARY KEY, menu_item_id INT, order_date DATE); | Get menu items that are sourced from vendors with no certifications | SELECT m.menu_item, m.vendor FROM menu_items m LEFT JOIN sustainable_sources s ON m.vendor = s.vendor WHERE s.source_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (region VARCHAR(255), material VARCHAR(255), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (region, material, recycling_rate) VALUES ('North East', 'plastic', 0.35), ('North East', 'paper', 0.45); | Which recycling rates are higher: for plastic or for paper, in the 'North East' region? | SELECT material, recycling_rate FROM recycling_rates WHERE region = 'North East' AND material IN ('plastic', 'paper') INTERSECT SELECT 'paper' AS material, MAX(recycling_rate) FROM recycling_rates WHERE region = 'North East' UNION ALL SELECT 'plastic' AS material, MAX(recycling_rate) FROM recycling_rates WHERE region =... | 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.