context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE climate_mitigation (id INT, project_name TEXT, budget INT, start_year INT, location TEXT); INSERT INTO climate_mitigation (id, project_name, budget, start_year, location) VALUES (1, 'Tree Planting', 50000, 2016, 'South America'); INSERT INTO climate_mitigation (id, project_name, budget, start_year, locatio...
What is the average budget of climate mitigation projects in South America that started before 2018?
SELECT AVG(budget) FROM climate_mitigation WHERE location = 'South America' AND start_year < 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE language (id INT, name TEXT, country TEXT, num_speakers INT, endangered BOOLEAN); INSERT INTO language (id, name, country, num_speakers, endangered) VALUES (1, 'Swahili', 'Tanzania', 15000000, false), (2, 'Hausa', 'Nigeria', 50000000, false), (3, 'Yoruba', 'Nigeria', 30000000, true), (4, 'Zulu', 'South Afr...
What is the total number of endangered language speakers in each country in Africa?
SELECT country, SUM(num_speakers) FROM language WHERE endangered = true GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element TEXT, quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 100), (2016, 'Dysprosium', 150), (2017, 'Dysprosium', 200), (2018, 'Dysprosium', 250), (2019, 'Dysprosium', 300), (2020, 'Dysprosium', 350), (2015, 'Neodymium', 500), (2016, 'Neod...
Which REEs were produced in 2015?
SELECT DISTINCT element FROM production WHERE year = 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (Id INT, Name VARCHAR(50)); INSERT INTO Countries (Id, Name) VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'); CREATE TABLE SatelliteDeployments (Id INT, CountryId INT, Year INT, Success BOOLEAN); INSERT INTO SatelliteDeployments (Id, CountryId, Year, Success) VALUES (1, 1, 2019, TRUE), (2, 1, 2019...
Identify the number of successful and failed satellite deployments per country in 2019.
SELECT c.Name, SUM(CASE WHEN sd.Success THEN 1 ELSE 0 END) as Successes, SUM(CASE WHEN NOT sd.Success THEN 1 ELSE 0 END) as Failures FROM Countries c LEFT JOIN SatelliteDeployments sd ON c.Id = sd.CountryId WHERE sd.Year = 2019 GROUP BY c.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE posts (id INT, account_id INT, content TEXT, timestamp TIMESTAMP); CREATE TABLE interactions (id INT, post_id INT, user_id INT); INSERT INTO accounts (id, name, location) VALUES (1, 'user1', 'Australia'); INSERT INTO posts (id, accou...
How many unique users have interacted with posts containing the hashtag #vegan, in the last 3 days, from accounts located in Australia?
SELECT COUNT(DISTINCT interactions.user_id) FROM interactions JOIN posts ON interactions.post_id = posts.id JOIN accounts ON posts.account_id = accounts.id WHERE posts.timestamp >= NOW() - INTERVAL '3 days' AND posts.content LIKE '%#vegan%' AND accounts.location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (id INT, name VARCHAR(50), area VARCHAR(10)); INSERT INTO mental_health_facilities (id, name, area) VALUES (1, 'Facility A', 'Rural'), (2, 'Facility B', 'Urban'), (3, 'Facility C', 'Rural'), (4, 'Facility D', 'Urban'), (5, 'Facility E', 'Rural'), (6, 'Facility F', 'Rural'), (7, 'Fa...
Identify the top 5 rural areas with the highest number of mental health facilities.
SELECT area, COUNT(*) FROM mental_health_facilities WHERE area = 'Rural' GROUP BY area ORDER BY COUNT(*) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE tunnels (id INT, name TEXT, build_year INT, location TEXT); INSERT INTO tunnels (id, name, build_year, location) VALUES (1, 'Tunnel A', 1990, 'California'), (2, 'Tunnel B', 2000, 'Texas');
Determine the number of tunnels built in each state
SELECT location, COUNT(*) FROM tunnels GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicBikeSystems (bike_id INT, city VARCHAR(20), PRIMARY KEY (bike_id));
Delete records in the 'PublicBikeSystems' table where 'city' is 'San Diego'
DELETE FROM PublicBikeSystems WHERE city = 'San Diego';
gretelai_synthetic_text_to_sql
CREATE TABLE GameSessions (PlayerID INT, GamePreference VARCHAR(20), HoursPlayed DECIMAL(5,2)); INSERT INTO GameSessions (PlayerID, GamePreference, HoursPlayed) VALUES (1, 'RPG', 10.5), (2, 'FPS', 5.3), (3, 'Strategy', 7.2);
Find the maximum hours played in a single game session for players who have played RPG games
SELECT MAX(HoursPlayed) FROM GameSessions WHERE GamePreference = 'RPG';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_holders (policy_holder_id INT, policy_holder_name VARCHAR(50), policy_type VARCHAR(50)); CREATE TABLE policies (policy_id INT, policy_holder_id INT, policy_type VARCHAR(50));
Identify the policyholders who have both home and auto insurance policies with us.
SELECT ph.policy_holder_id, ph.policy_holder_name FROM policy_holders ph JOIN policies p1 ON ph.policy_holder_id = p1.policy_holder_id JOIN policies p2 ON ph.policy_holder_id = p2.policy_holder_id WHERE p1.policy_type = 'home' AND p2.policy_type = 'auto' GROUP BY ph.policy_holder_id;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_data (customer_id INT, name VARCHAR(20), region VARCHAR(10)); INSERT INTO customer_data (customer_id, name, region) VALUES (1, 'John Doe', 'north'), (2, 'Jane Smith', 'east'), (3, 'Mary Johnson', 'north'); CREATE TABLE investment_data (customer_id INT, investment FLOAT); INSERT INTO investment_dat...
What is the minimum investment made by a customer in the northern region?
SELECT MIN(investment) FROM investment_data INNER JOIN customer_data ON investment_data.customer_id = customer_data.customer_id WHERE customer_data.region = 'north';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO climate_mitigation_projects (project_id, project_name, location, budget) VALUES (1, 'Carbon Capture in Germany', 'Germany', 4000000.00), (2, 'Forest Conservation in France', 'Fr...
What is the average budget for climate mitigation projects in Europe?
SELECT AVG(budget) FROM climate_mitigation_projects WHERE location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Production (ProductionID INT PRIMARY KEY, ChemicalName VARCHAR(50), Department VARCHAR(50), ProductionDate DATE, Quantity INT); INSERT INTO Production (ProductionID, ChemicalName, Department, ProductionDate, Quantity) VALUES (1, 'Sodium Hydroxide', 'Production', '2021-01-15', 5000); INSERT INTO Production ...
what is the total quantity of chemical 'Sodium Hydroxide' produced by the Production department in the year 2021?
SELECT SUM(Production.Quantity) FROM Production WHERE Production.ChemicalName = 'Sodium Hydroxide' AND Production.Department = 'Production' AND YEAR(Production.ProductionDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, category VARCHAR(20)); INSERT INTO project (id, name, location, start_date, end_date, category) VALUES (4, 'Utility Relocation', 'City D', '2021-01-01', '2021-12-31', 'Utilities'); CREATE TABLE category (id INT, name V...
What are the names of categories with no projects?
SELECT c.name FROM category c WHERE c.name NOT IN (SELECT DISTINCT category FROM project);
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy_name VARCHAR(255), account_id INT, transaction_value DECIMAL(10, 2), transaction_date DATE); INSERT INTO investment_strategies (id, strategy_name, account_id, transaction_value, transaction_date) VALUES (1, 'Conservative', 1, 50, '2022-01-01'), (2, 'Moderate', 1, 100...
What is the total number of transactions and total transaction value for each investment strategy in the last month?
SELECT s.strategy_name, COUNT(s.id) AS num_transactions, SUM(s.transaction_value) AS total_transaction_value FROM investment_strategies s WHERE s.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY s.strategy_name;
gretelai_synthetic_text_to_sql
CREATE TABLE factory_location(factory_id INT, location VARCHAR(255), lead_time FLOAT); INSERT INTO factory_location(factory_id, location, lead_time) VALUES (1, 'Mexico', 30), (2, 'Guatemala', 25), (3, 'India', 45);
What is the average lead time for garment production by factory location?
SELECT location, AVG(lead_time) FROM factory_location GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Operations (operation_id INT, operation_type VARCHAR(50), year INT); INSERT INTO Operations (operation_id, operation_type, year) VALUES (1, 'Intelligence gathering', 2022), (2, 'Surveillance', 2021);
How many intelligence gathering missions were conducted in the Middle East in 2022?
SELECT COUNT(*) FROM Operations WHERE operation_type = 'Intelligence gathering' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE crime_incidents (id INT, date DATE, type VARCHAR(20)); INSERT INTO crime_incidents (id, date, type) VALUES (1, '2022-01-01', 'theft'), (2, '2022-01-02', 'burglary'); CREATE TABLE emergency_calls (id INT, date DATE, type VARCHAR(20)); INSERT INTO emergency_calls (id, date, type) VALUES (1, '2022-01-01', 'em...
What is the total number of crime incidents, emergency calls, and fire incidents in the last week?
SELECT 'crime incidents' AS type, COUNT(*) FROM crime_incidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) UNION ALL SELECT 'emergency calls' AS type, COUNT(*) FROM emergency_calls WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) UNION ALL SELECT 'fire incidents' AS type, COUNT(*) FROM fire_incidents WH...
gretelai_synthetic_text_to_sql
CREATE TABLE esports_players (PlayerID INT, Name VARCHAR(20), Email VARCHAR(30)); INSERT INTO esports_players (PlayerID, Name, Email) VALUES (1, 'John Doe', 'johndoe@example.com');
Update the email of player 'John Doe' in 'esports_players' table.
UPDATE esports_players SET Email = 'newemail@example.com' WHERE Name = 'John Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSales (id INT, equipment_model VARCHAR(255), region VARCHAR(255), quantity INT); INSERT INTO EquipmentSales (id, equipment_model, region, quantity) VALUES (1, 'M1 Abrams', 'Africa', 60), (2, 'F-35', 'Africa', 150), (3, 'M2 Bradley', 'Africa', 45);
What is the maximum number of units sold for any military equipment model in Africa?
SELECT MAX(quantity) as max_sold FROM EquipmentSales WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE shipwreck_io (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO shipwreck_io (id, name, location, depth) VALUES (1, 'Titanic', 'Atlantic Ocean', 3784); INSERT INTO shipwreck_io (id, name, location, depth) VALUES (2, 'Prince of Wales', 'Indian Ocean', 3674);
What is the minimum depth at which a shipwreck has been discovered in the Indian Ocean?
SELECT MIN(depth) FROM shipwreck_io WHERE location = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Hawks'), (2, 'Heat'); CREATE TABLE players (player_id INT, player_name VARCHAR(255), team_id INT, birth_date DATE); INSERT INTO players (player_id, player_name, team_id, birth_date) VALUES (1, 'John Collins', 1,...
What is the average age of players on each team?
SELECT teams.team_name, AVG(DATEDIFF(CURDATE(), players.birth_date) / 365.25) AS avg_age FROM teams INNER JOIN players ON teams.team_id = players.team_id GROUP BY teams.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, state TEXT, has_diabetes BOOLEAN); INSERT INTO patients (id, name, age, state, has_diabetes) VALUES (1, 'John Doe', 65, 'California', true), (2, 'Jane Smith', 45, 'Texas', false);
What is the average age of patients with diabetes in each state?
SELECT patients.state, AVG(patients.age) FROM patients WHERE patients.has_diabetes = true GROUP BY patients.state;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(100), state VARCHAR(50), contract_value FLOAT);
Calculate the total value of defense contracts awarded to companies in Texas
SELECT SUM(contract_value) FROM defense_contracts WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE mexico_licenses (id INT, license_number INT);CREATE TABLE colombia_licenses (id INT, license_number INT);CREATE TABLE chile_licenses (id INT, license_number INT);INSERT INTO mexico_licenses (id, license_number) VALUES (1, 1001), (2, 1002);INSERT INTO colombia_licenses (id, license_number) VALUES (1, 2001),...
Find the number of aquatic farming licenses issued in Mexico, Colombia, and Chile?
SELECT COUNT(*) FROM mexico_licenses UNION SELECT COUNT(*) FROM colombia_licenses UNION SELECT COUNT(*) FROM chile_licenses
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_na (id INT, customer_id INT, country VARCHAR(255), score INT); INSERT INTO financial_wellbeing_na (id, customer_id, country, score) VALUES (1, 5001, 'United States', 70), (2, 5002, 'Canada', 80), (3, 5003, 'Mexico', 65);
What is the minimum financial wellbeing score for customers in North America?
SELECT MIN(score) FROM financial_wellbeing_na WHERE country IN ('United States', 'Canada', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT PRIMARY KEY, sale_date DATE, item_sold VARCHAR(255), quantity INT, sale_price DECIMAL(5,2));
What is the total revenue for a given day?
SELECT SUM(quantity * sale_price) FROM Sales WHERE sale_date = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE fields (field_id VARCHAR(10), devices INT); INSERT INTO fields (field_id, devices) VALUES ('A', 15), ('B', 20), ('C', 10);
Show the number of IoT devices connected to each field as of January 1, 2021.
SELECT field_id, COUNT(*) FROM fields GROUP BY field_id;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists startups(id INT, name VARCHAR(255), location VARCHAR(255), funding FLOAT);INSERT INTO startups(id, name, location, funding) VALUES (1, 'StartupA', 'California', 15000000.00), (2, 'StartupB', 'New York', 20000000.00), (3, 'StartupC', 'Texas', 120...
What is the average funding for biotech startups in the Pacific region?
SELECT AVG(funding) FROM biotech.startups WHERE location LIKE 'Pacific%';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel (VesselID INT, Name VARCHAR(255), CarrierID INT, GrossTonnage INT, YearBuilt INT); INSERT INTO Vessel (VesselID, Name, CarrierID, GrossTonnage, YearBuilt) VALUES (2, 'MSC Amsterdam', 2, 94000, 2005);
What is the GrossTonnage of all vessels owned by the carrier registered in Greece?
SELECT Vessel.GrossTonnage FROM Vessel INNER JOIN Carrier ON Vessel.CarrierID = Carrier.CarrierID WHERE Carrier.FlagState = 'Greece';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_projects (state VARCHAR(20), year INT, num_projects INT); INSERT INTO sustainable_projects (state, year, num_projects) VALUES ('New York', 2018, 1250), ('New York', 2019, 1500), ('New York', 2020, 1700);
How many sustainable building projects were completed in New York between 2018 and 2020?
SELECT SUM(num_projects) FROM sustainable_projects WHERE state = 'New York' AND year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Route (Id INT, Vessel_Id INT, Start_Port_Id INT, End_Port_Id INT, Distance INT); INSERT INTO Route (Id, Vessel_Id, Start_Port_Id, End_Port_Id, Distance) VALUES (1, 1, 3, 4, 1500), (2, 2, 3, 5, 2000);
What is the average distance of voyages starting from the port with ID 3 that lasted more than 7 days?
SELECT AVG(Distance) FROM Route R WHERE R.Start_Port_Id = 3 AND DATEDIFF(day, (SELECT Start_Date FROM Voyage WHERE Id = R.Id), (SELECT End_Date FROM Voyage WHERE Id = R.Id)) > 7;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (user_id INT, song_id INT, duration FLOAT, date DATE);
Find users who streamed different songs on the same day in 'music_streaming' table?
SELECT a.user_id, a.date as streaming_date, COUNT(DISTINCT a.song_id) as unique_songs FROM music_streaming a INNER JOIN music_streaming b ON a.user_id = b.user_id AND a.date = b.date WHERE a.song_id != b.song_id GROUP BY a.user_id, a.date HAVING COUNT(DISTINCT a.song_id) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturing(id INT, cost FLOAT, year INT, manufacturer VARCHAR(20)); INSERT INTO spacecraft_manufacturing(id, cost, year, manufacturer) VALUES (1, 5000000, 2025, 'SpaceCorp'); INSERT INTO spacecraft_manufacturing(id, cost, year, manufacturer) VALUES (2, 7000000, 2025, 'Galactic Inc');
What was the total cost of manufacturing spacecrafts in the year 2024 and 2026?
SELECT SUM(cost) FROM spacecraft_manufacturing WHERE year IN (2024, 2026);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_sourcing (id INT PRIMARY KEY, restaurant_id INT, ingredient VARCHAR(50), sourcing_percentage DECIMAL(5, 2));
Delete all records in the sustainable_sourcing table where the sourcing_percentage is 0
DELETE FROM sustainable_sourcing WHERE sourcing_percentage = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(50));
Count the number of marine species by conservation status
SELECT conservation_status, COUNT(*) FROM marine_species GROUP BY conservation_status;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_by_gender (id INT, gender VARCHAR(50), score FLOAT); INSERT INTO financial_capability_by_gender (id, gender, score) VALUES (1, 'Male', 6.5), (2, 'Female', 7.2), (3, 'Non-binary', 8.0);
What is the financial capability score distribution across different genders?
SELECT gender, AVG(score) as avg_score, STDDEV(score) as std_dev FROM financial_capability_by_gender GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance (id INT, equipment VARCHAR(255), date DATE, labor INT, parts INT); INSERT INTO Maintenance (id, equipment, date, labor, parts) VALUES (1, 'Tank', '2020-01-05', 500, 200), (2, 'Humvee', '2020-01-10', 300, 150), (3, 'Helicopter', '2020-02-15', 700, 300), (4, 'Airplane', '2020-03-20', 800, 400);
Delete all records related to equipment maintenance performed in January 2020.
DELETE FROM Maintenance WHERE date BETWEEN '2020-01-01' AND '2020-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, state VARCHAR(255), billing_amount DECIMAL(10, 2)); INSERT INTO cases (id, state, billing_amount) VALUES (1, 'California', 5000.00);
What is the average billing amount for cases in the state of California?
SELECT AVG(cases.billing_amount) AS avg_billing_amount FROM cases WHERE cases.state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralHealthFacility9 (id INT, name TEXT, age INT, diagnosis TEXT); INSERT INTO RuralHealthFacility9 (id, name, age, diagnosis) VALUES (1, 'Karen Red', 55, 'Arthritis'), (2, 'Leon Green', 60, 'Arthritis');
What is the average age of patients with 'Arthritis' in 'RuralHealthFacility9'?
SELECT AVG(age) FROM RuralHealthFacility9 WHERE diagnosis = 'Arthritis';
gretelai_synthetic_text_to_sql
CREATE TABLE shipment_deliveries (id INT, shipment_id INT, region VARCHAR(10), delivery_time INT); INSERT INTO shipment_deliveries (id, shipment_id, region, delivery_time) VALUES (1, 1001, 'Northeast', 3), (2, 1002, 'Northeast', 5), (3, 1003, 'Southeast', 4);
What is the average delivery time for shipments to the Northeast region?
SELECT AVG(delivery_time) FROM shipment_deliveries WHERE region = 'Northeast';
gretelai_synthetic_text_to_sql
CREATE TABLE Weather (location VARCHAR(20), temperature INT, date DATE); INSERT INTO Weather (location, temperature, date) VALUES ('Storage Warehouse', 15, '2022-02-01');
What is the average temperature in the Storage Warehouse in February?
SELECT AVG(temperature) FROM Weather WHERE location = 'Storage Warehouse' AND date LIKE '2022-02-%';
gretelai_synthetic_text_to_sql
CREATE TABLE ConcertTicketSales (year INT, revenue FLOAT);
What was the total revenue from concert ticket sales in 2020?
SELECT SUM(revenue) FROM ConcertTicketSales WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (id INT, vehicle_type VARCHAR(255), model_year INT, last_maintenance_date DATE, next_maintenance_date DATE); INSERT INTO vehicles (id, vehicle_type, model_year, last_maintenance_date, next_maintenance_date) VALUES (2002, 'Tram', 2018, '2022-02-10', '2022-08-10'), (2003, 'Bus', 2016, '2022-03-12', ...
How many months until the next maintenance for vehicle type 'Tram'?
SELECT vehicle_type, TIMESTAMPDIFF(MONTH, last_maintenance_date, next_maintenance_date) as months_until_next_maintenance FROM vehicles WHERE vehicle_type = 'Tram';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, program_name VARCHAR(50), program_type VARCHAR(20), org_id INT, start_date DATE, end_date DATE, budget DECIMAL(10,2));
What are the total expenses for community development programs in Africa?
SELECT SUM(budget) FROM programs WHERE program_type = 'Community Development' AND country_code = 'AF';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, sector VARCHAR(20), division VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO Projects (id, sector, division, budget) VALUES (1, 'Transportation', 'Bridges', 1000000), (2, 'Transportation', 'Roads', 1500000), (3, 'Water', 'Dams', 800000), (4, 'Transportation', 'Tunnels', 1800000), (5, 'Wat...
How many resilience projects are in the transportation and water sectors?
SELECT COUNT(*) FROM Projects WHERE sector IN ('Transportation', 'Water');
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines_uk (id INT, production FLOAT); INSERT INTO wind_turbines_uk (id, production) VALUES (1, 4.5), (2, 5.2), (3, 6.0), (4, 3.8);
What is the percentage of wind turbines in the UK that have a production value greater than 5.0?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM wind_turbines_uk WHERE production > 5.0) as percentage FROM wind_turbines_uk WHERE production > 5.0;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (id INT, loan_amount FLOAT, country VARCHAR(255)); INSERT INTO socially_responsible_lending (id, loan_amount, country) VALUES (1, 12000, 'South Africa'), (2, 15000, 'South Africa'), (3, 18000, 'South Africa');
What is the maximum loan amount for socially responsible lending in South Africa?
SELECT MAX(loan_amount) FROM socially_responsible_lending WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, state VARCHAR(2)); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (12345, 'Auto', 50000, 'TX'); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (67890, 'Home', 30000...
Update the state to 'HI' for the policy with policy number 12345.
UPDATE policies SET state = 'HI' WHERE policy_number = 12345;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_sourcing (id INT, product_id INT, ingredient_id INT, supplier_id INT, country VARCHAR(50)); INSERT INTO ingredient_sourcing (id, product_id, ingredient_id, supplier_id, country) VALUES (1, 101, 1, 201, 'France'), (2, 101, 2, 202, 'Italy'), (3, 101, 3, 203, 'Spain');
What are the ingredient sourcing details for product 101?
SELECT ingredient_id, supplier_id, country FROM ingredient_sourcing WHERE product_id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Vehicles (id INT, vehicle_type VARCHAR(255), price FLOAT, country VARCHAR(255), sale_date DATE); INSERT INTO Military_Vehicles (id, vehicle_type, price, country, sale_date) VALUES (1, 'Tank', 5000000, 'USA', '2022-01-01'); INSERT INTO Military_Vehicles (id, vehicle_type, price, country, sale_date)...
What is the average price of military vehicles sold in the US in 2022?
SELECT AVG(price) FROM Military_Vehicles WHERE country = 'USA' AND YEAR(sale_date) = 2022 AND vehicle_type = 'Tank' OR vehicle_type = 'Fighter Jet';
gretelai_synthetic_text_to_sql
CREATE TABLE Praseodymium_Production (year INT, production FLOAT); INSERT INTO Praseodymium_Production (year, production) VALUES (2015, 2000), (2016, 2100), (2017, 2300), (2018, 2500), (2019, 2700), (2020, 2900);
What is the percentage change in Praseodymium production from 2018 to 2019?
SELECT ((production[year=2019] - production[year=2018])/production[year=2018])*100 FROM Praseodymium_Production WHERE year IN (2018, 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_gender TEXT, industry TEXT); INSERT INTO company (id, name, founding_year, founder_gender, industry) VALUES (1, 'Acme Inc', 2010, 'female', 'healthcare'); INSERT INTO company (id, name, founding_year, founder_gender, industry) VALUES (2, 'Beta Corp', 2...
What is the sum of funding raised for companies with a female founder in the healthcare sector?
SELECT SUM(funding_raised) FROM investment_rounds INNER JOIN company ON investment_rounds.company_id = company.id WHERE company.founder_gender = 'female' AND company.industry = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(255), international_designator VARCHAR(20));
Update satellites with 'USA' in the name to have 'United States' instead
UPDATE satellites SET name = REPLACE(name, 'USA', 'United States') WHERE name LIKE '%USA%';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (PolicyID int, ClaimAmount int, SaleCountry varchar(20)); INSERT INTO Claims (PolicyID, ClaimAmount, SaleCountry) VALUES (1, 500, 'USA'), (2, 2000, 'Canada'), (3, 800, 'Mexico'), (4, 1500, 'USA');
What is the maximum claim amount for policies sold in each country?
SELECT SaleCountry, MAX(ClaimAmount) OVER (PARTITION BY SaleCountry) as MaxClaimAmount FROM Claims;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_age_gender (person_id INT, age INT, gender VARCHAR(6), score INT); INSERT INTO financial_wellbeing_age_gender (person_id, age, gender, score) VALUES (1, 25, 'Male', 7), (2, 35, 'Female', 8), (3, 45, 'Male', 9), (4, 55, 'Female', 6), (5, 65, 'Male', 8);
What is the average financial wellbeing score for each age group and gender?
SELECT FLOOR(age / 10) * 10 AS age_group, gender, AVG(score) FROM financial_wellbeing_age_gender GROUP BY age_group, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE drivers (driver_id INT, driver_name VARCHAR(255)); CREATE TABLE trips (trip_id INT, driver_id INT, route_id INT, trip_date DATE);
Which drivers have completed more than 500 trips on route 101?
SELECT d.driver_name FROM drivers d INNER JOIN trips t ON d.driver_id = t.driver_id WHERE t.route_id = 101 GROUP BY d.driver_name HAVING COUNT(t.trip_id) > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE geological_survey (location VARCHAR(255), mineral VARCHAR(255), quantity FLOAT, year INT); INSERT INTO geological_survey (location, mineral, quantity, year) VALUES ('Mine A', 'Gold', 1000, 2015), ('Mine A', 'Silver', 2000, 2015), ('Mine B', 'Gold', 1500, 2016), ('Mine B', 'Silver', 2500, 2016);
What is the total quantity of gold and silver extracted by each location?
SELECT location, SUM(CASE WHEN mineral = 'Gold' THEN quantity ELSE 0 END) as total_gold, SUM(CASE WHEN mineral = 'Silver' THEN quantity ELSE 0 END) as total_silver FROM geological_survey GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai (project_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO ethical_ai (project_id, region, budget) VALUES (1, 'North America', 60000.00), (2, 'Europe', 40000.00), (3, 'North America', 70000.00);
What is the minimum budget required for ethical AI projects in North America?
SELECT MIN(budget) FROM ethical_ai WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, transaction_date DATE); INSERT INTO transactions (transaction_id, transaction_date) VALUES (1, '2021-01-01'), (2, '2021-01-01'), (3, '2021-01-02'), (4, '2021-01-03'), (5, '2021-01-03'), (6, '2021-01-04');
What is the maximum number of transactions per day?
SELECT MAX(transaction_count) FROM (SELECT COUNT(*) AS transaction_count FROM transactions GROUP BY transaction_date) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, user_name TEXT);CREATE TABLE posts (post_id INT, post_text TEXT, user_id INT, post_date DATE);
How many posts were made by each user in the last month?
SELECT u.user_id, u.user_name, COUNT(p.post_id) as posts_last_month FROM users u JOIN posts p ON u.user_id = p.user_id WHERE p.post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY u.user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo (id INT, vessel_name VARCHAR(255), port_name VARCHAR(255), weight INT); INSERT INTO cargo (id, vessel_name, port_name, weight) VALUES (1, 'Seafarer', 'Port of Los Angeles', 5000), (2, 'Oceanus', 'Port of New York', 7000), (3, 'Neptune', 'Port of Singapore', 6000), (4, 'Seafarer', 'Port of Los Angeles...
What is the average cargo weight handled by the ACME Shipping Company per port call?
SELECT AVG(weight) FROM cargo WHERE vessel_name IN (SELECT name FROM vessels WHERE company = 'ACME Shipping') GROUP BY port_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (Brand_ID INT, Brand_Name TEXT, Country TEXT); INSERT INTO Brands (Brand_ID, Brand_Name, Country) VALUES (1, 'Lush', 'UK'), (2, 'The Body Shop', 'France'), (3, 'Estée Lauder', 'USA'), (4, 'Natural Beauty', 'Germany'); CREATE TABLE Sales (Sale_ID INT, Brand_ID INT, Sale_Amount INT); INSERT INTO Sales...
What is the average sale amount for each country in the EU?
SELECT B.Country, AVG(S.Sale_Amount) FROM Brands B INNER JOIN Sales S ON B.Brand_ID = S.Brand_ID WHERE B.Country IN ('UK', 'France', 'Germany') GROUP BY B.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist_id INT, location TEXT, price DECIMAL);
Get the total revenue for concerts by each artist.
SELECT artist_id, SUM(price) FROM concerts GROUP BY artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Conservation_Initiatives(id INT, initiative_name VARCHAR(50), region VARCHAR(50), status VARCHAR(50), start_date DATE, end_date DATE);
What is the number of marine conservation initiatives by status?
SELECT status, COUNT(*) AS Number_Of_Initiatives FROM Conservation_Initiatives GROUP BY status;
gretelai_synthetic_text_to_sql
CREATE TABLE COD_Players (PlayerID INT, Player VARCHAR(50), Kills INT, Deaths INT, Game VARCHAR(50)); INSERT INTO COD_Players (PlayerID, Player, Kills, Deaths, Game) VALUES (1, 'Jamal', 100, 50, 'Call of Duty'); INSERT INTO COD_Players (PlayerID, Player, Kills, Deaths, Game) VALUES (2, 'Amina', 120, 60, 'Call of Duty')...
Show player names and their highest killstreak for 'Call of Duty'.
SELECT Player, MAX(Kills - Deaths) AS Highest_Killstreak FROM COD_Players WHERE Game = 'Call of Duty' GROUP BY Player;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists smart_cities; CREATE TABLE if not exists smart_cities.projects (id INT, project_name VARCHAR, location VARCHAR); CREATE TABLE if not exists smart_cities.technologies (id INT, project_id INT, technology_category VARCHAR); INSERT INTO smart_cities.projects (id, project_name, location) VALUES (...
List all smart city projects and their corresponding technology categories in the 'smart_cities' schema.
SELECT smart_cities.projects.project_name, smart_cities.technologies.technology_category FROM smart_cities.projects INNER JOIN smart_cities.technologies ON smart_cities.projects.id = smart_cities.technologies.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Publications (id INT PRIMARY KEY, title VARCHAR(255), author_id INT, year INT, FOREIGN KEY (author_id) REFERENCES Archaeologists(id)); INSERT INTO Publications (id, title, author_id, year) VALUES (1, 'Uncovering the Secrets of the Maya', 2, 2018), (2, 'The Forgotten Kingdom: Inca Civilization', 3, 2020), (...
List all publications by a specific author
SELECT * FROM Publications WHERE author_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Desserts (dessert_name VARCHAR(50), flavor VARCHAR(20), price DECIMAL(5,2), sales INTEGER); INSERT INTO Desserts (dessert_name, flavor, price, sales) VALUES ('Chocolate Cake', 'Chocolate', 5.99, 0), ('Cheesecake', 'Vanilla', 6.49, 0), ('Apple Pie', 'Cinnamon', 4.99, 0), ('Tiramisu', 'Coffee', 7.50, 0);
What is the most popular dessert item by customer count?
SELECT dessert_name, MAX(sales) FROM Desserts;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_beds INT, territory TEXT, has_helipad BOOLEAN); INSERT INTO hospitals (id, name, location, num_beds, territory, has_helipad) VALUES (1, 'Hospital A', 'Rural Nunavut', 20, 'Nunavut', true), (2, 'Hospital B', 'Rural Northwest Territories', 25, 'Northwest Terri...
What is the number of rural hospitals and clinics in each territory, and the number of hospitals with a helipad in each?
SELECT t.territory, COUNT(h.id) AS num_hospitals, COUNT(c.id) AS num_clinics, COUNT(h2.id) AS num_hospitals_with_helipad FROM hospitals h INNER JOIN clinics c ON h.territory = c.territory INNER JOIN hospitals h2 ON h.territory = h2.territory AND h2.has_helipad = true GROUP BY t.territory;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ai_interactions (hotel_id INT, interaction_date DATE, ai_chatbot_interactions INT); INSERT INTO hotel_ai_interactions (hotel_id, interaction_date, ai_chatbot_interactions) VALUES (1, '2021-12-12', 150), (2, '2022-01-15', 120), (3, '2022-02-20', 180), (4, '2022-03-17', 200);
What is the minimum number of AI chatbot interactions in the EU in the last year?
SELECT MIN(ai_chatbot_interactions) FROM hotel_ai_interactions WHERE interaction_date >= DATEADD(year, -1, GETDATE()) AND region = 'EU';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, industry TEXT); CREATE TABLE services (id INT, supplier_id INT, department TEXT, date DATE); INSERT INTO suppliers (id, name, industry) VALUES (1, 'Supplier A', 'Manufacturing'), (2, 'Supplier B', 'Electronics'); INSERT INTO services (id, supplier_id, department, date) VALUES ...
Which suppliers have not provided any services to the assembly department in the past year?
SELECT DISTINCT s.name FROM suppliers s LEFT JOIN services se ON s.id = se.supplier_id WHERE se.department = 'Assembly' AND se.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Prawn_Farms (Farm_ID INT, Farm_Name TEXT, Water_pH FLOAT); INSERT INTO Prawn_Farms (Farm_ID, Farm_Name, Water_pH) VALUES (1, 'Farm J', 7.8); INSERT INTO Prawn_Farms (Farm_ID, Farm_Name, Water_pH) VALUES (2, 'Farm K', 7.5); INSERT INTO Prawn_Farms (Farm_ID, Farm_Name, Water_pH) VALUES (3, 'Farm L', 7.2);
What is the minimum water pH level in Prawn Farms?
SELECT MIN(Water_pH) FROM Prawn_Farms;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Gender VARCHAR(10), Ethnicity VARCHAR(20), YearsOfExperience INT); INSERT INTO CommunityHealthWorkers (WorkerID, Gender, Ethnicity, YearsOfExperience) VALUES (1, 'Female', 'Hispanic', 5), (2, 'Male', 'African American', 10), (3, 'Female', 'Asian', 7), (4, 'Male', 'Nati...
What is the diversity score for each community health worker?
SELECT WorkerID, (YearsOfExperience + CASE WHEN Gender = 'Female' THEN 10 ELSE 5 END + CASE WHEN Ethnicity IN ('Hispanic', 'African American', 'Asian', 'Native American') THEN 15 ELSE 0 END) / 3 AS DiversityScore FROM CommunityHealthWorkers;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, user_id INT, country VARCHAR(255), tour_date DATE); INSERT INTO virtual_tours (tour_id, user_id, country, tour_date) VALUES (1, 1001, 'Egypt', '2022-02-03'), (2, 1002, 'South Africa', '2022-04-10'), (3, 1003, 'Morocco', '2022-01-15');
How many users engaged with virtual tours in 'Africa' during each month of 2022?
SELECT country, EXTRACT(MONTH FROM tour_date) AS month, COUNT(DISTINCT user_id) FROM virtual_tours WHERE country = 'Africa' AND tour_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY country, month;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(50), type VARCHAR(50), orbit VARCHAR(50), mass FLOAT, years_in_orbit INT); INSERT INTO space_debris (id, name, type, orbit, mass, years_in_orbit) VALUES (1, 'Debris1', 'Panel', 'LEO', 50.3, 12), (2, 'Debris2', 'Bolt', 'LEO', 0.05, 3), (3, 'Debris3', 'Rod', 'LEO', 2.8, 8);
Find the total mass of all space debris in Low Earth Orbit (LEO) that have been in orbit for more than 10 years.
SELECT SUM(mass) FROM space_debris WHERE orbit = 'LEO' AND years_in_orbit > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (id INT, mission_name VARCHAR(50), location VARCHAR(50), year INT, budget INT);
What is the minimum budget allocated to humanitarian assistance missions in the Middle East since 2016?
SELECT MIN(budget) FROM humanitarian_assistance WHERE location LIKE '%Middle East%' AND year >= 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehiclesGermany (vehicle_id INT, model VARCHAR(100), co2_emissions DECIMAL(5,2), country VARCHAR(50), year INT); INSERT INTO ElectricVehiclesGermany (vehicle_id, model, co2_emissions, country, year) VALUES (1, 'Model Y', 0, 'Germany', 2021), (2, 'E-Golf', 0, 'Germany', 2021);
What is the average CO2 emission of electric vehicles sold in Germany in 2021?
SELECT AVG(co2_emissions) FROM ElectricVehiclesGermany WHERE country = 'Germany' AND year = 2021 AND co2_emissions > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE systems (system_id INT, system_name VARCHAR(255), department VARCHAR(255));CREATE TABLE cve_scores (system_id INT, score INT, scan_date DATE);CREATE TABLE scan_dates (scan_date DATE, system_id INT);
What are the total CVE scores and number of scans for each system in the IT department in the last month?
SELECT s.system_name, SUM(c.score) as total_score, COUNT(sd.scan_date) as scan_count FROM systems s INNER JOIN cve_scores c ON s.system_id = c.system_id INNER JOIN scan_dates sd ON s.system_id = sd.system_id WHERE s.department = 'IT' AND sd.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY s.system_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Production (production_id INT, material_id INT, production_quantity INT); INSERT INTO Production (production_id, material_id, production_quantity) VALUES (1, 1, 500), (2, 2, 800), (3, 1, 600), (4, 2, 700), (5, 3, 900), (6, 3, 1000); CREATE TABLE Materials (material_id INT, material_name VARCHAR(50)); INSER...
What is the average production quantity for each material?
SELECT m.material_name, AVG(production_quantity) FROM Production p INNER JOIN Materials m ON p.material_id = m.material_id GROUP BY m.material_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), region VARCHAR(255)); CREATE TABLE climate_change_impact (id INT, species_id INT, impact VARCHAR(255)); INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Coral Reef', 'Pacific'), (2, 'Kelp', 'Atlantic'); INSERT INTO climate_change_impact (i...
Show the impact of climate change on coral reefs in the Pacific region.
SELECT marine_species.species_name, climate_change_impact.impact FROM marine_species INNER JOIN climate_change_impact ON marine_species.id = climate_change_impact.species_id WHERE marine_species.species_name = 'Coral Reef' AND marine_species.region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE EventDates (EventID INT, EventDate DATE); INSERT INTO EventDates (EventID, EventDate) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-01-15');
Determine the average number of games played by players who joined esports events in each country, with a ranking.
SELECT E.EventCountry, AVG(TotalGames) AS AvgGamesPlayed, RANK() OVER (ORDER BY AVG(TotalGames) DESC) AS Rank FROM Players P JOIN EventParticipation EP ON P.PlayerID = EP.PlayerID GROUP BY E.EventCountry
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), network VARCHAR(255), creation_date DATE); INSERT INTO digital_assets (asset_id, name, network, creation_date) VALUES (1, 'Asset1', 'solana', '2022-02-01'), (2, 'Asset2', 'ethereum', '2022-01-01'); CREATE TABLE smart_contracts (contract_id INT, network VARCH...
What are the names of the digital assets in the 'solana' network that were created after the latest updated smart contract?
SELECT name FROM digital_assets WHERE network = 'solana' AND creation_date > (SELECT MAX(last_updated) FROM smart_contracts WHERE network = 'solana');
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO rural_hospitals (id, name, location, capacity) VALUES (1, 'Hospital A', 'City1', 50), (2, 'Hospital B', 'City2', 75);
How many rural hospitals are in the "rural_hospitals" table?
SELECT COUNT(*) FROM rural_hospitals;
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (id INT, permit_number TEXT, permit_type TEXT, date DATE, location TEXT);
How many building permits were issued for residential construction in Canada in the last 12 months?
SELECT COUNT(*) FROM Building_Permits WHERE permit_type = 'Residential' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_transactions (id INT, buyer_id INT, seller_id INT, type VARCHAR(15), amount INT, date DATE); INSERT INTO renewable_energy_transactions (id, buyer_id, seller_id, type, amount, date) VALUES (1, 1001, 2001, 'Solar Energy', 300, '2023-01-01');
What is the total amount of solar energy sold by each seller in 2023?
SELECT seller_id, SUM(amount) as total_solar_sold FROM renewable_energy_transactions WHERE type = 'Solar Energy' AND date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY seller_id;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, garment_type VARCHAR(20), color VARCHAR(20), price DECIMAL(10, 2), quantity INT);
What is the total revenue generated from garment sales?
SELECT SUM(price * quantity) AS total_revenue FROM sales;
gretelai_synthetic_text_to_sql
CREATE TABLE grad_students (id INT, name TEXT, gpa DECIMAL(3,2), department TEXT); INSERT INTO grad_students (id, name, gpa, department) VALUES (1, 'Kai', 3.9, 'Physics'); INSERT INTO grad_students (id, name, gpa, department) VALUES (2, 'Lena', 3.7, 'Math'); INSERT INTO grad_students (id, name, gpa, department) VALUES ...
What is the average GPA of graduate students in the Art department?
SELECT department, AVG(gpa) FROM grad_students WHERE department = 'Art'
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT, product_id INT, revenue DECIMAL(5,2)); INSERT INTO suppliers (supplier_id, supplier_name, product_id, revenue) VALUES (1, 'Supplier A', 1, 1000.00); INSERT INTO suppliers (supplier_id, supplier_name, product_id, revenue) VALUES (2, 'Supplier B', 2, 2000.00); ...
What is the total revenue for each supplier?
SELECT supplier_name, SUM(revenue) FROM suppliers GROUP BY supplier_name;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population(animal_id INT, animal_name VARCHAR(50), category VARCHAR(20), year INT);INSERT INTO animal_population VALUES (1, 'Tiger', 'Exotic', 2021), (2, 'Giraffe', 'Exotic', 2022);CREATE TABLE community_education(animal_id INT, program_year INT);INSERT INTO community_education VALUES (1, 2022), (3,...
What is the total number of animals in the 'exotic' category that were part of community education programs in '2022'?
SELECT SUM(cp.animal_id) FROM community_education cp JOIN animal_population ap ON cp.animal_id = ap.animal_id WHERE ap.category = 'Exotic' AND cp.program_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program_id INT, signup_date DATE); CREATE TABLE programs (program_id INT, program_name TEXT); INSERT INTO programs VALUES (1, 'Food Bank'); INSERT INTO programs VALUES (2, 'Education Support');
How many volunteers signed up for each program in Q1 2021?
SELECT program_id, program_name, COUNT(volunteer_id) as num_volunteers FROM volunteers JOIN programs ON volunteers.program_id = programs.program_id WHERE QUARTER(signup_date) = 1 AND YEAR(signup_date) = 2021 GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS visitors (id INT PRIMARY KEY, visitor_name TEXT, country TEXT, destination TEXT, visit_date DATE); INSERT INTO visitors (id, visitor_name, country, destination, visit_date) VALUES (1, 'John Doe', 'USA', 'France', '2020-07-01'), (2, 'Jane Smith', 'Canada', 'Germany', '2020-10-15'), (3, 'Mike J...
Find the total number of visitors from the USA who visited European destinations in 2020.
SELECT COUNT(*) FROM visitors WHERE country = 'USA' AND EXTRACT(YEAR FROM visit_date) = 2020 AND destination LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, project_name VARCHAR, start_date DATE, end_date DATE);
How many cross-border defense projects are currently ongoing?
SELECT COUNT(*) FROM defense_projects WHERE start_date < CURDATE() AND end_date > CURDATE();
gretelai_synthetic_text_to_sql
CREATE SCHEMA disability_services; CREATE TABLE staff (id INT, name VARCHAR(50), accommodation VARCHAR(50)); CREATE TABLE students (id INT, name VARCHAR(50), accommodation VARCHAR(50));
What is the total number of distinct accommodation types offered to students and staff in the "disability_services" schema, excluding the "service_animal" and "accessibility_parking" types?
SELECT COUNT(DISTINCT accommodation) FROM disability_services.staff WHERE accommodation NOT IN ('service_animal', 'accessibility_parking') UNION SELECT COUNT(DISTINCT accommodation) FROM disability_services.students WHERE accommodation NOT IN ('service_animal', 'accessibility_parking');
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.research (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255)); INSERT INTO biotech.research (id, name, country, type) VALUES (1, 'ProjectA', 'India', 'Genetics'), (2, 'ProjectB', 'China', 'Bioprocess'), (3, 'ProjectC', '...
How many genetic research projects are being conducted in India and China?
SELECT COUNT(*) FROM biotech.research WHERE type = 'Genetics' AND (country = 'India' OR country = 'China');
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance (id INT, maintenance_date DATE, equipment_id INT, maintenance_cost FLOAT);
What is the total value of military equipment maintenance in the last month?
SELECT SUM(maintenance_cost) FROM Maintenance WHERE maintenance_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND equipment_type = 'Military';
gretelai_synthetic_text_to_sql
CREATE TABLE Feedback (Service TEXT, Score INTEGER); INSERT INTO Feedback (Service, Score) VALUES ('Public Transportation', 8), ('Healthcare', 7), ('Education', 9);
What is the average citizen feedback score for public transportation services?
SELECT AVG(Score) FROM Feedback WHERE Service = 'Public Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID INT, Age INT, DiversityTraining BOOLEAN); INSERT INTO EmployeeTraining (EmployeeID, Age, DiversityTraining) VALUES (1, 35, TRUE), (2, 40, FALSE), (3, 30, TRUE);
What is the average age of employees who have completed diversity training?
SELECT AVG(Age) FROM EmployeeTraining WHERE DiversityTraining = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Exhibitions (id INT, country VARCHAR(255), year INT, visitors_per_day INT);
What is the maximum number of visitors per day for digital exhibitions in Spain during 2022?
SELECT MAX(visitors_per_day) FROM Digital_Exhibitions WHERE country = 'Spain' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_name VARCHAR(50), year INT, num_schools INT); INSERT INTO regions VALUES ('North', 2020, 50); INSERT INTO regions VALUES ('North', 2021, 55); INSERT INTO regions VALUES ('South', 2020, 60); INSERT INTO regions VALUES ('South', 2021, 63);
What is the change in the number of public schools in each region between 2020 and 2021?
SELECT region_name, (LEAD(num_schools) OVER (PARTITION BY region_name ORDER BY year) - num_schools) as change_in_num_schools FROM regions;
gretelai_synthetic_text_to_sql