context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE authors (id INT, name VARCHAR(255), underrepresented BOOLEAN); INSERT INTO authors (id, name, underrepresented) VALUES (1, 'Alice', true), (2, 'Bob', false); CREATE TABLE papers (id INT, title VARCHAR(255), published_date DATE, author_id INT); INSERT INTO papers (id, title, published_date, author_id) VALUES (1, 'Paper1', '2021-06-01', 1), (2, 'Paper2', '2020-12-25', 2); CREATE TABLE topics (id INT, paper_id INT, title VARCHAR(255)) INSERT INTO topics (id, paper_id, title) VALUES (1, 1, 'Algorithmic Fairness'), (2, 2, 'AI Safety');
How many papers on algorithmic fairness were published by authors from underrepresented communities in the past year, in the AI Research database?
SELECT COUNT(*) FROM papers JOIN authors ON papers.author_id = authors.id WHERE authors.underrepresented = true AND YEAR(papers.published_date) = YEAR(CURRENT_DATE()) AND topics.title = 'Algorithmic Fairness';
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (id INT PRIMARY KEY, operation VARCHAR(100), location VARCHAR(50), year INT, budget INT); INSERT INTO PeacekeepingOperations (id, operation, location, year, budget) VALUES (2, 'EUFOR ALTHEA', 'Bosnia and Herzegovina', 2016, 12345678);
What is the minimum budget for peacekeeping operations in Europe since 2016?
SELECT MIN(budget) FROM PeacekeepingOperations WHERE location LIKE '%Europe%' AND year >= 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_yearly (year INT, region VARCHAR(10), cases INT); INSERT INTO infectious_disease_yearly (year, region, cases) VALUES (2019, 'North', 100), (2020, 'North', 120), (2019, 'South', 150), (2020, 'South', 180);
What is the change in infectious disease cases between consecutive years?
SELECT year, region, cases, LAG(cases, 1) OVER (PARTITION BY region ORDER BY year) AS prev_cases, cases - LAG(cases, 1) OVER (PARTITION BY region ORDER BY year) AS change FROM infectious_disease_yearly;
gretelai_synthetic_text_to_sql
CREATE TABLE dept_students (id INT, department VARCHAR(255), gender VARCHAR(10), student_count INT); INSERT INTO dept_students (id, department, gender, student_count) VALUES (1, 'Physics', 'Male', 15), (2, 'Physics', 'Female', 10), (3, 'Computer Science', 'Male', 20), (4, 'Computer Science', 'Female', 18);
How many female and male graduate students are there in each department?
SELECT department, gender, SUM(student_count) AS total_students FROM dept_students GROUP BY department, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE song_details (song_id INT, genre VARCHAR(20), length DECIMAL(5,2)); INSERT INTO song_details (song_id, genre, length) VALUES (1, 'Pop', 3.45), (2, 'Rock', 4.10), (3, 'Jazz', 5.20), (4, 'Pop', 3.20), (5, 'Rock', 4.25);
What are the top 3 genres with the highest average song length in the 'song_details' table?
SELECT genre, AVG(length) as avg_length FROM song_details GROUP BY genre ORDER BY avg_length DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_initiatives ( id INT PRIMARY KEY, region VARCHAR(255), initiative_name VARCHAR(255), initiative_description TEXT, start_date DATE, end_date DATE); INSERT INTO recycling_initiatives (id, region, initiative_name, initiative_description, start_date, end_date) VALUES (1, 'Africa', 'Plastic Bottle Collection', 'Collecting plastic bottles in schools and parks.', '2020-01-01', '2020-12-31'), (2, 'South America', 'E-Waste Disposal', 'Establishing e-waste drop-off points in major cities.', '2019-06-15', '2021-06-14'), (3, 'Oceania', 'Composting Program', 'Implementing composting programs in households.', '2018-04-22', '2022-04-21'), (4, 'Antarctica', 'Research and Development', 'Researching new waste reduction methods.', '2023-07-04', '2026-07-03'); CREATE VIEW active_recycling_initiatives AS SELECT * FROM recycling_initiatives WHERE end_date >= CURDATE();
Create a view for active recycling initiatives
CREATE VIEW active_recycling_initiatives AS SELECT * FROM recycling_initiatives WHERE end_date >= CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_players (player_name TEXT, team TEXT, home_runs INT); INSERT INTO baseball_players (player_name, team, home_runs) VALUES ('Mike Trout', 'Angels', 45), ('Aaron Judge', 'Yankees', 44), ('Nolan Arenado', 'Rockies', 42);
How many home runs has each baseball player hit in the current season?
SELECT player_name, team, home_runs FROM baseball_players;
gretelai_synthetic_text_to_sql
CREATE TABLE GarmentSales (SaleID INT, Category VARCHAR(255), SaleMonth VARCHAR(255)); INSERT INTO GarmentSales (SaleID, Category, SaleMonth) VALUES (1, 'Tops', 'January');
Rank garment categories by the number of times they were sold, per month, and show only the top ranked category in each month.
SELECT Category, SaleMonth, ROW_NUMBER() OVER (PARTITION BY SaleMonth ORDER BY COUNT(*) DESC) as Rank FROM GarmentSales GROUP BY Category, SaleMonth HAVING Rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganizationESG (OrgID INT, Country VARCHAR(50), Region VARCHAR(50), ESG FLOAT); INSERT INTO OrganizationESG (OrgID, Country, Region, ESG) VALUES (1, 'US', 'Americas', 75), (2, 'Canada', 'Americas', 80), (3, 'Mexico', 'Americas', 70), (4, 'Brazil', 'Americas', 85), (5, 'Argentina', 'Americas', 78), (6, 'Colombia', 'Americas', 72);
Find the average ESG score for each country in the Americas region?
SELECT Country, AVG(ESG) as AvgESG FROM OrganizationESG WHERE Region = 'Americas' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME); INSERT INTO Artifacts (ArtifactID, Name, CreationDate) VALUES (1, 'Ancient Dagger', '1500-01-01'), (2, 'Modern Artifact', '2020-01-01');
What is the name and creation date of the artifact with the second latest creation date?
SELECT Name, CreationDate FROM (SELECT Name, CreationDate, ROW_NUMBER() OVER (ORDER BY CreationDate DESC) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE south_china_sea_farms (id INT, name TEXT, ph FLOAT);
What is the minimum ph level recorded in fish farms in the South China Sea?
SELECT MIN(ph) FROM south_china_sea_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE production (company_id INT, year INT, ree_production INT); INSERT INTO production (company_id, year, ree_production) VALUES (1, 2019, 1200), (1, 2020, 1500), (1, 2021, 1800), (2, 2019, 800), (2, 2020, 1000), (2, 2021, 1200);
Summarize REE production by company and year.
SELECT company_id, year, SUM(ree_production) as total_production FROM production GROUP BY company_id, year;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_development ( id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(64), safety_training_hours INT );
Insert a new record into the 'workforce_development' table with 'employee_name' as 'Sophia Lee', 'department' as 'engineering', and 'safety_training_hours' as 12
INSERT INTO workforce_development (employee_name, department, safety_training_hours) VALUES ('Sophia Lee', 'engineering', 12);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_activities (activity_id INT, activity_name TEXT, country TEXT, capacity INT); INSERT INTO sustainable_activities (activity_id, activity_name, country, capacity) VALUES (1, 'Amazon Rainforest Tour', 'Brazil', 50), (2, 'Iguazu Falls Hike', 'Brazil', 100);
List all sustainable tourism activities in Brazil and their respective capacities.
SELECT activity_name, capacity FROM sustainable_activities WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR, location VARCHAR, LGBTQ_identification VARCHAR); INSERT INTO community_health_workers (id, name, location, LGBTQ_identification) VALUES (1, 'John Doe', 'Urban', 'Yes'); INSERT INTO community_health_workers (id, name, location, LGBTQ_identification) VALUES (2, 'Jane Smith', 'Rural', 'No');
How many community health workers identify as part of the LGBTQ+ community in urban areas?
SELECT location, COUNT(*) as total_LGBTQ_workers FROM community_health_workers WHERE location = 'Urban' AND LGBTQ_identification = 'Yes' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE PoetryReadings(id INT, age INT, gender VARCHAR(10), visit_date DATE);
What is the percentage of visitors who attended "Poetry Readings" and were aged 18-35?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM PoetryReadings) FROM PoetryReadings WHERE age BETWEEN 18 AND 35;
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID INT, Name VARCHAR(50), Country VARCHAR(50), Score INT);
What is the average score of players residing in Asia?
SELECT AVG(Score) FROM Player WHERE Country IN ('China', 'India', 'Japan', 'South Korea', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, location VARCHAR(10), item VARCHAR(10), quantity INT); INSERT INTO warehouses (id, location, item, quantity) VALUES (1, 'NY', 'A101', 200), (2, 'NJ', 'A101', 300), (3, 'CA', 'B203', 150), (4, 'NY', 'C304', 50);
What is the total quantity of items in warehouses located in 'NY' and 'NJ'?
SELECT SUM(quantity) FROM warehouses WHERE location IN ('NY', 'NJ');
gretelai_synthetic_text_to_sql
CREATE TABLE hospital (hospital_id INT, name TEXT, location TEXT, beds INT, state TEXT);
What is the average number of hospital beds in rural areas of each state?
SELECT state, AVG(beds) FROM hospital WHERE location LIKE '%rural%' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (year INT, campaign VARCHAR(20), target VARCHAR(20), budget FLOAT); INSERT INTO climate_communication (year, campaign, target, budget) VALUES (2020, 'Campaign1', 'Bangladesh', 2000000), (2020, 'Campaign2', 'Pakistan', 1500000), (2020, 'Campaign3', 'Mozambique', 1800000), (2020, 'Campaign4', 'Maldives', 2200000), (2020, 'Campaign5', 'Fiji', 1900000);
Find the number of unique climate communication campaigns in 2020 that targeted countries with high vulnerability to climate change, and the average budget for these campaigns.
SELECT COUNT(DISTINCT campaign) AS num_campaigns, AVG(budget) AS avg_budget FROM climate_communication WHERE year = 2020 AND target IN ('Bangladesh', 'Pakistan', 'Mozambique', 'Maldives', 'Fiji');
gretelai_synthetic_text_to_sql
CREATE TABLE Pacific_Ocean (id INT, date DATE, deaths INT); INSERT INTO Pacific_Ocean (id, date, deaths) VALUES (1, '2022-01-01', 100), (2, '2022-01-05', 200), (3, '2022-02-15', 300);
What is the number of fish deaths in the Pacific Ocean in the last 3 months?
SELECT COUNT(deaths) FROM Pacific_Ocean WHERE date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE);
Show the names and locations of restorative justice programs that have ended, grouped by location
SELECT location, GROUP_CONCAT(name) AS Programs FROM programs WHERE type = 'Restorative Justice' AND end_date IS NOT NULL GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR, region VARCHAR); INSERT INTO marine_species (name, region) VALUES ('Dolphin', 'Atlantic'), ('Shark', 'Pacific'), ('Clownfish', 'Indian'), ('Tuna', 'Atlantic'), ('Jellyfish', 'Atlantic');
What is the maximum number of marine species in each region?
SELECT region, MAX(COUNT(*)) OVER (PARTITION BY NULL) FROM marine_species GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE election_data (state VARCHAR(255), party VARCHAR(255), votes INT, total_votes INT); INSERT INTO election_data (state, party, votes, total_votes) VALUES ('Florida', 'Democratic', 4800000, 11000000);
What is the percentage of voters in 'Florida' who voted for the Democratic party in the 2020 presidential election?
SELECT (votes * 100.0 / total_votes) AS percentage FROM election_data WHERE state = 'Florida' AND party = 'Democratic';
gretelai_synthetic_text_to_sql
CREATE TABLE player_stats (player VARCHAR(255), year INT, goals INT); INSERT INTO player_stats (player, year, goals) VALUES ('Messi', 2019, 51);
How many goals did Messi score in 2019?
SELECT goals FROM player_stats WHERE player = 'Messi' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Player_Demographics (id INT PRIMARY KEY, player_id INT, age INT, gender VARCHAR(255), country VARCHAR(255));
Add a new column 'disability_status' to 'Player_Demographics'
ALTER TABLE Player_Demographics ADD COLUMN disability_status VARCHAR(255);
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, State VARCHAR(10)); CREATE TABLE Cases (CaseID INT, CaseType VARCHAR(20), BillingAmount INT); INSERT INTO Attorneys (AttorneyID, State) VALUES (1, 'NY'), (2, 'CA'), (3, 'NY'), (4, 'NJ'); INSERT INTO Cases (CaseID, CaseType, BillingAmount) VALUES (1, 'Civil', 500), (2, 'Criminal', 1000), (3, 'Civil', 750), (4, 'Civil', 800);
List the case types and their respective average billing amounts for cases handled by attorneys from New York or California.
SELECT CaseType, AVG(BillingAmount) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.State = 'NY' OR Attorneys.State = 'CA' GROUP BY CaseType;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (id INT, name TEXT, balance INT, type TEXT); INSERT INTO digital_assets (id, name, balance, type) VALUES (1, 'Asset1', 50, 'token'), (2, 'Asset2', 100, 'coin'), (3, 'Asset3', 150, 'token');
What is the average balance of all digital assets with a type of 'coin'?
SELECT AVG(digital_assets.balance) AS avg_balance FROM digital_assets WHERE digital_assets.type = 'coin';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50)); CREATE TABLE education_programs (id INT, habitat_id INT, coordinator_name VARCHAR(50));
List all the community education programs in the 'education_programs' table that are not associated with any animal species in the 'animal_population' table.
SELECT e.coordinator_name FROM education_programs e LEFT JOIN animal_population a ON e.habitat_id = a.id WHERE a.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (id INT, initiative_name VARCHAR(50), country VARCHAR(50), year INT, funded BOOLEAN); INSERT INTO climate_communication (id, initiative_name, country, year, funded) VALUES (1, 'Climate Awareness Campaign', 'Nigeria', 2020, FALSE);
Which climate communication initiatives in Africa were not funded in 2020?
SELECT initiative_name FROM climate_communication WHERE country = 'Africa' AND year = 2020 AND funded = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, business_size VARCHAR(255), contract_date DATE); INSERT INTO defense_contracts (contract_id, business_size, contract_date) VALUES (1, 'Small Business', '2022-03-01'), (2, 'Large Business', '2022-04-02'), (3, 'Small Business', '2022-03-03');
How many defense contracts were awarded to small businesses in the month of March?
SELECT COUNT(*) FROM defense_contracts WHERE business_size = 'Small Business' AND EXTRACT(MONTH FROM contract_date) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE trams (id INT, city VARCHAR(50), fare DECIMAL(5,2)); INSERT INTO trams (id, city, fare) VALUES (1, 'Berlin', 2.10), (2, 'Berlin', 1.90), (3, 'Berlin', 2.30), (4, 'New York', 3.50);
What is the total fare collected for trams in Berlin?
SELECT SUM(fare) FROM trams WHERE city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, worker_name VARCHAR(50), language_spoken VARCHAR(20), years_of_experience INT);
List all community health workers from Brazil
SELECT * FROM community_health_workers WHERE state = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Forests ( ForestID INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Hectares FLOAT ); CREATE TABLE Species ( SpeciesID INT PRIMARY KEY, Name VARCHAR(50), ForestID INT, FOREIGN KEY (ForestID) REFERENCES Forests(ForestID)); CREATE TABLE Wildlife ( WildlifeID INT PRIMARY KEY, Species VARCHAR(50), Population INT, ForestID INT, FOREIGN KEY (ForestID) REFERENCES Forests(ForestID)); CREATE VIEW TotalPopulation AS SELECT Species, SUM(Population) AS TotalPopulation FROM Wildlife GROUP BY Species;
Which species have the highest total population in a specific country?
SELECT Species, TotalPopulation FROM Wildlife INNER JOIN TotalPopulation ON Wildlife.Species = TotalPopulation.Species WHERE Forests.Country = 'Brazil' GROUP BY Species ORDER BY TotalPopulation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (id INT, title VARCHAR(50), description TEXT, date DATE);
Add new record to sustainable_practices table with id 12, title 'Rainwater Harvesting Systems Installation', description 'Installation of rainwater harvesting systems on buildings', date '2022-05-05'
INSERT INTO sustainable_practices (id, title, description, date) VALUES (12, 'Rainwater Harvesting Systems Installation', 'Installation of rainwater harvesting systems on buildings', '2022-05-05');
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates(city TEXT, material_type TEXT, recycling_rate FLOAT); INSERT INTO recycling_rates(city, material_type, recycling_rate) VALUES('S', 'plastic', 0.7), ('S', 'glass', 0.8), ('S', 'paper', 0.9);
What is the recycling rate by material type in city S?
SELECT material_type, AVG(recycling_rate) FROM recycling_rates WHERE city = 'S' GROUP BY material_type;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farm (farm_id INT, location VARCHAR(20), num_fish INT); INSERT INTO fish_farm (farm_id, location, num_fish) VALUES (1, 'Baltic Sea', 5000), (2, 'North Sea', 7000), (3, 'Baltic Sea', 6000);
How many fish are raised in each farm in the Baltic Sea region?
SELECT farm_id, location, num_fish FROM fish_farm WHERE location = 'Baltic Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (post_id INT, user_id INT, post_type VARCHAR(20), posted_at TIMESTAMP); INSERT INTO posts (post_id, user_id, post_type, posted_at) VALUES (1, 101, 'Text', '2021-01-01 12:00:00'), (2, 102, 'Image', '2021-01-02 13:00:00'); CREATE TABLE users (user_id INT, age INT, gender VARCHAR(10), country VARCHAR(10)); INSERT INTO users (user_id, age, gender, country) VALUES (101, 25, 'Female', 'Japan'), (102, 35, 'Male', 'France');
What is the average number of posts per day, for users from Japan, grouped by age and gender?
SELECT u.age, u.gender, AVG(COUNT(*)) AS avg_posts_per_day FROM users u INNER JOIN posts p ON u.user_id = p.user_id WHERE u.country = 'Japan' GROUP BY u.age, u.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE resilience_standards (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE);
List the projects in the 'resilience_standards' table that have a start date within the next 30 days, ordered by their start date.
SELECT * FROM resilience_standards WHERE start_date >= GETDATE() AND start_date < DATEADD(day, 30, GETDATE()) ORDER BY start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE experiments (id INT, name VARCHAR(50), technology VARCHAR(50), description TEXT, target VARCHAR(50)); INSERT INTO experiments (id, name, technology, description, target) VALUES (2, 'Experiment2', 'CRISPR', 'Gene editing using CRISPR...', 'Plants');
Which genetic research experiments used CRISPR technology for gene editing in plants?
SELECT name FROM experiments WHERE technology = 'CRISPR' AND target = 'Plants';
gretelai_synthetic_text_to_sql
CREATE TABLE campus (id INT, name VARCHAR(50), region VARCHAR(50)); CREATE TABLE disability_services_office (id INT, campus_id INT, phone VARCHAR(20), email VARCHAR(50));
Update the contact information for the disability services office at the specified campus, including phone number and email address.
UPDATE disability_services_office dso SET phone = '555-123-4567', email = 'ds@campus.edu' WHERE campus_id = (SELECT id FROM campus WHERE name = 'Campus Name');
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_images (image_id INT, image_url TEXT, capture_time TIMESTAMP); INSERT INTO satellite_images (image_id, image_url, capture_time) VALUES (1, 'image1.jpg', '2022-01-01 10:00:00'), (2, 'image2.jpg', '2021-05-01 10:00:00');
Which satellite images in the 'satellite_images' table were taken after 2021-06-01?
SELECT image_id, image_url, capture_time FROM satellite_images WHERE capture_time > '2021-06-01';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists north_africa; USE north_africa; CREATE TABLE if not exists military_bases (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO military_bases (id, name, type, location) VALUES (1, 'Wheelus Air Base', 'Air Force Base', 'Libya'), (2, 'Mers El Kébir', 'Navy Base', 'Algeria'), (3, 'British Army Training Unit Suffield', 'Army Base', 'Canada');
Show me the names and locations of all military bases located in 'north_africa' schema
SELECT name, location FROM north_africa.military_bases;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, Age INT, Gender VARCHAR(20), State VARCHAR(20)); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (1, 45, 'Female', 'Texas'); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (2, 35, 'Male', 'Texas');
What is the average age of community health workers in Texas?
SELECT AVG(Age) FROM CommunityHealthWorker WHERE State = 'Texas' AND Gender = 'Community Health Worker';
gretelai_synthetic_text_to_sql
CREATE TABLE education_levels (person_id INT, city VARCHAR(255), tertiary_education BOOLEAN); INSERT INTO education_levels (person_id, city, tertiary_education) VALUES (1, 'Melbourne', TRUE), (2, 'Melbourne', TRUE), (3, 'Melbourne', FALSE); CREATE TABLE population_sizes (city VARCHAR(255), size INT); INSERT INTO population_sizes (city, size) VALUES ('Melbourne', 5000000);
What is the percentage of the population in Melbourne that has completed a tertiary education, and what is the population size?
SELECT (COUNT(*) * 100.0 / (SELECT size FROM population_sizes WHERE city = 'Melbourne')) AS education_percentage FROM education_levels WHERE city = 'Melbourne' AND tertiary_education = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_north (sector VARCHAR(20), usage INT); INSERT INTO water_usage_north (sector, usage) VALUES ('Agriculture', 300), ('Domestic', 200), ('Industrial', 500); CREATE TABLE water_usage_south (sector VARCHAR(20), usage INT); INSERT INTO water_usage_south (sector, usage) VALUES ('Agriculture', 400), ('Domestic', 250), ('Industrial', 600);
Find the total water usage by each sector across all regions using a UNION.
(SELECT sector, SUM(usage) FROM water_usage_north GROUP BY sector) UNION (SELECT sector, SUM(usage) FROM water_usage_south GROUP BY sector)
gretelai_synthetic_text_to_sql
CREATE TABLE ArtData (id INT, art_category VARCHAR(50), num_pieces INT); INSERT INTO ArtData (id, art_category, num_pieces) VALUES (1, 'Abstract', 100), (2, 'Surrealist', 150), (3, 'Impressionist', 200), (4, 'Cubist', 120), (5, 'Expressionist', 180);
What is the total number of art pieces in the abstract and surrealist categories?
SELECT SUM(num_pieces) FROM ArtData WHERE art_category IN ('Abstract', 'Surrealist');
gretelai_synthetic_text_to_sql
CREATE TABLE department (dept_id INT, dept_name TEXT, building TEXT); CREATE TABLE workshops (workshop_id INT, workshop_name TEXT, year INT, dept_id INT); INSERT INTO department (dept_id, dept_name, building) VALUES (10, 'Social Sciences', 'Westside Building'), (20, 'Physical Education', 'Gymnasium'); INSERT INTO workshops (workshop_id, workshop_name, year, dept_id) VALUES (101, 'Teaching Strategies', 2022, 10), (102, 'Inclusive Education', 2022, 10), (103, 'Data Analysis', 2021, 20);
How many professional development workshops were conducted in the social sciences department in 2022?
SELECT COUNT(w.workshop_id) as num_workshops FROM workshops w INNER JOIN department d ON w.dept_id = d.dept_id WHERE w.year = 2022 AND d.dept_name = 'Social Sciences';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure (id INT, name TEXT, location TEXT, project_status TEXT, completion_date DATE);
List the names and locations of rural infrastructure projects in 'rural_development' database, grouped by project status and year of completion.
SELECT name, location, project_status, completion_date FROM infrastructure GROUP BY name, location, project_status, completion_date;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, location VARCHAR(50), region VARCHAR(50), year INT, size INT); INSERT INTO charging_stations (id, location, region, year, size) VALUES (1, 'Delhi', 'North', 2022, 500); INSERT INTO charging_stations (id, location, region, year, size) VALUES (2, 'Mumbai', 'West', 2022, 600); INSERT INTO charging_stations (id, location, region, year, size) VALUES (3, 'Bangalore', 'South', 2022, 700); INSERT INTO charging_stations (id, location, region, year, size) VALUES (4, 'Kolkata', 'East', 2022, 400);
How many electric vehicle charging stations were installed in each region of India in 2022?
SELECT region, COUNT(size) FROM charging_stations WHERE year = 2022 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE TeamSales (TeamID INT, GameID INT, TicketPrice DECIMAL(5,2), Attendance INT); INSERT INTO TeamSales (TeamID, GameID, TicketPrice, Attendance) VALUES (1, 1, 50.00, 1000), (1, 2, 55.00, 1200), (2, 1, 45.00, 800), (2, 2, 50.00, 900), (3, 1, 60.00, 1500), (3, 2, 65.00, 1800);
Find the top 3 teams with the highest total ticket revenue.
SELECT TeamID, SUM(TicketPrice * Attendance) as TotalRevenue FROM TeamSales GROUP BY TeamID ORDER BY TotalRevenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, age INT, country TEXT, role TEXT); INSERT INTO volunteers (id, age, country, role) VALUES (1, 35, 'Mexico', 'Language Preservation'), (2, 45, 'USA', 'Language Preservation'), (3, 28, 'Mexico', 'Community Engagement');
What is the average age of language preservation volunteers in Mexico?
SELECT AVG(age) FROM volunteers WHERE country = 'Mexico' AND role = 'Language Preservation';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT, name TEXT, location TEXT, funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'Texas', 5000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (2, 'StartupB', 'California', 7000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (3, 'StartupC', 'Texas', 3000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (4, 'StartupD', 'California', 4000000.00); INSERT INTO biotech.startups (id, name, location, funding) VALUES (5, 'StartupE', 'California', 2000000.00);
Minimum funding for biotech startups in California
SELECT MIN(funding) FROM biotech.startups WHERE location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE middle_eastern_countries (country VARCHAR(255), population INT, water_consumption INT); INSERT INTO middle_eastern_countries (country, population, water_consumption) VALUES ('Saudi Arabia', 34000000, 13600000000), ('Iran', 84000000, 33600000000);
Find the average water consumption per person in Middle Eastern countries.
SELECT country, water_consumption / population AS avg_water_consumption FROM middle_eastern_countries;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_planting (id INT, location VARCHAR(50), crop VARCHAR(50), planting_date DATE, planting_time TIME); INSERT INTO crop_planting (id, location, crop, planting_date, planting_time) VALUES (1, 'Field3', 'Corn', '2022-02-20', '14:30:00'), (2, 'Field5', 'Soybeans', '2022-03-01', '09:45:00');
Determine the number of times each crop type has been planted in Field3, Field5, and Field8 in 2022.
SELECT crop, COUNT(*) AS planting_count FROM crop_planting WHERE location IN ('Field3', 'Field5', 'Field8') AND planting_date >= '2022-01-01' AND planting_date < '2023-01-01' GROUP BY crop;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (volunteer_id INT, program_id INT, hours DECIMAL(10, 2), hour_date DATE); INSERT INTO volunteer_hours VALUES (1, 101, 3.00, '2021-01-01'), (2, 101, 2.50, '2021-02-01'), (3, 102, 4.00, '2021-01-10');
Which programs had the highest volunteer hours in 2021?
SELECT program_id, SUM(hours) FROM volunteer_hours GROUP BY program_id ORDER BY SUM(hours) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE TramMaintenance (MaintenanceID INT, MaintenanceDate DATE, VehicleID INT);
What is the total number of maintenance events for trams in the last year?
SELECT COUNT(MaintenanceID) FROM TramMaintenance WHERE MaintenanceDate >= DATEADD(YEAR, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE SuicideRates (Region VARCHAR(50), Population INT, Suicides INT); INSERT INTO SuicideRates (Region, Population, Suicides) VALUES ('North', 1000000, 1000), ('South', 1200000, 1500), ('East', 1100000, 1200), ('West', 900000, 900);
What is the suicide rate in each region?
SELECT Region, (SUM(Suicides) / SUM(Population)) * 100000 AS SuicideRate FROM SuicideRates GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE RestorativeJusticeFacilitators (FacilitatorName text, CaseType text, NumCases int); INSERT INTO RestorativeJusticeFacilitators VALUES ('Facilitator1', 'Assault', 15, '2022-01-01'), ('Facilitator1', 'Theft', 10, '2022-01-01'), ('Facilitator2', 'Assault', 12, '2022-01-01'), ('Facilitator2', 'Theft', 8, '2022-01-01');
What is the number of cases handled by each restorative justice facilitator, broken down by facilitator name and case type?
SELECT FacilitatorName, CaseType, SUM(NumCases) FROM RestorativeJusticeFacilitators GROUP BY FacilitatorName, CaseType;
gretelai_synthetic_text_to_sql
CREATE TABLE job_levels (id INT, level VARCHAR(255)); INSERT INTO job_levels (id, level) VALUES (1, 'Entry'), (2, 'Mid'), (3, 'Senior'); CREATE TABLE salaries (id INT, job_level_id INT, salary INT); INSERT INTO salaries (id, job_level_id, salary) VALUES (1, 1, 50000), (2, 2, 70000), (3, 3, 90000);
What is the minimum, maximum, and average salary by job level?
SELECT job_levels.level, MIN(salaries.salary) as min_salary, MAX(salaries.salary) as max_salary, AVG(salaries.salary) as avg_salary FROM job_levels JOIN salaries ON job_levels.id = salaries.job_level_id GROUP BY job_levels.level;
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_id INT PRIMARY KEY, state_name TEXT, budget_allocation FLOAT);CREATE TABLE infrastructure_budget (state_id INT, budget FLOAT);
Identify the states with the highest and lowest budget allocation to infrastructure
SELECT s.state_name, AVG(ib.budget) as avg_budget FROM states s INNER JOIN infrastructure_budget ib ON s.state_id = ib.state_id GROUP BY s.state_name ORDER BY avg_budget DESC LIMIT 1;SELECT s.state_name, AVG(ib.budget) as avg_budget FROM states s INNER JOIN infrastructure_budget ib ON s.state_id = ib.state_id GROUP BY s.state_name ORDER BY avg_budget ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50), account_balance DECIMAL(10,2)); INSERT INTO clients (client_id, name, region, account_balance) VALUES (1, 'Lei Wang', 'Asia Pacific', 35000.00), (2, 'Hiroshi Tanaka', 'Asia Pacific', 40000.00);
What is the maximum account balance for clients in the Asia Pacific region?
SELECT MAX(account_balance) FROM clients WHERE region = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Destinations (id INT PRIMARY KEY, country_id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO Destinations (id, country_id, name, type) VALUES (1, 1, 'Sydney Opera House', 'Cultural'); INSERT INTO Destinations (id, country_id, name, type) VALUES (2, 1, 'Great Barrier Reef', 'Natural'); INSERT INTO Destinations (id, country_id, name, type) VALUES (3, 2, 'Niagara Falls', 'Natural'); INSERT INTO Destinations (id, country_id, name, type) VALUES (4, 2, 'CN Tower', 'Architectural');
What is the average number of visitors for natural destinations in each country?
SELECT country_id, AVG(visitors) FROM Tourists t JOIN Destinations d ON t.country_id = d.country_id WHERE d.type = 'Natural' GROUP BY country_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), TotalDonation DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, TotalDonation) VALUES (1, 'John Doe', 15000.00), (2, 'Jane Smith', 12000.00), (3, 'Alice Johnson', 10000.00);
What is the total donation amount per donor, sorted by the highest donors?
SELECT DonorName, TotalDonation FROM (SELECT DonorName, TotalDonation, ROW_NUMBER() OVER (ORDER BY TotalDonation DESC) as rnk FROM Donors) sub WHERE rnk = 1 OR rnk = 2 OR rnk = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence_reports (report_id INT, report_date DATE, threat_category VARCHAR(255), generating_agency VARCHAR(255));
Show the number of threat intelligence reports generated by each agency in the past quarter
SELECT generating_agency, COUNT(*) as report_count FROM threat_intelligence_reports WHERE report_date >= DATEADD(quarter, -1, CURRENT_DATE) GROUP BY generating_agency;
gretelai_synthetic_text_to_sql
training_programs
Show the number of active training programs by department
SELECT department, COUNT(*) as active_programs FROM training_programs WHERE CURDATE() BETWEEN start_date AND end_date GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'Australia'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3, 'Alice Johnson', 'Japan'); CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount decimal(10, 2)); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 5000); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (2, 2, 1000); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (3, 2, 1500); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (4, 3, 2000);
What is the average donation amount for donors from Oceania?
SELECT AVG(Donations.DonationAmount) as AverageDonationAmount FROM Donors INNER JOIN Donations ON Donations.DonorID = Donors.DonorID WHERE Donors.Country IN ('Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE customer_orders (id INT, customer VARCHAR(100), product VARCHAR(100), category VARCHAR(100), order_date DATE, quantity INT);
Identify the top 5 most purchased products in the "skincare" category by customers from the United States.
SELECT product, SUM(quantity) as total_purchases FROM customer_orders WHERE country = 'United States' AND category = 'skincare' GROUP BY product ORDER BY total_purchases DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists gaming; CREATE TABLE if not exists gaming.games (game_id INT, game_name VARCHAR(255), category VARCHAR(255), release_date DATE, revenue FLOAT); INSERT INTO gaming.games (game_id, game_name, category, release_date, revenue) VALUES (1, 'Game A', 'Action', '2021-01-01', 5000000), (2, 'Game B', 'Adventure', '2021-06-15', 7000000), (3, 'Game C', 'Simulation', '2022-04-01', 3000000), (4, 'Game D', 'Strategy', '2022-07-22', 8000000);
What is the total revenue generated by each game category in Q2 2022?
SELECT category, SUM(revenue) as total_revenue FROM gaming.games WHERE release_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE team_wins (id INT, team VARCHAR(50), sport VARCHAR(20), season VARCHAR(10), wins INT);
What is the average number of wins per season for a specific football team?
SELECT AVG(wins) FROM team_wins WHERE team = 'Manchester United' AND sport = 'Football' GROUP BY season;
gretelai_synthetic_text_to_sql
CREATE TABLE NATOCybersecurityStrategies (id INT, strategy VARCHAR(255), implementation_date DATE); INSERT INTO NATOCybersecurityStrategies (id, strategy, implementation_date) VALUES (1, 'NATO Cyber Defence Pledge', '2016-07-08'); INSERT INTO NATOCybersecurityStrategies (id, strategy, implementation_date) VALUES (2, 'NATO Cyber Coalition', '2018-11-14');
What is the name and implementation date of each cybersecurity strategy implemented by NATO in the last 5 years?
SELECT strategy, implementation_date FROM NATOCybersecurityStrategies WHERE implementation_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE item_inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT);
Update the quantity of item_id 100 to 500 in the item_inventory table
UPDATE item_inventory SET quantity = 500 WHERE item_id = 100;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, city TEXT, views INT); INSERT INTO virtual_tours (tour_id, city, views) VALUES (1, 'CityX', 200), (2, 'CityY', 300), (3, 'CityZ', 150), (4, 'CityX', 250), (5, 'CityW', 400);
What are the top 2 most viewed cities for virtual tours in 'North America'?
SELECT city, SUM(views) as total_views FROM virtual_tours WHERE city IN ('CityX', 'CityY', 'CityZ', 'CityW') GROUP BY city ORDER BY total_views DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE AffordableHousing (UnitID INT, City VARCHAR(50), OccupancyRate DECIMAL(4,2)); INSERT INTO AffordableHousing (UnitID, City, OccupancyRate) VALUES (1, 'San Francisco', 0.85), (2, 'New York', 0.92), (3, 'Los Angeles', 0.76);
Show affordable housing units by city and their respective occupancy rates.
SELECT City, OccupancyRate FROM AffordableHousing WHERE UnitID IN (SELECT UnitID FROM AffordableHousing WHERE City IN ('San Francisco', 'New York', 'Los Angeles') AND OccupancyRate < 1);
gretelai_synthetic_text_to_sql
CREATE TABLE RiskAssessments (assessment_id INT, region VARCHAR(50), risk_level VARCHAR(10), assessment_date DATE);
Identify the geopolitical risk assessments with high, medium, and low risks for the Middle East in the past 6 months.
SELECT region, risk_level FROM RiskAssessments WHERE region = 'Middle East' AND assessment_date BETWEEN '2022-01-01' AND CURDATE() GROUP BY region, risk_level;
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentPlants (ID INT, State VARCHAR(20), Efficiency FLOAT); INSERT INTO WastewaterTreatmentPlants (ID, State, Efficiency) VALUES (1, 'California', 0.92), (2, 'Texas', 0.91), (3, 'Florida', 0.89), (4, 'California', 0.93), (5, 'Texas', 0.90), (6, 'Florida', 0.88);
List the top 3 states with the highest wastewater treatment plant efficiency in descending order.
SELECT State, Efficiency FROM (SELECT State, Efficiency, ROW_NUMBER() OVER (ORDER BY Efficiency DESC) as rn FROM WastewaterTreatmentPlants) tmp WHERE rn <= 3
gretelai_synthetic_text_to_sql
CREATE TABLE FinanceAIs (ID INT, AI VARCHAR(255), Type VARCHAR(255), Date DATE, Company_Country VARCHAR(255)); INSERT INTO FinanceAIs (ID, AI, Type, Date, Company_Country) VALUES (1, 'AI1', 'Finance', '2023-01-01', 'Brazil'), (2, 'AI2', 'Non-Finance', '2023-01-05', 'Argentina'), (3, 'AI3', 'Finance', '2023-02-12', 'Chile'), (4, 'AI4', 'Finance', '2023-03-01', 'Colombia'), (5, 'AI5', 'Non-Finance', '2023-03-05', 'Peru'), (6, 'AI6', 'Finance', '2023-04-01', 'Uruguay'), (7, 'AI7', 'Finance', '2023-05-01', 'Bolivia');
What is the total number of AI models created for finance applications, by month, in the year 2023, for companies based in South America?
SELECT EXTRACT(MONTH FROM Date) as Month, COUNT(*) as Total_Finance_AIs FROM FinanceAIs WHERE Type = 'Finance' AND Date BETWEEN '2023-01-01' AND '2023-12-31' AND Company_Country IN ('Brazil', 'Argentina', 'Chile', 'Colombia', 'Peru', 'Uruguay', 'Bolivia') GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE RetailerB (item VARCHAR(20), quantity INT); INSERT INTO RetailerB VALUES ('Tops', 300);
Which retailer sold the most 'Tops'?
SELECT item, MAX(quantity) FROM RetailerB WHERE item = 'Tops';
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityVulnerabilities (ID INT, Country VARCHAR(50), Year INT, Vulnerabilities INT); INSERT INTO CybersecurityVulnerabilities (ID, Country, Year, Vulnerabilities) VALUES (1, 'Country1', 2019, 100); INSERT INTO CybersecurityVulnerabilities (ID, Country, Year, Vulnerabilities) VALUES (2, 'Country2', 2020, 150); INSERT INTO CybersecurityVulnerabilities (ID, Country, Year, Vulnerabilities) VALUES (3, 'Country3', 2019, 120);
What is the total number of cybersecurity vulnerabilities found in 'Middle East' and 'Oceania' in 2019 and 2020?
SELECT Country, SUM(Vulnerabilities) as TotalVulnerabilities FROM CybersecurityVulnerabilities WHERE Country IN ('Middle East', 'Oceania') AND Year IN (2019, 2020) GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (region varchar(255), level decimal(10,2)); INSERT INTO ocean_acidity (region, level) VALUES ('Atlantic', 8.10), ('Pacific', 7.90), ('Indian', 8.05);
What is the maximum ocean acidity level in the Atlantic region?
SELECT MAX(level) FROM ocean_acidity WHERE region = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (ID INT, Name VARCHAR(255), Missions VARCHAR(255)); CREATE TABLE Missions (ID INT, Destination VARCHAR(255)); INSERT INTO Astronauts (ID, Name, Missions) VALUES (1, 'Astronaut1', 'Mars,Moon'), (2, 'Astronaut2', 'Mars'), (3, 'Astronaut3', 'Moon'); INSERT INTO Missions (ID, Destination) VALUES (1, 'Mars'), (2, 'Mars'), (3, 'Moon'), (4, 'Mars');
Which astronauts have never flown a mission to Mars?
SELECT Astronauts.Name FROM Astronauts LEFT JOIN Missions ON Astronauts.Missions = Missions.Destination WHERE Destination IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255), city VARCHAR(100)); INSERT INTO teams (team_id, team_name, city) VALUES (1, 'Golden State Warriors', 'San Francisco'), (2, 'New York Knicks', 'New York'); CREATE TABLE game_attendance (game_id INT, team_id INT, num_fans INT); INSERT INTO game_attendance (game_id, team_id, num_fans) VALUES (1, 1, 15000), (2, 1, 20000), (3, 2, 10000), (4, 2, 25000), (5, 2, 30000);
What is the total number of fans who attended games in 'New York'?
SELECT SUM(ga.num_fans) as total_fans_attended FROM game_attendance ga WHERE ga.team_id IN (SELECT t.team_id FROM teams t WHERE t.city = 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityDevelopmentPrograms (id INT, country VARCHAR(50), program_name VARCHAR(100), budget FLOAT); INSERT INTO CommunityDevelopmentPrograms (id, country, program_name, budget) VALUES (1, 'India', 'Rural Education', 25000.0), (2, 'Brazil', 'Clean Water Initiative', 30000.0);
What was the combined budget for community development programs in India and Brazil in 2018?'
SELECT SUM(budget) FROM CommunityDevelopmentPrograms WHERE country IN ('India', 'Brazil') AND YEAR(start_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount FLOAT); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2022-01-01', 75.00), (2, 2, '2022-02-14', 125.00);
What is the total donation amount per month in 2022?
SELECT DATE_FORMAT(DonationDate, '%Y-%m') AS Month, SUM(DonationAmount) AS TotalDonation FROM Donations WHERE YEAR(DonationDate) = 2022 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Players VALUES (1, 25, 'Male'); INSERT INTO Players VALUES (2, 22, 'Female'); CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventName VARCHAR(20)); INSERT INTO EsportsEvents VALUES (1, 1, 'Dreamhack'); INSERT INTO EsportsEvents VALUES (2, 2, 'ESL One'); CREATE TABLE VRGameSessions (SessionID INT, PlayerID INT, VRGameCount INT); INSERT INTO VRGameSessions VALUES (1, 1, 5); INSERT INTO VRGameSessions VALUES (2, 2, 3);
What is the average age of players who have participated in esports events, and the number of VR games they have played?
SELECT AVG(Players.Age), AVG(VRGameSessions.VRGameCount) FROM Players INNER JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID INNER JOIN VRGameSessions ON Players.PlayerID = VRGameSessions.PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE professionals (name TEXT, title TEXT, location TEXT); INSERT INTO professionals (name, title, location) VALUES ('Dr. Smith', 'Doctor', 'Rural Mexico'), ('Nurse Johnson', 'Nurse', 'Rural Mexico'); CREATE TABLE facilities (name TEXT, location TEXT); INSERT INTO facilities (name, location) VALUES ('Facility X', 'Rural Mexico'), ('Facility Y', 'Rural Mexico');
List the names of healthcare professionals who work in rural areas of Mexico and the facilities they work for.
SELECT professionals.name, facilities.name FROM professionals INNER JOIN facilities ON professionals.location = facilities.location WHERE professionals.location = 'Rural Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE expedition (org VARCHAR(20), depth INT); INSERT INTO expedition VALUES ('Ocean Explorer', 2500), ('Ocean Explorer', 3000), ('Sea Discoverers', 2000), ('Marine Investigators', 4000), ('Marine Investigators', 4500), ('Deep Sea Divers', 7000), ('Deep Sea Divers', 6500), ('Abyssal Pioneers', 5000), ('Abyssal Pioneers', 5500);
List the top 3 organizations with the highest average expedition depth, along with their average depths.
SELECT org, AVG(depth) AS avg_depth FROM expedition GROUP BY org ORDER BY avg_depth DESC LIMIT 3;
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', 'Europe');INSERT INTO investments (investment_id, client_id, market, value) VALUES (1, 1, 'US', 50000), (2, 2, 'Europe', 120000);
What is the total investment value in the European market for clients with a last name starting with 'B'?
SELECT SUM(i.value) FROM clients c INNER JOIN investments i ON c.client_id = i.client_id WHERE SUBSTRING(c.name, 1, 1) = 'B' AND i.market = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (year INT, element TEXT, production_quantity FLOAT); INSERT INTO production_data (year, element, production_quantity) VALUES (2015, 'Gadolinium', 450); INSERT INTO production_data (year, element, production_quantity) VALUES (2016, 'Gadolinium', 500); INSERT INTO production_data (year, element, production_quantity) VALUES (2017, 'Gadolinium', 550);
Find the total production quantity (in metric tons) of Gadolinium for the years 2015 and 2016.
SELECT SUM(production_quantity) FROM production_data WHERE element = 'Gadolinium' AND year IN (2015, 2016);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, type TEXT); INSERT INTO hotels (hotel_id, hotel_name, city, type) VALUES (1, 'Hotel A', 'London', 'Luxury'), (2, 'Hotel B', 'London', 'Budget'), (3, 'Hotel C', 'London', 'Boutique'); CREATE TABLE energy_consumption (hotel_id INT, consumption FLOAT); INSERT INTO energy_consumption (hotel_id, consumption) VALUES (1, 1500), (2, 1200), (3, 1000);
What is the distribution of hotel energy consumption in London by type?
SELECT type, AVG(consumption) FROM hotels INNER JOIN energy_consumption ON hotels.hotel_id = energy_consumption.hotel_id WHERE city = 'London' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE fleets (fleet_id INT, fleet_name VARCHAR(50), cargo_handling_time INT); INSERT INTO fleets (fleet_id, fleet_name, cargo_handling_time) VALUES (1, 'FleetA', 500), (2, 'FleetB', 750), (3, 'FleetC', 600);
What is the total cargo handling time for each fleet?
SELECT fleet_name, SUM(cargo_handling_time) FROM fleets GROUP BY fleet_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, depth FLOAT, country TEXT); INSERT INTO marine_protected_areas (name, depth, country) VALUES ('Galapagos Islands', 3500.0, 'Ecuador'), ('Socorro Island', 3050.0, 'Mexico'), ('Mariana Trench', 10994.0, 'USA');
How many countries have marine protected areas deeper than 3000 meters?
SELECT COUNT(DISTINCT country) FROM marine_protected_areas WHERE depth > 3000;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteer (VolunteerID int, VolunteerName varchar(50), Country varchar(50)); CREATE TABLE VolunteerProgram (ProgramID int, VolunteerID int, ProgramLocation varchar(50));
List all volunteers who have participated in programs in Africa?
SELECT VolunteerName FROM Volunteer JOIN VolunteerProgram ON Volunteer.VolunteerID = VolunteerProgram.VolunteerID WHERE Country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE SCHEMA AI_Safety;CREATE TABLE Algorithms (algo_id INT, complexity_score INT, accuracy_score FLOAT); INSERT INTO AI_Safety.Algorithms (algo_id, complexity_score, accuracy_score) VALUES (1, 6, 0.95), (2, 4, 0.9), (3, 7, 0.8);
Calculate the percentage of algorithms with a complexity score under 4 in the 'AI_Safety' schema.
SELECT (COUNT(*) FILTER (WHERE complexity_score < 4)) * 100.0 / COUNT(*) FROM AI_Safety.Algorithms;
gretelai_synthetic_text_to_sql
CREATE TABLE AssetAllocation (AssetAllocationID INT, AssetID INT, AssetName VARCHAR(100), AllocationType VARCHAR(50), AllocationValue FLOAT); INSERT INTO AssetAllocation (AssetAllocationID, AssetID, AssetName, AllocationType, AllocationValue) VALUES (1, 1, 'Asset1', 'Security', 0.7), (2, 1, 'Asset1', 'Commodity', 0.3), (3, 2, 'Asset2', 'Security', 0.5), (4, 2, 'Asset2', 'Currency', 0.5); ALTER TABLE AssetAllocation ADD COLUMN AssetID INT;
What is the distribution of digital assets by type, for companies based in South America?
SELECT AssetType, SUM(AllocationValue) as TotalValue FROM AssetAllocation INNER JOIN DigitalAsset ON AssetAllocation.AssetID = DigitalAsset.AssetID WHERE IssuerLocation = 'South America' GROUP BY AssetType;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (project VARCHAR(50), country VARCHAR(50), amount FLOAT, impact INT, date DATE); INSERT INTO climate_finance (project, country, amount, impact, date) VALUES ('Green City', 'USA', 5000000, 1, '2020-01-01'); INSERT INTO climate_finance (project, country, amount, impact, date) VALUES ('Clean Energy', 'India', 3000000, -1, '2020-01-01');
Delete all climate finance projects that do not have a positive impact on climate adaptation.
DELETE FROM climate_finance WHERE impact < 0;
gretelai_synthetic_text_to_sql
CREATE TABLE theatre_2 (event VARCHAR(255), date DATE, revenue FLOAT); INSERT INTO theatre_2 (event, date, revenue) VALUES ('Comedy Night', '2021-02-01', 2500), ('Comedy Night', '2021-02-02', 3000), ('Drama Night', '2021-02-01', 1800);
What was the total revenue from ticket sales for the "Comedy Night" event?
SELECT SUM(revenue) FROM theatre_2 WHERE event = 'Comedy Night';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareFacilities (ID INT, Name TEXT, ZipCode TEXT, City TEXT, State TEXT, Capacity INT); INSERT INTO HealthcareFacilities (ID, Name, ZipCode, City, State, Capacity) VALUES (1, 'General Hospital', '12345', 'Anytown', 'NY', 500), (2, 'Community Clinic', '67890', 'Othertown', 'NY', 100);
find the number of healthcare facilities and the number of unique ZIP codes in the HealthcareFacilities table, using an INTERSECT operator
SELECT COUNT(*) FROM HealthcareFacilities INTERSECT SELECT COUNT(DISTINCT ZipCode) FROM HealthcareFacilities;
gretelai_synthetic_text_to_sql
CREATE TABLE mine_operators (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), gender VARCHAR(10), years_of_experience INT); INSERT INTO mine_operators (id, name, role, gender, years_of_experience) VALUES (1, 'John Doe', 'Mining Engineer', 'Male', 7), (2, 'Maria', 'Environmental Engineer', 'Female', 5);
List the names, roles, and years of experience of mining engineers with the role 'Mining Engineer'.
SELECT name, role, years_of_experience FROM mine_operators WHERE role = 'Mining Engineer';
gretelai_synthetic_text_to_sql
CREATE TABLE site (site_id INT, site_name TEXT); CREATE TABLE co2_emission (emission_id INT, site_id INT, co2_emission_kg FLOAT); INSERT INTO site (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'); INSERT INTO co2_emission (emission_id, site_id, co2_emission_kg) VALUES (1, 1, 500), (2, 1, 600), (3, 2, 300), (4, 2, 400);
What is the average CO2 emission per site?
SELECT e.site_id, AVG(e.co2_emission_kg) as avg_co2_emission FROM co2_emission e GROUP BY e.site_id;
gretelai_synthetic_text_to_sql