context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE military_innovation (id INT, year INT, quarter INT, projects INT); INSERT INTO military_innovation (id, year, quarter, projects) VALUES (1, 2017, 3, 20), (2, 2017, 4, 25), (3, 2018, 3, 30), (4, 2018, 4, 35), (5, 2019, 3, 40), (6, 2019, 4, 45);
How many military innovation projects were initiated in the second half of the years 2017 to 2019?
SELECT SUM(projects) FROM military_innovation WHERE quarter >= 3 AND year BETWEEN 2017 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE student_scores (student_id INT, year INT, mental_health_score INT, school_id INT); INSERT INTO student_scores (student_id, year, mental_health_score, school_id) VALUES (1, 2020, 75, 100), (1, 2021, 80, 100), (2, 2020, 80, 101), (2, 2021, 85, 101), (3, 2020, 70, 100), (3, 2021, 75, 100);
What is the difference in mental health scores between the first and last year for each student, grouped by school?
SELECT a.school_id, (b.mental_health_score - a.mental_health_score) as difference FROM student_scores a JOIN student_scores b ON a.student_id = b.student_id AND a.school_id = b.school_id WHERE a.year = (SELECT MIN(year) FROM student_scores c WHERE a.student_id = c.student_id) AND b.year = (SELECT MAX(year) FROM student_scores c WHERE a.student_id = c.student_id);
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (expenditure_id INT, organization_id INT, quarter INT, year INT, amount DECIMAL(10, 2));
What was the total R&D expenditure for each organization in H1 2022?
SELECT organization_id, SUM(amount) as total_expenditure FROM rd_expenditure WHERE quarter IN (1, 2) AND year = 2022 GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE resident (zip_code INT, gender TEXT, infected BOOLEAN);
What is the number of female residents in the most infected zip code?
SELECT COUNT(*) FROM resident r1 WHERE r1.infected = TRUE AND r1.gender = 'female' AND r1.zip_code = (SELECT r2.zip_code FROM resident r2 WHERE r2.infected = TRUE GROUP BY r2.zip_code LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (CHWId INT, Name VARCHAR(50)); CREATE TABLE CulturalCompetencyTrainings (TrainingId INT, CHWId INT, TrainingDate DATE); INSERT INTO CommunityHealthWorkers (CHWId, Name) VALUES (1, 'Jasmine'), (2, 'Kareem'), (3, 'Leah'); INSERT INTO CulturalCompetencyTrainings (TrainingId, CHWId, TrainingDate) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'), (4, 3, '2021-04-01'), (5, 3, '2021-05-01');
List unique cultural competency training dates for each community health worker.
SELECT CHW.Name, TrainingDate FROM CommunityHealthWorkers CHW INNER JOIN CulturalCompetencyTrainings CCT ON CHW.CHWId = CCT.CHWId;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id VARCHAR(10), number_of_voyages INT); INSERT INTO vessels (vessel_id, number_of_voyages) VALUES ('vessel_x', 12), ('vessel_y', 15), ('vessel_p', 18);
What is the total number of voyages for vessel_p?
SELECT SUM(number_of_voyages) FROM vessels WHERE vessel_id = 'vessel_p';
gretelai_synthetic_text_to_sql
CREATE TABLE agriculture_sales (country VARCHAR(50), crop VARCHAR(50), yield INT); INSERT INTO agriculture_sales (country, crop, yield) VALUES ('Canada', 'corn', 1000), ('Canada', 'wheat', 2000), ('USA', 'corn', 3000), ('USA', 'wheat', 4000), ('Mexico', 'corn', 2500), ('Mexico', 'wheat', 1500);
What is the total crop yield for each country in 'agriculture_sales' table?
SELECT country, SUM(yield) as total_yield FROM agriculture_sales GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(50), category VARCHAR(20), author_id INT); INSERT INTO articles (id, title, category, author_id) VALUES (1, 'Oil Prices Rising', 'technology', 1), (2, 'Government Corruption', 'science', 2), (3, 'Baseball Game', 'sports', 3), (4, 'Climate Change', 'technology', 3); CREATE TABLE authors (id INT, name VARCHAR(50), gender VARCHAR(10)); INSERT INTO authors (id, name, gender) VALUES (1, 'Anna Smith', 'female'), (2, 'John Doe', 'male'), (3, 'Alice Johnson', 'female'), (4, 'Bob Brown', 'male');
What is the percentage of articles about technology and science written by female authors?
SELECT (COUNT(articles.id) * 100.0 / (SELECT COUNT(*) FROM articles)) AS percentage FROM articles INNER JOIN authors ON articles.author_id = authors.id WHERE articles.category IN ('technology', 'science') AND authors.gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE southeast_asian_orders (id INT PRIMARY KEY, supplier_id INT, delivery_time INT); INSERT INTO southeast_asian_orders (id, supplier_id, delivery_time) VALUES (1, 1, 7), (2, 2, 10), (3, 3, 5), (4, 4, 8), (5, 5, 12); CREATE TABLE southeast_asian_suppliers (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50)); INSERT INTO southeast_asian_suppliers (id, name, country) VALUES (1, 'Fair Trade Farms', 'Thailand'), (2, 'Green Earth', 'Vietnam'), (3, 'Sustainable Source', 'Cambodia'), (4, 'Eco Harvest', 'Indonesia'), (5, 'Ethical Textiles', 'Malaysia');
What is the average delivery time, in days, for orders placed with suppliers in Southeast Asia?
SELECT AVG(delivery_time) as avg_delivery_time FROM southeast_asian_orders JOIN southeast_asian_suppliers ON southeast_asian_orders.supplier_id = southeast_asian_suppliers.id WHERE country IN ('Thailand', 'Vietnam', 'Cambodia', 'Indonesia', 'Malaysia');
gretelai_synthetic_text_to_sql
CREATE TABLE faculty_research_grants (grant_id INT, faculty_id INT, grant_amount INT); INSERT INTO faculty_research_grants (grant_id, faculty_id, grant_amount) VALUES (1, 1, 15000), (2, 2, 20000), (3, 3, 30000), (4, 3, 5000);
Rank faculty by the number of research grants awarded in descending order, assigning a unique rank to faculty with the same number of grants.
SELECT faculty_id, RANK() OVER (ORDER BY COUNT(grant_id) DESC) as faculty_rank FROM faculty_research_grants GROUP BY faculty_id ORDER BY faculty_rank;
gretelai_synthetic_text_to_sql
CREATE TABLE years (year INT); INSERT INTO years (year) VALUES (2015), (2016), (2017), (2018), (2019), (2020); CREATE TABLE patents (id INT, year INT, granted BOOLEAN); INSERT INTO patents (id, year, granted) VALUES (1, 2015, TRUE), (2, 2016, TRUE), (3, 2017, FALSE), (4, 2018, TRUE), (5, 2019, FALSE), (6, 2020, TRUE);
How many legal technology patents were granted per year?
SELECT p.year, COUNT(p.id) AS total_patents FROM patents p WHERE p.granted = TRUE GROUP BY p.year;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_data (id INT, name VARCHAR(50), country VARCHAR(50), destination VARCHAR(50), visit_year INT); INSERT INTO tourism_data (id, name, country, destination, visit_year) VALUES (1, 'Taro Yamada', 'Japan', 'Tokyo', 2023), (2, 'Hana Suzuki', 'Japan', 'Kyoto', 2023), (3, 'Sota Tanaka', 'Japan', NULL, 2022);
List the destinations visited by tourists from Japan in 2023, if available.
SELECT DISTINCT destination FROM tourism_data WHERE country = 'Japan' AND visit_year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE germany_pants (pant_id INT, pant_name VARCHAR(50), pant_price DECIMAL(5,2), pant_size VARCHAR(10), eco_friendly BOOLEAN); INSERT INTO germany_pants VALUES (1, 'Eco Women''s Pants', 65.99, 'S', true); INSERT INTO germany_pants VALUES (2, 'Eco Women''s Pants', 70.99, 'M', true); INSERT INTO germany_pants VALUES (3, 'Eco Women''s Pants', 60.99, 'L', true); INSERT INTO germany_pants VALUES (4, 'Women''s Pants', 50.99, 'XS', false);
What is the minimum price of eco-friendly women's pants in Germany, and how many different sizes are available for those pants?
SELECT MIN(pant_price) as min_price, COUNT(DISTINCT pant_size) as num_sizes FROM germany_pants WHERE eco_friendly = true AND pant_name = 'Eco Women''s Pants';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_sales(sales_date DATE, country VARCHAR(255), product_type VARCHAR(255), sales_quantity INT, sales_revenue DECIMAL(10,2));
Show the monthly sales revenue trend for organic hair care products in France.
SELECT DATE_TRUNC('month', sales_date) AS month, SUM(sales_revenue) AS monthly_revenue FROM cosmetics_sales WHERE country = 'France' AND product_type = 'hair care' AND contains_natural_ingredients = TRUE GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), is_protected BOOLEAN);
Find the total number of protected marine species.
SELECT COUNT(*) FROM species WHERE is_protected = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE accessories_sales (product_category VARCHAR(255), geography VARCHAR(255), sales_amount DECIMAL(10,2), half_year INT, year INT); INSERT INTO accessories_sales (product_category, geography, sales_amount, half_year, year) VALUES ('Women''s Accessories', 'Germany', 3500.00, 1, 2020), ('Women''s Accessories', 'Germany', 4000.00, 1, 2020);
What was the average sales amount for women's accessories in Germany in H1 2020?
SELECT AVG(sales_amount) FROM accessories_sales WHERE product_category = 'Women''s Accessories' AND geography = 'Germany' AND half_year = 1 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE public.community_policing (id serial PRIMARY KEY, city varchar(255), score int); INSERT INTO public.community_policing (city, score) VALUES ('Chicago', 85);
What is the maximum community policing score in the city of Chicago?
SELECT MAX(score) FROM public.community_policing WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (id INT, name VARCHAR(50), data_usage DECIMAL(10,2), state VARCHAR(50)); INSERT INTO broadband_subscribers (id, name, data_usage, state) VALUES (17, 'Liam Nguyen', 7000, 'NY'); INSERT INTO broadband_subscribers (id, name, data_usage, state) VALUES (18, 'Noah Patel', 7500, 'NY');
What is the maximum broadband usage for a single customer in New York?
SELECT MAX(data_usage) FROM broadband_subscribers WHERE state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (project_name TEXT, location TEXT, amount INTEGER); INSERT INTO climate_finance (project_name, location, amount) VALUES ('Project A', 'Asia', 500000), ('Project B', 'Africa', 300000), ('Project C', 'Africa', 200000);
Which countries in 'Africa' have received climate finance?
SELECT DISTINCT location FROM climate_finance WHERE location LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE Exoplanets ( id INT, discovery_method VARCHAR(255), telescope VARCHAR(255), habitable_zone BOOLEAN );
Calculate the total number of exoplanets discovered by the Kepler Space Telescope, and the number of these exoplanets that are in the habitable zone.
SELECT COUNT(*) as total_exoplanets, SUM(habitable_zone) as habitable_zone_exoplanets FROM Exoplanets WHERE telescope = 'Kepler Space Telescope';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, date DATE, product VARCHAR(50), category VARCHAR(50), store VARCHAR(50), quantity INT); CREATE TABLE stores (id INT, name VARCHAR(50), location VARCHAR(50));
How many products in each category are sold per day, on average, for stores in the US?
SELECT category, AVG(quantity) as avg_sales_per_day FROM sales JOIN stores ON sales.store = stores.name WHERE stores.location = 'US' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants(RestaurantID INT, Name VARCHAR(50), Category VARCHAR(50));CREATE TABLE Inspections(InspectionID INT, RestaurantID INT, Violation BOOLEAN, InspectionDate DATE);INSERT INTO Restaurants VALUES (1, 'Fancy Diner', 'Fine Dining'), (2, 'Burger Bites', 'Fast Food'), (3, 'Tasty Sushi', 'Asian Cuisine');INSERT INTO Inspections VALUES (1, 1, TRUE, '2022-03-15'), (2, 1, FALSE, '2022-06-01'), (3, 2, TRUE, '2022-04-20'), (4, 3, FALSE, '2022-05-10');
Find the number of food safety violations for each restaurant category in the last 6 months?
SELECT Category, COUNT(*) FROM Restaurants r JOIN Inspections i ON r.RestaurantID = i.RestaurantID WHERE InspectionDate >= DATEADD(month, -6, GETDATE()) AND Violation = TRUE GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (model_name TEXT, fairness_score INTEGER); INSERT INTO algorithmic_fairness (model_name, fairness_score) VALUES ('modelX', 82), ('modelY', 85);
Update the fairness score for 'modelX' to 87 in the 'algorithmic_fairness' table.
UPDATE algorithmic_fairness SET fairness_score = 87 WHERE model_name = 'modelX';
gretelai_synthetic_text_to_sql
CREATE TABLE exit (id INT, company_id INT, exit_year INT); CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_military TEXT); INSERT INTO exit (id, company_id, exit_year) VALUES (1, 1, 2019); INSERT INTO company (id, name, founding_year, founder_military) VALUES (1, 'Acme Inc', 2010, 'veteran');
What is the earliest year a startup founded by a veteran was successful?
SELECT MIN(exit.exit_year) FROM exit JOIN company ON exit.company_id = company.id WHERE company.founder_military = 'veteran';
gretelai_synthetic_text_to_sql
CREATE TABLE CosmeticProducts (ProductID int, ProductName varchar(50), ConsumerRating int, Country varchar(50)); CREATE TABLE IngredientSources (IngredientSourceID int, ProductID int, SupplierID int, IsOrganic bit);
Which cosmetic products in the 'South America' region have a ConsumerRating higher than the average rating for the region, and their supplier information?
SELECT c.ProductName, i.SupplierID, i.IsOrganic FROM CosmeticProducts c INNER JOIN (SELECT ProductID, AVG(ConsumerRating) as AvgRating FROM CosmeticProducts WHERE Country LIKE 'South America%' GROUP BY ProductID) sub ON c.ProductID = sub.ProductID INNER JOIN IngredientSources i ON c.ProductID = i.ProductID WHERE sub.AvgRating < c.ConsumerRating AND Country LIKE 'South America%';
gretelai_synthetic_text_to_sql
CREATE TABLE yearly_waste (country VARCHAR(50), year INT, total_waste FLOAT); INSERT INTO yearly_waste (country, year, total_waste) VALUES ('USA', 2019, 250), ('China', 2019, 230), ('India', 2019, 150), ('Indonesia', 2019, 110), ('Pakistan', 2019, 90), ('Mexico', 2019, 80);
What is the total waste generated by the bottom 3 waste-generating countries in 2019?
SELECT SUM(total_waste) FROM yearly_waste WHERE country IN (SELECT country FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY total_waste DESC) rn FROM yearly_waste WHERE year = 2019) t WHERE rn > 3);
gretelai_synthetic_text_to_sql
CREATE TABLE HempTextiles (id INT, production_cost DECIMAL, country VARCHAR);
What is the average production cost of hemp-based textiles in the USA?
SELECT AVG(production_cost) FROM HempTextiles WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (exhibition_id INT, name VARCHAR(20), start_date DATE);
Insert new records into the 'exhibitions' table for exhibitions with IDs 8 and 9, names 'Sculpture Garden' and 'Ancient Artifacts', and start dates of '2023-08-01' and '2023-10-01', respectively
INSERT INTO exhibitions (exhibition_id, name, start_date) VALUES (8, 'Sculpture Garden', '2023-08-01'), (9, 'Ancient Artifacts', '2023-10-01');
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity_sydney (city VARCHAR(50), capacity INT); INSERT INTO landfill_capacity_sydney (city, capacity) VALUES ('Sydney', 4500), ('Tokyo', 5500), ('London', 4000);
What is the maximum landfill capacity in Sydney?
SELECT MAX(capacity) FROM landfill_capacity_sydney WHERE city = 'Sydney';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_patients (id INT, age INT, gender VARCHAR(20), diagnosis VARCHAR(20)); INSERT INTO rural_patients (id, age, gender, diagnosis) VALUES (1, 65, 'Male', 'Diabetes'); CREATE TABLE diabetes_records (id INT, patient_id INT, record_date DATE); INSERT INTO diabetes_records (id, patient_id, record_date) VALUES (1, 1, '2021-01-01');
What is the average age of patients who have been diagnosed with diabetes in rural areas of Texas?
SELECT AVG(rural_patients.age) FROM rural_patients INNER JOIN diabetes_records ON rural_patients.id = diabetes_records.patient_id WHERE rural_patients.diagnosis = 'Diabetes' AND rural_patients.location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists destinations (destination_id int, destination_name varchar(50), region_id int); INSERT INTO destinations (destination_id, destination_name, region_id) VALUES (1, 'Seattle', 1), (2, 'Portland', 1), (3, 'London', 2); CREATE TABLE if not exists visitor_stats (visitor_id int, destination_id int, visit_date date); INSERT INTO visitor_stats (visitor_id, destination_id, visit_date) VALUES (1, 1, '2022-06-01'), (1, 1, '2022-06-30'), (2, 1, '2022-06-03'), (3, 2, '2022-06-02'), (4, 3, '2022-06-04'), (5, 3, '2022-06-05'), (6, 4, '2022-06-06'), (6, 4, '2022-06-20');
How many visitors returned to the same destination within a month?
SELECT COUNT(DISTINCT vs.visitor_id) as num_returning_visitors FROM (SELECT visitor_id, destination_id, visit_date FROM visitor_stats WHERE visit_date BETWEEN DATEADD(day, -30, CURRENT_DATE) AND CURRENT_DATE GROUP BY visitor_id, destination_id, visit_date HAVING COUNT(DISTINCT visit_date) > 1) vs;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Country varchar(50), Score int); INSERT INTO CountryScores (PlayerID, PlayerName, Game, Country, Score) VALUES (1, 'Player1', 'Game1', 'USA', 1000), (2, 'Player2', 'Game2', 'Canada', 1200), (3, 'Player3', 'Game3', 'Mexico', 1500), (4, 'Player4', 'Game1', 'USA', 800);
What is the average score for players in each country?
SELECT Country, AVG(Score) as AvgScore FROM CountryScores GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_storage (id INT PRIMARY KEY, chemical_id INT, storage_location VARCHAR(255)); INSERT INTO chemical_storage (id, chemical_id, storage_location) VALUES (1, 1, 'North Lab'), (2, 2, 'North Lab');
List the top 2 locations with the most chemicals stored.
SELECT storage_location, COUNT(DISTINCT chemical_id) AS num_chemicals, RANK() OVER (ORDER BY COUNT(DISTINCT chemical_id) DESC) AS rank FROM chemical_storage GROUP BY storage_location HAVING rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT, created_at DATETIME); INSERT INTO articles (id, title, category, likes, created_at) VALUES (1, 'Climate crisis: 12 years to save the planet', 'climate change', 100, '2022-01-01 10:30:00');
What is the average age of users who liked articles about climate change in the past month?
SELECT AVG(DATEDIFF('day', created_at, NOW())) as avg_age FROM articles WHERE category = 'climate change' AND likes > 50 AND created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artist VARCHAR(30), city VARCHAR(20), pieces INT); INSERT INTO Artworks (artist, city, pieces) VALUES ('Artist1', 'Seoul', 20), ('Artist2', 'Seoul', 30), ('Artist3', 'Seoul', 15), ('Artist4', 'Paris', 40), ('Artist5', 'Paris', 50);
What is the average number of artworks per artist in Seoul?
SELECT city, AVG(pieces/1.0) as avg_artworks FROM Artworks GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_statistics (id INT, project_id INT, workers_count INT, overtime_hours DECIMAL(3,2)); INSERT INTO labor_statistics (id, project_id, workers_count, overtime_hours) VALUES (2, 2, 45, 6.0), (3, 3, 30, 4.5);
What is the average overtime per worker for projects with more than 40 workers?
SELECT AVG(overtime_hours / workers_count) FROM labor_statistics WHERE workers_count > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_name TEXT, creation_year INT, category TEXT);
What is the earliest creation_year for artworks in the 'sculptures' category?
SELECT MIN(creation_year) FROM Artworks WHERE category = 'sculptures';
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationModes (mode_id INT, mode TEXT, co2_emission FLOAT); CREATE TABLE EU_Transportation (transportation_id INT, mode_id INT);
What is the average CO2 emission for each transportation mode in the EU?
SELECT mode, AVG(co2_emission) AS avg_co2_emission FROM TransportationModes tm INNER JOIN EU_Transportation et ON tm.mode_id = et.mode_id GROUP BY 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HeartRateData (HeartRate INT, WorkoutType VARCHAR(20), MemberID INT, WorkoutDate DATE); INSERT INTO HeartRateData (HeartRate, WorkoutType, MemberID, WorkoutDate) VALUES (85, 'Yoga', 1, '2021-01-06'), (90, 'Yoga', 1, '2021-01-07'), (75, 'Yoga', 2, '2021-03-19'), (80, 'Yoga', 3, '2021-08-15');
Calculate the average heart rate of users during their yoga sessions, grouped by gender.
SELECT AVG(HeartRate) as AvgHeartRate, Gender FROM HeartRateData INNER JOIN Members ON HeartRateData.MemberID = Members.MemberID INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE WorkoutType = 'Yoga' GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health_time (student_id INT, mental_health_score INT, mental_health_date DATE); INSERT INTO student_mental_health_time (student_id, mental_health_score, mental_health_date) VALUES (1, 75, '2021-01-01'), (2, 80, '2021-02-01'), (3, 60, '2021-03-01'), (4, 65, '2021-04-01'), (5, 85, '2021-05-01'), (6, 90, '2021-06-01');
What is the trend in student mental health scores over the past year, by month?
SELECT EXTRACT(MONTH FROM mental_health_date) as month, AVG(mental_health_score) as avg_mental_health_score FROM student_mental_health_time WHERE mental_health_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE production (chemical VARCHAR(20), month INT, year INT, cost FLOAT); INSERT INTO production (chemical, month, year, cost) VALUES ('Eco-friendly Polymer', 1, 2019, 450.25), ('Eco-friendly Polymer', 2, 2019, 470.33), ('Eco-friendly Polymer', 3, 2019, 495.10), ('Basic Polymer', 1, 2019, 300.00), ('Basic Polymer', 2, 2019, 315.20), ('Basic Polymer', 3, 2019, 330.00);
List the production cost of the 'Eco-friendly Polymer' chemical for each month in 2019
SELECT month, cost FROM production WHERE chemical = 'Eco-friendly Polymer' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE FoodItems (FoodItemID INT, FoodItemName TEXT, Category TEXT, Weight FLOAT);
What is the total weight of each food category?
SELECT Category, SUM(Weight) AS TotalWeight FROM FoodItems GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, sector VARCHAR(20), date DATE); INSERT INTO security_incidents (id, sector, date) VALUES (1, 'healthcare', '2022-05-01');
How many security incidents were there in the healthcare sector in the last month?
SELECT COUNT(*) FROM security_incidents WHERE sector = 'healthcare' AND date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName TEXT, LastName TEXT, IsRecurring BOOLEAN, TotalDonations DECIMAL(5,2)); INSERT INTO Donors (DonorID, FirstName, LastName, IsRecurring, TotalDonations) VALUES (1, 'Fatima', 'Al-Faisal', true, 800.00), (2, 'Hiroshi', 'Sato', false, 500.00), (3, 'Ingrid', 'Jensen', true, 1200.00), (4, 'Jose', 'Garcia', true, 900.00);
Who are the top 3 recurring donors by total donated amount?
SELECT FirstName, LastName, TotalDonations FROM Donors WHERE IsRecurring = true ORDER BY TotalDonations DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(255), role VARCHAR(255), department VARCHAR(255)); CREATE TABLE training_records (id INT PRIMARY KEY, employee_id INT, course VARCHAR(255), completed DATE, FOREIGN KEY (employee_id) REFERENCES employees(id)); CREATE VIEW safety_courses AS SELECT * FROM training_records WHERE course LIKE '%safety%' AND course LIKE '%hazardous%';
Identify employees who have not completed any safety training related to handling hazardous materials.
SELECT employees.name FROM employees LEFT JOIN safety_courses ON employees.id = safety_courses.employee_id WHERE safety_courses.completed IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ChemicalBatches (id INT, pH FLOAT, production_date DATE, country VARCHAR(50)); INSERT INTO ChemicalBatches (id, pH, production_date, country) VALUES (1, 4.8, '2019-02-12', 'USA'), (2, 6.2, '2020-03-04', 'USA'), (3, 5.4, '2018-08-20', 'USA');
Identify chemical batches with pH levels lower than 5.5 produced in the USA before 2020.
SELECT id, pH, production_date FROM ChemicalBatches WHERE pH < 5.5 AND country = 'USA' AND production_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_events (id INT, event_type VARCHAR(50), region VARCHAR(10), timestamp TIMESTAMP); INSERT INTO regulatory_events (id, event_type, region, timestamp) VALUES (1, 'Event1', 'Americas', '2022-01-01 00:00:00'), (2, 'Event2', 'Americas', '2022-02-01 00:00:00');
How many regulatory events have occurred in the Americas in the last 6 months?
SELECT COUNT(*) as event_count FROM regulatory_events WHERE region = 'Americas' AND timestamp >= '2022-01-01 00:00:00' AND timestamp < '2022-07-01 00:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), language VARCHAR(50), word_count INT, publication_date DATE); INSERT INTO articles (id, title, language, word_count, publication_date) VALUES (1, 'Article1', 'English', 500, '2022-01-01'), (2, 'Article2', 'Spanish', 350, '2022-02-01'), (3, 'Article3', 'French', 400, '2022-03-01');
List the number of articles and total words per language for articles in 2022
SELECT language, SUM(word_count) as total_words FROM articles WHERE publication_date >= '2022-01-01' AND publication_date < '2023-01-01' GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE site_visitors (site_id INT, name TEXT, country TEXT, year INT, visitor_count INT); INSERT INTO site_visitors (site_id, name, country, year, visitor_count) VALUES (1, 'Himeji Castle', 'Japan', 2022, 850000);
Update the visitor count for the 'Himeji Castle' in Japan for 2022 to 900000.
UPDATE site_visitors SET visitor_count = 900000 WHERE name = 'Himeji Castle' AND country = 'Japan' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT PRIMARY KEY, Name VARCHAR(50), Location VARCHAR(50), Date DATE, PrizePool FLOAT);
Insert a new esports event
INSERT INTO EsportsEvents (EventID, Name, Location, Date, PrizePool) VALUES (3, 'Esports Event 3', 'City 3', '2024-03-01', 200000);
gretelai_synthetic_text_to_sql
CREATE TABLE WeightCategory (WeightCategoryID INT, WeightRange VARCHAR(50), LowerLimit INT, UpperLimit INT); INSERT INTO WeightCategory (WeightCategoryID, WeightRange, LowerLimit, UpperLimit) VALUES (1, 'up to 1000', 0, 1000); INSERT INTO WeightCategory (WeightCategoryID, WeightRange, LowerLimit, UpperLimit) VALUES (2, '1000-5000', 1000, 5000);
What is the rank of each cargo by weight category?
SELECT CargoName, Weight, RANK() OVER (PARTITION BY w.WeightCategoryID ORDER BY Weight DESC) as Rank FROM Cargo c JOIN WeightCategory w ON c.Weight BETWEEN w.LowerLimit AND w.UpperLimit;
gretelai_synthetic_text_to_sql
CREATE TABLE submarine_cables (name VARCHAR(255), length FLOAT, ocean VARCHAR(255));
What is the total length of all submarine cables in the Atlantic Ocean?
SELECT SUM(length) FROM submarine_cables WHERE ocean = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE households (household_id INT, city VARCHAR(255), high_speed_internet BOOLEAN);
List the top 10 cities with the highest percentage of households with access to high-speed internet, based on the most recent data available.
SELECT city, (COUNT(*) FILTER (WHERE high_speed_internet = true) * 100.0 / COUNT(*)) AS high_speed_percentage FROM households GROUP BY city ORDER BY high_speed_percentage DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name VARCHAR(50), policy_type VARCHAR(50), sum_insured DECIMAL(10, 2), DOB DATE); INSERT INTO policyholders (id, name, policy_type, sum_insured, DOB) VALUES (1, 'Richard Roe', 'Life', 2000000, '1968-12-12');
List the top 5 policyholders with the highest sum insured.
SELECT name, sum_insured FROM (SELECT name, sum_insured, ROW_NUMBER() OVER (ORDER BY sum_insured DESC) AS rank FROM policyholders) AS ranked_policyholders WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE train_lines (line_id INT, line_name VARCHAR(255)); CREATE TABLE train_schedules (schedule_id INT, line_id INT, departure_time TIME); INSERT INTO train_lines VALUES (1, 'Line 1'); INSERT INTO train_lines VALUES (2, 'Line 2'); INSERT INTO train_schedules VALUES (1, 1, '07:00:00'); INSERT INTO train_schedules VALUES (2, 1, '08:00:00'); INSERT INTO train_schedules VALUES (3, 2, '09:00:00');
What is the earliest and latest departure time for each train line?
SELECT line_name, MIN(departure_time) as earliest_departure, MAX(departure_time) as latest_departure FROM train_lines l JOIN train_schedules s ON l.line_id = s.line_id GROUP BY l.line_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Violations (Industry TEXT, ViolationCount INT, ViolationDate DATE); INSERT INTO Violations (Industry, ViolationCount, ViolationDate) VALUES ('Textile', 10, '2022-01-01'), ('Textile', 15, '2022-04-01'), ('Textile', 5, '2022-03-01');
What are the labor rights violation records for the textile industry in the first quarter of 2022?
SELECT Industry, ViolationCount FROM Violations WHERE Industry = 'Textile' AND ViolationDate >= DATE('2022-01-01') AND ViolationDate < DATE('2022-04-01') ORDER BY ViolationCount;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (id INT, dish VARCHAR(255), vegan BOOLEAN, low_carb BOOLEAN); INSERT INTO Dishes (id, dish, vegan, low_carb) VALUES (1, 'Quinoa Salad', TRUE, TRUE), (2, 'Beef Stew', FALSE, FALSE), (3, 'Vegetable Curry', TRUE, FALSE), (4, 'Chicken Fried Rice', FALSE, FALSE), (5, 'Lentil Soup', TRUE, TRUE);
What is the total count of dishes that are both vegan and low-carb?
SELECT COUNT(*) FROM Dishes WHERE vegan = TRUE AND low_carb = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (region VARCHAR(255), waste_type VARCHAR(255), capacity_percentage DECIMAL(5,2), date DATE); INSERT INTO landfill_capacity (region, waste_type, capacity_percentage, date) VALUES ('Northeast', 'Plastic', 80.0, '2021-01-01'), ('Northeast', 'Plastic', 78.0, '2021-01-02'), ('Northeast', 'Paper', 60.0, '2021-01-01'), ('Northeast', 'Paper', 62.0, '2021-01-02');
What is the change in landfill capacity percentage for each waste type, in the Northeast region, between the first and the last date?
SELECT region, waste_type, capacity_percentage, date, LAG(capacity_percentage, 1) OVER (PARTITION BY waste_type ORDER BY date) as prev_capacity_percentage, capacity_percentage - LAG(capacity_percentage, 1) OVER (PARTITION BY waste_type ORDER BY date) as capacity_percentage_change FROM landfill_capacity WHERE region = 'Northeast';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_satisfaction (id INT, paper_name VARCHAR(50), algorithm_type VARCHAR(50), satisfaction_score INT); INSERT INTO ai_safety_satisfaction (id, paper_name, algorithm_type, satisfaction_score) VALUES (1, 'Safe and Effective Algorithms for Autonomous Systems', 'Deep Learning', 90), (2, 'Mitigating Adversarial Attacks on Deep Learning Models', 'Deep Learning', 85), (3, 'Towards Explainable AI for Safety-critical Systems', 'Explainable AI', 95);
What is the average satisfaction score for AI safety research papers, grouped by algorithm type?
SELECT algorithm_type, AVG(satisfaction_score) FROM ai_safety_satisfaction GROUP BY algorithm_type;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists renewable_energy_projects (id INT, name VARCHAR(100), year INT, completed BOOLEAN); INSERT INTO renewable_energy_projects (id, name, year, completed) VALUES (1, 'Renewable Energy Development', 2020, TRUE);
How many renewable energy projects were completed in '2020'?
SELECT COUNT(*) FROM renewable_energy_projects WHERE year = 2020 AND completed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, initiative_name VARCHAR(255), start_date DATE); INSERT INTO community_policing (id, initiative_name, start_date) VALUES (1, 'Safe Streets Program', '2017-01-01'), (2, 'Youth Mentoring', '2018-04-01');
What is the total number of community policing initiatives implemented in the city of Dallas since the year 2017?
SELECT COUNT(*) FROM community_policing WHERE start_date <= '2017-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE SpeciesWaterTemp (SpeciesID int, Date date, WaterTemp float); INSERT INTO SpeciesWaterTemp (SpeciesID, Date, WaterTemp) VALUES (1, '2022-01-01', 12.5), (1, '2022-01-02', 13.2), (2, '2022-01-01', 14.1), (2, '2022-01-02', 14.6);
What is the minimum water temperature recorded for each fish species?
SELECT SpeciesName, MIN(WaterTemp) as MinTemp FROM SpeciesWaterTemp GROUP BY SpeciesName;
gretelai_synthetic_text_to_sql
CREATE TABLE gold_staff (id INT, state VARCHAR(20), employees INT, gold_production FLOAT); INSERT INTO gold_staff (id, state, employees, gold_production) VALUES (6, 'California', 60, 12500.5), (7, 'Nevada', 70, 16000.3), (8, 'California', 80, 19000.3), (9, 'Nevada', 90, 22000.0);
What is the average gold production per employee for each state?
SELECT state, AVG(gold_production/employees) as avg_productivity FROM gold_staff GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_observations (id INT, animal_species VARCHAR(255), protected_area VARCHAR(255), observation_date DATE);
Which animal species have not been observed in protected areas for the past 3 years?
SELECT animal_species FROM animal_observations WHERE protected_area IN (SELECT name FROM protected_areas) AND observation_date < (CURRENT_DATE - INTERVAL '3 years') GROUP BY animal_species HAVING COUNT(DISTINCT observation_date) < 3;
gretelai_synthetic_text_to_sql
CREATE TABLE buses (route_id INT, city VARCHAR(50), fare DECIMAL(5,2)); INSERT INTO buses (route_id, city, fare) VALUES (1, 'New York', 2.50), (2, 'New York', 2.75), (3, 'Los Angeles', 1.75), (4, 'Los Angeles', 1.85), (5, 'San Francisco', 2.25);
How many buses are there in total in each city?
SELECT city, COUNT(DISTINCT route_id) FROM buses GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE HempFabrics (id INT, supplier VARCHAR(50), lead_time INT); INSERT INTO HempFabrics (id, supplier, lead_time) VALUES (1, 'EcoHemp', 12), (2, 'GreenHemp', 15), (3, 'SustainableHemp', 18);
What is the average lead time for hemp fabric suppliers?
SELECT AVG(lead_time) FROM HempFabrics;
gretelai_synthetic_text_to_sql
CREATE TABLE Billing (ID INT PRIMARY KEY, CaseID INT, Amount DECIMAL(10,2), BillingDate DATE); CREATE TABLE Cases (ID INT PRIMARY KEY, CaseNumber VARCHAR(20), ClientID INT, AttorneyID INT, Outcome VARCHAR(20)); INSERT INTO Billing (ID, CaseID, Amount, BillingDate) VALUES (1, 1, 5000.00, '2022-01-01'), (2, 2, 3000.00, '2022-03-15'), (3, 3, 7000.00, '2022-06-30'); INSERT INTO Cases (ID, CaseNumber, ClientID, AttorneyID, Outcome) VALUES (1, '12345', 1, 1, 'Won'), (2, '54321', 2, 2, 'Won'), (3, '98765', 3, 3, 'Lost');
Find the total billing amount for cases handled by attorneys named 'Sarah' or 'David' for the first half of 2022.
SELECT SUM(Amount) FROM Billing WHERE CaseID IN (SELECT ID FROM Cases WHERE AttorneyID IN (SELECT ID FROM Attorneys WHERE Name IN ('Sarah', 'David'))) AND BillingDate BETWEEN '2022-01-01' AND '2022-06-30'
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (vehicle_id INT, vehicle_type VARCHAR(255), city VARCHAR(255), state VARCHAR(255));
how many electric vehicles are there in Canada?
SELECT COUNT(*) FROM electric_vehicles WHERE state = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_name VARCHAR(50), email VARCHAR(50), department_name VARCHAR(50), salary DECIMAL(10,2));
What is the name and email address of the employee with the highest salary in each department in the employees table?
SELECT employee_name, email FROM employees AS e1 WHERE salary = (SELECT MAX(salary) FROM employees AS e2 WHERE e1.department_name = e2.department_name) GROUP BY department_name;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicle_services (service_id INT, service_name TEXT, type TEXT, city TEXT, country TEXT);
Delete the autonomous taxi service with ID 1502 from the autonomous_vehicle_services table
DELETE FROM autonomous_vehicle_services WHERE service_id = 1502;
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (room_type VARCHAR(20), booking_channel VARCHAR(20), booking_date DATE); INSERT INTO bookings (room_type, booking_channel, booking_date) VALUES ('Standard', 'Direct', '2021-03-15'), ('Suite', 'Online Travel Agency', '2021-04-01'), ('Standard', 'Direct', '2021-05-20');
How many 'Suite' rooms were booked through online travel agencies in Q2 of 2021?
SELECT COUNT(*) FROM bookings WHERE room_type = 'Suite' AND booking_channel = 'Online Travel Agency' AND QUARTER(booking_date) = 2 AND YEAR(booking_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE cardano_network (transaction_date DATE, transaction_volume DECIMAL(18,2), network_name TEXT);
Find the daily transaction volume for the 'Cardano' network in the last 30 days.
SELECT transaction_date, SUM(transaction_volume) as daily_transaction_volume FROM cardano_network WHERE network_name = 'Cardano' AND transaction_date >= CURRENT_DATE - INTERVAL '30 days' GROUP BY transaction_date ORDER BY transaction_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE LanguagePreservationCenter (Location VARCHAR(255), NumberOfArtPrograms INT); INSERT INTO LanguagePreservationCenter (Location, NumberOfArtPrograms) VALUES ('Vancouver', 15), ('Toronto', 12), ('Montreal', 18), ('Calgary', 10), ('Ottawa', 16);
What is the average number of art programs per language preservation center in Canada, ordered from highest to lowest?
SELECT AVG(NumberOfArtPrograms) AS AverageArtPrograms, Location FROM LanguagePreservationCenter WHERE Location = 'Canada' GROUP BY Location ORDER BY AverageArtPrograms DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE indian_sites (site_id INT, site_name TEXT, country TEXT, safety_score FLOAT); INSERT INTO indian_sites (site_id, site_name, country, safety_score) VALUES (1, 'Site I', 'India', 80.5), (2, 'Site J', 'India', 75.3), (3, 'Site K', 'India', 92.6), (4, 'Site L', 'India', 78.9);
Determine the production site in India with the lowest safety score.
SELECT site_name, safety_score, MIN(safety_score) OVER (PARTITION BY country) as min_safety_score FROM indian_sites WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE Training (EmployeeID INT, Salary DECIMAL(10, 2), LeadershipTraining BOOLEAN, Position VARCHAR(20)); INSERT INTO Training (EmployeeID, Salary, LeadershipTraining, Position) VALUES (1, 90000.00, TRUE, 'Manager'), (2, 80000.00, FALSE, 'Manager'), (3, 70000.00, TRUE, 'Individual Contributor');
What is the sum of salaries for employees who have completed leadership training and work in management positions?
SELECT SUM(Salary) FROM Training WHERE LeadershipTraining = TRUE AND Position = 'Manager';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT PRIMARY KEY, country_name VARCHAR(255), area VARCHAR(255)); INSERT INTO countries (country_id, country_name, area) VALUES (1, 'United States', 'urban'), (2, 'Canada', 'urban'), (3, 'Mexico', 'rural'); CREATE TABLE life_expectancy (country_id INT, expectancy FLOAT); INSERT INTO life_expectancy (country_id, expectancy) VALUES (1, 80), (2, 82), (3, 75);
What is the average life expectancy in rural areas?
SELECT c.country_name, le.expectancy FROM countries c JOIN life_expectancy le ON c.country_id = le.country_id WHERE c.area = 'rural';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), location VARCHAR(255));
Add a new column "sustainability_rating" to the "restaurants" table
ALTER TABLE restaurants ADD COLUMN sustainability_rating INT;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (id INT, equipment_name TEXT, sale_date DATE, quantity INT, total_cost FLOAT);
insert new military equipment sale records into sales_data
INSERT INTO sales_data (id, equipment_name, sale_date, quantity, total_cost) VALUES (3, 'M2 Bradley', '2021-03-15', 8, 25000000), (4, 'APS-153 Radar', '2021-05-20', 1, 2000000);
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT, name VARCHAR(20), species VARCHAR(20), age INT); INSERT INTO animals (id, name, species, age) VALUES (1, 'George', 'Gorilla', 35); INSERT INTO animals (id, name, species, age) VALUES (2, 'Gina', 'Gorilla', 28);
What is the average age of all gorillas in the animals table?
SELECT AVG(age) FROM animals WHERE species = 'Gorilla';
gretelai_synthetic_text_to_sql
CREATE TABLE site (site_id INT, name TEXT, depth FLOAT); INSERT INTO site (site_id, name, depth) VALUES (1, 'Great Barrier Reef', 123.45);
What is the average depth of all great barrier reef sites?
SELECT AVG(depth) FROM site WHERE name = 'Great Barrier Reef'
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10), last_publication_date DATE); CREATE TABLE conferences (id INT, name VARCHAR(50), tier VARCHAR(10)); CREATE TABLE publications (id INT, faculty_id INT, conference_id INT);
What is the number of publications in the top-tier Computer Science conferences by female faculty members in the past year?
SELECT COUNT(*) FROM (SELECT f.id FROM faculty f JOIN publications p ON f.id = p.faculty_id JOIN conferences c ON p.conference_id = c.id WHERE f.gender = 'Female' AND f.department = 'Computer Science' AND f.last_publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND c.tier = 'Top-tier') subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, sector, funding) VALUES (2, 'StartupB', 'Canada', 'Biotechnology', 7000000);
What is the average funding for biotechnology startups in Canada?
SELECT AVG(funding) FROM startups WHERE sector = 'Biotechnology' AND location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (Movie_ID INT, Movie_Name VARCHAR(100), Release_Year INT, Genre VARCHAR(50), Production_Company_ID INT, Budget DECIMAL(10,2)); INSERT INTO Movies (Movie_ID, Movie_Name, Release_Year, Genre, Production_Company_ID, Budget) VALUES (1, 'Movie 1', 2010, 'Action', 1, 30000000);
Identify the total budget for action movies.
SELECT SUM(Budget) FROM Movies WHERE Genre = 'Action';
gretelai_synthetic_text_to_sql
CREATE TABLE Household_Water_Usage (Household_ID INT, City VARCHAR(20), Year INT, Water_Consumption FLOAT); INSERT INTO Household_Water_Usage (Household_ID, City, Year, Water_Consumption) VALUES (1, 'Detroit', 2017, 120.5), (2, 'Detroit', 2018, 110.2);
Identify the water usage trend for households in Detroit from 2017 to 2020.
SELECT Year, AVG(Water_Consumption) FROM Household_Water_Usage WHERE City = 'Detroit' GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE landfills (country VARCHAR(50), capacity INT, year INT); INSERT INTO landfills (country, capacity, year) VALUES ('Brazil', 12000, 2021), ('Argentina', 10000, 2021), ('Colombia', 9000, 2021), ('Peru', 8000, 2021), ('Venezuela', 7000, 2021);
How many landfills are there in South America with a capacity greater than 8000 tons as of 2021?'
SELECT COUNT(*) as num_landfills FROM landfills WHERE capacity > 8000 AND year = 2021 AND country IN ('Brazil', 'Argentina', 'Colombia', 'Peru', 'Venezuela');
gretelai_synthetic_text_to_sql
CREATE TABLE impact (id INT, country TEXT, tourism INT, economic INT); INSERT INTO impact (id, country, tourism, economic) VALUES (1, 'Mexico', 30000, 500000);
Get the local economic impact of tourism in Mexico.
SELECT economic FROM impact WHERE country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE beneficiaries (id INT, name TEXT, country TEXT); INSERT INTO beneficiaries VALUES (1, 'Rajesh', 'India'); CREATE TABLE support (id INT, beneficiary_id INT, sector TEXT, support_date DATE, amount INT); INSERT INTO support VALUES (1, 1, 'food security', '2018-01-01', 500);
Identify all the unique beneficiaries in India who received support from the 'food security' sector in 2018, the number of times they received support, and the total amount donated to each.
SELECT beneficiaries.name, COUNT(support.id), SUM(support.amount) FROM beneficiaries INNER JOIN support ON beneficiaries.id = support.beneficiary_id WHERE beneficiaries.country = 'India' AND support.sector = 'food security' AND support.support_date BETWEEN '2018-01-01' AND '2018-12-31' GROUP BY beneficiaries.id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR(255), max_depth FLOAT); INSERT INTO marine_species (name, max_depth) VALUES ('Mariana Snailfish', 8178);
What is the maximum depth reached by any marine species?
SELECT MAX(max_depth) FROM marine_species;
gretelai_synthetic_text_to_sql
CREATE TABLE ExhibitionVisitors (id INT, region VARCHAR(20), quarter INT, year INT, visitors INT); INSERT INTO ExhibitionVisitors (id, region, quarter, year, visitors) VALUES (13, 'Middle East', 3, 2021, 500); INSERT INTO ExhibitionVisitors (id, region, quarter, year, visitors) VALUES (14, 'Middle East', 3, 2021, 700);
What is the minimum number of visitors for exhibitions in the Middle East in Q3 2021?
SELECT MIN(visitors) FROM ExhibitionVisitors WHERE region = 'Middle East' AND quarter = 3 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE enrollment(id INT, program TEXT, semester TEXT); INSERT INTO enrollment(id, program, semester) VALUES (1, 'Data Science', 'Fall'), (2, 'Physics', 'Fall'), (3, 'Mathematics', 'Spring');
What is the number of students enrolled in the Physics program in the Fall semester?
SELECT COUNT(*) FROM enrollment WHERE program = 'Physics' AND semester = 'Fall';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, category VARCHAR(20), risk_score INT, last_observed DATE); INSERT INTO vulnerabilities (id, category, risk_score, last_observed) VALUES (1, 'applications', 7, '2021-01-01'); INSERT INTO vulnerabilities (id, category, risk_score, last_observed) VALUES (2, 'applications', 5, '2021-01-02');
What is the average risk score for vulnerabilities in the 'applications' category, partitioned by the 'last observed' date?
SELECT last_observed, AVG(risk_score) OVER (PARTITION BY category ORDER BY last_observed) FROM vulnerabilities;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_gender TEXT, total_funding INT); INSERT INTO companies (id, name, industry, founder_gender, total_funding) VALUES (1, 'DriveEasy', 'Transportation', 'Female', 2000000); INSERT INTO companies (id, name, industry, founder_gender, total_funding) VALUES (2, 'FlySmart', 'Transportation', 'Male', 3000000); INSERT INTO companies (id, name, industry, founder_gender, total_funding) VALUES (3, 'BikeTech', 'Transportation', 'Female', 1500000);
What is the total funding received by companies with female founders in the transportation sector?
SELECT SUM(total_funding) FROM companies WHERE founder_gender = 'Female' AND industry = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name TEXT, title TEXT); INSERT INTO attorneys (attorney_id, name, title) VALUES (1, 'Thomas', 'Partner'), (2, 'Thomas', 'Associate'); CREATE TABLE clients (client_id INT, attorney_id INT, name TEXT); INSERT INTO clients (client_id, attorney_id, name) VALUES (1, 1, 'Jones'), (2, 1, 'Brown'), (3, 2, 'Davis'), (4, 2, 'Miller');
What is the number of unique clients represented by attorneys with the last name 'Thomas'?
SELECT COUNT(DISTINCT clients.client_id) FROM attorneys INNER JOIN clients ON attorneys.attorney_id = clients.attorney_id WHERE attorneys.name = 'Thomas';
gretelai_synthetic_text_to_sql
CREATE TABLE exhibition_halls (hall_id INT, capacity INT); INSERT INTO exhibition_halls (hall_id, capacity) VALUES (1, 500), (2, 750), (3, 1000);
What is the maximum number of visitors that can be accommodated in the museum's exhibition halls?
SELECT MAX(capacity) FROM exhibition_halls;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_type VARCHAR(255)); CREATE TABLE billing (bill_id INT, case_id INT, amount DECIMAL(10,2));
What is the average billing amount for each case type, based on the 'case_type' column in the 'cases' table?
SELECT c.case_type, AVG(b.amount) FROM cases c INNER JOIN billing b ON c.case_id = b.case_id GROUP BY c.case_type;
gretelai_synthetic_text_to_sql
CREATE TABLE player (player_id INT, player_name VARCHAR(50), age INT, country VARCHAR(50), game_genre VARCHAR(20)); INSERT INTO player (player_id, player_name, age, country, game_genre) VALUES (1, 'John Doe', 25, 'USA', 'VR'); INSERT INTO player (player_id, player_name, age, country, game_genre) VALUES (2, 'Jane Smith', 30, 'Canada', 'RPG');
How many players play VR games by country?
SELECT country, COUNT(*) FROM player WHERE game_genre = 'VR' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE doctors (id INT, name VARCHAR(50), specialty VARCHAR(50), rural_clinic BOOLEAN); INSERT INTO doctors (id, name, specialty, rural_clinic) VALUES (2, 'Jose Hernandez', 'Cardiology', true);
What is the name and specialty of all doctors working in rural clinics?
SELECT name, specialty FROM doctors WHERE rural_clinic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping_projects (project_id INT, project_name TEXT, station_id INT); INSERT INTO ocean_floor_mapping_projects (project_id, project_name, station_id) VALUES (1, 'Project 1', 1), (2, 'Project 2', 3), (3, 'Project 3', 2); CREATE TABLE marine_life_research_stations (station_id INT, station_name TEXT, depth FLOAT); INSERT INTO marine_life_research_stations (station_id, station_name, depth) VALUES (1, 'Station A', 2500.3), (2, 'Station B', 1800.5), (3, 'Station C', 3200.7);
Present the total depth surveyed by each ocean floor mapping project
SELECT p.project_name, SUM(m.depth) AS total_depth FROM ocean_floor_mapping_projects p JOIN marine_life_research_stations m ON p.station_id = m.station_id GROUP BY p.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(50), ocean VARCHAR(50), conservation_status VARCHAR(50));
Update the conservation status of the 'Hawaiian Monk Seal' to 'Endangered' in the North Pacific.
UPDATE marine_species SET conservation_status = 'Endangered' WHERE species = 'Hawaiian Monk Seal' AND ocean = 'North Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE members (id INT, join_date DATE); INSERT INTO members (id, join_date) VALUES (1, '2021-01-01');
How many new members joined per quarter in 2021?
SELECT DATE_TRUNC('quarter', join_date) AS quarter, COUNT(*) AS new_members FROM members WHERE YEAR(join_date) = 2021 GROUP BY quarter;
gretelai_synthetic_text_to_sql