context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE rural_infrastructure (id INT, country VARCHAR(255), sector VARCHAR(255), allocated_budget INT, year INT); INSERT INTO rural_infrastructure (id, country, sector, allocated_budget, year) VALUES (1, 'Bangladesh', 'Transport', 1000000, 2019), (2, 'Bangladesh', 'Education', 500000, 2019), (3, 'India', 'Healthca...
Infrastructure budget allocation for rural development initiatives, by country and sector, for the year 2019?
SELECT country, sector, SUM(allocated_budget) as total_allocated_budget FROM rural_infrastructure WHERE year = 2019 GROUP BY country, sector;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (id INT, name VARCHAR(50), uses_organic_cotton BOOLEAN); CREATE TABLE reviews (id INT, brand_id INT, rating INT, review TEXT); INSERT INTO brands (id, name, uses_organic_cotton) VALUES (1, 'Brand A', true), (2, 'Brand B', false), (3, 'Brand C', true); INSERT INTO reviews (id, brand_id, rating, revie...
List all consumer reviews of brands that use organic cotton?
SELECT r.rating, r.review FROM brands b INNER JOIN reviews r ON b.id = r.brand_id WHERE b.uses_organic_cotton = true;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (zone TEXT, fare DECIMAL(5,2), effective_date DATE);
Update the 'fare' column in the 'fares' table for 'Zone 1' to $2.50
UPDATE fares SET fare = 2.50 WHERE zone = 'Zone 1';
gretelai_synthetic_text_to_sql
CREATE TABLE netflix_productions (id INT, title VARCHAR(255), year INT, production_budget INT, revenue INT); INSERT INTO netflix_productions (id, title, year, production_budget, revenue) VALUES (1, 'Stranger Things', 2019, 25000000, 242000000), (2, 'The Crown', 2019, 130000000, 134000000);
What's the total revenue of Netflix's original productions in 2019?
SELECT SUM(revenue) FROM netflix_productions WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, rating FLOAT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, city, rating, ai_adoption) VALUES (1, 'Hotel A', 'Tokyo', 4.5, true), (2, 'Hotel B', 'Seoul', 4.2, false), (3, 'Hotel C', 'Tokyo', 4.7, true);
What is the total number of hotels that have adopted AI technology and are located in Tokyo or Seoul?
SELECT COUNT(*) FROM hotels WHERE ai_adoption = true AND city IN ('Tokyo', 'Seoul');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor INT, donation FLOAT, donation_date DATE); INSERT INTO donations (id, donor, donation, donation_date) VALUES (1, 1, 500.00, '2018-01-01'), (2, 1, 750.00, '2019-01-01'), (3, 2, 1000.00, '2019-01-01'), (4, 2, 1500.00, '2020-01-01');
List all donors who have donated over $1000 in total and their corresponding total donation amounts.
SELECT donor, SUM(donation) AS total_donations FROM donations GROUP BY donor HAVING total_donations > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE international_visitors (visitor_id INT, destination_id INT, num_visitors INT, carbon_footprint FLOAT); INSERT INTO international_visitors (visitor_id, destination_id, num_visitors, carbon_footprint) VALUES (7, 7, 20000, 1.2); INSERT INTO international_visitors (visitor_id, destination_id, num_visitors, car...
What is the average carbon footprint of tourists visiting destinations in Africa?
SELECT AVG(carbon_footprint) FROM international_visitors i INNER JOIN destinations d ON i.destination_id = d.destination_id WHERE d.country_id IN (SELECT country_id FROM countries WHERE continent = 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentPlants (ID INT, State VARCHAR(20), Efficiency FLOAT); INSERT INTO WastewaterTreatmentPlants (ID, State, Efficiency) VALUES (17, 'Ohio', 0.85), (18, 'Ohio', 0.87), (19, 'Ohio', 0.83), (20, 'Ohio', 0.88);
What is the minimum wastewater treatment plant efficiency in the state of Ohio?
SELECT MIN(Efficiency) FROM WastewaterTreatmentPlants WHERE State = 'Ohio'
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, regional_office VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, regional_office) VALUES (1, 'Boston'), (2, 'Boston'), (3, 'NYC'), (4, 'NYC'), (5, 'NYC');
How many broadband customers does the NYC regional office have?
SELECT COUNT(*) FROM broadband_subscribers WHERE regional_office = 'NYC';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, country VARCHAR(255), engagement_date DATE); INSERT INTO virtual_tours (tour_id, country, engagement_date) VALUES (1, 'France', '2022-03-05'), (2, 'France', '2022-03-10'), (3, 'Germany', '2022-03-12');
How many virtual tours were engaged in France last month?
SELECT COUNT(*) FROM virtual_tours WHERE country = 'France' AND engagement_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareProviders (ProviderID INT, CulturalCompetencyScore INT, PatientSatisfactionScore INT); INSERT INTO HealthcareProviders (ProviderID, CulturalCompetencyScore, PatientSatisfactionScore) VALUES (1, 85, 9); INSERT INTO HealthcareProviders (ProviderID, CulturalCompetencyScore, PatientSatisfactionScore)...
What is the correlation between cultural competency scores and patient satisfaction scores?
SELECT CORR(CulturalCompetencyScore, PatientSatisfactionScore) FROM HealthcareProviders;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects(id INT, name TEXT, location TEXT, type TEXT);INSERT INTO genetics.research_projects (id, name, location, type) VALUES (1, 'ProjectX', 'USA', 'Genetic'), (2, 'ProjectY', 'USA', 'Genomic'), (3, 'ProjectZ', 'Canada', 'Genomic');
Which genetic research projects in the US focus on genomic sequencing?
SELECT name FROM genetics.research_projects WHERE location = 'USA' AND type = 'Genomic';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'manufacturing', 50000.00), (2, 'Jane Smith', 'engineering', 60000.00), (3, 'Alice Johnson', 'HR', 55000.00), (4, 'Bob Brown', 'quality control', ...
What is the minimum salary paid to an employee in the 'engineering' department?
SELECT MIN(salary) FROM employees WHERE department = 'engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, cba_expiration_year INT); INSERT INTO unions (id, name, cba_expiration_year) VALUES (1, 'Union A', 2023), (2, 'Union B', 2024), (3, 'Union C', 2023);
Which unions have collective bargaining agreements expiring in 2023?
SELECT name FROM unions WHERE cba_expiration_year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE user_profile (user_id INT, age INT, PRIMARY KEY (user_id)); INSERT INTO user_profile (user_id, age) VALUES (1, 55), (2, 45), (3, 60); CREATE TABLE activity_log (log_id INT, user_id INT, activity_name VARCHAR(20), duration INT, log_date DATE, PRIMARY KEY (log_id), FOREIGN KEY (user_id) REFERENCES user_profi...
Identify the top 3 fitness activities with the highest total time spent by users aged 50 or older, in descending order, for the past 30 days.
SELECT activity_name, SUM(duration) as total_duration FROM activity_log JOIN user_profile ON activity_log.user_id = user_profile.user_id WHERE user_profile.age >= 50 AND log_date >= DATE(NOW()) - INTERVAL 30 DAY GROUP BY activity_name ORDER BY total_duration DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_attendance (fan_id INT, game_date DATE, team VARCHAR(50)); INSERT INTO baseball_attendance (fan_id, game_date, team) VALUES (1, '2022-06-01', 'Red Sox'), (2, '2022-06-01', 'Red Sox'), (3, '2022-06-02', 'Yankees'), (4, '2022-06-03', 'Red Sox'), (5, '2022-06-04', 'Yankees');
How many unique fans attended baseball games in the last 30 days, broken down by team?
SELECT team, COUNT(DISTINCT fan_id) FROM baseball_attendance WHERE game_date >= CURDATE() - INTERVAL 30 DAY GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_orbits (id INT, name VARCHAR(255), orbit_type VARCHAR(255)); CREATE VIEW molniya_satellites AS SELECT * FROM satellite_orbits WHERE orbit_type = 'Molniya';
How many satellites are in the Molniya orbit?
SELECT COUNT(*) FROM molniya_satellites;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'Buenos Aires Warehouse', 'Buenos Aires'); CREATE TABLE Packages (id INT, warehouse_id INT, delivery_time INT, status VARCHAR(20)); INSERT INTO Packages (id, warehouse_id, delivery_time, status) VALUES...
What is the maximum delivery time for packages shipped from 'Buenos Aires' warehouse?
SELECT MAX(delivery_time) FROM Packages WHERE warehouse_id = (SELECT id FROM Warehouse WHERE city = 'Buenos Aires') AND status = 'shipped';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (species TEXT, population REAL, biomass REAL); INSERT INTO marine_mammals (species, population, biomass) VALUES ('Beluga Whale', 15000, 250000), ('Narwhal', 10000, 300000);
What is the total biomass of marine mammals in the Arctic Ocean?
SELECT SUM(biomass) FROM marine_mammals WHERE species IN ('Beluga Whale', 'Narwhal', 'Bowhead Whale');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryBases (Country VARCHAR(50), NumberOfBases INT); INSERT INTO MilitaryBases (Country, NumberOfBases) VALUES ('France', 50), ('Germany', 40), ('Italy', 35), ('Spain', 30), ('Poland', 25), ('Ukraine', 20);
What is the average number of military bases in each European country, excluding microstates?
SELECT AVG(NumberOfBases) FROM MilitaryBases WHERE Country IN ('France', 'Germany', 'Italy', 'Spain', 'Poland', 'Ukraine');
gretelai_synthetic_text_to_sql
CREATE TABLE communities_languages (id INT, community_name VARCHAR, language VARCHAR); INSERT INTO communities_languages VALUES (1, 'First Nations', 'Cree');
List the unique indigenous communities and their languages in the Arctic region.
SELECT DISTINCT community_name, language FROM communities_languages;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_salaries (position VARCHAR(50), employee_name VARCHAR(50), salary INTEGER, company_location VARCHAR(50));
What is the minimum salary for data scientists in 'tech_salaries' table?
SELECT MIN(salary) FROM tech_salaries WHERE position = 'Data Scientist';
gretelai_synthetic_text_to_sql
CREATE TABLE green_initiatives (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2));CREATE VIEW v_highest_budget_initiatives AS SELECT gi.name, gi.location, gi.budget FROM green_initiatives gi WHERE gi.location LIKE 'Southeast%';
List the top 3 green initiatives with the highest budget in Southeast Asia, ordered by budget.
SELECT * FROM v_highest_budget_initiatives ORDER BY budget DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE music (id INT, title VARCHAR(255), artist VARCHAR(255), genre VARCHAR(50), play_count INT); INSERT INTO music (id, title, artist, genre, play_count) VALUES (1, 'SongA', 'ArtistA', 'Pop', 2000000); INSERT INTO music (id, title, artist, genre, play_count) VALUES (2, 'SongB', 'ArtistB', 'Rock', 3000000); INSE...
What are the top 3 most popular music genres by total plays?
SELECT genre, SUM(play_count) as total_plays FROM music GROUP BY genre ORDER BY total_plays DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(255)); CREATE TABLE mining_activities (activity_id INT, site_id INT, activity_date DATE); INSERT INTO mining_sites (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'); INSERT INTO mining_activities (activity_id, site_id, activity_date) VALUES...
Find the total number of mining activities for each mining site, ordered by the total number of activities
SELECT s.site_name, COUNT(a.activity_id) as total_activities FROM mining_sites s INNER JOIN mining_activities a ON s.site_id = a.site_id GROUP BY s.site_name ORDER BY total_activities DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, region VARCHAR(20), financial_wellbeing_score DECIMAL(3, 1)); INSERT INTO customers (customer_id, region, financial_wellbeing_score) VALUES (1, 'Northeast', 6.5), (2, 'Midwest', 7.2), (3, 'West', 8.5);
How many customers have a financial wellbeing score greater than 8?
SELECT COUNT(*) FROM customers WHERE financial_wellbeing_score > 8;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_sales (sale_id INT, song_id INT, release_year INT, platform_id INT);
What is the total number of songs released per year and platform, based on the 'release_year' column in the 'song' table and the 'platform' column in the 'digital_sales' table?
SELECT ds.release_year, ds.platform_id, COUNT(ds.song_id) AS songs_released FROM digital_sales ds GROUP BY ds.release_year, ds.platform_id;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), num_employees INT, hire_date DATE); INSERT INTO mining_operations (id, name, num_employees, hire_date) VALUES (1, 'Gold Rush Inc.', 100, '2022-01-01'), (2, 'Gold Rush Inc.', 101, '2022-02-01'), (3, 'Gold Rush Inc.', 102, '2022-03-01'), (4, 'Silver Strike Ltd.', ...
What is the number of employees hired each month in the 'mining_operations' table?
SELECT EXTRACT(MONTH FROM hire_date), COUNT(*) FROM mining_operations GROUP BY EXTRACT(MONTH FROM hire_date);
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_tech (tech_id INT, tech_name VARCHAR(30), city VARCHAR(20), population INT); INSERT INTO smart_city_tech (tech_id, tech_name, city, population) VALUES (1, 'Smart Grids', 'Buenos Aires', 3000000), (2, 'Smart Lighting', 'Rio de Janeiro', 6500000), (3, 'Smart Traffic Management', 'Santiago', 250000...
List all smart city technology adoptions in the South American cities with a population greater than 2 million.
SELECT tech_name, city FROM smart_city_tech WHERE population > 2000000 AND city IN ('Buenos Aires', 'Rio de Janeiro', 'Santiago');
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, investment_date DATE, country VARCHAR(50), investment_amount DECIMAL(5,2));
What is the average network investment in each country over the past year?
SELECT country, AVG(investment_amount) as avg_investment FROM network_investments WHERE YEAR(investment_date) = YEAR(current_date) - 1 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE retail_stores (store_id INT, store_name VARCHAR(255)); INSERT INTO retail_stores (store_id, store_name) VALUES (1, 'Store A'), (2, 'Store B'), (3, 'Store C'); CREATE TABLE sales (sale_id INT, store_id INT, sale_date DATE, revenue DECIMAL(10, 2)); INSERT INTO sales (sale_id, store_id, sale_date, revenue) VA...
What is the total revenue for each retail store in the month of January 2022?
SELECT s.store_id, SUM(s.revenue) AS total_revenue FROM sales s WHERE EXTRACT(MONTH FROM s.sale_date) = 1 GROUP BY s.store_id;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableMaterials (material_name TEXT, continent TEXT, quantity INT); INSERT INTO SustainableMaterials (material_name, continent, quantity) VALUES ('Material1', 'Continent1', 500), ('Material2', 'Continent2', 700), ('Material3', 'Continent1', 300);
What is the total quantity of sustainable materials sourced from each continent?
SELECT continent, SUM(quantity) as total_quantity FROM SustainableMaterials GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, location TEXT); INSERT INTO unions (id, name, location) VALUES (1, 'Union X', 'USA'), (2, 'Union Y', 'Canada'); CREATE TABLE violations (id INT, union_id INT, date DATE, violation_count INT); INSERT INTO violations (id, union_id, date, violation_count) VALUES (1, 1, '2021-02-15',...
What is the average number of labor rights violations for each union in the Americas in the last year?
SELECT u.name, AVG(v.violation_count) FROM unions u JOIN violations v ON u.id = v.union_id WHERE u.location LIKE 'Americas%' AND v.date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY u.name;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_trains (train_id INT, ride_id INT, start_time TIMESTAMP, end_time TIMESTAMP, speed FLOAT, city VARCHAR(255));
What is the average speed of electric trains in Madrid?
SELECT AVG(speed) FROM electric_trains WHERE city = 'Madrid';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, volunteer_name VARCHAR(50), state VARCHAR(5), signup_date DATE); INSERT INTO volunteers (id, volunteer_name, state, signup_date) VALUES (1, 'Alice Johnson', 'NY', '2021-03-01'); INSERT INTO volunteers (id, volunteer_name, state, signup_date) VALUES (2, 'Bob Brown', 'CA', '2021-02-15');
How many volunteers signed up in each state during 2021?
SELECT state, COUNT(*) as num_volunteers FROM volunteers WHERE signup_date >= '2021-01-01' AND signup_date < '2022-01-01' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, country TEXT, rating FLOAT); INSERT INTO eco_hotels VALUES (1, 'Eco Hotel Lisbon', 'Portugal', 4.6), (2, 'Green Hotel Barcelona', 'Spain', 4.4);
What is the average rating of eco-friendly hotels in Portugal and Spain?
SELECT AVG(rating) FROM eco_hotels WHERE country IN ('Portugal', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE WindFarms (WindFarmID INT, Name VARCHAR(255), State VARCHAR(255), ConstructionDate DATE, PowerGenerationCapacity INT, WindTurbineCount INT); INSERT INTO WindFarms VALUES (1, 'Wind Farm A', 'Texas', '2010-05-15', 50, 10); INSERT INTO WindFarms VALUES (2, 'Wind Farm B', 'Oklahoma', '2012-02-23', 60, 12); INS...
List the names, locations, and construction dates of all wind farms in Texas and Oklahoma, along with their respective power generation capacities and the number of wind turbines.
SELECT Name, Location, ConstructionDate, PowerGenerationCapacity, WindTurbineCount FROM WindFarms WHERE State IN ('Texas', 'Oklahoma');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (project_name VARCHAR(50), location VARCHAR(50), start_year INT, budget INT, sector VARCHAR(50)); INSERT INTO climate_projects (project_name, location, start_year, budget, sector) VALUES ('Solar Farm A', 'China', 2017, 1000000, 'Solar'), ('Wind Farm B', 'India', 2018, 1500000, 'Wind');
List all climate mitigation projects in Asia that were started after 2015 and their respective budgets.
SELECT project_name, location, budget FROM climate_projects WHERE location IN ('Asia') AND start_year > 2015 AND sector = 'Climate Mitigation';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, client_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (id, client_id, transaction_amount, transaction_date) VALUES (1, 1, 500.00, '2022-01-01'), (2, 2, 800.00, '2022-01-02'), (3, 1, 1200.00, '2022-01-03'); CREATE TABLE clients (id INT, name ...
What is the average transaction amount for each client?
SELECT clients.id, clients.name, AVG(transactions.transaction_amount) FROM clients INNER JOIN transactions ON clients.id = transactions.client_id GROUP BY clients.id;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), state VARCHAR(255), certification_level VARCHAR(255), carbon_offset_tons INT);
List the green building certifications and their carbon offset values for buildings in the state of New York.
SELECT certification_level, carbon_offset_tons FROM green_buildings WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id int, product_name varchar(255), transparency_score float); INSERT INTO products (product_id, product_name, transparency_score) VALUES (1, 'Product A', 8.5), (2, 'Product B', 9.2), (3, 'Product C', 7.8);
Which products have the highest transparency score?
SELECT product_name, transparency_score FROM products ORDER BY transparency_score DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Factory_Demographics (id INT, factory_id INT, position VARCHAR(255), gender VARCHAR(255), workers INT); INSERT INTO Factory_Demographics (id, factory_id, position, gender, workers) VALUES (1, 1001, 'Management', 'Female', 150), (2, 1002, 'Management', 'Female', 200);
Which factories have a higher percentage of women in management positions compared to the industry average?
SELECT factory_id, ((workers / (SELECT SUM(workers) FROM Factory_Demographics WHERE position = 'Management')) * 100) as women_management_percentage FROM Factory_Demographics WHERE gender = 'Female' AND position = 'Management';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY AUTO_INCREMENT, Name VARCHAR(100));CREATE TABLE Albums (AlbumID INT PRIMARY KEY AUTO_INCREMENT, Title VARCHAR(100), ArtistID INT, FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID));
Delete the artist 'John Smith' if they don't have any albums
DELETE FROM Artists WHERE ArtistID NOT IN (SELECT ArtistID FROM Albums);
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, category VARCHAR(255), vulnerability VARCHAR(255), severity INT); INSERT INTO vulnerabilities (id, timestamp, category, vulnerability, severity) VALUES (1, '2022-01-01 10:00:00', 'Web Applications', 'SQL Injection', 8), (2, '2022-01-01 10:00:00', 'Network Infra...
Calculate the average severity score for each vulnerability category in the last year.
SELECT category, AVG(severity) as avg_severity FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR) GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (id INT, name VARCHAR(50), occupation VARCHAR(50), union_member BOOLEAN, salary FLOAT); INSERT INTO union_members (id, name, occupation, union_member, salary) VALUES (1, 'Sofia Garcia', 'Engineer', true, 82000.00), (2, 'Jose Hernandez', 'Engineer', false, 75000.00), (3, 'Maria Rodriguez', 'Cl...
Delete all records with union_member set to false from the 'union_members' table
DELETE FROM union_members WHERE union_member = false;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, name TEXT, country TEXT, amount DECIMAL(10,2)); INSERT INTO Donations (id, name, country, amount) VALUES (1, 'Raj Patel', 'India', 500), (2, 'Min Lee', 'China', 1000), (3, 'Park Kim', 'South Korea', 750), (4, 'Nguyen Tran', 'Vietnam', 800);
Find the names and donation amounts of the top 3 donors from each country in the Donations table.
SELECT name, amount, country FROM (SELECT name, amount, country, ROW_NUMBER() OVER (PARTITION BY country ORDER BY amount DESC) AS rn FROM Donations) AS TopDonorsPerCountry WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tb_cases (patient_id INT, state VARCHAR(255), year INT, confirmed BOOLEAN); INSERT INTO tb_cases (patient_id, state, year, confirmed) VALUES (1, 'CA', 2020, TRUE), (2, 'CA', 2019, FALSE), (3, 'NY', 2020, TRUE);
How many confirmed TB cases were there in California in 2020?
SELECT COUNT(*) FROM tb_cases WHERE state = 'CA' AND year = 2020 AND confirmed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Rights (sector VARCHAR(20), violation_reported BOOLEAN); INSERT INTO Labor_Rights (sector, violation_reported) VALUES ('Healthcare', true), ('Healthcare', false), ('Education', true);
How many labor rights violations have been reported in the healthcare sector?
SELECT SUM(violation_reported) as total_violations FROM Labor_Rights WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE us_gulf_of_mexico_gas_production (well VARCHAR(255), year INT, production FLOAT);
List the top 5 wells with highest gas production in the US Gulf of Mexico.
SELECT well, production FROM us_gulf_of_mexico_gas_production WHERE year = 2020 ORDER BY production DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE worker_salaries (id INT, region VARCHAR(255), salary INT); INSERT INTO worker_salaries (id, region, salary) VALUES (1, 'North', 50000), (2, 'South', 55000), (3, 'East', 60000), (4, 'West', 70000);
What is the average salary for workers in the 'East' region?
SELECT AVG(salary) FROM worker_salaries WHERE region = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, country VARCHAR(20)); INSERT INTO patients (id, country) VALUES (1, 'USA'), (2, 'Canada'); CREATE TABLE counseling (id INT, patient_id INT); INSERT INTO counseling (id, patient_id) VALUES (1, 1), (2, 2);
What is the number of patients in the USA who received counseling?
SELECT COUNT(*) FROM patients INNER JOIN counseling ON patients.id = counseling.patient_id WHERE patients.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections (record_id INT, inspection_date DATE, cuisine VARCHAR(255), violation_count INT); INSERT INTO food_safety_inspections (record_id, inspection_date, cuisine, violation_count) VALUES (1, '2022-01-01', 'Italian', 3), (2, '2022-01-15', 'Mexican', 0);
Insert a new food safety inspection record for 'French' cuisine with a violation count of 1
INSERT INTO food_safety_inspections (record_id, inspection_date, cuisine, violation_count) VALUES (3, '2022-03-01', 'French', 1);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), founder_race VARCHAR(50)); CREATE TABLE investment_round (id INT, company_id INT, round_amount INT); INSERT INTO company (id, name, founder_race) VALUES (1, 'TechX', 'Black'); INSERT INTO investment_round (id, company_id, round_amount) VALUES (1, 1, 2000000); INSERT INTO ...
What is the maximum investment round for startups founded by Black individuals?
SELECT MAX(ir.round_amount) AS max_investment_round FROM company c JOIN investment_round ir ON c.id = ir.company_id WHERE c.founder_race = 'Black';
gretelai_synthetic_text_to_sql
CREATE TABLE union_safety (id INT, union_name TEXT, state TEXT, involved_in_safety BOOLEAN); INSERT INTO union_safety (id, union_name, state, involved_in_safety) VALUES (1, 'Union M', 'Arizona', true), (2, 'Union N', 'Arizona', false), (3, 'Union O', 'Arizona', true);
What is the difference in the number of members between unions that are involved in workplace safety and those that are not in Arizona?
SELECT SUM(involved_in_safety) - SUM(NOT involved_in_safety) FROM union_safety WHERE state = 'Arizona';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(50), city VARCHAR(50), signup_date DATE); INSERT INTO Volunteers (id, volunteer_name, city, signup_date) VALUES (1, 'Jane Smith', 'New York', '2022-01-01'), (2, 'John Doe', 'Los Angeles', '2022-02-01'), (3, 'Bob Johnson', 'Chicago', '2022-03-01'), (4, 'Alice Willi...
What is the number of unique volunteers by city?
SELECT city, COUNT(DISTINCT volunteer_name) as num_unique_volunteers FROM Volunteers GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Market_Share (id INT, vehicle_type VARCHAR(255), market_share DECIMAL(4,2), country VARCHAR(50), year INT); INSERT INTO Market_Share (id, vehicle_type, market_share, country, year) VALUES (1, 'Electric Vehicles', 25.5, 'South Korea', 2020); INSERT INTO Market_Share (id, vehicle_type, market_share, country,...
What is the market share percentage of electric vehicles in South Korea in 2020?
SELECT market_share FROM Market_Share WHERE country = 'South Korea' AND year = 2020 AND vehicle_type = 'Electric Vehicles';
gretelai_synthetic_text_to_sql
CREATE TABLE missions (id INT, name VARCHAR(50), agency VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO missions (id, name, agency, start_date, end_date) VALUES (1, 'Gaia', 'ESA', '2013-12-19', 'ONGOING'); INSERT INTO missions (id, name, agency, start_date, end_date) VALUES (2, 'CHEOPS', 'ESA', '2019-12-18', ...
What is the maximum discovery date of exoplanets found by ESA missions?
SELECT MAX(discovery_date) FROM exoplanets INNER JOIN missions ON exoplanets.mission = missions.name WHERE missions.agency = 'ESA';
gretelai_synthetic_text_to_sql
CREATE TABLE MicroTransactions (TransactionID INT, PlayerID INT, Amount FLOAT, Game VARCHAR(50)); INSERT INTO MicroTransactions (TransactionID, PlayerID, Amount, Game) VALUES (1, 1, 20, 'PUBG'); INSERT INTO MicroTransactions (TransactionID, PlayerID, Amount, Game) VALUES (2, 2, 30, 'PUBG'); INSERT INTO MicroTransaction...
What is the sum of all microtransactions made by players from Africa in PUBG?
SELECT Continent, SUM(Amount) as TotalMicroTransactions FROM MicroTransactions JOIN Players ON MicroTransactions.PlayerID = Players.PlayerID WHERE Game = 'PUBG' AND Continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE FlightData (Airport VARCHAR(20), FlightNumber VARCHAR(20), Delay INT); INSERT INTO FlightData (Airport, FlightNumber, Delay) VALUES ('LAX', 'UA123', 10), ('JFK', 'DL456', 20), ('Heathrow', 'BA789', 30), ('LAX', 'UA987', 40);
Identify the airports with the longest average flight delay.
SELECT Airport, AVG(Delay) AS AvgDelay FROM FlightData GROUP BY Airport ORDER BY AvgDelay DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE endangered_marine_species (id INT, species TEXT); INSERT INTO endangered_marine_species (id, species) VALUES (1, 'Blue Whale'), (2, 'Fin Whale'), (3, 'Hawksbill Turtle'), (4, 'Green Sea Turtle'), (5, 'Leatherback Turtle');
how many species are there in the 'Endangered Marine Species' list?
SELECT COUNT(*) FROM endangered_marine_species;
gretelai_synthetic_text_to_sql
CREATE TABLE industry_threats (industry VARCHAR(255), threat_type VARCHAR(255), num_successful_attacks INT);
Compare the cybersecurity threats faced by different industries and the number of successful attacks they have experienced.
SELECT industry, threat_type, SUM(num_successful_attacks) as total_attacks FROM industry_threats GROUP BY industry, threat_type ORDER BY total_attacks DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE audience_preferences (id INT, audience_id INT, category TEXT, preference TEXT);
Insert a new record into the "audience_preferences" table with the following details: id 6, audience_id 2, category "Politics", preference "Likes reading about local politics"
INSERT INTO audience_preferences (id, audience_id, category, preference) VALUES (6, 2, 'Politics', 'Likes reading about local politics');
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, region TEXT, transaction_amount DECIMAL); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (1, 'John Doe', 'Asia', 500.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (2, 'Jane Smith', 'Europe', 600.00); INSERT INTO cl...
Find the client_id of the client who has the highest transaction amount in each region.
SELECT client_id, region FROM (SELECT client_id, region, transaction_amount, ROW_NUMBER() OVER (PARTITION BY region ORDER BY transaction_amount DESC) AS rank FROM clients) AS ranked_clients WHERE rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), role VARCHAR(50)); INSERT INTO employees (id, name, department, role) VALUES (1, 'John Doe', 'hr', 'employee'), (2, 'Jane Smith', 'hr', 'manager'), (3, 'Bob Johnson', 'operations', 'employee'), (4, 'Alice', 'it', 'employee'), (5, 'Eli', 'research...
Update the role of employee with id 4 to 'senior employee'.
UPDATE employees SET role = 'senior employee' WHERE id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE veg_dishes (dish_id INT, name VARCHAR(50), protein_content DECIMAL(3,2), fiber_content DECIMAL(3,2)); INSERT INTO veg_dishes VALUES (1, 'Vegetarian Chili', 15.5, 8.5); INSERT INTO veg_dishes VALUES (2, 'Vegetable Curry', 12.3, 6.2); CREATE TABLE cafe_locations (dish_id INT, location VARCHAR(50)); INSERT IN...
Find the average protein and fiber content for vegetarian dishes in 'Plant-Powered Cafe'?
SELECT AVG(vd.protein_content), AVG(vd.fiber_content) FROM veg_dishes vd JOIN cafe_locations cl ON vd.dish_id = cl.dish_id WHERE cl.location = 'Plant-Powered Cafe';
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Budgets AS SELECT 10000 AS budget UNION SELECT 12000;
What is the minimum budget for any community education program?
SELECT MIN(budget) FROM Community_Budgets;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), region VARCHAR(255), production FLOAT);
Delete records in the 'wells' table where the 'region' is 'Gulf of Mexico'
DELETE FROM wells WHERE region = 'Gulf of Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, org_id INT, amount INT, date DATE, purpose VARCHAR(30)); INSERT INTO grants (id, org_id, amount, date, purpose) VALUES (1, 1, 10000, '2023-03-01', 'capacity building'), (2, 2, 5000, '2022-12-15', 'program delivery'), (3, 3, 7500, '2023-02-05', 'fundraising'), (4, 1, 15000, '2022-05-15', 'ca...
What is the total amount of grants awarded for capacity building in the last 2 years?
SELECT SUM(amount) FROM grants WHERE purpose = 'capacity building' AND date >= DATEADD(year, -2, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, practice_area VARCHAR(255), billing_amount DECIMAL(10,2)); INSERT INTO cases (id, practice_area, billing_amount) VALUES (1, 'Civil', 5000.00), (2, 'Criminal', 3000.00), (3, 'Civil', 7000.00), (4, 'Civil', 6000.00), (5, 'Criminal', 4000.00);
What is the average billing amount for cases in the 'Civil' practice area?
SELECT AVG(billing_amount) FROM cases WHERE practice_area = 'Civil';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, coowners INT, sustainability_rating FLOAT); INSERT INTO properties (id, coowners, sustainability_rating) VALUES (1, 2, 80.5), (2, 1, 60.0);
What is the maximum sustainability rating in areas with co-owned properties?
SELECT MAX(sustainability_rating) FROM properties WHERE coowners > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE DispensaryViolations (id INT, state VARCHAR(50), year INT, num_violations INT); INSERT INTO DispensaryViolations (id, state, year, num_violations) VALUES (1, 'Oregon', 2019, 50), (2, 'Oregon', 2018, 40), (3, 'California', 2019, 60), (4, 'California', 2018, 50);
What was the total number of violations by dispensaries in the state of Oregon in 2019?
SELECT SUM(num_violations) FROM DispensaryViolations WHERE state = 'Oregon' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE disinformation (id INT, incident_date DATE, incident_type VARCHAR(20)); INSERT INTO disinformation (id, incident_date, incident_type) VALUES (1, '2021-07-01', 'fake news'), (2, '2021-08-15', 'propaganda'), (3, '2021-09-30', 'manipulated media');
What is the total number of disinformation incidents in the last 6 months, by type?
SELECT incident_type, COUNT(*) AS count FROM disinformation WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE City (id INT, name VARCHAR(50), budget FLOAT); INSERT INTO City (id, name, budget) VALUES (1, 'CityA', 2000000); INSERT INTO City (id, name, budget) VALUES (2, 'CityB', 3000000); INSERT INTO City (id, name, budget) VALUES (3, 'CityC', 4000000); CREATE TABLE Department (id INT, city_id INT, name VARCHAR(50)...
What is the total budget for services in CityB?
SELECT SUM(s.budget) FROM Service s JOIN Department d ON s.department_id = d.id WHERE d.city_id = (SELECT id FROM City WHERE name = 'CityB');
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes( process_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), labor_practice_score INT);
Alter 'manufacturing_processes' table to add 'circular_supply_chain' column
ALTER TABLE manufacturing_processes ADD circular_supply_chain BOOLEAN;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50));CREATE TABLE investments (investment_id INT, client_id INT, market VARCHAR(50), value INT);INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'North America'), (2, 'Barbara Black', 'Asia');INSERT INTO investments (investment_id...
How many clients have invested in the Australian market?
SELECT COUNT(DISTINCT c.client_id) FROM clients c INNER JOIN investments i ON c.client_id = i.client_id WHERE i.market = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, Organic BOOLEAN, FairTrade BOOLEAN, VendorID INT); INSERT INTO Vendors VALUES (1, 'VendorH', 'Germany'), (2, 'VendorI', 'Germany'), (3, 'VendorJ', 'Germany'); INSERT INTO Products VA...
Identify the number of vendors that sell only fair trade and organic products.
SELECT COUNT(DISTINCT v.VendorID) FROM Vendors v JOIN Products p ON v.VendorID = p.VendorID WHERE p.Organic = true AND p.FairTrade = true GROUP BY v.VendorID HAVING COUNT(DISTINCT p.ProductID) = (SELECT COUNT(*) FROM Products WHERE VendorID = v.VendorID);
gretelai_synthetic_text_to_sql
CREATE TABLE europe_safety_testing (id INT, vehicle VARCHAR(50), make VARCHAR(50), country VARCHAR(50), score INT);
Create a table for vehicle safety testing results in Europe
CREATE TABLE europe_safety_testing (id INT, vehicle VARCHAR(50), make VARCHAR(50), country VARCHAR(50), score INT);
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (spacecraft_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (1, 'Voyager 1', '1977-09-05'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (2, 'Voyager 2', '1977-08-20'); INSERT INTO spacecrafts (spacecraft_id, n...
Which satellite was launched on the same day as 'Cassini'?
SELECT name FROM spacecrafts WHERE launch_date = (SELECT launch_date FROM spacecrafts WHERE name = 'Cassini');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_category VARCHAR(255), co2_emissions INT);
What are the product categories with zero CO2 emissions in our supply chain?
SELECT product_category FROM products WHERE co2_emissions = 0 GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT PRIMARY KEY, product_name TEXT, product_type TEXT, brand_id INT, is_vegan BOOLEAN, price DECIMAL); INSERT INTO products (product_id, product_name, product_type, brand_id, is_vegan, price) VALUES (1, 'Shampoo', 'Hair Care', 1, true, 14.99), (2, 'Conditioner', 'Hair Care', 1, true, 1...
What is the maximum price of vegan hair care products?
SELECT MAX(price) FROM products WHERE product_type = 'Hair Care' AND is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE victims (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(20));
Insert a new victim record into the "victims" table
INSERT INTO victims (id, name, age, gender, race, ethnicity) VALUES (1001, 'John Doe', 35, 'Male', 'Caucasian', 'Hispanic');
gretelai_synthetic_text_to_sql
CREATE TABLE job_postings_database (id INT, role TEXT, posting_date DATE); INSERT INTO job_postings_database (id, role, posting_date) VALUES (1, 'Diversity Officer', '2022-01-01'), (2, 'Inclusion Specialist', '2022-01-02'), (3, 'Software Engineer', '2022-01-03');
What is the total number of diversity and inclusion roles in the job postings database?
SELECT COUNT(*) as total FROM job_postings_database WHERE role LIKE '%diversity%' OR role LIKE '%inclusion%';
gretelai_synthetic_text_to_sql
CREATE TABLE committee (id INT, name VARCHAR(255)); INSERT INTO committee (id, name) VALUES (1, 'Finance'), (2, 'Transport'), (3, 'Education'); CREATE TABLE member (id INT, committee_id INT, name VARCHAR(255), gender VARCHAR(10)); INSERT INTO member (id, committee_id, name, gender) VALUES (1, 1, 'John Smith', 'Male'), ...
What are the names of the committees that have never had a female member?
SELECT c.name FROM committee c WHERE c.id NOT IN (SELECT m.committee_id FROM member m WHERE m.gender = 'Female')
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (factory_id INT, factory_location VARCHAR(50)); CREATE TABLE Orders (order_id INT, order_date DATE, factory_id INT);
Provide a list of factories in India that have not received any orders in the last 6 months.
SELECT f.factory_id, f.factory_location FROM Factories f LEFT JOIN Orders o ON f.factory_id = o.factory_id WHERE o.order_date < NOW() - INTERVAL 6 MONTH OR o.order_date IS NULL AND f.factory_location = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE user_stats (id INT, user_id INT, gender VARCHAR(10), heart_rate INT, activity VARCHAR(50), timestamp TIMESTAMP); INSERT INTO user_stats (id, user_id, gender, heart_rate, activity, timestamp) VALUES (1, 1001, 'female', 85, 'yoga', '2022-03-02 09:00:00'); INSERT INTO user_stats (id, user_id, gender, heart_ra...
Calculate the average heart rate for users identified as female during their yoga sessions.
SELECT AVG(heart_rate) FROM user_stats WHERE gender = 'female' AND activity = 'yoga';
gretelai_synthetic_text_to_sql
CREATE TABLE Timeline (Project_ID INT, Activity VARCHAR(50), Start_Date DATE, End_Date DATE); CREATE VIEW Vancouver_Projects AS SELECT * FROM Projects WHERE City = 'Vancouver';
Show the projects with delays of more than 30 days in Vancouver.
SELECT p.Project_ID, p.Project_Name, t.Activity, DATEDIFF(t.End_Date, t.Start_Date) as Days_Difference FROM Vancouver_Projects p INNER JOIN Timeline t ON p.Project_ID = t.Project_ID WHERE DATEDIFF(t.End_Date, t.Start_Date) > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Age INT, SpacecraftExperience VARCHAR(50)); INSERT INTO Astronauts (AstronautID, Name, Age, SpacecraftExperience) VALUES (1, 'John Doe', 45, 'SpaceX Dragon'); CREATE TABLE Spacecraft (SpacecraftID INT, SpacecraftName VARCHAR(50), Manufacturer VARCHAR(50)); INS...
What is the average age of astronauts who have piloted a SpaceX Dragon spacecraft?
SELECT AVG(Age) FROM Astronauts INNER JOIN Spacecraft ON Astronauts.SpacecraftExperience = Spacecraft.SpacecraftName WHERE Spacecraft.Manufacturer = 'SpaceX' AND Spacecraft.SpacecraftName = 'SpaceX Dragon';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), VesselType VARCHAR(100), PortID INT); INSERT INTO Vessels (VesselID, VesselName, VesselType, PortID) VALUES (1, 'Ever Ace', 'Container Ship', 1); CREATE TABLE Cargo (CargoID INT, CargoName VARCHAR(100), Quantity INT, VesselID INT); INSERT INTO Cargo (CargoI...
What is the total quantity of electronics transported by container ships?
SELECT SUM(Cargo.Quantity) FROM Cargo INNER JOIN Vessels ON Cargo.VesselID = Vessels.VesselID INNER JOIN VesselTypes ON Vessels.VesselType = VesselTypes.VesselType WHERE VesselTypes.VesselType = 'Container Ship' AND Cargo.CargoName = 'Electronics';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping_projects (project_id INT, name TEXT, start_date DATE); INSERT INTO ocean_floor_mapping_projects (project_id, name, start_date) VALUES (1, 'Mapping Project A', '2018-01-01'), (2, 'Mapping Project B', '2019-07-01'), (3, 'Mapping Project C', '2020-03-15');
List all ocean floor mapping projects and their start dates.
SELECT name, start_date FROM ocean_floor_mapping_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, artist VARCHAR(100), type VARCHAR(50), attendees INT); INSERT INTO events (id, artist, type, attendees) VALUES (1, 'Aura', 'Indigenous', 300), (2, 'Joseph', 'Non-indigenous', 400), (3, 'Kara', 'Indigenous', 350);
What was the average attendance at events organized by indigenous artists?
SELECT AVG(attendees) FROM events WHERE artist IN (SELECT artist FROM events WHERE type = 'Indigenous');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonationDate DATE, DonorState VARCHAR(2)); INSERT INTO Donors (DonorID, DonationDate, DonorState) VALUES (1, '2022-06-05', 'NY'), (2, '2022-07-02', 'CA'), (3, '2022-07-15', 'TX');
How many new donors have donated in the last month and in which state do they reside?
SELECT COUNT(DISTINCT DonorID), DonorState FROM Donors WHERE DonationDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY DonorState;
gretelai_synthetic_text_to_sql
CREATE TABLE state_hospitals (id INT, name TEXT, location TEXT, num_beds INT, state TEXT); INSERT INTO state_hospitals (id, name, location, num_beds, state) VALUES (1, 'Hospital A', 'Rural Texas', 200, 'Texas'), (2, 'Hospital B', 'Rural California', 250, 'California'); CREATE TABLE state_clinics (id INT, name TEXT, loc...
What is the percentage of rural hospitals in each state with less than 50 beds, and the number of clinics in those states?
SELECT s.state, 100.0 * AVG(CASE WHEN sh.num_beds < 50 THEN 1 ELSE 0 END) AS pct_hospitals_less_than_50_beds, COUNT(sc.id) AS num_clinics FROM state_hospitals sh INNER JOIN state_clinics sc ON sh.state = sc.state GROUP BY s.state;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, ethnicity VARCHAR(50), therapy_dropped BOOLEAN, medication_dropped BOOLEAN);
What is the number of patients who dropped out of therapy and medication, separated by ethnicity?
SELECT ethnicity, SUM(CASE WHEN therapy_dropped = TRUE THEN 1 ELSE 0 END) AS dropped_therapy, SUM(CASE WHEN medication_dropped = TRUE THEN 1 ELSE 0 END) AS dropped_medication FROM patients GROUP BY ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_vegan BOOLEAN, price DECIMAL, country TEXT); INSERT INTO products (product_id, product_name, is_vegan, price, country) VALUES (1, 'Lipstick', true, 15.99, 'Canada');
Find the average price of vegan cosmetics sold in Canada.
SELECT AVG(price) FROM products WHERE is_vegan = true AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE incidents_by_country (id INT, country TEXT, quarter INT, year INT, incident_count INT); INSERT INTO incidents_by_country (id, country, quarter, year, incident_count) VALUES (1, 'US', 4, 2021, 50); INSERT INTO incidents_by_country (id, country, quarter, year, incident_count) VALUES (2, 'UK', 4, 2021, 40); I...
List the top 3 countries with the highest number of security incidents in Q4 of 2021.
SELECT country, incident_count FROM incidents_by_country WHERE quarter = 4 AND year = 2021 ORDER BY incident_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_routes (vehicle_id INT, route_id INT, date DATE); INSERT INTO vehicle_routes (vehicle_id, route_id, date) VALUES (101, 101, '2022-01-01'), (102, 101, '2022-01-02'), (103, 102, '2022-01-01'), (104, 102, '2022-01-02'), (105, 103, '2022-01-01'), (106, 103, '2022-01-02'), (107, 102, '2022-02-01'), (108...
How many unique vehicles have been used in route 103 over the last 30 days?
SELECT route_id, COUNT(DISTINCT vehicle_id) FROM vehicle_routes WHERE date >= CURDATE() - INTERVAL 30 DAY AND route_id = 103 GROUP BY route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_reviews (hotel_id INT, review_date DATE, review_score INT); CREATE VIEW hotel_review_summary AS SELECT hotel_id, COUNT(*), AVG(review_score) FROM hotel_reviews GROUP BY hotel_id;
List the number of reviews for each hotel_id from the "hotel_review_summary" view
SELECT hotel_id, review_count FROM hotel_review_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title VARCHAR(255), genre VARCHAR(255), release_year INT); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, timestamp TIMESTAMP); INSERT INTO songs (id, title, genre, release_year) VALUES (1, 'Song1', 'Hip Hop', 2016), (2, 'Song2', 'Rock', 2010), (3, 'Song3', 'Hip Hop', 2015); ...
What is the total number of streams for songs with a genre of hip-hop that were released in 2015 or later?
SELECT COUNT(*) FROM streams JOIN songs ON streams.song_id = songs.id WHERE songs.genre = 'Hip Hop' AND songs.release_year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE IndigenousCommunities (CommunityID int, CommunityName varchar(50), Country varchar(50)); INSERT INTO IndigenousCommunities VALUES (1, 'CommunityA', 'Ecuador'), (2, 'CommunityB', 'Brazil'), (3, 'CommunityC', 'Canada'); CREATE TABLE ExtractionData (CommunityID int, ExtractionDate date, Material varchar(10), ...
What is the total quantity of copper extracted by indigenous communities in Ecuador in H1 2021?
SELECT ic.CommunityName, SUM(ed.Quantity) as TotalExtraction FROM ExtractionData ed JOIN IndigenousCommunities ic ON ed.CommunityID = ic.CommunityID WHERE ed.ExtractionDate BETWEEN '2021-01-01' AND '2021-06-30' AND ed.Material = 'Copper' AND ic.Country = 'Ecuador' GROUP BY ic.CommunityName;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildingProjects (id INT, reduction_type VARCHAR(50), co2_reduction FLOAT); INSERT INTO GreenBuildingProjects (id, reduction_type, co2_reduction) VALUES (1, 'Insulation', 50.0), (2, 'Lighting', 75.0), (3, 'Insulation', 60.0);
What is the total CO2 emission reduction of green building projects in the 'GreenBuildingProjects' table, grouped by reduction_type?
SELECT reduction_type, SUM(co2_reduction) FROM GreenBuildingProjects GROUP BY reduction_type;
gretelai_synthetic_text_to_sql