context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE oceania_wonders (id INT, country TEXT, nature_visits INT); INSERT INTO oceania_wonders VALUES (1, 'Australia', 2000), (2, 'New Zealand', 3000); CREATE TABLE central_america_wonders (id INT, country TEXT, nature_visits INT); INSERT INTO central_america_wonders VALUES (1, 'Costa Rica', 5000), (2, 'Panama', 4000);
What is the percentage of international tourists visiting natural wonders in Oceania compared to Central America?
SELECT 100.0 * SUM(nature_visits) / (SELECT SUM(nature_visits) FROM central_america_wonders) FROM oceania_wonders
gretelai_synthetic_text_to_sql
CREATE TABLE Forests ( ForestID INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Hectares FLOAT ); CREATE TABLE Wildlife ( WildlifeID INT PRIMARY KEY, Species VARCHAR(50), Population INT, ForestID INT, FOREIGN KEY (ForestID) REFERENCES Forests(ForestID)); CREATE VIEW SizablePopulation AS SELECT Species, Population FROM Wildlife WHERE Population > 300;
What forests have a sizable wildlife population?
SELECT Forests.Name, SizablePopulation.Species, SizablePopulation.Population FROM Forests INNER JOIN SizablePopulation ON Forests.ForestID = SizablePopulation.ForestID;
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections (restaurant_id INT, inspection_date DATE, violation_count INT);
Insert new records in the food_safety_inspections table with random restaurant_ids and violation_counts, and an inspection_date of '2023-01-18'
INSERT INTO food_safety_inspections (restaurant_id, inspection_date, violation_count) VALUES (FLOOR(RAND()*(SELECT MAX(restaurant_id) FROM food_safety_inspections))+1, '2023-01-18', FLOOR(RAND()*6)+1);
gretelai_synthetic_text_to_sql
CREATE TABLE freshwater_farms (id INT, species VARCHAR(50), biomass FLOAT); INSERT INTO freshwater_farms (id, species, biomass) VALUES (1, 'Tilapia', 1500.0), (2, 'Catfish', 2000.0); CREATE TABLE marine_farms (id INT, species VARCHAR(50), biomass FLOAT); INSERT INTO marine_farms (id, species, biomass) VALUES (1, 'Tuna', 2500.0), (2, 'Salmon', 1000.0);
What is the difference in biomass between freshwater and marine species?
SELECT SUM(freshwater_farms.biomass) - SUM(marine_farms.biomass) FROM freshwater_farms, marine_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT PRIMARY KEY, name VARCHAR(255), objective TEXT);
What was the primary objective of the Mars Science Laboratory mission?
SELECT objective FROM SpaceMissions WHERE name = 'Mars Science Laboratory';
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 a new genetic research project in India
INSERT INTO biotech.research (id, name, country, type) VALUES (5, 'ProjectE', 'India', 'Genetics');
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_usage (usage_id INT, fabric VARCHAR(255), garment_type VARCHAR(255), usage_quantity INT, usage_date DATE); CREATE TABLE garment_info (garment_id INT, garment_type VARCHAR(255), season VARCHAR(255));
How many units of a specific fabric were used in garment manufacturing for the Spring 2022 season?
SELECT usage_quantity FROM fabric_usage JOIN garment_info ON fabric_usage.garment_type = garment_info.garment_type WHERE fabric = 'silk' AND season = 'Spring 2022';
gretelai_synthetic_text_to_sql
CREATE TABLE BarentsSea.wells (well_id INT, depth FLOAT); INSERT INTO BarentsSea.wells (well_id, depth) VALUES (1, 1200.5), (2, 1500.3), (3, 1750.2);
List all wells and their depths in the 'BarentsSea' schema.
SELECT well_id, depth FROM BarentsSea.wells;
gretelai_synthetic_text_to_sql
CREATE TABLE CUSTOMER_INTERESTS(city VARCHAR(20), interest VARCHAR(20)); INSERT INTO CUSTOMER_INTERESTS(city, interest) VALUES('Seoul', 'Sustainable Fashion'), ('Seoul', 'Fast Fashion'), ('Seoul', 'Luxury'), ('Seoul', 'Sustainable Fashion'), ('Seoul', 'Fast Fashion');
What percentage of customers in Seoul are interested in sustainable fashion?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM CUSTOMER_INTERESTS WHERE city = 'Seoul')) FROM CUSTOMER_INTERESTS WHERE city = 'Seoul' AND interest = 'Sustainable Fashion';
gretelai_synthetic_text_to_sql
CREATE TABLE Businesses (id INT PRIMARY KEY, gender VARCHAR(10), funded_project BOOLEAN);CREATE TABLE RuralInfrastructure (id INT PRIMARY KEY, business_id INT);
How many women-led businesses received funding for rural infrastructure projects since 2015?
SELECT COUNT(*) FROM Businesses INNER JOIN RuralInfrastructure ON Businesses.id = RuralInfrastructure.business_id WHERE gender = 'women' AND funded_project = TRUE AND YEAR(RuralInfrastructure.project_date) >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE compliance (compliance_id INT, regulation VARCHAR(100), description VARCHAR(255), compliance_date DATE);
Insert a new compliance record into the compliance table
INSERT INTO compliance (compliance_id, regulation, description, compliance_date) VALUES (4001, 'Net Neutrality', 'Complied with net neutrality regulations', '2021-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(255), state VARCHAR(255), financial_wellbeing_score INT);
What is the distribution of financial wellbeing scores for customers in California?
SELECT state, COUNT(*) as count, MIN(financial_wellbeing_score) as min_score, AVG(financial_wellbeing_score) as avg_score, MAX(financial_wellbeing_score) as max_score FROM customers WHERE state = 'California' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO patients (id, name, age, gender) VALUES (1, 'John Doe', 45, 'Male'), (2, 'Jane Smith', 35, 'Female'), (3, 'Alice Johnson', 50, 'Female');
What is the total number of patients by age range and gender?
SELECT CASE WHEN age < 30 THEN 'Under 30' WHEN age < 50 THEN '30-49' ELSE '50 and over' END AS age_range, gender, COUNT(*) FROM patients GROUP BY age_range, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE audience (id INT PRIMARY KEY, name VARCHAR(100), age INT, country VARCHAR(50));
Update the "audience" table to reflect a change in the age of a visitor from Spain
UPDATE audience SET age = 30 WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mining_type VARCHAR(255), country VARCHAR(255), water_consumption FLOAT); INSERT INTO mining_operations (id, mining_type, country, water_consumption) VALUES (1, 'open pit', 'Canada', 10000), (2, 'underground', 'Canada', 15000), (3, 'open pit', 'Canada', 12000);
What is the average water consumption per mining operation in Canada, partitioned by the mining type, ordered by the highest consumption?
SELECT mining_type, AVG(water_consumption) as avg_water_consumption FROM mining_operations WHERE country = 'Canada' GROUP BY mining_type ORDER BY avg_water_consumption DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE operators (operator_id INT, operator_name TEXT, country TEXT); INSERT INTO operators (operator_id, operator_name, country) VALUES (1, 'Operator A', 'USA'), (2, 'Operator B', 'Canada'), (3, 'Operator C', 'Mexico'), (4, 'Operator D', 'Brazil');
Delete all records from the 'operators' table where the operator is not based in the United States or Canada.
DELETE FROM operators WHERE country NOT IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE Mines (MineID INT, MineType VARCHAR(20), ProductionCapacity INT); INSERT INTO Mines (MineID, MineType, ProductionCapacity) VALUES (1, 'Coal', 500000); INSERT INTO Mines (MineID, MineType, ProductionCapacity) VALUES (2, 'Gold', 200000); INSERT INTO Mines (MineID, MineType, ProductionCapacity) VALUES (3, 'Gold', 300000);
What is the minimum production capacity of the Australian gold mines?
SELECT MIN(ProductionCapacity) FROM Mines WHERE MineType = 'Gold' AND Country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (ID INT PRIMARY KEY, Name TEXT); CREATE TABLE Research_Facilities (ID INT PRIMARY KEY, Country_ID INT, Name TEXT);
List all unique countries with space research facilities
SELECT DISTINCT c.Name FROM Countries c INNER JOIN Research_Facilities rf ON c.ID = rf.Country_ID;
gretelai_synthetic_text_to_sql
CREATE TABLE user_calories (user_id INT, date DATE, calories INT); INSERT INTO user_calories (user_id, date, calories) VALUES (1, '2022-03-01', 300), (1, '2022-03-02', 350), (2, '2022-03-01', 250), (2, '2022-03-02', 200), (1, '2022-03-03', 400), (3, '2022-03-01', 500), (3, '2022-03-02', 600), (3, '2022-03-03', 700);
Find the total calories burned per day for the top 5 most active users in the last week.
SELECT SUM(calories) FROM (SELECT user_id, date, SUM(calories) as calories FROM user_calories WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY user_id, date ORDER BY calories DESC LIMIT 5) as temp;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities ( id INT PRIMARY KEY, city_name VARCHAR(255), region VARCHAR(255), project_count INT ); INSERT INTO smart_cities (id, city_name, region, project_count) VALUES (1, 'Barcelona', 'Europe', 35); INSERT INTO smart_cities (id, city_name, region, project_count) VALUES (2, 'San Francisco', 'North America', 27);
Identify the smart city project with the highest project count
SELECT city_name, project_count FROM smart_cities ORDER BY project_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 8.5), (2, 'finance', 7.3), (3, 'technology', 8.7);
What is the sum of ESG ratings for all companies?
SELECT SUM(ESG_rating) FROM companies;
gretelai_synthetic_text_to_sql
CREATE TABLE media_ethics (id INT, ethical_issue VARCHAR(255), description TEXT, resolution DATE);
Update the resolution date of the 'plagiarism' record in the 'media_ethics' table
UPDATE media_ethics SET resolution = '2022-12-31' WHERE ethical_issue = 'Plagiarism';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT);CREATE TABLE research_grant (id INT, department_id INT, amount INT);
What is the maximum amount of a research grant awarded to the Mathematics department?
SELECT MAX(rg.amount) FROM research_grant rg WHERE rg.department_id IN (SELECT id FROM department WHERE name = 'Mathematics');
gretelai_synthetic_text_to_sql
CREATE TABLE CourtCasesByJudge (CaseID INT, JudgeName VARCHAR(20), Year INT); INSERT INTO CourtCasesByJudge (CaseID, JudgeName, Year) VALUES (1, 'Judge1', 2021), (2, 'Judge2', 2021), (3, 'Judge1', 2021);
What is the maximum number of court cases heard by each judge in the last year?
SELECT JudgeName, MAX(COUNT(*)) FROM CourtCasesByJudge GROUP BY JudgeName;
gretelai_synthetic_text_to_sql
CREATE TABLE hospital_funding (state VARCHAR(255), year INT, hospital_name VARCHAR(255), funding_amount FLOAT); INSERT INTO hospital_funding (state, year, hospital_name, funding_amount) VALUES ('Texas', 2022, 'Hospital A', 1000000.00), ('Texas', 2022, 'Hospital B', 1500000.00), ('Texas', 2022, 'Hospital C', 1200000.00); CREATE TABLE hospitals (hospital_name VARCHAR(255), hospital_type VARCHAR(255)); INSERT INTO hospitals (hospital_name, hospital_type) VALUES ('Hospital A', 'Public'), ('Hospital B', 'Private'), ('Hospital C', 'Public');
Identify the public hospital with the lowest funding in the state of Texas in 2022, using an inner join.
SELECT f.hospital_name, f.funding_amount FROM hospital_funding f INNER JOIN hospitals h ON f.hospital_name = h.hospital_name WHERE f.state = 'Texas' AND f.year = 2022 ORDER BY f.funding_amount ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE households (id INT, head_of_household_gender VARCHAR(255), camp_id INT); INSERT INTO households (id, head_of_household_gender, camp_id) VALUES (1, 'Female', 1001), (2, 'Male', 1001), (3, 'Female', 1002); CREATE TABLE aid (id INT, camp_id INT, amount FLOAT); INSERT INTO aid (id, camp_id, amount) VALUES (1001, 1001, 500), (1002, 1001, 500), (1003, 1002, 700);
How many female-led households receive aid in camps?
SELECT COUNT(*) FROM households h JOIN aid a ON h.camp_id = a.camp_id WHERE h.head_of_household_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_loans (id INT PRIMARY KEY, customer_id INT, amount DECIMAL(10,2), date DATE);
What is the total amount of Shariah-compliant loans issued by the bank?
SELECT SUM(amount) FROM shariah_loans;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (year INT, sector VARCHAR(20), savings FLOAT); INSERT INTO conservation_initiatives (year, sector, savings) VALUES (2019, 'commercial', 3000);
How much water was saved by the conservation initiative in the commercial sector in 2019?
SELECT SUM(savings) FROM conservation_initiatives WHERE year = 2019 AND sector = 'commercial';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR(255), max_depth FLOAT);
What is the maximum depth recorded for any marine species?
SELECT max_depth FROM marine_species ORDER BY max_depth DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, region VARCHAR(50)); INSERT INTO Donations (donor_id, donation_amount, donation_date, region) VALUES (1, 500, '2021-01-01', 'Pacific'), (2, 250, '2021-02-01', 'Pacific'), (3, 750, '2021-03-01', 'Atlantic');
What was the average donation amount from individual donors in the Pacific region in 2021?
SELECT AVG(donation_amount) FROM Donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' AND region = 'Pacific' AND donor_id NOT IN (SELECT donor_id FROM Donations WHERE donation_type = 'Corporate');
gretelai_synthetic_text_to_sql
CREATE TABLE sector (sector_id INT, sector VARCHAR(50)); INSERT INTO sector (sector_id, sector) VALUES (1, 'Banking'), (2, 'Retail'), (3, 'Real Estate'), (4, 'Technology');
What are the names of clients that have made transactions in every sector?
SELECT client_name FROM client c WHERE NOT EXISTS (SELECT 1 FROM sector s WHERE NOT EXISTS (SELECT 1 FROM transaction t WHERE t.client_id = c.client_id AND t.sector = s.sector));
gretelai_synthetic_text_to_sql
CREATE TABLE bus_maintanence (bus_id INT, bus_model VARCHAR(255), bus_year INT, last_maintenance_date DATE); INSERT INTO bus_maintanence (bus_id, bus_model, bus_year, last_maintenance_date) VALUES (1, 'Bus 1', 2010, '2022-02-01'), (2, 'Bus 2', 2015, '2022-03-01'), (3, 'Bus 3', 2012, '2022-01-01');
Insert a new bus with bus_id 6, bus_model 'Electra', bus_year 2025, and last_maintenance_date '2022-02-01' into the bus_maintanence table
INSERT INTO bus_maintanence (bus_id, bus_model, bus_year, last_maintenance_date) VALUES (6, 'Electra', 2025, '2022-02-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, item_name VARCHAR(50), material VARCHAR(50), revenue INT, location VARCHAR(50)); INSERT INTO Sales (id, item_name, material, revenue, location) VALUES (1, 'Shirt', 'Organic Cotton', 25, 'USA'), (2, 'Pants', 'Hemp', 30, 'Canada'), (3, 'Jacket', 'Recycled Polyester', 50, 'USA'), (4, 'Shirt', 'Tencel', 20, 'Canada'), (5, 'Skirt', 'Bamboo', 35, 'Mexico');
What is the total revenue generated from sustainable clothing sales in Canada?
SELECT SUM(revenue) FROM Sales WHERE material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo') AND location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (id INT, name TEXT, district TEXT); INSERT INTO neighborhoods (id, name, district) VALUES (1, 'Downtown', 'City Center'), (2, 'Richfield', 'North District'); CREATE TABLE crimes (id INT, neighborhood_id INT, type TEXT, year INT, month INT, day INT); INSERT INTO crimes (id, neighborhood_id, type, year, month, day) VALUES (1, 1, 'Theft', 2020, 1, 1), (2, 1, 'Assault', 2019, 12, 31), (3, 2, 'Burglary', 2020, 2, 14);
How many crimes were committed in each neighborhood for the year 2020?
SELECT n.name, c.type, COUNT(c.id) as total_crimes FROM neighborhoods n JOIN crimes c ON n.id = c.neighborhood_id WHERE c.year = 2020 GROUP BY n.id, c.type;
gretelai_synthetic_text_to_sql
CREATE TABLE worker (id INT, name TEXT, role TEXT, mine_id INT, employment_year INT);
How many workers in each role have been employed in mines for more than 5 years?
SELECT worker.role, COUNT(worker.id) as workers_count FROM worker WHERE worker.employment_year < (CURRENT_DATE - INTERVAL 5 YEAR) GROUP BY worker.role;
gretelai_synthetic_text_to_sql
CREATE TABLE strategies (id INT, strategy VARCHAR(30), investment_year INT, investment_amount FLOAT); INSERT INTO strategies (id, strategy, investment_year, investment_amount) VALUES (1, 'renewable energy', 2019, 120000), (2, 'sustainable agriculture', 2020, 185000), (3, 'renewable energy', 2020, 155000);
What's the total investment amount for 'renewable energy' strategies, grouped by investment year?
SELECT investment_year, SUM(investment_amount) FROM strategies WHERE strategy = 'renewable energy' GROUP BY investment_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, revenue) VALUES (1, 'Asian Fusion', 'New York', 50000.00), (2, 'Bella Italia', 'Los Angeles', 60000.00), (3, 'Sushi House', 'New York', 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 80000.00);
Show the average revenue for restaurants in each city.
SELECT city, AVG(revenue) FROM Restaurants GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (store_id INT, region TEXT, revenue INT); INSERT INTO sales (store_id, region, revenue) VALUES (1, 'Southern', 28000), (2, 'Southern', 22000), (3, 'Southern', 30000);
Which retail stores in the Southern region have a revenue greater than $25,000?
SELECT store_id, region, revenue FROM sales WHERE region = 'Southern' AND revenue > 25000;
gretelai_synthetic_text_to_sql
CREATE TABLE funds (id INT, category TEXT, region TEXT, amount DECIMAL(10,2)); INSERT INTO funds (id, category, region, amount) VALUES (1, 'Refugee Support', 'Middle East', 250000.00), (2, 'Disaster Response', 'Asia', 300000.00), (3, 'Community Development', 'Africa', 150000.00);
What is the maximum amount of funds spent on refugee support in each region?
SELECT region, MAX(amount) FROM funds WHERE category = 'Refugee Support' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, player_name VARCHAR(100)); CREATE TABLE games (game_id INT, home_team INT, away_team INT, home_runs INT);
What is the average number of home runs hit per game by each player in the MLB?
SELECT players.player_name, AVG(games.home_runs) as avg_home_runs_per_game FROM players INNER JOIN games ON players.player_id = games.home_team GROUP BY players.player_name;
gretelai_synthetic_text_to_sql
CREATE TABLE monitoring_stations (id INT PRIMARY KEY, station_name VARCHAR(255), region VARCHAR(255)); CREATE VIEW station_count_per_region AS SELECT region, COUNT(*) as station_count FROM monitoring_stations GROUP BY region;
Display the number of monitoring stations in each region from the monitoring_stations table.
SELECT region, station_count FROM station_count_per_region;
gretelai_synthetic_text_to_sql
CREATE TABLE historical_sites(site_id INT, site_name TEXT, country TEXT, num_virtual_tours INT); INSERT INTO historical_sites(site_id, site_name, country, num_virtual_tours) VALUES (1, 'Alhambra', 'Spain', 1500), (2, 'Sagrada Familia', 'Spain', 1200), (3, 'Mosque of Cordoba', 'Spain', 800);
List all historical sites in Spain with over 1000 virtual tours, ordered by the number of virtual tours in descending order.
SELECT site_id, site_name, num_virtual_tours FROM historical_sites WHERE country = 'Spain' AND num_virtual_tours > 1000 ORDER BY num_virtual_tours DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE sector_codes (sector_number INT, sector_name TEXT); INSERT INTO sector_codes (sector_number, sector_name) VALUES (1, 'Sector A'), (2, 'Sector B'), (3, 'Sector C'); CREATE TABLE community_crimes (crime_id INT, crime_type TEXT, sector INT);
What is the total number of crimes committed in each community policing sector?
SELECT sector, SUM(crimes) FROM (SELECT sector, COUNT(*) AS crimes FROM community_crimes JOIN sector_codes ON community_crimes.sector = sector_codes.sector_number GROUP BY sector, crime_type) AS subquery GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(20), Manufacturer VARCHAR(20), LaunchDate DATE, Status VARCHAR(20)); INSERT INTO Spacecraft (SpacecraftID, Name, Manufacturer, LaunchDate, Status) VALUES (1, 'Voyager 1', 'NASA', '1977-09-05', 'Active'); INSERT INTO Spacecraft (SpacecraftID, Name, Manufacturer, LaunchDate, Status) VALUES (2, 'Voyager 2', 'NASA', '1977-08-20', 'Inactive');
Count the number of active spacecraft by manufacturer.
SELECT Manufacturer, COUNT(*) FROM Spacecraft WHERE Status = 'Active' GROUP BY Manufacturer
gretelai_synthetic_text_to_sql
CREATE TABLE trains (id INT PRIMARY KEY, route_id INT, station VARCHAR(20), wheelchair_accessible BOOLEAN);
Show train routes with wheelchair accessibility for the city of 'Rio de Janeiro'
SELECT DISTINCT route_id FROM trains WHERE station = 'Rio de Janeiro' AND wheelchair_accessible = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance) VALUES (1, 'Savings', 'New York', 5000.00), (2, 'Checking', 'New York', 7000.00), (3, 'Checking', 'Santiago', 9000.00), (4, 'Savings', 'Santiago', 4000.00);
What is the maximum checking account balance in the Santiago branch?
SELECT MAX(balance) FROM accounts WHERE account_type = 'Checking' AND branch = 'Santiago';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, name VARCHAR(255), source VARCHAR(255), recyclable BOOLEAN);
Insert a new sustainable material into the "materials" table
INSERT INTO materials (material_id, name, source, recyclable) VALUES (3001, 'Recycled Polyester', 'Plastic Bottles', TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 5000.00); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (2, 'Health', 7000.00); CREATE TABLE VolunteerHours (ProgramID INT, VolunteerHours INT); INSERT INTO VolunteerHours (ProgramID, VolunteerHours) VALUES (1, 100);
Identify the programs with no reported volunteer hours but have received donations in the last six months?
SELECT p.ProgramName FROM Programs p LEFT JOIN VolunteerHours v ON p.ProgramID = v.ProgramID WHERE v.ProgramID IS NULL AND p.ProgramID IN (SELECT ProgramID FROM Donations WHERE DonationDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH));
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT); CREATE TABLE donations (id INT, donor_id INT, campaign_id INT, donation_amount DECIMAL(10,2)); INSERT INTO donors (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mary Johnson'); INSERT INTO donations (id, donor_id, campaign_id, donation_amount) VALUES (1, 1, 1, 50.00), (2, 2, 1, 100.00), (3, 1, 1, 150.00);
Who are the top 3 donors to a specific campaign?
SELECT name, SUM(donation_amount) as total_donation FROM donations JOIN donors ON donations.donor_id = donors.id WHERE campaign_id = 1 GROUP BY donor_id ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_database (offender_id INT, offense VARCHAR(255)); CREATE TABLE offender_demographics (offender_id INT, ethnicity VARCHAR(255));
Find offenders with multiple offenses in the 'criminal_database' table who have no ethnicity information?
SELECT offender_id FROM criminal_database WHERE offender_id IN (SELECT offender_id FROM (SELECT offender_id, COUNT(offense) as num_offenses FROM criminal_database GROUP BY offender_id HAVING num_offenses > 1) AS temp WHERE offender_id NOT IN (SELECT offender_id FROM offender_demographics)) GROUP BY offender_id;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), sector VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_infrastructure (id, project_name, sector, location, start_date, end_date) VALUES (1, 'Rural Road Project', 'Infrastructure', 'Village C, Country Z', '2021-01-01', '2021-12-31');
How many rural infrastructure projects were completed in 2021?
SELECT COUNT(*) FROM rural_infrastructure WHERE YEAR(end_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE program (id INT, name VARCHAR(50)); INSERT INTO program (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE donation (id INT, amount DECIMAL(10,2), program_id INT); CREATE TABLE volunteer (id INT, name VARCHAR(50), program_id INT);
What is the sum of donations and total number of volunteers for each program?
SELECT v.program_id, SUM(d.amount) as total_donations, COUNT(v.id) as total_volunteers FROM donation d JOIN volunteer v ON d.program_id = v.program_id GROUP BY v.program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, program_name TEXT, participant_count INT, participant_disability TEXT, year INT); INSERT INTO programs (id, program_name, participant_count, participant_disability, year) VALUES (1, 'Education', 200, 'Yes', 2021), (2, 'Health', 150, 'No', 2021);
Insert new programs and their respective participant counts for 2023.
INSERT INTO programs (program_name, participant_count, participant_disability, year) VALUES ('Science', 120, 'No', 2023), ('Arts', 180, 'Yes', 2023);
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionCountries (production_id INT, country VARCHAR(255), material_type VARCHAR(255)); INSERT INTO ProductionCountries (production_id, country, material_type) VALUES (1, 'USA', 'Organic Cotton'), (2, 'Canada', 'Recycled Polyester'), (3, 'Mexico', 'Reclaimed Wood'), (4, 'India', 'Conflict-Free Minerals'), (5, 'Bangladesh', 'Fair Trade Textiles'), (6, 'China', 'Natural Dyes'), (7, 'France', 'Organic Cotton'), (8, 'Germany', 'Reclaimed Wood');
How many sustainable materials are used by each country in production?
SELECT country, COUNT(DISTINCT material_type) as num_materials FROM ProductionCountries GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE produce (id INT, name VARCHAR(255), organic BOOLEAN, price_per_unit DECIMAL(5,2)); INSERT INTO produce (id, name, organic, price_per_unit) VALUES (1, 'Apples', TRUE, 1.25), (2, 'Bananas', TRUE, 0.99), (3, 'Carrots', FALSE, 1.75);
List all organic produce with a price per unit less than $1.50.
SELECT name FROM produce WHERE organic = TRUE AND price_per_unit < 1.50;
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents (StudentID int, StudentName varchar(255)); CREATE TABLE Publications (PublicationID int, StudentID int, Title varchar(255));
What is the number of research publications for each student, with a rank based on the number of publications?
SELECT StudentName, COUNT(*) as NumPublications, RANK() OVER (ORDER BY COUNT(*) DESC) as PublicationRank FROM Publications p JOIN GraduateStudents gs ON p.StudentID = gs.StudentID GROUP BY StudentName;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft_Table (id INT, model VARCHAR(100), year_manufactured INT);
What is the average age of the aircraft in the Aircraft_Table?
SELECT AVG(YEAR_MANUFACTURED) FROM Aircraft_Table;
gretelai_synthetic_text_to_sql
CREATE TABLE company_info (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO company_info (id, sector, ESG_score) VALUES (1, 'Technology', 75.0), (2, 'Finance', 60.0), (3, 'Technology', 82.5), (4, 'Healthcare', 65.0), (5, 'Healthcare', 67.5);
Identify the number of companies in each sector with an ESG score below 70.0.
SELECT sector, COUNT(*) as companies FROM company_info WHERE ESG_score < 70.0 GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT, country VARCHAR(50), region VARCHAR(50), capacity FLOAT); INSERT INTO solar_projects (id, country, region, capacity) VALUES (1, 'China', 'asia_pacific', 5678.90), (2, 'Japan', 'asia_pacific', 2345.67), (3, 'India', 'asia_pacific', 1234.56), (4, 'Australia', 'asia_pacific', 4567.89);
Which are the top 3 countries with the highest solar power capacity (in MW) in the 'asia_pacific' region?
SELECT region, country, SUM(capacity) as total_capacity FROM solar_projects WHERE region = 'asia_pacific' GROUP BY country, region ORDER BY total_capacity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Workshops (WorkshopID INT, Date DATE, IncomeLevel VARCHAR(255), Gender VARCHAR(255)); INSERT INTO Workshops (WorkshopID, Date, IncomeLevel, Gender) VALUES (1, '2022-07-01', 'Low Income', 'Female'); INSERT INTO Workshops (WorkshopID, Date, IncomeLevel, Gender) VALUES (2, '2022-07-01', 'Middle Income', 'Male'); INSERT INTO Workshops (WorkshopID, Date, IncomeLevel, Gender) VALUES (3, '2022-10-01', 'Low Income', 'Female');
How many financial wellbeing workshops were held in Q3 for low-income individuals and women?
SELECT COUNT(*) FROM Workshops WHERE Date >= '2022-07-01' AND Date < '2022-10-01' AND IncomeLevel = 'Low Income' AND Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE europe_visitors (id INT, country VARCHAR(20), tourists INT); INSERT INTO europe_visitors (id, country, tourists) VALUES (1, 'France', 40000000), (2, 'Germany', 35000000), (3, 'United Kingdom', 30000000), (4, 'Italy', 25000000), (5, 'Spain', 22000000);
What is the percentage of total tourists visiting European countries that went to France?
SELECT (france_tourists.tourists * 100.0 / europe_visitors.total_tourists) AS percentage FROM (SELECT SUM(tourists) AS total_tourists FROM europe_visitors) AS europe_visitors, (SELECT tourists FROM europe_visitors WHERE country = 'France') AS france_tourists;
gretelai_synthetic_text_to_sql
endangered_language (language, status, total_speakers)
Update the status column to 'vulnerable' in the endangered_language table where total_speakers is greater than 10000.
UPDATE endangered_language SET status = 'vulnerable' WHERE total_speakers > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding(id INT PRIMARY KEY, company_name VARCHAR(100)); CREATE TABLE exit_strategies(id INT PRIMARY KEY, company_id INT, exit_type VARCHAR(50)); INSERT INTO company_founding VALUES (1, 'Acme Inc'); INSERT INTO company_founding VALUES (2, 'Beta Corp'); INSERT INTO exit_strategies VALUES (1, 1, 'Acquisition');
List all companies that have not yet had an exit event
SELECT cf.company_name FROM company_founding cf LEFT JOIN exit_strategies es ON cf.id = es.company_id WHERE es.company_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget INT); CREATE TABLE agricultural_innovation (id INT, project_name VARCHAR(255), budget INT);
What is the total budget for all agricultural innovation projects in the 'rural_infrastructure' and 'agricultural_innovation' tables?
SELECT SUM(rural_infrastructure.budget + agricultural_innovation.budget) AS total_budget FROM rural_infrastructure INNER JOIN agricultural_innovation ON rural_infrastructure.project_name = agricultural_innovation.project_name;
gretelai_synthetic_text_to_sql
CREATE TABLE finance.loans (loan_id INT, is_shariah_compliant BOOLEAN, is_repaid BOOLEAN); INSERT INTO finance.loans (loan_id, is_shariah_compliant, is_repaid) VALUES (1, true, true), (2, false, true), (3, true, false), (4, true, true), (5, false, false);
Determine the percentage of Shariah-compliant loans in the 'finance' schema's 'loans' table that have been fully repaid.
SELECT 100.0 * COUNT(*) FILTER (WHERE is_shariah_compliant = true AND is_repaid = true) / COUNT(*) FILTER (WHERE is_shariah_compliant = true) FROM finance.loans;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, region TEXT, has_ethical_ai BOOLEAN, num_employees INT); INSERT INTO Companies (id, name, region, has_ethical_ai, num_employees) VALUES (1, 'TechCo', 'APAC', true, 1000), (2, 'GreenTech', 'APAC', true, 1500), (3, 'EthicalLabs', 'Americas', true, 750), (4, 'Tech4All', 'EMEA', true, 800), (5, 'InclusiveTech', 'APAC', false, 1200), (6, 'GlobalTech', 'EMEA', true, 3000), (7, 'SustainableAI', 'EMEA', true, 1500);
What is the average number of employees in companies that have implemented ethical AI in EMEA?
SELECT AVG(num_employees) FROM Companies WHERE region = 'EMEA' AND has_ethical_ai = true;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policyholder_id INT, policyholder_name VARCHAR(50), policyholder_state VARCHAR(2)); INSERT INTO policyholders (policyholder_id, policyholder_name, policyholder_state) VALUES (1, 'Kenneth White', 'PA'), (2, 'Hailey Green', 'OH'), (3, 'Andrew Miller', 'PA'), (4, 'Ava Taylor', 'OH'), (5, 'Jayden Clark', 'MI'), (6, 'Mia Lewis', 'PA'), (7, 'Lucas Anderson', 'OH'), (8, ' Harper Mitchell', 'MI'); CREATE TABLE claims (claim_id INT, policyholder_id INT, claim_date DATE); INSERT INTO claims (claim_id, policyholder_id, claim_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-03-01'), (3, 3, '2021-02-01'), (4, 4, '2021-01-01'), (5, 5, '2021-03-01'), (6, 2, '2021-04-01'), (7, 5, '2021-05-01'), (8, 6, '2021-06-01');
How many policyholders are in each state?
SELECT policyholder_state, COUNT(DISTINCT policyholder_id) as policyholder_count FROM policyholders GROUP BY policyholder_state;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (id INT, country VARCHAR(50), year INT, price FLOAT);
Update the carbon pricing for Seoul in 2026 to 40 EUR
UPDATE carbon_pricing SET price = 40 WHERE country = 'Seoul' AND year = 2026;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity(year INT, state VARCHAR(20), capacity INT); INSERT INTO landfill_capacity VALUES (2018, 'Texas', 1000000), (2019, 'Texas', 1100000);
What is the landfill capacity for Texas in 2018 and 2019?
SELECT year, state, SUM(capacity) as total_capacity FROM landfill_capacity WHERE state = 'Texas' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, type TEXT); INSERT INTO unions (id, type) VALUES (1, 'Manufacturing'), (2, 'Service'); CREATE TABLE regions (id INT, region TEXT); INSERT INTO regions (id, region) VALUES (1, 'North'), (2, 'South'); CREATE TABLE safety_scores (id INT, union_id INT, region_id INT, score INT); INSERT INTO safety_scores (id, union_id, region_id, score) VALUES (1, 1, 1, 85), (2, 1, 2, 90), (3, 2, 1, 70), (4, 2, 2, 80);
What is the rank of each region by total workplace safety score, partitioned by union type?
SELECT region, RANK() OVER (PARTITION BY u.type ORDER BY SUM(s.score) DESC) as rank FROM safety_scores s JOIN unions u ON s.union_id = u.id JOIN regions r ON s.region_id = r.id GROUP BY region, u.type;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, equipment_type VARCHAR(255), last_maintenance_date DATE, next_maintenance_date DATE, unit_id INT, base_location VARCHAR(255)); CREATE TABLE unit (unit_id INT, unit_name VARCHAR(255));
How many military equipment units are due for maintenance in the next 6 months, broken down by equipment type and base location?
SELECT e.equipment_type, u.base_location, COUNT(*) FROM military_equipment e JOIN unit u ON e.unit_id = u.unit_id WHERE e.next_maintenance_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH) GROUP BY e.equipment_type, u.base_location;
gretelai_synthetic_text_to_sql
CREATE TABLE property_location ( id INT PRIMARY KEY, price FLOAT, location VARCHAR(255) ); INSERT INTO property_location (id, price, location) VALUES (1, 500000, 'urban'), (2, 300000, 'rural'), (3, 400000, 'urban');
What is the difference in average property price between urban and rural areas?
SELECT AVG(price_urban) - AVG(price_rural) FROM (SELECT price FROM property_location WHERE location = 'urban') AS price_urban JOIN (SELECT price FROM property_location WHERE location = 'rural') AS price_rural ON 1=1;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, player_name TEXT, team_id INT, position TEXT, games_played INT, points_per_game DECIMAL(5,2)); INSERT INTO players (player_id, player_name, team_id, position, games_played, points_per_game) VALUES (1, 'LeBron James', 25, 'Forward', 67, 25.0), (2, 'Kevin Durant', 7, 'Forward', 55, 26.9);
What is the total points scored by each player in the 2021 NBA season, sorted by the total points in descending order?
SELECT player_name, SUM(points_per_game * games_played) AS total_points FROM players GROUP BY player_name ORDER BY total_points DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(50), budget DECIMAL(10, 2), category VARCHAR(50));
Identify the workforce development programs with the top three highest budgets.
SELECT program_name, budget FROM (SELECT program_name, budget, ROW_NUMBER() OVER (ORDER BY budget DESC) as rn FROM programs) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (incident_id INT, incident_type TEXT, region TEXT, incident_date DATE);
How many cybersecurity incidents have been reported in the Pacific region in the last year?
SELECT COUNT(*) FROM cybersecurity_incidents WHERE region = 'Pacific' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_events (event_id INT, event_name VARCHAR(50), artist_name VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO cultural_events (event_id, event_name, artist_name, revenue) VALUES (1, 'Dance Performance', 'Artist C', 15000); INSERT INTO cultural_events (event_id, event_name, artist_name, revenue) VALUES (2, 'Music Concert', 'Artist D', 8000);
List all the cultural events with a revenue over 10000 and their corresponding artist.
SELECT cultural_events.event_name, artist_name, revenue FROM cultural_events INNER JOIN (SELECT event_name, MAX(revenue) as max_revenue FROM cultural_events GROUP BY event_name) subquery ON cultural_events.event_name = subquery.event_name AND cultural_events.revenue = subquery.max_revenue;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturers (manufacturer_id INT, name VARCHAR(100)); INSERT INTO spacecraft_manufacturers (manufacturer_id, name) VALUES (1, 'SpaceX'), (2, 'NASA'), (3, 'Blue Origin'); CREATE TABLE space_missions (mission_id INT, spacecraft_manufacturer_id INT, destination VARCHAR(100)); INSERT INTO space_missions (mission_id, spacecraft_manufacturer_id, destination) VALUES (1, 1, 'Mars'), (2, 2, 'Moon'), (3, 3, 'Mars');
Which spacecraft manufacturers have launched missions to Mars?
SELECT sm.name FROM spacecraft_manufacturers sm INNER JOIN space_missions smm ON sm.manufacturer_id = smm.spacecraft_manufacturer_id WHERE smm.destination = 'Mars';
gretelai_synthetic_text_to_sql
CREATE TABLE stops (id INT, name VARCHAR(255), city VARCHAR(255), lat DECIMAL(9,6), lon DECIMAL(9,6)); INSERT INTO stops (id, name, city, lat, lon) VALUES (1, 'Station 1', 'City A', 41.1234, -8.7654); INSERT INTO stops (id, name, city, lat, lon) VALUES (2, 'Station 2', 'City B', 42.2345, -9.8901); INSERT INTO stops (id, name, city, lat, lon) VALUES (3, 'Station 3', 'City C', 43.3456, -10.9012); INSERT INTO stops (id, name, city, lat, lon) VALUES (4, 'Station 4', 'City C', 44.4567, -11.0123);
What is the average fare for routes that pass through stations located in City C?
SELECT f.route_id, AVG(f.fare) AS avg_fare FROM fares f JOIN stops s ON f.stop_id = s.id WHERE s.city = 'City C' GROUP BY f.route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE shipping (id INT, order_id INT, shipping_country VARCHAR(50), shipping_cost DECIMAL(5,2)); INSERT INTO shipping (id, order_id, shipping_country, shipping_cost) VALUES (1, 1, 'Canada', 10.00), (2, 2, 'USA', 5.00);
What is the average shipping cost for orders shipped to the USA?
SELECT AVG(shipping_cost) FROM shipping WHERE shipping_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Crops (id INT, country VARCHAR(255), crop VARCHAR(255), water_footprint INT); INSERT INTO Crops (id, country, crop, water_footprint) VALUES (1, 'Spain', 'Tomatoes', 200), (2, 'Spain', 'Potatoes', 150), (3, 'Portugal', 'Rice', 250), (4, 'Portugal', 'Corn', 180);
What is the average water footprint for crops grown in Spain and Portugal?
SELECT AVG(water_footprint) FROM Crops WHERE country IN ('Spain', 'Portugal') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_projects (project_id INT, project_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), capacity FLOAT); INSERT INTO wind_projects (project_id, project_name, city, state, capacity) VALUES (1, 'Seattle Wind Farm', 'Seattle', 'WA', 30.5); INSERT INTO wind_projects (project_id, project_name, city, state, capacity) VALUES (2, 'Emerald City Turbines', 'Seattle', 'WA', 25.2); INSERT INTO wind_projects (project_id, project_name, city, state, capacity) VALUES (3, 'Washington Wind Works', 'Olympia', 'WA', 15.0);
What is the capacity of the smallest wind energy project in the state of Washington?
SELECT MIN(capacity) FROM wind_projects WHERE state = 'WA';
gretelai_synthetic_text_to_sql
CREATE TABLE revenue_by_date (date DATE, restaurant VARCHAR(50), revenue INT); INSERT INTO revenue_by_date (date, restaurant, revenue) VALUES ('2022-01-01', 'Restaurant A', 3000), ('2022-01-01', 'Restaurant B', 4000), ('2022-01-01', 'Restaurant C', 5000), ('2022-01-02', 'Restaurant A', 4000), ('2022-01-02', 'Restaurant B', 5000), ('2022-01-02', 'Restaurant C', 6000), ('2022-01-03', 'Restaurant A', 5000), ('2022-01-03', 'Restaurant B', 6000), ('2022-01-03', 'Restaurant C', 7000);
What is the total revenue for a specific restaurant in the past month?
SELECT SUM(revenue) FROM revenue_by_date WHERE restaurant = 'Restaurant A' AND date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE europe_attractions (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO europe_attractions VALUES (1, 'Plitvice Lakes', 'Croatia', 150000), (2, 'Sarek National Park', 'Sweden', 120000), (3, 'Dolomites', 'Italy', 200000);
Which countries in Europe have more than 100000 visitors to their natural attractions?
SELECT country, SUM(visitors) FROM europe_attractions GROUP BY country HAVING SUM(visitors) > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (1, 'John Doe', 'Marketing', 75000), (2, 'Jane Smith', 'Marketing', 80000), (3, 'Mike Johnson', 'Sales', 70000), (4, 'Emily Lee', 'IT', 85000), (5, 'David Kim', 'IT', 80000);
How many employees in each department have a salary above the department average?
SELECT E1.Department, COUNT(*) FROM Employees E1 INNER JOIN (SELECT Department, AVG(Salary) AS AvgSalary FROM Employees GROUP BY Department) E2 ON E1.Department = E2.Department WHERE E1.Salary > E2.AvgSalary GROUP BY E1.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY, Gender VARCHAR(6), Sexuality VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, Gender, Sexuality) VALUES (1, 'Female', 'Heterosexual'), (2, 'Male', 'Gay'), (3, 'Non-binary', 'Queer');
How many cases were handled by attorneys who identify as LGBTQ+?
SELECT COUNT(*) FROM Attorneys WHERE Sexuality IN ('Gay', 'Lesbian', 'Queer', 'Bisexual', 'Pansexual', 'Asexual');
gretelai_synthetic_text_to_sql
CREATE TABLE sales_by_product (product VARCHAR(255), revenue FLOAT); INSERT INTO sales_by_product (product, revenue) VALUES ('White T-Shirt', 1500), ('Blue Jeans', 1300), ('Red Dress', 1200), ('Black Heels', 1000), ('Brown Bag', 800);
Find the top 2 products with the highest sales in the year 2021?
SELECT product, SUM(revenue) FROM sales_by_product WHERE revenue IS NOT NULL AND product IS NOT NULL GROUP BY product ORDER BY SUM(revenue) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (sid INT, name TEXT, PRIMARY KEY(sid)); CREATE TABLE station_emergencies (eid INT, sid INT, time TIMESTAMP, PRIMARY KEY(eid), FOREIGN KEY(sid) REFERENCES stations(sid));
What is the maximum number of emergencies handled by a single police station in a day?
SELECT sid, MAX(TIMESTAMPDIFF(DAY, (SELECT time FROM station_emergencies se2 WHERE se2.sid = se.sid AND se2.time < (SELECT MIN(time) FROM station_emergencies se3 WHERE se3.sid = se.sid AND se3.time > se2.time)), (SELECT time FROM station_emergencies se4 WHERE se4.sid = se.sid AND se4.time = (SELECT MIN(time) FROM station_emergencies se5 WHERE se5.sid = se4.sid AND se5.time > (SELECT MAX(time) FROM station_emergencies se6 WHERE se6.sid = se4.sid AND se6.time < se4.time))))) AS max_day FROM station_emergencies se GROUP BY sid;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name VARCHAR(50), city VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO startups VALUES (1, 'StartupA', 'NYC', 12000000.00), (2, 'StartupB', 'SF', 15000000.00), (3, 'StartupC', 'NYC', 8000000.00);
What is the average budget per biotech startup by city?
SELECT city, AVG(budget) FROM startups GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE installations (id INT, region VARCHAR(20), type VARCHAR(20), date DATE); INSERT INTO installations (id, region, type, date) VALUES (1, 'Western', 'Solar', '2021-01-05'); INSERT INTO installations (id, region, type, date) VALUES (2, 'Central', 'Wind', '2021-01-10');
How many solar panel installations were done in the Western region in Q1 of 2021?
SELECT COUNT(*) FROM installations WHERE region = 'Western' AND date BETWEEN '2021-01-01' AND '2021-03-31' AND type = 'Solar';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), genre VARCHAR(50)); INSERT INTO artists (artist_id, artist_name, genre) VALUES (1, 'Beyoncé', 'rnb'), (2, 'Adele', 'pop'), (3, 'Taylor Swift', 'country'), (4, 'Metallica', 'metal'), (5, 'Eminem', 'hip-hop'); CREATE TABLE songs (song_id INT, song_name VARCHAR(100), artist_id INT); INSERT INTO songs (song_id, song_name, artist_id) VALUES (1, 'Crazy in Love', 1), (2, 'Rolling in the Deep', 2), (3, 'Shake it Off', 3), (4, 'Enter Sandman', 4), (5, 'Lose Yourself', 5), (6, 'Single Ladies', 1);
Delete the artist 'Beyoncé' from the rnb genre.
DELETE FROM artists WHERE artist_name = 'Beyoncé' AND genre = 'rnb'; DELETE FROM songs WHERE artist_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, cause_id INT, amount DECIMAL(10, 2)); CREATE TABLE investments (investment_id INT, investor_id INT, sector_id INT, amount DECIMAL(10, 2));
Delete records of donations and investments from the 'donations' and 'investments' tables with a value over 100000 for the 'amount' column.
DELETE FROM donations WHERE amount > 100000; DELETE FROM investments WHERE amount > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (project_id INT, sector VARCHAR(50), labor_cost FLOAT, year INT); INSERT INTO labor_costs (project_id, sector, labor_cost, year) VALUES (1, 'Sustainable', 30000, 2021), (2, 'Conventional', 25000, 2021), (3, 'Sustainable', 35000, 2021);
What is the maximum labor cost in the sustainable building sector in 2021?
SELECT MAX(labor_cost) FROM labor_costs WHERE sector = 'Sustainable' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (id INT PRIMARY KEY, species VARCHAR(255), population INT);
Show all the marine life species and their population in the 'MarineLife' table
SELECT species, population FROM MarineLife;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, amount FLOAT, region VARCHAR(20)); INSERT INTO network_investments (investment_id, amount, region) VALUES (1, 500000, 'Europe'), (2, 600000, 'Africa');
What is the total amount spent on network infrastructure in the European region?
SELECT SUM(amount) FROM network_investments WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, abstract TEXT); INSERT INTO research_papers (id, title, publication_year, abstract) VALUES (1, 'Deep Learning for Autonomous Driving', 2021, 'In this paper, we propose a deep learning approach for autonomous driving...'), (2, 'Motion Planning for Autonomous Vehicles', 2020, 'In this paper, we propose a motion planning algorithm for autonomous vehicles...'), (3, 'Simulation for Autonomous Driving Testing', 2022, 'In this paper, we propose a simulation-based testing framework for autonomous driving...');
Which autonomous driving research papers were published in the research_papers table in the year 2021?
SELECT title FROM research_papers WHERE publication_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty(FacultyID INT, LastGrantDate DATE); INSERT INTO Faculty VALUES (1, '2020-01-01');
Identify faculty members who have not received any research grants in the last 2 years.
SELECT FacultyID FROM Faculty WHERE Faculty.LastGrantDate < DATEADD(year, -2, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE WasteSatisfaction (Year INT, Satisfied INT); INSERT INTO WasteSatisfaction (Year, Satisfied) VALUES (2021, 75);
What is the percentage of citizens satisfied with waste management services in 2021?
SELECT Satisfied/100.0 * 100.0 AS Percentage FROM WasteSatisfaction WHERE Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE contracts (contract_id INT, contract_value FLOAT, contract_date DATE); INSERT INTO contracts (contract_id, contract_value, contract_date) VALUES (1, 500000, '2020-01-01'), (2, 300000, '2019-05-15'), (3, 800000, '2021-08-27');
What is the total contract value for each contract in descending order?
SELECT contract_id, contract_value FROM contracts ORDER BY contract_value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE berlin_taxis (id INT, trip_duration INT, is_accessible BOOLEAN); INSERT INTO berlin_taxis (id, trip_duration, is_accessible) VALUES (1, 15, TRUE), (2, 20, FALSE);
Identify the most common trip duration for accessible taxi rides in Berlin.
SELECT is_accessible, MODE(trip_duration) AS common_trip_duration FROM berlin_taxis WHERE is_accessible = TRUE GROUP BY is_accessible;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), ethnicity VARCHAR(30)); INSERT INTO community_health_workers (worker_id, name, ethnicity) VALUES (1, 'Hoa Nguyen', 'Asian American'), (2, 'Juan Hernandez', 'Hispanic'), (3, 'Mark Johnson', 'Non-Hispanic');
Update the ethnicity of community health worker with worker_id 1 to Asian American.
UPDATE community_health_workers SET ethnicity = 'Asian American' WHERE worker_id = 1;
gretelai_synthetic_text_to_sql