context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE wind_projects (project_id INT, project_name VARCHAR(255), state VARCHAR(255), installed_capacity FLOAT); | What is the total installed capacity (in MW) of wind power projects in the state of California? | SELECT SUM(installed_capacity) FROM wind_projects WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sustainable_Buildings (id INT, project_cost FLOAT, state VARCHAR(255), quarter VARCHAR(255)); INSERT INTO Sustainable_Buildings (id, project_cost, state, quarter) VALUES (1, 500000, 'Texas', 'Q1 2021'); INSERT INTO Sustainable_Buildings (id, project_cost, state, quarter) VALUES (2, 750000, 'Texas', 'Q1 2021'); | What was the average project cost for sustainable buildings in Texas in Q1 2021? | SELECT AVG(project_cost) FROM Sustainable_Buildings WHERE state = 'Texas' AND quarter = 'Q1 2021'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure (id INT, project_name TEXT, location TEXT, project_type TEXT); INSERT INTO infrastructure (id, project_name, location, project_type) VALUES (1, 'Smart City 1', 'Singapore', 'smart_city'), (2, 'Green Building 1', 'Japan', 'green_building'); | How many smart city projects are there in the 'infrastructure' table for the 'Asia' region? | SELECT COUNT(*) FROM infrastructure WHERE location LIKE '%Asia%' AND project_type = 'smart_city'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_violations (id INT, employee_id INT, department VARCHAR(255), violation_count INT); INSERT INTO policy_violations (id, employee_id, department, violation_count) VALUES (1, 444, 'engineering', 3), (2, 555, 'engineering', 2), (3, 666, 'engineering', 1), (4, 777, 'engineering', 5), (5, 888, 'engineering', 2); | What is the total number of policy violations by employees in the engineering department? | SELECT employee_id, SUM(violation_count) as total_violations FROM policy_violations WHERE department = 'engineering' GROUP BY employee_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE retail_stores(id INT, store_name VARCHAR(50), store_location VARCHAR(50)); CREATE TABLE sustainable_garments(id INT, garment_id INT, garment_name VARCHAR(50), sustainability_rating FLOAT); INSERT INTO retail_stores(id, store_name, store_location) VALUES (1, 'Store A', 'USA'), (2, 'Store B', 'Canada'); INSERT INTO sustainable_garments(id, garment_id, garment_name, sustainability_rating) VALUES (1, 1, 'T-Shirt', 0.8), (2, 2, 'Jeans', 0.9); | List all retail stores in the US that sell sustainable garments. | SELECT retail_stores.store_name FROM retail_stores INNER JOIN sustainable_garments ON retail_stores.id = sustainable_garments.id WHERE retail_stores.store_location = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (id INT, chapter VARCHAR(255), join_date DATE); INSERT INTO union_members (id, chapter, join_date) VALUES (1, 'NYC', '2022-09-01'), (2, 'LA', '2022-11-15'), (3, 'NYC', '2022-10-06'), (4, 'LA', '2022-08-20'), (5, 'NYC', '2022-05-12'), (6, 'LA', '2022-12-03'); | For each union chapter, find the number of members who have joined in the last 6 months, ranked by the most recent join date. | SELECT chapter, ROW_NUMBER() OVER (ORDER BY join_date DESC) as rank, join_date FROM union_members WHERE join_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY chapter ORDER BY rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Gender VARCHAR(10), Age INT, Country VARCHAR(50), PreferredGenre VARCHAR(20)); INSERT INTO Players (PlayerID, Gender, Age, Country, PreferredGenre) VALUES (10, 'Female', 24, 'Japan', 'Puzzle'); INSERT INTO Players (PlayerID, Gender, Age, Country, PreferredGenre) VALUES (11, 'Female', 27, 'South Korea', 'Puzzle'); | What is the total number of female players who prefer puzzle games and are located in Asia? | SELECT COUNT(*) FROM Players WHERE Gender = 'Female' AND PreferredGenre = 'Puzzle' AND Country IN ('Japan', 'South Korea', 'China', 'India'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Dishes (DishID INT, DishName VARCHAR(50), Category VARCHAR(50), OrganicIngredientQTY INT); INSERT INTO Dishes (DishID, DishName, Category, OrganicIngredientQTY) VALUES (1, 'Veggie Pizza', 'Pizza', 500), (2, 'Margherita Pizza', 'Pizza', 300), (3, 'Chicken Caesar Salad', 'Salad', 250), (4, 'Garden Salad', 'Salad', 400); | What is the total quantity of organic ingredients used in each dish category? | SELECT Category, SUM(OrganicIngredientQTY) as TotalOrganicIngredientQTY FROM Dishes GROUP BY Category; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, sale_date DATE, item_id INT, quantity INT); INSERT INTO sales (sale_id, sale_date, item_id, quantity) VALUES (1, '2022-01-01', 1, 10), (2, '2022-01-02', 2, 5), (3, '2022-02-01', 3, 8), (4, '2022-02-02', 1, 15), (5, '2022-03-01', 2, 7), (6, '2022-03-02', 3, 12); | How many items were sold in each month for the last six months? | SELECT EXTRACT(MONTH FROM sale_date) AS month, SUM(quantity) AS total_sold FROM sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE counties(id INT, name TEXT, state TEXT); INSERT INTO counties VALUES (1, 'County A', 'California'); INSERT INTO counties VALUES (2, 'County B', 'California'); INSERT INTO counties VALUES (3, 'County C', 'California'); CREATE TABLE libraries(id INT, county_id INT, name TEXT, total_books INT); INSERT INTO libraries VALUES (1, 1, 'Library A', 10000); INSERT INTO libraries VALUES (2, 1, 'Library B', 12000); INSERT INTO libraries VALUES (3, 2, 'Library C', 14000); INSERT INTO libraries VALUES (4, 3, 'Library D', 16000); | What is the number of public libraries in each county in the state of California, including their names and total book collections? | SELECT c.name as county_name, l.name as library_name, COUNT(*) as library_count, SUM(l.total_books) as total_books FROM counties c JOIN libraries l ON c.id = l.county_id WHERE c.state = 'California' GROUP BY c.name, l.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_buildings (id INT, state VARCHAR(2), cost DECIMAL(5,2)); INSERT INTO sustainable_buildings (id, state, cost) VALUES (1, 'TX', 150.50), (2, 'CA', 200.75), (3, 'TX', 175.20); | Determine the minimum labor cost per square foot for sustainable building projects. | SELECT MIN(cost) FROM sustainable_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE RD_expenditures2 (expenditure_id INT, drug_name TEXT, amount FLOAT, manufacturer TEXT); INSERT INTO RD_expenditures2 (expenditure_id, drug_name, amount, manufacturer) VALUES (1, 'DrugK', 3000000, 'Manufacturer3'), (2, 'DrugL', 3500000, 'Manufacturer3'); | What is the maximum R&D expenditure for drugs by manufacturer? | SELECT manufacturer, MAX(amount) as max_expenditure FROM RD_expenditures2 GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE HaircareProducts (product_id INT, product_name VARCHAR(255), price DECIMAL(5,2), is_vegan BOOLEAN, country VARCHAR(50)); | Update the price of all vegan haircare products sold in Japan to be 10% higher. | UPDATE HaircareProducts SET price = price * 1.1 WHERE is_vegan = TRUE AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_visitors (id INT, exhibition_name VARCHAR(50), visitors INT, visit_date DATE); INSERT INTO daily_visitors (id, exhibition_name, visitors, visit_date) VALUES (1, 'Monet and the Impressionists', 200, '2022-01-01'); INSERT INTO daily_visitors (id, exhibition_name, visitors, visit_date) VALUES (2, 'Monet and the Impressionists', 250, '2022-02-15'); | What is the maximum number of visitors in a single day for the exhibition 'Monet and the Impressionists'? | SELECT MAX(visitors) FROM daily_visitors WHERE exhibition_name = 'Monet and the Impressionists'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50)); INSERT INTO athletes (athlete_id, name) VALUES (1, 'John Doe'); CREATE TABLE teams (team_id INT, name VARCHAR(50)); INSERT INTO teams (team_id, name) VALUES (1, 'Los Angeles Lakers'); | Which athletes in the 'Athletes' table have the same name as a team in the 'Teams' table? | SELECT a.name FROM athletes a INNER JOIN teams t ON a.name = t.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, program VARCHAR(255), hours INT); INSERT INTO volunteers (id, program, hours) VALUES (1, 'Animal Welfare', 20), (2, 'Education', 30); | What is the total number of volunteers and their combined hours for the 'Animal Welfare' program? | SELECT program, COUNT(*), SUM(hours) FROM volunteers WHERE program = 'Animal Welfare'; | gretelai_synthetic_text_to_sql |
CREATE VIEW species_summary AS SELECT species, population, region FROM ocean_species; | Display the species, population, and region information | SELECT * FROM species_summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name VARCHAR(50), country VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, country, funding) VALUES (1, 'StartupA', 'India', 7000000); INSERT INTO startups (id, name, country, funding) VALUES (2, 'StartupB', 'India', 3000000); INSERT INTO startups (id, name, country, funding) VALUES (3, 'StartupC', 'India', 6000000); | Which biotech startups in India have received funding over 5000000? | SELECT name FROM startups WHERE country = 'India' AND funding > 5000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleets (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); | Delete a fleet from the "fleets" table | DELETE FROM fleets WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE FlightSafety ( id INT, airline_company VARCHAR(255), safety_record INT); INSERT INTO FlightSafety (id, airline_company, safety_record) VALUES (1, 'AirlineA', 95), (2, 'AirlineB', 92), (3, 'AirlineA', 97), (4, 'AirlineC', 89), (5, 'AirlineB', 93); | Find the average flight safety record for each airline company. | SELECT airline_company, AVG(safety_record) OVER (PARTITION BY airline_company) AS avg_safety_record FROM FlightSafety; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Program TEXT, State TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Program, State) VALUES (1, 'Jane Smith', 'Feeding America', 'NY'); | Find the number of volunteers who participated in programs in both NY and CA? | SELECT COUNT(DISTINCT VolunteerID) FROM Volunteers WHERE State IN ('NY', 'CA') GROUP BY VolunteerID HAVING COUNT(DISTINCT State) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Strains (strain_id INT, strain_type TEXT, thc_percentage DECIMAL(4,2)); | List the names of all indica strains with an average THC percentage greater than 15%. | SELECT strain_name FROM Strains WHERE strain_type = 'indica' GROUP BY strain_name HAVING AVG(thc_percentage) > 15.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE Articles (id INT, title VARCHAR(255), publish_date DATE); INSERT INTO Articles (id, title, publish_date) VALUES (1, 'Article 1', '2016-01-15'), (2, 'Article 2', '2016-02-10'), (3, 'Article 3', '2016-03-05'), (4, 'Article 4', '2016-04-01'), (5, 'Article 5', '2016-05-15'), (6, 'Article 6', '2016-06-10'), (7, 'Article 7', '2016-07-05'), (8, 'Article 8', '2016-08-01'), (9, 'Article 9', '2016-09-15'), (10, 'Article 10', '2016-10-10'), (11, 'Article 11', '2016-11-05'), (12, 'Article 12', '2016-12-01'); | How many articles were published per month in 2016? | SELECT MONTH(publish_date) AS Month, COUNT(*) AS Articles_Count FROM Articles WHERE YEAR(publish_date) = 2016 GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location VARCHAR, level FLOAT); INSERT INTO ocean_acidification (location, level) VALUES ('Atlantic Ocean', 7.8), ('Pacific Ocean', 8.2); | What is the minimum ocean acidification level in the Atlantic Ocean? | SELECT MIN(level) FROM ocean_acidification WHERE location = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, company_id INT, investment_date DATE, amount FLOAT); INSERT INTO investments (id, company_id, investment_date, amount) VALUES (1, 4, '2021-02-14', 250000.0), (2, 2, '2021-05-27', 500000.0), (3, 5, '2020-12-30', 750000.0); | How many investments were made in the healthcare sector in 2021? | SELECT COUNT(*) FROM investments WHERE investment_date >= '2021-01-01' AND investment_date < '2022-01-01' AND company_id IN (SELECT id FROM companies WHERE sector = 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_virtual_tours(date DATE, site_id INT, revenue INT); INSERT INTO daily_virtual_tours (date, site_id, revenue) VALUES ('2021-12-12', 1, 600), ('2021-12-12', 2, 800), ('2021-12-13', 1, 700); CREATE TABLE virtual_tour_sites(site_id INT, site_name TEXT, country TEXT); INSERT INTO virtual_tour_sites (site_id, site_name, country) VALUES (1, 'Masai Mara National Reserve', 'Kenya'), (2, 'Amboseli National Park', 'Kenya'); | What was the daily revenue of virtual tours in Kenya on Jamhuri Day? | SELECT SUM(revenue) FROM daily_virtual_tours JOIN virtual_tour_sites ON daily_virtual_tours.site_id = virtual_tour_sites.site_id WHERE virtual_tour_sites.country = 'Kenya' AND date = '2021-12-12'; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, usage FLOAT, region VARCHAR(255)); INSERT INTO broadband_subscribers (subscriber_id, usage, region) VALUES (1, 80.5, 'North'), (2, 70.2, 'North'), (3, 65.1, 'South'), (4, 95.3, 'East'), (5, 55.0, 'West'); | Find broadband subscribers with usage in the top 10% for each region, ordered by region and then by usage in descending order. | SELECT region, subscriber_id, usage FROM (SELECT region, subscriber_id, usage, NTILE(10) OVER (PARTITION BY region ORDER BY usage DESC) as usage_tile FROM broadband_subscribers) t WHERE t.usage_tile = 1 ORDER BY region, usage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_demographics (player_id INT, age INT, gender VARCHAR(50)); INSERT INTO player_demographics (player_id, age, gender) VALUES (1, 25, 'Male'), (2, 35, 'Female'), (3, 17, 'Female'); | Delete records in the "player_demographics" table where the "age" is less than 18 | DELETE FROM player_demographics WHERE age < 18; | gretelai_synthetic_text_to_sql |
CREATE TABLE district_stats (district_id INT, cases INT); INSERT INTO district_stats (district_id, cases) VALUES (1, 12), (2, 18), (3, 9), (4, 15), (5, 10), (6, 14); | What is the standard deviation of restorative justice cases per district? | SELECT d.district_id, STDEV(d.cases) AS std_dev_cases FROM district_stats d GROUP BY d.district_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(50), coowners INT, cost INT); INSERT INTO properties VALUES (1, 'CityX', 2, 500000); INSERT INTO properties VALUES (2, 'CityX', 1, 400000); INSERT INTO properties VALUES (3, 'CityY', 3, 700000); INSERT INTO properties VALUES (4, 'CityY', 1, 600000); | Find the average house cost in each city, excluding properties with co-owners | SELECT city, AVG(cost) as avg_cost FROM properties WHERE coowners = 1 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleets (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); | Insert a new fleet into the "fleets" table | INSERT INTO fleets (id, name, country) VALUES (1, 'Pacific Fleet', 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_expenditures (country VARCHAR(255), year INT, expenditure INT); | Display the military expenditures of each country and the yearly change in expenditure, along with the overall percentage change since the first year of data. | SELECT country, year, expenditure, (expenditure - LAG(expenditure) OVER (PARTITION BY country ORDER BY year)) as yearly_change, ((expenditure - FIRST_VALUE(expenditure) OVER (PARTITION BY country ORDER BY year)) * 100.0 / FIRST_VALUE(expenditure) OVER (PARTITION BY country ORDER BY year)) as percentage_change FROM military_expenditures; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (product_id INT, ingredient VARCHAR(255)); | What is the total price of products that contain Shea Butter | SELECT SUM(price) FROM products JOIN ingredients ON products.product_id = ingredients.product_id WHERE ingredients.ingredient = 'Shea Butter'; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response.sector_donations (sector_id INT, donation_amount DECIMAL); INSERT INTO disaster_response.sector_donations (sector_id, donation_amount) VALUES (1, 5000.00), (2, 7500.00), (3, 10000.00), (4, 12000.00); | What is the sum of donations for each sector in the 'disaster_response' schema? | SELECT sector_id, SUM(donation_amount) FROM disaster_response.sector_donations GROUP BY sector_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name VARCHAR(50), country VARCHAR(50), techniques VARCHAR(50), costs FLOAT); INSERT INTO projects (id, name, country, techniques, costs) VALUES (1, 'ProjectX', 'USA', 'DNA sequencing, PCR', 12000); INSERT INTO projects (id, name, country, techniques, costs) VALUES (2, 'ProjectY', 'USA', 'PCR, bioinformatics', 15000); INSERT INTO projects (id, name, country, techniques, costs) VALUES (3, 'ProjectZ', 'USA', 'DNA sequencing, bioinformatics', 18000); | What is the total DNA sequencing cost for projects in the US? | SELECT SUM(costs) FROM projects WHERE country = 'USA' AND techniques LIKE '%DNA sequencing%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_impact_investments (id INT, country VARCHAR(50), transaction_value FLOAT); INSERT INTO social_impact_investments (id, country, transaction_value) VALUES (1, 'United States', 5000.0), (2, 'Canada', 7000.0), (3, 'United Kingdom', 10000.0); | What is the maximum transaction value for social impact investments in the United Kingdom? | SELECT MAX(transaction_value) FROM social_impact_investments WHERE country = 'United Kingdom'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (id INT, name TEXT, location TEXT, practice TEXT); INSERT INTO farms (id, name, location, practice) VALUES (1, 'Smith Farm', 'Rural', 'Organic'); INSERT INTO farms (id, name, location, practice) VALUES (2, 'Jones Farm', 'Urban', 'Conventional'); CREATE TABLE weather (id INT, farm_id INT, month INT, temperature INT, precipitation INT); INSERT INTO weather (id, farm_id, month, temperature, precipitation) VALUES (1, 1, 5, 25, 40); INSERT INTO weather (id, farm_id, month, temperature, precipitation) VALUES (2, 2, 5, 18, 80); | What is the average temperature and precipitation in May for farms in rural areas using organic practices? | SELECT AVG(w.temperature), AVG(w.precipitation) FROM weather w JOIN farms f ON w.farm_id = f.id WHERE w.month = 5 AND f.location = 'Rural' AND f.practice = 'Organic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE collections (collection_name VARCHAR(20), product_type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO collections (collection_name, product_type, price) VALUES ('spring22', 'shirt', 25.99), ('spring22', 'shirt', 30.99), ('spring22', 'pant', 40.00); | What is the average price of cotton shirts in the 'spring22' collection? | SELECT AVG(price) FROM collections WHERE product_type = 'shirt' AND collection_name = 'spring22'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_healthcare_workers (id INT, name VARCHAR(50), title VARCHAR(50), location VARCHAR(50)); | Delete records with the title 'Nurse' in the 'rural_healthcare_workers' table | DELETE FROM rural_healthcare_workers WHERE title = 'Nurse'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft_Manufacturing (id INT, manufacturer VARCHAR(20), cost INT, launch_date DATE); INSERT INTO Spacecraft_Manufacturing (id, manufacturer, cost, launch_date) VALUES (1, 'ISRO', 2000000, '2022-02-14'); | What is the total cost of spacecraft manufactured by ISRO and their launch dates? | SELECT sm.manufacturer, sm.launch_date, SUM(sm.cost) FROM Spacecraft_Manufacturing sm GROUP BY sm.manufacturer, sm.launch_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE florida_water_consumption (id INT, month INT, year INT, state VARCHAR(20), water_consumption FLOAT); INSERT INTO florida_water_consumption (id, month, year, state, water_consumption) VALUES (1, 6, 2021, 'Florida', 10000), (2, 7, 2021, 'Florida', 12000), (3, 8, 2021, 'Florida', 11000); | What is the total water consumption in the state of Florida for the months of June, July, and August in the year 2021? | SELECT SUM(water_consumption) FROM florida_water_consumption WHERE state = 'Florida' AND month IN (6, 7, 8) AND year = 2021 | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT); | What is the average number of employees per mining operation in 'Australia'? | SELECT AVG(num_employees) FROM mining_operations WHERE location = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE judge_case_distribution (case_id INT, judge_name VARCHAR(20), case_type VARCHAR(10), case_outcome VARCHAR(20)); INSERT INTO judge_case_distribution (case_id, judge_name, case_type, case_outcome) VALUES (1, 'Smith', 'Murder', 'Guilty'), (1, 'Smith', 'Theft', 'Not Guilty'); | What is the distribution of cases by case type and case outcome for each judge? | SELECT judge_name, case_type, case_outcome, COUNT(*) as total_cases FROM judge_case_distribution GROUP BY judge_name, case_type, case_outcome; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_conservation (id INT PRIMARY KEY, location VARCHAR(50), water_savings FLOAT); | Find the location with the most water savings | SELECT location, MAX(water_savings) FROM water_conservation GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), StartDate DATE); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, SignUpDate DATE); INSERT INTO Programs (ProgramID, ProgramName, StartDate) VALUES (1, 'ProgramA', '2019-01-01'), (2, 'ProgramB', '2018-01-01'); INSERT INTO Volunteers (VolunteerID, ProgramID, SignUpDate) VALUES (1, 1, '2019-01-01'), (2, 1, '2019-01-02'), (3, 2, '2018-01-01'); | How many volunteers signed up in each program, for programs that started in 2019, ordered by the number of signups in descending order? | SELECT p.ProgramID, p.ProgramName, COUNT(v.VolunteerID) AS SignUpCount FROM Programs p JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE p.StartDate >= '2019-01-01' GROUP BY p.ProgramID, p.ProgramName ORDER BY SignUpCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cargo(Id INT, VesselId INT, ArrivalPort VARCHAR(255), Weight DECIMAL(10,2)); INSERT INTO Cargo VALUES (1, 1, 'Valparaiso', 500.5), (2, 1, 'Valparaiso', 700.3), (3, 2, 'Singapore', 900), (4, 2, 'Tokyo', 600); | What is the total weight in metric tons of cargo that arrived at the port of Valparaiso in the month of January? | SELECT SUM(c.Weight) FROM Cargo c WHERE c.ArrivalPort = 'Valparaiso' AND MONTH(c.ArrivalDateTime) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cyber_threats (threat VARCHAR(100), first_half FLOAT, impact_score FLOAT); INSERT INTO cyber_threats (threat, first_half, impact_score) VALUES ('Log4j Vulnerability', 1.5, 9.1), ('RansomEXX Attacks', 1.5, 8.4), ('WhatsApp Vulnerability', 2, 7.6), ('Hafnium Attacks', 1, 7.5), ('Kaseya Supply-Chain Attack', 2.5, 7.3); | What were the top 3 cybersecurity threats in the first half of 2022? | SELECT threat, impact_score FROM cyber_threats WHERE first_half BETWEEN 1 AND 2 ORDER BY impact_score DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), Cause TEXT); | Which causes received the most funding? | SELECT Cause, SUM(DonationAmount) as TotalFunding FROM Donors GROUP BY Cause ORDER BY TotalFunding DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE VIEW fish_summary AS SELECT species_name, conservation_status FROM fish_species | Delete the view fish_summary | DROP VIEW fish_summary | gretelai_synthetic_text_to_sql |
CREATE TABLE attacks (id INT, sector VARCHAR(20), pattern VARCHAR(50), timestamp TIMESTAMP); | What are the most common attack patterns in the financial services sector in the past year? | SELECT sector, pattern, COUNT(*) as frequency FROM attacks WHERE sector = 'financial services' AND timestamp >= NOW() - INTERVAL 1 YEAR GROUP BY sector, pattern ORDER BY frequency DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE portland_prop(id INT, owner1 VARCHAR(20), owner2 VARCHAR(20), lease_exp DATE); INSERT INTO portland_prop VALUES (1, 'Alice', 'Bob', '2023-06-01'), (2, 'Charlie', 'David', '2023-01-15'); | Find all the co-owned properties in Portland with a lease expiration date in the next 6 months. | SELECT * FROM portland_prop WHERE (owner1 <> owner2) AND (lease_exp BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH)); | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_statistics(id INT, crime_type VARCHAR(20), location VARCHAR(20), time DATE); | Delete all records related to 'robbery' in 'Miami' | DELETE FROM crime_statistics WHERE crime_type = 'robbery' AND location = 'Miami'; | gretelai_synthetic_text_to_sql |
CREATE TABLE industry_4_0 ( id INT PRIMARY KEY, company_name VARCHAR(255), manufacturing_country VARCHAR(64), automation_level VARCHAR(64) ); INSERT INTO industry_4_0 (id, company_name, manufacturing_country, automation_level) VALUES (1, 'GHI Co', 'Japan', 'Medium'); INSERT INTO industry_4_0 (id, company_name, manufacturing_country, automation_level) VALUES (2, 'JKL Inc', 'USA', 'Low'); | Update the "industry_4_0" table to set the "automation_level" as "High" for all records where the "manufacturing_country" is "Japan" | UPDATE industry_4_0 SET automation_level = 'High' WHERE manufacturing_country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Boroughs (BoroughID INT, BoroughName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, PropertyType VARCHAR(255), BoroughID INT); INSERT INTO Boroughs VALUES (1, 'Brooklyn'); INSERT INTO Properties VALUES (1, 'Co-op', 1); | What is the count of co-op properties in each borough of 'New York City'? | SELECT BoroughName, COUNT(*) FROM Properties p JOIN Boroughs b ON p.BoroughID = b.BoroughID WHERE p.PropertyType = 'Co-op' GROUP BY BoroughName; | gretelai_synthetic_text_to_sql |
CREATE TABLE environment (date DATE, location VARCHAR(50), material VARCHAR(50), score FLOAT); INSERT INTO environment (date, location, material, score) VALUES ('2020-01-01', 'Peru', 'Copper', 75), ('2020-02-01', 'Peru', 'Copper', 72), ('2020-03-01', 'Peru', 'Copper', 78); | What are the average monthly environmental impact scores for copper mining in Peru? | SELECT AVG(score) as avg_monthly_score FROM environment WHERE location = 'Peru' AND material = 'Copper' GROUP BY EXTRACT(MONTH FROM date); | gretelai_synthetic_text_to_sql |
CREATE VIEW startups_without_funding AS SELECT company_name FROM company_founding_data WHERE company_name NOT IN (SELECT company_name FROM funding_records); | Delete records of startups that have not received any funding in the 'startups_without_funding' view | DELETE FROM startups_without_funding; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species VARCHAR(255)); INSERT INTO marine_species (id, species) VALUES (1, 'Dolphin'), (2, 'Shark'), (3, 'Turtle'); CREATE TABLE pollution_control (id INT, species_id INT, initiative VARCHAR(255)); INSERT INTO pollution_control (id, species_id, initiative) VALUES (1, 1, 'Beach Cleanup'), (2, 1, 'Ocean Floor Mapping'), (3, 2, 'Beach Cleanup'), (4, 2, 'Ocean Floor Mapping'), (5, 3, 'Beach Cleanup'); | List all marine species that have more than one associated pollution control initiative. | SELECT marine_species.species FROM marine_species INNER JOIN pollution_control ON marine_species.id = pollution_control.species_id GROUP BY marine_species.species HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (state VARCHAR(20), capacity INT, year INT); INSERT INTO energy_storage (state, capacity, year) VALUES ('California', 5000, 2021), ('California', 6000, 2021), ('California', 4000, 2021); | What is the maximum energy storage capacity in MWh for the state of California in 2021? | SELECT MAX(capacity) FROM energy_storage WHERE state = 'California' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE asia (country VARCHAR(50), obesity_rate DECIMAL(3,1)); INSERT INTO asia (country, obesity_rate) VALUES ('China', 4.8), ('India', 3.3), ('Indonesia', 6.9); | What is the obesity rate in Asia by country? | SELECT country, AVG(obesity_rate) as avg_obesity_rate FROM asia GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE jobs (id INT, job_title VARCHAR(100)); INSERT INTO jobs (id, job_title) VALUES (1, 'Software Engineer'), (2, 'Data Analyst'), (3, 'Product Manager'); | List all unique job titles in the 'jobs' table | SELECT DISTINCT job_title FROM jobs; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_reports (id INT, project_id INT, funder VARCHAR(100), amount DECIMAL(10, 2), date DATE); INSERT INTO climate_finance_reports (id, project_id, funder, amount, date) VALUES (1, 1, 'Global Green Fund', 250000, '2021-07-15'), (2, 2, 'EcoFund', 125000, '2022-03-20'); | What are the climate finance reports for projects in India? | SELECT * FROM climate_finance_reports WHERE project_id IN (SELECT id FROM projects WHERE location = 'India'); | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_routes (region VARCHAR(10), num_stations INT); INSERT INTO subway_routes (region, num_stations) VALUES ('east', 8), ('west', 10), ('north', 12), ('south', 9); | How many subway routes have fewer than 10 stations in the 'east' region? | SELECT COUNT(*) FROM subway_routes WHERE region = 'east' AND num_stations < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (country VARCHAR(50), amount FLOAT); INSERT INTO humanitarian_assistance (country, amount) VALUES ('USA', 4000000000), ('UK', 2000000000), ('Canada', 1500000000), ('Australia', 1000000000), ('Japan', 3000000000); | What is the total amount of humanitarian assistance provided by the US and UK? | SELECT SUM(ha.amount) FROM humanitarian_assistance ha WHERE ha.country IN ('USA', 'UK'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_sites (id INT PRIMARY KEY, name TEXT, location TEXT, size FLOAT, annual_production INT, co2_emissions INT); INSERT INTO mine_sites (id, name, location, size, annual_production, co2_emissions) VALUES (1, 'Chuquicamata', 'Chile', 830.0, 340000, 1200); INSERT INTO mine_sites (id, name, location, size, annual_production, co2_emissions) VALUES (2, 'Collahuasi', 'Chile', 520.0, 270000, 900); INSERT INTO mine_sites (id, name, location, size, annual_production, co2_emissions) VALUES (3, 'El Teniente', 'Chile', 350.0, 220000, 750); | What is the average water consumption for mines located in Chile where CO2 emissions are higher than 1000? | SELECT location, AVG(co2_emissions) as avg_co2_emissions FROM mine_sites WHERE location = 'Chile' GROUP BY location HAVING avg_co2_emissions > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Rural_Infrastructure_Projects (Project_ID INT, Project_Name TEXT, Location TEXT, Status TEXT, Completion_Date DATE); INSERT INTO Rural_Infrastructure_Projects (Project_ID, Project_Name, Location, Status, Completion_Date) VALUES (1, 'Rural Road Construction', 'Bangladesh', 'Completed', '2016-12-31'); | What is the total number of rural infrastructure projects in Bangladesh that were completed between 2015 and 2017? | SELECT COUNT(*) FROM Rural_Infrastructure_Projects WHERE Status = 'Completed' AND Location = 'Bangladesh' AND Completion_Date BETWEEN '2015-01-01' AND '2017-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (clinical_trial_id INT, state VARCHAR(255), approval_date DATE); INSERT INTO clinical_trials (clinical_trial_id, state, approval_date) VALUES (1, 'California', '2018-01-01'); | List all clinical trials approved in the state of 'California' between 2018 and 2020, ordered by approval date. | SELECT * FROM clinical_trials WHERE state = 'California' AND approval_date BETWEEN '2018-01-01' AND '2020-12-31' ORDER BY approval_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_sources (ingredient_id INT, ingredient_name VARCHAR(50), source_type VARCHAR(50)); INSERT INTO ingredient_sources (ingredient_id, ingredient_name, source_type) VALUES (1001, 'Aloe Vera', 'Organic Farm'), (1002, 'Rose Hip Oil', 'Conventional Farm'), (1003, 'Jojoba Oil', 'Organic Farm'); | List of ingredients sourced from organic farms? | SELECT ingredient_name FROM ingredient_sources WHERE source_type = 'Organic Farm'; | gretelai_synthetic_text_to_sql |
CREATE TABLE uranium_production (country VARCHAR(20), quantity INT); INSERT INTO uranium_production (country, quantity) VALUES ('Kazakhstan', 8000), ('Canada', 6000); | What is the total quantity of uranium mined in Kazakhstan and Canada? | SELECT country, SUM(quantity) FROM uranium_production WHERE country IN ('Kazakhstan', 'Canada') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crop_Prices (id INT PRIMARY KEY, crop_name VARCHAR(50), price DECIMAL(5,2), market_location VARCHAR(50), price_date DATE); INSERT INTO Crop_Prices (id, crop_name, price, market_location, price_date) VALUES (1, 'Corn', 4.50, 'Mexico', '2022-01-01'); INSERT INTO Crop_Prices (id, crop_name, price, market_location, price_date) VALUES (2, 'Soybeans', 8.20, 'Canada', '2022-01-01'); INSERT INTO Crop_Prices (id, crop_name, price, market_location, price_date) VALUES (3, 'Rice', 12.00, 'Mexico', '2022-06-15'); CREATE TABLE Markets (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); INSERT INTO Markets (id, name, location) VALUES (1, 'Central de Abasto', 'Mexico'); INSERT INTO Markets (id, name, location) VALUES (2, 'Granville Island', 'Canada'); CREATE TABLE Market_Location (market_id INT, crop_price_id INT); INSERT INTO Market_Location (market_id, crop_price_id) VALUES (1, 1); INSERT INTO Market_Location (market_id, crop_price_id) VALUES (1, 3); | Which crop has the highest price in the market in Mexico in the last 6 months? | SELECT crop_name, MAX(price) FROM Crop_Prices JOIN Market_Location ON Crop_Prices.id = Market_Location.crop_price_id JOIN Markets ON Market_Location.market_id = Markets.id WHERE Markets.location = 'Mexico' AND price_date > DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY crop_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospital (hospital_id INT, beds INT, nurse_count INT); | How many nurses work in hospitals with more than 100 beds? | SELECT COUNT(*) FROM hospital WHERE beds > 100 AND nurse_count > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(255), lead_organization VARCHAR(255), start_date DATE); INSERT INTO peacekeeping_operations (id, operation_name, lead_organization, start_date) VALUES (1, 'AMISOM', 'African Union', '2007-01-19'), (2, 'MINUSMA', 'United Nations', '2013-07-25'), (3, 'EUTM Mali', 'European Union', '2013-02-18'); | Identify the peacekeeping operations where the African Union or the United Nations is the lead organization | SELECT * FROM peacekeeping_operations WHERE lead_organization IN ('African Union', 'United Nations'); | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(255), language VARCHAR(255), word_count INT); INSERT INTO articles (id, title, language, word_count) VALUES (1, 'Article1', 'English', 500), (2, 'Article2', 'French', 700), (3, 'Article3', 'Spanish', 600); | What is the average word count of articles by language? | SELECT language, AVG(word_count) as avg_word_count FROM articles GROUP BY language; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research_projects (id INT, project_name VARCHAR(50), lead_researcher VARCHAR(50), budget FLOAT); INSERT INTO genetic_research_projects (id, project_name, lead_researcher, budget) VALUES (1, 'CRISPR Gene Editing', 'Dan', 5000000), (2, 'Stem Cell Research', 'Ella', 7000000), (3, 'Gene Therapy', 'Fiona', 8000000); | What is the budget for the 'CRISPR Gene Editing' project and the name of its lead researcher in the 'genetic_research' database? | SELECT project_name, lead_researcher, budget FROM genetic_research_projects WHERE project_name = 'CRISPR Gene Editing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE resilience_metrics (id INT PRIMARY KEY, metric_name VARCHAR(255), metric_value INT, project_id INT); INSERT INTO resilience_metrics (id, metric_name, metric_value, project_id) VALUES (1, 'Earthquake Resistance', 90, 1); INSERT INTO resilience_metrics (id, metric_name, metric_value, project_id) VALUES (2, 'Wind Resistance', 95, 1); | Insert a new record into the resilience_metrics table with the name 'Flood Resistance' and value 85 for the project with id 2 | INSERT INTO resilience_metrics (metric_name, metric_value, project_id) VALUES ('Flood Resistance', 85, 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE quadrant (id INT, name VARCHAR(20)); INSERT INTO quadrant (id, name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Southwest'), (4, 'Northwest'); CREATE TABLE events (id INT, quadrant_id INT, event_name VARCHAR(50), budget INT); INSERT INTO events (id, quadrant_id, event_name, budget) VALUES (1, 3, 'Coffee with a Cop', 6000), (2, 4, 'Neighborhood Watch', 3000), (3, 2, 'Juvenile Engagement', 4000); | List all community policing events with a budget over $5000 in the Southwest quadrant. | SELECT * FROM events WHERE quadrant_id = (SELECT id FROM quadrant WHERE name = 'Southwest') AND budget > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity_california (year INT, capacity_cubic_meters BIGINT); INSERT INTO landfill_capacity_california (year, capacity_cubic_meters) VALUES (2020, 123456789), (2022, 134567890), (2023, 145678901); | What was the landfill capacity in California in 2021? | SELECT capacity_cubic_meters FROM landfill_capacity_california WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE LollapaloozaTicketSales (year INT, tickets INT); | What is the total number of tickets sold for the Lollapalooza music festival in the United States from 2015-2019? | SELECT SUM(tickets) FROM LollapaloozaTicketSales WHERE year BETWEEN 2015 AND 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE CrueltyFreeProducts (product VARCHAR(255), country VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO CrueltyFreeProducts (product, country, revenue) VALUES ('Shampoo', 'Germany', 1000), ('Conditioner', 'Germany', 1200), ('Styling Gel', 'Germany', 800); | What is the total revenue of cruelty-free haircare products in Germany? | SELECT SUM(revenue) FROM CrueltyFreeProducts WHERE product LIKE 'Shampoo%' OR product LIKE 'Conditioner%' OR product LIKE 'Styling Gel%' AND country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle_Types (Id INT, Name VARCHAR(50)); CREATE TABLE Vehicle_Releases (Id INT, Name VARCHAR(50), Release_Date DATE, Origin_Country VARCHAR(50), CO2_Emission INT, Vehicle_Type_Id INT); | What is the average CO2 emission of sports cars released since 2020 in the European Union? | SELECT AVG(CO2_Emission) FROM Vehicle_Releases vr INNER JOIN Vehicle_Types vt ON vr.Vehicle_Type_Id = vt.Id WHERE vt.Name = 'Sports Car' AND Release_Date >= '2020-01-01' AND Origin_Country IN (SELECT Country FROM Countries WHERE Region = 'European Union'); | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_research (research_id INT, title VARCHAR(100), publication_year INT, publication VARCHAR(50), country VARCHAR(50)); | How many autonomous driving research papers were published by country? | SELECT country, COUNT(*) FROM autonomous_research WHERE research_category = 'Autonomous Driving' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE smoking (patient_id INT, age INT, gender TEXT, state TEXT, smokes INT); INSERT INTO smoking (patient_id, age, gender, state, smokes) VALUES (1, 25, 'Male', 'Texas', 1); | What is the total number of smokers in the state of Texas who are under the age of 30? | SELECT SUM(smokes) FROM smoking WHERE state = 'Texas' AND age < 30 AND smokes = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE housing (id INT, city VARCHAR(255), inclusive BOOLEAN); INSERT INTO housing (id, city, inclusive) VALUES (1, 'Denver', TRUE), (2, 'Denver', FALSE), (3, 'Boulder', TRUE), (4, 'Denver', TRUE); | What is the total number of inclusive housing units in the city of Denver? | SELECT COUNT(*) FROM housing WHERE city = 'Denver' AND inclusive = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Innovation (id INT, project VARCHAR(255)); CREATE TABLE Peacekeeping (id INT, operation VARCHAR(255)); | What is the total number of military innovation projects in the 'Innovation' table and peacekeeping operations in the 'Peacekeeping' table? | SELECT COUNT(*) FROM Innovation UNION SELECT COUNT(*) FROM Peacekeeping; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness_papers (year INT, paper_id INT, paper_title VARCHAR(255), author_name VARCHAR(255), num_citations INT); INSERT INTO algorithmic_fairness_papers (year, paper_id, paper_title, author_name, num_citations) VALUES ('2018', '1', 'Algorithmic Fairness: A Review', 'Alice Johnson', '50'); | What is the average number of citations for the top 5% of algorithmic fairness papers by year? | SELECT year, AVG(num_citations) as avg_citations FROM (SELECT year, num_citations, NTILE(100) OVER (PARTITION BY year ORDER BY num_citations DESC) as citation_group FROM algorithmic_fairness_papers) t WHERE citation_group = 1 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mediators (MediatorID INT, Name VARCHAR(50), Age INT, Experience INT, Ethnicity VARCHAR(50)); CREATE TABLE Cases (CaseID INT, MediatorID INT, Date DATE); INSERT INTO Mediators (MediatorID, Name, Age, Experience, Ethnicity) VALUES (1, 'Juan Garcia', 45, 12, 'Hispanic'), (2, 'Li Chen', 38, 7, 'Asian'), (3, 'Amina Diop', 42, 18, 'African'), (4, 'Boris Petrov', 50, 25, 'European'); INSERT INTO Cases (CaseID, MediatorID, Date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'), (4, 3, '2021-04-01'), (5, 3, '2021-05-01'), (6, 4, '2021-06-01'); | What is the rank of each mediator based on the number of cases handled, with ties broken by age and ethnicity? | SELECT MediatorID, Name, RANK() OVER (ORDER BY COUNT(*) DESC, Age, Ethnicity) as Rank FROM Mediators JOIN Cases ON Mediators.MediatorID = Cases.MediatorID GROUP BY MediatorID, Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, budget DECIMAL(10,2)); INSERT INTO heritage_sites (id, budget) VALUES (1, 80000.00), (2, 90000.00), (3, 100000.00); | Update the budget for the heritage site with ID 3 to $120,000.00. | UPDATE heritage_sites SET budget = 120000.00 WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_projects (id INT, country VARCHAR(255), year INT, cost FLOAT); INSERT INTO rural_infrastructure_projects (id, country, year, cost) VALUES (1, 'Indonesia', 2018, 75000.00), (2, 'Indonesia', 2018, 80000.00); | What was the maximum cost of any rural infrastructure project in Indonesia in 2018?' | SELECT MAX(cost) FROM rural_infrastructure_projects WHERE country = 'Indonesia' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists renewables; CREATE TABLE if not exists renewables.wind_projects (id INT, project_name VARCHAR, location VARCHAR, installed_capacity FLOAT); CREATE TABLE if not exists renewables.solar_projects (id INT, project_name VARCHAR, location VARCHAR, installed_capacity FLOAT); INSERT INTO renewables.wind_projects (id, project_name, location, installed_capacity) VALUES (1, 'Wind Farm 1', 'Asia', 100.5), (2, 'Wind Farm 2', 'Europe', 120.3), (3, 'Wind Farm 3', 'USA', 150.5); INSERT INTO renewables.solar_projects (id, project_name, location, installed_capacity) VALUES (1, 'Solar Project 1', 'USA', 150.5), (2, 'Solar Project 2', 'Canada', 180.3); | What are the names and installed capacities of wind energy projects located in Asia or Europe? | SELECT project_name, installed_capacity FROM renewables.wind_projects WHERE location IN ('Asia', 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, age INT, preference VARCHAR(20)); INSERT INTO users (id, age, preference) VALUES (1, 35, 'sports'), (2, 45, 'politics'), (3, 28, 'business'), (4, 50, 'business'), (5, 60, 'business'); | What is the minimum age of users who prefer watching business news? | SELECT MIN(age) FROM users WHERE preference = 'business'; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_equity_metrics (metric VARCHAR(50), culture VARCHAR(50)); INSERT INTO health_equity_metrics (metric, culture) VALUES ('Access to Care', 'Hispanic'), ('Quality of Care', 'Hispanic'), ('Access to Care', 'African American'); | How many health equity metrics are available for each cultural group? | SELECT culture, COUNT(DISTINCT metric) FROM health_equity_metrics GROUP BY culture; | gretelai_synthetic_text_to_sql |
CREATE TABLE car_claims (policyholder_name TEXT, claim_amount INTEGER); CREATE TABLE health_claims (policyholder_name TEXT, claim_amount INTEGER); INSERT INTO car_claims VALUES ('Alice', 500), ('Bob', 200), ('Carol', 300), ('Dave', 400); INSERT INTO health_claims VALUES ('Bob', 1500), ('Eve', 800), ('Alice', 900); | What are the total claim amounts for policyholders who have made claims in both the car and health insurance categories? | SELECT SUM(claim_amount) FROM car_claims WHERE policyholder_name IN (SELECT policyholder_name FROM health_claims); | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE AdvocacyGroups (AdvocacyGroupID INT, AdvocacyGroupName VARCHAR(50)); CREATE TABLE AdvocatesData (AdvocateID INT, AdvocacyGroupID INT, RegionID INT, Date DATE); | What is the percentage of labor rights advocates who joined AdvocacyGroupC in each region in the year 2021? | SELECT r.RegionName, AVG(CASE WHEN YEAR(a.Date) = 2021 AND a.AdvocacyGroupID = (SELECT AdvocacyGroupID FROM AdvocacyGroups WHERE AdvocacyGroupName = 'AdvocacyGroupC') THEN 100.0 ELSE 0.0 END) AS Percentage FROM Regions r JOIN AdvocatesData a ON r.RegionID = a.RegionID GROUP BY r.RegionName; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255), category VARCHAR(255), followers INT); INSERT INTO users (id, country, category, followers) VALUES (1, 'France', 'fashion', 1500); | How many users from France in the fashion category have more than 1000 followers? | SELECT COUNT(DISTINCT users.id) FROM users WHERE users.country = 'France' AND users.category = 'fashion' AND users.followers > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop (type TEXT, yield FLOAT, cost FLOAT, planting_date DATE); | What is the total cost and average yield for each crop type in the current year? | SELECT c.type, SUM(c.cost) as total_cost, AVG(c.yield) as avg_yield FROM crop c WHERE c.planting_date >= DATEADD(year, 0, DATEADD(day, DATEDIFF(day, 0, CURRENT_DATE), 0)) GROUP BY c.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyholderID INT, City VARCHAR(20), IssueDate DATE); INSERT INTO Policyholders (PolicyholderID, City, IssueDate) VALUES (1, 'Toronto', '2022-01-15'), (2, 'Toronto', '2022-02-20'), (3, 'Miami', '2022-03-25'); | How many policies were issued per month in 'Toronto' for the year 2022? | SELECT DATE_FORMAT(IssueDate, '%Y-%m') AS Month, COUNT(*) as NumberOfPolicies FROM Policyholders WHERE City = 'Toronto' AND YEAR(IssueDate) = 2022 GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_cars (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, horsepower INT, is_electric BOOLEAN, is_hybrid BOOLEAN); | What is the average horsepower of hybrid vehicles in the 'green_cars' table by year? | SELECT year, AVG(horsepower) as avg_horsepower FROM green_cars WHERE is_hybrid = TRUE GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE educators (educator_id INT, name TEXT, state TEXT, tenure_years DECIMAL(3,1), position TEXT); INSERT INTO educators (educator_id, name, state, tenure_years, position) VALUES (1, 'John Doe', 'NY', 7.5, 'Teacher'), (2, 'Jane Smith', 'CA', 5.2, 'Principal'); | What is the average tenure of educators by state? | SELECT state, AVG(tenure_years) OVER (PARTITION BY state) FROM educators; | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_teams (team_id INT, team_name VARCHAR(50), goals_scored INT); INSERT INTO soccer_teams (team_id, team_name, goals_scored) VALUES (1, 'Barcelona', 86); INSERT INTO soccer_teams (team_id, team_name, goals_scored) VALUES (2, 'Real Madrid', 92); | Which team has the most goals in the 'soccer_teams' table? | SELECT team_name, MAX(goals_scored) FROM soccer_teams; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, YearsOfExperience INT, City VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, City) VALUES (1, 10, 'Jakarta'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, City) VALUES (2, 3, 'New York'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, City) VALUES (3, 7, 'Jakarta'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, BillingAmount INT); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (1, 1, 2000); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (2, 1, 3000); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (3, 2, 1000); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (4, 3, 1500); | What is the maximum billing amount for cases handled by attorneys from Jakarta with more than 7 years of experience? | SELECT MAX(BillingAmount) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.City = 'Jakarta' AND Attorneys.YearsOfExperience > 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesStore (id INT PRIMARY KEY, store_name VARCHAR(50), location VARCHAR(50), garment_type VARCHAR(50), quantity INT, sale_date DATE); INSERT INTO SalesStore (id, store_name, location, garment_type, quantity, sale_date) VALUES (1, 'Store E', 'Africa', 'Cotton Pants', 80, '2022-04-23'); | What is the maximum quantity of 'Cotton' garments sold in a single day in 'Africa' retail stores in Q2 of 2022? | SELECT MAX(quantity) as max_quantity FROM SalesStore WHERE location = 'Africa' AND garment_type = 'Cotton' AND sale_date BETWEEN '2022-04-01' AND '2022-06-30'; | 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.