context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE menu_items (menu_item_id INT, menu_category VARCHAR(255), item_name VARCHAR(255), is_sustainable BOOLEAN); CREATE TABLE orders (order_id INT, customer_id INT, menu_item_id INT, order_date DATE, order_price INT); | List the top 5 customers by spending on sustainable ingredients in the last 30 days? | SELECT c.customer_name, SUM(o.order_price) as total_spend FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.is_sustainable = TRUE AND o.order_date BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE() GROUP BY c.customer_name ORDER BY total_spen... | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_sales (restaurant_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO restaurant_sales (restaurant_id, sale_date, revenue) VALUES (1, '2022-01-01', 5000.00), (1, '2022-01-02', 6000.00), (2, '2022-01-01', 4000.00); | What was the total revenue for the month of January 2022 across all restaurants? | SELECT SUM(revenue) FROM restaurant_sales WHERE EXTRACT(MONTH FROM sale_date) = 1 AND EXTRACT(YEAR FROM sale_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE industrial_sectors (id INT, sector VARCHAR(255)); INSERT INTO industrial_sectors (id, sector) VALUES (1, 'Manufacturing'), (2, 'Mining'), (3, 'Construction'); CREATE TABLE water_consumption (year INT, sector_id INT, consumption INT); INSERT INTO water_consumption (year, sector_id, consumption) VALUES (2020... | What is the maximum water consumption by each industrial sector in 2021, if the consumption data is not available? | SELECT i.sector, MAX(COALESCE(w.consumption, 0)) as max_consumption FROM industrial_sectors i LEFT JOIN water_consumption w ON i.id = w.sector_id AND w.year = 2021 GROUP BY i.sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_pd (teacher_id INT, school_id INT, course_id INT, course_type VARCHAR(255)); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), course_type VARCHAR(255)); CREATE TABLE schools (school_id INT, school_name VARCHAR(255)); | What is the total number of professional development courses completed by teachers in each school, grouped by course type? | SELECT s.school_name, c.course_type, COUNT(DISTINCT t.teacher_id, t.course_id) as num_courses FROM teacher_pd t INNER JOIN schools s ON t.school_id = s.school_id INNER JOIN courses c ON t.course_id = c.course_id GROUP BY s.school_name, c.course_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name VARCHAR(50), country VARCHAR(50), sustainable BOOLEAN); INSERT INTO hotels (id, name, country, sustainable) VALUES (1, 'Eco Hotel', 'Japan', TRUE), (2, 'Green Hotel', 'USA', TRUE), (3, 'Classic Hotel', 'Japan', FALSE); CREATE TABLE hotel_awards (id INT, hotel_id INT, award VARCHAR(50))... | How many sustainable hotels are there in Japan and how many awards have they won in total? | SELECT COUNT(DISTINCT hotels.id), SUM(hotel_awards.count) FROM hotels JOIN (SELECT hotel_id, COUNT(*) AS count FROM hotel_awards GROUP BY hotel_id) AS hotel_awards ON hotels.id = hotel_awards.hotel_id WHERE hotels.country = 'Japan' AND hotels.sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyReview (policy_id INT, policy_name VARCHAR(50), policy_owner VARCHAR(50), last_reviewed DATETIME); | List the policy names and their corresponding policy owners for policies that have not been reviewed in the past 6 months, based on the PolicyReview table. | SELECT policy_name, policy_owner FROM PolicyReview WHERE last_reviewed < DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_ratings (id INT, title VARCHAR(255), release_year INT, genre VARCHAR(255), imdb_rating DECIMAL(3,2)); INSERT INTO movie_ratings (id, title, release_year, genre, imdb_rating) VALUES (1, 'Movie1', 2018, 'Action', 5.2), (2, 'Movie2', 2019, 'Comedy', 5.5), (3, 'Movie3', 2017, 'Drama', 6.0), (4, 'Movie4',... | Which movies have the lowest IMDb rating per genre, sorted by release year? | SELECT genre, title, release_year, MIN(imdb_rating) AS lowest_imdb_rating FROM movie_ratings GROUP BY genre ORDER BY release_year, lowest_imdb_rating; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (id INT, name VARCHAR, state VARCHAR, health_equity_score INT); INSERT INTO mental_health_facilities (id, name, state, health_equity_score) VALUES (1, 'Facility One', 'Texas', 75); INSERT INTO mental_health_facilities (id, name, state, health_equity_score) VALUES (2, 'Facility Two'... | What is the average health equity metric score for mental health facilities in Texas? | SELECT state, AVG(health_equity_score) as avg_score FROM mental_health_facilities WHERE state = 'Texas' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA Government;CREATE TABLE Government.State (name VARCHAR(255), population INT);CREATE TABLE Government.Library (name VARCHAR(255), state VARCHAR(255), budget INT); | What is the total budget allocated to public libraries in each state with a population greater than 5 million? | SELECT state, SUM(budget) FROM Government.Library WHERE state IN (SELECT name FROM Government.State WHERE population > 5000000) GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (id INT, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), is_eco_friendly BOOLEAN); INSERT INTO inventory (id, item_name, category, price, is_eco_friendly) VALUES (1, 'Straight Jeans', 'Bottoms', 59.99, true), (2, 'Skinny Jeans', 'Bottoms', 49.99, false); | Update the price of all eco-friendly jeans to $65.99. | UPDATE inventory SET price = 65.99 WHERE is_eco_friendly = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, cargo_weight INT, visit_date DATE, visit_port TEXT); | What is the total cargo weight carried by vessels that have visited the Port of Singapore in the last month, and what is the average cargo weight per vessel for these vessels? | SELECT AVG(cargo_weight), SUM(cargo_weight) FROM vessels WHERE visit_date >= DATEADD(month, -1, GETDATE()) AND visit_port = 'Singapore'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Gender varchar(50), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (1, 'John', 'Doe', 'IT', 'Male', 75000); INSERT INTO Employees (EmployeeID, F... | What is the number of employees by department and gender? | SELECT Department, Gender, COUNT(*) as TotalEmployees FROM Employees GROUP BY Department, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, vehicle_type VARCHAR(20), year INT, quantity INT); INSERT INTO sales (id, vehicle_type, year, quantity) VALUES (1, 'hybrid', 2018, 3000), (2, 'hybrid', 2019, 4500), (3, 'hybrid', 2020, 6000), (4, 'ev', 2018, 1000), (5, 'ev', 2019, 2000), (6, 'ev', 2020, 5000); | Find the total number of hybrid vehicles sold in 2020 | SELECT SUM(quantity) FROM sales WHERE vehicle_type = 'hybrid' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE asia_pacific_readers (id INT, age INT, country VARCHAR(255), news_preference VARCHAR(255)); INSERT INTO asia_pacific_readers (id, age, country, news_preference) VALUES (1, 35, 'Japan', 'sports'), (2, 45, 'Australia', 'politics'); | Find the average age of readers who prefer sports news in the Asia-Pacific region, grouped by their country. | SELECT r.country, AVG(r.age) FROM asia_pacific_readers r JOIN countries c ON r.country = c.country WHERE r.news_preference = 'sports' AND c.region = 'Asia-Pacific' GROUP BY r.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_agencies (id INT, agency_name VARCHAR(255), director_name VARCHAR(255)); INSERT INTO intelligence_agencies (id, agency_name, director_name) VALUES (1, 'RAW', 'Samant Goel'); INSERT INTO intelligence_agencies (id, agency_name, director_name) VALUES (2, 'IB', 'Arvind Kumar'); | Who are the top 2 intelligence agency directors in India and their respective agencies? | SELECT agency_name, director_name FROM intelligence_agencies WHERE agency_name IN ('RAW', 'IB') LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_accounts (id INT, username VARCHAR(255), region VARCHAR(255), account_created DATETIME); INSERT INTO user_accounts (id, username, region, account_created) VALUES (1, 'jdoe', 'Asia-Pacific', '2022-01-05'), (2, 'jsmith', 'Europe', '2022-01-06'); | How many user accounts were created in the 'Asia-Pacific' region in the last month? | SELECT COUNT(*) FROM user_accounts WHERE region = 'Asia-Pacific' AND account_created >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE EmergencyResponse (Id INT, Incident VARCHAR(20), ResponseTime INT, City VARCHAR(20), State VARCHAR(20)); CREATE VIEW EmergencyResponseView AS SELECT Incident, ResponseTime, ROW_NUMBER() OVER (PARTITION BY Incident ORDER BY ResponseTime) as Rank FROM EmergencyResponse; | What is the average response time for the three types of incidents with the shortest average response time? | SELECT e.Incident, AVG(e.ResponseTime) as AvgResponseTime FROM EmergencyResponseView e WHERE e.Rank <= 3 GROUP BY e.Incident; | gretelai_synthetic_text_to_sql |
CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, CuisineType varchar(255), Price decimal(5,2)); INSERT INTO MenuItems (MenuItemID, RestaurantID, CuisineType, Price) VALUES (1, 1, 'Italian', 12.99), (2, 2, 'Mexican', 8.99), (3, 3, 'Chinese', 10.99); | What is the average price of menu items for each cuisine type? | SELECT R.CuisineType, AVG(MI.Price) as AvgPrice FROM Restaurants R INNER JOIN MenuItems MI ON R.RestaurantID = MI.RestaurantID GROUP BY R.CuisineType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Game (id INT, name VARCHAR(255)); INSERT INTO Game (id, name) VALUES (1, 'Arena Shooter'), (2, 'Battle Royale'); | Find the total number of players who have played both "Arena Shooter" and "Battle Royale" games. | SELECT COUNT(DISTINCT PlayerId) FROM (SELECT PlayerId FROM GamePlayer G1 WHERE G1.name = 'Arena Shooter' INTERSECT SELECT PlayerId FROM GamePlayer G2 WHERE G2.name = 'Battle Royale') AS Subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibition (ExhibitionID INT PRIMARY KEY, Title VARCHAR(50), SiteID INT, StartDate DATE, EndDate DATE, Civilization VARCHAR(50)); INSERT INTO Exhibition (ExhibitionID, Title, SiteID, StartDate, EndDate, Civilization) VALUES (3, 'Aztec Empire: Myth and Reality', 3, '2005-01-01', '2005-12-31', 'Aztec Civiliz... | What are the names of exhibitions about the Aztec Civilization held at sites in the United States? | SELECT Title FROM Exhibition WHERE SiteID IN (SELECT SiteID FROM Site WHERE Country = 'United States') AND Civilization = 'Aztec Civilization'; | gretelai_synthetic_text_to_sql |
CREATE TABLE route (id INT, name TEXT, length FLOAT, fare FLOAT); INSERT INTO route (id, name, length, fare) VALUES (1, 'Central Line', 25.3, 3.5), (2, 'Circle Line', 22.8, 4.2), (3, 'Jubilee Line', 36.2, 5.0); | What is the average fare for each route in the 'route' table? | SELECT name, AVG(fare) as avg_fare FROM route GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (strain_id INT, strain_name VARCHAR(50)); | Add new strain 'OG Kush' to 'strains' table | INSERT INTO strains (strain_name) VALUES ('OG Kush'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crop (id INT, variety VARCHAR(255), farm_id INT);CREATE TABLE temperature (id INT, crop_id INT, measurement DATE, temp INT); | Determine the minimum temperature recorded for each crop variety in the past month | SELECT variety, MIN(temp) FROM (SELECT temp, crop_id, variety FROM temperature JOIN crop ON temperature.crop_id = crop.id) AS subquery GROUP BY variety WHERE measurement >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE EcoPackaging (id INT, material VARCHAR(50), order_quantity INT); INSERT INTO EcoPackaging (id, material, order_quantity) VALUES (1, 'Recycled Cardboard Boxes', 500), (2, 'Biodegradable Bags', 2000), (3, 'Plant-Based Packing Peanuts', 1000); | What is the maximum order quantity for eco-friendly packaging materials? | SELECT MAX(order_quantity) FROM EcoPackaging; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species VARCHAR(255), population INT, habitat VARCHAR(255)); INSERT INTO marine_species (id, species, population, habitat) VALUES (1, 'polar_bear', 25000, 'Arctic'); | List marine species with populations greater than 1000 in the Arctic. | SELECT species FROM marine_species WHERE habitat = 'Arctic' AND population > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, shipped_date DATE, destination VARCHAR(20), weight INT); INSERT INTO shipments (id, shipped_date, destination, weight) VALUES (1, '2022-02-15', 'Oceania', 250), (2, '2022-03-10', 'Oceania', 180), (3, '2022-03-03', 'Oceania', 300); | What is the number of shipments with a weight greater than 200 kg that were sent to 'Oceania' in the last month? | SELECT COUNT(*) FROM shipments WHERE shipped_date >= DATEADD(month, -1, GETDATE()) AND destination = 'Oceania' AND weight > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(50)); CREATE TABLE mining_sites (id INT, region_id INT, name VARCHAR(50), location VARCHAR(50), environmental_impact_score DECIMAL(5,2)); | What is the average environmental impact score and total number of mining sites for each region? | SELECT r.name AS region, AVG(ms.environmental_impact_score) AS avg_score, COUNT(ms.id) AS total_sites FROM regions r INNER JOIN mining_sites ms ON r.id = ms.region_id GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE europe_country (name VARCHAR(50), co2_emission_mwh DECIMAL(5,2)); INSERT INTO europe_country (name, co2_emission_mwh) VALUES ('France', 120.9), ('Germany', 320.9), ('Spain', 230.5); | Find the average CO2 emissions per MWh for each country in Europe. | SELECT name, AVG(co2_emission_mwh) OVER (PARTITION BY name) AS avg_emission FROM europe_country WHERE name IN ('France', 'Germany', 'Spain'); | gretelai_synthetic_text_to_sql |
CREATE TABLE museums (id INT, name TEXT, city TEXT); INSERT INTO museums (id, name, city) VALUES (1, 'Tokyo Museum', 'Tokyo'); | Update the name of the Tokyo museum to 'Tokyo National Museum'. | UPDATE museums SET name = 'Tokyo National Museum' WHERE name = 'Tokyo Museum' AND city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE africa_water_conservation (region VARCHAR(255), year INT, saved FLOAT, total FLOAT); INSERT INTO africa_water_conservation (region, year, saved, total) VALUES ('West Africa', 2018, 1000000, 5000000), ('West Africa', 2019, 1200000, 6000000), ('East Africa', 2018, 800000, 4000000), ('East Africa', 2019, 9000... | What is the total amount of water saved through conservation efforts in each region of Africa, for the years 2018 and 2019, and what was the total amount of water consumption during those years? | SELECT region, SUM(saved) as total_saved, SUM(total) as total_consumption, 100.0 * SUM(saved) / SUM(total) as savings_percentage FROM africa_water_conservation WHERE year IN (2018, 2019) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response (id INT, organization VARCHAR(50), location VARCHAR(50), assistance_type VARCHAR(50), quantity INT); INSERT INTO disaster_response (id, organization, location, assistance_type, quantity) VALUES (1, 'WFP', 'Syria', 'Food', 5000), (2, 'UNWRA', 'Gaza', 'Food', 3000), (3, 'IFRC', 'Syria', 'Sh... | What is the total quantity of assistance provided by each organization in 'disaster_response' table, regardless of type? | SELECT organization, SUM(quantity) FROM disaster_response GROUP BY organization; | gretelai_synthetic_text_to_sql |
CREATE TABLE australia_sustainable_tours (id INT, type VARCHAR(255), revenue FLOAT); INSERT INTO australia_sustainable_tours (id, type, revenue) VALUES (1, 'Sustainable', 900.00), (2, 'Sustainable', 1000.00); | What is the average revenue per sustainable tour in Australia? | SELECT AVG(revenue) FROM australia_sustainable_tours WHERE type = 'Sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonID INT, DonDate DATE, OrgID INT, Region VARCHAR(255), Amount INT); INSERT INTO Donations (DonID, DonDate, OrgID, Region, Amount) VALUES (1, '2021-01-01', 1, 'North', 500), (2, '2021-02-15', 2, 'South', 700), (3, '2021-03-30', 3, 'East', 900), (4, '2021-04-10', 1, 'North', 600), (5, '2021-05-2... | What is the total amount of charitable giving for each region? | SELECT Region, SUM(Amount) as TotalDonations FROM Donations GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE pacific_marine_protected_areas (id INT, name TEXT, region TEXT, avg_depth FLOAT); INSERT INTO pacific_marine_protected_areas (id, name, region, avg_depth) VALUES (1, 'Marianas Trench Marine National Monument', 'Pacific', 10991.0), (2, 'Deep Sea Coral Reserve', 'Pacific', 1500.0); | Find the number of marine protected areas in the Pacific Ocean with an average depth greater than 1000 meters. | SELECT COUNT(*) FROM pacific_marine_protected_areas WHERE region = 'Pacific' AND avg_depth > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE City_Council (council_id INT, council_member VARCHAR(50), district_number INT, salary DECIMAL(10,2), PRIMARY KEY (council_id)); INSERT INTO City_Council (council_id, council_member, district_number, salary) VALUES (1, 'James Smith', 1, 85000.00), (2, 'Katherine Johnson', 2, 85000.00), (3, 'Mohammed Ahmed',... | Update the salary of the council member representing district 3 to $90,000.00. | UPDATE City_Council SET salary = 90000.00 WHERE district_number = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE extraction_sites (site_id INT PRIMARY KEY, site_name VARCHAR(100), location VARCHAR(100), extraction_type VARCHAR(50)); INSERT INTO extraction_sites (site_id, site_name, location, extraction_type) VALUES (1, 'Site A', 'Country X', 'Surface mining'), (2, 'Site B', 'Country Y', 'Underground mining'); | What are the names and locations of all surface mining sites? | SELECT site_name, location FROM extraction_sites WHERE extraction_type = 'Surface mining'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Service (id INT, department_id INT, name VARCHAR(50), cost DECIMAL(10,2)); INSERT INTO Service (id, department_id, name, cost) VALUES (1, 1, 'ServiceA', 25000.00); INSERT INTO Service (id, department_id, name, cost) VALUES (2, 1, 'ServiceB', 30000.00); INSERT INTO Service (id, department_id, name, cost) VA... | What are the service names with the highest budget? | SELECT Service.name FROM Service WHERE cost = (SELECT MAX(cost) FROM Service) | gretelai_synthetic_text_to_sql |
CREATE TABLE europium_market (country VARCHAR(255), value DECIMAL(10,2)); INSERT INTO europium_market (country, value) VALUES ('South Africa', 125.60), ('Egypt', 132.90), ('Nigeria', 110.00); | What is the total market value of Europium in Africa? | SELECT SUM(value) FROM europium_market WHERE country IN ('South Africa', 'Egypt', 'Nigeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (project_id INT, project_location VARCHAR(50), project_type VARCHAR(50)); INSERT INTO Projects (project_id, project_location, project_type) VALUES (1, 'Nigeria', 'Community Development'), (2, 'Canada', 'Education'), (3, 'Kenya', 'Community Development'); | What is the total number of community development projects in each continent? | SELECT project_location, COUNT(*) AS 'Total Projects' FROM Projects WHERE project_type = 'Community Development' GROUP BY project_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), ProgramType VARCHAR(50), DonationAmount DECIMAL(10,2), VolunteerHours INT); INSERT INTO Programs (ProgramID, ProgramName, ProgramType, DonationAmount, VolunteerHours) VALUES (101, 'Environmental Conservation', 'Donation', 1000.00, 50), (102, 'Education Supp... | What is the average donation amount and total volunteer hours for programs related to environmental conservation? | SELECT ProgramType, AVG(DonationAmount) AS AvgDonation, SUM(VolunteerHours) AS TotalVolunteerHours FROM Programs WHERE ProgramType = 'Donation' GROUP BY ProgramType; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance) VALUES (1, 'Savings', 'New York', 5000.00), (2, 'Checking', 'New York', 7000.00), (3, 'Savings', 'Phoenix', 6000.00), (4, 'Savings', 'Phoenix', ... | What is the total savings account balance for customers in the Phoenix branch? | SELECT SUM(balance) FROM accounts WHERE account_type = 'Savings' AND branch = 'Phoenix'; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceanography (id INT PRIMARY KEY, name VARCHAR(255), average_depth FLOAT, area FLOAT, volume FLOAT); | Delete the 'Indian Ocean' record from the 'oceanography' table | WITH deleted_indian AS (DELETE FROM oceanography WHERE name = 'Indian Ocean') SELECT * FROM deleted_indian; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyID int, PolicyholderName varchar(50), PolicyType varchar(50), Premium int); INSERT INTO Policy (PolicyID, PolicyholderName, PolicyType, Premium) VALUES (1, 'John Doe', 'Auto', 1000), (2, 'Jane Smith', 'Home', 2000); CREATE TABLE Claim (ClaimID int, PolicyID int, ClaimAmount int); INSERT INTO ... | What is the total claim amount and policy type for each policyholder? | SELECT P.PolicyholderName, P.PolicyType, SUM(C.ClaimAmount) AS TotalClaimAmount FROM Policy P JOIN Claim C ON P.PolicyID = C.PolicyID GROUP BY P.PolicyholderName, P.PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityWaste (CityName VARCHAR(50), WasteQuantity INT, WasteYear INT, CityRegion VARCHAR(50)); CREATE TABLE CircularEconomy (Region VARCHAR(50), Initiative VARCHAR(50), ImplementationYear INT); INSERT INTO CityWaste (CityName, WasteQuantity, WasteYear, CityRegion) VALUES ('CityA', 12000, 2020, 'RegionA'), ('C... | What are the total waste generation quantities for each city, along with the number of circular economy initiatives implemented in the corresponding region, for 2020? | SELECT CityWaste.CityName, SUM(CityWaste.WasteQuantity) AS TotalWasteQuantity, COUNT(CircularEconomy.Initiative) AS NumberOfInitiatives FROM CityWaste INNER JOIN CircularEconomy ON CityWaste.CityRegion = CircularEconomy.Region WHERE CityWaste.WasteYear = 2020 GROUP BY CityWaste.CityName; | gretelai_synthetic_text_to_sql |
CREATE TABLE ForestPlots (PlotID int, PlotName varchar(50)); INSERT INTO ForestPlots VALUES (1, 'Plot1'), (2, 'Plot2'); CREATE TABLE Trees (TreeID int, TreeSpecies varchar(50), PlotID int); INSERT INTO Trees VALUES (1, 'Oak', 1), (2, 'Maple', 1), (3, 'Pine', 2); | Which tree species are present in each forest plot? | SELECT ForestPlots.PlotName, Trees.TreeSpecies FROM ForestPlots INNER JOIN Trees ON ForestPlots.PlotID = Trees.PlotID; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_type VARCHAR(20)); INSERT INTO customers (customer_id, customer_type) VALUES (1, 'Retail'), (2, 'Wholesale'), (3, 'Institutional'); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2)); INSERT INTO transactions (transaction_i... | What is the total transaction value per customer type? | SELECT customer_type, SUM(transaction_value) as total_transaction_value FROM transactions JOIN customers ON transactions.customer_id = customers.customer_id GROUP BY customer_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Archaeologists (id INT PRIMARY KEY, name VARCHAR(255), specialty TEXT, years_experience INT); INSERT INTO Archaeologists (id, name, specialty, years_experience) VALUES (1, 'Dr. Jane Doe', 'Egyptology', 20); | Insert data about an archaeologist into the Archaeologists table | INSERT INTO Archaeologists (id, name, specialty, years_experience) VALUES (2, 'Dr. John Smith', 'Mayan Civilization', 15); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, country TEXT, energy_consumption FLOAT, year INT); INSERT INTO hotels (hotel_id, hotel_name, city, country, energy_consumption, year) VALUES (1, 'Hotel A', 'Rome', 'Italy', 12000.0, 2021), (1, 'Hotel A', 'Rome', 'Italy', 13000.0, 2022); | Calculate the year-over-year percentage change in energy consumption for all hotels. | SELECT hotel_name, ((energy_consumption - LAG(energy_consumption) OVER (PARTITION BY hotel_name ORDER BY year))/LAG(energy_consumption) OVER (PARTITION BY hotel_name ORDER BY year))*100 as percentage_change FROM hotels; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donation_Categories (id INT, category TEXT, min_donation INT); INSERT INTO Donation_Categories (id, category, min_donation) VALUES (1, 'Education', 50); INSERT INTO Donation_Categories (id, category, min_donation) VALUES (2, 'Healthcare', 100); | List all donation categories and their respective minimum donation amounts. | SELECT category, min_donation FROM Donation_Categories; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (id INT, country VARCHAR(255), project_name VARCHAR(255), carbon_offset INT); INSERT INTO carbon_offsets (id, country, project_name, carbon_offset) VALUES (1, 'Canada', 'Project G', 1000), (2, 'Mexico', 'Project H', 1500); | What is the total carbon offset of renewable energy projects in Canada and Mexico? | SELECT SUM(carbon_offset) FROM carbon_offsets WHERE country IN ('Canada', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, gender_identity VARCHAR(255), first_generation_status VARCHAR(255), num_open_pedagogy_projects INT); INSERT INTO students (student_id, gender_identity, first_generation_status, num_open_pedagogy_projects) VALUES (1, 'Female', 'Yes', 3), (2, 'Non-binary', 'No', 5), (3, 'Male', 'Yes... | What is the average number of open pedagogy projects completed by students who identify as first-generation, broken down by their gender identity? | SELECT gender_identity, AVG(num_open_pedagogy_projects) as avg_projects FROM students WHERE first_generation_status = 'Yes' GROUP BY gender_identity; | gretelai_synthetic_text_to_sql |
CREATE TABLE packaging_materials (id INT, order_qty INT, recycled BOOLEAN); INSERT INTO packaging_materials (id, order_qty, recycled) VALUES (1, 500, true), (2, 750, false), (3, 600, true); | What is the maximum order quantity for recycled packaging materials? | SELECT MAX(order_qty) FROM packaging_materials WHERE recycled = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai (technique_id INT, technique_name VARCHAR(255), region VARCHAR(255), usage_count INT); INSERT INTO explainable_ai (technique_id, technique_name, region, usage_count) VALUES (1, 'SHAP', 'Argentina', 150), (2, 'LIME', 'Australia', 200), (3, 'TreeExplainer', 'New Zealand', 120), (4, 'Partial De... | Display the top 5 most frequently used explainable AI techniques in Latin America and Oceania. | SELECT technique_name, usage_count FROM explainable_ai WHERE region IN ('Latin America', 'Oceania') ORDER BY usage_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocations (Year INT, Service TEXT, Amount INT); INSERT INTO BudgetAllocations (Year, Service, Amount) VALUES (2022, 'Education', 15000000), (2022, 'Healthcare', 20000000); | What is the total budget allocation for education and healthcare services in 2022? | SELECT SUM(Amount) FROM BudgetAllocations WHERE Service IN ('Education', 'Healthcare') AND Year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE tram_fares (fare_id INT, tram_id INT, fare DECIMAL(5,2), date DATE); INSERT INTO tram_fares (fare_id, tram_id, fare, date) VALUES (1, 101, 3.00, '2022-01-01'), (2, 102, 2.50, '2022-01-02'), (3, 101, 3.00, '2022-01-03'), (4, 103, 2.00, '2022-01-04'); | What is the total fare collected for trams in 'south' region in January 2022? | SELECT SUM(fare) FROM tram_fares WHERE region = 'south' AND date >= '2022-01-01' AND date <= '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation_projects (id INT, project_name VARCHAR(100), location VARCHAR(100), start_year INT); INSERT INTO climate_adaptation_projects (id, project_name, location, start_year) VALUES (1, 'Sea Level Rise Protection', 'Pacific Islands', 2010), (2, 'Coastal Erosion Prevention', 'Europe', 2005); | List all climate adaptation projects in the Pacific Islands and their respective start years. | SELECT project_name, start_year FROM climate_adaptation_projects WHERE location = 'Pacific Islands'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_virtual_tours (hotel_id INT, country VARCHAR(50), views INT); INSERT INTO hotel_virtual_tours (hotel_id, country, views) VALUES (1, 'France', 1000), (2, 'France', 1200), (3, 'Germany', 800); CREATE TABLE hotel_info (hotel_id INT, hotel_name VARCHAR(50)); INSERT INTO hotel_info (hotel_id, hotel_name) ... | How many hotel virtual tours have been viewed in France, ordered by the most popular? | SELECT hv.country, hi.hotel_name, hv.views FROM hotel_virtual_tours hv JOIN hotel_info hi ON hv.hotel_id = hi.hotel_id WHERE country = 'France' ORDER BY views DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT, name VARCHAR(255), location VARCHAR(255), capacity FLOAT, technology VARCHAR(255)); | What is the total installed capacity (MW) of renewable energy projects? | SELECT SUM(capacity) FROM renewable_projects WHERE technology IN ('Solar', 'Wind', 'Hydro', 'Geothermal', 'Biomass'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_escapes (id INT, escape_date DATE, species VARCHAR(50), quantity INT); INSERT INTO fish_escapes (id, escape_date, species, quantity) VALUES (1, '2021-02-12', 'Salmon', 250), (2, '2021-03-04', 'Tilapia', 120), (3, '2021-07-18', 'Salmon', 300); | How many fish escapes were recorded in the past year for each species? | SELECT species, YEAR(escape_date) as escape_year, SUM(quantity) as total_escapes FROM fish_escapes WHERE escape_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY species, YEAR(escape_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor_Hours (id INT, worker_id TEXT, company TEXT, job_title TEXT, hours_worked FLOAT, country TEXT); | What is the total number of labor hours worked in the construction industry in Brazil in the last quarter? | SELECT SUM(hours_worked) FROM Labor_Hours WHERE country = 'Brazil' AND start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (SiteID INT, SiteName TEXT, Country TEXT, StartDate DATE, EndDate DATE);CREATE VIEW ArtifactCountPerSite AS SELECT SiteID, COUNT(*) AS ArtifactCount FROM Artifacts GROUP BY SiteID; | List all excavation sites and their total number of artifacts | SELECT e.SiteName, ac.ArtifactCount FROM ExcavationSites e JOIN ArtifactCountPerSite ac ON e.SiteID = ac.SiteID; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, improvement VARCHAR(255)); INSERT INTO patients (id, age, improvement) VALUES (1, 35, 'Improved'), (2, 42, 'Not Improved'), (3, 32, 'Improved'); CREATE TABLE therapy (patient_id INT, therapy_type VARCHAR(255)); INSERT INTO therapy (patient_id, therapy_type) VALUES (1, 'CBT'), (2,... | What is the median age of patients who improved after CBT? | SELECT MEDIAN(age) as median_age FROM patients JOIN therapy ON patients.id = therapy.patient_id WHERE improvement = 'Improved' AND therapy_type = 'CBT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Feed the Hungry'), (2, 'Tutoring'); CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT); INSERT INTO VolunteerPrograms (VolunteerID, ProgramID) VALUES (1, 1), (1, 2), (2, 1), (2, 2); CREATE TAB... | List all programs with their respective volunteer and community member impact counts. | SELECT Programs.ProgramName, COUNT(DISTINCT VolunteerPrograms.VolunteerID) AS VolunteerCount, SUM(CommunityImpact.Impacted) AS CommunityImpactCount FROM Programs INNER JOIN VolunteerPrograms ON Programs.ProgramID = VolunteerPrograms.ProgramID INNER JOIN CommunityImpact ON Programs.ProgramID = CommunityImpact.ProgramID ... | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, diagnosis VARCHAR(255), age INT); INSERT INTO patients (patient_id, diagnosis, age) VALUES (1, 'depression', 35), (2, 'anxiety', 28), (3, 'depression', 42); | What is the average age of patients diagnosed with depression in the 'mental_health' schema? | SELECT AVG(age) FROM mental_health.patients WHERE diagnosis = 'depression'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movie (id INT, title VARCHAR(100), production_country VARCHAR(50), production_budget INT, won_Oscar BOOLEAN); INSERT INTO movie (id, title, production_country, production_budget, won_Oscar) VALUES (1, 'The Shape of Water', 'United States', 190000000, true); | List all the countries with their respective number of Oscar-winning movies and total production budget. | SELECT production_country, COUNT(*), SUM(production_budget) FROM movie WHERE won_Oscar = true GROUP BY production_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE interest_free_loans (loan_id INT, amount DECIMAL(10, 2), borrower VARCHAR(255), loan_date DATE); INSERT INTO interest_free_loans (loan_id, amount, borrower, loan_date) VALUES (1, 5000, 'Mohammed', '2022-04-01'); INSERT INTO interest_free_loans (loan_id, amount, borrower, loan_date) VALUES (2, 6000, 'Fatima... | Calculate the sum of interest-free loans issued to 'Mohammed' in 2022. | SELECT SUM(amount) FROM interest_free_loans WHERE borrower = 'Mohammed' AND loan_date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_models (model_id INT, model_name VARCHAR(50), trained_for VARCHAR(50), training_location VARCHAR(50), training_date DATE); | Determine the total number of AI models trained for algorithmic fairness in the last 3 years, grouped by the training location. | SELECT training_location, COUNT(*) AS total FROM ai_models WHERE trained_for = 'algorithmic fairness' AND training_date >= DATE(CURRENT_DATE) - INTERVAL 3 YEAR GROUP BY training_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, date DATE); INSERT INTO virtual_tours (tour_id, hotel_id, date) VALUES (1, 4, '2022-02-15'), (2, 4, '2022-02-17'), (3, 5, '2022-03-01'), (4, 5, '2022-03-05'); | How many virtual tours were engaged in the last month for hotels in France? | SELECT COUNT(*) FROM virtual_tours WHERE hotel_id IN (SELECT hotel_id FROM hotels WHERE country = 'France') AND date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (VehicleID INT, VehicleType VARCHAR(50), Region VARCHAR(50), NextMaintenanceDate DATE); INSERT INTO Vehicles (VehicleID, VehicleType, Region, NextMaintenanceDate) VALUES (1, 'Bus', 'RegionA', '2023-03-01'), (2, 'Tram', 'RegionA', '2023-04-15'), (3, 'Train', 'RegionB', '2023-02-28'); | How many vehicles are due for maintenance in each region? | SELECT Region, COUNT(*) as VehiclesDueForMaintenance FROM Vehicles WHERE NextMaintenanceDate <= CURDATE() GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics (fan_id INT, gender VARCHAR(10), age INT, location VARCHAR(30)); | Show the number of fans from each location in the 'fan_demographics' table. | SELECT location, COUNT(*) FROM fan_demographics GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founding_date DATE); INSERT INTO startups(id, name, industry, founding_date) VALUES (1, 'TechStart', 'Technology', '2019-01-01'); | How many startups were founded in the technology sector in the last 5 years? | SELECT COUNT(*) FROM startups WHERE industry = 'Technology' AND founding_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor (LaborID INT, MineID INT, Year INT, LaborProductivityScore FLOAT); INSERT INTO Labor (LaborID, MineID, Year, LaborProductivityScore) VALUES (1, 1, 2019, 5.5); INSERT INTO Labor (LaborID, MineID, Year, LaborProductivityScore) VALUES (2, 1, 2018, 6.0); INSERT INTO Labor (LaborID, MineID, Year, LaborPro... | Update the labor productivity score of mine with ID 4 to 9.0. | UPDATE Labor SET LaborProductivityScore = 9.0 WHERE MineID = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtualtours (id INT, hotel_id INT, views INT); INSERT INTO virtualtours (id, hotel_id, views) VALUES (1, 5, 120); INSERT INTO virtualtours (id, hotel_id, views) VALUES (2, 6, 150); | Identify the number of virtual tours engaged for hotels in the 'Asia' region. | SELECT COUNT(*) FROM virtualtours WHERE hotel_id IN (SELECT id FROM hotels WHERE region = 'Asia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(50), gender VARCHAR(50), location VARCHAR(50)); INSERT INTO farmers (id, name, gender, location) VALUES (1, 'John Doe', 'Male', 'Springfield'); INSERT INTO farmers (id, name, gender, location) VALUES (2, 'Jane Doe', 'Female', 'Springfield'); | How many female farmers are in the 'farmers' table? | SELECT COUNT(*) FROM farmers WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (id INT, location VARCHAR(20)); INSERT INTO carbon_offset_programs (id, location) VALUES (1, 'Europe'), (2, 'Asia'), (3, 'North America'), (4, 'Europe'), (5, 'Asia'); | Count the number of carbon offset programs implemented in 'Europe' and 'Asia'. | SELECT location, COUNT(*) AS count FROM carbon_offset_programs WHERE location IN ('Europe', 'Asia') GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Articles (ArticleID INT, Title VARCHAR(100), AuthorID INT, Category VARCHAR(50), WordCount INT, PublishedDate DATE, AuthorGender VARCHAR(10)); | What is the total number of articles published in 2020, written by female authors and belonging to the 'Investigative Journalism' category? | SELECT COUNT(*) FROM Articles WHERE PublishedDate >= '2020-01-01' AND PublishedDate < '2021-01-01' AND AuthorGender = 'Female' AND Category = 'Investigative Journalism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, initiative_name VARCHAR(255), completion_date DATE, organization_type VARCHAR(50), state VARCHAR(50)); INSERT INTO community_development (id, initiative_name, completion_date, organization_type, state) VALUES (1, 'Education Program', '2017-08-15', 'NGO', 'Uttar Pradesh'), (2,... | How many community development initiatives were completed in India's Uttar Pradesh state by NGOs in 2017? | SELECT COUNT(*) FROM community_development WHERE state = 'Uttar Pradesh' AND organization_type = 'NGO' AND EXTRACT(YEAR FROM completion_date) = 2017 | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (id INT, cases INT, billing_rate DECIMAL(5,2), underrepresented_client BOOLEAN); | Identify the average billing rate for attorneys who have represented clients from underrepresented communities. | SELECT AVG(billing_rate) FROM Attorneys WHERE underrepresented_client = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE steps (id INT, user_id INT, daily_step_count INT, step_date DATE); INSERT INTO steps (id, user_id, daily_step_count, step_date) VALUES (1, 1, 8000, '2022-03-01'), (2, 2, 9000, '2022-03-15'); | Identify users who increased their step count by more than 10% in the last 30 days. | SELECT user_id FROM (SELECT user_id, daily_step_count, LAG(daily_step_count, 1) OVER (PARTITION BY user_id ORDER BY id) AS previous_step_count, (daily_step_count::DECIMAL / LAG(daily_step_count, 1) OVER (PARTITION BY user_id ORDER BY id)) * 100 AS step_increase_percentage FROM steps WHERE DATE(CURRENT_DATE() - INTERVAL... | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (initiative_name VARCHAR(50), country VARCHAR(50), year INT, budget INT); INSERT INTO climate_finance (initiative_name, country, year, budget) VALUES ('Green Cities Initiative', 'USA', 2022, 500000); INSERT INTO climate_finance (initiative_name, country, year, budget) VALUES ('Climate Smart... | What is the total number of climate finance initiatives and their combined budget in North America in 2022? | SELECT COUNT(*) as num_initiatives, SUM(budget) as total_budget FROM climate_finance WHERE year = 2022 AND country = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workout_data_extended(id INT, member_id INT, workout_type VARCHAR(20), workout_duration INT, country VARCHAR(20), additional_data VARCHAR(20)); INSERT INTO workout_data_extended(id, member_id, workout_type, workout_duration, country, additional_data) VALUES (1, 1, 'Running', 60, 'USA', 'Trail'), (2, 2, 'Cy... | Find the top 3 workout types with the longest duration, excluding those with a duration less than 15 minutes. | SELECT workout_type, AVG(workout_duration) as avg_duration FROM workout_data_extended WHERE workout_duration >= 15 GROUP BY workout_type ORDER BY avg_duration DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, location VARCHAR(20), completion_year INT, initiative_name VARCHAR(50), project_cost FLOAT); INSERT INTO community_development (id, location, completion_year, initiative_name, project_cost) VALUES (1, 'Rural', 2018, 'Community Library', 15000.00), (2, 'Urban', 2019, 'Communit... | What is the total cost of community development initiatives in rural areas of Kenya in 2019? | SELECT SUM(project_cost) FROM community_development WHERE location = 'Rural' AND completion_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_temperature (crop_type TEXT, date DATE, temperature INTEGER); | What is the maximum temperature recorded for each crop type in the past month? | SELECT crop_type, MAX(temperature) as max_temp FROM crop_temperature WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT, name TEXT, category TEXT, budget INT); INSERT INTO Programs (id, name, category, budget) VALUES (1, 'Art Exhibition', 'Arts', 50000), (2, 'Music Festival', 'Culture', 150000), (3, 'Theater Performance', 'Arts', 80000); | Show the total amount of funding for programs in 'Arts' and 'Culture' categories, excluding programs with a budget over $100,000. | SELECT SUM(budget) FROM Programs WHERE category IN ('Arts', 'Culture') AND budget <= 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, runtime_minutes INT, director VARCHAR(255)); | List the top 5 directors based on the total runtime of their movies, considering movies released between 2005 and 2015. | SELECT director, SUM(runtime_minutes) as total_runtime FROM movies WHERE release_year BETWEEN 2005 AND 2015 GROUP BY director ORDER BY total_runtime DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_studios (id INT, studio_name VARCHAR(255), country VARCHAR(255)); INSERT INTO movie_studios (id, studio_name, country) VALUES (1, 'Universal Pictures', 'United States'); INSERT INTO movie_studios (id, studio_name, country) VALUES (2, 'Paramount Pictures', 'United States'); INSERT INTO movie_studios (... | What is the total number of movies produced by studios located in the United States and Canada? | SELECT COUNT(*) FROM movie_studios WHERE country IN ('United States', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE VeteranJobApplications (Quarter TEXT, Year INT, NumberOfApplications INT); INSERT INTO VeteranJobApplications (Quarter, Year, NumberOfApplications) VALUES ('Q1', 2021, 1200), ('Q2', 2021, 1500), ('Q3', 2021, 1800), ('Q4', 2021, 1300); | How many veteran job applications were received in Q3 2021? | SELECT NumberOfApplications FROM VeteranJobApplications WHERE Quarter = 'Q3' AND Year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE City_Water_Usage (ID INT, City VARCHAR(50), State VARCHAR(20), Usage FLOAT); | Find the total water consumption for the 10 largest cities in the United States? | SELECT City, SUM(Usage) FROM (SELECT City, Usage FROM City_Water_Usage WHERE City IN ('New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Philadelphia', 'San Antonio', 'San Diego', 'Dallas', 'San Jose') ORDER BY Usage DESC LIMIT 10) t GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, name TEXT, location TEXT, attendance INT); INSERT INTO events (id, name, location, attendance) VALUES (1, 'Festival A', 'New York', 500), (2, 'Conference B', 'London', 300), (3, 'Exhibition C', 'New York', 700); | What is the average attendance at cultural events in New York? | SELECT AVG(attendance) FROM events WHERE location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_programs (id INT, name VARCHAR(255), region VARCHAR(255), habitat_preserved BOOLEAN); INSERT INTO education_programs (id, name, region, habitat_preserved) VALUES (1, 'Save the Wetlands', 'Africa', true), (2, 'Trees for Tomorrow', 'Asia', false); | How many education programs were successful in each region? | SELECT region, COUNT(*) FROM education_programs WHERE habitat_preserved = true GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE entrepreneurs_funding (id INT, entrepreneur_name VARCHAR(50), gender VARCHAR(10), project_category VARCHAR(50), funding DECIMAL(10, 2)); | List the number of female and male entrepreneurs who received funding for their projects in the 'entrepreneurs_funding' table, separated by project category? | SELECT project_category, gender, COUNT(*) FROM entrepreneurs_funding GROUP BY project_category, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, beds INT, rural BOOLEAN); INSERT INTO hospitals (id, name, location, beds, rural) VALUES (1, 'Hospital A', 'Texas', 200, true), (2, 'Hospital B', 'California', 300, true); | How many hospitals are there in the rural areas of Texas and California? | SELECT SUM(rural) FROM hospitals WHERE location IN ('Texas', 'California') AND rural = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, name TEXT, region TEXT, donation FLOAT); INSERT INTO Donations (id, name, region, donation) VALUES (1, 'Ella', 'East Coast', 150.2), (2, 'Fred', 'West Coast', 200.0); | What is the average donation amount in the 'East Coast' region? | SELECT AVG(donation) FROM Donations WHERE region = 'East Coast'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Southern_Ocean (id INT, pH DECIMAL(3,2), prawn_farm VARCHAR(20)); INSERT INTO Southern_Ocean (id, pH, prawn_farm) VALUES (1, 8.1, 'Farm 1'), (2, 7.9, 'Farm 2'), (3, 8.3, 'Farm 3'); | What is the maximum pH level in the Southern Ocean for prawn farms? | SELECT MAX(pH) FROM Southern_Ocean WHERE prawn_farm IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval_2018 (drug VARCHAR(50), year INT, status VARCHAR(50)); INSERT INTO drug_approval_2018 (drug, year, status) VALUES ('DrugM', 2018, 'Approved'), ('DrugN', 2018, 'Approved'); CREATE TABLE market_access (drug VARCHAR(50), country VARCHAR(50)); INSERT INTO market_access (drug, country) VALUES ('Dr... | List all drugs that were approved in 2018 and have market access in Canada? | SELECT market_access.drug FROM market_access INNER JOIN drug_approval_2018 ON market_access.drug = drug_approval_2018.drug WHERE drug_approval_2018.year = 2018 AND drug_approval_2018.status = 'Approved' AND market_access.country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Banks (BankID INT, Name VARCHAR(255)); INSERT INTO Banks (BankID, Name) VALUES (1, 'ABC Bank'); INSERT INTO Banks (BankID, Name) VALUES (2, 'XYZ Bank'); CREATE TABLE Products (ProductID INT, Name VARCHAR(255), BankID INT); INSERT INTO Products (ProductID, Name, BankID) VALUES (1, 'Savings Account', 1); INS... | What are the names of all savings products offered by ethical banks? | SELECT P.Name FROM Products P INNER JOIN Banks B ON P.BankID = B.BankID WHERE B.Name IN ('ABC Bank', 'XYZ Bank') AND P.Name LIKE '%Savings%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (id INT, item_id INT, category TEXT, quantity INT, price DECIMAL(5,2));INSERT INTO inventory (id, item_id, category, quantity, price) VALUES (1, 1, 'Pizza', 100, 5.99), (2, 2, 'Pasta', 75, 6.99), (3, 3, 'Salad', 50, 4.99); | What is the total inventory value for each category in Mexico? | SELECT c.category, SUM(i.quantity * i.price) AS total_inventory_value FROM inventory i JOIN categories c ON i.category = c.id WHERE c.country = 'Mexico' GROUP BY c.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE QuarterlyFruitPrices (quarter INT, year INT, fruit VARCHAR(20), price FLOAT); | What was the change in price of 'Bananas' between January and December in 'QuarterlyFruitPrices' table? | SELECT (SUM(CASE WHEN quarter = 4 THEN price ELSE 0 END) - SUM(CASE WHEN quarter = 1 THEN price ELSE 0 END)) as banana_price_change FROM QuarterlyFruitPrices WHERE fruit = 'Bananas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), transaction_date DATE, city VARCHAR(50)); INSERT INTO Donations (id, donation_amount, transaction_date, city) VALUES (1, 500, '2021-01-01', 'New York'), (2, 300, '2021-04-15', 'Los Angeles'), (3, 700, '2021-07-03', 'Chicago'), (4, 800, '2021-10-17', 'Housto... | How many donations were made in each city in 2021? | SELECT city, COUNT(*) as donation_count FROM Donations WHERE YEAR(transaction_date) = 2021 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_safety_records (brand TEXT, product_id INT, country TEXT, safety_rating INT); | Which cosmetic brands have the highest and lowest product safety records in the Japanese market? | SELECT brand, MAX(safety_rating) as highest_safety_rating, MIN(safety_rating) as lowest_safety_rating FROM product_safety_records WHERE country = 'Japan' GROUP BY brand ORDER BY highest_safety_rating DESC, lowest_safety_rating; | 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.