context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE energy_consumption (country text, source text, year integer, consumption integer);
What was the total energy consumption of the top 5 renewable energy sources, by country, in 2018?
SELECT country, source, SUM(consumption) as total_consumption FROM energy_consumption WHERE year = 2018 AND source IN ('Solar', 'Wind', 'Hydro', 'Geothermal', 'Biomass') GROUP BY country ORDER BY total_consumption DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, size INT, country VARCHAR(255)); INSERT INTO properties (id, size, country) VALUES (1, 1500, 'Spain'), (2, 2000, 'Spain'), (3, 1800, 'Spain');
What is the 3rd largest property size in Spain?
SELECT size FROM (SELECT size, ROW_NUMBER() OVER (ORDER BY size DESC) as rn FROM properties WHERE country = 'Spain') t WHERE rn = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, employee_name VARCHAR(255), department VARCHAR(255)); CREATE TABLE accommodations (accommodation_id INT, employee_id INT, accommodation_type VARCHAR(255), request_date DATE); INSERT INTO employees (employee_id, employee_name, department) VALUES (1, 'Jane Smith', 'HR'), (2, 'John...
Who are the top 5 employees with the most disability accommodations requests?
SELECT e.employee_name, COUNT(a.employee_id) as num_requests FROM employees e INNER JOIN accommodations a ON e.employee_id = a.employee_id GROUP BY e.employee_name ORDER BY num_requests DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName text); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'Alice Johnson'), (2, 'Bob Smith'), (3, 'Carol Brown');
What is the number of unique donors and volunteers for each organization, ordered by the number of total contributions?
SELECT OrganizationID, ROW_NUMBER() OVER (ORDER BY DonorCount + VolunteerCount DESC) as Rank, DonorCount, VolunteerCount FROM (SELECT OrganizationID, COUNT(DISTINCT DonorID) as DonorCount, COUNT(DISTINCT VolunteerID) as VolunteerCount FROM Volunteers JOIN Donations ON Volunteers.DonorID = Donations.DonorID JOIN Donatio...
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholder (PolicyholderID INT, PolicyholderAge INT, PolicyholderGender VARCHAR(10)); CREATE TABLE Claim (ClaimID INT, PolicyholderID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Policyholder VALUES (1, 45, 'Female'), (2, 55, 'Male'), (3, 30, 'Female'); INSERT INTO Claim VALUES (1, 1, 5000), (2, 1, 3000)...
Find the total claim amount for each gender?
SELECT PolicyholderGender, SUM(ClaimAmount) as TotalClaimAmount FROM Claim JOIN Policyholder ON Claim.PolicyholderID = Policyholder.PolicyholderID GROUP BY PolicyholderGender;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, organization VARCHAR(255), result VARCHAR(10), duration INT); INSERT INTO space_missions (id, organization, result, duration) VALUES (1, 'NASA', 'successful', 120), (2, 'SpaceX', 'successful', 200), (3, 'ESA', 'unsuccessful', 150), (4, 'NASA', 'successful', 180), (5, 'SpaceX', 'unsu...
What is the average duration of successful space missions for each organization?
SELECT organization, AVG(duration) FROM space_missions WHERE result = 'successful' GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (id INT, name VARCHAR(50), is_organic BOOLEAN, supplier_id INT); INSERT INTO ingredients (id, name, is_organic, supplier_id) VALUES (1, 'Kale', TRUE, 101), (2, 'Quinoa', TRUE, 101), (3, 'Eggs', FALSE, 102), (4, 'Garlic', TRUE, 103); CREATE TABLE suppliers (id INT, name VARCHAR(50)); INSERT INTO...
Find suppliers offering the most variety of organic ingredients
SELECT s.name, COUNT(DISTINCT i.name) FROM ingredients i INNER JOIN suppliers s ON i.supplier_id = s.id WHERE i.is_organic = TRUE GROUP BY s.name ORDER BY COUNT(DISTINCT i.name) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name TEXT); CREATE TABLE cases (case_id INT, attorney_id INT);
How many cases did each attorney work on, grouped by attorney name?
SELECT a.name, COUNT(c.attorney_id) AS case_count FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id GROUP BY a.name
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (id INT, community_name VARCHAR(255), region VARCHAR(255)); INSERT INTO indigenous_communities (id, community_name, region) VALUES (1, 'Community A', 'arctic_circle'), (2, 'Community B', 'canada'), (3, 'Community C', 'greenland'), (4, 'Community D', 'arctic_circle');
List all indigenous communities in the 'arctic_circle' region.
SELECT community_name FROM indigenous_communities WHERE region = 'arctic_circle';
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk_assessments (id INT, region VARCHAR(255), assessment_year INT, assessment_text TEXT); INSERT INTO geopolitical_risk_assessments (id, region, assessment_year, assessment_text) VALUES (1, 'South America', 2018, 'Assessment 3'); INSERT INTO geopolitical_risk_assessments (id, region, assessme...
Find the number of geopolitical risk assessments for the South American region in the year 2018.
SELECT COUNT(*) FROM geopolitical_risk_assessments WHERE region = 'South America' AND assessment_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, location VARCHAR(50), capacity INT); INSERT INTO factories (factory_id, location, capacity) VALUES (1, 'Madrid, Spain', 5000), (2, 'Paris, France', 7000), (3, 'London, UK', 6000);
How many factories are there in total?
SELECT COUNT(*) FROM factories;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Gender VARCHAR(50), Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Gender, Salary) VALUES (1, 'John Doe', 'Male', 75000.00), (2, 'Jane Smith', 'Female', 80000.00), (3, 'Mike Johnson', 'Male', 60000.00);
What is the difference in average salary between male and female employees?
SELECT (AVG(CASE WHEN Gender = 'Male' THEN Salary ELSE NULL END) - AVG(CASE WHEN Gender = 'Female' THEN Salary ELSE NULL END)) AS salary_difference;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, name VARCHAR(50), region VARCHAR(20), program_type VARCHAR(30)); INSERT INTO programs (program_id, name, region, program_type) VALUES (1, 'Financial Education', 'East', 'Financial Capability'), (2, 'Credit Counseling', 'West', 'Debt Management');
What is the percentage of financial capability programs offered in the East region?
SELECT region, (COUNT(*) FILTER (WHERE program_type = 'Financial Capability')) * 100.0 / COUNT(*) AS percentage FROM programs GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (country VARCHAR(100), threat_level VARCHAR(20), quarter VARCHAR(10));
Compare threat levels for 'USA' and 'Canada' in Q2 2022
SELECT country, threat_level FROM threat_intelligence WHERE country IN ('USA', 'Canada') AND quarter = 'Q2 2022';
gretelai_synthetic_text_to_sql
CREATE TABLE region (region_id INT, name VARCHAR(255)); INSERT INTO region (region_id, name) VALUES (1, 'west_africa'); CREATE TABLE shelter (shelter_id INT, name VARCHAR(255), region_id INT, capacity INT); INSERT INTO shelter (shelter_id, name, region_id, capacity) VALUES (1, 'Shelter1', 1, 50), (2, 'Shelter2', 1, 75)...
What is the maximum capacity of a shelter in 'west_africa' region?
SELECT MAX(capacity) FROM shelter WHERE region_id = (SELECT region_id FROM region WHERE name = 'west_africa');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetic_sales (product_id INT, sale_volume INT, market VARCHAR(10)); CREATE TABLE product_info (product_id INT, is_natural BOOLEAN); INSERT INTO product_info (product_id, is_natural) VALUES (1, true), (2, false), (3, true); INSERT INTO cosmetic_sales (product_id, sale_volume, market) VALUES (1, 200, 'ME')...
What is the total sales volume for natural cosmetics in the Middle Eastern market?
SELECT SUM(cs.sale_volume) FROM cosmetic_sales cs JOIN product_info pi ON cs.product_id = pi.product_id WHERE pi.is_natural = true AND cs.market = 'ME';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents (incident_id INT, incident_date DATE, ai_subfield TEXT, incident_description TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_date, ai_subfield, incident_description) VALUES (1, '2020-01-01', 'Explainable AI', 'Model failed to provide clear explanations'); INSERT INTO ai_sa...
What is the total number of AI safety incidents reported for each AI subfield in the first half of 2021?
SELECT ai_subfield, COUNT(*) as incidents FROM ai_safety_incidents WHERE incident_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY ai_subfield;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_tools (tool_id INT, tool_name VARCHAR(50), region VARCHAR(50), rating FLOAT); INSERT INTO ai_tools (tool_id, tool_name, region, rating) VALUES (1, 'AITSG1', 'APAC', 4.3), (2, 'AITSG2', 'EMEA', 4.6), (3, 'AITSG3', 'AMER', 4.5);
Which regions have the highest and lowest rated AI tools?
SELECT region, MAX(rating) as max_rating, MIN(rating) as min_rating FROM ai_tools GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Garment (garment_id INT PRIMARY KEY, garment_name VARCHAR(50), category VARCHAR(50), price DECIMAL(10,2)); INSERT INTO Garment (garment_id, garment_name, category, price) VALUES (1, 'Cotton T-Shirt', 'Tops', 20.00), (2, 'Jeans Pants', 'Bottoms', 40.00), (3, 'Linen Blouse', 'Tops', 30.00);
Delete the garment records with a price less than 20.00 or greater than 40.00 in the Garment table.
DELETE FROM Garment WHERE price < 20.00 OR price > 40.00;
gretelai_synthetic_text_to_sql
CREATE TABLE Port (port_id INT PRIMARY KEY, port_name VARCHAR(255)); INSERT INTO Port (port_id, port_name) VALUES (1, 'Seattle'); CREATE TABLE Vessel_Movement (vessel_id INT, movement_date DATE, port_id INT, speed DECIMAL(5,2), PRIMARY KEY (vessel_id, movement_date));
What was the average speed of vessels visiting port Seattle in the fourth quarter of 2020?
SELECT AVG(speed) FROM Vessel_Movement VM JOIN Port P ON VM.port_id = P.port_id WHERE P.port_name = 'Seattle' AND EXTRACT(MONTH FROM VM.movement_date) BETWEEN 10 AND 12 AND EXTRACT(YEAR FROM VM.movement_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (id INTEGER, method TEXT, interpretability_score REAL, last_updated TIMESTAMP);
Insert a new record into the explainable_ai table with method set to 'SHAP', interpretability_score set to 0.9, and last_updated set to the current timestamp
INSERT INTO explainable_ai (method, interpretability_score, last_updated) VALUES ('SHAP', 0.9, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name TEXT, location TEXT); INSERT INTO marine_protected_areas (area_name, location) VALUES ('Area 1', 'Caribbean Sea'), ('Area 2', 'Mediterranean Sea'), ('Area 3', 'Caribbean Sea'), ('Area 4', 'Indian Ocean');
How many marine protected areas are in the Caribbean sea?
SELECT COUNT(*) FROM marine_protected_areas WHERE location = 'Caribbean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO economic_diversification (id, name, type, budget) VALUES (1, 'Handicraft Training', 'Economic Diversification', 50000.00), (2, 'Eco-tourism Development', 'Economic Diversification', 120000.00);
What are the types of economic diversification projects in the 'economic_diversification' table?
SELECT DISTINCT type FROM economic_diversification WHERE type = 'Economic Diversification';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_orbits (id INT, satellite_id VARCHAR(50), orbit_type VARCHAR(20), orbital_speed FLOAT);
What is the maximum orbital speed (in km/s) of all satellites in the Geostationary orbit?
SELECT MAX(orbital_speed) FROM satellite_orbits WHERE orbit_type = 'Geostationary';
gretelai_synthetic_text_to_sql
CREATE TABLE Forwarders (id INT, name VARCHAR(255)); CREATE TABLE Shipments (id INT, forwarder_id INT, shipped_date DATE, delivered_date DATE, delay INT);
Find the total number of delayed shipments for each freight forwarder in the last month?
SELECT f.name, SUM(CASE WHEN s.delay > 0 THEN 1 ELSE 0 END) as total_delayed FROM Forwarders f JOIN Shipments s ON f.id = s.forwarder_id WHERE shipped_date >= DATEADD(month, -1, GETDATE()) GROUP BY f.id, f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, state VARCHAR(20)); CREATE TABLE workout_data (id INT, user_id INT, date DATE, calories INT);
What is the total calories burned by users living in New York on Tuesdays?
SELECT SUM(calories) FROM workout_data w JOIN users u ON w.user_id = u.id WHERE u.state = 'New York' AND DAYOFWEEK(w.date) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, price DECIMAL(10,2), country VARCHAR(50), concert_date DATE);
Identify the top 3 countries with the highest concert ticket sales in Q2 of 2022, ordered by sales amount.
SELECT country, SUM(price) as total_sales FROM ticket_sales WHERE EXTRACT(MONTH FROM concert_date) BETWEEN 4 AND 6 GROUP BY country ORDER BY total_sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.cargo (id INT, cargo_type VARCHAR(255), arrived_at DATE);
Insert new cargo records for 'rare earth minerals' with IDs 300, 301, and 302, arrived at port on Jun 15, 2022, Jun 16, 2022, and Jun 17, 2022 respectively
INSERT INTO ocean_shipping.cargo (id, cargo_type, arrived_at) VALUES (300, 'rare earth minerals', '2022-06-15'), (301, 'rare earth minerals', '2022-06-16'), (302, 'rare earth minerals', '2022-06-17');
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ai (hotel TEXT, ai BOOLEAN); INSERT INTO hotel_ai (hotel, ai) VALUES ('Hotel Marrakech', true), ('Hotel Cairo', false), ('Hotel Capetown', true), ('Hotel Alexandria', false), ('Hotel Tunis', true); CREATE TABLE hotels_africa (hotel TEXT, region TEXT); INSERT INTO hotels_africa (hotel, region) VALUES ...
What is the percentage of hotels in 'Africa' that have adopted AI?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM hotels_africa)) AS percentage FROM hotel_ai WHERE ai = true AND region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE SCHEMA PrecisionFarming; CREATE TABLE IoT_Sensors (sensor_id INT, sensor_name VARCHAR(50), measurement VARCHAR(50)); INSERT INTO PrecisionFarming.IoT_Sensors (sensor_id, sensor_name, measurement) VALUES (1, 'Sensor1', 'temperature'), (2, 'Sensor2', 'humidity'), (4, 'Sensor4', 'moisture'), (5, 'Sensor5', 'moistur...
List the number of IoT sensors in the 'PrecisionFarming' schema that have a 'moisture' or 'temperature' measurement.
SELECT COUNT(*) FROM PrecisionFarming.IoT_Sensors WHERE measurement = 'moisture' OR measurement = 'temperature';
gretelai_synthetic_text_to_sql
CREATE TABLE claim (claim_id INT, processed_by VARCHAR(50)); INSERT INTO claim VALUES (1, 'Laura Smith'); INSERT INTO claim VALUES (2, 'Maria Silva');
Which claims were processed by the claims adjuster 'Maria Silva'?
SELECT claim_id FROM claim WHERE processed_by = 'Maria Silva';
gretelai_synthetic_text_to_sql
CREATE TABLE ad_interactions (id INT, user_id INT, timestamp TIMESTAMP);
Insert new ad interactions for user with ID 1111
INSERT INTO ad_interactions (user_id) VALUES (1111), (1111), (1111);
gretelai_synthetic_text_to_sql
CREATE TABLE Album (AlbumID INT, AlbumName VARCHAR(50), ReleaseYear INT, ArtistID INT); CREATE TABLE Artist (ArtistID INT, ArtistName VARCHAR(50)); INSERT INTO Album (AlbumID, AlbumName, ReleaseYear, ArtistID) VALUES (1, 'Fearless', 2008, 1), (2, 'Red', 2012, 1), (3, 'Map of the Soul: Persona', 2019, 2), (4, 'BE', 2020...
What is the release year of the most recent album for each artist?
SELECT ArtistName, ReleaseYear, ROW_NUMBER() OVER (PARTITION BY ArtistID ORDER BY ReleaseYear DESC) AS Rank FROM Album JOIN Artist ON Album.ArtistID = Artist.ArtistID;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), amount INT, year INT); INSERT INTO production (country, amount, year) VALUES ('Myanmar', 5000, 2018); INSERT INTO production (country, amount, year) VALUES ('Myanmar', 5500, 2019); INSERT INTO production (country, amount, year) VALUES ('Myanmar', 6000, 2020);
How many tons of REEs were produced by Myanmar between 2018 and 2020?
SELECT SUM(amount) as total_production FROM production WHERE country = 'Myanmar' AND year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, department VARCHAR(20));CREATE TABLE workers (worker_id INT, company_id INT, salary DECIMAL(5,2), position VARCHAR(20));
What is the average salary of workers in the 'mining' department across all companies?
SELECT AVG(salary) FROM workers w INNER JOIN companies c ON w.company_id = c.company_id WHERE department = 'mining';
gretelai_synthetic_text_to_sql
CREATE TABLE Tournaments (Game VARCHAR(50), TournamentName VARCHAR(50), PrizePool INT); INSERT INTO Tournaments (Game, TournamentName, PrizePool) VALUES ('CS:GO', 'EL Major 2022', 500000); INSERT INTO Tournaments (Game, TournamentName, PrizePool) VALUES ('Dota 2', 'The International 2022', 40000000); INSERT INTO Tourna...
Identify players who have not participated in any tournament with a prize pool over 5 million.
SELECT Players.PlayerName, Players.Game FROM Players LEFT JOIN Tournaments ON Players.Game = Tournaments.Game WHERE Tournaments.PrizePool < 5000000 OR Tournaments.TournamentName IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (event_date DATE, region VARCHAR(255)); INSERT INTO defense_diplomacy (event_date, region) VALUES ('2020-01-01', 'Europe'), ('2021-01-01', 'Asia'), ('2020-06-01', 'Africa');
Find the number of defense diplomacy events in each region
SELECT region, COUNT(*) as total_events FROM defense_diplomacy GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (name, depth) VALUES ('Galapagos Islands', 2000.0), ('Grand Bahama Bank', 800.0);
Update the depth of the 'Galapagos Islands' in the marine_protected_areas table to 1500 meters.
UPDATE marine_protected_areas SET depth = 1500 WHERE name = 'Galapagos Islands';
gretelai_synthetic_text_to_sql
CREATE TABLE causes (cause_id INT, name VARCHAR(255), category VARCHAR(255));
List the 'Social Services' causes that received the most donations in H1 2022, along with their total donation amounts.
SELECT c.name, SUM(d.donation_amount) as total_donated FROM donations d JOIN causes c ON d.cause = c.name WHERE d.donation_date BETWEEN '2022-01-01' AND '2022-06-30' AND c.category = 'Social Services' GROUP BY c.name ORDER BY total_donated DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorRegistry (donorID INT, donationDate DATE, donationAmount DECIMAL(10,2)); INSERT INTO DonorRegistry (donorID, donationDate, donationAmount) VALUES (1, '2022-03-02', 150.50), (2, '2022-03-15', 200.00), (3, '2022-03-27', 125.75);
What is the total donation amount received from all donors in the last month?
SELECT SUM(donationAmount) FROM DonorRegistry WHERE donationDate >= '2022-03-01' AND donationDate <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Missions (MissionID INT, Name VARCHAR(50), LaunchDate DATETIME, CrewGender VARCHAR(10)); INSERT INTO Missions (MissionID, Name, LaunchDate, CrewGender) VALUES (1, 'Artemis I', '2022-08-29', 'Male'), (2, 'Artemis II', '2023-06-01', 'Mixed'), (3, 'Artemis III', '2024-08-10', 'Female');
List all space missions that have had both male and female crew members.
SELECT Name FROM Missions WHERE CrewGender = 'Male' AND CrewGender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE student (id INT, name VARCHAR(255), department_id INT, research_area VARCHAR(255)); CREATE TABLE department (id INT, name VARCHAR(255), school VARCHAR(255));
What is the distribution of graduate students by research area in the School of Medicine?
SELECT d.name, s.research_area, COUNT(s.id) as count FROM student s JOIN department d ON s.department_id = d.id WHERE d.school = 'School of Medicine' GROUP BY d.name, s.research_area;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_surface_temperatures (id INT, location TEXT, temperature FLOAT, region TEXT);
What is the minimum temperature recorded at ocean surface in the Southern Ocean?
SELECT MIN(temperature) FROM ocean_surface_temperatures WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists humanitarian_aid (id INT, project_name VARCHAR(100), location VARCHAR(100), amount FLOAT, date DATE); INSERT INTO humanitarian_aid (id, project_name, location, amount, date) VALUES (1, 'Flood Relief', 'Pakistan', 5000000, '2010-07-01'); INSERT INTO humanitarian_aid (id, project_name, location...
What is the rank of the humanitarian aid projects in Nigeria based on their costs?
SELECT project_name, location, amount, RANK() OVER(ORDER BY amount DESC) as rank FROM humanitarian_aid WHERE location = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (Name TEXT, Medical_Procedures TEXT); INSERT INTO Astronauts (Name, Medical_Procedures) VALUES ('John Glenn', 'Y'), ('Valentina Tereshkova', 'Y'), ('Neil Armstrong', 'checkup');
Update astronaut records with medical procedure 'Y' to procedure 'Z'
WITH updated_procedures AS (UPDATE Astronauts SET Medical_Procedures = 'Z' WHERE Medical_Procedures = 'Y') SELECT * FROM updated_procedures;
gretelai_synthetic_text_to_sql
CREATE TABLE natural_disasters (id INT, state VARCHAR(255), type VARCHAR(255), number_of_disasters INT); INSERT INTO natural_disasters (id, state, type, number_of_disasters) VALUES (1, 'Texas', 'Tornado', 30), (2, 'Texas', 'Flood', 40);
What is the most common type of natural disaster in Texas?
SELECT type, COUNT(*) AS count FROM natural_disasters WHERE state = 'Texas' GROUP BY type ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cricket_league (game_id INT, team_name VARCHAR(50), coach_gender VARCHAR(10)); CREATE VIEW cricket_league_won AS SELECT game_id, team_name FROM cricket_league WHERE result = 'win';
How many cricket games in the cricket_league table were won by teams that have a male coach?
SELECT COUNT(*) FROM cricket_league_won JOIN cricket_league ON cricket_league_won.team_name = cricket_league.team_name WHERE coach_gender = 'male';
gretelai_synthetic_text_to_sql
CREATE TABLE aquaculture_sites (site_id INT, region VARCHAR(50), farm_type VARCHAR(50), dissolved_oxygen FLOAT); INSERT INTO aquaculture_sites VALUES (1, 'Asia', 'Freshwater', 8.5), (2, 'Asia', 'Marine', 9.2), (3, 'Africa', 'Freshwater', 7.8), (4, 'Europe', 'Marine', 7.5);
What is the maximum dissolved oxygen level for aquaculture sites located in Asia, partitioned by farm type?
SELECT region, farm_type, MAX(dissolved_oxygen) AS max_dissolved_oxygen FROM aquaculture_sites WHERE region = 'Asia' GROUP BY region, farm_type;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, state VARCHAR(2), billing_amount DECIMAL(10,2)); INSERT INTO cases (id, state, billing_amount) VALUES (1, 'CA', 5000.00), (2, 'NY', 3000.00), (3, 'CA', 4000.00), (4, 'TX', 6000.00);
What is the total billing amount for cases in each state?
SELECT state, SUM(billing_amount) FROM cases GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE orders (id INT, dispensary_id INT, item_type TEXT, price DECIMAL, order_date DATE);
Which dispensaries in Washington have the highest total sales for concentrates this year?
SELECT d.name, SUM(o.price) as total_sales FROM dispensaries d INNER JOIN orders o ON d.id = o.dispensary_id WHERE d.state = 'Washington' AND o.item_type = 'concentrates' AND YEAR(o.order_date) = YEAR(CURRENT_DATE) GROUP BY d.name ORDER BY total_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investments (id INT, country VARCHAR(255), amount FLOAT, strategy_id INT);
Insert a new record of impact investment in Kenya with an amount of 2500000 and strategy_id 3.
INSERT INTO impact_investments (id, country, amount, strategy_id) VALUES (1, 'Kenya', 2500000, 3);
gretelai_synthetic_text_to_sql
CREATE TABLE production (production_id INT, material_id INT, quantity INT, country TEXT); CREATE TABLE materials (material_id INT, material_name TEXT, is_sustainable BOOLEAN); INSERT INTO production (production_id, material_id, quantity, country) VALUES (1, 1, 100, 'USA'), (2, 1, 200, 'USA'), (3, 2, 50, 'Canada'), (4, ...
What is the percentage of sustainable materials used in each country?
SELECT country, 100.0 * SUM(quantity) / (SELECT SUM(quantity) FROM production WHERE country = production.country) AS percentage FROM production JOIN materials ON production.material_id = materials.material_id WHERE is_sustainable = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE loans_issued (loan_id INT, issue_date DATE, loan_type VARCHAR(20)); INSERT INTO loans_issued (loan_id, issue_date, loan_type) VALUES (101, '2022-01-01', 'Shariah-compliant personal loan'), (102, '2022-04-01', 'Socially responsible auto loan'), (103, '2022-07-01', 'Shariah-compliant mortgage');
What is the total number of Shariah-compliant and socially responsible loans issued in each quarter?
SELECT DATE_FORMAT(issue_date, '%Y-%m') AS quarter, loan_type, COUNT(*) FROM loans_issued GROUP BY quarter, loan_type;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartContracts (id INT, name VARCHAR(255), transaction_count INT, transaction_date DATE); INSERT INTO SmartContracts (id, name, transaction_count, transaction_date) VALUES (1, 'ContractA', 10, '2021-11-01'), (2, 'ContractB', 5, '2021-11-02'), (3, 'ContractC', 15, '2021-11-03');
What is the maximum number of transactions per day for the smart contract with the id 2 in the month of November 2021?
SELECT MAX(transaction_count) FROM SmartContracts WHERE id = 2 AND transaction_date >= '2021-11-01' AND transaction_date < '2021-12-01';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (state VARCHAR(50), year INT, vehicle_type VARCHAR(50), sales INT);
How many hybrid vehicles were sold in 'California' from '2020' to '2022' in the 'sales_data' table?
SELECT SUM(sales) FROM sales_data WHERE vehicle_type = 'hybrid' AND state = 'California' AND year BETWEEN 2020 AND 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), department VARCHAR(50), country VARCHAR(50), hire_date DATE); INSERT INTO workers (id, name, department, country, hire_date) VALUES (1, 'John Doe', 'Human Resources', 'Canada', '2021-06-01');
Delete records in the "workers" table where the "department" is "Human Resources" and the "country" is "Canada" from the past 6 months
DELETE FROM workers WHERE department = 'Human Resources' AND country = 'Canada' AND hire_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE);
Delete records in the "player_scores" table where the score is below 500
DELETE FROM player_scores WHERE score < 500;
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT); CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT, animal_id INT); CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(50));
What is the total number of animals in habitats that are located in a specific region?
SELECT COUNT(DISTINCT animals.id) AS total_animals FROM animals INNER JOIN habitats ON animals.id = habitats.animal_id INNER JOIN regions ON habitats.location = regions.name WHERE regions.name = 'African Savannah';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (patient_id INT, age INT, gender VARCHAR(10), country VARCHAR(20)); CREATE TABLE rural_hospitals (patient_id INT, age INT, gender VARCHAR(10), admission_date DATE);
How many male patients are there in rural_hospitals and rural_clinics combined?
SELECT COUNT(*) FROM (SELECT patient_id FROM rural_clinics WHERE gender = 'Male' UNION ALL SELECT patient_id FROM rural_hospitals WHERE gender = 'Male') AS combined_male_patients;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Projects (Project_ID INT, Labor_Hours INT, Region TEXT); INSERT INTO Sustainable_Projects (Project_ID, Labor_Hours, Region) VALUES (1, 5000, 'Northeast'), (2, 7000, 'Midwest'), (3, 6000, 'West'); CREATE TABLE Non_Sustainable_Projects (Project_ID INT, Labor_Hours INT, Region TEXT); INSERT INTO N...
What is the total number of construction labor hours worked on sustainable projects, and how many labor hours were spent on non-sustainable projects in the same region?
SELECT SUM(Sustainable_Projects.Labor_Hours) AS Sustainable_Labor_Hours, SUM(Non_Sustainable_Projects.Labor_Hours) AS Non_Sustainable_Labor_Hours FROM Sustainable_Projects, Non_Sustainable_Projects WHERE Sustainable_Projects.Region = Non_Sustainable_Projects.Region;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_status (id INT, tech VARCHAR, status VARCHAR); INSERT INTO military_tech_status (id, tech, status) VALUES (1, 'Stealth Helicopter', 'Completed'), (2, 'AI-Powered Drone', 'In Progress'), (3, 'Electric Tank', 'Completed');
Display the military technologies and their development status, and determine the percentage of completed technologies.
SELECT tech, status, COUNT(*) OVER () * 100.0 / SUM(CASE WHEN status = 'Completed' THEN 1.0 ELSE 0.0 END) OVER () as pct_completed FROM military_tech_status WHERE status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genetech', 'California', 12000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'Zymergen', 'California', 25000000);
Which biotech startups have received funding over 10 million and are located in California?
SELECT name FROM startups WHERE funding > 10000000 AND location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE agriculture_data (region VARCHAR(50), rainfall INT, record_date DATE); INSERT INTO agriculture_data VALUES ('Central America', 100, '2022-01-01'); INSERT INTO agriculture_data VALUES ('Central America', 120, '2022-02-01'); INSERT INTO agriculture_data VALUES ('South America', 150, '2022-01-01'); INSERT INT...
What is the average rainfall per month for each region in the 'agriculture_data' table?
SELECT region, EXTRACT(MONTH FROM record_date) AS month, AVG(rainfall) AS avg_rainfall FROM agriculture_data GROUP BY region, month;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation (id INT, name TEXT, city TEXT, sustainable INT); INSERT INTO accommodation (id, name, city, sustainable) VALUES (1, 'Green Retreat', 'Sydney', 1); INSERT INTO accommodation (id, name, city, sustainable) VALUES (2, 'Eco Lodge', 'Melbourne', 1); INSERT INTO accommodation (id, name, city, sustai...
List all cities with more than 5 sustainable accommodations?
SELECT city, COUNT(*) as num_sustainable FROM accommodation WHERE sustainable = 1 GROUP BY city HAVING COUNT(*) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, vessel_name VARCHAR(50), fuel_efficiency DECIMAL(3,2));
Insert a new vessel with vessel_name 'Seacrest' and fuel_efficiency 5.2 into the vessel_performance table
INSERT INTO vessel_performance (vessel_name, fuel_efficiency) VALUES ('Seacrest', 5.2);
gretelai_synthetic_text_to_sql
CREATE TABLE communities (id INT, name VARCHAR(255)); INSERT INTO communities (id, name) VALUES (1, 'Community1'), (2, 'Community2'); CREATE TABLE applications (id INT, name VARCHAR(255), community_id INT, sector VARCHAR(255), published_date DATE); INSERT INTO applications (id, name, community_id, sector, published_dat...
Which underrepresented communities have contributed to the development of creative AI applications for the entertainment sector in the past two years, in the Creative AI database?
SELECT communities.name FROM communities JOIN applications ON communities.id = applications.community_id WHERE sector = 'Entertainment' AND YEAR(published_date) >= YEAR(CURRENT_DATE()) - 2 AND communities.name IN ('Community1', 'Community2');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), region VARCHAR(255), establishment_year INT); INSERT INTO marine_protected_areas (name, region, establishment_year) VALUES ('Azores Nature Park', 'Atlantic', 2011), ('Cape Verde Islands', 'Atlantic', 2014), ('Bermuda', 'Atlantic', 1966);
What is the total number of marine protected areas in the Atlantic region that were established after 2010?
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Atlantic' AND establishment_year > 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE fire_departments (id INT, department_name VARCHAR(50), location VARCHAR(50), population INT, average_response_time FLOAT);
What is the average response time for fire departments in urban areas with a population greater than 500,000?
SELECT AVG(average_response_time) FROM fire_departments WHERE population > 500000 AND location = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE diversion_referrals (id INT, program_category TEXT, defendant_ethnicity TEXT, referral_date DATE);
How many individuals have been referred to diversion programs in the past month, broken down by the program category and the defendant's ethnicity?
SELECT program_category, defendant_ethnicity, COUNT(*) FROM diversion_referrals WHERE referral_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY program_category, defendant_ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonationAmount decimal(10,2), CauseID int); CREATE TABLE Causes (CauseID int, CauseName varchar(50)); INSERT INTO Donors (DonorID, DonorName, DonationAmount, CauseID) VALUES (1, 'John Doe', 1000, 1), (2, 'Jane Smith', 2000, 2), (3, 'Mike Johnson', 3000, 3), (4, '...
What is the total amount donated to each cause?
SELECT c.CauseName, SUM(d.DonationAmount) as TotalDonationAmount FROM Donors d JOIN Causes c ON d.CauseID = c.CauseID GROUP BY c.CauseName;
gretelai_synthetic_text_to_sql
CREATE TABLE flu_cases (case_id INT, reported_date DATE, state VARCHAR(255)); INSERT INTO flu_cases VALUES (1, '2021-12-01', 'Florida'); INSERT INTO flu_cases VALUES (2, '2021-12-03', 'Florida');
What is the total number of flu cases reported in the last 30 days in Florida?
SELECT COUNT(*) FROM flu_cases WHERE state = 'Florida' AND reported_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2017, 'Lanthanum', 1500), (2018, 'Lanthanum', 1600), (2019, 'Lanthanum', 1700), (2020, 'Lanthanum', 1800);
What is the total production of Lanthanum in 2018 and 2019?
SELECT SUM(quantity) FROM production WHERE element = 'Lanthanum' AND year IN (2018, 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE program_donations (program VARCHAR(10), amount DECIMAL(10,2)); INSERT INTO program_donations (program, amount) VALUES ('ProgA', 5000.00), ('ProgA', 3000.00), ('ProgB', 7000.00);
What is the average amount of donations received by each program?
SELECT program, AVG(amount) FROM program_donations GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyInvestment (organization VARCHAR(50), year INT, investment FLOAT); INSERT INTO RenewableEnergyInvestment (organization, year, investment) VALUES ('Shell', 2010, 1500000), ('Shell', 2015, 2000000), ('BP', 2010, 1200000), ('BP', 2015, 1800000);
What is the total investment in renewable energy by each organization in Europe since 2010?
SELECT organization, SUM(investment) as 'Total Investment in Renewable Energy' FROM RenewableEnergyInvestment WHERE year >= 2010 AND continent = 'Europe' GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20), Country VARCHAR(50)); INSERT INTO Members (MemberID, Age, Gender, MembershipType, Country) VALUES (1, 35, 'Female', 'Premium', 'Japan'), (2, 45, 'Male', 'Basic', 'Canada'), (3, 28, 'Female', 'Premium', 'USA'), (4, 32, 'Male', '...
What is the maximum duration of a Pilates class attended by a member from Japan?
SELECT MAX(Duration) FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE Members.Country = 'Japan' AND Class = 'Pilates';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, billing_date DATE, billing_amount DECIMAL(10, 2)); INSERT INTO cases (case_id, billing_date, billing_amount) VALUES (1, '2021-01-01', 5000.00), (2, '2021-02-01', 7000.00), (3, '2021-03-01', 3000.00);
What is the total billing amount for cases in the last 3 months?
SELECT SUM(billing_amount) FROM cases WHERE billing_date >= (CURRENT_DATE - INTERVAL '3 months');
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_type VARCHAR(20)); INSERT INTO customers (customer_id, customer_type) VALUES (1, 'Retail'), (2, 'Wholesale'), (3, 'Institutional'); CREATE TABLE transactions (transaction_date DATE, customer_id INT, transaction_value DECIMAL(10, 2)); INSERT INTO transactions (transactio...
What is the number of transactions per day for the past week for customers in the 'Retail' customer type?
SELECT transactions.transaction_date, COUNT(transactions.transaction_id) as number_of_transactions FROM transactions JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND customers.customer_type = 'Retail' GROUP BY transactions....
gretelai_synthetic_text_to_sql
CREATE TABLE FoodJustice (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50)); INSERT INTO FoodJustice (id, name, location, type) VALUES (1, 'Fair Trade', 'North America', 'Food Justice');
List the food justices in North America.
SELECT * FROM FoodJustice WHERE location = 'North America' AND type = 'Food Justice';
gretelai_synthetic_text_to_sql
CREATE TABLE FishSpecies (SpeciesID int, SpeciesName varchar(50), WaterTemp float); INSERT INTO FishSpecies (SpeciesID, SpeciesName, WaterTemp) VALUES (1, 'Salmon', 12.5), (2, 'Tuna', 15.2), (3, 'Cod', 10.9);
What is the maximum water temperature recorded for each fish species?
SELECT SpeciesName, MAX(WaterTemp) as MaxTemp FROM FishSpecies GROUP BY SpeciesName;
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityImpact (id INT, impact_level TEXT); INSERT INTO CybersecurityImpact (id, impact_level) VALUES (1, 'High'), (2, 'Medium'), (3, 'Low'); CREATE TABLE CybersecurityIncidentsByYear (id INT, year INT, impact_id INT); INSERT INTO CybersecurityIncidentsByYear (id, year, impact_id) VALUES (1, 2021, 1),...
What is the total number of cybersecurity incidents reported worldwide each year for the last 3 years and their respective impact levels?
SELECT YEAR(CybersecurityIncidentsByYear.year) as year, COUNT(CybersecurityIncidentsByYear.id) as total_incidents, AVG(CybersecurityImpact.impact_level) as avg_impact FROM CybersecurityIncidentsByYear INNER JOIN CybersecurityImpact ON CybersecurityIncidentsByYear.impact_id = CybersecurityImpact.id GROUP BY YEAR(Cyberse...
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR, category VARCHAR, revenue INT); INSERT INTO Restaurants (id, name, category, revenue) VALUES (1, 'Bistro', 'French', 500000); INSERT INTO Restaurants (id, name, category, revenue) VALUES (2, 'Pizzeria', 'Italian', 600000); INSERT INTO Restaurants (id, name, category, reve...
Which restaurants have a revenue greater than $700,000?
SELECT name, revenue FROM Restaurants WHERE revenue > 700000;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, project_name TEXT, region TEXT, budget DECIMAL, status TEXT); INSERT INTO projects (id, project_name, region, budget, status) VALUES (1, 'Typhoon Relief', 'Pacific', 100000.00, 'completed'), (2, 'Flood Recovery', 'Pacific', 150000.00, 'cancelled'), (3, 'Earthquake Assistance', 'Pacific', ...
What is the total budget for disaster response projects in the Pacific, excluding those that were cancelled?
SELECT SUM(budget) as total_budget FROM projects WHERE region = 'Pacific' AND status != 'cancelled';
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_customers (customer_id INT, water_usage FLOAT, usage_date DATE); INSERT INTO industrial_customers (customer_id, water_usage, usage_date) VALUES (1, 500.3, '2022-02-01'), (2, 700.2, '2022-02-02'), (3, 0, '2022-02-03');
Find the total water usage by industrial customers in the month of February 2022, excluding any customers with a water usage of 0.
SELECT SUM(water_usage) FROM industrial_customers WHERE usage_date BETWEEN '2022-02-01' AND '2022-02-28' AND water_usage > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE site_safety (site_id INT, site_name TEXT, incident_date DATE, accident_type TEXT, accident_details TEXT); INSERT INTO site_safety (site_id, site_name, incident_date, accident_type, accident_details) VALUES (1, 'ABC Mine', '2021-03-15', 'Fire', 'Fire broke out in a mining tunnel'), (2, 'DEF Mine', '2021-02-...
How many accidents occurred at each mine site in H1 2021?
SELECT site_name, COUNT(*) as accidents_h1_2021 FROM site_safety WHERE incident_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, has_mental_health_disorder BOOLEAN, last_visit_date DATE); CREATE TABLE community_health_workers_visits (patient_id INT, visit_date DATE); INSERT INTO patients (id, has_mental_health_disorder, last_visit_date) VALUES (1, true, '2022-02-20'), (2, false, '2022-03-05'), (3, true, '2022-03-10...
What is the percentage of patients with mental health disorders who have had a community health worker visit in the past month?
SELECT (COUNT(*) FILTER (WHERE patients.has_mental_health_disorder = true AND community_health_workers_visits.visit_date >= (CURRENT_DATE - INTERVAL '1 month'))) * 100.0 / (SELECT COUNT(*) FROM patients WHERE has_mental_health_disorder = true) as percentage;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (id INT, country VARCHAR, region VARCHAR, level INT); INSERT INTO travel_advisories (id, country, region, level) VALUES (1, 'Ukraine', 'Europe', 4);
Which countries in Europe have the highest travel advisory level?
SELECT country FROM travel_advisories WHERE region = 'Europe' AND level = (SELECT MAX(level) FROM travel_advisories WHERE region = 'Europe');
gretelai_synthetic_text_to_sql
CREATE TABLE fines (fine_id INT, violation_type VARCHAR(20), fine INT, collection_date DATE); INSERT INTO fines (fine_id, violation_type, fine, collection_date) VALUES (1, 'Speeding', 200, '2022-01-15'), (2, 'Parking', 50, '2022-01-17'), (3, 'Speeding', 100, '2022-01-18');
What is the total fine collected, for each type of violation?
SELECT violation_type, SUM(fine) as total_fine FROM fines GROUP BY violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT); CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT); INSERT INTO Volunteers (VolunteerID, Name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); INSERT INTO VolunteerPrograms (VolunteerID, ProgramID) VALUES (1, 1), (2, 1), (3, 2);
How many volunteers are engaged in each program, based on the 'Volunteers' and 'VolunteerPrograms' tables?
SELECT VolunteerPrograms.ProgramID, COUNT(DISTINCT Volunteers.VolunteerID) as VolunteerCount FROM VolunteerPrograms INNER JOIN Volunteers ON VolunteerPrograms.VolunteerID = Volunteers.VolunteerID GROUP BY VolunteerPrograms.ProgramID;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_responses (id INT, incident_type VARCHAR(50), status VARCHAR(20), responded_by VARCHAR(100)); INSERT INTO incident_responses (id, incident_type, status, responded_by) VALUES (1, 'Phishing', 'Resolved', 'Security Analyst 1'), (2, 'Malware', 'In Progress', 'Security Analyst 2'), (3, 'Ransomware', 'R...
How many security incidents were resolved by 'Security Analyst 1' in the 'incident_responses' table?
SELECT COUNT(*) FROM incident_responses WHERE responded_by = 'Security Analyst 1' AND status = 'Resolved';
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO startups VALUES (1, 'StartupA', 'Healthcare', 2010, 'Female'); INSERT INTO startups VALUES (2, 'StartupB', 'Tech', 2015, 'Male');
What is the average funding amount received by startups founded by women in the healthcare sector?
SELECT AVG(funding_amount) FROM investments JOIN startups ON investments.startup_id = startups.id WHERE startups.founder_gender = 'Female' AND startups.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (mammal_id INT, mammal_name VARCHAR(255), PRIMARY KEY(mammal_id)); INSERT INTO marine_mammals (mammal_id, mammal_name) VALUES (1, 'Blue Whale'), (2, 'Fin Whale'); CREATE TABLE conservation_status (status_id INT, mammal_id INT, status VARCHAR(255), PRIMARY KEY(status_id, mammal_id), FOREIGN K...
What are the names of all the whale species in the Antarctic Ocean and their conservation status?
SELECT marine_mammals.mammal_name, conservation_status.status FROM marine_mammals INNER JOIN conservation_status ON marine_mammals.mammal_id = conservation_status.mammal_id INNER JOIN ocean_distribution ON marine_mammals.mammal_id = ocean_distribution.mammal_id WHERE ocean_distribution.region = 'Antarctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE bus_maintenance (id INT, bus_name VARCHAR(255), maintenance_date DATE); INSERT INTO bus_maintenance (id, bus_name, maintenance_date) VALUES (1, 'Bus 101', '2022-01-05'), (2, 'Bus 102', '2022-01-10');
What are the names of all the buses that have had maintenance work in the past month?
SELECT bus_name FROM bus_maintenance WHERE maintenance_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cities (city varchar(20)); INSERT INTO cities (city) VALUES ('melbourne'), ('rio de janeiro'); CREATE TABLE if not exists vehicle_counts (city varchar(20), vehicle_type varchar(20), count int); INSERT INTO vehicle_counts (city, vehicle_type, count) VALUES ('melbourne', 'electric', 1000), ('me...
What is the total number of electric and autonomous vehicles in 'melbourne' and 'rio de janeiro'?
SELECT city, SUM(count) as total_count FROM vehicle_counts WHERE (vehicle_type = 'electric' OR vehicle_type = 'autonomous') AND city IN ('melbourne', 'rio de janeiro') GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT PRIMARY KEY, account_id INT, type VARCHAR(255), amount DECIMAL(10,2), date DATE, client_id INT); INSERT INTO transactions (id, account_id, type, amount, date, client_id) VALUES (1, 1, 'Deposit', 2000.00, '2021-01-01', 1001), (2, 2, 'Withdrawal', 1500.00, '2021-02-10', 1002), (3, 3, 'Tr...
Calculate the total amount of transactions made in 'Los Angeles' in the month of March.
SELECT SUM(amount) FROM transactions WHERE date BETWEEN '2021-03-01' AND '2021-03-31' AND client_id IN (SELECT id FROM clients WHERE city = 'Los Angeles');
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (country TEXT, year INT); INSERT INTO deep_sea_expeditions (country, year) VALUES ('USA', 2010), ('USA', 2012), ('France', 2011), ('Japan', 2015), ('China', 2018), ('Germany', 2016), ('Spain', 2017), ('Canada', 2019), ('UK', 2013), ('Australia', 2014);
How many deep-sea expeditions have been conducted in each country?
SELECT country, COUNT(*) FROM deep_sea_expeditions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, dispensary TEXT, product TEXT, quantity INT, price DECIMAL); INSERT INTO sales (id, dispensary, product, quantity, price) VALUES (1, 'Rainbow Dispensary', 'Gorilla Glue', 4, 55.99);
Insert new sales data for 'Sunshine Dispensary'
INSERT INTO sales (id, dispensary, product, quantity, price) VALUES (2, 'Sunshine Dispensary', 'Blue Dream', 7, 42.00);
gretelai_synthetic_text_to_sql
CREATE TABLE public_schools (id INT, name TEXT, location TEXT, num_students INT, avg_teacher_age FLOAT); INSERT INTO public_schools (id, name, location, num_students, avg_teacher_age) VALUES (1, 'School 1', 'NC', 500, 45.3), (2, 'School 2', 'NC', 600, 43.2), (3, 'School 3', 'NC', 700, 47.1);
Update the average teacher age for public schools in a state to be the average of all schools in that state.
UPDATE public_schools SET avg_teacher_age = (SELECT AVG(avg_teacher_age) FROM public_schools AS s WHERE public_schools.location = s.location) WHERE TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE artist (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE album (id INT PRIMARY KEY, title VARCHAR(255), year INT, artist_id INT, FOREIGN KEY (artist_id) REFERENCES artist(id)); INSERT INTO artist (id, name, country) VALUES (1, 'ArtistA', 'USA'), (2, 'ArtistB', 'USA'), (3, 'ArtistC...
Who are the top 3 music artists by number of albums in the US?
SELECT a.name, COUNT(al.id) AS albums_count FROM artist a JOIN album al ON a.id = al.artist_id GROUP BY a.id ORDER BY albums_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donors (id, name, country, amount_donated) VALUES (1, 'Alice', 'USA', 5000.00), (2, 'Bob', 'Canada', 3000.00), (3, 'Charlie', 'USA', 7000.00), (4, 'David', 'UK', 8000.00), (5, 'Eve', 'Germany', 9000.00);
List the names and countries of donors who have donated more than $5000, but less than $10000.
SELECT name, country FROM donors WHERE amount_donated > 5000.00 AND amount_donated < 10000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE ships (id INT, name VARCHAR(255), capacity INT); INSERT INTO ships (id, name, capacity) VALUES (1, 'Acme1', 5000), (2, 'Acme2', 7000);
Update the capacity of all cargo ships owned by Acme Corp by 10%
UPDATE ships SET capacity = capacity * 1.1 WHERE name LIKE 'Acme%';
gretelai_synthetic_text_to_sql