context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE EmployeeTraining (TrainingID INT, EmployeeID INT, TrainingName VARCHAR(50), TrainingCost DECIMAL(10,2), TrainingDate DATE); CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), HireDate DATE);
What is the average training cost per employee in the Sales department?
SELECT AVG(TrainingCost) as AvgTrainingCost FROM EmployeeTraining INNER JOIN Employees ON EmployeeTraining.EmployeeID = Employees.EmployeeID WHERE Department = 'Sales';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 800.00, '2022-10-01'); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (2, 2, 900.00, '2022-07-30'); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (3, 3, 700.00, '2022-09-15');
Which donor made the largest donation in Q3 2022?
SELECT donor_id, MAX(donation_amount) FROM donations WHERE QUARTER(donation_date) = 3 AND YEAR(donation_date) = 2022 GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Programs (Program_ID INT, CO2_Emission_Reduction FLOAT, Program_Start_Date DATE); INSERT INTO Carbon_Offset_Programs (Program_ID, CO2_Emission_Reduction, Program_Start_Date) VALUES (1, 5000.0, '2020-01-01'), (2, 7000.0, '2020-01-15'), (3, 3000.0, '2019-12-01');
What is the total CO2 emission reduction for each carbon offset program in the past year?
SELECT Program_ID, CO2_Emission_Reduction FROM Carbon_Offset_Programs WHERE Program_Start_Date >= DATEADD(YEAR, -1, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE VendorIngredients (id INT, vendor_id INT, name VARCHAR(255), carbon_footprint INT);
Which vendors have the highest and lowest average carbon footprint for their ingredients?
SELECT vendor_id, MAX(carbon_footprint) AS max_carbon_footprint, MIN(carbon_footprint) AS min_carbon_footprint FROM VendorIngredients GROUP BY vendor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID int, SupplierName varchar(50), Region varchar(50)); INSERT INTO Suppliers VALUES (1, 'SupplierA', 'Northeast'), (2, 'SupplierB', 'Southeast'); CREATE TABLE Sales (SaleID int, SupplierID int, TimberVolume float, SaleYear int); INSERT INTO Sales VALUES (1, 1, 500, 2020), (2, 1, 700, 2019), (3, 2, 600, 2020);
What is the total volume of timber sold by each supplier in a specific year, grouped by region?
SELECT Suppliers.Region, Sales.SaleYear, SUM(Sales.TimberVolume) as TotalTimberVolume FROM Suppliers INNER JOIN Sales ON Suppliers.SupplierID = Sales.SupplierID GROUP BY Suppliers.Region, Sales.SaleYear;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT);CREATE TABLE inspections (id INT, vessel_id INT, date DATE);CREATE TABLE cargos (id INT, vessel_id INT, material TEXT, destination TEXT, date DATE); INSERT INTO vessels (id, name, type) VALUES (1, 'VesselE', 'Livestock'); INSERT INTO inspections (id, vessel_id, date) VALUES (1, 1, '2020-01-01'); INSERT INTO cargos (id, vessel_id, material, destination, date) VALUES (1, 1, 'Livestock', 'Indian', '2020-01-01');
What is the average time between inspections for vessels that transported livestock in the Indian Ocean in 2020?
SELECT AVG(DATEDIFF(i2.date, i1.date)) FROM inspections i1 JOIN inspections i2 ON i1.vessel_id = i2.vessel_id AND i1.date < i2.date JOIN cargos c ON i1.vessel_id = c.vessel_id WHERE c.material = 'Livestock' AND c.destination = 'Indian' AND i1.date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY i1.vessel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_table (chemical_id INT, chemical_name VARCHAR(50), safety_rating INT); CREATE TABLE environmental_impact_table (record_id INT, chemical_id INT, environmental_impact_float);
Show the names and environmental impact of all chemicals in the chemical_table and environmental_impact_table
SELECT t1.chemical_name, t2.environmental_impact_float FROM chemical_table t1 INNER JOIN environmental_impact_table t2 ON t1.chemical_id = t2.chemical_id;
gretelai_synthetic_text_to_sql
CREATE TABLE court_cases (case_id INT, victim_name TEXT, case_state TEXT, case_status TEXT); INSERT INTO court_cases (case_id, victim_name, case_state, case_status) VALUES (88888, 'Jamie Lee', 'New York', 'Resolved');
Who are the victims of all cases that have been resolved in the state of New York?
SELECT victim_name FROM court_cases WHERE case_state = 'New York' AND case_status = 'Resolved';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID INT, RestaurantName VARCHAR(255), City VARCHAR(255), State VARCHAR(255), DailyRevenue DECIMAL(10,2), Date DATE);
What is the average daily revenue for restaurants in California, ordered by daily revenue?
SELECT State, AVG(DailyRevenue) OVER (PARTITION BY State ORDER BY State) as AvgDailyRevenue, Date FROM Restaurants WHERE State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name VARCHAR(50), race VARCHAR(50), graduation_date DATE); CREATE TABLE papers (paper_id INT, student_id INT, publication_date DATE);
How many research papers have been published by graduate students from underrepresented racial and ethnic groups in the past 5 years?
SELECT COUNT(p.paper_id) FROM students s INNER JOIN papers p ON s.student_id = p.student_id WHERE s.graduation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND s.race IN ('Black', 'Hispanic', 'Native American');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence_sources (source VARCHAR(50), ioc_count INT); INSERT INTO threat_intelligence_sources (source, ioc_count) VALUES ('Source A', 250), ('Source B', 220), ('Source C', 190), ('Source D', 160), ('Source E', 140), ('Source F', 120);
Identify the top 5 threat intelligence sources with the most number of unique indicators of compromise (IOCs) in the last 6 months.
SELECT source, ioc_count FROM threat_intelligence_sources WHERE ioc_date >= DATEADD(month, -6, GETDATE()) GROUP BY source ORDER BY SUM(ioc_count) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, user_id INT, program VARCHAR(50), hours DECIMAL(10, 2), volunteer_date DATE); INSERT INTO Volunteers (id, user_id, program, hours, volunteer_date) VALUES (1, 201, 'program A', 3.00, '2021-02-01'); INSERT INTO Volunteers (id, user_id, program, hours, volunteer_date) VALUES (2, 202, 'program B', 2.50, '2021-03-05');
Who volunteered the most hours in program B in 2022?
SELECT user_id, SUM(hours) FROM Volunteers WHERE program = 'program B' AND volunteer_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY user_id ORDER BY SUM(hours) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams VALUES (1, 'TeamA'), (2, 'TeamB'); CREATE TABLE games (game_id INT, team_id INT, home_attendance INT, season INT); INSERT INTO games VALUES (1, 1, 45000, 2022), (2, 1, 50000, 2022), (3, 2, 38000, 2022), (4, 2, 42000, 2022);
What is the average home game attendance for each team in the 2022 season?
SELECT t.team_name, AVG(g.home_attendance) AS avg_attendance FROM teams t JOIN games g ON t.team_id = g.team_id WHERE g.season = 2022 GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vendor_vulnerabilities (id INT, vendor TEXT, domain TEXT, vulnerability_id INT, date_discovered DATE); INSERT INTO vendor_vulnerabilities (id, vendor, domain, vulnerability_id, date_discovered) VALUES (1, 'Tech Co', 'Network Security', 1, '2022-07-27'); INSERT INTO vendor_vulnerabilities (id, vendor, domain, vulnerability_id, date_discovered) VALUES (2, 'Data Inc', 'Endpoint Security', 2, '2022-07-28'); INSERT INTO vendor_vulnerabilities (id, vendor, domain, vulnerability_id, date_discovered) VALUES (3, 'SecureNet', 'Cloud Security', 3, '2022-07-29'); INSERT INTO vendor_vulnerabilities (id, vendor, domain, vulnerability_id, date_discovered) VALUES (4, 'AppSecure', 'Application Security', 4, '2022-07-30'); INSERT INTO vendor_vulnerabilities (id, vendor, domain, vulnerability_id, date_discovered) VALUES (5, 'AccessGuard', 'Identity and Access Management', 5, '2022-07-31');
What is the total number of vulnerabilities found in the last month for vendors located in Southeast Asia?
SELECT COUNT(*) as count FROM vendor_vulnerabilities WHERE date_discovered >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND vendor IN ('Tech Co', 'Data Inc', 'SecureNet', 'AppSecure', 'AccessGuard') AND vendor LIKE '% Southeast Asia%';
gretelai_synthetic_text_to_sql
CREATE TABLE VesselData (VesselID INT, VesselName VARCHAR(50), Type VARCHAR(50), Length INT, EnginePower INT); INSERT INTO VesselData (VesselID, VesselName, Type, Length, EnginePower) VALUES (1, 'SeaQueen', 'Cargo', 150, 5000); CREATE TABLE IncidentData (IncidentID INT, IncidentType VARCHAR(50), IncidentDate DATE, VesselID INT, Location VARCHAR(50)); INSERT INTO IncidentData (IncidentID, IncidentType, IncidentDate, VesselID, Location) VALUES (1, 'Collision', '2021-01-01', 1, 'Mediterranean Sea');
What is the maximum engine power of sailboats that were involved in an incident in the Mediterranean Sea?
SELECT MAX(v.EnginePower) FROM VesselData v INNER JOIN IncidentData i ON v.VesselID = i.VesselID WHERE v.Type = 'Sailboat' AND i.Location = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (organization_id INT, organization_name TEXT, region TEXT); INSERT INTO organizations (organization_id, organization_name, region) VALUES (1, 'Access Ability Africa', 'Africa'), (2, 'Equality Empowerment', 'Asia'); CREATE TABLE policy_advocacy_campaigns (campaign_id INT, organization_id INT, campaign_name TEXT, number_of_people_served INT); INSERT INTO policy_advocacy_campaigns (campaign_id, organization_id, campaign_name, number_of_people_served) VALUES (1, 1, 'Equal Opportunities for All', 700), (2, 1, 'Breaking Barriers', 300), (3, 2, 'Empowerment Tour', 1000);
List all policy advocacy campaigns led by organizations in the African region that have served more than 500 people.
SELECT organization_name FROM organizations o JOIN policy_advocacy_campaigns pc ON o.organization_id = pc.organization_id WHERE region = 'Africa' AND number_of_people_served > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(50), region VARCHAR(20), avg_depth FLOAT, has_coral_reef BOOLEAN); INSERT INTO marine_protected_areas (name, region, avg_depth, has_coral_reef) VALUES ('Area A', 'Pacific', 1200.5, true), ('Area B', 'Pacific', 1500.2, false), ('Area C', 'Atlantic', 1800.9, true);
What is the minimum depth of all marine protected areas in the 'Pacific' region with a coral reef?'
SELECT MIN(avg_depth) FROM marine_protected_areas WHERE region = 'Pacific' AND has_coral_reef = true;
gretelai_synthetic_text_to_sql
CREATE TABLE military_diplomacy (id INT, country VARCHAR(255), year INT, event_name VARCHAR(255)); INSERT INTO military_diplomacy (id, country, year, event_name) VALUES (1, 'Egypt', 2019, 'Russian-Egyptian Military Cooperation Commission');
What is the number of military diplomacy events held by Russia with African countries in 2019?
SELECT COUNT(*) FROM military_diplomacy WHERE country LIKE 'Africa%' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(255)); INSERT INTO Artists (ArtistID, ArtistName) VALUES (1, 'Artist1'), (2, 'Artist2'), (3, 'Artist3'), (4, 'Artist4'), (5, 'Artist5'); CREATE TABLE Concerts (ConcertID INT, ArtistID INT, Venue VARCHAR(255)); INSERT INTO Concerts (ConcertID, ArtistID, Venue) VALUES (1, 1, 'Venue1'), (2, 2, 'Venue2'), (3, 3, 'Venue3'), (4, 4, 'Venue4'), (5, 5, 'Venue5'), (6, 1, 'Venue6'), (7, 2, 'Venue7'), (8, 3, 'Venue8');
List all artists who have never had a concert in the United States.
SELECT DISTINCT A.ArtistName FROM Artists A LEFT JOIN Concerts C ON A.ArtistID = C.ArtistID WHERE C.Venue NOT LIKE '%United States%';
gretelai_synthetic_text_to_sql
CREATE TABLE operational_satellites_mass (id INT, name VARCHAR(255), mass FLOAT); INSERT INTO operational_satellites_mass (id, name, mass) VALUES (1, 'Operational Satellite 1', 1500.0), (2, 'Operational Satellite 2', 500.0), (3, 'Operational Satellite 3', 2000.0);
What is the minimum and maximum mass of operational satellites?
SELECT MIN(mass) AS minimum_mass, MAX(mass) AS maximum_mass FROM operational_satellites_mass WHERE status = 'Operational';
gretelai_synthetic_text_to_sql
CREATE TABLE public_health_policies (id INT, name TEXT, description TEXT, created_at TIMESTAMP);
Insert a new public health policy record for 'Tobacco Control Act' created at '2000-01-01 00:00:00'.
INSERT INTO public_health_policies (name, created_at) VALUES ('Tobacco Control Act', '2000-01-01 00:00:00');
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensor_development;CREATE TABLE if not exists biosensor_development.sensors (id INT, name VARCHAR(100), continent VARCHAR(50));INSERT INTO biosensor_development.sensors (id, name, continent) VALUES (1, 'TypeA', 'Europe'), (2, 'TypeB', 'South America'), (3, 'TypeA', 'Africa'), (4, 'TypeC', 'Asia');
How many biosensor types are being developed in each continent?
SELECT continent, COUNT(*) FROM biosensor_development.sensors GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT, name VARCHAR(255), mental_health_program BOOLEAN); INSERT INTO schools (id, name, mental_health_program) VALUES (1, 'School A', true), (2, 'School B', false), (3, 'School C', true);
Which schools have a mental health program?
SELECT name FROM schools WHERE mental_health_program = true;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, user_id INT, amount DECIMAL(10,2), transaction_time TIMESTAMP);
What is the transaction count per day for the last week?
SELECT DATE(transaction_time) as transaction_date, COUNT(*) as transaction_count FROM transactions WHERE transaction_time > DATEADD(week, -1, GETDATE()) GROUP BY transaction_date;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, attorney_id INT, outcome TEXT, billing_amount INT); INSERT INTO cases (id, attorney_id, outcome, billing_amount) VALUES (1, 1, 'Favorable', 10000); CREATE TABLE attorneys (id INT, name TEXT, region TEXT, title TEXT); INSERT INTO attorneys (id, name, region, title) VALUES (1, 'Jim Smith', 'California', 'Associate');
What is the total billing amount for cases with a favorable outcome in the 'California' region?
SELECT SUM(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.region = 'California' AND cases.outcome = 'Favorable';
gretelai_synthetic_text_to_sql
CREATE TABLE archaeological_sites (site_id INT, name VARCHAR(50), ocean VARCHAR(20));
Which underwater archaeological sites are located in the Mediterranean?
SELECT name FROM archaeological_sites WHERE ocean = 'Mediterranean';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), year INT);
Delete records of peacekeeping operations led by a specific country.
DELETE FROM peacekeeping_operations WHERE country = 'France' AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE researchers (id INT, name VARCHAR(50), project VARCHAR(50)); INSERT INTO researchers (id, name, project) VALUES (1, 'Alice', 'gene sequencing'), (2, 'Bob', 'biosensor development'), (3, 'Charlie', 'gene sequencing');
Update the 'project' of the researcher with id '2' to 'synthetic biology' in the 'researchers' table.
UPDATE researchers SET project = 'synthetic biology' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, state VARCHAR(20)); INSERT INTO mobile_customers (customer_id, data_usage, state) VALUES (1, 3.5, 'New York'), (2, 6.2, 'New York');
What is the maximum data usage by a mobile customer in the state of New York?
SELECT MAX(data_usage) FROM mobile_customers WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE GraduatePrograms(ProgramID INT, ProgramName VARCHAR(50), Enrollment INT); INSERT INTO GraduatePrograms (ProgramID, ProgramName, Enrollment) VALUES (1, 'Physics', 25), (2, 'Mathematics', 30);
How many students are enrolled in each graduate program, ranked by the number of students?
SELECT ProgramName, ROW_NUMBER() OVER(ORDER BY Enrollment DESC) AS Rank, Enrollment FROM GraduatePrograms;
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS community_education (program_id INT, program_name VARCHAR(50), donation_count INT); INSERT INTO community_education (program_id, program_name, donation_count) VALUES (1, 'Wildlife Conservation 101', 500); INSERT INTO community_education (program_id, program_name, donation_count) VALUES (2, 'Endangered Species Awareness', 300); INSERT INTO community_education (program_id, program_name, donation_count) VALUES (3, 'Habitat Protection Techniques', 0);
List the community education programs that have not received any donations.
SELECT program_name FROM community_education WHERE donation_count = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE social_impact_bonds (id INT, investment DECIMAL(10,2), country VARCHAR(50)); INSERT INTO social_impact_bonds (id, investment, country) VALUES (1, 15000, 'Africa'), (2, 20000, 'North America'), (3, 10000, 'Africa');
What is the maximum investment in social impact bonds in Africa?
SELECT MAX(investment) FROM social_impact_bonds WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE treatments (treatment_id INT, year INT, cost DECIMAL(10,2), condition VARCHAR(30)); INSERT INTO treatments (treatment_id, year, cost, condition) VALUES (1, 2021, 500.00, 'Anxiety'), (2, 2022, 600.00, 'Depression'), (3, 2021, 700.00, 'Anxiety');
What is the total cost of all mental health conditions treated in 2021?
SELECT SUM(cost) FROM treatments WHERE year = 2021 GROUP BY condition;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_pricing (id INT PRIMARY KEY, attraction_id INT, price FLOAT);
Insert new virtual tour pricing into 'virtual_tour_pricing' table
INSERT INTO virtual_tour_pricing (id, attraction_id, price) VALUES (1, 1, 19.99);
gretelai_synthetic_text_to_sql
CREATE TABLE advocacy (campaign_id INT, campaign_name VARCHAR(255), country VARCHAR(255), campaign_start_date DATE, campaign_end_date DATE); INSERT INTO advocacy (campaign_id, campaign_name, country, campaign_start_date, campaign_end_date) VALUES (1, 'Campaign1', 'Mexico', '2019-01-01', '2019-04-30'), (2, 'Campaign2', 'Mexico', '2019-10-01', '2019-12-31');
How many advocacy campaigns were conducted in Mexico in 2019?
SELECT COUNT(*) FROM advocacy WHERE country = 'Mexico' AND YEAR(campaign_start_date) = 2019 AND YEAR(campaign_end_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Location) VALUES (1, 'Supplier A', 'Northeast'), (2, 'Supplier B', 'Southeast'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, IsMeat BOOLEAN); INSERT INTO Products (ProductID, ProductName, SupplierID, IsMeat) VALUES (1, 'Beef', 1, true), (2, 'Chicken', 1, true), (3, 'Tofu', 2, false); CREATE TABLE Sales (SaleID INT, ProductID INT, Quantity INT); INSERT INTO Sales (SaleID, ProductID, Quantity) VALUES (1, 1, 10), (2, 2, 15), (3, 3, 8);
What is the total quantity of meat products sold in the Southeast region?
SELECT SUM(Quantity) FROM Sales JOIN Products ON Sales.ProductID = Products.ProductID JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE IsMeat = true AND Suppliers.Location = 'Southeast';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT, name VARCHAR(50), start_stop_id INT, end_stop_id INT); INSERT INTO routes (id, name, start_stop_id, end_stop_id) VALUES (1, 'Broadway Line', 1, 20); CREATE TABLE trips (id INT, start_time TIMESTAMP, end_time TIMESTAMP, passenger_count INT, stop_id INT); INSERT INTO trips (id, start_time, end_time, passenger_count, stop_id) VALUES (10, '2022-01-10 07:00:00', '2022-01-10 07:59:59', 125, 1);
How many passengers used the 'Broadway Line' during rush hour on January 10, 2022?
SELECT SUM(t.passenger_count) FROM trips t INNER JOIN routes r ON t.stop_id = r.start_stop_id WHERE r.name = 'Broadway Line' AND TIME(t.start_time) BETWEEN '07:00:00' AND '07:59:59';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, industry VARCHAR(50), region VARCHAR(50), fair_trade BOOLEAN);
How many factories in the electronics industry are compliant with fair trade practices in Asia?
SELECT COUNT(*) FROM factories WHERE industry = 'electronics' AND region = 'Asia' AND fair_trade = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name VARCHAR(20)); INSERT INTO ports (id, name) VALUES (1, 'Toronto'), (2, 'Montreal'); CREATE TABLE containers (id INT, weight INT, port_id INT); INSERT INTO containers (id, weight, port_id) VALUES (1, 500, 1), (2, 1000, 1), (3, 2000, 2), (4, 2500, 2);
What is the minimum weight of a container handled by port 'Toronto'?
SELECT MIN(weight) FROM containers WHERE port_id = (SELECT id FROM ports WHERE name = 'Toronto');
gretelai_synthetic_text_to_sql
CREATE TABLE ForestPlots (PlotID int, PlotName varchar(50)); INSERT INTO ForestPlots VALUES (1, 'Plot1'), (2, 'Plot2'); CREATE TABLE Trees (TreeID int, TreeSpecies varchar(50), PlotID int); INSERT INTO Trees VALUES (1, 'Oak', 1), (2, 'Maple', 1), (3, 'Pine', 2); CREATE TABLE CarbonSequestration (PlotID int, Sequestration float); INSERT INTO CarbonSequestration VALUES (1, 500), (2, 600);
Which tree species are present in each forest plot, including the carbon sequestration for each plot?
SELECT ForestPlots.PlotName, Trees.TreeSpecies, CarbonSequestration.Sequestration FROM ForestPlots INNER JOIN Trees ON ForestPlots.PlotID = Trees.PlotID INNER JOIN CarbonSequestration ON ForestPlots.PlotID = CarbonSequestration.PlotID;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(20), total_spent DECIMAL(5,2)); INSERT INTO customers (customer_id, name, total_spent) VALUES (1, 'Amina', 150.00), (2, 'Babatunde', 200.00), (3, 'Chen', 300.00), (4, 'Dalia', 50.00), (5, 'Elias', 400.00); CREATE TABLE sales (sale_id INT, customer_id INT, product_id INT, sale_amount DECIMAL(5,2)); INSERT INTO sales (sale_id, customer_id, product_id, sale_amount) VALUES (1, 1, 1, 25.99), (2, 2, 2, 19.99), (3, 3, 3, 39.99), (4, 1, 4, 35.99); CREATE TABLE products (product_id INT, material VARCHAR(20), is_sustainable BOOLEAN); INSERT INTO products (product_id, material, is_sustainable) VALUES (1, 'organic cotton', TRUE), (2, 'conventional cotton', FALSE), (3, 'hemp', TRUE), (4, 'recycled polyester', TRUE);
Who are the top 5 customers by spending on sustainable materials?
SELECT customers.name, SUM(sales.sale_amount) AS total_spent FROM customers JOIN sales ON customers.customer_id = sales.customer_id JOIN products ON sales.product_id = products.product_id WHERE products.is_sustainable = TRUE GROUP BY customers.name ORDER BY total_spent DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmMetrics (farm_type VARCHAR(10), temperature FLOAT, humidity FLOAT); INSERT INTO FarmMetrics (farm_type, temperature, humidity) VALUES ('Organic', 22.6, 68.3), ('Organic', 21.4, 70.1), ('Organic', 23.9, 65.7), ('Conventional', 24.5, 63.2), ('Conventional', 25.6, 61.8), ('Conventional', 23.1, 64.9);
Find the difference in average temperature and humidity between organic and conventional farms.
SELECT AVG(temperature) - (SELECT AVG(temperature) FROM FarmMetrics WHERE farm_type = 'Conventional') as temp_diff, AVG(humidity) - (SELECT AVG(humidity) FROM FarmMetrics WHERE farm_type = 'Conventional') as humidity_diff FROM FarmMetrics WHERE farm_type = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (id INT PRIMARY KEY, mine_id INT, year INT, monthly_production INT);CREATE TABLE reclamation_data (id INT PRIMARY KEY, mine_id INT, year INT, reclamation_cost INT);CREATE TABLE mine_employees (id INT PRIMARY KEY, mine_id INT, employee_id INT, employment_start_date DATE, employment_end_date DATE);CREATE TABLE employee_demographics (id INT PRIMARY KEY, employee_id INT, gender VARCHAR(255), ethnicity VARCHAR(255));CREATE VIEW employee_stats AS SELECT mine_id, COUNT(employee_id) as employee_count, AVG(DATEDIFF(employment_end_date, employment_start_date))/365 as avg_tenure FROM mine_employees GROUP BY mine_id;CREATE VIEW operation_duration AS SELECT mine_id, COUNT(DISTINCT year) as operation_years FROM production_data GROUP BY mine_id;
Identify the number of employees, average tenure, and mines with more than 10 years of operation for mines in the African continent.
SELECT e.mine_id, e.employee_count, e.avg_tenure, o.operation_years FROM employee_stats e JOIN operation_duration o ON e.mine_id = o.mine_id WHERE o.operation_years > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE StdPlayerScores (player_id INT, game_id INT, player_score INT); INSERT INTO StdPlayerScores (player_id, game_id, player_score) VALUES (1, 1, 1500), (2, 1, 1800), (3, 2, 2000), (4, 2, 1900), (5, 3, 1200), (6, 3, 1600);
What is the standard deviation of player scores for each game?
SELECT G.game_name, STDDEV(SPS.player_score) as std_deviation FROM StdPlayerScores SPS JOIN Games G ON SPS.game_id = G.game_id GROUP BY G.game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales(ticket_id INT, game_id INT, sport VARCHAR(20), tickets_sold INT);
Determine the percentage of ticket sales from each sport in the total ticket sales.
SELECT sport, 100.0 * SUM(tickets_sold) / (SELECT SUM(tickets_sold) FROM ticket_sales) AS percentage FROM ticket_sales GROUP BY sport;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (menu_id INT, inventory_quantity INT); CREATE TABLE orders_summary (order_id INT, menu_id INT, quantity INT); INSERT INTO inventory (menu_id, inventory_quantity) VALUES (1, 10), (2, 0), (3, 5); INSERT INTO orders_summary (order_id, menu_id, quantity) VALUES (1, 1, 2), (2, 3, 1);
List menu items with zero orders but available inventory.
SELECT m.menu_name FROM inventory i JOIN menus m ON i.menu_id = m.menu_id LEFT JOIN orders_summary os ON m.menu_id = os.menu_id WHERE i.inventory_quantity > 0 AND os.menu_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_name TEXT, revenue FLOAT, quarter INT, year INT); INSERT INTO sales (drug_name, revenue, quarter, year) VALUES ('JKL-012', 45000.00, 4, 2022), ('MNO-345', 55000.00, 4, 2022), ('GHI-999', 40000.00, 4, 2022);
What was the total sales revenue of drug 'MNO-345' in Q4 2022?
SELECT SUM(revenue) FROM sales WHERE drug_name = 'MNO-345' AND quarter = 4 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_products (product_id INT, name VARCHAR(255), rating FLOAT, is_vegan BOOLEAN, is_cruelty_free BOOLEAN);
What is the average rating of natural skincare products that are vegan and cruelty-free?
SELECT AVG(rating) FROM skincare_products WHERE is_vegan = TRUE AND is_cruelty_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE capacity_building_data (id INT, country VARCHAR(50), investment DECIMAL(10,2)); INSERT INTO capacity_building_data (id, country, investment) VALUES (1, 'USA', 100000.00), (2, 'Canada', 80000.00), (3, 'Mexico', 90000.00), (4, 'Brazil', 110000.00);
What is the total capacity building investment by country?
SELECT country, SUM(investment) as total_investment FROM capacity_building_data GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing_ny (id INT, year INT, revenue FLOAT); INSERT INTO carbon_pricing_ny (id, year, revenue) VALUES (1, 2018, 100.0), (2, 2019, 120.0), (3, 2020, 150.0);
What is the average carbon pricing revenue in New York state between 2018 and 2020?
SELECT AVG(revenue) FROM carbon_pricing_ny WHERE year BETWEEN 2018 AND 2020 AND state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_research (org_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO ethical_ai_research (org_id, region, budget) VALUES (1, 'Europe', 50000.00), (2, 'Europe', 75000.00), (3, 'Asia', 60000.00);
What is the average budget allocated for ethical AI research by organizations in Europe?
SELECT AVG(budget) FROM ethical_ai_research WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE causes (cause_id INT, cause_name VARCHAR(50)); INSERT INTO causes (cause_id, cause_name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE donations (donation_id INT, cause_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (donation_id, cause_id, donation_amount, donation_date) VALUES (1, 1, 500, '2022-02-01'), (2, 2, 750, '2022-01-15'), (3, 1, 300, '2022-03-05'), (4, 3, 400, '2022-02-10');
Which causes received donations in the last month?
SELECT cause_name, MAX(donation_date) as latest_donation_date FROM donations JOIN causes ON donations.cause_id = causes.cause_id WHERE donation_date >= DATEADD(month, -1, GETDATE()) GROUP BY cause_name HAVING latest_donation_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE LanguagePreservation (ID INT, Contributor TEXT, Contribution TEXT, Region TEXT); INSERT INTO LanguagePreservation (ID, Contributor, Contribution, Region) VALUES (1, 'Goethe-Institut', 'German language support', 'Europe'), (2, 'Institut Français', 'French language support', 'Europe');
Who are the top 3 contributors to language preservation efforts in 'Europe'?
SELECT Contributor, Contribution FROM LanguagePreservation WHERE Region = 'Europe' LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (country VARCHAR(255), num_tours INT); INSERT INTO virtual_tours (country, num_tours) VALUES ('USA', 3000), ('Canada', 2000), ('Mexico', 1500);
Which countries had the highest number of virtual tours in Q2 2022?
SELECT country, SUM(num_tours) as total_tours FROM virtual_tours WHERE quarter = 'Q2' AND year = 2022 GROUP BY country ORDER BY total_tours DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID int, Name varchar(50), Country varchar(50), StartDate date); INSERT INTO ExcavationSites (SiteID, Name, Country, StartDate) VALUES (5, 'Site E', 'Egypt', '2013-11-11'); CREATE TABLE Artifacts (ArtifactID int, SiteID int, Name varchar(50), Description text, DateFound date); INSERT INTO Artifacts (ArtifactID, SiteID, Name, Description, DateFound) VALUES (4, 5, 'Artifact W', 'An Egyptian artifact', '2017-07-07');
Delete all artifacts related to a specific excavation site
DELETE FROM Artifacts WHERE SiteID = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (id INT, company VARCHAR(255), year INT, amount INT); INSERT INTO defense_contracts (id, company, year, amount) VALUES (1, 'Lockheed Martin', 2020, 10000000), (2, 'Boeing', 2020, 12000000), (3, 'Northrop Grumman', 2019, 8000000), (4, 'Raytheon', 2020, 9000000);
Show the total defense contracts awarded to each company in 2020
SELECT company, SUM(amount) as total_contracts FROM defense_contracts WHERE year = 2020 GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_types (type TEXT, id INTEGER, recycling_rate FLOAT); INSERT INTO waste_types (type, id, recycling_rate) VALUES ('Plastic', 1, 0.3), ('Paper', 2, 0.5), ('Glass', 3, 0.7);
Insert new waste type 'Ceramics' into waste_types table.
INSERT INTO waste_types (type, id, recycling_rate) VALUES ('Ceramics', 4, NULL);
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 total number of healthcare facilities and the number of unique ZIP codes in the HealthcareFacilities table, using a UNION operator
SELECT COUNT(*) FROM HealthcareFacilities UNION SELECT COUNT(DISTINCT ZipCode) FROM HealthcareFacilities;
gretelai_synthetic_text_to_sql
CREATE TABLE GH_Well (Well_ID VARCHAR(10), Production_Rate INT); INSERT INTO GH_Well (Well_ID, Production_Rate) VALUES ('W001', 200), ('W002', 300);
What is the number of wells in the 'GH_Well' table that have a production rate greater than 500?
SELECT COUNT(*) FROM GH_Well WHERE Production_Rate > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, type TEXT, city TEXT); INSERT INTO subscribers (id, type, city) VALUES (1, 'mobile', 'New York'); INSERT INTO subscribers (id, type, city) VALUES (2, 'mobile', 'Los Angeles'); INSERT INTO subscribers (id, type, city) VALUES (3, 'mobile', 'Chicago'); INSERT INTO subscribers (id, type, city) VALUES (4, 'broadband', 'Chicago');
List the top 3 cities with the highest mobile subscriber count.
SELECT city, COUNT(*) as subscriber_count FROM subscribers WHERE type = 'mobile' GROUP BY city ORDER BY subscriber_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicCottonTshirts(brand VARCHAR(255), production_cost DECIMAL(5,2));
What is the average production cost of organic cotton t-shirts across all brands?
SELECT AVG(production_cost) FROM OrganicCottonTshirts;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, amount INT); INSERT INTO production (country, year, amount) VALUES ('China', 2020, 140000), ('USA', 2020, 38000), ('Australia', 2020, 20000), ('India', 2020, 5000);
Which country had the highest rare earth element production in 2020?
SELECT country, MAX(amount) AS max_amount FROM production WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (CompanyID INT, CompanyName VARCHAR(50), Country VARCHAR(50), LaborProductivity DECIMAL(5,2)); INSERT INTO Companies (CompanyID, CompanyName, Country, LaborProductivity) VALUES (1, 'ACME Mining', 'Canada', 15.5), (2, 'BIG Excavations', 'South Africa', 12.3), (3, 'Giga Drilling', 'Australia', 18.7), (4, 'Mega Quarrying', 'Brazil', 10.1);
Which countries have mining companies with the highest labor productivity?
SELECT Country FROM Companies WHERE LaborProductivity IN (SELECT MAX(LaborProductivity) FROM Companies);
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers(id INT, technology VARCHAR(20), type VARCHAR(10)); INSERT INTO subscribers(id, technology, type) VALUES (1, '4G', 'mobile'), (2, '5G', 'mobile'), (3, '3G', 'mobile');
Delete all records of mobile subscribers with the technology '3G'.
DELETE FROM subscribers WHERE technology = '3G' AND type = 'mobile';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(100), network VARCHAR(100)); INSERT INTO smart_contracts (contract_id, name, network) VALUES (1, 'Contract1', 'Binance Smart Chain'), (2, 'Contract2', 'Binance Smart Chain'), (3, 'Contract3', 'Binance Smart Chain'), (4, 'Contract4', 'Binance Smart Chain'), (5, 'Contract5', 'Binance Smart Chain');
What are the smart contracts that have been executed on the Binance Smart Chain network?
SELECT name FROM smart_contracts WHERE network = 'Binance Smart Chain';
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Nationality VARCHAR(20), SpaceMissions INT, TrainingHours INT); INSERT INTO Astronauts (AstronautID, FirstName, LastName, Nationality, SpaceMissions, TrainingHours) VALUES (1, 'Yang', 'Liwei', 'Chinese', 2, 1500); INSERT INTO Astronauts (AstronautID, FirstName, LastName, Nationality, SpaceMissions, TrainingHours) VALUES (2, 'Liu', 'Boming', 'Chinese', 1, 1200); INSERT INTO Astronauts (AstronautID, FirstName, LastName, Nationality, SpaceMissions, TrainingHours) VALUES (3, 'Wang', 'Yaping', 'Chinese', 1, 1300);
What is the average training duration for Chinese astronauts?
SELECT Nationality, AVG(TrainingHours) FROM Astronauts WHERE Nationality = 'Chinese' GROUP BY Nationality;
gretelai_synthetic_text_to_sql
CREATE TABLE program_implementation (id INT, program VARCHAR(30), county VARCHAR(30), start_year INT); INSERT INTO program_implementation (id, program, county, start_year) VALUES (1, 'Coffee with a Cop', 'Los Angeles County', 2015), (2, 'Block Watch', 'Los Angeles County', 2016), (3, 'Community Police Academy', 'Los Angeles County', 2017), (4, 'Junior Police Academy', 'Los Angeles County', 2018), (5, 'Police Explorers', 'Los Angeles County', 2019);
What is the total number of community policing programs implemented in Los Angeles County by year?
SELECT start_year, COUNT(*) as total FROM program_implementation WHERE county = 'Los Angeles County' GROUP BY start_year;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents (id INT, incident_name VARCHAR(255), country VARCHAR(255), incident_category VARCHAR(255)); INSERT INTO ai_safety_incidents (id, incident_name, country, incident_category) VALUES (1, 'IncidentX', 'UAE', 'Malfunction'), (2, 'IncidentY', 'Saudi Arabia', 'Unintended Behavior'), (3, 'IncidentZ', 'Israel', 'Privacy Breach');
List all AI safety incidents in the Middle East with their respective categories.
SELECT * FROM ai_safety_incidents WHERE country IN ('UAE', 'Saudi Arabia', 'Israel');
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_diversity (id INT, name VARCHAR(100), role VARCHAR(50), gender VARCHAR(10)); INSERT INTO workforce_diversity (id, name, role, gender) VALUES (1, 'John Doe', 'Mining Engineer', 'Male'); INSERT INTO workforce_diversity (id, name, role, gender) VALUES (2, 'Jane Smith', 'Geologist', 'Female');
How many female and male employees are there in the 'workforce_diversity' table?
SELECT gender, COUNT(*) FROM workforce_diversity GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE argentina_participants (country TEXT, year INT, initiative_type TEXT, participants INT); INSERT INTO argentina_participants (country, year, initiative_type, participants) VALUES ('Argentina', 2018, 'Community Development', 250), ('Argentina', 2018, 'Community Development', 300), ('Argentina', 2019, 'Community Development', 350), ('Argentina', 2019, 'Community Development', 400), ('Argentina', 2020, 'Community Development', 450), ('Argentina', 2020, 'Community Development', 500), ('Argentina', 2021, 'Community Development', 550), ('Argentina', 2021, 'Community Development', 600);
Which community development initiatives in Argentina had the highest participant growth rate, in the past 3 years?
SELECT year, initiative_type, MAX(participants) - MIN(participants) OVER (PARTITION BY initiative_type ORDER BY year ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS growth_rate FROM argentina_participants WHERE country = 'Argentina' AND initiative_type = 'Community Development' AND year BETWEEN 2018 AND 2021 ORDER BY growth_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, name VARCHAR(50), ocean_border VARCHAR(50));INSERT INTO countries (country_id, name, ocean_border) VALUES (1, 'India', 'Indian'), (2, 'Madagascar', 'Indian'), (3, 'Tanzania', 'Indian'), (4, 'Indonesia', 'Pacific'), (5, 'Malaysia', 'Pacific');CREATE TABLE initiatives (initiative_id INT, name VARCHAR(50), country_id INT);INSERT INTO initiatives (initiative_id, name, country_id) VALUES (1, 'Beach Cleanup', 1), (2, 'Recycling Program', 2), (3, 'Mangrove Planting', 3), (4, 'Ocean Education', 4), (5, 'Waste Management', 5);
List all the pollution control initiatives in countries that border the Indian Ocean.
SELECT i.name FROM initiatives i JOIN countries c ON i.country_id = c.country_id WHERE c.ocean_border = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Buildings (id INT, project_name TEXT, state TEXT, timeline INT);CREATE TABLE Construction_Projects (id INT, project_name TEXT, timeline INT);
What is the average project timeline for sustainable buildings in California?
SELECT AVG(timeline) FROM Sustainable_Buildings WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(50), language VARCHAR(50), publish_date DATE); INSERT INTO articles (article_id, title, language, publish_date) VALUES (1, 'Article1', 'Spanish', '2023-01-01'), (2, 'Article2', 'French', '2023-02-14'), (3, 'Article3', 'German', '2023-03-05');
Count the number of articles in each language published on the media platform, for articles published in 2023.
SELECT language, COUNT(*) as article_count FROM articles WHERE YEAR(publish_date) = 2023 GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, ip_address VARCHAR(50), department VARCHAR(50), description TEXT, date DATE);
Which IP addresses are associated with the most security incidents in the 'security_incidents' table?
SELECT ip_address, COUNT(*) as incident_count FROM security_incidents GROUP BY ip_address ORDER BY incident_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE bookings(booking_id INT, booking_date DATE, num_tours INT);
How many local tours were booked per month in 2021?
SELECT EXTRACT(MONTH FROM booking_date) AS month, AVG(num_tours) FROM bookings WHERE EXTRACT(YEAR FROM booking_date) = 2021 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (id INT, project_name VARCHAR(255), budget INT);
Delete all records in the 'agricultural_innovation' table where the budget is less than 75000.
DELETE FROM agricultural_innovation WHERE budget < 75000;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, condition VARCHAR(50), country VARCHAR(50)); INSERT INTO patients (id, condition, country) VALUES (1, 'Depression', 'Africa'), (2, 'Anxiety', 'Africa'), (3, 'Depression', 'Africa'), (4, 'Bipolar Disorder', 'Africa'); CREATE TABLE treatments (id INT, patient_id INT, treatment VARCHAR(50)); INSERT INTO treatments (id, patient_id, treatment) VALUES (1, 1, 'Medication'), (2, 2, 'Talk Therapy'), (3, 3, 'Medication'), (4, 4, 'Medication');
What is the most common treatment approach for patients with depression in Africa?
SELECT treatments.treatment, COUNT(*) AS count FROM patients INNER JOIN treatments ON patients.id = treatments.patient_id WHERE patients.condition = 'Depression' AND patients.country = 'Africa' GROUP BY treatments.treatment ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA oceans;CREATE TABLE oceans.mapping_projects (id INT PRIMARY KEY, country VARCHAR(50), avg_depth DECIMAL(5,2)); INSERT INTO oceans.mapping_projects (id, country, avg_depth) VALUES (1, 'Canada', 4500.00), (2, 'Mexico', 3500.00);
What is the average depth of ocean floor mapping projects by country?
SELECT context.country, AVG(context.avg_depth) FROM oceans.mapping_projects AS context GROUP BY context.country;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, name VARCHAR(50));CREATE TABLE animals (id INT, species VARCHAR(50), program_id INT);INSERT INTO education_programs (id, name) VALUES (1, 'Adopt an Animal'), (2, 'Wildlife Warriors'), (3, 'Endangered Species');INSERT INTO animals (id, species, program_id) VALUES (1, 'Lion', 1), (2, 'Elephant', 2);
Show community education programs without any species
SELECT e.name FROM education_programs e LEFT JOIN animals a ON e.id = a.program_id WHERE a.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region VARCHAR(255)); INSERT INTO regions (region_id, region) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Asia'), (5, 'Africa');
What is the distribution of security incidents by region for the last month?
SELECT region, COUNT(*) as incident_count FROM incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, region TEXT, num_rooms INT); CREATE TABLE virtual_tours (id INT, hotel_id INT, views INT);
How many virtual tours were engaged with in the APAC region for hotels with over 200 rooms?
SELECT COUNT(*) FROM hotels JOIN virtual_tours ON hotels.id = virtual_tours.hotel_id WHERE hotels.region = 'APAC' AND hotels.num_rooms > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name TEXT, ocean_acidification_data BOOLEAN); INSERT INTO marine_species (id, species_name, ocean_acidification_data) VALUES (1, 'Coral', true); INSERT INTO marine_species (id, species_name, ocean_acidification_data) VALUES (2, 'Humpback Whale', false);
What is the number of marine species with data on ocean acidification?
SELECT COUNT(*) FROM marine_species WHERE ocean_acidification_data = true;
gretelai_synthetic_text_to_sql
CREATE TABLE textiles (id INT, type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO textiles (id, type, price) VALUES (1, 'cotton', 5.50), (2, 'silk', 15.00);
What is the average price of cotton textiles in the 'textiles' table?
SELECT AVG(price) FROM textiles WHERE type = 'cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE us_tourists (id INT, country VARCHAR(20), tourists INT); INSERT INTO us_tourists (id, country, tourists) VALUES (1, 'United States', 75000000); CREATE TABLE canada_tourists (id INT, country VARCHAR(20), tourists INT); INSERT INTO canada_tourists (id, country, tourists) VALUES (1, 'Canada', 22000000);
What is the difference in the number of tourists visiting the United States and Canada?
SELECT (us_tourists.tourists - canada_tourists.tourists) AS diff FROM us_tourists, canada_tourists;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists interactions (interaction_id INT, user_id INT, country VARCHAR(50), interactions_count INT, quarter INT, year INT); INSERT INTO interactions (interaction_id, user_id, country, interactions_count, quarter, year) VALUES (1, 1, 'South Korea', 25, 1, 2022), (2, 2, 'South Korea', 30, 1, 2022);
Show the number of content interactions per user in South Korea for Q1 2022.
SELECT user_id, AVG(interactions_count) FROM interactions WHERE country = 'South Korea' AND quarter = 1 AND year = 2022 GROUP BY user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(50), date_time DATETIME);
Find the latest incident date and time in the 'incidents' table
SELECT MAX(date_time) FROM incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (shipment_id INT, origin VARCHAR(50), destination VARCHAR(50)); INSERT INTO Shipments (shipment_id, origin, destination) VALUES (1, 'China', 'United States'); INSERT INTO Shipments (shipment_id, origin, destination) VALUES (2, 'China', 'United States');
What is the total number of shipments from China to the United States?
SELECT COUNT(*) FROM Shipments WHERE origin = 'China' AND destination = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO Cities (id, name) VALUES (1, 'New York'), (2, 'Chicago'), (3, 'Los Angeles'); CREATE TABLE Events (id INT PRIMARY KEY, city_id INT, price DECIMAL(10,2)); INSERT INTO Events (id, city_id, price) VALUES (1, 1, 50.00), (2, 1, 100.00), (3, 2, 75.00), (4, 3, 150.00), (5, 3, 200.00);
What are the top 3 cities with the highest total revenue?
SELECT Cities.name, SUM(Events.price) as Total_Revenue FROM Cities INNER JOIN Events ON Cities.id = Events.city_id GROUP BY Cities.name ORDER BY Total_Revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_agriculture_africa (project_name TEXT, area_ha FLOAT); INSERT INTO urban_agriculture_africa (project_name, area_ha) VALUES ('Project C', 34.5); INSERT INTO urban_agriculture_africa (project_name, area_ha) VALUES ('Project D', 56.7);
What is the total area (in hectares) of all urban agriculture projects in the 'Africa' region?
SELECT SUM(area_ha) FROM urban_agriculture_africa;
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (permit_id INT, building_type VARCHAR(50), location VARCHAR(50), year_issued INT); INSERT INTO Building_Permits (permit_id, building_type, location, year_issued) VALUES (1, 'High-rise residential', 'New York City', 2018); INSERT INTO Building_Permits (permit_id, building_type, location, year_issued) VALUES (2, 'Single-family home', 'New York City', 2019);
Identify the number of building permits issued in New York City for high-rise residential buildings between 2018 and 2020, including those with zero permits issued.
SELECT COUNT(*) FROM (SELECT 1 FROM Building_Permits WHERE building_type = 'High-rise residential' AND location = 'New York City' AND year_issued BETWEEN 2018 AND 2020 GROUP BY year_issued) AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE community_programs (id INT PRIMARY KEY, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), capacity INT);
Create a table 'community_programs'
CREATE TABLE community_programs (id INT PRIMARY KEY, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), capacity INT);
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50));CREATE TABLE Destination (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), description TEXT, sustainability_rating INT);CREATE VIEW Top_Sustainable_Destinations AS SELECT Destination.country, COUNT(Destination.id) AS destination_count FROM Destination WHERE Destination.sustainability_rating >= 4 GROUP BY Destination.country ORDER BY destination_count DESC;
What are the top 5 countries with the most sustainable tourism destinations?
SELECT * FROM Top_Sustainable_Destinations LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE industry (company_id INT, industry TEXT); INSERT INTO industry (company_id, industry) VALUES (1, 'Tech'); INSERT INTO industry (company_id, industry) VALUES (2, 'Finance');
Calculate the total funding for startups with at least one female founder in the tech industry
SELECT SUM(funding_amount) FROM investment_rounds ir INNER JOIN company c ON ir.company_id = c.id INNER JOIN diversity d ON c.id = d.company_id INNER JOIN industry i ON c.id = i.company_id WHERE i.industry = 'Tech' AND d.founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (funding_source_name VARCHAR(50), program_name VARCHAR(50), funding_amount DECIMAL(10,2), funding_year INT); INSERT INTO funding_sources (funding_source_name, program_name, funding_amount, funding_year) VALUES ('Government Grant', 'Theatre', 25000, 2022), ('Private Donation', 'Theatre', 50000, 2022), ('Corporate Sponsorship', 'Music', 30000, 2022);
Insert a new record for a 'Literature' program funded by 'Foundation Grant' in 2023 with an amount of 20000.
INSERT INTO funding_sources (funding_source_name, program_name, funding_amount, funding_year) VALUES ('Foundation Grant', 'Literature', 20000, 2023);
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationRecords (RecordID INT, SiteID INT, Date DATE); INSERT INTO ExcavationRecords (RecordID, SiteID, Date) VALUES (1, 1, '2005-01-01'), (2, 2, '2009-06-12'), (3, 3, '2011-09-28');
Delete any excavation records older than 2010?
DELETE FROM ExcavationRecords WHERE Date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE orders (customer_id INT, order_date DATE, size VARCHAR(10), quantity INT); INSERT INTO orders (customer_id, order_date, size, quantity) VALUES (1, '2022-01-01', 'large', 100), (2, '2022-01-02', 'large', 200), (3, '2022-01-03', 'medium', 150), (4, '2022-01-04', 'large', 120), (4, '2022-01-05', 'medium', 130); CREATE TABLE customers (customer_id INT, name VARCHAR(20)); INSERT INTO customers (customer_id, name) VALUES (1, 'John'), (2, 'Sarah'), (3, 'Mohammed'), (4, 'Ayanna');
What is the percentage of orders placed by each customer in the 'medium' size category?
SELECT c.customer_id, c.name, 100.0 * COUNT(o.order_id) / (SELECT COUNT(*) FROM orders) as pct_orders FROM orders o RIGHT JOIN customers c ON o.customer_id = c.customer_id WHERE size = 'medium' GROUP BY c.customer_id, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_paris (city VARCHAR(50), initiative_count INT, year INT); INSERT INTO circular_economy_paris (city, initiative_count, year) VALUES ('Paris', 200, 2019), ('Paris', 250, 2020), ('Paris', 300, 2021);
What is the total circular economy initiatives in Paris over the last 2 years?
SELECT SUM(initiative_count) FROM circular_economy_paris WHERE city = 'Paris' AND year >= 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (id INT, game_id INT, team VARCHAR(50), tickets_sold INT);
Count the number of tickets sold for the "Home Team" in the "tickets" table.
SELECT COUNT(*) FROM tickets WHERE team = 'Home Team';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user VARCHAR(255), hashtags TEXT, timestamp TIMESTAMP);
List users who have used the hashtag "#fitness" more than 5 times in the past week.
SELECT user FROM posts WHERE hashtags LIKE '%#fitness%' GROUP BY user HAVING COUNT(*) > 5 AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, name VARCHAR(255), year INT, category VARCHAR(255)); INSERT INTO artworks (id, name, year, category) VALUES (1, 'Painting', 1920, 'painting'), (2, 'Sculpture', 1930, 'sculpture'), (3, 'Print', 1940, 'print');
What is the minimum year of creation for artworks in the 'painting' category?
SELECT MIN(year) FROM artworks WHERE category = 'painting';
gretelai_synthetic_text_to_sql