context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Heritage_Sites (Site_Name VARCHAR(50), Country VARCHAR(50), Region VARCHAR(50)); INSERT INTO Heritage_Sites (Site_Name, Country, Region) VALUES ('Angkor Wat', 'Cambodia', 'Southeast Asia'), ('Borobudur', 'Indonesia', 'Southeast Asia'); | What are the names and locations of all heritage sites in Southeast Asia, organized by country? | SELECT Country, Site_Name, Region FROM Heritage_Sites WHERE Region = 'Southeast Asia' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (song_name VARCHAR, platform VARCHAR, streams INT); | How many streams did the song 'Hound Dog' get on the music streaming platform? | SELECT SUM(streams) FROM streams WHERE song_name = 'Hound Dog'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_observations (expedition_id INT, species_count INT); | What is the maximum number of species observed in a single expedition? | SELECT MAX(species_count) FROM species_observations; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username VARCHAR(255), role VARCHAR(255), followers INT, created_at TIMESTAMP, category VARCHAR(255)); | Which user gained the most followers in the "gaming" category in March 2022? | SELECT username FROM users WHERE category = 'gaming' AND created_at >= '2022-03-01' AND created_at < '2022-04-01' ORDER BY followers DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (id INT, hotel_id INT, otan_code TEXT, region TEXT, year INT, bookings INT); | What is the total number of bookings for online travel agencies in the 'APAC' region for the year 2022? | SELECT otan_code, SUM(bookings) FROM bookings WHERE region = 'APAC' AND year = 2022 GROUP BY otan_code; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID INT, SupplierName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, Local BOOLEAN, SupplierID INT); INSERT INTO Suppliers (SupplierID, SupplierName, Country) VALUES (1, 'SupplierA', 'USA'), (2, 'SupplierB', 'Canada'), (3, 'SupplierC', 'France')... | What is the maximum price of locally sourced products sold by suppliers in Australia? | SELECT MAX(Price) FROM Products JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Local = true AND Country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer VARCHAR(20), purchases INT); INSERT INTO customers (customer, purchases) VALUES ('Customer D', 12), ('Customer E', 8), ('Customer F', 20); CREATE TABLE denim_sales (customer VARCHAR(20), denim INT); INSERT INTO denim_sales (customer, denim) VALUES ('Customer D', 6), ('Customer E', 5), (... | Who is the top customer for sustainable denim? | SELECT customer, purchases FROM (SELECT customer, SUM(denim) AS denim_purchases FROM denim_sales GROUP BY customer) AS denim_purchases INNER JOIN customers ON denim_purchases.customer = customers.customer WHERE denim_purchases >= 5 ORDER BY denim_purchases DESC LIMIT 1; | 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, 'Rio de Janeiro', 'Brazil'); 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)... | What is the total number of tourists visiting Rio de Janeiro, Brazil, in the last 30 days? | SELECT COUNT(DISTINCT visitor_id) FROM visit_logs JOIN cities ON visit_logs.city_id = cities.city_id WHERE cities.name = 'Rio de Janeiro' AND visit_date >= (CURRENT_DATE - INTERVAL '30 days'); | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, name VARCHAR(255)); CREATE TABLE initiatives (initiative_id INT, country_id INT, type VARCHAR(255)); | Count pollution control initiatives for each country. | SELECT c.name, COUNT(i.initiative_id) AS initiative_count FROM countries c JOIN initiatives i ON c.country_id = i.country_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_scores (model_id INT, region VARCHAR(50), safety FLOAT); INSERT INTO safety_scores (model_id, region, safety) VALUES (1, 'South Asia', 0.97), (2, 'Europe', 0.78), (3, 'South Asia', 0.92), (4, 'North America', 0.65), (5, 'South America', 0.98); | How many creative AI models have a safety score above 0.95 and were developed in South Asia? | SELECT COUNT(*) FROM safety_scores WHERE region = 'South Asia' AND safety > 0.95; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (TransactionID INT, CustomerID INT, Amount DECIMAL(10,2), TransactionDate DATE); INSERT INTO Transactions (TransactionID, CustomerID, Amount, TransactionDate) VALUES (1, 1, 100.00, '2022-02-01'); INSERT INTO Transactions (TransactionID, CustomerID, Amount, TransactionDate) VALUES (2, 1, 200.00... | Count the number of transactions that are not marked as fraud for customers from the United States. | SELECT COUNT(*) FROM Transactions T INNER JOIN Fraud F ON T.TransactionID = F.TransactionID INNER JOIN Customers C ON T.CustomerID = C.CustomerID WHERE F.IsFraud = 0 AND C.Country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(255)); CREATE TABLE natural_disasters (id INT, region_id INT, year INT); INSERT INTO regions (id, name) VALUES (1, 'West Coast'); INSERT INTO natural_disasters (id, region_id, year) VALUES (1, 1, 2020); | How many natural disasters were recorded in the 'West Coast' region in 2020? | SELECT COUNT(*) FROM natural_disasters WHERE region_id = (SELECT id FROM regions WHERE name = 'West Coast') AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE influencers (influencer_id INT, influencer_name VARCHAR(100), region VARCHAR(50)); CREATE TABLE media_literacy_scores (influencer_id INT, score INT); | Who are the top media literacy influencers in Asia? | SELECT influencer_name FROM influencers JOIN media_literacy_scores ON influencers.influencer_id = media_literacy_scores.influencer_id WHERE region = 'Asia' ORDER BY score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (1, 'School District 1'), (2, 'School District 2'); CREATE TABLE schools (id INT, name VARCHAR(255), district_id INT, student_population INT); INSERT INTO schools (id, name, district_id, student_population) VALUES (1, 'School 1'... | What is the name and location of all schools in 'School District 1' that have a student population greater than 500? | SELECT name, district_id FROM schools WHERE district_id = (SELECT id FROM districts WHERE name = 'School District 1') AND student_population > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, GameType VARCHAR(10)); INSERT INTO Players (PlayerID, Age, GameType) VALUES (1, 25, 'VR'), (2, 30, 'Non-VR'), (3, 22, 'VR'); | What is the average age of players who play VR games? | SELECT AVG(Age) FROM Players WHERE GameType = 'VR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(30), genre VARCHAR(20), rating INT); | What is the average rating of artworks in the 'Impressionism' genre, excluding artworks with a rating of 0? | SELECT AVG(Artwork.rating) FROM Artwork WHERE Artwork.genre = 'Impressionism' AND Artwork.rating > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_certifications (certification_id INT PRIMARY KEY, ingredient_id INT, certification_date DATE, certified_by TEXT); | Create a table to store cruelty-free certification records for ingredients | CREATE TABLE ingredient_certifications (certification_id INT PRIMARY KEY, ingredient_id INT, certification_date DATE, certified_by TEXT); | gretelai_synthetic_text_to_sql |
CREATE TABLE bills (id INT PRIMARY KEY, title VARCHAR(255), sponsor_id INT, status VARCHAR(255)); INSERT INTO bills (id, title, sponsor_id, status) VALUES (1, 'Public Space Enhancement Act', 1, 'Introduced'), (2, 'Affordable Housing Development Act', 2, 'Passed'); | Remove the bill with id 2 | DELETE FROM bills WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (site_id INT, site_name VARCHAR(50)); CREATE TABLE ExcavationTimeline (site_id INT, start_year INT, end_year INT); INSERT INTO ExcavationSites (site_id, site_name) VALUES (6, 'Petra'); INSERT INTO ExcavationTimeline (site_id, start_year, end_year) VALUES (6, 1929, 1934), (6, 1958, 1961), (6... | What was the total duration of excavations at the 'Petra' site? | SELECT SUM(DATEDIFF(year, start_year, end_year)) FROM ExcavationTimeline WHERE site_id = (SELECT site_id FROM ExcavationSites WHERE site_name = 'Petra'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (student_id INT, name VARCHAR(50), visual_impairment BOOLEAN); CREATE TABLE Support_Programs (program_id INT, state VARCHAR(50), student_id INT); | How many students with visual impairments are enrolled in support programs in Texas and Florida? | SELECT COUNT(DISTINCT S.student_id) FROM Students S INNER JOIN Support_Programs SP ON S.student_id = SP.student_id WHERE S.visual_impairment = TRUE AND SP.state IN ('Texas', 'Florida'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Autonomous_Buses (id INT, route_number INT, fleet_number INT, in_service DATE, last_maintenance_date DATE); INSERT INTO Autonomous_Buses (id, route_number, fleet_number, in_service, last_maintenance_date) VALUES (3, 103, 2503, '2021-12-31', '2021-12-28'), (4, 104, 2504, '2021-12-30', '2021-12-27'); | Which routes have more than 2 autonomous buses that were in service before 2022-01-01? | SELECT route_number, COUNT(*) as total_buses FROM Autonomous_Buses WHERE in_service < '2022-01-01' GROUP BY route_number HAVING total_buses > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life (id INT, species VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO marine_life (id, species, population, region) VALUES (1, 'Salmon', 15000, 'pacific_ocean'); INSERT INTO marine_life (id, species, population, region) VALUES (2, 'Lionfish', 1200, 'atlantic_ocean'); INSERT INTO mari... | Display the species column and the total population for each species in the marine_life table, ordered by total population in descending order. | SELECT species, SUM(population) OVER (PARTITION BY species) as total_population FROM marine_life ORDER BY total_population DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), DiversityTraining VARCHAR(10)); INSERT INTO Employees (EmployeeID, EmployeeName, Department, DiversityTraining) VALUES (1, 'John Doe', 'IT', 'Completed'), (2, 'Jane Smith', 'IT', 'In Progress'), (3, 'Mike Johnson', 'HR', 'Complete... | Determine the percentage of employees who have completed diversity and inclusion training, by department. | SELECT Department, PERCENT_RANK() OVER (PARTITION BY DiversityTraining ORDER BY COUNT(*) DESC) AS PercentageCompleted FROM Employees GROUP BY Department, DiversityTraining; | gretelai_synthetic_text_to_sql |
CREATE TABLE deepest_points (ocean TEXT, trench_name TEXT, depth INTEGER); INSERT INTO deepest_points (ocean, trench_name, depth) VALUES ('Pacific Ocean', 'Mariana Trench', 10994), ('Indian Ocean', 'Java Trench', 7290), ('Atlantic Ocean', 'Puerto Rico Trench', 8380); | Find the maximum depth of the Indian Ocean | SELECT MAX(depth) FROM deepest_points WHERE ocean = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT, order_value DECIMAL(10,2), device VARCHAR(20), country VARCHAR(50)); INSERT INTO orders (id, order_value, device, country) VALUES (1, 150.50, 'desktop', 'Spain'), (2, 75.20, 'mobile', 'Canada'), (3, 225.00, 'desktop', 'Spain'); | What is the minimum order value for purchases made using a desktop device in Spain? | SELECT MIN(order_value) FROM orders WHERE device = 'desktop' AND country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells_canada (id INT, well_name VARCHAR(50), location VARCHAR(50), company VARCHAR(50), num_drills INT, drill_date DATE, is_private BOOLEAN, province VARCHAR(50)); INSERT INTO wells_canada VALUES (7, 'Well V', 'Alberta', 'Canadian Oil', 5, '2020-06-01', true, 'Alberta'); INSERT INTO wells_canada VALUES (8,... | Identify the number of wells drilled in each province of Canada for privately-owned companies between 2019 and 2021 | SELECT province, SUM(num_drills) FROM wells_canada WHERE is_private = true AND drill_date BETWEEN '2019-01-01' AND '2021-12-31' GROUP BY province; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name TEXT, area FLOAT, region TEXT, carbon_sequestration FLOAT); INSERT INTO forests (id, name, area, region, carbon_sequestration) VALUES (1, 'Arctic Tundra', 123456.7, 'Arctic', 123.4), (2, 'Svalbard', 23456.7, 'Arctic', 234.5); | What is the average carbon sequestration of forests in the 'Arctic' region? | SELECT AVG(carbon_sequestration) FROM forests WHERE region = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(100), Country varchar(50), DonationDate date); INSERT INTO Donors (DonorID, DonorName, Country, DonationDate) VALUES (1, 'John Doe', 'USA', '2022-01-01'), (2, 'Jane Smith', 'Canada', '2021-01-01'), (3, 'Ali Khan', 'Pakistan', '2022-03-01'), (4, 'Han Lee', 'South Korea... | How many new donors from Asia joined in 2022? | SELECT COUNT(*) FROM Donors WHERE YEAR(DonationDate) = 2022 AND Country IN ('Afghanistan', 'Bahrain', 'Bangladesh', 'Bhutan', 'Brunei', 'Cambodia', 'China', 'Cyprus', 'East Timor', 'India', 'Indonesia', 'Iran', 'Iraq', 'Israel', 'Japan', 'Jordan', 'Kazakhstan', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Lebanon', 'Malaysia', 'Ma... | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (ship_id INT, ship_name VARCHAR(255), registration_date DATE, fleet_id INT); INSERT INTO ships VALUES (1, 'Sea Giant', '2010-03-23', 1), (2, 'Poseidon', '2012-09-08', 1); CREATE TABLE fleets (fleet_id INT, fleet_name VARCHAR(255)); INSERT INTO fleets VALUES (1, 'Sea Fleet'); CREATE TABLE cargo (cargo... | List all ships in 'Sea Fleet' with their total cargo weight in 2022 | SELECT s.ship_name, SUM(c.weight) as total_weight FROM ships s JOIN cargo c ON s.ship_id = c.ship_id WHERE s.fleet_id = 1 AND YEAR(c.handling_date) = 2022 GROUP BY s.ship_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, policy_holder VARCHAR(50), coverage_amount INT); CREATE TABLE claim (claim_id INT, policy_id INT, claim_amount INT, claim_date DATE); INSERT INTO policy (policy_id, policy_holder, coverage_amount) VALUES (1, 'John Doe', 400000), (2, 'Jane Smith', 600000), (3, 'Mary Johnson', 350000);... | Delete policy records for policyholders living in 'California' | DELETE FROM policy WHERE policy_holder IN (SELECT policy_holder FROM policy JOIN (SELECT 'California' AS state_name UNION ALL SELECT 'CA') AS ca ON policy_holder LIKE '%CA%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Esports_Events (id INT, name VARCHAR(50), event_date DATE); INSERT INTO Esports_Events (id, name, event_date) VALUES (1, 'Dreamhack', '2022-01-01'), (2, 'ESL One', '2021-01-01'), (3, 'IEM', '2022-03-01'); | Count the number of esports events in 2022 | SELECT COUNT(*) FROM Esports_Events WHERE event_date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FerryFares (FareID INT, RouteID INT, Fare FLOAT); | What is the maximum fare for a ferry ride? | SELECT MAX(Fare) FROM FerryFares WHERE RouteID = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_preference (id INT PRIMARY KEY, consumer_id INT, product_id INT, preference_score INT, category VARCHAR(100));CREATE TABLE product (id INT PRIMARY KEY, name VARCHAR(100));CREATE TABLE consumer (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(100));CREATE VIEW avg_preference_score_by... | List the names of products that have a preference score above the average preference score for products in the same category. | SELECT p.name FROM product p JOIN consumer_preference cp ON p.id = cp.product_id JOIN avg_preference_score_by_category aps ON cp.category = aps.category WHERE cp.preference_score > aps.avg_preference_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (id INT, project_name VARCHAR(20), project_location VARCHAR(20), project_type VARCHAR(20)); INSERT INTO climate_projects (id, project_name, project_location, project_type) VALUES (1, 'Adaptation Project 1', 'Pacific Islands', 'Climate Adaptation'), (2, 'Mitigation Project 1', 'Europe', 'Cl... | Delete all records related to climate adaptation projects in the Pacific Islands from the climate_projects table. | DELETE FROM climate_projects WHERE project_location = 'Pacific Islands' AND project_type = 'Climate Adaptation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, temperature FLOAT); INSERT INTO fish_farms (id, name, location, temperature) VALUES (1, 'Farm A', 'South Pacific Ocean', 22.5), (2, 'Farm B', 'North Pacific Ocean', 18.0); | What is the average temperature (°C) for fish farms located in the South Pacific Ocean? | SELECT AVG(temperature) FROM fish_farms WHERE location = 'South Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE meals (id INT, name TEXT, restaurant_type TEXT); INSERT INTO meals (id, name, restaurant_type) VALUES (1, 'Filet Mignon', 'fine dining'), (2, 'Chicken Caesar', 'casual dining'), (3, 'Tofu Stir Fry', 'fine dining'); CREATE TABLE nutrition (meal_id INT, calorie_count INT); INSERT INTO nutrition (meal_id, cal... | What is the minimum calorie count for meals served at casual dining restaurants? | SELECT MIN(nutrition.calorie_count) FROM nutrition JOIN meals ON nutrition.meal_id = meals.id WHERE meals.restaurant_type = 'casual dining'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), HireDate DATE, Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, HireDate, Salary) VALUES (1, 'John Doe', '2022-01-01', 80000.00), (2, 'Jane Smith', '2022-02-14', 85000.00), (3, 'Mike Johnson', '2021-12-01', 90000.00); | What is the average salary of employees hired in 2022? | SELECT AVG(Salary) FROM Employees WHERE YEAR(HireDate) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE prices (id INT, brand VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO prices (id, brand, price) VALUES (1, 'Lush', 25.99), (2, 'NYX', 12.99), (3, 'Burt’s Bees', 15.99), (4, 'Tarte', 28.99), (5, 'Urban Decay', 21.99); | Update the price of all Lush products to $30.00. | UPDATE prices SET price = 30.00 WHERE brand = 'Lush'; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor_stats (state TEXT, project_id INT, labor_cost FLOAT); | What is the maximum labor cost for construction projects in 'New York' in the 'construction_labor_stats' table? | SELECT MAX(labor_cost) FROM construction_labor_stats WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE maritime_safety_ratings (route TEXT, safety_rating INTEGER); INSERT INTO maritime_safety_ratings (route, safety_rating) VALUES ('Route A', 7), ('Route B', 8), ('Route C', 6); | What is the minimum safety rating for maritime routes in the Indian Ocean? | SELECT MIN(safety_rating) FROM maritime_safety_ratings WHERE route LIKE '%Indian Ocean%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MobileInvestments (Area varchar(10), Investment int); CREATE TABLE BroadbandInvestments (Area varchar(10), Investment int); INSERT INTO MobileInvestments (Area, Investment) VALUES ('North', 100000), ('South', 120000), ('rural', 75000); INSERT INTO BroadbandInvestments (Area, Investment) VALUES ('East', 800... | List the total network investments made in 'rural' areas for mobile and broadband networks separately, and the difference between the two. | SELECT SUM(CASE WHEN Area = 'rural' THEN Investment ELSE 0 END) AS RuralBroadband, SUM(CASE WHEN Area = 'rural' THEN 0 ELSE Investment END) AS RuralMobile, RuralBroadband - RuralMobile AS InvestmentDifference FROM MobileInvestments MI JOIN BroadbandInvestments BI ON 1=1; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), region VARCHAR(50)); CREATE TABLE diseases (id INT, patient_id INT, name VARCHAR(50), diagnosis_date DATE, severity INT); INSERT INTO patients (id, name, age, gender, region) VALUES (1, 'James Smith', 65, 'Male', 'Rural Alabama'); INSERT INTO... | List the names of patients diagnosed with diabetes in rural Alabama and the diagnosis date. | SELECT patients.name, diseases.diagnosis_date FROM patients INNER JOIN diseases ON patients.id = diseases.patient_id WHERE patients.region = 'Rural Alabama' AND diseases.name = 'Diabetes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm (id INT, farm_name TEXT, region TEXT, species TEXT, weight FLOAT, age INT); INSERT INTO Farm (id, farm_name, region, species, weight, age) VALUES (1, 'OceanPacific', 'Pacific', 'Tilapia', 500.3, 2), (2, 'SeaBreeze', 'Atlantic', 'Salmon', 300.1, 1), (3, 'OceanPacific', 'Pacific', 'Tilapia', 600.5, 3), ... | What is the total biomass of fish in the 'Atlantic' and 'Pacific' regions? | SELECT SUM(weight) FROM Farm WHERE region IN ('Atlantic', 'Pacific'); | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (project_id INT, project_name TEXT, location TEXT, project_type TEXT, start_year INT); INSERT INTO climate_projects (project_id, project_name, location, project_type, start_year) VALUES (1, 'Adaptation 1', 'Australia', 'climate adaptation', 2010), (2, 'Mitigation 1', 'New Zealand', 'climat... | Identify the number of climate adaptation projects in Oceania for each year since 2010. | SELECT start_year, COUNT(*) as project_count FROM climate_projects WHERE project_type = 'climate adaptation' AND location LIKE 'Oceania%' AND start_year >= 2010 GROUP BY start_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (id INT, region VARCHAR(255), volume FLOAT); INSERT INTO timber_production (id, region, volume) VALUES (1, 'Northwest', 1234.56), (2, 'Southeast', 789.12), (3, 'Northwest', 456.34); | What is the maximum volume of timber in the timber_production table? | SELECT MAX(volume) FROM timber_production; | gretelai_synthetic_text_to_sql |
CREATE TABLE bollywood_movies (id INT, title VARCHAR(255), release_year INT, runtime INT); INSERT INTO bollywood_movies (id, title, release_year, runtime) VALUES (1, 'Tanhaji', 2020, 135), (2, 'Chhapaak', 2020, 123); | What's the average runtime of Bollywood movies released in 2020? | SELECT AVG(runtime) FROM bollywood_movies WHERE release_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE WarzoneLegends (PlayerID INT, Kills INT, Matches INT); INSERT INTO WarzoneLegends (PlayerID, Kills, Matches) VALUES (1, 120, 25), (2, 85, 20), (3, 135, 30), (4, 90, 22), (5, 110, 28); | What is the average number of kills per match for players who have more than 100 kills in the "WarzoneLegends" table? | SELECT AVG(Kills/Matches) FROM WarzoneLegends WHERE Kills > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, close_date DATE); INSERT INTO cases (case_id, close_date) VALUES (1, '2022-01-01'), (2, '2021-08-01'), (3, '2022-05-15'); | Delete all cases with a close date older than 6 months. | DELETE FROM cases WHERE close_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_missions (id INT, spacecraft VARCHAR(50), altitude INT); INSERT INTO spacecraft_missions (id, spacecraft, altitude) VALUES (1, 'Starship', 10000); | What is the maximum altitude reached by spacecraft built by SpaceX? | SELECT MAX(altitude) FROM spacecraft_missions WHERE spacecraft = 'Starship'; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates_tokyo (city VARCHAR(50), recycling_rate DECIMAL(5,2), date DATE); INSERT INTO recycling_rates_tokyo (city, recycling_rate, date) VALUES ('Tokyo', 0.75, '2022-01-01'), ('Tokyo', 0.76, '2022-02-01'), ('Tokyo', 0.77, '2022-03-01'), ('Tokyo', 0.78, '2022-04-01'), ('Tokyo', 0.79, '2022-05-01'), ... | What is the average recycling rate in Tokyo for the last 12 months? | SELECT AVG(recycling_rate) FROM recycling_rates_tokyo WHERE city = 'Tokyo' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, organic BOOLEAN, product_id INT); | List the top 5 ingredients used in cosmetic products that are sourced from organic farms, along with the number of products that use each ingredient. | SELECT ingredient_name, COUNT(*) as num_products FROM ingredients WHERE organic = TRUE GROUP BY ingredient_name ORDER BY num_products DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_stations (station_name TEXT, entries INTEGER, exits INTEGER); INSERT INTO subway_stations (station_name, entries, exits) VALUES ('Times Square-42nd St', 45678, 43210), ('Grand Central-42nd St', 34567, 35432), ('34th St-Herald Sq', 23456, 24321); | What are the names of the busiest subway stations in New York City, based on the number of entries and exits? | SELECT station_name FROM subway_stations ORDER BY entries + exits DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY, name VARCHAR(255), last_update_date DATETIME); INSERT INTO smart_contracts (contract_id, name, last_update_date) VALUES (1, 'Contract1', '2022-01-10 15:00:00'), (2, 'Contract2', '2022-02-05 16:00:00'), (3, 'Contract3', '2022-03-01 14:00:00'), (4, 'Contract4', '... | Delete any smart contracts that have not been updated in the last 60 days. | DELETE FROM smart_contracts WHERE last_update_date < DATE_SUB(CURRENT_DATE, INTERVAL 60 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE MillE(mill_name TEXT, timber_volume INT); INSERT INTO MillE (mill_name, timber_volume) VALUES ('Mill E', 600); CREATE TABLE MillSales(mill_name TEXT, sale_volume INT); INSERT INTO MillSales (mill_name, sale_volume) VALUES ('Mill A', 500), ('Mill B', 350), ('Mill E', 700); | Display the total volume of timber sold by each mill, excluding sales from 'Mill E'. | SELECT ms.mill_name, SUM(ms.sale_volume) FROM MillSales ms WHERE ms.mill_name NOT IN ('Mill E') GROUP BY ms.mill_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (id INT, city VARCHAR(50), language VARCHAR(50), visitors INT); INSERT INTO Visitors (id, city, language, visitors) VALUES (1, 'Istanbul', 'French', 2000); | Find the total number of visitors that attended exhibitions in Istanbul and spoke French. | SELECT SUM(visitors) FROM Visitors WHERE city = 'Istanbul' AND language = 'French'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name VARCHAR(50), total_billing_amount DECIMAL(10,2)); INSERT INTO clients (id, name, total_billing_amount) VALUES (1, 'ABC Corp', 50000.00), (2, 'XYZ Inc', 75000.00), (3, 'LMN LLC', 30000.00); | List the top 3 clients by total billing amount | SELECT name, total_billing_amount FROM clients ORDER BY total_billing_amount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emission(country VARCHAR(50), co2_emission FLOAT); INSERT INTO co2_emission(country, co2_emission) VALUES('CountryX', 25.6), ('CountryY', 32.8), ('CountryZ', 38.1); | What is the total CO2 emission (in metric tons) for each country where textiles are sourced? | SELECT country, SUM(co2_emission) FROM co2_emission GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name VARCHAR(50), restaurant_id INT); CREATE TABLE sales (menu_item_id INT, revenue INT, restaurant_id INT); | Identify the top 3 menu items by sales across all restaurants | SELECT menu_items.name, SUM(sales.revenue) as total_sales FROM sales JOIN menu_items ON sales.menu_item_id = menu_items.id GROUP BY menu_items.name ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, Outcome VARCHAR(10)); INSERT INTO Cases (CaseID, Outcome) VALUES (1, 'Favorable'), (2, 'Unfavorable'); CREATE TABLE Attorneys (AttorneyID INT, CaseID INT); INSERT INTO Attorneys (AttorneyID, CaseID) VALUES (1, 1), (2, 2); | Which attorneys have worked on cases with a favorable outcome? | SELECT DISTINCT Attorneys.AttorneyID FROM Attorneys INNER JOIN Cases ON Attorneys.CaseID = Cases.CaseID WHERE Cases.Outcome = 'Favorable'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA RuralHealth; USE RuralHealth; CREATE TABLE Counties (CountyID INT, CountyName VARCHAR(50), CountyPopulation INT, StateAbbreviation VARCHAR(10)); CREATE TABLE MentalHealthProviders (ProviderID INT, CountyID INT, ProviderType VARCHAR(50)); INSERT INTO Counties (CountyID, CountyName, CountyPopulation, StateA... | What is the number of mental health providers per 100,000 people for each county, ordered from highest to lowest? | SELECT CountyID, (SUM(CASE WHEN ProviderType IN ('Psychiatrist', 'Social Worker', 'Therapist') THEN 1 ELSE 0 END) * 100000.0 / CountyPopulation) as MentalHealthProvidersPer100k FROM MentalHealthProviders INNER JOIN Counties ON MentalHealthProviders.CountyID = Counties.CountyID INNER JOIN StatesPopulation ON Counties.St... | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_development (teacher_id INT, subject_teached VARCHAR(30), course_completed INT); | Find the number of teachers who have not completed any professional development courses in the 'teacher_development' table, grouped by their teaching subject. | SELECT subject_teached, COUNT(teacher_id) FROM teacher_development WHERE course_completed = 0 GROUP BY subject_teached; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name TEXT, population INTEGER, ocean TEXT); | What is the maximum population of any marine species in the Southern Ocean? | SELECT MAX(population) FROM marine_species WHERE ocean = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding (funding_id INT, event_type VARCHAR(20), funding_source VARCHAR(20), amount INT, event_location VARCHAR(20)); INSERT INTO Funding (funding_id, event_type, funding_source, amount, event_location) VALUES (1, 'Music', 'Private', 7000, 'New York'), (2, 'Dance', 'Private', 3000, 'Chicago'), (3, 'Music',... | What is the total funding received for music events from the "Private" funding source, excluding events in 'New York'? | SELECT SUM(amount) FROM Funding WHERE event_type = 'Music' AND funding_source = 'Private' AND event_location <> 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO sites (id, name, country, visitors) VALUES (1, 'Site1', 'Italy', 500), (2, 'Site2', 'Italy', 700); | What is the total number of visitors to cultural heritage sites in Italy? | SELECT SUM(visitors) FROM sites WHERE country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, GameName VARCHAR(50), Genre VARCHAR(50), Rating INT); INSERT INTO Games (GameID, GameName, Genre, Rating) VALUES (1, 'Game1', 'Action', 9), (2, 'Game2', 'RPG', 8), (3, 'Game3', 'Strategy', 10), (4, 'Game4', 'Simulation', 7); | List all unique game genres that have a rating of 9 or higher. | SELECT DISTINCT Genre FROM Games WHERE Rating >= 9; | gretelai_synthetic_text_to_sql |
CREATE TABLE disasters (id INT PRIMARY KEY, name TEXT, start_date DATE); | Insert a new record for a disaster with ID 10, name 'Flood', and start date 2021-11-01 into the "disasters" table | INSERT INTO disasters (id, name, start_date) VALUES (10, 'Flood', '2021-11-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO organizations (id, sector, ESG_rating) VALUES (1, 'Healthcare', 7.5), (2, 'Technology', 8.2), (3, 'Healthcare', 8.0), (4, 'Renewable Energy', 9.0); CREATE TABLE investments (id INT, organization_id INT); INSERT INTO investments (id, ... | List all organizations and their investments in the renewable energy sector | SELECT organizations.sector, organizations.id, investments.id AS investment_id FROM organizations JOIN investments ON organizations.id = investments.organization_id WHERE organizations.sector = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations(id INT, donor_name TEXT, donation_amount FLOAT, donation_date DATE, industry TEXT); INSERT INTO donations(id, donor_name, donation_amount, donation_date, industry) VALUES (1, 'James Lee', 50, '2022-11-29', 'Technology'), (2, 'Grace Kim', 100, '2022-12-01', 'Finance'), (3, 'Anthony Nguyen', 25, '2... | What is the average donation amount for donors in the Technology industry who gave on Giving Tuesday? | SELECT AVG(donation_amount) FROM donations WHERE industry = 'Technology' AND donation_date = '2022-11-29'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_name TEXT, num_research_stations INT); INSERT INTO countries (country_name, num_research_stations) VALUES ('Canada', 7), ('USA', 12), ('Australia', 6), ('Indonesia', 4), ('Japan', 8); | Identify countries with a minimum of 5 marine research stations. | SELECT country_name FROM countries WHERE num_research_stations >= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), institution_id INT, mental_health_score INT, location VARCHAR(10)); INSERT INTO students (id, name, institution_id, mental_health_score, location) VALUES (1, 'Jane Doe', 1, 80, 'urban'), (2, 'John Doe', 2, 70, 'rural'), (3, 'Ava Smith', 1, 85, 'urban'), (4, 'Ben Johnson'... | What is the average mental health score for students in rural and urban areas? | SELECT location, AVG(mental_health_score) as avg_score FROM students GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA carbon_offsets; CREATE TABLE projects (project_name VARCHAR(255), region VARCHAR(255), investment_amount INT); INSERT INTO projects (project_name, region, investment_amount) VALUES ('Tropical Forest Conservation', 'Asia', 5000000), ('Wind Power Generation', 'Europe', 8000000), ('Soil Carbon Sequestration'... | Find the average investment amount for carbon offset projects in the 'Africa' and 'Europe' regions, excluding oceanic projects. | SELECT region, AVG(investment_amount) FROM carbon_offsets.projects WHERE region IN ('Africa', 'Europe') AND region != 'Oceania' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research (study_name VARCHAR(255), location VARCHAR(255), technology VARCHAR(255), publish_date DATE); INSERT INTO genetic_research (study_name, location, technology, publish_date) VALUES ('GeneUSA', 'USA', 'CRISPR-Cas9', '2023-01-01'); | Which genetic research studies from the USA or Mexico have used CRISPR technology and published results in the last 6 months? | SELECT study_name FROM genetic_research WHERE (location = 'USA' OR location = 'Mexico') AND technology = 'CRISPR-Cas9' AND publish_date BETWEEN DATEADD(MONTH, -6, GETDATE()) AND GETDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeBenefits (id INT, EmployeeID INT, CompanyType TEXT, HealthcareBenefits BOOLEAN); | What is the percentage of non-union workers in the 'Finance' sector who receive healthcare benefits? | SELECT (COUNT(*) / (SELECT COUNT(*) FROM EmployeeBenefits WHERE CompanyType != 'Union') * 100) FROM EmployeeBenefits WHERE CompanyType != 'Union' AND HealthcareBenefits = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Highway (id INT, name TEXT, location TEXT, number_of_lanes INT); INSERT INTO Highway (id, name, location, number_of_lanes) VALUES (1, 'A1 Autoroute', 'France', 3), (2, 'A6 Autoroute', 'France', 2); | What is the minimum number of lanes for highways in France? | SELECT MIN(number_of_lanes) FROM Highway WHERE location = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE station (station_id INT, name TEXT, location TEXT); INSERT INTO station (station_id, name, location) VALUES (1, 'Station A', 'City Center'), (2, 'Station B', 'North District'); CREATE TABLE ticket_sales (sale_id INT, station_id INT, sale_date DATE, revenue FLOAT); INSERT INTO ticket_sales (sale_id, station... | What was the total revenue for each station in January 2022? | SELECT station.name, SUM(ticket_sales.revenue) as total_revenue FROM station JOIN ticket_sales ON station.station_id = ticket_sales.station_id WHERE ticket_sales.sale_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY station.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, country TEXT, amount DECIMAL(10,2)); INSERT INTO donations (id, country, amount) VALUES (4, 'Nigeria', 25.00), (5, 'South Africa', 75.50), (6, 'Egypt', 100.00); | What was the average gift size in Africa? | SELECT AVG(amount) FROM donations WHERE country IN ('Nigeria', 'South Africa', 'Egypt'); | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_hours (labor_id INT, state VARCHAR(20), year INT, hours_worked INT); INSERT INTO labor_hours (labor_id, state, year, hours_worked) VALUES (1, 'California', 2019, 1500000), (2, 'California', 2018, 1400000), (3, 'New York', 2019, 1200000), (4, 'Texas', 2019, 1300000), (5, 'California', 2020, 1350000); | What is the minimum number of construction labor hours worked in a year in the state of California? | SELECT state, MIN(hours_worked) FROM labor_hours GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50));CREATE TABLE Investments (CustomerID INT, InvestmentType VARCHAR(10), Sector VARCHAR(10));INSERT INTO Customers VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Bob Johnson');INSERT INTO Investments VALUES (1,'Stocks','Real Estate'),(1,'Bonds','Healthcare'),(2,'Stocks... | What are the names of customers who have invested in at least three different sectors? | SELECT DISTINCT c.Name FROM Customers c INNER JOIN Investments i ON c.CustomerID = i.CustomerID GROUP BY c.CustomerID, c.Name HAVING COUNT(DISTINCT i.Sector) >= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers(supplier_id INT, supplier_name TEXT, state TEXT); INSERT INTO suppliers(supplier_id, supplier_name, state) VALUES (1, 'Eco-Friendly Fabrics', 'California'); CREATE TABLE products(product_id INT, product_name TEXT, supplier_id INT); INSERT INTO products(product_id, product_name, supplier_id) VALUE... | What is the total quantity of 'organic cotton' products sold by suppliers in California? | SELECT SUM(sales.quantity) FROM sales JOIN products ON sales.product_id = products.product_id JOIN suppliers ON products.supplier_id = suppliers.supplier_id WHERE suppliers.state = 'California' AND products.product_name LIKE '%organic cotton%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, registration_date DATE, name VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO customers (customer_id, registration_date, name) VALUES (1, '2022-01-01', 'Charlie Brown'); INSERT INTO transactions (transac... | Show the number of new customers and total transaction amount for new customers in the past week. | SELECT COUNT(DISTINCT c.customer_id) as num_new_customers, SUM(t.transaction_amount) as total_transaction_amount FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE c.registration_date BETWEEN DATEADD(day, -7, GETDATE()) AND GETDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_name TEXT, manager_name TEXT); INSERT INTO programs VALUES (1, 'Education', 'Alice Johnson'), (2, 'Health', 'Bob Brown'); | List all programs in the 'programs' table and their respective managers. | SELECT * FROM programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.medical_emergencies (id SERIAL PRIMARY KEY, city VARCHAR(255), response_time INTEGER); INSERT INTO public.medical_emergencies (city, response_time) VALUES ('Chicago', 120), ('Chicago', 150), ('Chicago', 90); | What is the average response time for medical emergencies in the city of Chicago? | SELECT AVG(response_time) FROM public.medical_emergencies WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (id INT, green_certified BOOLEAN, city VARCHAR(20), zip_code INT); INSERT INTO buildings (id, green_certified, city, zip_code) VALUES (1, true, 'Los Angeles', 90001), (2, false, 'Los Angeles', 90001), (3, true, 'Los Angeles', 90002), (4, true, 'Los Angeles', 90002), (5, false, 'Los Angeles', 9000... | Identify the top 3 zip codes with the highest number of green-certified buildings in the city of Los Angeles. | SELECT zip_code, COUNT(*) as num_green_buildings FROM buildings WHERE city = 'Los Angeles' AND green_certified = true GROUP BY zip_code ORDER BY num_green_buildings DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), state VARCHAR(255));CREATE TABLE sales (sale_id INT, dispensary_id INT, strain VARCHAR(255), quantity INT); | What are the top 5 strains sold in California dispensaries? | SELECT strain, SUM(quantity) as total_quantity FROM sales JOIN dispensaries ON sales.dispensary_id = dispensaries.dispensary_id WHERE state = 'California' GROUP BY strain ORDER BY total_quantity DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (id INT, hotel_id INT, country TEXT, views INT); INSERT INTO virtual_tours (id, hotel_id, country, views) VALUES (1, 1, 'Japan', 200), (2, 2, 'China', 350), (3, 3, 'Japan', 400), (4, 4, 'India', 150), (5, 5, 'China', 50); | List the top 3 countries with the highest virtual tour engagement in 'Asia'? | SELECT country, SUM(views) as total_views FROM virtual_tours WHERE country LIKE 'Asia%' GROUP BY country ORDER BY total_views DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), followers INT, country VARCHAR(50)); INSERT INTO users (id, name, followers, country) VALUES (1, 'Ayu Saputra', 1000, 'Indonesia'), (2, 'Budi Prasetyo', 2000, 'Indonesia'), (3, 'Dewi Santoso', 3000, 'Indonesia'); | What is the average number of followers for users in Indonesia? | SELECT AVG(followers) FROM users WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID int, Name varchar(50), Region varchar(50)); INSERT INTO Attorneys VALUES (1, 'John Smith', 'Northeast'), (2, 'Jane Doe', 'Southeast'); CREATE TABLE Billing (BillingID int, AttorneyID int, Amount decimal(10,2)); INSERT INTO Billing VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 300.00),... | What is the average billing amount per attorney by region? | SELECT A.Region, A.Name, AVG(B.Amount) as AvgBillingPerAttorney FROM Attorneys A JOIN Billing B ON A.AttorneyID = B.AttorneyID GROUP BY A.Region, A.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects(id INT, project_name VARCHAR(50), project_type VARCHAR(50), country VARCHAR(50));CREATE TABLE carbon_offsets(project_id INT, carbon_offset_value INT); | What is the average carbon offset value for each project type in the projects and carbon_offsets tables? | SELECT p.project_type, AVG(co.carbon_offset_value) AS avg_offset_value FROM projects p INNER JOIN carbon_offsets co ON p.id = co.project_id GROUP BY p.project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_conservation_scores (state VARCHAR(20), score INT); INSERT INTO water_conservation_scores (state, score) VALUES ('California', 85), ('Texas', 70), ('New York', 80), ('Florida', 75); | Which states have water conservation initiative scores above 80? | SELECT state FROM water_conservation_scores WHERE score > 80 | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_tech (subscriber_id INT, subscription_start_date DATE, technology VARCHAR(50), subscription_fee DECIMAL(10, 2)); INSERT INTO subscriber_tech (subscriber_id, subscription_start_date, technology, subscription_fee) VALUES (1, '2020-01-01', 'Fiber', 50.00), (2, '2019-06-15', 'Cable', 40.00), (3, '20... | What is the maximum subscription fee for each technology in the 'subscriber_tech' table? | SELECT technology, MAX(subscription_fee) as max_fee FROM subscriber_tech GROUP BY technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_date DATE, customer_id INT, amount DECIMAL(10,2)); INSERT INTO transactions (transaction_date, customer_id, amount) VALUES ('2022-01-01', 1, 100), ('2022-01-05', 1, 200), ('2022-01-02', 2, 150), ('2022-01-03', 2, 50), ('2021-01-04', 3, 300), ('2021-01-05', 3, 250), ('2021-01-10', ... | What is the moving average of transaction amounts for each customer over the past year? | SELECT customer_id, AVG(amount) OVER (PARTITION BY customer_id ORDER BY transaction_date ROWS BETWEEN 364 PRECEDING AND CURRENT ROW) AS moving_avg FROM transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeSalaries (EmployeeID int, Gender varchar(10), Department varchar(20), Salary decimal(10,2)); INSERT INTO EmployeeSalaries (EmployeeID, Gender, Department, Salary) VALUES (1, 'Female', 'IT', 75000.00), (2, 'Male', 'IT', 80000.00), (3, 'Non-binary', 'IT', 70000.00), (4, 'Female', 'Marketing', 72000.0... | What is the average salary for employees in the Marketing department by gender? | SELECT Department, Gender, AVG(Salary) FROM EmployeeSalaries WHERE Department = 'Marketing' GROUP BY Department, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE Sales (id INT, dispensary_id INT, revenue DECIMAL(10,2), sale_date DATE); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Washington DC'); INSERT INTO Sales (id, dispensary_id, revenue, sale_date) VALUES (1, 1, 15000, '2022-06... | What is the total revenue for each dispensary in Washington DC in the last week? | SELECT d.name, SUM(s.revenue) FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id WHERE d.state = 'Washington DC' AND s.sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND CURDATE() GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (dept_name VARCHAR(255), num_professors INT, num_female_professors INT); INSERT INTO departments (dept_name, num_professors, num_female_professors) VALUES ('Humanities', 50, 20), ('Social Sciences', 60, 25), ('Sciences', 70, 30), ('Arts', 45, 15); | Find the number of professors in the 'Arts' department. | SELECT num_professors FROM departments WHERE dept_name = 'Arts'; | gretelai_synthetic_text_to_sql |
CREATE TABLE stores (store_id INT, store_location VARCHAR(255));CREATE TABLE products (product_id INT, product_name VARCHAR(255), store_id INT, transparency_score DECIMAL(3, 2), FK_store_id REFERENCES stores(store_id));CREATE TABLE certifications (certification_id INT, certification_date DATE, FK_product_id REFERENCES ... | Calculate the average product transparency score for each store, along with the store's location and certification date. | SELECT s.store_location, AVG(p.transparency_score) as avg_transparency_score, c.certification_date FROM stores s JOIN products p ON s.store_id = p.store_id JOIN certifications c ON p.product_id = c.product_id GROUP BY s.store_id, c.certification_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE routes (route_id INT, route_name VARCHAR(255)); INSERT INTO routes (route_id, route_name) VALUES (1, 'Green Line'), (2, 'Red Line'); | Delete the 'Red Line' route | DELETE FROM routes WHERE route_name = 'Red Line'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, city VARCHAR(20), country VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id, city, country) VALUES (1, 'New York', 'USA'), (2, 'Los Angeles', 'USA'), (3, 'Chicago', 'USA'), (4, 'Paris', 'France'), (5, 'London', 'UK'), (6, 'Tokyo', 'Japan'), (7, 'Sydney', 'Australia'), (8,... | How many exhibitions were held in each country, and how many visitors attended in total? | SELECT e.country, COUNT(DISTINCT e.exhibition_id) AS num_exhibitions, SUM(v.visitor_id) AS num_visitors FROM Exhibitions e LEFT JOIN Visitors v ON e.exhibition_id = v.exhibition_id GROUP BY e.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE mature_forest (id INT, species VARCHAR(255), age INT); INSERT INTO mature_forest (id, species, age) VALUES (1, 'Pine', 25), (2, 'Oak', 30), (3, 'Maple', 28); | What is the total age of trees in the mature_forest table? | SELECT SUM(age) FROM mature_forest; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (port_id INT, port_name TEXT, country TEXT); INSERT INTO Port (port_id, port_name, country) VALUES (1, 'Port of Kolkata', 'India'); INSERT INTO Port (port_id, port_name, country) VALUES (2, 'Port of Chittagong', 'Bangladesh'); CREATE TABLE Shipment (shipment_id INT, container_id INT, port_id INT, ship... | What is the average weight of containers shipped from the Port of Kolkata to Bangladesh in the last 3 months? | SELECT AVG(c.weight) as avg_weight FROM Container c JOIN Shipment s ON c.container_id = s.container_id JOIN Port p ON s.port_id = p.port_id WHERE p.country = 'Bangladesh' AND s.shipping_date >= NOW() - INTERVAL '3 months' AND s.port_id = (SELECT port_id FROM Port WHERE port_name = 'Port of Kolkata'); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(100), is_vegan BOOLEAN, category VARCHAR(50), country VARCHAR(50)); INSERT INTO products (product_id, name, is_vegan, category, country) VALUES (1, 'Lipstick', false, 'Makeup', 'UK'); INSERT INTO products (product_id, name, is_vegan, category, country) VALUES (2, 'Mas... | Find the number of non-vegan makeup products in the UK. | SELECT COUNT(*) FROM products WHERE is_vegan = false AND category = 'Makeup' AND country = 'UK'; | 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.