context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE regions (id INT PRIMARY KEY, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'Pacific'), (2, 'Atlantic'); CREATE TABLE operations (id INT PRIMARY KEY, region_id INT, year INT, FOREIGN KEY (region_id) REFERENCES regions(id));
How many cargo handling operations were performed in the 'Pacific' region in 2020?
SELECT COUNT(*) FROM operations WHERE region_id = (SELECT id FROM regions WHERE name = 'Pacific') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (application_id TEXT, community_type TEXT, submission_date DATE); INSERT INTO creative_ai (application_id, community_type, submission_date) VALUES ('App1', 'Underrepresented', '2020-02-12'), ('App2', 'Represented', '2019-06-15'), ('App3', 'Underrepresented', '2020-11-05');
Count of creative AI applications submitted from underrepresented communities in 2020.
SELECT COUNT(*) FROM creative_ai WHERE community_type = 'Underrepresented' AND submission_date >= '2020-01-01' AND submission_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE flood_control_projects (id INT, project_name VARCHAR(255), location VARCHAR(255), construction_cost INT, people_served INT); INSERT INTO flood_control_projects (id, project_name, location, construction_cost, people_served) VALUES (1, 'Levee System', 'Midwest', 25000000, 50000), (2, 'Floodplain Restoration', 'Midwest', 18000000, 30000), (3, 'Detention Basin', 'Midwest', 22000000, 40000);
List all flood control projects in the Midwest that were constructed between 1990 and 2000, along with their construction cost and the number of people served, and rank them by the construction cost in ascending order.
SELECT project_name, construction_cost, people_served, ROW_NUMBER() OVER (ORDER BY construction_cost ASC) as rank FROM flood_control_projects WHERE location = 'Midwest' AND construction_cost BETWEEN 1990 AND 2000 GROUP BY project_name, construction_cost, people_served;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investments (id INT, value INT, location VARCHAR(50)); INSERT INTO impact_investments (id, value, location) VALUES (1, 12000, 'South Asia'), (2, 7000, 'East Asia'), (3, 15000, 'South Asia');
What is the count of impact investments in South Asia with a value greater than 10000?
SELECT COUNT(*) FROM impact_investments WHERE location = 'South Asia' AND value > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, element VARCHAR(10), quantity INT); INSERT INTO production (country, year, element, quantity) VALUES ('China', 2020, 'Nd', 120000), ('Australia', 2020, 'Nd', 8000), ('China', 2020, 'Pr', 130000), ('China', 2020, 'Dy', 140000);
How many unique elements were produced in each country in 2020?
SELECT country, COUNT(DISTINCT element) FROM production WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE CertificationLevels (LevelID INT, Level VARCHAR(50)); CREATE TABLE MentalHealthScores (MH_ID INT, LevelID INT, MentalHealthScore INT); INSERT INTO CertificationLevels (LevelID, Level) VALUES (1, 'Basic'), (2, 'Intermediate'), (3, 'Advanced'); INSERT INTO MentalHealthScores (MH_ID, LevelID, MentalHealthScore) VALUES (1, 1, 70), (2, 1, 75), (3, 2, 80), (4, 2, 85), (5, 3, 90), (6, 3, 95);
What is the minimum mental health score by community health worker certification level?
SELECT c.Level, MIN(mhs.MentalHealthScore) as Min_Score FROM MentalHealthScores mhs JOIN CertificationLevels c ON mhs.LevelID = c.LevelID GROUP BY c.Level;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT, organization VARCHAR(255), region VARCHAR(255), amount DECIMAL(10,2));
What is the minimum amount of funding received by a refugee support organization in the Middle East?
SELECT MIN(amount) FROM funding WHERE region = 'Middle East' AND organization LIKE '%refugee support%';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation FLOAT, quarter TEXT, year INT); INSERT INTO Donors (id, name, country, donation, quarter, year) VALUES (1, 'Charlie', 'USA', 100.0, 'Q2', 2021), (2, 'David', 'Mexico', 150.0, 'Q2', 2021), (3, 'Eve', 'Canada', 75.0, 'Q2', 2021), (4, 'Frank', 'USA', 200.0, 'Q3', 2021), (5, 'Greg', 'India', 50.0, 'Q1', 2021);
What is the total number of unique countries that have made donations in 2021?
SELECT COUNT(DISTINCT country) FROM Donors WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, Ethnicity VARCHAR(255), Diagnosis VARCHAR(255)); INSERT INTO Patients (PatientID, Age, Ethnicity, Diagnosis) VALUES (1, 35, 'Hispanic', 'Influenza'); CREATE TABLE DiagnosisHistory (PatientID INT, Diagnosis VARCHAR(255), DiagnosisDate DATE); INSERT INTO DiagnosisHistory (PatientID, Diagnosis, DiagnosisDate) VALUES (1, 'Influenza', '2021-03-15');
What is the average age of patients who have been diagnosed with influenza in the past year, grouped by their ethnicity?
SELECT Ethnicity, AVG(Age) FROM Patients p JOIN DiagnosisHistory dh ON p.PatientID = dh.PatientID WHERE dh.Diagnosis = 'Influenza' AND dh.DiagnosisDate >= DATEADD(year, -1, GETDATE()) GROUP BY Ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, State VARCHAR(2), ParityStatus VARCHAR(10)); CREATE TABLE CulturalCompetency (ID INT PRIMARY KEY, State VARCHAR(2), CompetencyStatus VARCHAR(10));
Create a view to display state and parity status
CREATE VIEW ParityView AS SELECT State, ParityStatus FROM MentalHealthParity;
gretelai_synthetic_text_to_sql
CREATE TABLE risk_assessments (id INT, investment_id INT, risk_level VARCHAR(255), assessment_date DATE); INSERT INTO risk_assessments (id, investment_id, risk_level, assessment_date) VALUES (1, 1, 'Low', '2022-01-15'), (2, 2, 'Medium', '2022-02-15'); CREATE TABLE impact_investments (id INT, sector VARCHAR(255), project VARCHAR(255), location VARCHAR(255), amount FLOAT); INSERT INTO impact_investments (id, sector, project, location, amount) VALUES (1, 'Water and Sanitation', 'Water Purification Plant', 'Kenya', 2000000.00), (2, 'Renewable Energy', 'Wind Farm Project', 'Egypt', 5000000.00);
What are the total investment amounts and the associated risk levels for the Water and Sanitation sector investments in African countries?
SELECT i.sector, SUM(i.amount) as total_amount, r.risk_level FROM impact_investments i INNER JOIN risk_assessments r ON i.id = r.investment_id WHERE i.sector = 'Water and Sanitation' AND i.location LIKE 'Africa%' GROUP BY i.sector, r.risk_level;
gretelai_synthetic_text_to_sql
CREATE TABLE nutrition_data (state VARCHAR(20), calories INT); INSERT INTO nutrition_data (state, calories) VALUES ('California', 2000), ('Texas', 2500), ('New York', 1800);
What is the total calorie intake by state?
SELECT state, SUM(calories) FROM nutrition_data GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE spending (id INT, location VARCHAR(20), amount FLOAT); INSERT INTO spending (id, location, amount) VALUES (1, 'rural Montana', 5000000);
What is the total healthcare spending in rural Montana?
SELECT SUM(amount) FROM spending WHERE location = 'rural Montana';
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (DepartmentID INT PRIMARY KEY, DepartmentName VARCHAR(50), EmployeesCount INT);
Insert new records into the Departments table
INSERT INTO Departments (DepartmentID, DepartmentName, EmployeesCount) VALUES (1, 'HR', 100), (2, 'IT', 200), (3, 'Finance', 50), (4, 'Marketing', 75), (5, 'Legal', 150), (6, 'Sales', 125), (7, 'Diversity and Inclusion', 5);
gretelai_synthetic_text_to_sql
CREATE TABLE patents (patent_id INT, patent_number INT, filing_date DATE, vehicle_id INT); CREATE TABLE vehicles (vehicle_id INT, manufacture VARCHAR(20), has_autonomous_features BOOLEAN);
How many autonomous vehicle patents were filed in the last 3 years?
SELECT COUNT(*) FROM patents p JOIN vehicles v ON p.vehicle_id = v.vehicle_id WHERE has_autonomous_features = TRUE AND p.filing_date >= DATEADD(year, -3, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, content TEXT, created_at TIMESTAMP); CREATE VIEW latest_post AS SELECT posts.user_id, MAX(posts.created_at) AS latest_post FROM posts GROUP BY posts.user_id;
Insert new users and their posts.
INSERT INTO users (id, name, country) VALUES (1, 'Alice', 'Australia'), (2, 'Bob', 'Canada'); INSERT INTO posts (id, user_id, content, created_at) SELECT NULL, users.id, 'Hello World!', NOW() FROM users WHERE users.id NOT IN (SELECT latest_post.user_id FROM latest_post);
gretelai_synthetic_text_to_sql
CREATE TABLE Accessible_Tech (company VARCHAR(50), product VARCHAR(50)); INSERT INTO Accessible_Tech (company, product) VALUES ('Google', 'Screen Reader'), ('Microsoft', 'Adaptive Keyboard'), ('Apple', 'Voice Control'), ('IBM', 'Accessibility Checker');
What is the total number of accessible technology products by company?
SELECT company, COUNT(product) FROM Accessible_Tech GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption(material VARCHAR(20), water_consumption DECIMAL(5,2)); INSERT INTO water_consumption(material, water_consumption) VALUES('organic cotton', 20.00), ('recycled polyester', 15.00), ('hemp', 10.00);
What is the average water consumption for producing the top 2 sustainable materials?
SELECT AVG(water_consumption) FROM water_consumption WHERE material IN (SELECT material FROM water_consumption ORDER BY water_consumption LIMIT 2);
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(50)); CREATE TABLE charging_stations (id INT, city_id INT, station_count INT); INSERT INTO cities (id, name) VALUES (1, 'San Francisco'), (2, 'Los Angeles'), (3, 'New York'); INSERT INTO charging_stations (id, city_id, station_count) VALUES (1, 1, 500), (2, 2, 700), (3, 3, 800);
Which cities have adopted electric vehicle charging stations?
SELECT DISTINCT c.name FROM cities c JOIN charging_stations cs ON c.id = cs.city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE covid_cases (id INT, location TEXT, confirmed INT); INSERT INTO covid_cases (id, location, confirmed) VALUES (1, 'New York City', 500); INSERT INTO covid_cases (id, location, confirmed) VALUES (2, 'Chicago', 400);
How many confirmed COVID-19 cases were reported in Chicago?
SELECT SUM(confirmed) FROM covid_cases WHERE location = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE flights (flight_id INT, aircraft_type VARCHAR(50), flight_time INT);
What is the average flight time for each aircraft type?
SELECT aircraft_type, AVG(flight_time) as avg_flight_time FROM flights GROUP BY aircraft_type;
gretelai_synthetic_text_to_sql
CREATE TABLE investigative_reports (id INT, title VARCHAR(255), author VARCHAR(255), publication_date DATE);
What is the total number of articles published in each month of the year in the 'investigative_reports' table?
SELECT EXTRACT(MONTH FROM publication_date) as month, COUNT(*) as total_articles FROM investigative_reports GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, sector VARCHAR(20), esg_score FLOAT); INSERT INTO investments (id, sector, esg_score) VALUES (1, 'Healthcare', 80.5), (2, 'Finance', 72.3), (3, 'Healthcare', 84.2);
What's the average ESG score for all investments in the Healthcare sector?
SELECT AVG(esg_score) FROM investments WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT PRIMARY KEY, title VARCHAR(100), principal_investigator VARCHAR(50), amount NUMERIC, start_date DATE, end_date DATE);
Delete a research grant record from the "grants" table
WITH deleted_grant AS (DELETE FROM grants WHERE id = 3 RETURNING *) SELECT * FROM deleted_grant;
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (country VARCHAR(2), regulation_name VARCHAR(100));
Insert a new record into the "regulations" table with "country" as "Australia", "regulation_name" as "Australian Securities and Investments Commission Act 2001"
INSERT INTO regulations (country, regulation_name) VALUES ('AU', 'Australian Securities and Investments Commission Act 2001');
gretelai_synthetic_text_to_sql
CREATE TABLE facility_supplies (id INT, facility_id INT, supply_id INT, supply_quantity INT, received_date DATE); INSERT INTO facility_supplies (id, facility_id, supply_id, supply_quantity, received_date) VALUES (1, 1, 1, 50, '2021-02-03'); INSERT INTO facility_supplies (id, facility_id, supply_id, supply_quantity, received_date) VALUES (2, 2, 2, 75, '2021-02-04');
How many supplies were received by each facility, tiered by quantity?
SELECT facility_id, NTILE(2) OVER (ORDER BY SUM(supply_quantity) DESC) as tier, SUM(supply_quantity) as total_quantity FROM facility_supplies GROUP BY facility_id;
gretelai_synthetic_text_to_sql
CREATE TABLE roads (name VARCHAR(255), intersects VARCHAR(255)); INSERT INTO roads (name, intersects) VALUES ('Road1', 'Main Street'), ('Road2', 'Second Street'), ('Road3', 'Main Street');
Which roads in the 'infrastructure' schema intersect with the road named 'Main Street'?
SELECT name FROM roads WHERE intersects = 'Main Street';
gretelai_synthetic_text_to_sql
CREATE TABLE StateX_Infrastructure (Quarter INT, Year INT, Amount FLOAT); INSERT INTO StateX_Infrastructure (Quarter, Year, Amount) VALUES (1, 2022, 2500000), (2, 2022, 3000000);
What is the total amount of funds spent on infrastructure projects in 'StateX' in Q1 and Q2 of 2022?
SELECT SUM(Amount) FROM StateX_Infrastructure WHERE Year = 2022 AND Quarter <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO museums (id, name, country, visitors) VALUES (1, 'Museum A', 'Spain', 25000), (2, 'Museum B', 'Spain', 30000), (3, 'Museum C', 'France', 22000);
What is the maximum number of visitors for a museum in Spain?
SELECT MAX(visitors) FROM museums WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE streams (song_id INT, artist_id INT, platform VARCHAR(50), stream_count INT); INSERT INTO streams (song_id, artist_id, platform, stream_count) VALUES (1, 1, 'Spotify', 1000000), (2, 2, 'Apple Music', 2000000);
_What is the average number of streams for songs in the Pop genre on Spotify, for artists with more than 5 million total streams across all platforms?_
SELECT AVG(s.stream_count) FROM streams s JOIN artists a ON s.artist_id = a.id WHERE s.platform = 'Spotify' AND a.genre = 'Pop' AND a.total_streams > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices (id INT, country VARCHAR(255), year INT, carbon_price DECIMAL(5,2)); INSERT INTO carbon_prices (id, country, year, carbon_price) VALUES (1, 'US', 2019, 15.0), (2, 'Mexico', 2019, 10.0);
What was the minimum carbon price in the US and Mexico in 2019?
SELECT MIN(carbon_price) FROM carbon_prices WHERE country IN ('US', 'Mexico') AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, Program TEXT);
How many volunteers signed up in each program?
SELECT Program, COUNT(*) FROM Volunteers GROUP BY Program;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Id INT, Name VARCHAR(50), Age INT, Amount DECIMAL(10,2)); INSERT INTO Donors (Id, Name, Age, Amount) VALUES (1, 'Ella Davis', 45, 1200.00), (2, 'Avery Thompson', 50, 1500.00), (3, 'Scarlett White', 55, 1800.00); CREATE TABLE Recipients (Id INT, Name VARCHAR(50), Age INT, Amount DECIMAL(10,2)); INSERT INTO Recipients (Id, Name, Age, Amount) VALUES (1, 'Mental Health Support', 60, 1000.00), (2, 'Disaster Relief', 65, 1300.00), (3, 'Climate Change Action', 70, 1600.00);
Who are the donors that have donated the same amount as or more than the average donation amount for recipients?
SELECT Name FROM Donors WHERE Amount >= (SELECT AVG(Amount) FROM Recipients);
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, name TEXT, owner TEXT, energy_consumption FLOAT); INSERT INTO GreenBuildings (id, name, owner, energy_consumption) VALUES (1, 'EcoTower', 'ACME Inc', 1500.0), (2, 'GreenSpire', 'GreenCorp', 1200.0), (3, 'GreenVista', 'ACME Inc', 1300.0), (4, 'GreenPlaza', 'EcoInnovations', 1000.0);
What is the average energy consumption for buildings owned by 'GreenCorp' and 'EcoInnovations'?
SELECT AVG(energy_consumption) FROM GreenBuildings WHERE owner IN ('GreenCorp', 'EcoInnovations');
gretelai_synthetic_text_to_sql
CREATE TABLE FinancialWellbeing (userID VARCHAR(20), wellbeingScore INT); INSERT INTO FinancialWellbeing (userID, wellbeingScore) VALUES ('Ahmed', 6), ('Sara', 8), ('Mohammed', 7);
Find the user with the highest financial wellbeing score in the FinancialWellbeing table.
SELECT userID, MAX(wellbeingScore) FROM FinancialWellbeing;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), donation_amount DECIMAL(10, 2), donation_date DATE);
Delete the record for donor_id 2001
DELETE FROM donors WHERE donor_id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtTypes (TypeID int, Name varchar(50)); CREATE TABLE ArtPieces (ArtPieceID int, Title varchar(50), YearCreated int, TypeID int);
What are the most common types of artwork?
SELECT ArtTypes.Name, COUNT(ArtPieces.ArtPieceID) AS ArtPiecesCount FROM ArtTypes INNER JOIN ArtPieces ON ArtTypes.TypeID = ArtPieces.TypeID GROUP BY ArtTypes.Name ORDER BY ArtPiecesCount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Satisfaction (Year INT, Category TEXT, Score INT); INSERT INTO Satisfaction (Year, Category, Score) VALUES (2021, 'Healthcare', 8), (2021, 'Education', 7), (2021, 'Transportation', 6);
What is the average citizen satisfaction score for 2021, by service category?
SELECT Category, AVG(Score) FROM Satisfaction WHERE Year = 2021 GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE prenatal_care (patient_id INT, state TEXT, pregnant INT, adequate_care INT); INSERT INTO prenatal_care (patient_id, state, pregnant, adequate_care) VALUES (1, 'California', 1, 1);
How many pregnant women in the state of California have received adequate prenatal care?
SELECT COUNT(*) FROM prenatal_care WHERE state = 'California' AND pregnant = 1 AND adequate_care = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_stops (stop_id INT, route_id INT, stop_sequence INT, stop_time TIME); INSERT INTO bus_stops (stop_id, route_id, stop_sequence, stop_time) VALUES (1, 1, 1, '00:05:00'), (2, 1, 2, '00:10:00'), (3, 1, 3, '00:15:00'), (4, 2, 1, '00:03:00'), (5, 2, 2, '00:08:00'), (6, 2, 3, '00:13:00');
What is the average time between bus stops for each route?
SELECT route_id, AVG(TIMESTAMPDIFF(SECOND, LAG(stop_time) OVER (PARTITION BY route_id ORDER BY stop_sequence), stop_time)) AS avg_time_between_stops FROM bus_stops GROUP BY route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, has_heart_disease BOOLEAN); INSERT INTO patients (id, name, age, has_heart_disease) VALUES (1, 'John Doe', 65, true), (2, 'Jane Smith', 45, false), (3, 'Bob Johnson', 35, false);
What is the prevalence of heart disease in each age group, and what is the total population in each age group?
SELECT FLOOR(patients.age / 10) * 10 AS age_group, COUNT(patients.id), SUM(CASE WHEN patients.has_heart_disease = true THEN 1 ELSE 0 END) FROM patients GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, name VARCHAR(255), city VARCHAR(255), wheelchair_accessible BOOLEAN, sold_date DATE); INSERT INTO properties (property_id, name, city, wheelchair_accessible, sold_date) VALUES (1, 'The Accessible Abode', 'Denver', true, '2020-01-01'), (2, 'The Pet-friendly Pad', 'Denver', false, '2022-01-01'), (3, 'The Wheelchair Wonders', 'Denver', true, NULL);
What are the names and wheelchair accessibility statuses of properties in the city of Denver that have not been sold in the past year?
SELECT name, wheelchair_accessible FROM properties WHERE city = 'Denver' AND sold_date IS NULL OR sold_date < DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, timestamp TIMESTAMP, region VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO security_incidents (id, timestamp, region, incident_type) VALUES (1, '2021-01-01 10:00:00', 'North America', 'malware'), (2, '2021-01-02 12:30:00', 'Europe', 'phishing'), (3, '2021-01-03 08:15:00', 'Asia', 'ddos');
How many security incidents occurred in each region, in the last year?
SELECT region, COUNT(*) as incident_count FROM security_incidents WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 YEAR) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, judge_race VARCHAR(20), state VARCHAR(20), open_date DATE); INSERT INTO cases (case_id, judge_race, state, open_date) VALUES (1, 'White', 'California', '2019-01-01'), (2, 'Black', 'California', '2020-01-01'), (3, 'Asian', 'California', '2019-01-01');
How many criminal cases were open in the state of California on January 1, 2020 that were resolved by a judge who is a member of a racial or ethnic minority?
SELECT COUNT(*) FROM cases WHERE state = 'California' AND open_date < '2020-01-01' AND judge_race NOT IN ('White', 'Hispanic');
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftModels (model_id INT, name VARCHAR(50), manufacturer VARCHAR(50), country VARCHAR(50)); INSERT INTO AircraftModels (model_id, name, manufacturer, country) VALUES (1, 'Air1', 'AvionicCorp', 'USA'), (2, 'Air2', 'AeroCanada', 'Canada'), (3, 'Air3', 'EuroJet', 'France'), (4, 'Air4', 'AvionicCorp', 'Mexico');
What are the names of all countries that have manufactured aircraft?
SELECT DISTINCT country FROM AircraftModels;
gretelai_synthetic_text_to_sql
CREATE TABLE schools_region (id INT PRIMARY KEY, school_name TEXT, school_type TEXT, region TEXT, built_date DATE); INSERT INTO schools_region (id, school_name, school_type, region, built_date) VALUES (1, 'Primary School', 'Public', 'Asia', '2020-01-01');
How many schools have been built per region in 2020 and 2021?
SELECT region, COUNT(*) as schools_built FROM schools_region WHERE built_date >= '2020-01-01' AND built_date < '2022-01-01' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE innovation_trends (trend_id INT, trend_name VARCHAR(50), description VARCHAR(200));
Create a table for innovation trends
CREATE TABLE innovation_trends (trend_id INT, trend_name VARCHAR(50), description VARCHAR(200));
gretelai_synthetic_text_to_sql
CREATE TABLE patient_info_2023 (patient_id INT, first_treatment_date DATE); INSERT INTO patient_info_2023 (patient_id, first_treatment_date) VALUES (5, '2023-02-03'), (6, '2023-01-15'), (7, '2023-06-28'), (8, NULL); CREATE TABLE therapy_sessions_2023 (patient_id INT, session_date DATE); INSERT INTO therapy_sessions_2023 (patient_id, session_date) VALUES (5, '2023-02-03'), (7, '2023-06-28'), (7, '2023-06-30');
Find the first treatment date for each patient who started therapy in '2023'
SELECT patient_id, MIN(session_date) AS first_treatment_date FROM therapy_sessions_2023 WHERE patient_id IN (SELECT patient_id FROM patient_info_2023 WHERE first_treatment_date IS NULL OR first_treatment_date = '2023-01-01') GROUP BY patient_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ConcertTickets (ticket_id INT, genre VARCHAR(20), price DECIMAL(5,2));
What is the minimum ticket price for Latin music concerts?
SELECT MIN(price) FROM ConcertTickets WHERE genre = 'Latin';
gretelai_synthetic_text_to_sql
CREATE TABLE West_Materials (location VARCHAR(20), material VARCHAR(30), cost FLOAT, order_date DATE); INSERT INTO West_Materials VALUES ('CA', 'Concrete', 1200, '2022-01-05'), ('WA', 'Cement', 900, '2022-02-10'), ('OR', 'Insulation', 700, '2022-03-15');
What is the total cost of construction materials in the West, partitioned by month?
SELECT location, material, SUM(cost) OVER (PARTITION BY EXTRACT(MONTH FROM order_date)) as total_cost FROM West_Materials;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_agents (id INT, name VARCHAR(50), position VARCHAR(50), agency VARCHAR(50));
What are the names and positions of intelligence agents who work for the external_intelligence agency, listed in the intelligence_agents table?
SELECT name, position FROM intelligence_agents WHERE agency = 'external_intelligence';
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Buildings (id INT, region VARCHAR(20), CO2_emission FLOAT); INSERT INTO Green_Buildings (id, region, CO2_emission) VALUES (1, 'Europe', 45.2), (2, 'Asia', 56.3), (3, 'Africa', 33.9);
What is the average CO2 emission of green buildings in Europe?
SELECT AVG(CO2_emission) FROM Green_Buildings WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_total_depths (name VARCHAR(255), basin VARCHAR(255), depth FLOAT); INSERT INTO marine_species_total_depths (name, basin, depth) VALUES ('Species1', 'Atlantic', 123.45), ('Species2', 'Pacific', 567.89), ('Species3', 'Indian', 345.67), ('Species4', 'Atlantic', 789.10);
What is the total depth of all marine species in the Indian basin, grouped by species name?
SELECT name, SUM(depth) as total_depth FROM marine_species_total_depths WHERE basin = 'Indian' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT PRIMARY KEY, vessel_id INT, max_speed FLOAT, avg_speed FLOAT, fuel_efficiency FLOAT);
List all records from the "vessel_performance" table.
SELECT * FROM vessel_performance;
gretelai_synthetic_text_to_sql
CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(255), population INT); CREATE TABLE ResourceManagement (id INT PRIMARY KEY, location VARCHAR(255), manager VARCHAR(255));
What is the species name and corresponding management location for all species with a population over 700?
SELECT Species.name, ResourceManagement.location FROM Species INNER JOIN ResourceManagement ON 1=1 WHERE Species.population > 700;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score INT); INSERT INTO suppliers (id, name, location, sustainability_score) VALUES (1, 'Supplier X', 'Paris', 86);
What is the name of the supplier with a sustainability score greater than 85?
SELECT name FROM suppliers WHERE sustainability_score > 85;
gretelai_synthetic_text_to_sql
CREATE TABLE certifications (id INT, certifier_name VARCHAR(50), country VARCHAR(50), total_certified INT); INSERT INTO certifications (id, certifier_name, country, total_certified) VALUES (1, 'Fair Trade USA', 'USA', 3000), (2, 'Ethical Trade', 'UK', 2500), (3, 'Business Social Compliance Initiative', 'Germany', 2000);
Who is the top ethical labor practice certifier in the United States?
SELECT certifier_name, total_certified FROM certifications WHERE country = 'USA' AND total_certified = (SELECT MAX(total_certified) FROM certifications WHERE country = 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, delivery_time INT, country VARCHAR(50)); INSERT INTO orders (id, delivery_time, country) VALUES (1, 5, 'Australia'), (2, 3, 'Canada'), (3, 7, 'Australia');
What is the maximum delivery time for orders shipped to Australia?
SELECT MAX(delivery_time) FROM orders WHERE country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE mine_equipment (id INT, state VARCHAR(50), machine_type VARCHAR(50), production INT); INSERT INTO mine_equipment (id, state, machine_type, production) VALUES (1, 'Queensland', 'Coal Machine', 5500); INSERT INTO mine_equipment (id, state, machine_type, production) VALUES (2, 'Queensland', 'Coal Machine', 6000);
What is the average coal production per machine in Queensland, Australia, that has produced more than 5000 tons in a year?
SELECT AVG(production) FROM mine_equipment WHERE state = 'Queensland' AND production > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (id INT, timestamp TIMESTAMP, algorithm VARCHAR, explainability FLOAT);
What is the trend of explainability scores for AI algorithms in the explainable AI dataset over time?
SELECT algorithm, timestamp, AVG(explainability) OVER (PARTITION BY algorithm ORDER BY timestamp RANGE BETWEEN INTERVAL '1 day' PRECEDING AND CURRENT ROW) FROM explainable_ai;
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (neighborhood_id INT, name VARCHAR(255));CREATE TABLE properties (property_id INT, neighborhood_id INT, price INT, coowners INT); INSERT INTO neighborhoods (neighborhood_id, name) VALUES (1, 'Central Park'), (2, 'SoHo'); INSERT INTO properties (property_id, neighborhood_id, price, coowners) VALUES (1, 1, 500000, 2), (2, 1, 600000, 1), (3, 2, 800000, 4);
What is the average property price in each neighborhood for co-owned properties?
SELECT neighborhoods.name, AVG(properties.price) as avg_price FROM properties JOIN neighborhoods ON properties.neighborhood_id = neighborhoods.neighborhood_id WHERE properties.coowners > 1 GROUP BY neighborhoods.name;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name TEXT, menu_type TEXT, price DECIMAL, daily_sales INT, region TEXT); CREATE VIEW vegetarian_menu AS SELECT * FROM menu WHERE menu_type = 'vegetarian';
What is the most expensive vegetarian menu item in the Central region?
SELECT menu_name, MAX(price) FROM vegetarian_menu WHERE region = 'Central';
gretelai_synthetic_text_to_sql
CREATE TABLE Matches (MatchID INT, PlayerID INT, Game VARCHAR(50), Wins INT); INSERT INTO Matches (MatchID, PlayerID, Game, Wins) VALUES (1, 1, 'Shooter Game 2022', 45), (2, 1, 'Shooter Game 2022', 52), (3, 2, 'Shooter Game 2022', 60), (4, 3, 'Racing Simulator 2022', 30);
What is the maximum number of wins for a player in "Shooter Game 2022"?
SELECT MAX(Wins) FROM Matches WHERE Game = 'Shooter Game 2022';
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name TEXT, manufacturer TEXT, retail_price DECIMAL); INSERT INTO drugs (drug_id, drug_name, manufacturer, retail_price) VALUES (1, 'DrugA', 'ManuA', 100.00), (2, 'DrugB', 'ManuB', 150.00);
What is the average retail price of all drugs in Spain?
SELECT AVG(retail_price) FROM drugs WHERE manufacturer = 'ManuA' AND country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE RetailSales (id INT, garment_type VARCHAR(20), country VARCHAR(20), revenue DECIMAL(10, 2), year INT); INSERT INTO RetailSales (id, garment_type, country, revenue, year) VALUES (1, 'Dress', 'Japan', 75.50, 2021), (2, 'Shirt', 'Japan', 120.00, 2021), (3, 'Pant', 'Japan', 100.00, 2021), (4, 'Jacket', 'Japan', 150.00, 2021), (5, 'Shirt', 'Japan', 50.00, 2021), (6, 'Dress', 'Japan', 60.00, 2021);
What was the average retail sales revenue per 'Pant' item in Japan in 2021?
SELECT AVG(revenue) as avg_revenue_per_item FROM RetailSales WHERE garment_type = 'Pant' AND country = 'Japan' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStock (farm_id INT, date DATE, action VARCHAR(10), quantity INT); INSERT INTO FarmStock (farm_id, date, action, quantity) VALUES (1, '2021-01-01', 'added', 300), (1, '2021-01-05', 'removed', 50);
How many fish were removed from the Tilapia farm each month in 2021?
SELECT EXTRACT(MONTH FROM date) month, SUM(quantity) quantity FROM FarmStock WHERE farm_id = 1 AND YEAR(date) = 2021 AND action = 'removed' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE shows (id INT, title VARCHAR(100), genre VARCHAR(50), country VARCHAR(50), release_year INT, runtime INT);
How many shows were released in each country, and what is the total runtime for each country?
SELECT country, COUNT(*), SUM(runtime) FROM shows GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE epicquest_players_by_country (player_id INT, level INT, region VARCHAR(20), country VARCHAR(20)); INSERT INTO epicquest_players_by_country (player_id, level, region, country) VALUES (1, 25, 'North America', 'USA'), (2, 30, 'Europe', 'Germany'), (3, 22, 'Asia', 'Japan'), (4, 35, 'North America', 'Canada'), (5, 18, 'Europe', 'France'), (6, 28, 'Asia', 'South Korea');
What is the distribution of player levels in "EpicQuest" for players from different countries, grouped by region?
SELECT region, AVG(level) AS avg_level, MIN(level) AS min_level, MAX(level) AS max_level FROM epicquest_players_by_country GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (name VARCHAR(255), city VARCHAR(255), date DATE); INSERT INTO Exhibitions (name, city, date) VALUES ('Modern Art', 'New York', '2023-03-01'), ('Contemporary Art', 'Los Angeles', '2023-04-01'), ('Classic Art', 'New York', '2023-03-15'), ('Impressionism', 'Paris', '2023-05-01');
What is the date of the next art exhibition in New York?
SELECT MIN(date) FROM Exhibitions WHERE date > CURDATE() AND city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE donor_demographics (donor_id INTEGER, donor_name TEXT, age INTEGER, location TEXT); INSERT INTO donor_demographics (donor_id, donor_name, age, location) VALUES (1, 'John Smith', 35, 'New York'), (2, 'Jane Doe', 28, 'San Francisco');
Insert a new donor 'Ali Ahmed' from 'Pakistan' into the 'donor_demographics' table.
INSERT INTO donor_demographics (donor_id, donor_name, age, location) VALUES (3, 'Ali Ahmed', 45, 'Pakistan');
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, state VARCHAR(2), workers INT); INSERT INTO unions (id, state, workers) VALUES (1, 'CA', 5000), (2, 'TX', 7000);
What is the total number of workers in unions advocating for labor rights in California and Texas?
SELECT SUM(workers) FROM unions WHERE state IN ('CA', 'TX') AND issue = 'labor_rights';
gretelai_synthetic_text_to_sql
CREATE TABLE reo_production (id INT PRIMARY KEY, reo_type VARCHAR(50), impurity_level FLOAT, production_year INT);
Calculate the average impurity level for each REO type in 2023 from the reo_production table
SELECT reo_type, AVG(impurity_level) FROM reo_production WHERE production_year = 2023 GROUP BY reo_type;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (sensor_id INT, temperature FLOAT, reading_time TIMESTAMP); INSERT INTO sensor_data (sensor_id, temperature, reading_time) VALUES (1, 23.5, '2022-01-01 10:00:00'), (2, 25.3, '2022-01-01 10:00:00');
What is the most recent temperature reading for each sensor in the 'sensor_data' table?
SELECT sensor_id, temperature, reading_time FROM (SELECT sensor_id, temperature, reading_time, ROW_NUMBER() OVER (PARTITION BY sensor_id ORDER BY reading_time DESC) rn FROM sensor_data) t WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT PRIMARY KEY, equipment_name VARCHAR(100), origin VARCHAR(50), type VARCHAR(50));
Add new record to military_equipment table, including 'M1 Abrams' as equipment_name, 'USA' as origin, 'Tank' as type
INSERT INTO military_equipment (equipment_name, origin, type) VALUES ('M1 Abrams', 'USA', 'Tank');
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_research (id INT, study_name VARCHAR(50), method VARCHAR(50), data TEXT); INSERT INTO genetic_research (id, study_name, method, data) VALUES (1, 'Mutation Study 1', 'Genetic mutation analysis', 'ACTG...'); INSERT INTO genetic_research (id, study_name, method, data) VALUES (2, 'Sequencing Study 2', 'RNA sequencing', 'AGU...');
Show the genetic research studies and their methods from the 'genetic_research' table where the study is related to 'genetic mutations' or 'DNA sequencing' ordered by the study name in descending order.
SELECT study_name, method FROM genetic_research WHERE method LIKE '%genetic mutation%' OR method LIKE '%DNA sequencing%' ORDER BY study_name DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(255), genre VARCHAR(255), gender VARCHAR(10)); CREATE TABLE albums (album_id INT, album_name VARCHAR(255), release_year INT, artist_id INT, sales INT); INSERT INTO artists (artist_id, artist_name, genre, gender) VALUES (1, 'Beyoncé', 'R&B', 'Female'); INSERT INTO albums (album_id, album_name, release_year, artist_id, sales) VALUES (1, 'Dangerously in Love', 2003, 1, 5000000);
How many albums were sold by female R&B artists between 2000 and 2009?
SELECT SUM(albums.sales) FROM albums JOIN artists ON albums.artist_id = artists.artist_id WHERE artists.genre = 'R&B' AND artists.gender = 'Female' AND albums.release_year BETWEEN 2000 AND 2009;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), production_country VARCHAR(50), actor_name VARCHAR(255)); INSERT INTO movies (id, title, production_country, actor_name) VALUES (1, 'MovieE', 'Nigeria', 'ActorX'), (2, 'MovieF', 'South Africa', 'ActorY'), (3, 'MovieG', 'Egypt', 'ActorZ'), (4, 'MovieH', 'Nigeria', 'ActorX'), (5, 'MovieI', 'Kenya', 'ActorW');
Who are the top 5 actors with the highest number of movies produced in the African film industry?
SELECT actor_name, COUNT(*) as movie_count FROM movies WHERE production_country IN ('Nigeria', 'South Africa', 'Egypt', 'Kenya') GROUP BY actor_name ORDER BY movie_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_neutral_countries (id INT, country VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO carbon_neutral_countries (id, country, start_date, end_date) VALUES (1, 'Costa Rica', '2019-01-01', '2025-12-31');
What is the average expenditure per visitor for countries that have implemented carbon neutrality practices?
SELECT AVG(t2.total_expenditure/t2.international_visitors) as avg_expenditure, cnc.country FROM carbon_neutral_countries cnc JOIN tourism_spending t2 ON cnc.country = t2.country GROUP BY cnc.country;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_id INT, permit_date DATE, city TEXT, state TEXT); INSERT INTO building_permits VALUES (1, '2020-01-01', 'Chicago', 'Illinois'), (2, '2019-12-15', 'New York', 'New York'), (3, '2020-06-20', 'Houston', 'Texas'), (4, '2021-02-03', 'Chicago', 'Illinois'), (5, '2020-07-10', 'Denver', 'Colorado'), (6, '2020-07-25', 'Denver', 'Colorado');
What are the building permits for the city of Denver in the month of July 2020?
SELECT permit_id, permit_date, city, state FROM building_permits WHERE city = 'Denver' AND EXTRACT(MONTH FROM permit_date) = 7 AND EXTRACT(YEAR FROM permit_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (id INT, veteran_status VARCHAR(50), employment_date DATE);
Show veteran employment statistics for the last 3 months, grouped by month
SELECT MONTH(employment_date) AS month, COUNT(*) AS total FROM veteran_employment WHERE employment_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureCostsNY (State TEXT, Year INTEGER, ProjectType TEXT, ConstructionCost REAL); INSERT INTO InfrastructureCostsNY (State, Year, ProjectType, ConstructionCost) VALUES ('New York', 2017, 'Bridge', 1750000.0), ('New York', 2017, 'Highway', 2350000.0), ('New York', 2017, 'Tunnel', 3250000.0), ('New York', 2018, 'Bridge', 1850000.0), ('New York', 2018, 'Highway', 2450000.0), ('New York', 2018, 'Tunnel', 3350000.0), ('New York', 2019, 'Bridge', 1700000.0), ('New York', 2019, 'Highway', 2300000.0), ('New York', 2019, 'Tunnel', 3200000.0);
What was the total construction cost for infrastructure projects in New York from 2017 to 2019, broken down by project type?
SELECT Year, ProjectType, SUM(ConstructionCost) as TotalCost FROM InfrastructureCostsNY WHERE State = 'New York' GROUP BY Year, ProjectType;
gretelai_synthetic_text_to_sql
CREATE TABLE production_countries (country_id INT PRIMARY KEY, country_name TEXT, production_volume INT, production_sustainability_score INT); INSERT INTO production_countries (country_id, country_name, production_volume, production_sustainability_score) VALUES (1, 'China', 1000, 50), (2, 'Bangladesh', 800, 40), (3, 'India', 900, 55);
Which country has the highest production volume?
SELECT country_name, production_volume FROM production_countries ORDER BY production_volume DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE VisitorDemographics (visitor_id INT, age INT, gender VARCHAR(50), country VARCHAR(100));
Insert new records for visitor demographics
INSERT INTO VisitorDemographics (visitor_id, age, gender, country)
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policyholder_id INT, first_name VARCHAR(20), last_name VARCHAR(20), email VARCHAR(30), date_of_birth DATE, gender ENUM('M', 'F')); INSERT INTO policyholders (policyholder_id, first_name, last_name, email, date_of_birth, gender) VALUES (1, 'John', 'Doe', 'johndoe@example.com', '1985-05-15', 'M'), (2, 'Jane', 'Doe', 'janedoe@example.com', '1990-08-08', 'F'), (3, 'Bob', 'Smith', 'bobsmith@example.com', '1976-11-12', 'M'), (4, 'Alice', 'Johnson', 'alicejohnson@example.com', '1982-02-23', 'F');
Count policyholders by gender and age group
SELECT FLOOR(DATEDIFF(CURDATE(), date_of_birth)/365) AS age_group, gender, COUNT(*) AS num_policyholders FROM policyholders GROUP BY age_group, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE media_outlets (id INT, outlet_name VARCHAR(50), language VARCHAR(50)); INSERT INTO media_outlets (id, outlet_name, language) VALUES (1, 'OutletA', 'English'), (2, 'OutletB', 'Spanish'), (3, 'OutletA', 'French');
What is the number of articles published by media outlets A and B in each language, and the percentage of articles published in each language?
SELECT language, COUNT(*) as num_articles, (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM media_outlets) ) as percentage FROM media_outlets WHERE outlet_name IN ('OutletA', 'OutletB') GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, data_usage FLOAT, plan_type VARCHAR(10), region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, data_usage, plan_type, region) VALUES (1, 8.5, 'postpaid', 'Northeast'); INSERT INTO subscribers (subscriber_id, data_usage, plan_type, region) VALUES (2, 12.3, 'postpaid', 'Southeast');
What is the average monthly data usage for postpaid mobile subscribers in the last 12 months, partitioned by region?
SELECT region, AVG(data_usage) OVER (PARTITION BY region ORDER BY region ROWS BETWEEN 11 PRECEDING AND CURRENT ROW) as avg_data_usage FROM subscribers WHERE plan_type = 'postpaid' AND subscriber_id IN (SELECT subscriber_id FROM subscribers WHERE plan_type = 'postpaid' ORDER BY subscriber_id DESC LIMIT 12);
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (company_id INT, round_name TEXT, funding_amount INT); INSERT INTO investment_rounds (company_id, round_name, funding_amount) VALUES (1, 'Series A', 5000000); INSERT INTO investment_rounds (company_id, round_name, funding_amount) VALUES (1, 'Series C', 15000000); INSERT INTO investment_rounds (company_id, round_name, funding_amount) VALUES (2, 'Series B', 10000000);
List all companies that have not had a series B funding round
SELECT company_id, name FROM company c LEFT JOIN (SELECT company_id FROM investment_rounds WHERE round_name = 'Series B') ir ON c.id = ir.company_id WHERE ir.company_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_plants (name VARCHAR(50), location VARCHAR(50), capacity FLOAT, primary key (name)); INSERT INTO solar_plants (name, location, capacity) VALUES ('Plant X', 'California', 120), ('Plant Y', 'Arizona', 180), ('Plant Z', 'Nevada', 210); CREATE TABLE solar_production (solar_plant VARCHAR(50), date DATE, energy_production FLOAT, primary key (solar_plant, date), foreign key (solar_plant) references solar_plants(name)); INSERT INTO solar_production (solar_plant, date, energy_production) VALUES ('Plant X', '2021-01-01', 1500), ('Plant X', '2021-01-02', 1600), ('Plant Y', '2021-01-01', 2200), ('Plant Y', '2021-01-02', 2500), ('Plant Z', '2021-01-01', 3000), ('Plant Z', '2021-01-02', 3100);
Identify the solar power plant with the highest energy production in a given year.
SELECT solar_plant, MAX(energy_production) as max_production FROM solar_production WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY solar_plant, EXTRACT(YEAR FROM date) ORDER BY max_production DESC LIMIT 1
gretelai_synthetic_text_to_sql
CREATE TABLE country_shipments (shipment_id INT, country VARCHAR(20), package_count INT); INSERT INTO country_shipments (shipment_id, country, package_count) VALUES (1, 'USA', 3), (2, 'Canada', 2), (3, 'Mexico', 1), (4, 'USA', 1), (5, 'Canada', 1), (6, 'USA', 1);
What is the total number of packages shipped to each country?
SELECT country, SUM(package_count) FROM country_shipments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_name VARCHAR(255), contact_info VARCHAR(255), program VARCHAR(255), hours INT); INSERT INTO Donations (id, donor_name, contact_info, program, hours) VALUES (1, 'Daniel Kim', 'danielkim@example.com', 'Environmental', 20), (2, 'Elena Thompson', 'elenathompson@example.com', 'Environmental', 15), (3, 'Felipe Rodriguez', 'feliperodriguez@example.com', 'Education', 30);
What is the total number of donation hours for the environmental program?
SELECT SUM(hours) FROM Donations WHERE program = 'Environmental';
gretelai_synthetic_text_to_sql
CREATE TABLE production(year INT, region VARCHAR(20), element VARCHAR(10), quantity INT); INSERT INTO production VALUES(2018, 'North America', 'Dysprosium', 1500), (2019, 'North America', 'Dysprosium', 1800), (2020, 'North America', 'Dysprosium', 2000);
What is the total production of Dysprosium in the 'North America' region for each year?
SELECT year, SUM(quantity) FROM production WHERE element = 'Dysprosium' AND region = 'North America' GROUP BY year
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), speed FLOAT, location VARCHAR(50), timestamp DATETIME);
Insert a new record for vessel 'VesselI' with a speed of 16.5 knots, located near the coast of Greece on October 1, 2021.
INSERT INTO vessel_performance (name, type, speed, location, timestamp) VALUES ('VesselI', 'Cargo', 16.5, 'Greece Coast', '2021-10-01 10:00:00');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_id INT, product_name TEXT, cruelty_free BOOLEAN, consumer_rating FLOAT); INSERT INTO cosmetics VALUES (1, 'Lipstick A', true, 4.6), (2, 'Foundation B', false, 4.3), (3, 'Mascara C', true, 4.7), (4, 'Eyeshadow D', true, 4.5), (5, 'Blush E', false, 4.4);
What is the average consumer rating for cruelty-free cosmetic products?
SELECT AVG(consumer_rating) as avg_rating FROM cosmetics WHERE cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_research (publication_year INT, num_papers INT); INSERT INTO ai_research (publication_year, num_papers) VALUES (2018, 325), (2019, 456), (2020, 578), (2021, 701);
How many ethical AI research papers have been published per year in the last 5 years?
SELECT publication_year, num_papers, COUNT(*) OVER (PARTITION BY publication_year) AS papers_per_year FROM ai_research;
gretelai_synthetic_text_to_sql
CREATE TABLE collective_bargaining (bargaining_id INT, union_name VARCHAR(50), contract_start_date DATE, contract_end_date DATE, region VARCHAR(50));CREATE TABLE union_membership (member_id INT, name VARCHAR(50), union_name VARCHAR(50), membership_start_date DATE, region VARCHAR(50));CREATE VIEW union_region AS SELECT DISTINCT union_name, region FROM collective_bargaining UNION SELECT DISTINCT union_name, region FROM union_membership;CREATE VIEW northeast_unions AS SELECT union_name FROM union_membership WHERE region = 'Northeast';
What is the ratio of unions with collective bargaining agreements to total unions in the Northeast region?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM union_region) as ratio FROM northeast_unions nu WHERE EXISTS (SELECT 1 FROM collective_bargaining cb WHERE cb.union_name = nu.union_name);
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_position (vessel_name TEXT, speed_knots INTEGER, region TEXT); INSERT INTO vessel_position (vessel_name, speed_knots, region) VALUES ('VesselB', 15, 'Atlantic ocean'); INSERT INTO vessel_position (vessel_name, speed_knots, region) VALUES ('VesselB', 18, 'Atlantic ocean');
What is the average speed of 'VesselB' during its journeys in the Atlantic ocean?
SELECT AVG(speed_knots) FROM vessel_position WHERE vessel_name = 'VesselB' AND region = 'Atlantic ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE tb_cases (country VARCHAR(50), year INTEGER, num_cases INTEGER); INSERT INTO tb_cases (country, year, num_cases) VALUES ('United States', 2019, 9000), ('Mexico', 2019, 15000), ('Brazil', 2019, 20000), ('Canada', 2019, 12000), ('Argentina', 2019, 18000), ('Chile', 2019, 10000);
Determine the total number of tuberculosis cases reported in each country, for the year 2019.
SELECT country, SUM(num_cases) as total_tb_cases FROM tb_cases WHERE year = 2019 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE residential (customer_id INT, water_usage FLOAT, usage_date DATE); INSERT INTO residential (customer_id, water_usage, usage_date) VALUES (1, 150.5, '2022-08-01'), (2, 0, '2022-08-02'), (3, 800.4, '2022-08-03');
Find the average water_usage in the residential table for the month of August 2022, excluding any customers with a water_usage of 0.
SELECT AVG(water_usage) FROM residential WHERE usage_date BETWEEN '2022-08-01' AND '2022-08-31' AND water_usage > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, Age int, Gender varchar(10), GamePreference varchar(20)); INSERT INTO Players (PlayerID, Age, Gender, GamePreference) VALUES (3, 35, 'Non-binary', 'Sports'); INSERT INTO Players (PlayerID, Age, Gender, GamePreference) VALUES (4, 28, 'Female', 'Puzzle');
What is the average age of players who prefer sports games, and what is the average age of players who prefer puzzle games?
SELECT GamePreference, AVG(Age) AS AvgAge FROM Players WHERE GamePreference IN ('Sports', 'Puzzle') GROUP BY GamePreference;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (region VARCHAR(50), year INT, num_incidents INT); INSERT INTO cybersecurity_incidents (region, year, num_incidents) VALUES ('North America', 2019, 4000), ('North America', 2020, 5000), ('North America', 2021, 6000);
What is the total number of cybersecurity incidents reported in North America in 2021?
SELECT SUM(num_incidents) FROM cybersecurity_incidents WHERE region = 'North America' AND year = 2021;
gretelai_synthetic_text_to_sql