context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE investments(id INT, region VARCHAR(10), investment_date DATE, amount INT);
What is the total investment in network infrastructure in the Northeast region for the current year?
SELECT SUM(investments.amount) FROM investments WHERE investments.region = 'Northeast' AND YEAR(investments.investment_date) = YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE military_exercises (id INT PRIMARY KEY, name VARCHAR(100), host_country VARCHAR(50), start_month VARCHAR(20));
Add new record to military_exercises table, including 'Northern Edge' as name, 'USA' as host_country, and 'April' as start_month
INSERT INTO military_exercises (name, host_country, start_month) VALUES ('Northern Edge', 'USA', 'April');
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (ID INT, OperationName TEXT, OperationDate DATE, ParticipatingCountries TEXT); INSERT INTO PeacekeepingOperations VALUES (1, 'Operation 1', '2012-01-01', 'USA, UK, France');
Show all peacekeeping operations that have been conducted by the UN in the last decade, along with the number of participating countries.
SELECT OperationName, ParticipatingCountries, COUNT(DISTINCT SUBSTRING_INDEX(ParticipatingCountries, ',', n)) as NumberOfCountries FROM PeacekeepingOperations p CROSS JOIN (SELECT numbers.N FROM (SELECT 1 as N UNION ALL SELECT 2 UNION ALL SELECT 3) numbers) n WHERE OperationDate BETWEEN DATEADD(year, -10, GETDATE()) AN...
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty(FacultyID INT, Name VARCHAR(50), Department VARCHAR(50)); INSERT INTO Faculty VALUES (1, 'James Johnson', 'Humanities'); INSERT INTO Faculty VALUES (2, 'Sophia Williams', 'Humanities'); CREATE TABLE ResearchGrants(GrantsID INT, FacultyID INT, Year INT, Amount INT); INSERT INTO ResearchGrants VALUES...
Who are the faculty members in the Humanities department who have not received any research grants in the past 5 years?
SELECT F.Name FROM Faculty F LEFT JOIN ResearchGrants RG ON F.FacultyID = RG.FacultyID WHERE F.Department = 'Humanities' AND RG.Year < YEAR(CURRENT_DATE) - 5 AND RG.Year IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, size TEXT, quantity INT, sale_date DATE, country TEXT); INSERT INTO sales (id, product_id, size, quantity, sale_date, country) VALUES (1, 1001, 'XS', 25, '2021-09-01', 'USA'), (2, 1002, 'XXL', 30, '2021-09-15', 'Canada'), (3, 1003, 'M', 40, '2021-09-20', 'Mexico');
What is the total quantity of clothes sold in each country in the past month?
SELECT country, SUM(quantity) FROM sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE consumption (consumption_id INT, state VARCHAR(20), water_consumption FLOAT, consumption_date DATE); INSERT INTO consumption (consumption_id, state, water_consumption, consumption_date) VALUES (1, 'California', 500000.0, '2022-01-01'), (2, 'California', 600000.0, '2022-02-01'), (3, 'California', 700000.0, ...
What is the total water consumption in the state of California, broken down by month?
SELECT state, SUM(water_consumption) FROM consumption GROUP BY state, PERIOD_DIFF(consumption_date, DATE_FORMAT(consumption_date, '%Y%m')) * 100;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorCities (City VARCHAR(50), Population INT); INSERT INTO DonorCities (City, Population) VALUES ('New York', 8500000), ('Los Angeles', 4000000), ('Chicago', 2700000), ('Houston', 2300000), ('Phoenix', 1700000); CREATE TABLE DonationsByCity (City VARCHAR(50), DonationAmount DECIMAL(10,2)); INSERT INTO Don...
What is the average donation amount for the city with the highest donation amount?
SELECT AVG(DonationAmount) FROM DonationsByCity WHERE City = (SELECT City FROM DonationsByCity GROUP BY City ORDER BY SUM(DonationAmount) DESC LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name TEXT, region TEXT, year INT);CREATE TABLE infrastructure (id INT, name TEXT, region TEXT, year INT);CREATE TABLE projects (id INT, name TEXT, region TEXT, year INT);
What is the total number of farmers, rural infrastructure projects, and community development projects in 'rural_development' database, grouped by region and year?
SELECT region, year, COUNT(DISTINCT farmers.id) + COUNT(DISTINCT infrastructure.id) + COUNT(DISTINCT projects.id) FROM farmers FULL OUTER JOIN infrastructure ON farmers.region = infrastructure.region AND farmers.year = infrastructure.year FULL OUTER JOIN projects ON farmers.region = projects.region AND farmers.year = p...
gretelai_synthetic_text_to_sql
CREATE TABLE mangroves (id INT, name TEXT, area_size FLOAT, location TEXT); INSERT INTO mangroves (id, name, area_size, location) VALUES (1, 'Bonaire Mangroves', 1200, 'Caribbean');
What is the total area covered by mangroves in the Caribbean?"
SELECT SUM(area_size) FROM mangroves WHERE location = 'Caribbean';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_models (id INT PRIMARY KEY, model_name VARCHAR(50), model_type VARCHAR(50), fairness_score FLOAT); INSERT INTO ai_safety_models (id, model_name, model_type, fairness_score) VALUES (1, 'ModelX', 'Recommender', 0.87); INSERT INTO ai_safety_models (id, model_name, model_type, fairness_score) VALUES ...
Retrieve AI safety models with a fairness score less than 0.85.
SELECT * FROM ai_safety_models WHERE fairness_score < 0.85;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT, distance FLOAT, start_location VARCHAR(50), end_location VARCHAR(50));
Insert a new record into the "routes" table with the following data: "id" = 4, "distance" = 850km, "start_location" = "Sydney", "end_location" = "Melbourne"
INSERT INTO routes (id, distance, start_location, end_location) VALUES (4, 850, 'Sydney', 'Melbourne');
gretelai_synthetic_text_to_sql
CREATE TABLE news_programs (title VARCHAR(255), duration INT, air_date DATE);
Get the total duration of news programs in minutes for each day of the week.
SELECT air_date, SUM(duration) FROM news_programs WHERE title LIKE '%news%' GROUP BY air_date;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, is_cruelty_free BOOLEAN, price DECIMAL, country TEXT); INSERT INTO products (product_id, name, is_cruelty_free, price, country) VALUES (1, 'Lipstick', TRUE, 15.99, 'UK'); INSERT INTO products (product_id, name, is_cruelty_free, price, country) VALUES (2, 'Eye Shadow', T...
What is the total number of cruelty-free cosmetics sold in the United Kingdom and France?
SELECT COUNT(*) FROM products WHERE is_cruelty_free = TRUE AND (country = 'UK' OR country = 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE Stores (store_id INT, store_name VARCHAR(50), state VARCHAR(50)); INSERT INTO Stores (store_id, store_name, state) VALUES (1, 'Eco-Market', 'New York'), (2, 'Green Vista', 'Texas'); CREATE TABLE Inventory (product_id INT, product_name VARCHAR(50), store_id INT, price DECIMAL(5, 2)); INSERT INTO Inventory (...
Update the price of 'Solar-Powered Lamps' to $29.99 in stores located in 'New York' and 'Texas'
UPDATE Inventory SET price = 29.99 WHERE product_name = 'Solar-Powered Lamps' AND store_id IN (SELECT store_id FROM Stores WHERE state IN ('New York', 'Texas'));
gretelai_synthetic_text_to_sql
CREATE TABLE soccer_games(id INT, team VARCHAR(50), league VARCHAR(50), location VARCHAR(50), result VARCHAR(10), year INT); INSERT INTO soccer_games(id, team, league, location, result, year) VALUES (1, 'Paris Saint-Germain', 'Ligue 1', 'Parc des Princes', 'Win', 2019), (2, 'Paris Saint-Germain', 'Ligue 1', 'Parc des P...
How many home games did the Paris Saint-Germain win in Ligue 1 during the 2019-2020 season?
SELECT COUNT(*) FROM soccer_games WHERE team = 'Paris Saint-Germain' AND league = 'Ligue 1' AND location = 'Parc des Princes' AND result = 'Win' AND (year = 2019 OR year = 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intel (threat VARCHAR(50), severity VARCHAR(10)); INSERT INTO threat_intel (threat, severity) VALUES ('Ransomware', 'High'), ('Phishing', 'Medium'), ('Malware', 'High'), ('SQL Injection', 'Low');
What are the unique combinations of threat types and their corresponding severity levels in the threat_intel table, sorted alphabetically by the threat type?
SELECT threat, severity FROM threat_intel ORDER BY threat ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE ConstructionLaborers (id INT, name TEXT, state TEXT, hourlyWage FLOAT);
What is the average hourly wage for construction laborers in Illinois?
SELECT AVG(hourlyWage) FROM ConstructionLaborers WHERE state = 'Illinois';
gretelai_synthetic_text_to_sql
CREATE TABLE wnba_games (game_id INT, team1_score INT, team2_score INT, player_points INT);
Who scored the most points in the 2019 WNBA finals?
SELECT player_points FROM wnba_games WHERE game_id IN (SELECT max(game_id) FROM wnba_games WHERE (team1_score + team2_score) > 100 AND season = 'finals' AND season_year = 2019) ORDER BY player_points DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites_medearth (id INT, name VARCHAR(50), country VARCHAR(50), orbit VARCHAR(50), launch_date DATE); INSERT INTO satellites_medearth (id, name, country, orbit, launch_date) VALUES (1, 'Galileo FOC FM1', 'Europe', 'Medium Earth Orbit', '2011-10-12'); INSERT INTO satellites_medearth (id, name, country, ...
Which countries have launched the most satellites to Medium Earth Orbit?
SELECT country, COUNT(*) FROM satellites_medearth WHERE orbit = 'Medium Earth Orbit' GROUP BY country ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE AccessStaff (staff_id INT, department VARCHAR(255), role VARCHAR(255)); INSERT INTO AccessStaff (staff_id, department, role) VALUES (1, 'Student Support', 'Accessibility Coordinator'); INSERT INTO AccessStaff (staff_id, department, role) VALUES (2, 'Academic Affairs', 'Accessibility Specialist');
What is the total number of accessibility-related staff in each department?
SELECT department, COUNT(DISTINCT staff_id) as total_staff FROM AccessStaff WHERE role LIKE '%accessibility%' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (id INT, name VARCHAR(255)); CREATE TABLE menu_items (id INT, name VARCHAR(255), menu_id INT); INSERT INTO menus (id, name) VALUES (1, 'Breakfast'), (2, 'Lunch'), (3, 'Dinner'); INSERT INTO menu_items (id, name, menu_id) VALUES (1, 'Pancakes', 1), (2, 'Salad', 2), (3, 'Pizza', 3);
List all the food items that are not part of any menu?
SELECT mi.name FROM menu_items mi LEFT JOIN menus m ON mi.menu_id = m.id WHERE m.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), population INT, habitat VARCHAR(255));
Delete the record for the "Leatherback Sea Turtle" in the "species" table for the Indian Ocean
WITH deleted_record AS (DELETE FROM species WHERE name = 'Leatherback Sea Turtle' AND habitat = 'Indian Ocean') SELECT * FROM deleted_record;
gretelai_synthetic_text_to_sql
CREATE TABLE trainees (trainee_id INT, trainee_name VARCHAR(255)); CREATE TABLE trainings (training_id INT, trainee_id INT, training_hours INT, training_date DATE);
What is the total number of hours spent on legal technology training by each trainee?
SELECT trainee_name, SUM(training_hours) as total_hours FROM trainings JOIN trainees ON trainings.trainee_id = trainees.trainee_id GROUP BY trainee_name;
gretelai_synthetic_text_to_sql
CREATE TABLE industry_data (company_name VARCHAR(100), industry VARCHAR(50), funding_amount INT);
Show the top 5 industries with the highest average funding amounts
SELECT industry, AVG(funding_amount) as avg_funding FROM industry_data GROUP BY industry ORDER BY avg_funding DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE donation_dates (donation_date DATE, donor_id INT);
What is the total donation amount by each donor by month?
SELECT d.donor_name, DATE_FORMAT(dd.donation_date, '%Y-%m') AS donation_month, SUM(d.donation_amount) FROM donors d JOIN donation_dates dd ON d.donor_id = dd.donor_id GROUP BY donation_month, d.donor_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Soil (field VARCHAR(50), date DATE, moisture FLOAT); INSERT INTO Soil (field, date, moisture) VALUES ('Field D', '2022-05-01', 42.5), ('Field D', '2022-05-02', 45.6), ('Field D', '2022-05-03', 48.2);
What is the minimum soil moisture in field D in the last month?
SELECT MIN(moisture) FROM Soil WHERE field = 'Field D' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue (date DATE, revenue INT);
Update the 'revenue' column in the 'restaurant_revenue' table to $6000 for '2023-03-01'
UPDATE restaurant_revenue SET revenue = 6000 WHERE date = '2023-03-01';
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_id INT, organization VARCHAR(255), year INT); INSERT INTO deep_sea_expeditions (expedition_id, organization, year) VALUES (1, 'NOAA', 2018), (2, 'WHOI', 2019), (3, 'NASA', 2020), (4, 'NOAA', 2021), (5, 'WHOI', 2021);
How many deep-sea expeditions were conducted by each organization in the last 5 years?
SELECT organization, COUNT(*) as expeditions_in_last_5_years FROM deep_sea_expeditions WHERE year >= 2017 GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, Organic BOOLEAN, VendorID INT); INSERT INTO Vendors VALUES (1, 'VendorE', 'UK'), (2, 'VendorF', 'UK'), (3, 'VendorG', 'UK'); INSERT INTO Products VALUES (1, 'Carrot', 0.6, true, 1), ...
Identify the vendors with the lowest revenue from organic products.
SELECT v.VendorName FROM Vendors v JOIN Products p ON v.VendorID = p.VendorID WHERE p.Organic = true GROUP BY v.VendorID, v.VendorName HAVING SUM(Price) = (SELECT MIN(TotalPrice) FROM (SELECT SUM(Price) AS TotalPrice FROM Products p JOIN Vendors v ON p.VendorID = v.VendorID WHERE p.Organic = true GROUP BY v.VendorID) t...
gretelai_synthetic_text_to_sql
CREATE TABLE certifications (id INT, location TEXT, date DATE, certification_type TEXT); INSERT INTO certifications (id, location, date, certification_type) VALUES (1, 'Great Barrier Reef', '2022-03-01', 'Sustainable Tourism'), (2, 'Sydney Opera House', '2021-12-15', 'Sustainable Tourism');
How many sustainable tourism certifications were issued in Oceania in the past year?
SELECT COUNT(*) FROM certifications WHERE date >= DATEADD(year, -1, GETDATE()) AND location LIKE 'Oceania%' AND certification_type = 'Sustainable Tourism';
gretelai_synthetic_text_to_sql
CREATE TABLE Tech_For_Good (project_id INT, project_name VARCHAR(100), region VARCHAR(50), budget FLOAT); INSERT INTO Tech_For_Good (project_id, project_name, region, budget) VALUES (1, 'Project A', 'Asia', 45000.00), (2, 'Project B', 'Africa', 55000.00), (3, 'Project C', 'Asia', 65000.00);
What is the total budget for technology for social good projects in Asia?
SELECT SUM(budget) FROM Tech_For_Good WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE VRAdoption (PlayerID INT, VRDevice VARCHAR(50), GamesPlayed INT); INSERT INTO VRAdoption (PlayerID, VRDevice, GamesPlayed) VALUES (1, 'Oculus Quest', 150), (2, 'HTC Vive', 200), (3, 'Valve Index', 100);
Identify players who have adopted virtual reality technology, ordered by the number of games played in descending order.
SELECT PlayerID, VRDevice, GamesPlayed FROM VRAdoption ORDER BY GamesPlayed DESC
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, product TEXT, production_volume INT); INSERT INTO mines (id, name, location, product, production_volume) VALUES (1, 'Hamersley', 'Australia', 'Iron', 15000);
What is the minimum production volume of iron in Australia?
SELECT MIN(production_volume) FROM mines WHERE location = 'Australia' AND product = 'Iron';
gretelai_synthetic_text_to_sql
CREATE TABLE wholesale (id INT, wholesaler VARCHAR(255), product VARCHAR(255), price FLOAT, ounce_weight FLOAT); INSERT INTO wholesale (id, wholesaler, product, price, ounce_weight) VALUES (1, 'Wholesaler D', 'Concentrate', 400.0, 0.0625);
What is the average price per ounce of concentrate sold by Wholesaler D?
SELECT AVG(price / ounce_weight) FROM wholesale WHERE wholesaler = 'Wholesaler D' AND product = 'Concentrate';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT); INSERT INTO department (id, name) VALUES (1, 'textile'), (2, 'metalworking'), (3, 'electronics'); CREATE TABLE worker (id INT, salary REAL, department_id INT); INSERT INTO worker (id, salary, department_id) VALUES (1, 3000, 1), (2, 3500, 1), (3, 4000, 2), (4, 4500, 2), (5, 5...
What is the average salary of workers in the 'textile' department?
SELECT AVG(worker.salary) FROM worker INNER JOIN department ON worker.department_id = department.id WHERE department.name = 'textile';
gretelai_synthetic_text_to_sql
CREATE TABLE community (community_id INT, community_name VARCHAR(255)); INSERT INTO community (community_id, community_name) VALUES (1, 'CommunityA'), (2, 'CommunityB'); CREATE TABLE rainfall (year INT, community_id INT, rainfall FLOAT); INSERT INTO rainfall (year, community_id, rainfall) VALUES (2000, 1, 50), (2000, 2...
What is the average rainfall for each community?
SELECT community_id, AVG(rainfall) as avg_rainfall FROM rainfall GROUP BY community_id
gretelai_synthetic_text_to_sql
CREATE TABLE projects(id INT, name VARCHAR(50), lead_researcher VARCHAR(50), start_date DATE);INSERT INTO projects (id, name, lead_researcher, start_date) VALUES (1, 'ProjectX', 'Dr. Jane Smith', '2021-01-01');INSERT INTO projects (id, name, lead_researcher, start_date) VALUES (2, 'ProjectY', 'Dr. Maria Rodriguez', '20...
Which genetic research projects have Dr. Maria Rodriguez as the lead researcher and were initiated after 2019?
SELECT name FROM projects WHERE lead_researcher = 'Dr. Maria Rodriguez' AND start_date > '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Garments (GarmentID INT, GarmentName VARCHAR(50));CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50));CREATE TABLE DiscontinuedGarments (GarmentID INT, ManufacturerID INT, DiscontinuedDate DATE);
List the garments that were discontinued and the manufacturers responsible, excluding a specific manufacturer.
SELECT G.GarmentName, M.ManufacturerName FROM Garments G JOIN DiscontinuedGarments DG ON G.GarmentID = DG.GarmentID JOIN Manufacturers M ON DG.ManufacturerID = M.ManufacturerID WHERE M.ManufacturerName != 'GreenThreads';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(50), state VARCHAR(2), award_year INT, contract_value DECIMAL(10, 2)); INSERT INTO defense_contracts (contract_id, company_name, state, award_year, contract_value) VALUES (1, 'Lockheed Martin', 'CA', 2020, 5000000.00), (2, 'Raytheon', 'MA', 2020, 700...
How many defense contracts were awarded to companies located in California in 2020?
SELECT COUNT(*) FROM defense_contracts WHERE state = 'CA' AND award_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, therapy VARCHAR(10)); INSERT INTO patients (patient_id, therapy) VALUES (1, 'CBT'), (2, 'DBT'), (3, 'CBT'), (4, 'NA');
What is the total number of patients who received cognitive behavioral therapy (CBT) or dialectical behavior therapy (DBT) in the United States?
SELECT SUM(therapy = 'CBT' OR therapy = 'DBT') FROM patients;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_servings (serving_id INT, serviced_state VARCHAR(20), servicing_year INT); INSERT INTO legal_aid_servings (serving_id, serviced_state, servicing_year) VALUES (1, 'Texas', 2018), (2, 'Texas', 2019), (3, 'California', 2018);
How many individuals have been served by legal aid organizations in Texas since 2018?
SELECT COUNT(*) FROM legal_aid_servings WHERE serviced_state = 'Texas' AND servicing_year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(20), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Department, Gender, Salary, HireDate) VALUES (1, 'IT', 'Male', 70000, '2021-02-15'), (2, 'HR', 'Female', 60000, '2018-05-01'), (3, 'IT', 'Female', 75000, '2020-11-01'), (4...
What is the average salary of employees in the IT department who were hired after 2020-01-01?
SELECT AVG(Salary) FROM Employees WHERE Department = 'IT' AND HireDate > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, garment_id INT, size VARCHAR(10), quantity INT, date DATE); INSERT INTO sales (id, garment_id, size, quantity, date) VALUES (1, 1, 'S', 10, '2021-01-01'); INSERT INTO sales (id, garment_id, size, quantity, date) VALUES (2, 1, 'M', 15, '2021-01-01'); INSERT INTO sales (id, garment...
What is the maximum quantity sold for each size in each quarter?
SELECT date_trunc('quarter', date) AS quarter, size, MAX(quantity) FROM sales GROUP BY quarter, size;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_initiatives (initiative_id INT, initiative_name VARCHAR(50), co2_emissions_reduction DECIMAL(10, 2)); INSERT INTO climate_mitigation_initiatives (initiative_id, initiative_name, co2_emissions_reduction) VALUES (1, 'Green Energy Fund', 2500000.00), (2, 'Energy Efficiency Fund', 3000000.00...
What is the total CO2 emissions reduction achieved by climate mitigation initiatives globally?
SELECT SUM(co2_emissions_reduction) FROM climate_mitigation_initiatives WHERE initiative_name IN ('Green Energy Fund', 'Energy Efficiency Fund', 'Carbon Pricing');
gretelai_synthetic_text_to_sql
CREATE TABLE farm_stocking_density (farm_id INT, farm_type VARCHAR(255), stocking_density INT); INSERT INTO farm_stocking_density (farm_id, farm_type, stocking_density) VALUES (1, 'Pond', 1200), (2, 'Cage', 1500), (3, 'Recirculating', 2000), (4, 'Pond', 800), (5, 'Cage', 1200);
What is the maximum stocking density of fish in any farm type?
SELECT MAX(stocking_density) FROM farm_stocking_density;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels(id INT, name VARCHAR(50), country VARCHAR(50), speed FLOAT); INSERT INTO vessels(id, name, country, speed) VALUES (1, 'Vessel1', 'Japan', 25.3); INSERT INTO vessels(id, name, country, speed) VALUES (2, 'Vessel2', 'Japan', 27.1);
What is the average speed of vessels arriving from Japan to the US west coast?
SELECT AVG(speed) FROM vessels WHERE country = 'Japan' AND name IN ('Vessel1', 'Vessel2')
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (id INT, customer_id INT, size VARCHAR(255), transaction_value DECIMAL(10, 2)); INSERT INTO Transactions (id, customer_id, size, transaction_value) VALUES (1, 101, 'Plus', 150.50), (2, 102, 'Regular', 120.00), (3, 103, 'Plus', 175.25), (4, 104, 'Regular', 110.00);
What is the average transaction value for plus size customers compared to non-plus size customers?
SELECT AVG(CASE WHEN size = 'Plus' THEN transaction_value ELSE 0 END) as avg_transaction_plus_size, AVG(CASE WHEN size = 'Regular' THEN transaction_value ELSE 0 END) as avg_transaction_regular_size FROM Transactions;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT PRIMARY KEY, name TEXT, budget INT, status TEXT, city_id INT, FOREIGN KEY (city_id) REFERENCES city(id));
What is the total budget for all public works projects in the state of California?
SELECT SUM(budget) FROM project WHERE city_id IN (SELECT id FROM city WHERE state = 'CA') AND status = 'Open';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_unemployment (state TEXT, num_veterans INT, total_population INT); INSERT INTO veteran_unemployment VALUES ('California', 10000, 500000), ('Texas', 12000, 600000), ('New York', 8000, 400000);
What is the percentage of veteran unemployment in each state?
SELECT state, (num_veterans::DECIMAL(10,2) / total_population::DECIMAL(10,2)) * 100 AS veteran_unemployment_percentage FROM veteran_unemployment;
gretelai_synthetic_text_to_sql
CREATE TABLE police_calls (id INT, call_type VARCHAR(50), call_location VARCHAR(100), response_time INT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO police_calls (id, call_type, call_location, response_time, city, state) VALUES (1, 'Disturbance', '789 Oak St', 10, 'Detroit', 'MI');
What is the total number of police calls in the city of Detroit?
SELECT COUNT(*) FROM police_calls WHERE city = 'Detroit';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (id INT, name VARCHAR(50), location VARCHAR(20), project_type VARCHAR(30), budget FLOAT, completion_date DATE);
Show the total budget for each rural infrastructure project type, sorted by total budget
SELECT project_type, SUM(budget) as total_budget FROM RuralInfrastructure GROUP BY project_type ORDER BY total_budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_id INT, funding_source VARCHAR(255)); INSERT INTO deep_sea_expeditions (expedition_id, funding_source) VALUES (1, 'European Union'), (2, 'National Geographic'), (3, 'United Nations');
Identify the number of deep-sea expeditions funded by the European Union.
SELECT COUNT(*) FROM deep_sea_expeditions WHERE funding_source = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Projects (Project_ID INT, Project_Name VARCHAR(255), Cost FLOAT, Year INT, Location VARCHAR(255));
What is the total cost of all infrastructure projects in the Southeast region of the US for each year since 2015?
SELECT Year, SUM(Cost) FROM Infrastructure_Projects WHERE Location LIKE '%Southeast%' AND Year >= 2015 GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition_Daily_Attendance (exhibition_id INT, visit_date DATE, visitor_count INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(50)); INSERT INTO Exhibitions (id, name) VALUES (1, 'Modern Art'); ALTER TABLE Exhibition_Daily_Attendance ADD FOREIGN KEY (exhibition_id) REFERENCES Exhibitions(id);
What is the average number of visitors per day for the 'Modern Art' exhibition in 2019?
SELECT AVG(visitor_count) FROM Exhibition_Daily_Attendance WHERE exhibition_id = 1 AND visit_date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE maintenance_requests (request_id INT, service_branch VARCHAR(255), request_date DATE); INSERT INTO maintenance_requests (request_id, service_branch, request_date) VALUES (1, 'Air Force', '2019-10-01'), (2, 'Navy', '2019-12-02'), (3, 'Air Force', '2019-11-03');
How many military aircraft maintenance requests were recorded for the Air Force in Q4 2019?
SELECT COUNT(*) FROM maintenance_requests WHERE service_branch = 'Air Force' AND EXTRACT(QUARTER FROM request_date) = 4 AND EXTRACT(YEAR FROM request_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts_in_space (id INT, name VARCHAR(50), launch_date DATE, return_date DATE);
What is the maximum number of people in space at the same time?
SELECT COUNT(DISTINCT name) FROM astronauts_in_space WHERE return_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS NationalSecurity; CREATE TABLE IF NOT EXISTS NationalSecurity.National_Security_Events (event_id INT, event_name VARCHAR(255), start_date DATE, end_date DATE, category VARCHAR(255)); INSERT INTO NationalSecurity.National_Security_Events (event_id, event_name, start_date, end_date, category) ...
List all the national security events related to 'Energy' in the 'NationalSecurity' schema.
SELECT * FROM NationalSecurity.National_Security_Events WHERE category = 'Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(50), signup_date TIMESTAMP);
What's the number of new users who signed up in the last month in the 'gaming' schema?
SELECT COUNT(*) FROM users WHERE signup_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE OperationTypes (OperationTypeID INT, OperationType VARCHAR(50)); INSERT INTO OperationTypes (OperationTypeID, OperationType) VALUES (1, 'Drilling'), (2, 'Exploration'), (3, 'Extraction'); CREATE TABLE Operations (OperationID INT, OperationTypeID INT, WasteGeneration INT); INSERT INTO Operations (OperationI...
What is the maximum waste generation for each operation type?
SELECT OperationTypes.OperationType, MAX(Operations.WasteGeneration) FROM OperationTypes INNER JOIN Operations ON OperationTypes.OperationTypeID = Operations.OperationTypeID GROUP BY OperationTypes.OperationType;
gretelai_synthetic_text_to_sql
CREATE TABLE ice_thickness (id INT, year INT, thickness FLOAT); INSERT INTO ice_thickness (id, year, thickness) VALUES (1, 2005, 3.2), (2, 2015, 2.8);
List all ice thickness measurements in the 'ice_thickness' table for the year 2005.
SELECT * FROM ice_thickness WHERE year = 2005;
gretelai_synthetic_text_to_sql
CREATE TABLE Teams (team_id INT, conference VARCHAR(255)); INSERT INTO Teams (team_id, conference) VALUES (1, 'Eastern'), (2, 'Western'), (3, 'Eastern'), (4, 'Western'); CREATE TABLE Athletes (athlete_id INT, team_id INT, name VARCHAR(255), participations INT); INSERT INTO Athletes (athlete_id, team_id, name, participa...
What is the average wellbeing program participation for athletes in the Western Conference?
SELECT Teams.conference, AVG(Athletes.participations) FROM Athletes INNER JOIN Teams ON Athletes.team_id = Teams.team_id WHERE Teams.conference = 'Western' GROUP BY Teams.conference;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName TEXT, Location TEXT); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Location) VALUES (1, 'EcoFabrics', 'USA'), (2, 'GreenTextiles', 'India'), (3, 'SustainableFibers', 'Brazil'); CREATE TABLE FabricUsage (ManufacturerID INT, Year INT, Sustai...
What is the total quantity of sustainable fabrics used by each manufacturer in the year 2020?
SELECT ManufacturerName, SUM(SustainableFabricsQuantity) as TotalQuantity FROM FabricUsage JOIN Manufacturers ON FabricUsage.ManufacturerID = Manufacturers.ManufacturerID WHERE Year = 2020 GROUP BY ManufacturerName;
gretelai_synthetic_text_to_sql
CREATE TABLE SaltwaterSpecies (id INT, species VARCHAR(255), population INT); INSERT INTO SaltwaterSpecies (id, species, population) VALUES (1, 'Salmon', 50000); INSERT INTO SaltwaterSpecies (id, species, population) VALUES (2, 'Tuna', 30000); CREATE TABLE FreshwaterSpecies (id INT, species VARCHAR(255), population INT...
List the total number of aquatic species in the 'SaltwaterSpecies' and 'FreshwaterSpecies' tables
SELECT (SELECT COUNT(DISTINCT species) FROM SaltwaterSpecies) + (SELECT COUNT(DISTINCT species) FROM FreshwaterSpecies);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_date DATE, drug_id INT, quantity INT);
Insert a new sales record for DrugE with a random date in 2022
INSERT INTO sales (sale_date, drug_id, quantity) VALUES (DATE('2022-01-01') + INTERVAL FLOOR(RAND() * 365) DAY, (SELECT drug_id FROM drugs WHERE drug_name = 'DrugE'), 500)
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (revenue_id INT, album_id INT, country VARCHAR(50), timestamp TIMESTAMP, amount FLOAT); INSERT INTO revenue (revenue_id, album_id, country, timestamp, amount) VALUES (1, 501, 'France', '2022-01-01 00:00:00', 15.99), (2, 502, 'Germany', '2022-01-02 12:30:00', 12.99); CREATE TABLE albums (album_id IN...
What is the total revenue generated by Jazz albums in the European market since 2018?
SELECT SUM(amount) FROM revenue JOIN albums ON revenue.album_id = albums.album_id WHERE albums.genre = 'Jazz' AND revenue.country IN ('France', 'Germany', 'Spain', 'Italy', 'United Kingdom') AND revenue.timestamp >= '2018-01-01' AND revenue.timestamp < '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE the_seattle_star (title TEXT, publication_date DATE);
What is the total number of articles published in 'The Seattle Star' that contain the words 'climate crisis' or 'green energy' in the last year?
SELECT COUNT(*) FROM the_seattle_star WHERE (lower(title) LIKE '%climate crisis%' OR lower(title) LIKE '%green energy%') AND publication_date > DATE('now','-1 year');
gretelai_synthetic_text_to_sql
CREATE TABLE Ports (PortID INT, PortName VARCHAR(100), City VARCHAR(100), Country VARCHAR(100)); INSERT INTO Ports (PortID, PortName, City, Country) VALUES (1, 'Port of Los Angeles', 'Los Angeles', 'USA'); INSERT INTO Ports (PortID, PortName, City, Country) VALUES (2, 'Port of Rotterdam', 'Rotterdam', 'Netherlands'); ...
List the names of ports where ro-ro ships have docked.
SELECT Ports.PortName FROM Ports INNER JOIN Vessels ON Ports.PortID = Vessels.PortID WHERE Vessels.VesselType = 'Ro-Ro Ship';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, location TEXT, price DECIMAL(5,2)); INSERT INTO virtual_tours (tour_id, tour_name, location, price) VALUES (1, 'Mt. Fuji Tour', 'Japan', 0), (2, 'Gyeongbokgung Palace Tour', 'South Korea', 15.99);
Show the details of all virtual tours in Japan and South Korea that are free of charge.
SELECT * FROM virtual_tours WHERE location IN ('Japan', 'South Korea') AND price = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE ProduceSupplier (SupplierID INT, SustainabilityRating INT, UnitsPerWeek INT); INSERT INTO ProduceSupplier VALUES (1, 85, 550), (2, 70, 400), (3, 90, 600);
How many produce suppliers in the database have a sustainability rating greater than 80 and supply more than 500 units of fruits and vegetables per week?
SELECT COUNT(*) FROM ProduceSupplier WHERE SustainabilityRating > 80 AND UnitsPerWeek > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE ghg_emissions (continent VARCHAR(255), year INT, total_emissions INT); INSERT INTO ghg_emissions (continent, year, total_emissions) VALUES ('Africa', 2020, 1500), ('Asia', 2020, 20000), ('Europe', 2020, 8000), ('North America', 2020, 14000), ('South America', 2020, 3000), ('Oceania', 2020, 1500);
What is the percentage of global GHG emissions by continent in 2020?
SELECT continent, (total_emissions::DECIMAL(10,2)/SUM(total_emissions) OVER ())*100 AS emission_percentage FROM ghg_emissions WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE cs_applicants(id INT, gender TEXT, gre_score INT, is_domestic BOOLEAN); INSERT INTO cs_applicants(id, gender, gre_score, is_domestic) VALUES (1, 'female', 160, true), (2, 'male', 170, false);
What is the average GRE score for domestic female applicants to the Computer Science program?
SELECT AVG(gre_score) FROM cs_applicants WHERE is_domestic = true AND gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE local_impact_japan (city TEXT, sustainability_score INT, economic_impact INT); INSERT INTO local_impact_japan (city, sustainability_score, economic_impact) VALUES ('Tokyo', 7, 4000000), ('Tokyo', 8, 5000000);
What is the local economic impact of sustainable tourism in Tokyo?
SELECT economic_impact FROM local_impact_japan WHERE city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, circular_supply_chain BOOLEAN, price INT); INSERT INTO products VALUES (1, TRUE, 20), (2, FALSE, 15), (3, TRUE, 25);
What is the average price of products with a circular supply chain?
SELECT AVG(price) FROM products WHERE circular_supply_chain = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (site_id INT, site_name VARCHAR(50)); CREATE TABLE ExcavationTimeline (site_id INT, start_year INT, end_year INT); INSERT INTO ExcavationSites (site_id, site_name) VALUES (3, 'Machu Picchu'); INSERT INTO ExcavationTimeline (site_id, start_year, end_year) VALUES (3, 1911, 1915), (3, 1916, 19...
What was the total duration of excavations at the 'Machu Picchu' site?
SELECT SUM(DATEDIFF(year, start_year, end_year)) FROM ExcavationTimeline WHERE site_id = (SELECT site_id FROM ExcavationSites WHERE site_name = 'Machu Picchu');
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing_policies (policy_id INT, city VARCHAR(20)); INSERT INTO inclusive_housing_policies (policy_id, city) VALUES (1, 'Berkeley'), (2, 'Berkeley'), (3, 'San_Francisco');
List the number of inclusive housing policies for each city in the database.
SELECT city, COUNT(*) FROM inclusive_housing_policies GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT PRIMARY KEY, ProgramName VARCHAR(50), Budget DECIMAL(10,2)); CREATE TABLE Donations (DonationID INT PRIMARY KEY, DonationAmount DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 15000.00); INSERT INTO Programs (ProgramID, ProgramName, Budg...
Find the programs that have a larger budget than the average donation amount
SELECT ProgramName FROM Programs WHERE Budget > (SELECT AVG(DonationAmount) FROM Donations);
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, funding_source VARCHAR(255), country VARCHAR(255), amount FLOAT);
Insert new records into the 'climate_finance' table with the following details: (1, 'Bilateral', 'Kenya', 25000)
INSERT INTO climate_finance (id, funding_source, country, amount) VALUES (1, 'Bilateral', 'Kenya', 25000);
gretelai_synthetic_text_to_sql
CREATE TABLE transparency_measures (measure_id INT, measure_name VARCHAR(255), budget DECIMAL(10,2), state VARCHAR(255), region VARCHAR(255), implementation_date DATE); INSERT INTO transparency_measures (measure_id, measure_name, budget, state, region, implementation_date) VALUES (1, 'Measure A', 10000, 'Illinois', 'Mi...
What is the average budget allocated for transparency measures in the Midwest in the last 3 years?
SELECT AVG(budget) FROM transparency_measures WHERE region = 'Midwest' AND implementation_date >= DATEADD(year, -3, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, price DECIMAL(5,2)); INSERT INTO production VALUES ('Neodymium', 2015, 45.25), ('Neodymium', 2016, 48.75), ('Neodymium', 2017, 52.35), ('Neodymium', 2018, 56.10), ('Neodymium', 2019, 60.85), ('Neodymium', 2020, 65.20);
What is the average price of Neodymium per year?
SELECT AVG(price) FROM production WHERE element = 'Neodymium' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Suns'), (2, 'Clippers'); CREATE TABLE players (player_id INT, player_name VARCHAR(255), team_id INT); INSERT INTO players (player_id, player_name, team_id) VALUES (1, 'Devin Booker', 1), (2, 'Kawhi Leonard', 2);...
Which team has the highest total points scored in the current season?
SELECT teams.team_name, SUM(games.points) FROM teams INNER JOIN players ON teams.team_id = players.team_id INNER JOIN games ON players.player_id = games.player_id GROUP BY teams.team_name ORDER BY SUM(games.points) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Gender) VALUES (1, 25, 'Male'); INSERT INTO Players (PlayerID, Age, Gender) VALUES (2, 28, 'Female'); INSERT INTO Players (PlayerID, Age, Gender) VALUES (3, 31, 'Non-binary');
Delete the record with PlayerID 3 from the Players table.
DELETE FROM Players WHERE PlayerID = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_network (network_name VARCHAR(20), total_assets INT); INSERT INTO ethereum_network (network_name, total_assets) VALUES ('Ethereum', 3000);
What is the total number of digital assets on the Ethereum network?
SELECT total_assets FROM ethereum_network WHERE network_name = 'Ethereum';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, treatment_date DATE, country TEXT); INSERT INTO patients (id, treatment_date, country) VALUES (1, '2018-01-01', 'Brazil'); INSERT INTO patients (id, treatment_date, country) VALUES (2, '2017-12-31', 'USA');
How many patients have been treated in mental health facilities in Brazil since 2018?
SELECT COUNT(*) FROM patients WHERE country = 'Brazil' AND treatment_date >= '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, state VARCHAR(255), subscription_type VARCHAR(255)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, state, subscription_type) VALUES (1, 3.5, 'California', 'postpaid'), (2, 4.2, 'Texas', 'postpaid'), (3, 3.8, 'New York', 'prepaid'), (4, 4...
What is the average daily data usage for postpaid mobile subscribers in each state?
SELECT AVG(data_usage) AS avg_data_usage, state FROM mobile_subscribers WHERE subscription_type = 'postpaid' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_incidents (id INT, incident_type VARCHAR(255), response_team VARCHAR(255), incident_count INT); INSERT INTO emergency_incidents (id, incident_type, response_team, incident_count) VALUES (NULL, NULL, NULL, NULL);
Insert new records into the emergency_incidents table for the following incident_type, response_team, and incident_count: ('Flood', 'Team C', 12)?
INSERT INTO emergency_incidents (incident_type, response_team, incident_count) VALUES ('Flood', 'Team C', 12);
gretelai_synthetic_text_to_sql
CREATE TABLE Rail_Systems (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Rail_Systems (project_id, project_name, location) VALUES (1, 'Light Rail Construction', 'Massachusetts'); INSERT INTO Rail_Systems (project_id, project_name, location) VALUES (2, 'Subway Extension', 'New York');
How many projects are there in total in the 'Rail_Systems' table?
SELECT COUNT(*) FROM Rail_Systems;
gretelai_synthetic_text_to_sql
CREATE TABLE returns (id INT, item_id INT, returned_at DATETIME, country VARCHAR(255)); INSERT INTO returns (id, item_id, returned_at, country) VALUES (1, 1001, '2022-01-10', 'USA'), (2, 1002, '2022-02-05', 'Canada'), (3, 1003, '2022-03-01', 'Mexico');
What is the total number of items returned from customers in Canada?
SELECT COUNT(*) FROM returns WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE policy (policy_number INT, coverage_amount INT); INSERT INTO policy VALUES (1, 50000); INSERT INTO policy VALUES (2, 75000);
Update the coverage amount to 150000 for policy number 2.
UPDATE policy SET coverage_amount = 150000 WHERE policy_number = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, order_date DATE, customer_id INT, item_id INT, order_value DECIMAL, is_sustainable BOOLEAN);
What is the total order value for sustainable fashion items in a given time period?
SELECT SUM(order_value) FROM orders WHERE is_sustainable = TRUE AND order_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_projects (id INT, project VARCHAR(50), location VARCHAR(50), start_date DATE); INSERT INTO climate_adaptation_projects (id, project, location, start_date) VALUES (1, 'Mangrove Restoration', 'Southeast Asia', '2010-01-01'), (2, 'Coastal Flooding Protection', 'Southeast Asia', '2015-01-01'...
List all climate adaptation projects in Southeast Asia and their start dates
SELECT project, start_date FROM climate_adaptation_projects WHERE location = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (title VARCHAR(255), rating INT, production_country VARCHAR(50)); INSERT INTO movies (title, rating, production_country) VALUES ('Movie1', 8, 'USA'), ('Movie2', 7, 'Canada'), ('Movie3', 9, 'USA'), ('Movie4', 6, 'Canada');
What is the average rating of movies produced in the US and Canada?
SELECT AVG(rating) FROM movies WHERE production_country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_plants (plant_id INT, plant_name VARCHAR(50), location VARCHAR(50)); INSERT INTO manufacturing_plants (plant_id, plant_name, location) VALUES (1, 'Plant A', 'New York'); INSERT INTO manufacturing_plants (plant_id, plant_name, location) VALUES (2, 'Plant B', 'Chicago'); CREATE TABLE chemical_w...
What are the total chemical waste quantities produced by each manufacturing plant in the year 2020?
SELECT m.plant_name, SUM(cw.waste_quantity) AS total_waste_2020 FROM manufacturing_plants m JOIN chemical_waste cw ON m.plant_id = cw.plant_id WHERE cw.waste_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY m.plant_name;
gretelai_synthetic_text_to_sql
CREATE TABLE nba_games (team VARCHAR(255), played INTEGER);
Find the number of games played by each team in the "nba_games" table
SELECT team, COUNT(*) FROM nba_games GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (id INT, country TEXT, project_type TEXT, last_update DATE); INSERT INTO climate_projects (id, country, project_type, last_update) VALUES (1, 'Brazil', 'climate adaptation', '2020-01-01');
Which countries have not reported any climate adaptation projects in the last 5 years?
SELECT country FROM climate_projects WHERE project_type = 'climate adaptation' AND last_update >= DATE('2016-01-01') GROUP BY country HAVING COUNT(*) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE major_us_cities_waste_generation (city VARCHAR(20), waste_rate FLOAT, population INT);
Alter the major US cities waste generation table to include a third column for population.
ALTER TABLE major_us_cities_waste_generation ADD COLUMN population INT;
gretelai_synthetic_text_to_sql
CREATE VIEW recent_sensor_data AS SELECT * FROM sensor_data WHERE date > DATE_SUB(NOW(), INTERVAL 1 DAY);
Delete all records from the view "recent_sensor_data" where the "humidity" is greater than 80
DELETE FROM recent_sensor_data WHERE humidity > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE state_union_members (id INT, state VARCHAR(255), chapter VARCHAR(255), member_count INT); INSERT INTO state_union_members (id, state, chapter, member_count) VALUES (1, 'NY', 'NYC', 5000), (2, 'NY', 'Buffalo', 3500), (3, 'CA', 'LA', 7000), (4, 'CA', 'San Francisco', 5500), (5, 'CA', 'San Diego', 6000);
For each state, rank the union chapters by the number of members, with ties, and find the top 2 chapters.
SELECT state, chapter, RANK() OVER (PARTITION BY state ORDER BY member_count DESC) as rank FROM state_union_members;
gretelai_synthetic_text_to_sql
CREATE TABLE sessions (session_id INT, patient_id INT, condition VARCHAR(50), country VARCHAR(50), num_sessions INT); INSERT INTO sessions (session_id, patient_id, condition, country, num_sessions) VALUES (1, 10, 'Anxiety', 'Spain', 8), (2, 11, 'Anxiety', 'Spain', 12), (3, 12, 'Depression', 'Spain', 5);
What is the maximum number of psychotherapy sessions attended by patients with anxiety disorders in Spain?
SELECT MAX(num_sessions) FROM sessions WHERE country = 'Spain' AND condition = 'Anxiety';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (vehicle_type VARCHAR(10), inventory_location VARCHAR(10), quantity_on_hand INT);
Determine the number of autonomous and electric vehicles in the 'inventory' table, partitioned by location.
SELECT inventory_location, COUNT(CASE WHEN vehicle_type LIKE '%Autonomous%' THEN 1 END) + COUNT(CASE WHEN vehicle_type LIKE '%Electric%' THEN 1 END) AS total_autonomous_electric FROM inventory GROUP BY inventory_location;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(50)); CREATE TABLE donations (donation_id INT, donor_id INT, project_id INT, donation_amount DECIMAL(10,2)); CREATE TABLE projects (project_id INT, project_name VARCHAR(50)); INSERT INTO donors (donor_id, donor_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'A...
What are the names of the donors who have given to 'projects' table and their total donation amounts?
SELECT donor_name, SUM(donation_amount) as total_donated FROM donors INNER JOIN donations ON donors.donor_id = donations.donor_id INNER JOIN projects ON donations.project_id = projects.project_id GROUP BY donor_name;
gretelai_synthetic_text_to_sql