context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), division VARCHAR(50), wins INT, championships INT);
What is the minimum number of wins for teams that have won a championship in the last 5 years?
SELECT MIN(teams.wins) FROM teams WHERE teams.championships > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTests (Id INT, TestType VARCHAR(50), VehicleId INT, TestDate DATE, Program VARCHAR(100)); CREATE TABLE AutonomousVehicles (Id INT, Name VARCHAR(100), Program VARCHAR(100)); INSERT INTO SafetyTests (Id, TestType, VehicleId, TestDate, Program) VALUES (9, 'Lane Keeping', 5, '2021-04-15', 'AutonomousDrivingGermany'), (10, 'Traffic Sign Recognition', 5, '2021-04-16', 'AutonomousDrivingGermany'); INSERT INTO AutonomousVehicles (Id, Name, Program) VALUES (5, 'AutonomousCarGermany', 'AutonomousDrivingGermany');
List all autonomous driving research programs in Germany and the number of safety tests conducted.
SELECT AutonomousVehicles.Program, COUNT(SafetyTests.Id) FROM AutonomousVehicles INNER JOIN SafetyTests ON AutonomousVehicles.Id = SafetyTests.VehicleId WHERE Program LIKE '%Germany%' GROUP BY AutonomousVehicles.Program;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_reports (id INT, report_date DATE, region VARCHAR(255)); INSERT INTO intelligence_reports (id, report_date, region) VALUES (1, '2022-01-01', 'Asia-Pacific'), (2, '2022-02-15', 'Europe'), (3, '2022-03-01', 'Asia-Pacific'); CREATE VIEW recent_intelligence_reports AS SELECT * FROM intelligence_reports WHERE report_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND region = 'Asia-Pacific';
What is the total number of intelligence reports filed in the last quarter for the Asia-Pacific region?
SELECT COUNT(*) FROM recent_intelligence_reports;
gretelai_synthetic_text_to_sql
CREATE TABLE age_group (age_group_id INT, age_group TEXT); CREATE TABLE enrollment (enrollment_id INT, age_group_id INT, num_students INT); INSERT INTO age_group (age_group_id, age_group) VALUES (1, 'Under 18'), (2, '18-24'), (3, '25-34'), (4, '35-44'), (5, '45-54'), (6, '55-64'), (7, '65+'); INSERT INTO enrollment (enrollment_id, age_group_id, num_students) VALUES (101, 2, 150), (102, 3, 120), (103, 4, 200), (104, 5, 250), (105, 6, 180), (106, 7, 130);
What is the total number of lifelong learning course enrollments by age group?
SELECT age_group, SUM(num_students) FROM enrollment INNER JOIN age_group ON enrollment.age_group_id = age_group.age_group_id GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (ID INT PRIMARY KEY, Country VARCHAR(50), AccommodationType VARCHAR(50), Quantity INT); INSERT INTO Accommodations (ID, Country, AccommodationType, Quantity) VALUES (1, 'USA', 'Sign Language Interpretation', 300), (2, 'Canada', 'Wheelchair Ramp', 250), (3, 'Mexico', 'Assistive Listening Devices', 150);
What is the number of accommodations provided, per accommodation type, per country?
SELECT Country, AccommodationType, SUM(Quantity) as Total FROM Accommodations GROUP BY Country, AccommodationType;
gretelai_synthetic_text_to_sql
CREATE TABLE content (content_id INT, content_type VARCHAR(20), language VARCHAR(20), audience_type VARCHAR(20), hours_available FLOAT); INSERT INTO content VALUES (1, 'educational', 'Quechua', 'children', 10.5);
How many hours of educational content are available in South America for speakers of indigenous languages?
SELECT SUM(hours_available) FROM content WHERE content_type = 'educational' AND language IN ('Quechua', 'Aymara', 'Guarani') AND audience_type = 'children' AND country IN ('Brazil', 'Argentina', 'Colombia', 'Peru', 'Chile');
gretelai_synthetic_text_to_sql
CREATE TABLE ExplainableAIModels (ModelID INT PRIMARY KEY, ModelName VARCHAR(50), TrainingTime FLOAT, Team VARCHAR(20)); INSERT INTO ExplainableAIModels (ModelID, ModelName, TrainingTime, Team) VALUES (1, 'ModelA', 2.5, 'Explainable AI'), (2, 'ModelB', 3.2, 'Explainable AI');
What is the average training time for models developed by Explainable AI team?
SELECT AVG(TrainingTime) FROM ExplainableAIModels WHERE Team = 'Explainable AI';
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO dispensaries (id, name, city, state) VALUES (1, 'Dispensary A', 'San Francisco', 'CA'); CREATE TABLE sales (id INT, dispensary_id INT, amount DECIMAL(10, 2));
What are total sales for each dispensary in California, grouped by city?
SELECT d.city, SUM(s.amount) as total_sales FROM dispensaries d INNER JOIN sales s ON d.id = s.dispensary_id WHERE d.state = 'CA' GROUP BY d.city;
gretelai_synthetic_text_to_sql
CREATE TABLE ota_stats (ota_name TEXT, virtual_tour_views INT); INSERT INTO ota_stats (ota_name, virtual_tour_views) VALUES ('Expedia', 15000), ('Booking.com', 18000), ('Agoda', 12000);
What is the total number of virtual tour views for each OTA in the 'ota_stats' table?
SELECT ota_name, SUM(virtual_tour_views) FROM ota_stats GROUP BY ota_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Dates (date DATE); CREATE TABLE Sales (sale_id INT, date DATE, product_id INT, quantity INT); CREATE TABLE Products (product_id INT, product_name VARCHAR(255), is_vegan BOOLEAN);
How many units of vegan products were sold in the second quarter of 2022?
SELECT SUM(s.quantity) as total_quantity FROM Sales s JOIN Dates d ON s.date = d.date JOIN Products p ON s.product_id = p.product_id WHERE d.date BETWEEN '2022-04-01' AND '2022-06-30' AND p.is_vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, YearsAtCompany INT);
What is the number of employees who have worked for more than 5 years in the company?
SELECT COUNT(*) as LongTermEmployees FROM Employees WHERE YearsAtCompany > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentFacilities (FacilityID INT, FacilityName VARCHAR(255), Address VARCHAR(255), City VARCHAR(255), State VARCHAR(255), ZipCode VARCHAR(10)); INSERT INTO WastewaterTreatmentFacilities (FacilityID, FacilityName, Address, City, State, ZipCode) VALUES (1, 'Clear Water Plant', '1234 5th St', 'Houston', 'TX', '77002'); CREATE TABLE WaterUsage (UsageID INT, FacilityID INT, UsageDate DATE, TotalGallons INT); INSERT INTO WaterUsage (UsageID, FacilityID, UsageDate, TotalGallons) VALUES (1, 1, '2022-01-01', 500000), (2, 1, '2022-01-02', 550000), (3, 1, '2022-01-03', 600000);
What is the cumulative water usage for the Clear Water Plant up to a specific date?
SELECT UsageID, SUM(TotalGallons) OVER (ORDER BY UsageDate) FROM WaterUsage WHERE FacilityID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Resilience (Id INT, City VARCHAR(50), Metric VARCHAR(50), Value FLOAT, Year INT); INSERT INTO Resilience (Id, City, Metric, Value, Year) VALUES (1, 'Miami', 'Flood Resistance', 70, 2010); INSERT INTO Resilience (Id, City, Metric, Value, Year) VALUES (2, 'Houston', 'Earthquake Resistance', 80, 2015);
What is the average resilience score for each city, grouped by metric?
SELECT City, AVG(Value) as Average_Resilience, Metric FROM Resilience GROUP BY City, Metric;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_processing_plants (id INT, name TEXT, region TEXT); CREATE TABLE plant_connections (id INT, plant_id INT, farm_id INT); INSERT INTO fish_processing_plants (id, name, region) VALUES (1, 'Plant A', 'West Africa'), (2, 'Plant B', 'West Africa'), (3, 'Plant C', 'Central Africa'); INSERT INTO plant_connections (id, plant_id, farm_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3), (4, 3, 4);
List the names and locations of fish processing plants in West Africa and their connected fish farms.
SELECT FPP.name, FPP.region, TF.name AS farm_name FROM fish_processing_plants FPP JOIN plant_connections PC ON FPP.id = PC.plant_id JOIN tilapia_farms TF ON PC.farm_id = TF.id WHERE FPP.region = 'West Africa';
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);
What is the total capacity of factories in Spain and France?
SELECT SUM(capacity) FROM factories WHERE location LIKE '%Spain%' OR location LIKE '%France%';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name TEXT); INSERT INTO players (player_id, name) VALUES (1, 'Messi'), (2, 'Ronaldo'), (3, 'Rooney'); CREATE TABLE goals (goal_id INT, player_id INT, league TEXT, goals INT); INSERT INTO goals (goal_id, player_id, league, goals) VALUES (1, 1, 'Premier League', 20), (2, 1, 'Premier League', 30), (3, 2, 'Premier League', 40), (4, 2, 'Bundesliga', 50), (5, 3, 'Premier League', 15);
How many players in total have scored at least 10 goals in the 'Premier League'?
SELECT COUNT(*) FROM (SELECT player_id FROM goals WHERE league = 'Premier League' GROUP BY player_id HAVING SUM(goals) >= 10) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (project_id INT, contractor_id INT, start_date DATE, end_date DATE);
Insert a new project with "project_id" 1001, "contractor_id" 1001, "start_date" "2022-01-01", and "end_date" "2022-12-31" into the "Projects" table.
INSERT INTO Projects (project_id, contractor_id, start_date, end_date) VALUES (1001, 1001, '2022-01-01', '2022-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE safety_stats (date DATE, accidents INT);
Show the number of accidents by month in the 'safety_stats' table.
SELECT EXTRACT(MONTH FROM date), COUNT(*) FROM safety_stats GROUP BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (1, 'Rihanna', 1000.00); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (2, 'Bill Gates', 5000.00); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (3, 'Oprah Winfrey', 2500.00);
What is the maximum donation amount and the corresponding donor's name?
SELECT DonorName, MAX(DonationAmount) FROM Donors;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, port_id INT, speed FLOAT); INSERT INTO vessels (id, name, port_id, speed) VALUES (1, 'VesselA', 1, 20.5), (2, 'VesselB', 1, 21.3), (3, 'VesselC', 2, 25.0);
Update the speed of the vessel 'VesselB' to 22.0 in the table 'vessels'.
UPDATE vessels SET speed = 22.0 WHERE name = 'VesselB';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), condition VARCHAR(50), country VARCHAR(50), birth_date DATE); INSERT INTO patients (patient_id, patient_name, condition, country, birth_date) VALUES (1, 'Hana Yamada', 'Anorexia', 'Japan', '1998-05-15'), (2, 'Taro Nakamura', 'Bulimia', 'Japan', '2001-08-08');
What is the minimum age of patients diagnosed with eating disorders in Japan?
SELECT MIN(YEAR(GETDATE()) - YEAR(birth_date)) FROM patients WHERE patients.country = 'Japan' AND patients.condition LIKE '%Eating Disorder%';
gretelai_synthetic_text_to_sql
CREATE TABLE enrollment(id INT, program TEXT, semester TEXT); INSERT INTO enrollment(id, program, semester) VALUES (1, 'Data Science', 'Spring'), (2, 'Mathematics', 'Spring'), (3, 'Physics', 'Fall');
How many students are enrolled in each program in the Spring semester?
SELECT program, COUNT(*) FROM enrollment GROUP BY program HAVING semester = 'Spring';
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling (cargo_handling_id INT, port VARCHAR(255), cargo_weight INT, handling_date DATE);INSERT INTO cargo_handling (cargo_handling_id, port, cargo_weight, handling_date) VALUES (1, 'Shanghai', 50000, '2022-02-01'), (2, 'Shanghai', 55000, '2022-02-02');
What is the average cargo weight handled per day by the port of Shanghai in February 2022?
SELECT AVG(cargo_weight) FROM cargo_handling WHERE port = 'Shanghai' AND EXTRACT(MONTH FROM handling_date) = 2 AND EXTRACT(YEAR FROM handling_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage_projects (project_id INT, state VARCHAR(20), start_year INT, end_year INT, investment FLOAT);
What was the total investment (in USD) in energy storage projects in Massachusetts between 2016 and 2021?
SELECT SUM(investment) FROM energy_storage_projects WHERE state = 'Massachusetts' AND start_year BETWEEN 2016 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (id INT, city VARCHAR(50), type VARCHAR(50), rating FLOAT); INSERT INTO buildings (id, city, type, rating) VALUES (1, 'New York', 'Residential', 80.5), (2, 'Los Angeles', 'Residential', 75.0);
What is the average energy efficiency rating of residential buildings in 'New York' city?
SELECT AVG(rating) FROM buildings WHERE city = 'New York' AND type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE Heritage_Donors (Donor_Name VARCHAR(50), Country VARCHAR(50), Donation_Amount INT); INSERT INTO Heritage_Donors (Donor_Name, Country, Donation_Amount) VALUES ('John Smith', 'USA', 500000), ('Jane Doe', 'Canada', 300000), ('Maria Garcia', 'Mexico', 400000);
Who are the top 5 contributors to heritage site preservation funds in the Americas, based on the amount donated?
SELECT Donor_Name, Country, Donation_Amount FROM Heritage_Donors WHERE Country IN ('USA', 'Canada', 'Mexico') ORDER BY Donation_Amount DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.experiments (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(100)); INSERT INTO genetics.experiments (id, name, location) VALUES (1, 'ExpA', 'London'), (2, 'ExpB', 'Manchester'), (3, 'ExpC', 'Paris'), (4, 'ExpD', 'Lyon'), (5, 'ExpE', 'Glasgow');
List all genetic research experiments conducted in the United Kingdom and France.
SELECT DISTINCT name FROM genetics.experiments WHERE location = 'United Kingdom' OR location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (offender_id INT, offender_age INT, offender_gender VARCHAR(10), offense_date DATE); INSERT INTO offenders (offender_id, offender_age, offender_gender, offense_date) VALUES (1, 32, 'Male', '2018-01-01'), (2, 28, 'Female', '2019-01-01'), (3, 45, 'Male', '2020-01-01');
What is the age distribution of offenders who committed crimes against women in the past 5 years?
SELECT offender_age, COUNT(*) AS num_offenders FROM offenders WHERE offender_gender = 'Male' AND offense_date BETWEEN DATEADD(year, -5, CURRENT_DATE()) AND CURRENT_DATE() GROUP BY offender_age;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (id INT, algorithm_name VARCHAR(50), incident_count INT, region VARCHAR(50)); INSERT INTO ai_safety (id, algorithm_name, incident_count, region) VALUES (1, 'Algorithm A', 3, 'Asia-Pacific'), (2, 'Algorithm B', 5, 'Asia-Pacific');
Identify the number of AI safety incidents for each algorithm in the Asia-Pacific region.
SELECT algorithm_name, region, SUM(incident_count) FROM ai_safety WHERE region = 'Asia-Pacific' GROUP BY algorithm_name, region;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (country VARCHAR(50), usage FLOAT, year INT); INSERT INTO water_usage (country, usage, year) VALUES ('China', 12345.6, 2020), ('India', 23456.7, 2020), ('Indonesia', 34567.8, 2020);
What is the total water usage in Mega Liters for the top 3 water consuming countries in Asia in 2020?
SELECT SUM(usage) FROM (SELECT usage FROM water_usage WHERE year = 2020 AND country IN ('China', 'India', 'Indonesia') ORDER BY usage DESC LIMIT 3);
gretelai_synthetic_text_to_sql
CREATE TABLE music_platforms (id INT, platform VARCHAR(255)); INSERT INTO music_platforms (id, platform) VALUES (1, 'Spotify'), (2, 'Apple Music'), (3, 'YouTube'), (4, 'Pandora'); CREATE TABLE streams (id INT, track_id INT, platform_id INT, timestamp TIMESTAMP); INSERT INTO streams (id, track_id, platform_id, timestamp) VALUES (1, 1, 1, '2022-01-01 00:00:00'), (2, 2, 2, '2022-01-01 01:00:00'), (3, 3, 3, '2022-01-01 02:00:00'), (4, 4, 4, '2022-01-01 03:00:00');
How many streams does each platform generate on average per day?
SELECT platform, AVG(TIMESTAMPDIFF(DAY, timestamp, LEAD(timestamp) OVER (PARTITION BY platform_id ORDER BY timestamp))) as avg_daily_streams FROM streams GROUP BY platform;
gretelai_synthetic_text_to_sql
CREATE TABLE org_social (org_id INT, org_name TEXT, initiative TEXT); INSERT INTO org_social (org_id, org_name, initiative) VALUES (1, 'OrgG', 'social good'), (2, 'OrgH', 'ethical AI'), (3, 'OrgI', 'social good');
What are the names of organizations working on social good projects in Europe?
SELECT org_name FROM org_social WHERE initiative = 'social good' AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Site (SiteID VARCHAR(10), SiteName VARCHAR(20)); INSERT INTO Site (SiteID, SiteName) VALUES ('I', 'Site I'); CREATE TABLE Artifact (ArtifactID VARCHAR(10), SiteID VARCHAR(10), Weight FLOAT); INSERT INTO Artifact (ArtifactID, SiteID, Weight) VALUES ('1', 'I', 12.3), ('2', 'I', 25.6), ('3', 'I', 18.9);
Update the weight of artifact '1' from 'Site I' to 18.5
UPDATE Artifact SET Weight = 18.5 WHERE ArtifactID = '1' AND SiteID = 'I';
gretelai_synthetic_text_to_sql
CREATE TABLE causes (id INT, name VARCHAR(255)); INSERT INTO causes (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'), (4, 'Poverty Alleviation'); CREATE TABLE donations (id INT, cause_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, cause_id, amount, donation_date) VALUES (1, 1, 500.00, '2022-04-01'), (2, 2, 1000.00, '2022-04-15'), (3, 1, 750.00, '2022-04-03'), (4, 3, 200.00, '2022-04-01'), (5, 2, 150.00, '2022-04-30'), (6, 4, 1250.00, '2022-04-25');
Which causes received the most donations in April 2022?
SELECT cause_id, SUM(amount) as total_donation_amount FROM donations WHERE donation_date BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY cause_id ORDER BY total_donation_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_minority VARCHAR(10)); INSERT INTO Companies (id, name, industry, country, founding_year, founder_minority) VALUES (1, 'GreenTech', 'Renewable Energy', 'USA', 2019, 'Yes'); INSERT INTO Companies (id, name, industry, country, founding_year, founder_minority) VALUES (2, 'SunPower', 'Renewable Energy', 'USA', 2018, 'No');
How many companies were founded by underrepresented minorities each year?
SELECT founding_year, COUNT(*) as underrepresented_minorities_count FROM Companies WHERE founder_minority = 'Yes' GROUP BY founding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50), production_qty FLOAT, commission_date DATE); INSERT INTO wells VALUES (1, 'Well A', 'North Sea', 15000, '2017-01-01'); INSERT INTO wells VALUES (2, 'Well B', 'North Sea', 12000, '2018-01-01'); INSERT INTO wells VALUES (3, 'Well C', 'Gulf of Mexico', 18000, '2016-01-01');
What is the average production quantity for wells in the 'North Sea' that were commissioned in 2017 or later?
SELECT AVG(production_qty) as avg_production FROM wells WHERE region = 'North Sea' AND commission_date >= '2017-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (city VARCHAR(20), num_buildings INT); INSERT INTO GreenBuildings (city, num_buildings) VALUES ('CityA', 250), ('CityB', 300), ('CityC', 180), ('CityD', 350);
What is the total number of green buildings in each city?
SELECT city, SUM(num_buildings) FROM GreenBuildings GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_plants (id INT PRIMARY KEY, name VARCHAR(255), capacity_mw FLOAT, country VARCHAR(255));
Update the 'capacity_mw' value to 50 in the 'solar_plants' table where the 'id' is 1
UPDATE solar_plants SET capacity_mw = 50 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE field (id INT, name VARCHAR(255)); CREATE TABLE satellite_image (id INT, field_id INT, brightness INT, contrast INT, timestamp TIMESTAMP); INSERT INTO field VALUES (1, 'Field A'), (2, 'Field B'); INSERT INTO satellite_image VALUES (1, 1, 100, 50, '2022-02-01 10:00:00'), (2, 2, 80, 60, '2022-02-01 10:00:00');
Identify the number of anomalous satellite image readings for each field in the last week, considering an anomaly as a reading 2 standard deviations away from the mean.
SELECT f.name, COUNT(*) as num_anomalies FROM field f INNER JOIN satellite_image si ON f.id = si.field_id CROSS JOIN (SELECT AVG(brightness) as avg_brightness, AVG(contrast) as avg_contrast, STDDEV(brightness) as stddev_brightness, STDDEV(contrast) as stddev_contrast FROM satellite_image WHERE timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW()) as means WHERE si.brightness < means.avg_brightness - 2 * means.stddev_brightness OR si.brightness > means.avg_brightness + 2 * means.stddev_brightness OR si.contrast < means.avg_contrast - 2 * means.stddev_contrast OR si.contrast > means.avg_contrast + 2 * means.stddev_contrast GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, city TEXT, state TEXT); INSERT INTO Dispensaries (id, name, city, state) VALUES (1, 'Dispensary A', 'Las Vegas', 'Nevada'); INSERT INTO Dispensaries (id, name, city, state) VALUES (2, 'Dispensary B', 'Reno', 'Nevada'); INSERT INTO Dispensaries (id, name, city, state) VALUES (3, 'Dispensary C', 'Las Vegas', 'Nevada');
How many dispensaries are located in each city in Nevada?
SELECT d.city, COUNT(DISTINCT d.id) as num_dispensaries FROM Dispensaries d WHERE d.state = 'Nevada' GROUP BY d.city;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policy_date DATE); INSERT INTO policies (policy_id, policy_date) VALUES (1, '2021-04-01'), (2, '2021-06-15');
Which clean energy policies were implemented in H1 2021?
SELECT policy_id, policy_date FROM policies WHERE policy_date BETWEEN '2021-01-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE mars_temperature (id INT, rover_name VARCHAR(50), temperature FLOAT); INSERT INTO mars_temperature (id, rover_name, temperature) VALUES (1, 'Spirit', -55), (2, 'Opportunity', -70), (3, 'Curiosity', -80);
What is the minimum temperature recorded on Mars by any rover?
SELECT MIN(temperature) FROM mars_temperature;
gretelai_synthetic_text_to_sql
CREATE TABLE species_timber (species_id INT, species_name VARCHAR(50), year INT, volume INT); INSERT INTO species_timber (species_id, species_name, year, volume) VALUES (1, 'Oak', 2018, 1000), (2, 'Pine', 2018, 2000), (3, 'Maple', 2018, 3000), (4, 'Birch', 2018, 4000), (1, 'Oak', 2019, 1500), (2, 'Pine', 2019, 2500), (3, 'Maple', 2019, 3500), (4, 'Birch', 2019, 4500);
What is the change in timber production between 2018 and 2019, by species, and rank them by the largest increase first?
SELECT species_id, species_name, (volume - LAG(volume, 1) OVER (PARTITION BY species_name ORDER BY year)) AS volume_change, RANK() OVER (ORDER BY volume_change DESC) AS volume_rank FROM species_timber WHERE year IN (2018, 2019) GROUP BY species_id, species_name, volume, year ORDER BY year, volume_rank ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, name VARCHAR(100), price DECIMAL(5,2), category VARCHAR(50));
Find the average price of garments in each category in the garments table
SELECT category, AVG(price) as avg_price FROM garments GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE DramaPerformances (id INT, district VARCHAR(10), performance_type VARCHAR(20), performance_date DATE); INSERT INTO DramaPerformances (id, district, performance_type, performance_date) VALUES (1, 'Manhattan', 'Play', '2020-02-01'), (2, 'Brooklyn', 'Musical', '2020-10-15'), (3, 'Queens', 'Opera', '2020-07-03');
What was the total number of drama performances in each city district in 2020?
SELECT district, performance_type, COUNT(*) as performance_count FROM DramaPerformances WHERE YEAR(performance_date) = 2020 AND performance_type = 'Drama' GROUP BY district, performance_type;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'); CREATE TABLE countries (id INT, region_id INT, name TEXT); INSERT INTO countries (id, region_id, name) VALUES (1, 1, 'United States'), (2, 1, 'Canada'), (3, 2, 'Brazil'); CREATE TABLE shipments (id INT, cargo_weight FLOAT, country_id INT); INSERT INTO shipments (id, cargo_weight, country_id) VALUES (1, 8000.0, 1), (2, 9000.0, 1), (3, 6000.0, 1);
What is the maximum cargo weight for shipments to the United States in 2022?
SELECT MAX(cargo_weight) FROM shipments INNER JOIN countries ON shipments.country_id = countries.id WHERE countries.name = 'United States' AND shipment_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); INSERT INTO mine (id, name, location) VALUES (1, 'Golden Mine', 'USA'), (2, 'Silver Mine', 'Canada'); CREATE TABLE temperature (id INT, mine_id INT, date DATE, temperature REAL); INSERT INTO temperature (id, mine_id, date, temperature) VALUES (1, 1, '2022-03-01', 20), (2, 1, '2022-03-02', 22), (3, 1, '2022-03-03', 25), (4, 2, '2022-03-01', 10), (5, 2, '2022-03-02', 12), (6, 2, '2022-03-03', 15);
What is the maximum daily temperature recorded at each mine location in the last month?
SELECT mine_id, MAX(temperature) as max_temperature FROM temperature WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founder_gender TEXT); INSERT INTO companies (id, name, founder_gender) VALUES (1, 'Foobar Inc', 'Female'), (2, 'Gizmos Inc', 'Male'), (3, 'Widgets Inc', 'Female'), (4, 'Doodads Inc', 'Male'), (5, 'Thingamajigs Inc', 'Female'), (6, 'Whatchamacallits Inc', 'Female'); CREATE TABLE success (company_id INT, is_successful BOOLEAN); INSERT INTO success (company_id, is_successful) VALUES (1, 1), (2, 0), (3, 1), (4, 1), (5, 1), (6, 0);
What is the success rate of startups founded by women?
SELECT COUNT(*) as num_successful_startups, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM companies) as success_rate FROM success JOIN companies ON success.company_id = companies.id WHERE companies.founder_gender = 'Female' AND is_successful = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE FishPopulationBySpecies (id INT, species VARCHAR(255), population INT); INSERT INTO FishPopulationBySpecies (id, species, population) VALUES (1, 'Tilapia', 15000); INSERT INTO FishPopulationBySpecies (id, species, population) VALUES (2, 'Carps', 12000); INSERT INTO FishPopulationBySpecies (id, species, population) VALUES (3, 'Goldfish', 8000); INSERT INTO FishPopulationBySpecies (id, species, population) VALUES (4, 'Catfish', 11000);
Display the species and total population of fish in the 'FishPopulationBySpecies' table with a population greater than 10000
SELECT species, SUM(population) FROM FishPopulationBySpecies WHERE population > 10000 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name VARCHAR(50), TotalDonations DECIMAL(10,2), LastDonation DATE);
What is the total amount donated by individual donors who have donated more than once in the last year?
SELECT SUM(TotalDonations) FROM (SELECT DonorID, SUM(DonationAmount) AS TotalDonations FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donations.DonationDate > DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND DonorID IN (SELECT DonorID FROM Donors GROUP BY DonorID HAVING COUNT(*) > 1) GROUP BY DonorID);
gretelai_synthetic_text_to_sql
CREATE TABLE dams (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE design_standards (dam_id INT, standard VARCHAR(255));
What are the names and design standards of the dams located in 'California' from the 'dams' and 'design_standards' tables?
SELECT d.name, ds.standard FROM dams d INNER JOIN design_standards ds ON d.id = ds.dam_id WHERE d.location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_name TEXT, country TEXT, sales_amount INT, sale_date DATE); INSERT INTO sales (drug_name, country, sales_amount, sale_date) VALUES ('Dolorol', 'USA', 5000, '2021-01-01');
What were the total sales of drug 'Dolorol' in the United States for 2021?
SELECT SUM(sales_amount) FROM sales WHERE drug_name = 'Dolorol' AND country = 'USA' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE facilities(name VARCHAR(50), country VARCHAR(50), build_year INT); INSERT INTO facilities(name, country, build_year) VALUES ('Facility1', 'Nigeria', 2019), ('Facility2', 'Nigeria', 2018), ('Facility3', 'Nigeria', 2020);
How many wastewater treatment facilities are there in Nigeria as of 2021?
SELECT COUNT(*) FROM facilities WHERE country = 'Nigeria' AND build_year <= 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (name TEXT, type TEXT, country TEXT); INSERT INTO projects (name, type, country) VALUES ('Project 1', 'Wind', 'Canada'), ('Project 2', 'Solar', 'Canada');
What are the names and types of renewable energy projects in Canada?
SELECT name, type FROM projects WHERE country = 'Canada'
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_initiatives (initiative_id INT, site_id INT, initiative_date DATE, initiative_description TEXT); INSERT INTO pollution_initiatives (initiative_id, site_id, initiative_date, initiative_description) VALUES (1, 1, '2022-08-01', 'Installed new filters'), (2, 3, '2022-07-15', 'Regular cleaning schedule established');
Which sites have no recorded pollution control initiatives?
SELECT site_id FROM marine_sites WHERE site_id NOT IN (SELECT site_id FROM pollution_initiatives);
gretelai_synthetic_text_to_sql
CREATE TABLE taxis (taxi_id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO taxis (taxi_id, type, city) VALUES (1, 'Electric Taxi', 'Singapore'), (2, 'Taxi', 'Singapore'), (3, 'Electric Taxi', 'Singapore'), (4, 'Taxi', 'Singapore');
What is the percentage of electric taxis in Singapore?
SELECT city, COUNT(*) * 100.0 / SUM(city = 'Singapore') OVER () AS percentage_etaxis FROM taxis WHERE type = 'Electric Taxi';
gretelai_synthetic_text_to_sql
CREATE TABLE mars_rovers(id INT, agency VARCHAR(255), mission_name VARCHAR(255), launch_date DATE, budget DECIMAL(10,2));
What is the average budget for all Mars rover missions launched by any space agency between 2000 and 2010, inclusive?
SELECT AVG(budget) FROM mars_rovers WHERE agency IN (SELECT agency FROM mars_rovers WHERE launch_date BETWEEN '2000-01-01' AND '2010-12-31' GROUP BY agency) AND mission_name LIKE '%Mars Rover%';
gretelai_synthetic_text_to_sql
CREATE TABLE Mines (MineID INT, Name TEXT, Location TEXT, TotalWorkers INT, TotalProduction INT); INSERT INTO Mines (MineID, Name, Location, TotalWorkers, TotalProduction) VALUES (1, 'Golden Mine', 'California', 250, 150000), (2, 'Silver Ridge', 'Nevada', 300, 210000), (3, 'Copper Quarry', 'Arizona', 400, 250000); CREATE TABLE AverageScores (AvgLaborProductivity DECIMAL(5,2)); INSERT INTO AverageScores (AvgLaborProductivity) VALUES ((SELECT AVG(TotalProduction/TotalWorkers) FROM Mines));
Which mines have a labor productivity higher than the average?
SELECT Name, TotalProduction/TotalWorkers AS LaborProductivity FROM Mines WHERE TotalProduction/TotalWorkers > (SELECT AvgLaborProductivity FROM AverageScores);
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(50), initiative_type VARCHAR(50)); CREATE TABLE budgets (budget_id INT, initiative_id INT, budget_amount INT); INSERT INTO initiatives (initiative_id, initiative_name, initiative_type) VALUES (101, 'Open Source Textbooks', 'Open Pedagogy'), (102, 'Peer Learning Networks', 'Open Pedagogy'), (103, 'Project-Based Learning', 'Open Pedagogy'); INSERT INTO budgets (budget_id, initiative_id, budget_amount) VALUES (201, 101, 10000), (202, 102, 15000), (203, 103, 12000);
What are the open pedagogy initiatives and their corresponding budgets?
SELECT i.initiative_name, b.budget_amount FROM initiatives i INNER JOIN budgets b ON i.initiative_id = b.initiative_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, title VARCHAR(50), value DECIMAL(10,2), collection VARCHAR(50)); CREATE TABLE Collections (id INT, name VARCHAR(50), category VARCHAR(50));
What is the total value of all artworks in our Asian art collection?
SELECT SUM(Artworks.value) FROM Artworks INNER JOIN Collections ON Artworks.collection = Collections.name WHERE Collections.category = 'Asian Art';
gretelai_synthetic_text_to_sql
CREATE SCHEMA estuaries; CREATE TABLE fish_farms (id INT, size FLOAT, location VARCHAR(20)); INSERT INTO fish_farms (id, size, location) VALUES (1, 40.2, 'estuary'), (2, 39.5, 'estuary'), (3, 52.3, 'estuary');
Find the total size of fish farms in 'estuaries' schema where the size is greater than 35.
SELECT SUM(size) FROM estuaries.fish_farms WHERE size > 35;
gretelai_synthetic_text_to_sql
CREATE TABLE researchers (researcher_id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), experience INT);
Insert a new record into the "researchers" table with the following information: "researcher_id": 401, "name": "Hiroshi Tanaka", "region": "Asia", "experience": 10.
INSERT INTO researchers (researcher_id, name, region, experience) VALUES (401, 'Hiroshi Tanaka', 'Asia', 10);
gretelai_synthetic_text_to_sql
CREATE TABLE finance (region VARCHAR(255), sector VARCHAR(255), amount FLOAT); INSERT INTO finance (region, sector, amount) VALUES ('Asia', 'Renewable Energy', 8000000), ('Africa', 'Renewable Energy', 6000000), ('Europe', 'Renewable Energy', 10000000);
What is the total climate finance investment in renewable energy in Asia?
SELECT SUM(amount) FROM finance WHERE region = 'Asia' AND sector = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification_stations (station_name TEXT, country TEXT, reading FLOAT);
How many ocean acidification monitoring stations exist in each country and their average readings?
SELECT ocean_acidification_stations.country, COUNT(ocean_acidification_stations.station_name) AS num_stations, AVG(ocean_acidification_stations.reading) AS avg_reading FROM ocean_acidification_stations GROUP BY ocean_acidification_stations.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50)); CREATE TABLE Genres (GenreID INT, Genre VARCHAR(50)); CREATE TABLE Streams (StreamID INT, ArtistID INT, GenreID INT, Streams INT, Sales INT);
What is the total number of streams for each artist, their respective genres, and the total sales for those streams?
SELECT A.ArtistName, G.Genre, SUM(S.Streams) as TotalStreams, SUM(S.Sales) as TotalSales FROM Streams S JOIN Artists A ON S.ArtistID = A.ArtistID JOIN Genres G ON S.GenreID = G.GenreID GROUP BY A.ArtistName, G.Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (id INT, country VARCHAR(255), region VARCHAR(255), year INT, cubic_meters FLOAT); INSERT INTO timber_production (id, country, region, year, cubic_meters) VALUES (1, 'China', 'Asia-Pacific', 2020, 789456.12), (2, 'Indonesia', 'Asia-Pacific', 2020, 678345.12), (3, 'Japan', 'Asia-Pacific', 2020, 567890.12);
What is the average timber production, in cubic meters, for each country in the Asia-Pacific region?
SELECT country, AVG(cubic_meters) FROM timber_production WHERE region = 'Asia-Pacific' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (State VARCHAR(255), Category VARCHAR(255), Amount DECIMAL(18,2)); INSERT INTO Budget (State, Category, Amount) VALUES ('MO', 'Healthcare', 1000000.00), ('MO', 'Education', 800000.00), ('IL', 'Healthcare', 1500000.00);
Show the total budget allocated to healthcare services in each state for the year 2020.
SELECT State, SUM(Amount) FROM Budget WHERE Category = 'Healthcare' AND YEAR(Date) = 2020 GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, factory_name TEXT, region TEXT); INSERT INTO factories (factory_id, factory_name, region) VALUES (1, 'Factory D', 'West'), (2, 'Factory E', 'North'), (3, 'Factory F', 'South'); CREATE TABLE employees (employee_id INT, factory_id INT, department TEXT, gender TEXT); INSERT INTO employees (employee_id, factory_id, department, gender) VALUES (1, 1, 'Production', 'Female'), (2, 1, 'Engineering', 'Male'), (3, 2, 'Production', 'Non-binary'), (4, 2, 'Management', 'Female'), (5, 3, 'Production', 'Male'), (6, 3, 'Engineering', 'Female');
List all factories with their respective workforce size, categorized by region and employee gender?
SELECT factories.factory_name, region, gender, COUNT(*) AS employee_count FROM factories JOIN employees ON factories.factory_id = employees.factory_id GROUP BY factories.factory_name, region, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE donors (id INT, country VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 20.00, '2017-01-01'); INSERT INTO donors (id, country) VALUES (1, 'France');
What is the minimum donation amount received from a single donor in France in the year 2017?
SELECT MIN(donation_amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.country = 'France' AND YEAR(donation_date) = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), position VARCHAR(50), age INT);
What's the average age of employees in the 'mining_operations' table?
SELECT AVG(age) FROM mining_operations;
gretelai_synthetic_text_to_sql
CREATE TABLE public_trips (trip_id INT, trip_date DATE, trip_city VARCHAR(50)); INSERT INTO public_trips (trip_id, trip_date, trip_city) VALUES (1, '2022-01-01', 'Sydney'), (2, '2022-01-02', 'Sydney');
What is the average number of public transportation trips per month in Sydney, Australia?
SELECT AVG(trips) FROM (SELECT COUNT(*) AS trips FROM public_trips WHERE trip_city = 'Sydney' GROUP BY EXTRACT(MONTH FROM trip_date)) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist_id INT, city VARCHAR(50), revenue FLOAT); INSERT INTO concerts (id, artist_id, city, revenue) VALUES (1, 1, 'Los Angeles', 500000), (2, 1, 'New York', 700000), (3, 2, 'Seoul', 800000), (4, 2, 'Tokyo', 900000), (5, 1, 'Berlin', 400000), (6, 3, 'Paris', 1000000);
What is the total revenue for concerts in 'Berlin'?
SELECT SUM(revenue) as total_revenue FROM concerts WHERE city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE WasteData (manufacturer_id INT, material VARCHAR(50), waste_quantity INT); INSERT INTO WasteData (manufacturer_id, material, waste_quantity) VALUES (1, 'Material1', 120), (1, 'Material2', 150), (2, 'Material1', 80), (2, 'Material3', 100); CREATE TABLE Manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(50), region VARCHAR(50)); INSERT INTO Manufacturers (manufacturer_id, manufacturer_name, region) VALUES (1, 'ManufacturerA', 'North America'), (2, 'ManufacturerB', 'Europe');
Show the top 3 materials with the highest waste generation across all manufacturers
SELECT material, SUM(waste_quantity) AS total_waste FROM WasteData GROUP BY material ORDER BY total_waste DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(50), email VARCHAR(50)); INSERT INTO graduate_students VALUES (1, 'Fiona', 'fiona@cs.edu'), (2, 'George', 'george@math.edu'), (3, 'Hannah', 'hannah@physics.edu');
Insert a new graduate student named 'Ivan' with an email address 'ivan@cs.edu' into the Graduate Students table.
INSERT INTO graduate_students (name, email) VALUES ('Ivan', 'ivan@cs.edu');
gretelai_synthetic_text_to_sql
CREATE TABLE construction_trades (trade_id INT, trade_name VARCHAR(255), hourly_rate DECIMAL(10,2)); INSERT INTO construction_trades (trade_id, trade_name, hourly_rate) VALUES (1, 'Carpentry', 35.50), (2, 'Electrical Work', 42.25), (3, 'Plumbing', 46.75); CREATE TABLE labor_statistics (trade_id INT, state VARCHAR(255), avg_cost DECIMAL(10,2));
What are the average labor costs for each construction trade in the state of California?
SELECT ct.trade_name, AVG(ls.avg_cost) as avg_cost_ca FROM construction_trades ct INNER JOIN labor_statistics ls ON ct.trade_id = ls.trade_id WHERE ls.state = 'California' GROUP BY ct.trade_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName VARCHAR(50)); INSERT INTO Volunteers (VolunteerID, VolunteerName) VALUES (1, 'James Smith'), (2, 'Jessica Johnson'); CREATE TABLE VolunteerHours (VolunteerHourID INT, VolunteerID INT, Program VARCHAR(50), VolunteerHours DECIMAL(10,2), VolunteerDate DATE); INSERT INTO VolunteerHours (VolunteerHourID, VolunteerID, Program, VolunteerHours, VolunteerDate) VALUES (1, 1, 'Youth', 2.00, '2022-04-01'), (2, 2, 'Youth', 3.00, '2022-05-01');
What is the total number of hours volunteered by each volunteer in the Youth programs in Q2 of 2022?
SELECT VolunteerName, SUM(VolunteerHours) as TotalHours FROM Volunteers INNER JOIN VolunteerHours ON Volunteers.VolunteerID = VolunteerHours.VolunteerID WHERE VolunteerHours.Program = 'Youth' AND QUARTER(VolunteerDate) = 2 AND Year(VolunteerDate) = 2022 GROUP BY VolunteerName;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtWorkSales (artworkID INT, saleDate DATE, artworkMedium VARCHAR(50), revenue DECIMAL(10,2));
What was the total revenue for each artwork medium in Q1 of 2021?
SELECT artworkMedium, SUM(revenue) as q1_revenue FROM ArtWorkSales WHERE saleDate BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY artworkMedium;
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (song_genre VARCHAR(255), state VARCHAR(255), stream_count INT, stream_date DATE); INSERT INTO Streams (song_genre, state, stream_count, stream_date) VALUES ('hip-hop', 'Texas', 5000, '2022-01-01'), ('rock', 'California', 8000, '2022-01-02');
What is the maximum number of streams for any rock song in California?
SELECT MAX(stream_count) FROM Streams WHERE song_genre = 'rock' AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(255), timestamp TIMESTAMP);CREATE VIEW phishing_incidents AS SELECT EXTRACT(MONTH FROM timestamp) as month, COUNT(*) as phishing_count FROM security_incidents WHERE incident_type = 'phishing' GROUP BY month;
Calculate the percentage of security incidents related to phishing attacks, for each month in the last year?
SELECT month, phishing_count, ROUND(phishing_count * 100.0 / total_incidents, 2) as phishing_percentage FROM phishing_incidents JOIN (SELECT EXTRACT(MONTH FROM timestamp) as month, COUNT(*) as total_incidents FROM security_incidents GROUP BY month) total_incidents ON phishing_incidents.month = total_incidents.month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, location VARCHAR(20), quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, location, quantity, price) VALUES (1, 'Northeast', 50, 12.99), (2, 'Midwest', 75, 19.99), (3, 'West', 35, 14.49);
What is the average quantity of seafood sold per transaction in the Midwest region?
SELECT AVG(quantity) FROM sales WHERE location = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE Property (id INT, neighborhood VARCHAR(20), sustainable_score INT); INSERT INTO Property (id, neighborhood, sustainable_score) VALUES (1, 'GreenCommunity', 85), (2, 'SolarVillage', 70), (3, 'GreenCommunity', 90);
How many properties in each neighborhood have a sustainable urbanism score greater than 80?
SELECT Property.neighborhood, COUNT(Property.id) FROM Property WHERE Property.sustainable_score > 80 GROUP BY Property.neighborhood;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_size (id INT PRIMARY KEY, size VARCHAR(10), customer_count INT); INSERT INTO customer_size (id, size, customer_count) VALUES (1, 'XS', 500), (2, 'S', 800), (3, 'M', 1200), (4, 'L', 1500);
Insert data into 'customer_size' table
INSERT INTO customer_size (id, size, customer_count) VALUES (1, 'XS', 500), (2, 'S', 800), (3, 'M', 1200), (4, 'L', 1500);
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions_canada (id INT, mission_name VARCHAR(255), mission_duration INT, lead_astronaut VARCHAR(255)); INSERT INTO space_missions_canada (id, mission_name, mission_duration, lead_astronaut) VALUES (1, 'Mission1', 600, 'AstronautA'), (2, 'Mission2', 400, 'AstronautB');
How many space missions have been led by astronauts from Canada with a duration greater than 500 days?
SELECT COUNT(*) FROM space_missions_canada WHERE lead_astronaut IN ('AstronautA', 'AstronautC', 'AstronautD') AND mission_duration > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence_reports (report_id INT, report_date DATE, threat_category VARCHAR(255), generating_agency VARCHAR(255));
Show the number of threat intelligence reports generated by each agency in the past 30 days
SELECT generating_agency, COUNT(*) as report_count FROM threat_intelligence_reports WHERE report_date >= DATEADD(day, -30, CURRENT_DATE) GROUP BY generating_agency;
gretelai_synthetic_text_to_sql
CREATE TABLE media_ethics (id INT, topic TEXT, description TEXT, created_at DATE);
Delete all records from the "media_ethics" table where the "topic" is "Data privacy"
DELETE FROM media_ethics WHERE topic = 'Data privacy';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoption (hotel_id INT, region VARCHAR(50), ai_integration VARCHAR(50));
Update the hotel_tech_adoption_table and set ai_integration to 'Yes' for all records from the Americas region
UPDATE hotel_tech_adoption SET ai_integration = 'Yes' WHERE region = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (id INT, date DATE, location VARCHAR(50), level DECIMAL(3,1)); INSERT INTO ocean_acidification (id, date, location, level) VALUES (1, '2021-08-15', 'Caribbean Sea', 7.9); INSERT INTO ocean_acidification (id, date, location, level) VALUES (2, '2022-03-02', 'Sargasso Sea', 8.1);
Delete all records in the 'ocean_acidification' table where the 'level' is above 8.0
DELETE FROM ocean_acidification WHERE level > 8.0;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, name TEXT);CREATE TABLE production (company_id INT, total_qty INT, renewable_qty INT);
What is the total production quantity for each company, and what is the percentage of that quantity that is produced using renewable energy?
SELECT c.name, SUM(p.total_qty) AS total_produced, (SUM(p.renewable_qty) / SUM(p.total_qty)) * 100 AS pct_renewable FROM companies c INNER JOIN production p ON c.company_id = p.company_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_launches (id INT, launch_year INT, satellites INT); INSERT INTO satellite_launches (id, launch_year, satellites) VALUES (1, 2000, 50), (2, 2001, 75), (3, 2002, 85), (4, 2003, 100);
How many satellites were launched per year?
SELECT launch_year, SUM(satellites) as total_satellites FROM satellite_launches GROUP BY launch_year;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, product VARCHAR(255), severity FLOAT); INSERT INTO vulnerabilities (id, product, severity) VALUES (1, 'ProductA', 5.0), (2, 'ProductB', 7.5), (3, 'ProductA', 3.0);
What is the average severity of vulnerabilities for each software product?
SELECT product, AVG(severity) as avg_severity FROM vulnerabilities GROUP BY product;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, followers INT, ad_revenue DECIMAL(10,2)); INSERT INTO users (id, followers, ad_revenue) VALUES (1, 15000, 500.00), (2, 12000, 450.00), (3, 18000, 600.00), (4, 9000, 300.00);
What was the average ad revenue in Q2 for users with over 10k followers?
SELECT AVG(ad_revenue) FROM users WHERE followers > 10000 AND QUARTER(registration_date) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE collective_bargaining (union_id INT, agreement_date DATE, agreement_duration INT); INSERT INTO collective_bargaining (union_id, agreement_date, agreement_duration) VALUES (1, '2021-01-01', 24); INSERT INTO collective_bargaining (union_id, agreement_date, agreement_duration) VALUES (2, '2022-05-15', 36);
Update "collective_bargaining" table where the "union_id" is 3
UPDATE collective_bargaining SET agreement_duration = 48 WHERE union_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartCities (id INT, country VARCHAR(50), project_count INT); INSERT INTO SmartCities (id, country, project_count) VALUES (1, 'Nigeria', 12), (2, 'Egypt', 8), (3, 'South Africa', 15), (4, 'Morocco', 9);
How many smart city projects are there in the African continent?
SELECT SUM(project_count) FROM SmartCities WHERE country IN ('Nigeria', 'Egypt', 'South Africa', 'Morocco', 'Tunisia');
gretelai_synthetic_text_to_sql
CREATE TABLE species (species_id INT, species_name TEXT); INSERT INTO species (species_id, species_name) VALUES (1, 'Fish species A'), (2, 'Fish species B'); CREATE TABLE biomass (biomass_id INT, species_id INT, region_id INT, biomass FLOAT); INSERT INTO biomass (biomass_id, species_id, region_id, biomass) VALUES (1, 1, 1, 150.3), (2, 1, 2, 160.5), (3, 2, 1, 140.2), (4, 2, 2, 130.1), (5, 2, 3, 120.9); CREATE TABLE region (region_id INT, region_name TEXT); INSERT INTO region (region_id, region_name) VALUES (1, 'North Atlantic'), (2, 'South Atlantic'), (3, 'Indian Ocean');
What is the total biomass for fish species B in the Atlantic Ocean?
SELECT SUM(biomass) FROM biomass WHERE species_id = (SELECT species_id FROM species WHERE species_name = 'Fish species B') AND region_id IN (SELECT region_id FROM region WHERE region_name LIKE '%Atlantic%');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, is_vegan BOOLEAN, price DECIMAL, country TEXT); INSERT INTO products (product_id, name, is_vegan, price, country) VALUES (1, 'Lipstick', TRUE, 15.99, 'USA'); INSERT INTO products (product_id, name, is_vegan, price, country) VALUES (2, 'Eye Shadow', FALSE, 12.49, 'Canada');
What is the average price of vegan cosmetics sold in the United States?
SELECT AVG(price) FROM products WHERE is_vegan = TRUE AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_transactions (tx_hash VARCHAR(255), block_number INT, timestamp TIMESTAMP, from_address VARCHAR(42), to_address VARCHAR(42), gas_price DECIMAL(18, 9));
What is the total number of Ethereum transactions with a gas price above 50 wei in Q2 2021?
SELECT COUNT(*) AS num_transactions FROM ethereum_transactions WHERE gas_price > 50 AND timestamp >= '2021-04-01 00:00:00' AND timestamp < '2021-07-01 00:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE legal_tech (record_id INT, location VARCHAR(20), tech_used VARCHAR(20), date DATE); INSERT INTO legal_tech (record_id, location, tech_used, date) VALUES (1, 'NY', 'AI', '2021-01-01'), (2, 'NY', 'Natural_Language_Processing', '2021-01-02'), (3, 'TX', 'AI', '2021-01-01'), (4, 'TX', 'Natural_Language_Processing', '2021-01-02'), (5, 'TX', 'AI', '2021-01-01'), (6, 'TX', 'Natural_Language_Processing', '2021-01-02'), (7, 'IL', 'AI', '2021-01-01'), (8, 'IL', 'Natural_Language_Processing', '2021-01-02');
List the unique tech_used values and their corresponding counts from the legal_tech table, but only for 'NY' and 'TX' locations.
SELECT tech_used, COUNT(*) FROM legal_tech WHERE location IN ('NY', 'TX') GROUP BY tech_used;
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityStrategies (ID INT, Country TEXT, Year INT, Strategy TEXT); INSERT INTO CybersecurityStrategies (ID, Country, Year, Strategy) VALUES (1, 'Japan', 2021, 'Quantum Cryptography'), (2, 'Japan', 2020, 'AI-driven Threat Intelligence'), (3, 'USA', 2021, 'Zero Trust Architecture');
What are the cybersecurity strategies of Japan in the past year?
SELECT Strategy FROM CybersecurityStrategies WHERE Country = 'Japan' AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Accounts (AccountId INT, AccountType VARCHAR(20), Balance DECIMAL(10,2)); INSERT INTO Accounts (AccountId, AccountType, Balance) VALUES (1, 'Checking', 2500.00), (2, 'Savings', 6000.00);
What are the Savings accounts with a balance greater than $4000?
SELECT AccountId, AccountType, Balance FROM Accounts WHERE AccountType = 'Savings' AND Balance > 4000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE fields (field_id INT, field_name VARCHAR(255), operator VARCHAR(255), discovery_date DATE);
Update the 'discovery_date' column in the 'fields' table for field 'F-01' to '2010-01-01'
UPDATE fields SET discovery_date = '2010-01-01' WHERE field_name = 'F-01';
gretelai_synthetic_text_to_sql