context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(100), DonationAmount DECIMAL(10,2), DonationDate DATE);
What's the total amount donated by individual donors who have made more than two donations in the year 2020?
SELECT SUM(DonationAmount) FROM Donors WHERE YEAR(DonationDate) = 2020 GROUP BY DonorID HAVING COUNT(DonorID) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_activity (vessel_id INT, activity_date DATE, PRIMARY KEY(vessel_id, activity_date));
Update the 'status' column to 'inactive' for all vessels in the 'vessels' table that have not been active in the past year.
UPDATE vessels v1 SET status = 'inactive' WHERE NOT EXISTS (SELECT 1 FROM vessel_activity va1 WHERE va1.vessel_id = v1.id AND va1.activity_date > DATE(NOW()) - INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE solar_farms (name TEXT, state TEXT, capacity FLOAT); INSERT INTO solar_farms (name, state, capacity) VALUES ('Mojave Solar', 'California', 250.0), ('Desert Sunlight', 'California', 550.0), ('Topaz Solar', 'California', 550.0);
What are the names and capacities of solar farms in California?
SELECT name, capacity FROM solar_farms WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales (supplier VARCHAR(255), region VARCHAR(255), equipment VARCHAR(255), quantity INT, sale_price DECIMAL(10,2), sale_year INT);
What is the minimum number of air defense systems supplied by YZ Corp to European countries in the year 2021?
SELECT MIN(quantity) FROM Military_Equipment_Sales WHERE supplier = 'YZ Corp' AND region = 'Europe' AND equipment = 'air defense systems' AND sale_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT PRIMARY KEY, project_name VARCHAR(255), project_location VARCHAR(255), project_type VARCHAR(255), completion_year INT, capacity_mw FLOAT);
List all renewable energy projects in India that were completed in 2018.
SELECT * FROM renewable_projects WHERE project_location = 'India' AND completion_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (OperationID INT, OperationName VARCHAR(100), OperationType VARCHAR(50), StartDate DATE, EndDate DATE);
What is the total number of peacekeeping operations conducted by the UN?
SELECT COUNT(OperationID) FROM PeacekeepingOperations WHERE OperationType = 'Peacekeeping';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_number VARCHAR(50), client_name VARCHAR(50), attorney_id INT); CREATE TABLE billing (billing_id INT, attorney_id INT, client_id INT, hours_billed INT, billing_rate DECIMAL(5,2));
List the names and case numbers of cases in 'cases' table that have a billing rate greater than $300 in 'billing' table
SELECT cases.case_number, cases.client_name FROM cases INNER JOIN billing ON cases.attorney_id = billing.attorney_id WHERE billing.billing_rate > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE oceania_tourists (id INT, country VARCHAR(20), tourists INT); INSERT INTO oceania_tourists (id, country, tourists) VALUES (1, 'Australia', 20000000), (2, 'New Zealand', 3000000);
What is the total number of tourists visiting countries in the Oceania continent?
SELECT SUM(tourists) FROM oceania_tourists;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, zip TEXT, consultations INT); INSERT INTO community_health_workers (id, name, zip, consultations) VALUES (1, 'John Doe', '32001', 35), (2, 'Jane Smith', '33101', 45); CREATE VIEW fl_workers AS SELECT * FROM community_health_workers WHERE zip BETWEEN '32001' AND ...
Who is the community health worker with the most mental health parity consultations in Florida?
SELECT name FROM fl_workers WHERE consultations = (SELECT MAX(consultations) FROM fl_workers);
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO community_development (id, name, type, budget) VALUES (1, 'Green Spaces', 'Community Development', 75000.00), (2, 'Smart Street Lighting', 'Agricultural Innovation', 120000.00), (3, 'Cultural Center', 'Community D...
What is the minimum budget for a community development project in the 'community_development' table?
SELECT MIN(budget) FROM community_development WHERE type = 'Community Development';
gretelai_synthetic_text_to_sql
CREATE TABLE stop (stop_id INT, stop_name TEXT);CREATE TABLE trip (trip_id INT, stop_id INT, passenger_count INT); INSERT INTO stop (stop_id, stop_name) VALUES (1, 'Stop1'), (2, 'Stop2'), (3, 'Stop3'), (4, 'Stop4'), (5, 'Stop5'), (6, 'Stop6'); INSERT INTO trip (trip_id, stop_id, passenger_count) VALUES (1, 1, 5), (2, 1...
Identify the top 5 most frequently used bus stops.
SELECT s.stop_name, SUM(t.passenger_count) as total_passenger_count FROM stop s JOIN trip t ON s.stop_id = t.stop_id GROUP BY s.stop_id ORDER BY total_passenger_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE public_libraries (state VARCHAR(20), num_libraries INT, budget FLOAT); INSERT INTO public_libraries (state, num_libraries, budget) VALUES ('California', 1500, 25000000);
How many public libraries are there in California, and what is the total budget allocated to them?
SELECT SUM(budget) FROM public_libraries WHERE state = 'California'; SELECT COUNT(*) FROM public_libraries WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(100)); CREATE TABLE exports (export_id INT, container_weight INT, country_id INT, shipped_date DATE, destination_country VARCHAR(100)); INSERT INTO countries VALUES (1, 'China'); INSERT INTO countries VALUES (2, 'India'); INSERT INTO exports VALUES (1, 10, 1,...
Which countries have the highest average container weight for exports to the USA, and what is the average weight per container for those shipments?
SELECT exports.destination_country, countries.country_name, AVG(exports.container_weight) as avg_weight_per_container FROM countries INNER JOIN exports ON countries.country_id = exports.country_id WHERE exports.destination_country = 'USA' GROUP BY exports.destination_country, countries.country_name ORDER BY AVG(exports...
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (name TEXT, location TEXT, beds INTEGER); INSERT INTO hospitals (name, location, beds) VALUES ('Hospital A', 'Rural Brazil', 50), ('Hospital B', 'Rural Brazil', 40), ('Hospital C', 'Rural Argentina', 30), ('Hospital D', 'Rural Argentina', 20), ('Hospital E', 'Rural Colombia', 10);
What is the total number of hospital beds in rural areas of Brazil, Argentina, and Colombia?
SELECT SUM(beds) FROM hospitals WHERE location LIKE 'Rural%';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_rights_violations (union_name TEXT, violation_date DATE); INSERT INTO labor_rights_violations (union_name, violation_date) VALUES ('Union A', '2020-01-05'), ('Union B', '2020-02-10'), ('Union C', '2020-03-15'), ('Union A', '2020-04-20'), ('Union D', '2020-05-25'), ('Union E', '2020-06-30'), ('Union A...
What is the average number of labor rights violations per month for the year 2020, for each union?
SELECT union_name, AVG(EXTRACT(MONTH FROM violation_date)) as avg_violations_per_month FROM labor_rights_violations WHERE EXTRACT(YEAR FROM violation_date) = 2020 GROUP BY union_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (id INT, team VARCHAR(50), conference VARCHAR(50), tickets_sold INT, revenue FLOAT);
What are the total ticket sales for each conference in the ticket_sales table?
SELECT conference, SUM(tickets_sold) AS total_tickets_sold FROM ticket_sales GROUP BY conference;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, segment VARCHAR(20)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO customers (id, segment) VALUES (1, 'SME'); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (1, 1, 1200, '2022-05-15');
Calculate the maximum transaction amount for the 'SME' customer segment in the last month.
SELECT MAX(amount) FROM transactions JOIN customers ON transactions.customer_id = customers.id WHERE customers.segment = 'SME' AND transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), ocean VARCHAR(255), depth INT); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (1, 'Mariana Snailfish', 'Pacific', 8178); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (2, 'Hadal Snailfish', 'Atlantic', 7500);
What is the total number of marine species observed in the Pacific and Atlantic oceans with a depth greater than 2000 meters?
SELECT SUM(CASE WHEN ocean IN ('Pacific', 'Atlantic') AND depth > 2000 THEN 1 ELSE 0 END) FROM marine_species;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_ethics (region VARCHAR(255), concern_rating FLOAT); INSERT INTO ai_ethics (region, concern_rating) VALUES ('APAC', 3.2), ('EMEA', 4.1), ('NA', 3.8), ('LA', 3.5);
What is the average AI ethical concern rating by region?
SELECT region, AVG(concern_rating) OVER (PARTITION BY region) AS avg_rating FROM ai_ethics;
gretelai_synthetic_text_to_sql
CREATE TABLE Hiring (HireID INT, EmployeeID INT, HireDate DATE, Community VARCHAR(50)); INSERT INTO Hiring (HireID, EmployeeID, HireDate, Community) VALUES (1, 5, '2022-01-15', 'LatinX'), (2, 6, '2022-02-20', 'African American'), (3, 7, '2022-03-05', 'LGBTQ+'), (4, 8, '2022-04-12', 'Women in STEM'), (5, 9, '2021-11-30'...
What is the total number of employees hired from the LGBTQ+ community after 2020?
SELECT COUNT(*) FROM Hiring WHERE YEAR(HireDate) > 2020 AND Community = 'LGBTQ+';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, customer_name VARCHAR(50), total_spent DECIMAL(10, 2)); CREATE TABLE ethical_jewelry_purchases (id INT, purchase_id INT, customer_id INT, purchase_value DECIMAL(10, 2)); INSERT INTO customers (id, customer_name, total_spent) VALUES (1, 'EcoBuyer', 1200.00), (2, 'GreenSpender', 1800.00), ...
What is the total value of ethical jewelry purchases made by customers in Canada in 2020?
SELECT SUM(purchase_value) FROM ethical_jewelry_purchases JOIN customers ON customers.id = ethical_jewelry_purchases.customer_id WHERE customers.country_of_residence = 'Canada' AND YEAR(purchase_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE investor (investor_id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO investor (investor_id, name, country) VALUES (1, 'Acme Corp', 'United States'); CREATE TABLE investment (investment_id INT, investor_id INT, strategy VARCHAR(255), impact_score FLOAT);
Insert a new impact investment for a US investor in climate change mitigation with an impact score of 80.
INSERT INTO investment (investment_id, investor_id, strategy, impact_score) VALUES (101, (SELECT investor_id FROM investor WHERE name = 'Acme Corp' AND country = 'United States'), 'Climate Change Mitigation', 80);
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (station_id INT, station_name VARCHAR(50), location VARCHAR(50), quantity INT);
Update the charging stations table to add a new charging station, 'GreenTech Los Angeles', with a quantity of 10.
UPDATE charging_stations SET quantity = quantity + 10 WHERE station_name = 'GreenTech Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE precedents (precedent_id INT PRIMARY KEY, precedent_name VARCHAR(50), year DECIMAL(4,0), court VARCHAR(50));
Insert a new precedent named 'Roe v. Wade' into the 'precedents' table
INSERT INTO precedents (precedent_id, precedent_name, year, court) VALUES (1, 'Roe v. Wade', 1973, 'Supreme Court');
gretelai_synthetic_text_to_sql
CREATE TABLE tribal_area_1 (farmer_id TEXT, indigenous BOOLEAN, community_food BOOLEAN); INSERT INTO tribal_area_1 (farmer_id, indigenous, community_food) VALUES ('i001', true, true), ('i002', true, false), ('i003', false, true), ('i004', false, false);
How many indigenous farmers in 'tribal_area_1' produce food for their community?
SELECT COUNT(*) FROM tribal_area_1 WHERE indigenous = true AND community_food = true;
gretelai_synthetic_text_to_sql
CREATE TABLE africa_users (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO africa_users (id, name, country) VALUES (1, 'John Doe', 'Nigeria'), (2, 'Jane Smith', 'South Africa');
Determine the number of registered users for each country in Africa, returning only countries with more than 1,000,000 users.
SELECT country, COUNT(*) as num_users FROM africa_users GROUP BY country HAVING num_users > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (id INT, excavation_site VARCHAR(20), artifact_name VARCHAR(30), pieces INT); INSERT INTO Artifacts (id, excavation_site, artifact_name, pieces) VALUES (1, 'CeramicMound', 'Pot', 700,), (2, 'CeramicMound', 'Plate', 300,);
Which artifacts were found in the 'CeramicMound' site and have more than 500 pieces?
SELECT artifact_name, pieces FROM Artifacts WHERE excavation_site = 'CeramicMound' AND pieces > 500;
gretelai_synthetic_text_to_sql
CREATE VIEW Resilience_Cost_By_Type AS SELECT project_id, project_name, project_type, cost, resilience_score FROM Water_Infrastructure JOIN Resilience_Scores ON Water_Infrastructure.project_id = Resilience_Scores.project_id WHERE year >= 2015; CREATE TABLE Project_Types (project_type VARCHAR(255), type_description VARC...
Display the total cost and average resilience score for each project type in the Resilience_Cost_By_Type view
SELECT project_type, AVG(resilience_score), SUM(cost) FROM Resilience_Cost_By_Type JOIN Project_Types ON Resilience_Cost_By_Type.project_type = Project_Types.project_type GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE state_energy (name VARCHAR(50), energy_consumption DECIMAL(5,2), renewable_energy DECIMAL(5,2), country VARCHAR(50)); INSERT INTO state_energy (name, energy_consumption, renewable_energy, country) VALUES ('California', 12345.6, 3421.7, 'United States'), ('Texas', 15678.9, 2950.1, 'United States'), ('New Yo...
Show the percentage of energy consumption from renewable sources for each state in the United States, sorted by the highest percentage.
SELECT name, (renewable_energy / energy_consumption) * 100 AS percentage FROM state_energy WHERE country = 'United States' ORDER BY percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Salary) VALUES (1, 'John Doe', 'IT', 70000), (2, 'Jane Smith', 'IT', 85000), (3, 'Mike Johnson', 'HR', 60000), (4, 'Sara Brown', 'HR', 65000);
Calculate the average salary of employees in each department, with a rank based on the average salary.
SELECT Department, AVG(Salary) AS AverageSalary, RANK() OVER (ORDER BY AVG(Salary) DESC) AS SalaryRank FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, region TEXT); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'US'), (2, 'Jane Smith', 'CA');
Delete the record of the client from the 'clients' table who resides in the 'CA' region.
DELETE FROM clients WHERE region = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE workshops (id INT, name VARCHAR(20), updated_at DATE); INSERT INTO workshops (id, name, updated_at) VALUES (1, 'Tech Tools', '2022-02-01'); INSERT INTO workshops (id, name, updated_at) VALUES (2, 'Diversity Training', '2022-04-15'); INSERT INTO workshops (id, name, updated_at) VALUES (3, 'Project-based Lea...
Delete outdated professional development workshops
DELETE FROM workshops WHERE updated_at < DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), founder_gender VARCHAR(10)); CREATE TABLE investment_round (id INT, company_id INT, round_number INT); INSERT INTO company (id, name, founder_gender) VALUES (1, 'Acme Corp', 'Female'); INSERT INTO investment_round (id, company_id, round_number) VALUES (1, 1, 1); INSERT IN...
How many investment rounds have been raised by companies with female co-founders?
SELECT COUNT(*) AS num_investment_rounds FROM company c JOIN investment_round ir ON c.id = ir.company_id WHERE c.founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE lenders (lender_id INT, lender_name VARCHAR(255));CREATE TABLE loans (loan_id INT, lender_id INT, issue_date DATE, loan_amount DECIMAL(10,2), borrower_social_responsibility_score INT, interest_rate DECIMAL(5,2), interest_earned DECIMAL(10,2));INSERT INTO lenders (lender_id, lender_name) VALUES (1, 'Lender ...
What is the total amount of interest earned by each lender on socially responsible loans in the last 3 months?
SELECT l.lender_name, SUM(l.interest_earned) as total_interest_earned FROM loans l INNER JOIN lenders le ON l.lender_id = le.lender_id WHERE l.issue_date BETWEEN (CURRENT_DATE - INTERVAL '3 months') AND CURRENT_DATE AND l.borrower_social_responsibility_score > 70 GROUP BY l.lender_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel_Positions (position_date date, vessel_name text, position_location text);
What are the names of vessels that have not reported their positions in the past month in the South China Sea?
SELECT DISTINCT v.vessel_name FROM Vessel_Positions v LEFT JOIN (SELECT position_date FROM Vessel_Positions WHERE position_date > NOW() - INTERVAL '1 month') AS sub ON v.position_date = sub.position_date WHERE sub.position_date IS NULL AND position_location LIKE '%South China Sea%';
gretelai_synthetic_text_to_sql
CREATE TABLE hr_dept_vulnerabilities (id INT, incident_date DATE, department VARCHAR(255), days_to_remediate INT); INSERT INTO hr_dept_vulnerabilities (id, incident_date, department, days_to_remediate) VALUES (1, '2022-01-01', 'HR', 3), (2, '2022-02-01', 'HR', 7), (3, '2022-03-01', 'HR', 5);
What is the minimum number of days it took to remediate vulnerabilities in the 'HR' department?
SELECT department, MIN(days_to_remediate) FROM hr_dept_vulnerabilities WHERE department = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_name VARCHAR(50)); INSERT INTO games VALUES (1, 'GameA'); INSERT INTO games VALUES (2, 'GameB'); INSERT INTO games VALUES (3, 'GameC'); CREATE TABLE game_sessions (session_id INT, player_id INT, game_id INT, duration INT); INSERT INTO game_sessions VALUES (1, 1, 1, 12); INSERT INTO...
What are the top 3 games by total playtime in the 'game_sessions' table, and what is the total playtime for each?
SELECT g.game_name, SUM(gs.duration) as total_playtime FROM game_sessions gs JOIN games g ON gs.game_id = g.game_id GROUP BY gs.game_id ORDER BY total_playtime DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE levees (id INT, name TEXT, state TEXT, avg_annual_precipitation FLOAT); INSERT INTO levees (id, name, state, avg_annual_precipitation) VALUES (1, 'LA-1 Floodgate', 'LA', 60);
What is the average annual precipitation for levees in Louisiana?
SELECT AVG(avg_annual_precipitation) FROM levees WHERE state = 'LA';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT PRIMARY KEY, location VARCHAR(50), rate FLOAT);
Display the recycling rate for each location
SELECT location, rate FROM recycling_rates;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, region TEXT, billing_amount DECIMAL(10, 2)); INSERT INTO clients (id, name, region, billing_amount) VALUES (1, 'Alice', 'los angeles', 200.00), (2, 'Bob', 'los angeles', 300.00), (3, 'Charlie', 'los angeles', 400.00);
What is the maximum billing amount for clients in the 'los angeles' region?
SELECT MAX(billing_amount) FROM clients WHERE region = 'los angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE Trout_Harvest (Harvest_ID INT, Farm_ID INT, Harvest_Date DATE, Quantity_Harvested INT); INSERT INTO Trout_Harvest (Harvest_ID, Farm_ID, Harvest_Date, Quantity_Harvested) VALUES (1, 1, '2021-08-15', 2000), (2, 2, '2021-09-20', 3000), (3, 3, '2021-10-05', 2500);
What is the total quantity of fish harvested in the Trout_Harvest table for each month?
SELECT DATE_FORMAT(Harvest_Date, '%%Y-%%m') AS Month, SUM(Quantity_Harvested) FROM Trout_Harvest GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, genre VARCHAR(20), release_year INT, streams INT); INSERT INTO songs (song_id, genre, release_year, streams) VALUES (1, 'classical', 2020, 7000); INSERT INTO songs (song_id, genre, release_year, streams) VALUES (2, 'classical', 2020, 8000); INSERT INTO songs (song_id, genre, release_yea...
How many classical songs were released in 2020 that have more than 6000 streams?
SELECT COUNT(*) FROM songs WHERE genre = 'classical' AND release_year = 2020 AND streams > 6000;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_name VARCHAR(255), open_date DATE, close_date DATE, PRIMARY KEY (case_id)); INSERT INTO cases (case_id, case_name, open_date, close_date) VALUES (1, 'Case 1', '2019-01-01', '2020-01-01'), (2, 'Case 2', '2020-01-01', '2021-01-01'), (3, 'Case 3', '2018-01-01', NULL);
List the names and case numbers of all cases in the justice system that have been open for more than 1 year
SELECT case_name, case_id FROM cases WHERE close_date IS NULL AND DATEDIFF(CURDATE(), open_date) > 365;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team VARCHAR(50)); INSERT INTO teams (team) VALUES ('Team Alpha'), ('Team Bravo');
Which athletes in the 'athlete_details' table have the same name as a team in the 'teams' table?
SELECT name FROM athlete_details WHERE name IN (SELECT team FROM teams);
gretelai_synthetic_text_to_sql
CREATE TABLE domestic_delivery_data (delivery_id INT, shipment_id INT, delivery_time INT); INSERT INTO domestic_delivery_data (delivery_id, shipment_id, delivery_time) VALUES (1, 1, 10), (2, 2, 8), (3, 3, 12), (4, 4, 9), (5, 5, 15);
What is the maximum delivery time for packages shipped within the same country?
SELECT MAX(delivery_time) FROM domestic_delivery_data JOIN shipment_data ON domestic_delivery_data.shipment_id = shipment_data.shipment_id WHERE origin_country = destination_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerRegion VARCHAR(10), GameName VARCHAR(20), Victories INT); INSERT INTO Players (PlayerID, PlayerRegion, GameName, Victories) VALUES (1, 'Africa', 'Galactic Conquest', 15), (2, 'Asia', 'Galactic Conquest', 20), (3, 'Africa', 'Galactic Conquest', 25);
What is the average number of victories for players from Africa in the game "Galactic Conquest"?
SELECT AVG(Victories) FROM Players WHERE PlayerRegion = 'Africa' AND GameName = 'Galactic Conquest';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (id INT, project VARCHAR(255), country VARCHAR(255), budget FLOAT); INSERT INTO RuralInfrastructure (id, project, country, budget) VALUES (1, 'Irrigation System', 'Pakistan', 500000);
Update the budget for the 'Irrigation System' project in Pakistan to 750000.
UPDATE RuralInfrastructure SET budget = 750000 WHERE project = 'Irrigation System' AND country = 'Pakistan';
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleSafetyRatings (ID INT, Model VARCHAR(255), Manufacturer VARCHAR(255), SafetyRating FLOAT); INSERT INTO VehicleSafetyRatings (ID, Model, Manufacturer, SafetyRating) VALUES (1, 'EcoCar', 'Green Motors', 4.8), (2, 'HyperHybrid', 'Blue Cars', 4.6), (3, 'SolarSedan', 'FutureAutomobiles', 4.9);
What is the safety rating of the 'HyperHybrid' model?
SELECT SafetyRating FROM VehicleSafetyRatings WHERE Model = 'HyperHybrid';
gretelai_synthetic_text_to_sql
CREATE TABLE service_providers (id INT, service_type VARCHAR(255), quantity INT); INSERT INTO service_providers (id, service_type, quantity) VALUES (1, 'sign_language_interpreters', 5), (2, 'assistive_technology_specialists', 10), (3, 'disability_counselors', 8), (4, 'accessibility_consultants', 6);
Count the number of sign language interpreters in the "service_providers" table
SELECT COUNT(*) FROM service_providers WHERE service_type = 'sign_language_interpreters';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_projects_2 (project_id INT, project_name TEXT, country TEXT, capacity_mw FLOAT); INSERT INTO wind_projects_2 (project_id, project_name, country, capacity_mw) VALUES (1, 'Wind Farm A', 'South Africa', 100.5), (2, 'Wind Farm B', 'Egypt', 250.3);
What is the maximum and minimum capacity (in MW) of wind power projects in Africa?
SELECT country, MAX(capacity_mw), MIN(capacity_mw) FROM wind_projects_2;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(10), Name VARCHAR(20), Type VARCHAR(20), Cargo_Capacity FLOAT); INSERT INTO Vessels (ID, Name, Type, Cargo_Capacity) VALUES ('1', 'Vessel A', 'Cargo', 10000.0), ('2', 'Vessel B', 'Tanker', 15000.0); CREATE TABLE Registry (ID VARCHAR(10), Vessel_ID VARCHAR(10), Registered_Country VARCHAR...
What is the total cargo capacity of vessels registered in Spain?
SELECT SUM(Cargo_Capacity) FROM Vessels INNER JOIN Registry ON Vessels.ID = Registry.Vessel_ID WHERE Registered_Country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthBudget (ID INT, Service VARCHAR(255), Budget INT); INSERT INTO HealthBudget (ID, Service, Budget) VALUES (1, 'Primary Health Care', 7000000), (2, 'Secondary Health Care', 9000000), (3, 'Tertiary Health Care', 11000000);
What is the maximum budget allocated to any public service in the health sector?
SELECT MAX(Budget) FROM HealthBudget WHERE Service LIKE 'Health%'
gretelai_synthetic_text_to_sql
CREATE TABLE Gadolinium_Market_Prices (id INT, year INT, country VARCHAR(20), market_price DECIMAL(10,2));
What is the minimum market price of Gadolinium in India over the past 3 years?
SELECT MIN(market_price) FROM Gadolinium_Market_Prices WHERE country = 'India' AND year BETWEEN 2020 AND 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, hotel_name TEXT, city TEXT); INSERT INTO eco_hotels (hotel_id, hotel_name, city) VALUES (1, 'EcoHotel Sydney', 'Sydney'), (2, 'GreenHotel Melbourne', 'Melbourne'), (3, 'SustainableSuites Sydney', 'Sydney');
List all eco-friendly hotels in Sydney and Melbourne.
SELECT hotel_name, city FROM eco_hotels WHERE city IN ('Sydney', 'Melbourne');
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country VARCHAR(50), trial_year INT, PRIMARY KEY (country, trial_year)); INSERT INTO clinical_trials (country, trial_year) VALUES ('Asia', 2017);
How many clinical trials were conducted in 'Asia' in 2017?
SELECT COUNT(*) FROM clinical_trials WHERE country = 'Asia' AND trial_year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE paris_agreement (country VARCHAR(255), paris_agreement BOOLEAN); INSERT INTO paris_agreement (country, paris_agreement) VALUES ('France', TRUE), ('Germany', TRUE), ('UK', TRUE), ('Italy', TRUE), ('Spain', TRUE), ('Brazil', FALSE), ('Russia', FALSE), ('India', TRUE), ('China', TRUE), ('US', FALSE); CREATE T...
What is the total installed capacity of wind energy in countries that have ratified the Paris Agreement?
SELECT SUM(capacity) FROM wind_energy WHERE country IN (SELECT country FROM paris_agreement WHERE paris_agreement = TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE strains (strain_id INT, name VARCHAR(255), type VARCHAR(255), organic BOOLEAN); INSERT INTO strains (strain_id, name, type, organic) VALUES (9, 'Blueberry OG', 'Hybrid', true); CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (9, 'Earth...
What was the total revenue from 'Organic' strains sold in 'Earthly Delights' dispensary in Q4 2022?
SELECT SUM(price * quantity) FROM sales INNER JOIN inventory ON sales.inventory_id = inventory.inventory_id INNER JOIN strains ON inventory.strain_id = strains.strain_id WHERE organic = true AND type = 'Organic' AND dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Earthly Delights') AND sale_date B...
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learning_programs (program_id INT, country VARCHAR(50), year INT); INSERT INTO lifelong_learning_programs (program_id, country, year) VALUES (1, 'USA', 2022), (2, 'Canada', 2021), (3, 'Mexico', 2022), (4, 'Brazil', 2021), (5, 'USA', 2022), (6, 'UK', 2022), (7, 'Germany', 2021), (8, 'France', 2022)...
How many lifelong learning programs were offered in each country in 2021?
SELECT country, COUNT(*) as program_count FROM lifelong_learning_programs WHERE year = 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE factories_energy (id INT, name VARCHAR(50), location VARCHAR(50), energy_source VARCHAR(50), energy_efficiency_rating INT); INSERT INTO factories_energy (id, name, location, energy_source, energy_efficiency_rating) VALUES (1, 'Factory A', 'New York', 'solar', 85), (2, 'Factory B', 'California', 'wind', 70)...
Display the name, location, and energy source of factories that have a higher energy efficiency rating than 80
SELECT name, location, energy_source FROM factories_energy WHERE energy_efficiency_rating > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE Esports_Events (event_id INT, event_name VARCHAR(255), game_type VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Esports_Events (event_id, event_name, game_type, start_date, end_date) VALUES (1, 'ESL One', 'MOBA', '2022-01-01', '2022-01-05'), (2, 'DreamHack', 'FPS', '2022-02-01', '2022-02-06'), ...
Show all events that are not 'MOBA' or 'RPG' related
SELECT * FROM Esports_Events WHERE game_type NOT IN ('MOBA', 'RPG');
gretelai_synthetic_text_to_sql
CREATE TABLE WarehouseManagement (id INT, customer VARCHAR(255), revenue FLOAT, region VARCHAR(255), half INT, year INT);
What is the total revenue generated from warehouse management for customers in the Middle East in H2 2022?
SELECT SUM(revenue) FROM WarehouseManagement WHERE region = 'Middle East' AND half = 2 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_gender TEXT);CREATE TABLE funding (id INT, company_id INT, amount INT); INSERT INTO company (id, name, industry, founder_gender) VALUES (1, 'TransporTech', 'Transportation', 'Male'), (2, 'GreenWheels', 'Transportation', 'Female'); INSERT INTO funding (id, ...
How many companies have received funding in the transportation sector, broken down by founder gender?
SELECT founder_gender, COUNT(*) FROM company INNER JOIN funding ON company.id = funding.company_id WHERE industry = 'Transportation' GROUP BY founder_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_incidents (id INT, type VARCHAR(255), location VARCHAR(255), year INT, volume FLOAT);INSERT INTO pollution_incidents (id, type, location, year, volume) VALUES (1, 'oil spill', 'Gulf of Mexico', 2005, 400000), (2, 'chemical leak', 'Atlantic Ocean', 2015, 1000), (3, 'oil spill', 'Mediterranean Sea'...
Delete all records in the 'pollution_incidents' table where the incident type is 'oil spill' and the incident occurred before 2010.
DELETE FROM pollution_incidents WHERE type = 'oil spill' AND year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Researchers (id INT, name VARCHAR(100), organization VARCHAR(100), expertise VARCHAR(100), publications INT); INSERT INTO Researchers (id, name, organization, expertise, publications) VALUES (1, 'Jane Smith', 'Arctic Research Institute', 'Climate Change', 12); INSERT INTO Researchers (id, name, organizatio...
What are the names of researchers at the Arctic Research Institute who specialize in climate change and have more than 10 publications?
SELECT DISTINCT name FROM Researchers WHERE expertise = 'Climate Change' AND publications > 10 AND organization = 'Arctic Research Institute'
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (id INT, title VARCHAR(50), galleryId INT, year INT, value INT, artistId INT, artist VARCHAR(50)); INSERT INTO ArtPieces (id, title, galleryId, year, value, artistId, artist) VALUES (1, 'Piece 1', 1, 2000, 10000, 1, 'Pablo'), (2, 'Piece 2', 1, 2010, 15000, 2, 'Dali'), (3, 'Piece 3', 2, 2020, 2000...
Update the value of art pieces by artist 'Pablo' by 5%
UPDATE ArtPieces SET value = value * 1.05 WHERE artistId = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE, currency VARCHAR(50));
Which customers have made transactions in both EUR and USD currencies in the past year?
SELECT c.name FROM customers c INNER JOIN transactions t1 ON c.customer_id = t1.customer_id AND t1.currency = 'EUR' INNER JOIN transactions t2 ON c.customer_id = t2.customer_id AND t2.currency = 'USD' WHERE t1.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND t2.transaction_date >= DATE_SUB(CURRENT_DATE, ...
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (fabric_type VARCHAR(50), year INT, month INT, co2_emissions DECIMAL(4,2), country VARCHAR(50));
What is the average monthly CO2 emissions for linen fabric in South Korea in 2022?
SELECT AVG(co2_emissions) as avg_monthly_co2_emissions FROM emissions WHERE fabric_type = 'linen' AND country = 'South Korea' AND year = 2022 GROUP BY fabric_type, country, year;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE, product_organic BOOLEAN, product_local BOOLEAN);
Show customer preferences for organic and locally sourced items as a percentage of their total orders.
SELECT c.customer_name, (SUM(CASE WHEN o.product_organic THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) as organic_percentage, (SUM(CASE WHEN o.product_local THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) as local_percentage FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_name;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, program_id INT, donation_date DATE); INSERT INTO donations (id, donor_id, program_id, donation_date) VALUES (1, 101, 4, '2022-01-01'), (2, 102, 4, '2022-02-01'), (3, 103, 3, '2022-03-01'); CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VA...
How many donations were made in the last month for the 'Arts' program?
SELECT COUNT(d.id) as donations_last_month FROM donations d WHERE d.program_id = 4 AND d.donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE units (id INT, city VARCHAR, build_year INT, rent DECIMAL);
What is the average rent for properties built after 2015 in Tokyo?
SELECT AVG(rent) FROM units WHERE city = 'Tokyo' AND build_year > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Gender VARCHAR(10), GameGenre VARCHAR(20));INSERT INTO Players (PlayerID, Gender, GameGenre) VALUES (1, 'Female', 'RPG');
What are the unique game genres played by female players?
SELECT DISTINCT GameGenre FROM Players WHERE Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'France'), (2, 30, 'Female', 'Germany'), (3, 22, 'Male', 'France'); CREATE TABLE GameTypes (GameID INT, GameName VARCHAR(20), Type VARCHAR(20)); INSERT INTO ...
What is the average age of players who play VR games in France?
SELECT AVG(Players.Age) FROM Players JOIN PlayerGames ON Players.PlayerID = PlayerGames.PlayerID JOIN GameTypes ON PlayerGames.GameID = GameTypes.GameID WHERE Players.Country = 'France' AND GameTypes.Type = 'VR';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(50), model VARCHAR(50), date_purchased DATE);
Delete all records from the 'equipment' table where the 'equipment_type' is 'Sequencer'
WITH cte1 AS (DELETE FROM equipment WHERE equipment_type = 'Sequencer') SELECT * FROM cte1;
gretelai_synthetic_text_to_sql
CREATE TABLE artists_watercolor (artist_id INT, name VARCHAR(50), medium VARCHAR(50), pieces INT);
What is the total number of pieces created by artists who have used watercolor as a medium?
SELECT SUM(pieces) FROM artists_watercolor WHERE medium = 'watercolor';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, program_id INT, name VARCHAR(50)); INSERT INTO volunteers (id, program_id, name) VALUES (1, 1, 'Alice'); INSERT INTO volunteers (id, program_id, name) VALUES (2, 1, 'Bob'); INSERT INTO volunteers (id, program_id, name) VALUES (3, 2, 'Charlie'); INSERT INTO volunteers (id, program_id, na...
Show the number of volunteers for each program, sorted by the number of volunteers in descending order
SELECT program_id, COUNT(*) as num_volunteers FROM volunteers GROUP BY program_id ORDER BY num_volunteers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), area_size FLOAT, region VARCHAR(255), country VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, area_size, region, country) VALUES (1, 'Great Barrier Reef', 344400, 'Pacific', 'Australia');
List all countries with marine protected areas in the Pacific Ocean that are larger than 50000 square kilometers.
SELECT DISTINCT country FROM marine_protected_areas WHERE region = 'Pacific' AND area_size > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_name VARCHAR(50), rating INT, design_elements VARCHAR(100)); INSERT INTO games (game_id, game_name, rating, design_elements) VALUES (1, 'GameA', 9, 'action, RPG, puzzle'), (2, 'GameB', 10, 'RPG, adventure, simulation'), (3, 'GameC', 9, 'strategy, simulation, FPS'), (4, 'GameD', 8, ...
How many unique game design elements are present in games with a rating of 9 or higher?
SELECT COUNT(DISTINCT trimmed_design_elements) FROM (SELECT REGEXP_SPLIT_TO_TABLE(design_elements, ',') AS trimmed_design_elements FROM games WHERE rating >= 9) AS split_design_elements;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (site_id INT, site_name TEXT, country TEXT, local_impact INT); INSERT INTO heritage_sites (site_id, site_name, country, local_impact) VALUES (1, 'Cultural Heritage Site 1', 'Egypt', 200000), (2, 'Cultural Heritage Site 2', 'Egypt', 250000);
What is the minimum local economic impact of cultural heritage sites in Egypt?
SELECT MIN(local_impact) FROM heritage_sites WHERE country = 'Egypt';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation FLOAT, quarter TEXT, year INT); INSERT INTO Donors (id, name, country, donation, quarter, year) VALUES (1, 'Charlie', 'USA', 100.0, 'Q2', 2021), (2, 'David', 'Mexico', 150.0, 'Q2', 2021), (3, 'Eve', 'Canada', 75.0, 'Q2', 2021), (4, 'Frank', 'USA', 200.0, 'Q...
What is the maximum donation amount made by donors from each country in Q2 2021?
SELECT country, MAX(donation) FROM Donors WHERE quarter = 'Q2' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50), Safety_Inspections INT, Engine_Capacity INT); INSERT INTO Vessels (ID, Name, Type, Safety_Inspections, Engine_Capacity) VALUES (1, 'MV Pegasus', 'Cargo Ship', 0, 4500), (2, 'MV Pisces', 'Passenger Ship', 1, 2000);
Display the vessel names, engine capacities, and safety inspection status for vessels that have not had any safety inspections or have an engine capacity greater than 4000, excluding passenger ships?
SELECT Name, Engine_Capacity, Safety_Inspections FROM Vessels WHERE Safety_Inspections = 0 OR Engine_Capacity > 4000 AND Type != 'Passenger Ship';
gretelai_synthetic_text_to_sql
CREATE TABLE species_measurements (species_id INT, measurement_date DATE);
Find the number of days since the first measurement for each species in the species_measurements table.
SELECT species_id, DATEDIFF(day, MIN(measurement_date) OVER (PARTITION BY species_id), measurement_date) FROM species_measurements;
gretelai_synthetic_text_to_sql
CREATE TABLE military_branch (id INT, name VARCHAR(255)); INSERT INTO military_branch (id, name) VALUES (1, 'Army'), (2, 'Navy'), (3, 'Air Force'); CREATE TABLE cyber_weapons (id INT, military_branch_id INT, size INT);
What is the average size of the cyber weapons stockpile for each military branch?
SELECT m.name, AVG(c.size) as avg_size FROM military_branch m JOIN cyber_weapons c ON m.id = c.military_branch_id GROUP BY m.id;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_management (service_id INT, service_name TEXT, city TEXT, state TEXT, cost INT); INSERT INTO waste_management (service_id, service_name, city, state, cost) VALUES (1, 'City of Houston Waste Services', 'Houston', 'Texas', 100000000); INSERT INTO waste_management (service_id, service_name, city, state,...
What is the total amount spent on waste management services in Texas, only considering cities with a population greater than 500,000?
SELECT SUM(cost) FROM waste_management WHERE state = 'Texas' AND city IN ('Houston', 'Dallas', 'San Antonio');
gretelai_synthetic_text_to_sql
CREATE TABLE bike_availability (location VARCHAR(20), day_of_week VARCHAR(10), bikes_available INT); INSERT INTO bike_availability (location, day_of_week, bikes_available) VALUES ('park1', 'Monday', 20), ('park1', 'Tuesday', 15), ('park2', 'Wednesday', 10);
What is the minimum number of bikes available in 'park2' on weekdays?
SELECT MIN(bikes_available) FROM bike_availability WHERE location = 'park2' AND day_of_week IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(100), Country varchar(50), DonationDate date); INSERT INTO Donors (DonorID, DonorName, Country, DonationDate) VALUES (1, 'John Doe', 'USA', '2021-01-01'), (2, 'Jane Smith', 'Canada', '2021-02-01'), (3, 'Ali Khan', 'Pakistan', '2021-03-01'), (4, 'Han Lee', 'South Korea...
How many donors from each country made donations in 2021?
SELECT Country, COUNT(*) as NumDonors FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE StateParks (state VARCHAR(50), park VARCHAR(50)); INSERT INTO StateParks (state, park) VALUES ('State1', 'ParkA'), ('State1', 'ParkB'), ('State2', 'ParkC'), ('State3', 'ParkD');
How many public parks are there in 'StateParks' table for each state?
SELECT state, COUNT(park) FROM StateParks GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); CREATE TABLE DonationEvents (EventID INT PRIMARY KEY, EventName VARCHAR(100), EventLocation VARCHAR(100), DonationID INT, FOREIGN KEY (DonationID) REFERENCES Donors(DonorID));
What is the total donation amount for 'Fundraising' events in 'New York' and 'Chicago'?
SELECT SUM(DonationAmount) as TotalDonationAmount FROM Donors d JOIN DonationEvents e ON d.DonorID = e.DonationID WHERE e.EventLocation IN ('New York', 'Chicago') AND e.EventName = 'Fundraising';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (industry TEXT, employment_rate FLOAT); INSERT INTO veteran_employment (industry, employment_rate) VALUES ('Technology', 85.3);
What is the employment rate for veterans in the technology sector?
SELECT employment_rate FROM veteran_employment WHERE industry = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), region VARCHAR(255), avg_depth FLOAT); INSERT INTO marine_protected_areas (name, region, avg_depth) VALUES ('Galapagos Marine Reserve', 'Pacific', 220.0), ('Great Barrier Reef', 'Pacific', 120.0);
What is the average depth of all marine protected areas in the Pacific region?
SELECT avg(avg_depth) FROM marine_protected_areas WHERE region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(20), destination VARCHAR(20), expenditure DECIMAL(10,2)); CREATE TABLE exchange_rates (country VARCHAR(20), currency VARCHAR(10), rate DECIMAL(10,2)); INSERT INTO exchange_rates (country, currency, rate) VALUES ('Canada', 'CAD', 1.0), ('Canada', 'USD', 1.3);
Find the total expenditure by Canadian tourists in Canadian Dollars in Toronto, given the exchange rate is 1.3?
SELECT SUM(expenditure * (SELECT rate FROM exchange_rates WHERE country = 'Canada' AND currency = 'CAD')) FROM tourism_stats WHERE visitor_country = 'Canada' AND destination = 'Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, region TEXT, cargo_weight_tonnes FLOAT); INSERT INTO ports VALUES (1, 'Port of Shanghai', 'Asia', 55000000), (2, 'Port of Singapore', 'Asia', 50000000), (3, 'Port of Shenzhen', 'Asia', 42000000), (4, 'Port of Ningbo-Zhoushan', 'Asia', 35000000), (5, 'Port of Hong Kong', ...
What is the average cargo weight handled by the top 5 ports in Asia?
SELECT AVG(cargo_weight_tonnes) FROM (SELECT cargo_weight_tonnes FROM ports WHERE region = 'Asia' ORDER BY cargo_weight_tonnes DESC LIMIT 5) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, data_usage FLOAT, plan_type VARCHAR(10), region VARCHAR(20), subscriber_date DATE); INSERT INTO subscribers (subscriber_id, data_usage, plan_type, region, subscriber_date) VALUES (1, 8.5, 'postpaid', 'Northeast', '2020-01-01'); INSERT INTO subscribers (subscriber_id, data_us...
Find the monthly trend in mobile data usage for the top 5 regions with the most subscribers, for the last 2 years.
SELECT region, EXTRACT(MONTH FROM subscriber_date) as month, AVG(data_usage) as avg_data_usage, RANK() OVER (ORDER BY AVG(data_usage) DESC) as region_rank FROM subscribers WHERE subscriber_date >= DATEADD(year, -2, CURRENT_DATE) GROUP BY region, EXTRACT(MONTH FROM subscriber_date) HAVING region_rank <= 5 ORDER BY regio...
gretelai_synthetic_text_to_sql
CREATE TABLE agri_innovation (country VARCHAR(50), project VARCHAR(50), investment FLOAT); INSERT INTO agri_innovation (country, project, investment) VALUES ('Mexico', 'Precision Agriculture', 500000), ('Brazil', 'GMO Research', 800000), ('Colombia', 'Organic Farming', 300000), ('Peru', 'Irrigation Systems', 700000), (...
What was the maximum and minimum investment in agricultural innovation projects in 2020?
SELECT MIN(investment) as min_investment, MAX(investment) as max_investment FROM agri_innovation WHERE YEAR(project) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50), start_year INT); INSERT INTO students (id, name, department, start_year) VALUES (1, 'Charlie', 'Mathematics', 2018); INSERT INTO students (id, name, department, start_year) VALUES (2, 'Dana', 'Computer Science', 2019); CREATE TABLE publications (i...
Count the number of publications by graduate students in the Mathematics department in the last 5 years.
SELECT COUNT(p.id) FROM publications p JOIN students s ON p.student_id = s.id WHERE s.department = 'Mathematics' AND p.year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE shared_scooters (scooter_id INT, city VARCHAR(20)); INSERT INTO shared_scooters (scooter_id, city) VALUES (1, 'Berlin'), (2, 'Berlin'), (3, 'Paris'), (4, 'Paris');
Delete all shared scooters in Berlin.
DELETE FROM shared_scooters WHERE city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE Preservation_Programs (Program_ID INT PRIMARY KEY, Name VARCHAR(100), Country VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Preservation_Programs (Program_ID, Name, Country, Budget) VALUES (1, 'Swahili Language Program', 'Tanzania', 50000.00); INSERT INTO Preservation_Programs (Program_ID, Name, Country,...
What is the budget for each language preservation program?
SELECT Name, Budget FROM Preservation_Programs;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (hotel_category VARCHAR(20), revenue DECIMAL(10,2), date DATE); INSERT INTO hotel_revenue (hotel_category, revenue, date) VALUES ('5 Star', 15000, '2022-01-01'), ('5 Star', 16000, '2022-01-02'), ('4 Star', 12000, '2022-01-01'), ('4 Star', 12500, '2022-01-02');
What is the total revenue for each hotel category in Q1 2022?
SELECT hotel_category, SUM(revenue) as total_revenue FROM hotel_revenue WHERE date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY hotel_category;
gretelai_synthetic_text_to_sql
CREATE TABLE public_services (id INT PRIMARY KEY, service VARCHAR(255), location VARCHAR(255), budget DECIMAL(10, 2), provider VARCHAR(255)); CREATE TABLE citizen_feedback (id INT PRIMARY KEY, city VARCHAR(255), age INT, feedback TEXT); CREATE TABLE public_feedback (id INT PRIMARY KEY, city VARCHAR(255), service VARCHA...
List all public services, their budget allocations, and corresponding citizen feedback ratings, if any.
SELECT p.service, p.budget, pf.rating FROM public_services p LEFT JOIN public_feedback pf ON p.service = pf.service;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_ME (city VARCHAR(50), usage INT); INSERT INTO water_usage_ME (city, usage) VALUES ('Cairo', 12000), ('Istanbul', 8000);
What is the total water usage in Cairo and Istanbul?
SELECT SUM(usage) FROM water_usage_ME WHERE city IN ('Cairo', 'Istanbul');
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tours (tour_id INT, operator_id INT, location VARCHAR, num_tourists INT); CREATE VIEW americas_sustainable_tours AS SELECT * FROM sustainable_tours WHERE location LIKE '%%America%%';
Identify the top 2 most popular sustainable tour destinations in the Americas.
SELECT location, SUM(num_tourists) AS total_tourists FROM americas_sustainable_tours GROUP BY location ORDER BY total_tourists DESC LIMIT 2;
gretelai_synthetic_text_to_sql