context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE submersible_dives (ocean VARCHAR(255), depth FLOAT); INSERT INTO submersible_dives (ocean, depth) VALUES ('Indian Ocean', 7020.0), ('Atlantic Ocean', 10928.0); | What is the maximum depth reached by a manned submersible in the Indian Ocean? | SELECT MAX(depth) FROM submersible_dives WHERE ocean = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), JoinDate DATETIME); | Update the 'Members' table to add a new column 'MembershipStartDate' and set the value as the 'JoinDate' | ALTER TABLE Members ADD MembershipStartDate DATETIME; UPDATE Members SET MembershipStartDate = JoinDate; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (volunteer_id INT, vol_name TEXT, vol_region TEXT, hours_served INT); INSERT INTO volunteer_hours (volunteer_id, vol_name, vol_region, hours_served) VALUES (1, 'John Doe', 'South', 50), (2, 'Jane Smith', 'South', 75), (3, 'Mary Johnson', 'South', 100); | What is the average number of volunteer hours per volunteer in the South? | SELECT AVG(hours_served) as avg_hours_per_volunteer FROM volunteer_hours WHERE vol_region = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, total_donations DECIMAL(10,2), num_donations INT); | What is the total donation amount and the number of donations for each donor in the 'donors' table, sorted by total donation amount in descending order? | SELECT donor_id, donor_name, total_donations, num_donations FROM donors ORDER BY total_donations DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(20)); INSERT INTO ports (port_id, port_name) VALUES (1, 'LA'), (2, 'LB'), (3, 'HOU'); CREATE TABLE cargo (cargo_id INT, port_id INT, container_count INT); INSERT INTO cargo (cargo_id, port_id, container_count) VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 4000), (4, 3, 6000), (5, 3, 7000), (6, 3, 8000); | What is the maximum container count in a single cargo transaction for port 'HOU'? | SELECT MAX(container_count) FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'HOU'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (site_id INT, name TEXT, country TEXT, status TEXT); INSERT INTO cultural_sites VALUES (1, 'Christ the Redeemer', 'Brazil', 'Good'), (2, 'Sugarloaf Mountain', 'Brazil', 'Good'), (3, 'Iguazu Falls', 'Brazil', 'Excellent'); | Find the number of cultural heritage sites in Brazil and their respective conservation status. | SELECT country, COUNT(site_id), status FROM cultural_sites WHERE country = 'Brazil' GROUP BY status; | gretelai_synthetic_text_to_sql |
CREATE TABLE compensation (id INT, department VARCHAR(10), salary DECIMAL(10,2)); INSERT INTO compensation (id, department, salary) VALUES (1, 'mining', 75000.00), (2, 'mining', 80000.00), (3, 'geology', 70000.00); | Find the number of employees and total salary for the "mining" department in the "compensation" table | SELECT COUNT(department) as num_employees, SUM(salary) as total_salary FROM compensation WHERE department = 'mining'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_disability BOOLEAN, user_country VARCHAR(50)); INSERT INTO users (user_id, user_disability, user_country) VALUES (1, true, 'India'); | Find the top 3 countries with the highest number of users with hearing impairments in the first quarter of 2021, and display the total number of users for each. | SELECT user_country, COUNT(*) as user_count FROM users WHERE EXTRACT(MONTH FROM user_last_login) BETWEEN 1 AND 3 AND user_disability = true GROUP BY user_country ORDER BY user_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE conditions (id INT, country VARCHAR(255), condition VARCHAR(255)); INSERT INTO conditions (id, country, condition) VALUES (1, 'US', 'Depression'), (2, 'Canada', 'Anxiety'), (3, 'US', 'Anxiety'); | What is the most common mental health condition in the US? | SELECT condition, COUNT(*) FROM conditions WHERE country = 'US' GROUP BY condition ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT); | Insert new records for the following items into the Inventory table | INSERT INTO Inventory (item_id, item_name, quantity, warehouse_id) VALUES (1, 'Oranges', 50, 101), (2, 'Apples', 75, 102), (3, 'Bananas', 30, 103); | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_tech_budget (id INT, initiative_name VARCHAR(50), continent VARCHAR(50), budget DECIMAL(5,2));INSERT INTO accessible_tech_budget (id, initiative_name, continent, budget) VALUES (1, 'Screen Reader', 'Africa', 50000.00), (2, 'Voice Recognition', 'Europe', 75000.00), (3, 'Speech Synthesis', 'Americas', 100000.00); | What is the average budget for accessible technology initiatives in each continent? | SELECT continent, AVG(budget) AS avg_budget FROM accessible_tech_budget GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotel_Ratings (hotel_name VARCHAR(50), rating DECIMAL(2,1)); INSERT INTO Hotel_Ratings (hotel_name, rating) VALUES ('The Grand Hotel', 4.5), ('Executive Suites', 4.2), ('Harbor View', 4.7); | What is the average rating for each hotel in the 'Hotel_Ratings' table? | SELECT hotel_name, AVG(rating) FROM Hotel_Ratings GROUP BY hotel_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor (id INT PRIMARY KEY, name TEXT, type TEXT, company_id INT, FOREIGN KEY (company_id) REFERENCES company(id)); INSERT INTO sensor (id, name, type, company_id) VALUES (1, 'Biosensor 101', 'Biosensor', 2); INSERT INTO company (id, name, industry, location) VALUES (2, 'NewCo Bio', 'Biotechnology', 'New York'); | What is the name and type of all sensors from companies in the 'Biotechnology' industry? | SELECT c.name, s.name, s.type FROM sensor s INNER JOIN company c ON s.company_id = c.id WHERE c.industry = 'Biotechnology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE baseball_players (player_id INT, name VARCHAR(50), position VARCHAR(50), salary DECIMAL(5,2)); INSERT INTO baseball_players (player_id, name, position, salary) VALUES (1, 'James Lee', 'Pitcher', 100000.00), (2, 'Jasmine White', 'Catcher', 125000.00), (3, 'Robert Johnson', 'Outfielder', 85000.00), (4, 'Grace Brown', 'Pitcher', 110000.00); | Which positions have the highest average salary in the baseball_players table? | SELECT position, AVG(salary) as avg_salary FROM baseball_players GROUP BY position ORDER BY avg_salary DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE shrimp_farms (id INT, name TEXT, country TEXT, water_depth FLOAT); INSERT INTO shrimp_farms (id, name, country, water_depth) VALUES (1, 'Farm E', 'Indonesia', 8.2); INSERT INTO shrimp_farms (id, name, country, water_depth) VALUES (2, 'Farm F', 'Indonesia', 9.1); | What is the maximum water depth for shrimp farms in Indonesia? | SELECT MAX(water_depth) FROM shrimp_farms WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, fund_name VARCHAR(255), sector VARCHAR(255), investment_amount FLOAT); | What is the total investment made by Impact Fund 2 in the healthcare sector? | SELECT SUM(investment_amount) as total_investment FROM investments WHERE fund_name = 'Impact Fund 2' AND sector = 'healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Construction_Labor_IL (id INT, hours_worked FLOAT, state VARCHAR(255), quarter VARCHAR(255)); INSERT INTO Construction_Labor_IL (id, hours_worked, state, quarter) VALUES (1, 150, 'Illinois', 'Q1 2022'); INSERT INTO Construction_Labor_IL (id, hours_worked, state, quarter) VALUES (2, 180, 'Illinois', 'Q1 2022'); INSERT INTO Construction_Labor_IL (id, hours_worked, state, quarter) VALUES (3, 210, 'Illinois', 'Q1 2022'); | What was the minimum number of construction labor hours worked in Illinois in Q1 2022? | SELECT MIN(hours_worked) FROM Construction_Labor_IL WHERE state = 'Illinois' AND quarter = 'Q1 2022'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, country TEXT, circular_economy BOOLEAN); INSERT INTO companies (id, name, country, circular_economy) VALUES (1, 'Smart Manufacturing', 'USA', TRUE); INSERT INTO companies (id, name, country, circular_economy) VALUES (2, 'Automated Assembly', 'Germany', FALSE); INSERT INTO companies (id, name, country, circular_economy) VALUES (3, 'Digital Production', 'China', TRUE); INSERT INTO companies (id, name, country, circular_economy) VALUES (4, 'Robotic R&D', 'South Africa', FALSE); INSERT INTO companies (id, name, country, circular_economy) VALUES (5, 'Connected Construction', 'Australia', TRUE); INSERT INTO companies (id, name, country, circular_economy) VALUES (6, 'Intelligent Industry', 'Brazil', FALSE); INSERT INTO companies (id, name, country, circular_economy) VALUES (7, 'Autonomous Automotive', 'Canada', TRUE); INSERT INTO companies (id, name, country, circular_economy) VALUES (8, 'Cybernetic Creations', 'India', TRUE); | What is the total number of companies that have implemented circular economy practices in each country? | SELECT country, COUNT(*) AS company_count FROM companies WHERE circular_economy = TRUE GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO companies (id, name, industry, founders, funding) VALUES (1, 'AIforAll', 'AI', 'LGBTQ+', 1000000.0); | What is the minimum funding received by a company founded by a person from the LGBTQ+ community in the AI sector? | SELECT MIN(funding) FROM companies WHERE founders = 'LGBTQ+' AND industry = 'AI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (id INT, type VARCHAR(50), campus VARCHAR(50)); INSERT INTO Accommodations (id, type, campus) VALUES (1, 'Sign Language Interpreting', 'East Campus'), (2, 'Assistive Listening Devices', 'West Campus'); | What is the total number of accommodations provided by type and campus? | SELECT Accommodations.type, Accommodations.campus, COUNT(*) as total FROM Accommodations GROUP BY Accommodations.type, Accommodations.campus; | gretelai_synthetic_text_to_sql |
CREATE TABLE reputable_news (article_id INT, author_name VARCHAR(50), author_age INT, word_count INT, publication_date DATE);CREATE TABLE investigative_reports (article_id INT, author_name VARCHAR(50), investigation_length INT, word_count INT, publication_date DATE); | What is the total word count of articles in 'reputable_news' table and 'investigative_reports' table for each author? | SELECT author_name, SUM(word_count) FROM reputable_news GROUP BY author_name;SELECT author_name, SUM(word_count) FROM investigative_reports GROUP BY author_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Equipment_Sales(equipment_id INT, manufacturer VARCHAR(255), purchaser VARCHAR(255), sale_date DATE, quantity INT);INSERT INTO Military_Equipment_Sales(equipment_id, manufacturer, purchaser, sale_date, quantity) VALUES (1, 'Boeing', 'Japan', '2018-07-15', 5), (2, 'Boeing', 'China', '2018-08-01', 10), (3, 'Boeing', 'South Korea', '2018-09-10', 7); | What is the average quantity of military equipment sold by Boeing to Asian countries in Q3 2018, excluding sales to China? | SELECT AVG(quantity) FROM Military_Equipment_Sales WHERE manufacturer = 'Boeing' AND purchaser NOT IN ('China') AND sale_date BETWEEN '2018-07-01' AND '2018-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (id INT, station_id INT, operator VARCHAR(255), city VARCHAR(255), num_chargers INT); INSERT INTO charging_stations (id, station_id, operator, city, num_chargers) VALUES (1, 987, 'GreenCharge', 'Tokyo', 12); INSERT INTO charging_stations (id, station_id, operator, city, num_chargers) VALUES (2, 654, 'EcoPower', 'Berlin', 8); INSERT INTO charging_stations (id, station_id, operator, city, num_chargers) VALUES (3, 321, 'SmartJuice', 'Sydney', 10); | What is the maximum number of electric vehicle charging stations in Tokyo, Berlin, and Sydney? | SELECT MAX(num_chargers) FROM charging_stations WHERE city IN ('Tokyo', 'Berlin', 'Sydney'); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations_south_africa (id INT, donor_name TEXT, country TEXT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations_south_africa (id, donor_name, country, donation_amount, donation_date) VALUES (1, 'Naledi Mthethwa', 'South Africa', 150.00, '2021-10-15'); INSERT INTO donations_south_africa (id, donor_name, country, donation_amount, donation_date) VALUES (2, 'Lebohang Ndlovu', 'South Africa', 200.00, '2021-07-28'); | What is the total donation amount for non-profit organizations in South Africa for the last 6 months? | SELECT SUM(donation_amount) FROM donations_south_africa WHERE country = 'South Africa' AND donation_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE country_energy(country TEXT, sector TEXT, measure_count INT); | Which countries have implemented more than 5 climate adaptation measures in the energy sector? | SELECT country, measure_count FROM country_energy WHERE sector = 'energy' GROUP BY country HAVING measure_count > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_impact (service varchar(20), region varchar(20), score int); INSERT INTO policy_impact (service, region, score) VALUES ('Education', 'Midwest', 80), ('Healthcare', 'Midwest', 70), ('Education', 'South', 75), ('Healthcare', 'South', 85); | What is the average policy impact score for education in the Midwest, and how many policies were evaluated? | SELECT AVG(score), COUNT(*) FROM policy_impact WHERE service = 'Education' AND region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID int, Name varchar(50), Location varchar(50)); CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), ProgramID int, VolunteerDate date); INSERT INTO Programs (ProgramID, Name, Location) VALUES (1, 'Feeding America', 'USA'), (2, 'Habitat for Humanity', 'Canada'); INSERT INTO Volunteers (VolunteerID, Name, ProgramID, VolunteerDate) VALUES (1, 'Bob', 1, '2022-01-01'), (2, 'Sally', 1, '2022-02-01'), (3, 'John', 2, '2022-03-01'); | List the number of volunteers who have volunteered for each program, broken down by month and year. | SELECT P.Name, DATE_FORMAT(V.VolunteerDate, '%Y-%m') as Date, COUNT(V.VolunteerID) as Volunteers FROM Programs P JOIN Volunteers V ON P.ProgramID = V.ProgramID GROUP BY P.ProgramID, Date; | gretelai_synthetic_text_to_sql |
CREATE TABLE threats(id INT, system VARCHAR(255), threat_level INT, date DATE); | List the number of threats detected by each system, in the last month, and the percentage of total threats each system detected. | SELECT system, COUNT(*) as count, ROUND(100 * COUNT(*) / (SELECT COUNT(*) FROM threats WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH)), 2) as percent FROM threats WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY system; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (name TEXT, state TEXT, avg_income INTEGER); INSERT INTO cities (name, state, avg_income) VALUES ('City1', 'California', 60000), ('City2', 'California', 70000), ('City3', 'California', 80000), ('City4', 'California', 50000), ('City5', 'California', 90000); | Who are the top 2 cities in California with the highest average income? | SELECT name, avg_income FROM (SELECT name, avg_income, ROW_NUMBER() OVER (ORDER BY avg_income DESC) as rank FROM cities WHERE state = 'California') as subquery WHERE rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (id INT, name VARCHAR(255)); INSERT INTO strains (id, name) VALUES (1, 'Strain A'), (2, 'Strain B'), (3, 'Strain C'); CREATE TABLE inventory (dispensary_id INT, strain_id INT, quantity INT, available_date DATE); INSERT INTO inventory (dispensary_id, strain_id, quantity, available_date) VALUES (1, 1, 100, '2022-02-20'), (1, 2, 75, '2022-02-25'), (1, 3, 50, '2022-03-01'), (2, 1, 80, '2022-02-15'), (2, 3, 100, '2022-03-05'); | How many unique strains of cannabis were available in each dispensary as of March 1st, 2022? | SELECT d.name, COUNT(DISTINCT i.strain_id) as unique_strains FROM inventory i JOIN dispensaries d ON i.dispensary_id = d.id WHERE i.available_date <= '2022-03-01' GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_expeditions (id INT PRIMARY KEY, vessel VARCHAR(255)); INSERT INTO research_expeditions (id, vessel) VALUES (1, 'Ocean Explorer'), (2, 'Marine Discoverer'); CREATE TABLE expedition_vessels (id INT PRIMARY KEY, expedition VARCHAR(255), vessel VARCHAR(255)); INSERT INTO expedition_vessels (id, expedition, vessel) VALUES (1, 'Deep Sea Dive', 'Ocean Explorer'); | What are the names of the vessels that have not been used in any marine research expeditions? | SELECT v.vessel FROM expedition_vessels v LEFT JOIN research_expeditions re ON v.vessel = re.vessel WHERE re.vessel IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, department VARCHAR(20));CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2), department VARCHAR(20)); INSERT INTO factories (factory_id, department) VALUES (1, 'textile'), (2, 'metal'), (3, 'electronics'); INSERT INTO workers (worker_id, factory_id, salary, department) VALUES (1, 1, 35000, 'textile'), (2, 1, 36000, 'textile'), (3, 2, 45000, 'metal'), (4, 2, 46000, 'metal'), (5, 3, 55000, 'electronics'); | What is the total number of workers in the 'textile' department across all factories? | SELECT COUNT(w.worker_id) FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'textile'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, game_name VARCHAR(50), revenue FLOAT); INSERT INTO games (game_id, game_name, revenue) VALUES (1, 'GameA', 5000000), (2, 'GameB', 7000000), (3, 'GameC', 3000000); | What is the total revenue for each game in the 'gaming' database? | SELECT game_name, SUM(revenue) as total_revenue FROM games GROUP BY game_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(50)); CREATE TABLE healthcare_access (access_id INT, country_id INT, score INT); | What is the average healthcare access score for each country? | SELECT c.country_name, AVG(ha.score) AS average_score FROM countries c JOIN healthcare_access ha ON c.country_id = ha.country_id GROUP BY c.country_id; | gretelai_synthetic_text_to_sql |
species_sightings (species_id, location_id, sighted_date, sighted_time, sighted_by) | Add new species sighting record | INSERT INTO species_sightings (species_id, location_id, sighted_date, sighted_time, sighted_by) | gretelai_synthetic_text_to_sql |
CREATE TABLE lutetium_production (country VARCHAR(20), year INT, quantity INT); INSERT INTO lutetium_production (country, year, quantity) VALUES ('China', 2018, 800), ('USA', 2018, 750), ('Australia', 2018, 650); | Which countries produced more than 700 units of lutetium in 2018? | SELECT country FROM lutetium_production WHERE year = 2018 AND quantity > 700; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name VARCHAR(255), category VARCHAR(255), budget FLOAT, status VARCHAR(255)); INSERT INTO projects (id, name, category, budget, status) VALUES (9, 'Storm Drainage Improvement', 'Public Works', 750000.00, 'Completed'), (10, 'Sewer System Expansion', 'Public Works', 1250000.00, 'Completed'); | What is the total budget for all completed projects in the 'Transportation' and 'Water Supply' categories? | SELECT SUM(budget) FROM projects WHERE (category = 'Transportation' OR category = 'Water Supply') AND status = 'Completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO forests (id, name, hectares, country) VALUES (1, 'Black Forest', 75000.0, 'Germany'), (2, 'Congo Basin', 500000.0, 'Congo'), (3, 'Valdivian Rainforest', 95000.0, 'Chile'), (4, 'Tongass National Forest', 680000.0, 'USA'); CREATE TABLE trees (id INT, species VARCHAR(255), height FLOAT, forest_id INT); INSERT INTO trees (id, species, height, forest_id) VALUES (1, 'Norway Spruce', 50.0, 1), (2, 'African Teak', 85.0, 2), (3, 'Patagonian Cypress', 80.0, 3), (4, 'Sitka Spruce', 90.0, 4); CREATE VIEW tall_trees AS SELECT forest_id, COUNT(*) as num_tall_trees FROM trees WHERE height > 80 GROUP BY forest_id; | Find forests with at least one tree species over 80 meters tall and less than 100,000 hectares in area? | SELECT forests.name FROM forests INNER JOIN tall_trees ON forests.id = tall_trees.forest_id WHERE forests.hectares < 100000 AND num_tall_trees > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE north_america_finance (country VARCHAR(50), year INT, sector VARCHAR(50), amount FLOAT); INSERT INTO north_america_finance (country, year, sector, amount) VALUES ('Canada', 2020, 'Energy', 5000000), ('US', 2020, 'Transportation', 6000000), ('Canada', 2020, 'Agriculture', 4000000), ('US', 2020, 'Waste management', 7000000); | What is the total amount of climate finance committed to each sector in North America in 2020? | SELECT sector, SUM(amount) as total_finance FROM north_america_finance WHERE country IN ('Canada', 'US') AND year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), sustainable BOOLEAN); CREATE TABLE material (id INT PRIMARY KEY, name VARCHAR(100), supplier_id INT, price DECIMAL(5,2)); CREATE TABLE product (id INT PRIMARY KEY, name VARCHAR(100), manufacturer_id INT, price DECIMAL(5,2), sustainable BOOLEAN); CREATE TABLE manufacturer (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), sustainable BOOLEAN); CREATE VIEW sustainable_materials AS SELECT material.id, material.name, material.price, supplier.name as supplier_name FROM material INNER JOIN supplier ON material.supplier_id = supplier.id WHERE supplier.sustainable = TRUE; | What is the average price of non-sustainable materials for each supplier, showing only suppliers with more than 3 products using their materials? | SELECT supplier_name, AVG(material.price) as average_price FROM material INNER JOIN product ON material.id = product.material_id INNER JOIN supplier ON material.supplier_id = supplier.id WHERE supplier.sustainable = FALSE GROUP BY supplier.name HAVING COUNT(*) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (department TEXT, budget INT); CREATE TABLE Innovation (department TEXT, project TEXT); INSERT INTO Departments (department, budget) VALUES ('Research', 500000), ('Development', 700000), ('Testing', 300000); INSERT INTO Innovation (department, project) VALUES ('Research', 'Stealth Technology'), ('Development', 'Unmanned Aerial Vehicle'), ('Testing', 'Cyber Security'); | Show the total number of military innovation projects and their corresponding budgets for each department in the 'Departments' and 'Innovation' tables | SELECT Departments.department, COUNT(Innovation.project) AS total_projects, SUM(Departments.budget) AS total_budget FROM Departments INNER JOIN Innovation ON Departments.department = Innovation.department GROUP BY Departments.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (manufacturer_id INT, name VARCHAR(50), fair_trade_certified CHAR(1)); INSERT INTO manufacturers (manufacturer_id, name, fair_trade_certified) VALUES (1, 'ManufacturerA', 'Y'), (2, 'ManufacturerB', 'N'), (3, 'ManufacturerC', 'Y'); CREATE TABLE products (product_id INT, manufacturer_id INT, material VARCHAR(50), quantity INT); INSERT INTO products (product_id, manufacturer_id, material, quantity) VALUES (1, 1, 'organic cotton', 100), (2, 1, 'recycled polyester', 200), (3, 2, 'organic cotton', 150), (4, 2, 'hemp', 50), (5, 3, 'organic cotton', 250), (6, 3, 'recycled polyester', 300), (7, 3, 'hemp', 75); | Which 'fair trade' certified manufacturers have the highest total quantity of sustainable materials used in their products? | SELECT manufacturer_id, SUM(quantity) AS total_quantity FROM products JOIN manufacturers ON products.manufacturer_id = manufacturers.manufacturer_id WHERE manufacturers.fair_trade_certified = 'Y' GROUP BY manufacturer_id ORDER BY total_quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE malware (id INT, variant VARCHAR(255), sector VARCHAR(255), date DATE); INSERT INTO malware (id, variant, sector, date) VALUES (1, 'variant1', 'education', '2022-01-01'); INSERT INTO malware (id, variant, sector, date) VALUES (2, 'variant2', 'healthcare', '2022-01-02'); | List all unique malware variants detected in the education sector in the last 6 months. | SELECT DISTINCT variant FROM malware WHERE sector = 'education' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE HighPricedTools (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO HighPricedTools (id, name, category, price) VALUES (1, 'AccessAdapt', 'Accessibility', 800.00), (2, 'EmpowerTech', 'Accessibility', 700.00); | List the tools in the 'Accessibility' category with a price greater than 75 dollars? | SELECT name FROM HighPricedTools WHERE category = 'Accessibility' AND price > 75; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_name TEXT, country_code TEXT); CREATE TABLE vessels (name TEXT, country_code TEXT); CREATE TABLE deep_sea_vessels (name TEXT, type TEXT); | List all countries with deep-sea exploration vessels and the number of vessels they have.' | SELECT countries.country_name, COUNT(vessels.name) FROM countries JOIN vessels ON countries.country_code = vessels.country_code JOIN deep_sea_vessels ON vessels.name = deep_sea_vessels.name WHERE deep_sea_vessels.type = 'Deep Sea Exploration' GROUP BY countries.country_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE feedback (id INT, citizen_id INT, created_at DATETIME); INSERT INTO feedback (id, citizen_id, created_at) VALUES (1, 1, '2022-01-01 12:34:56'), (2, 1, '2022-01-15 10:20:34'), (3, 2, '2022-02-20 16:45:01'); | How many citizen feedback records were created by each citizen in 2022? | SELECT citizen_id, COUNT(*) as num_records FROM feedback WHERE created_at BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY citizen_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (ProjectID INT, ProjectName VARCHAR(50), StartDate DATE, EndDate DATE, Department VARCHAR(50), State VARCHAR(50)); INSERT INTO Projects (ProjectID, ProjectName, StartDate, EndDate, Department, State) VALUES (7, 'Bridge Construction', '2022-02-01', '2022-08-31', 'Civil Engineering', 'California'); CREATE TABLE LaborCosts (ProjectID INT, EmployeeID INT, Cost DECIMAL(10,2)); INSERT INTO LaborCosts (ProjectID, EmployeeID, Cost) VALUES (7, 8, 50000.00); | What is the total labor cost for 'Civil Engineering' projects in 'California'? | SELECT SUM(LaborCosts.Cost) FROM Projects INNER JOIN LaborCosts ON Projects.ProjectID = LaborCosts.ProjectID WHERE Projects.Department = 'Civil Engineering' AND Projects.State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cooking_oils (id INT, name VARCHAR(255), temperature INT); INSERT INTO cooking_oils (id, name, temperature) VALUES (1, 'Olive Oil', 180), (2, 'Canola Oil', 200); CREATE TABLE dishes (id INT, name VARCHAR(255), type VARCHAR(255), cooking_oil_id INT); INSERT INTO dishes (id, name, type, cooking_oil_id) VALUES (1, 'Vegetable Stir Fry', 'Vegetarian', 1); | What is the minimum cooking oil temperature used in preparing our vegetarian dishes? | SELECT MIN(co.temperature) FROM cooking_oils co JOIN dishes d ON co.id = d.cooking_oil_id WHERE d.type = 'Vegetarian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE destination_marketing (destination VARCHAR(255), attraction VARCHAR(255), start_date DATE, end_date DATE); | Insert a new record into the destination_marketing table with the following data: 'Australia', 'Sydney Opera House', '01-FEB-2023', '31-MAR-2023' | INSERT INTO destination_marketing (destination, attraction, start_date, end_date) VALUES ('Australia', 'Sydney Opera House', '2023-02-01', '2023-03-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE DanceEvents (id INT, year INT, visitors INT); INSERT INTO DanceEvents (id, year, visitors) VALUES (1, 2019, 300), (2, 2020, 400), (3, 2021, 500); | What is the average number of visitors to the dance events in the year 2020? | SELECT AVG(visitors) FROM DanceEvents WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (worker_id INT, worker_name VARCHAR(50), state_id INT, health_equity_training BOOLEAN); CREATE TABLE states (state_id INT, state_name VARCHAR(50)); | How many community health workers have completed health equity training in each state? | SELECT states.state_name, COUNT(*) as count FROM workers JOIN states ON workers.state_id = states.state_id WHERE health_equity_training = TRUE GROUP BY states.state_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (campaign_id INT, campaign_name VARCHAR(50), budget INT); | list all campaigns with their budgets | SELECT campaign_name, budget FROM campaigns | gretelai_synthetic_text_to_sql |
CREATE TABLE water_quality_issues (id INT, state VARCHAR(20), year INT, issue_type VARCHAR(50)); | How many water quality issues were reported in New York in the year 2020? | SELECT COUNT(*) FROM water_quality_issues WHERE state = 'New York' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, program_id VARCHAR(20), amount DECIMAL(10,2)); INSERT INTO donations (donor_id, program_id, amount) VALUES (1, 'Education', 500.00), (2, 'Health', 300.00), (3, 'Education', 250.00); | What is the total donation amount by each program? | SELECT program_id, SUM(amount) AS total_donation FROM donations GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(50)); | Which spacecraft manufacturer has built the most spacecraft? | SELECT Manufacturer, COUNT(*) FROM Spacecraft GROUP BY Manufacturer ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions_2 (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_date DATE, customer_region VARCHAR(20)); INSERT INTO customer_transactions_2 (transaction_id, customer_id, transaction_value, transaction_date, customer_region) VALUES (1, 5, 12000, '2021-08-05', 'Asia'), (2, 6, 35000, '2021-07-20', 'Asia'), (3, 7, 8000, '2021-06-10', 'Asia'); | What is the average transaction value for customers in Asia in the last month, ordered by the transaction date in ascending order? | SELECT customer_region, AVG(transaction_value) as avg_transaction_value FROM customer_transactions_2 WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND customer_region = 'Asia' GROUP BY customer_region ORDER BY MIN(transaction_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (id INT, name VARCHAR(50), price DECIMAL(5,2), vegan BOOLEAN); | Find the average price of vegan cosmetics | SELECT AVG(price) FROM cosmetics WHERE vegan = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Country varchar(50)); INSERT INTO Volunteers (VolunteerID, Name, Country) VALUES (1, 'Alice Johnson', 'USA'), (2, 'Bob Brown', 'Canada'), (3, 'Carlos Garcia', 'Mexico'), (4, 'Daniela Green', NULL); | Which countries have no registered volunteers? | SELECT v.Country FROM Volunteers v WHERE v.Country NOT IN (SELECT DISTINCT Country FROM Volunteers WHERE Country IS NOT NULL); | gretelai_synthetic_text_to_sql |
CREATE TABLE member_profiles (member_id INT, member_city VARCHAR(255), has_wearable BOOLEAN); CREATE TABLE gym_class_attendance (member_id INT, class_name VARCHAR(255)); | Find the number of members who own a wearable device and have attended a workout in LA | SELECT COUNT(DISTINCT m.member_id) FROM member_profiles m INNER JOIN gym_class_attendance gca ON m.member_id = gca.member_id WHERE m.member_city = 'LA' AND m.has_wearable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), sales_last_month INT, sales_this_month INT); INSERT INTO menu_items (menu_item_id, name, sales_last_month, sales_this_month) VALUES (1, 'Pizza', 50, 60), (2, 'Tacos', 70, 85), (3, 'Pasta', 80, 70); | Which menu items have had a 20% increase in sales since last month? | SELECT name, (sales_this_month - sales_last_month) / sales_last_month * 100 AS percentage_change FROM menu_items WHERE (sales_this_month - sales_last_month) / sales_last_month * 100 > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(50), location VARCHAR(50), is_organic BOOLEAN); INSERT INTO Suppliers (supplier_id, supplier_name, location, is_organic) VALUES (1, 'EcoFarms', 'Canada', TRUE), (2, 'GreenHarvest', 'USA', TRUE), (3, 'NatureSelect', 'Mexico', TRUE), (4, 'BioGourmet', 'Germany', TRUE), (5, 'FreshCatch', 'Peru', FALSE); | Which countries have the most organic food suppliers? | SELECT location, COUNT(*) as organic_supplier_count FROM Suppliers WHERE is_organic = TRUE GROUP BY location ORDER BY organic_supplier_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (id INT, asset_id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO violations (id, asset_id, country, type) VALUES (1, 1, 'USA', 'Security Tokens'), (2, 2, 'China', 'Security Tokens'), (3, 3, 'India', 'Utility Tokens'); CREATE TABLE assets (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO assets (id, name, type) VALUES (1, 'Asset1', 'Security Tokens'), (2, 'Asset2', 'Security Tokens'), (3, 'Asset3', 'Utility Tokens'); | What is the total number of regulatory violations by country for digital assets classified as 'Security Tokens'? | SELECT COUNT(*) FROM violations v INNER JOIN assets a ON v.asset_id = a.id WHERE a.type = 'Security Tokens'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50), birth_date DATE, country VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name, birth_date, country) VALUES (1, 'Albert Namatjira', '1902-07-28', 'Australia'); CREATE TABLE Artworks (artwork_id INT, title VARCHAR(50), year_made INT, artist_id INT, price FLOAT); INSERT INTO Artworks (artwork_id, title, year_made, artist_id, price) VALUES (1, 'Mount Hermannsburg', 1947, 1, 500.0); | What is the total price of artworks created by Indigenous Australian artists? | SELECT SUM(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id WHERE Artists.country = 'Australia' AND Artists.artist_name = 'Albert Namatjira'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (name VARCHAR(255), input_type VARCHAR(255)); INSERT INTO creative_ai (name, input_type) VALUES ('GANs', 'image'), ('DeepDream', 'image'), ('StyleTransfer', 'image'); | Display creative AI applications that use image as input. | SELECT name FROM creative_ai WHERE input_type = 'image' | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), LaunchDate DATETIME, CountryOfOrigin VARCHAR(50), Weight INT); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, CountryOfOrigin, Weight) VALUES (1, 'Sat1', '2020-01-01', 'India', 500), (2, 'Sat2', '2019-05-15', 'India', 700); | What is the total weight of all satellites launched by India? | SELECT SUM(Weight) FROM Satellites WHERE CountryOfOrigin = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255)); CREATE TABLE streams (id INT, artist_id INT, platform VARCHAR(255), streams BIGINT); INSERT INTO artists VALUES (1, 'Taylor Swift'); INSERT INTO streams VALUES (1, 1, 'Spotify', 10000000); | Which artists have the most streams on the 'Spotify' platform? | SELECT a.name, SUM(s.streams) as total_streams FROM streams s JOIN artists a ON s.artist_id = a.id WHERE s.platform = 'Spotify' GROUP BY a.name ORDER BY total_streams DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Schools (id INT, name VARCHAR(20)); INSERT INTO Schools (id, name) VALUES (1, 'Elementary'), (2, 'High School'), (3, 'Middle School'); CREATE TABLE StudentMentalHealth (student_id INT, school_id INT, score INT); INSERT INTO StudentMentalHealth (student_id, school_id, score) VALUES (1, 1, 80), (2, 1, 90), (3, 2, 70), (4, 3, 85), (5, 1, 95); | What is the average mental health score of students in 'Elementary' schools? | SELECT AVG(smh.score) FROM StudentMentalHealth smh JOIN Schools s ON smh.school_id = s.id WHERE s.name = 'Elementary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_bases (id INT, base_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE intelligence_operations (id INT, operation_name VARCHAR(50), base_id INT); INSERT INTO military_bases (id, base_name, country) VALUES (1, 'Fort Bragg', 'USA'), (2, 'Camp Pendleton', 'USA'), (3, 'Canberra Deep Space Communication Complex', 'Australia'); INSERT INTO intelligence_operations (id, operation_name, base_id) VALUES (1, 'Operation Desert Storm', 1), (2, 'Operation Enduring Freedom', 2), (3, 'Operation Slipper', 3); | List all military bases, their countries, and connected intelligence operations | SELECT military_bases.base_name, military_bases.country, intelligence_operations.operation_name FROM military_bases INNER JOIN intelligence_operations ON military_bases.id = intelligence_operations.base_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE finance_distribution (group VARCHAR(255), funding FLOAT); | What is the percentage of climate finance allocated to the Indigenous communities? | SELECT (SUM(CASE WHEN group = 'Indigenous communities' THEN funding ELSE 0 END) / SUM(funding)) * 100 FROM finance_distribution; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (country_code CHAR(3), year INT, volume INT); INSERT INTO timber_production (country_code, year, volume) VALUES ('CAN', 2022, 15000), ('CAN', 2011, 13000), ('USA', 2022, 20000), ('USA', 2011, 16000), ('MEX', 2022, 8000), ('MEX', 2011, 7000); | Delete records of timber production for the United States before 2010 | DELETE FROM timber_production WHERE country_code = 'USA' AND year < 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_conservation_orgs (org_name TEXT, country TEXT, year_founded INTEGER); INSERT INTO marine_conservation_orgs (org_name, country, year_founded) VALUES ('Ocean Conservancy', 'USA', 1972), ('Marine Conservation Society', 'UK', 1983), ('Coral Reef Alliance', 'USA', 1994); | How many marine conservation organizations were founded in the year 2000? | SELECT COUNT(*) FROM marine_conservation_orgs WHERE year_founded = 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (id INT, country VARCHAR(50), name VARCHAR(50), capacity FLOAT); INSERT INTO wind_farms (id, country, name, capacity) VALUES (1, 'Germany', 'Windpark Nordsee', 320.0), (2, 'Spain', 'Parque Eolico Sierra Costera', 300.0); | What is the total installed capacity of wind farms in GW, grouped by country? | SELECT country, SUM(capacity) FROM wind_farms GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE game_scores_data (game_id INT, genre VARCHAR(255), score INT); INSERT INTO game_scores_data VALUES (1, 'FPS', 90), (2, 'RPG', 85), (3, 'Strategy', 80), (4, 'FPS', 82), (5, 'Simulation', 95), (6, 'Adventure', 98); | What is the highest scoring game by genre in the 'game_scores_data' schema? | SELECT g.genre, MAX(g.score) AS highest_score_by_genre FROM game_scores_data g GROUP BY g.genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE CargoShips(id INT, name VARCHAR(50), flag VARCHAR(50), capacity INT); CREATE TABLE Fleet(id INT, name VARCHAR(50), manager VARCHAR(50)); ALTER TABLE CargoShips ADD COLUMN fleet_id INT; UPDATE CargoShips SET fleet_id = 1 WHERE id = 1; INSERT INTO CargoShips VALUES (2, 'Ocean Giant', 'Marshall Islands', 200000); UPDATE CargoShips SET fleet_id = 2 WHERE id = 2; INSERT INTO Fleet VALUES (2, 'XYZ Shipping', 'Jane Smith'); | Who is the manager of the fleet that contains the cargo ship with the highest capacity? | SELECT Fleet.manager FROM Fleet INNER JOIN (SELECT fleet_id, MAX(capacity) as max_capacity FROM CargoShips GROUP BY fleet_id) AS max_capacities ON Fleet.id = max_capacities.fleet_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_id INT, sale_date DATE, sales INT, product_type VARCHAR(50), region VARCHAR(50)); INSERT INTO sales (product_id, sale_date, sales, product_type, region) VALUES (1, '2021-01-01', 500, 'Organic Skincare', 'Canada'), (2, '2021-01-01', 800, 'Natural Makeup', 'Canada'); | What is the average monthly sales of organic skincare products in Canada? | SELECT AVG(sales) AS avg_monthly_sales FROM sales WHERE product_type = 'Organic Skincare' AND region = 'Canada' AND sale_date BETWEEN DATEADD(month, -12, CURRENT_DATE) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_professional_development (teacher_id INT, professional_development_score INT); | Insert records into teacher professional development table | INSERT INTO teacher_professional_development (teacher_id, professional_development_score) VALUES (1, 90), (2, 85), (3, 95); | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_count (id INT, country VARCHAR(50), heritage_site VARCHAR(50)); INSERT INTO heritage_count (id, country, heritage_site) VALUES (1, 'USA', 'Mesa Verde'); INSERT INTO heritage_count (id, country, heritage_site) VALUES (2, 'Ecuador', 'Galapagos Islands'); | Who are the top 3 countries with the most heritage sites? | SELECT country, COUNT(heritage_site) FROM heritage_count GROUP BY country ORDER BY COUNT(heritage_site) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor (state VARCHAR(2), labor_cost NUMERIC); INSERT INTO construction_labor (state, labor_cost) VALUES ('WA', 45.5), ('OR', 38.3), ('CA', 52.1); | List the top 3 states with the highest average labor cost | SELECT state, AVG(labor_cost) FROM construction_labor GROUP BY state ORDER BY AVG(labor_cost) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT, city VARCHAR(50)); INSERT INTO users (id, name, age, city) VALUES (1, 'Ravi', 25, 'Mumbai'); INSERT INTO users (id, name, age, city) VALUES (2, 'Seetha', 30, 'Delhi'); INSERT INTO users (id, name, age, city) VALUES (3, 'Kumar', 35, 'Mumbai'); | What is the total number of users from Mumbai and Delhi? | SELECT city, COUNT(*) as total FROM users WHERE city IN ('Mumbai', 'Delhi') GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerRatings (PlayerID INT, GameID INT, Rating FLOAT); INSERT INTO PlayerRatings (PlayerID, GameID, Rating) VALUES (1, 1, 8.5), (1, 2, 9.2), (2, 1, 7.8), (2, 2, 8.9), (3, 1, 8.1), (3, 2, 9.0); | What is the maximum rating given to game 2? | SELECT MAX(Rating) FROM PlayerRatings WHERE GameID = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, GameName VARCHAR(20), Playtime FLOAT, Rank VARCHAR(10)); INSERT INTO Players (PlayerID, GameName, Playtime, Rank) VALUES (1, 'Galactic Conquest', 55.3, 'Gold'), (2, 'Galactic Conquest', 76.8, 'Platinum'), (3, 'Galactic Conquest', 34.9, 'Bronze'); | What is the average playtime of all players who achieved a rank of Platinum or higher in the game "Galactic Conquest"? | SELECT AVG(Playtime) FROM Players WHERE GameName = 'Galactic Conquest' AND Rank IN ('Platinum', 'Diamond', 'Master'); | gretelai_synthetic_text_to_sql |
CREATE TABLE outreach_events (id INT PRIMARY KEY, site_id INT, event_type VARCHAR(50), date DATE, attendance INT); | Insert new public outreach event for site 789 | INSERT INTO outreach_events (id, site_id, event_type, date, attendance) VALUES (1, 789, 'Public lecture', '2022-08-15', 30); | gretelai_synthetic_text_to_sql |
CREATE TABLE resource_extraction (id INT, site_id INT, extraction_date DATE, quantity INT); INSERT INTO resource_extraction (id, site_id, extraction_date, quantity) VALUES (1, 1, '2022-01-01', 100), (2, 1, '2022-02-01', 120), (3, 1, '2022-03-01', 150); | What is the total number of resources extracted by month? | SELECT EXTRACT(MONTH FROM extraction_date) AS month, SUM(quantity) FROM resource_extraction GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(255), team VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Events VALUES (1, 'Game 1', 'MLB', 150.00), (2, 'Game 2', 'MLB', 200.00), (3, 'Game 3', 'MLB', 175.00); | What are the top 3 expensive events hosted by 'MLB' teams? | SELECT event_name, price FROM Events WHERE team = 'MLB' ORDER BY price DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProtectedSpecies(species_id INT, species_name TEXT, region TEXT); INSERT INTO ProtectedSpecies (species_id, species_name, region) VALUES (201, 'Frog', 'Region E'), (202, 'Hawk', 'Region F'), (203, 'Squirrel', 'Region F'); | Which regions have no protected species with an ID greater than 200? | SELECT region FROM ProtectedSpecies WHERE species_id > 200 GROUP BY region HAVING COUNT(*) = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Loans (Id INT, Lender VARCHAR(20), Location VARCHAR(20), LoanType VARCHAR(20), LoanAmount DECIMAL(10,2), LoanYear INT); INSERT INTO Loans (Id, Lender, Location, LoanType, LoanAmount, LoanYear) VALUES (1, 'LenderA', 'Africa', 'Socially Responsible', 5000.00, 2022), (2, 'LenderB', 'Africa', 'Socially Responsible', 7000.00, 2022), (3, 'LenderC', 'Africa', 'Socially Responsible', 6000.00, 2022); | List the top 3 socially responsible lenders by total loan amount in Africa, for loans issued in 2022, in descending order. | SELECT Lender, SUM(LoanAmount) AS Total_Loan_Amount FROM Loans WHERE LoanType = 'Socially Responsible' AND LoanYear = 2022 GROUP BY Lender ORDER BY Total_Loan_Amount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_id INTEGER, title TEXT, artist_name TEXT, genre TEXT); INSERT INTO Artworks (artwork_id, title, artist_name, genre) VALUES (1, 'Artwork 1', 'Alice', 'Contemporary Art'), (2, 'Artwork 2', 'Bob', 'Contemporary Art'), (3, 'Artwork 3', 'Charlotte', 'Contemporary Art'), (4, 'Artwork 4', 'Dave', 'Contemporary Art'); | Who is the most prolific artist in the 'Contemporary Art' genre? | SELECT artist_name, COUNT(*) as count FROM Artworks WHERE genre = 'Contemporary Art' GROUP BY artist_name ORDER BY count DESC LIMIT 1 | gretelai_synthetic_text_to_sql |
CREATE TABLE patents (patent_id INTEGER, country TEXT, patent_date DATE); INSERT INTO patents VALUES (1, 'USA', '2022-01-01'), (2, 'Germany', '2021-12-31'); | What are the top 5 countries with the most agricultural automation patents in the past 5 years? | SELECT country, COUNT(patent_id) as patent_count FROM patents WHERE patent_date >= CURDATE() - INTERVAL 5 YEAR GROUP BY country ORDER BY patent_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, visual_impairment BOOLEAN, department VARCHAR(255)); INSERT INTO students (id, visual_impairment, department) VALUES (1, true, 'science'), (2, false, 'engineering'), (3, true, 'science'), (4, true, 'mathematics'), (5, false, 'science'); CREATE TABLE accommodations (id INT, student_id INT, year INT); INSERT INTO accommodations (id, student_id, year) VALUES (1, 1, 2018), (2, 1, 2019), (3, 3, 2018), (4, 3, 2019), (5, 3, 2020), (6, 4, 2020); | How many students with visual impairments received accommodations in each department in 2020? | SELECT s.department, COUNT(*) as accommodations FROM students s INNER JOIN accommodations a ON s.id = a.student_id WHERE s.visual_impairment = true AND a.year = 2020 GROUP BY s.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Building_Permits (Permit_ID INT, Permit_Number VARCHAR(255), State VARCHAR(255), Project_Type VARCHAR(255), Issue_Date DATE); INSERT INTO Building_Permits (Permit_ID, Permit_Number, State, Project_Type, Issue_Date) VALUES (1, '12345', 'California', 'Green Building', '2017-01-01'), (2, '67890', 'Texas', 'Green Building', '2018-01-01'), (3, '111213', 'California', 'Conventional Building', '2020-01-01'); | What is the number of building permits issued in the United States for green building projects in the last 5 years? | SELECT COUNT(*) FROM Building_Permits WHERE Project_Type = 'Green Building' AND Issue_Date >= DATEADD(year, -5, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE support_table (donor VARCHAR(20), donation_amount INT, donor_category VARCHAR(20)); INSERT INTO support_table (donor, donation_amount, donor_category) VALUES ('John Doe', 500, 'young_donors'); | What was the total amount donated by the 'young_donors' in 'support_table'? | SELECT SUM(donation_amount) FROM support_table WHERE donor_category = 'young_donors'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50), account_balance DECIMAL(10,2)); INSERT INTO clients (client_id, name, region, account_balance) VALUES (1, 'John Doe', 'West', 30000.00), (2, 'Jane Smith', 'East', 20000.00); | Which clients in the West region have an account balance greater than 25000? | SELECT client_id, name FROM clients WHERE region = 'West' AND account_balance > 25000; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2), sale_date DATE, is_circular_supply BOOLEAN, country TEXT); INSERT INTO sales (sale_id, product_id, price, sale_date, is_circular_supply, country) VALUES (1, 1, 39.99, '2022-02-12', true, 'Germany'); | What is the total revenue generated from selling circular supply chain products in Europe? | SELECT SUM(price) FROM sales WHERE is_circular_supply = true AND country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_development (id INT, worker_id INT, country VARCHAR(50), program VARCHAR(50), date DATE); INSERT INTO workforce_development (id, worker_id, country, program, date) VALUES (1, 1, 'United States', 'SQL Training', '2021-02-01'), (2, 2, 'Canada', 'AI Bootcamp', '2021-03-01'), (3, 3, 'Mexico', 'Data Science Course', '2021-11-01'); | List the total number of workers trained in workforce development programs in each country for 2021. | SELECT country, COUNT(DISTINCT worker_id) as num_workers_trained FROM workforce_development WHERE DATE_FORMAT(date, '%Y') = '2021' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Humanitarian_Assistance (Event_ID INT PRIMARY KEY, Quarter INT, Year INT); | Show the number of humanitarian assistance events per quarter in 2022. | SELECT Quarter, COUNT(*) FROM Humanitarian_Assistance WHERE Year = 2022 GROUP BY Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE MaterialUsage (BrandID INT, SustainableMaterial VARCHAR(50)); | Which sustainable materials are used by the most fashion brands, and how many fashion brands use each sustainable material? | SELECT TS.SustainableMaterial, COUNT(MU.BrandID) AS NumberOfBrandsUsingMaterial FROM TextileSuppliers TS INNER JOIN MaterialUsage MU ON TS.SustainableMaterial = MU.SustainableMaterial GROUP BY TS.SustainableMaterial ORDER BY NumberOfBrandsUsingMaterial DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), capacity_mw INT); INSERT INTO renewable_energy_projects (id, project_name, location, capacity_mw) VALUES (1, 'Wind Farm XYZ', 'Texas', 500); INSERT INTO renewable_energy_projects (id, project_name, location, capacity_mw) VALUES (2, 'Solar Park ABC', 'California', 800); INSERT INTO renewable_energy_projects (id, project_name, location, capacity_mw) VALUES (4, 'Hydro Plant DEF', 'Norway', 900); | Where are the renewable energy projects located with a capacity greater than 700 MW? | SELECT location FROM renewable_energy_projects WHERE capacity_mw > 700; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_loans (id INT, loan_date DATE, amount FLOAT); INSERT INTO socially_responsible_loans (id, loan_date, amount) VALUES (1, '2021-01-01', 5000), (2, '2021-02-01', 7000), (3, '2021-03-01', 8000), (4, '2021-01-01', 6000), (5, '2021-02-01', 9000); | What is the number of socially responsible loans issued per month? | SELECT DATE_FORMAT(loan_date, '%Y-%m') as month, COUNT(*) as loans_issued FROM socially_responsible_loans GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name TEXT, location TEXT, budget INT); CREATE TABLE volunteer_hours (id INT, volunteer_id INT, program_id INT, hours INT); | Show the total budget for each program, the number of volunteers who have contributed to the program, and the total number of hours contributed. | SELECT programs.name as program_name, SUM(volunteer_hours.hours) as total_hours, COUNT(DISTINCT volunteers.id) as num_volunteers, programs.budget as budget FROM programs LEFT JOIN volunteer_hours ON programs.id = volunteer_hours.program_id LEFT JOIN volunteers ON volunteer_hours.volunteer_id = volunteers.id GROUP BY programs.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, publication_date DATE); INSERT INTO articles (id, publication_date) VALUES | How many articles were published per month in 2021? | SELECT MONTH(publication_date) AS month, COUNT(*) as num_articles FROM articles WHERE YEAR(publication_date) = 2021 GROUP BY month | 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.