context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE wells (id INT, province VARCHAR(20), date DATE); INSERT INTO wells (id, province, date) VALUES (1, 'Alberta', '2022-01-01'); INSERT INTO wells (id, province, date) VALUES (2, 'British Columbia', '2022-01-02'); INSERT INTO wells (id, province, date) VALUES (3, 'Saskatchewan', '2022-01-03');
List the number of wells drilled in each province for the last 9 months, ordered by the number of wells.
SELECT province, COUNT(*) FROM wells WHERE date >= DATE_SUB(CURDATE(), INTERVAL 9 MONTH) GROUP BY province ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (id INT, dish_name VARCHAR(255), inspection_result VARCHAR(255)); CREATE TABLE Sales (id INT, dish_name VARCHAR(255), revenue DECIMAL(5,2));
What is the total revenue for dishes that were inspected and found to be in compliance?
SELECT SUM(revenue) FROM Sales s JOIN Inspections i ON s.dish_name = i.dish_name WHERE i.inspection_result = 'In Compliance';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, gender VARCHAR(50), region VARCHAR(50), material_type VARCHAR(50), quantity INT); INSERT INTO suppliers (supplier_id, gender, region, material_type, quantity) VALUES (1, 'Female', 'Latin America', 'Organic Cotton', 500), (2, 'Male', 'Europe', 'Recycled Polyester', 300), (3, 'Non...
What is the total quantity of sustainable materials supplied by women-owned businesses in Latin America?
SELECT SUM(quantity) FROM suppliers WHERE gender = 'Female' AND region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE player_hours (player_hours_id INT, player_id INT, game_id INT, hours INT); INSERT INTO player_hours VALUES (1, 1, 1, 10), (2, 1, 2, 5), (3, 2, 2, 8), (4, 3, 3, 12), (5, 4, 1, 7);
How many hours did each player spend on a game in the 'Simulation' genre?
SELECT player_id, SUM(hours) as total_hours FROM player_hours JOIN games ON player_hours.game_id = games.game_id WHERE genre = 'Simulation' GROUP BY player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, name TEXT, league TEXT); INSERT INTO teams (team_id, name, league) VALUES (1, 'Barcelona', 'La Liga'), (2, 'Real Madrid', 'La Liga'); CREATE TABLE goals (goal_id INT, team_id INT, goals INT); INSERT INTO goals (goal_id, team_id, goals) VALUES (1, 1, 3), (2, 1, 2), (3, 2, 1);
Find the total number of goals scored by the team 'Barcelona' in the 'La Liga' league.
SELECT SUM(goals) FROM goals JOIN teams ON goals.team_id = teams.team_id WHERE teams.name = 'Barcelona' AND teams.league = 'La Liga';
gretelai_synthetic_text_to_sql
CREATE TABLE community_centers (center_id INT, name TEXT, location TEXT, people_served INT); INSERT INTO community_centers (center_id, name, location, people_served) VALUES (1, 'Center A', 'Asia', 500), (2, 'Center B', 'Europe', 800), (3, 'Center C', 'Asia', 1000);
What is the maximum number of people served by a community center in 'Asia'?
SELECT MAX(people_served) FROM community_centers WHERE location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE company_data (company_name VARCHAR(30), sector VARCHAR(20), avg_salary INT); INSERT INTO company_data (company_name, sector, avg_salary) VALUES ('CompanyA', 'Healthcare', 70000), ('CompanyB', 'Healthcare', 90000), ('CompanyC', 'Finance', 80000);
What is the maximum salary in the 'healthcare' sector?
SELECT MAX(avg_salary) FROM company_data WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS events (id INT, name VARCHAR(255), type VARCHAR(255), year INT, visitors INT); INSERT INTO events (id, name, type, year, visitors) VALUES (1, 'EventA', 'Theater', 2020, 100), (2, 'EventB', 'Theater', 2020, 200), (3, 'EventC', 'Theater', 2020, 300);
What is the number of unique visitors for theater events in 2020?
SELECT COUNT(DISTINCT visitors) FROM events WHERE type = 'Theater' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE spending (year INT, location VARCHAR(20), amount INT); INSERT INTO spending (year, location, amount) VALUES (2020, 'Rural California', 5000000);
What is the total healthcare spending in rural areas of California in 2020?
SELECT SUM(amount) FROM spending WHERE location = 'Rural California' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_aid (id INT, location VARCHAR(255), person_id INT, amount FLOAT); INSERT INTO medical_aid (id, location, person_id, amount) VALUES (1, 'Urban', 1001, 150), (2, 'Urban', 1002, 120), (3, 'Rural', 1003, 100); CREATE TABLE people (id INT, location VARCHAR(255)); INSERT INTO people (id, location) VALUES...
What is the average amount of medical aid per person in urban areas?
SELECT AVG(amount) FROM medical_aid ma JOIN people p ON ma.person_id = p.id WHERE p.location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition1 (exhibition_id INT, visitor_id INT, primary key(exhibition_id, visitor_id)); INSERT INTO Exhibition1 VALUES (1, 1), (1, 2), (2, 3), (2, 4); CREATE TABLE Visitor (visitor_id INT, age INT, country VARCHAR(255), primary key(visitor_id)); INSERT INTO Visitor VALUES (1, 22, 'USA'), (2, 31, 'Canada')...
What is the age distribution of visitors who engaged in digital activities, grouped by exhibition and country?
SELECT Exhibition1.exhibition_id, Visitor.country, AVG(Visitor.age) FROM Exhibition1 INNER JOIN Visitor ON Exhibition1.visitor_id = Visitor.visitor_id INNER JOIN DigitalActivity ON Visitor.visitor_id = DigitalActivity.visitor_id GROUP BY Exhibition1.exhibition_id, Visitor.country;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (sales_id INT, drug_name VARCHAR(255), quantity_sold INT, sales_date DATE, region VARCHAR(255));
Delete all records for drug 'DrugZ' from the 'sales_data' table.
DELETE FROM sales_data WHERE drug_name = 'DrugZ';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_id VARCHAR(10), approval_year INT, expenditure NUMERIC(12,2));
What is the average R&D expenditure for drugs approved in 2018?
SELECT AVG(expenditure) FROM rd_expenditure WHERE approval_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE innovation_scores (chemical_id INT, innovation_score INT, measurement_date DATE); INSERT INTO innovation_scores (chemical_id, innovation_score, measurement_date) VALUES (105, 65, '2019-01-01'), (105, 68, '2019-04-01'), (105, 72, '2019-07-01'), (105, 75, '2019-10-01'), (101, 60, '2019-01-01'), (101, 63, '20...
Show the innovation progress for chemical 105 over time, including its innovation score and ranking among other chemicals?
SELECT innovation_score, RANK() OVER (PARTITION BY measurement_date ORDER BY innovation_score DESC) as innovation_rank FROM innovation_scores WHERE chemical_id = 105
gretelai_synthetic_text_to_sql
CREATE TABLE flights (flight_id INT, flight_name VARCHAR(50), destination_country VARCHAR(50));
Display the number of flights to each country from the 'flights' table
SELECT destination_country, COUNT(*) as flight_count FROM flights GROUP BY destination_country;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, gender VARCHAR(50), mental_health_score INT, date DATE); INSERT INTO student_mental_health VALUES (1, 'Female', 75, '2019-01-01'), (2, 'Male', 85, '2019-01-02');
What is the average mental health score for students, grouped by gender, for the past 3 years?
SELECT gender, AVG(mental_health_score) OVER (PARTITION BY gender ORDER BY date ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) as avg_score FROM student_mental_health;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (region VARCHAR(20), name VARCHAR(50), size FLOAT); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Atlantic Ocean', 'Bermuda Parks and Nature Reserves', 78); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Atlantic Ocean', 'Sargasso Sea', 3500000); ...
How many marine protected areas are in the Atlantic Ocean?
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, strategy_name VARCHAR(25));
Insert a new cybersecurity strategy 'Zero Trust Architecture' into the 'cybersecurity_strategies' table
INSERT INTO cybersecurity_strategies (strategy_name) VALUES ('Zero Trust Architecture');
gretelai_synthetic_text_to_sql
CREATE TABLE incident (id INT, incident_type VARCHAR(255), affected_system VARCHAR(255), country VARCHAR(255), timestamp TIMESTAMP); INSERT INTO incident (id, incident_type, affected_system, country, timestamp) VALUES (1, 'Phishing', 'Email', 'Germany', '2022-01-01 00:00:00'), (2, 'Malware', 'Website', 'France', '2022-...
List all cybersecurity incidents, their types, affected systems, and the country where they occurred, ordered by date.
SELECT incident_type, affected_system, country, timestamp FROM incident ORDER BY timestamp ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_fairness_projects (id INT PRIMARY KEY, project_name VARCHAR(50), category VARCHAR(50)); INSERT INTO safety_fairness_projects (id, project_name, category) VALUES (1, 'Secure AI', 'Safety'), (2, 'Robust AI', 'Safety'), (3, 'Privacy-Preserving AI', 'Safety'), (4, 'Verification & Validation', 'Safety'),...
Total number of AI safety and AI fairness projects.
SELECT COUNT(*) FROM safety_fairness_projects WHERE category IN ('Safety', 'Fairness');
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (customer_id INT, month DATE, savings_balance DECIMAL(10,2)); INSERT INTO financial_capability (customer_id, month, savings_balance) VALUES (1001, '2022-01-01', 15000.00), (1001, '2022-02-01', 17000.00), (1001, '2022-03-01', 18000.00), (1002, '2022-01-01', 20000.00), (1002, '2022-02-01...
For each customer in the financial_capability table, calculate the three-month moving average of their savings balance. Display the customer ID and moving average.
SELECT customer_id, AVG(savings_balance) OVER (PARTITION BY customer_id ORDER BY month ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as moving_average FROM financial_capability;
gretelai_synthetic_text_to_sql
CREATE TABLE Adoptions (id INT, city VARCHAR(255), vehicle_count INT, country VARCHAR(50), adoption_year INT); INSERT INTO Adoptions (id, city, vehicle_count, country, adoption_year) VALUES (1, 'Berlin', 1000, 'Germany', 2020); INSERT INTO Adoptions (id, city, vehicle_count, country, adoption_year) VALUES (2, 'Paris', ...
Which European city had the highest number of electric vehicle adoptions in 2020?
SELECT city, SUM(vehicle_count) FROM Adoptions WHERE country = 'Germany' OR country = 'France' AND adoption_year = 2020 GROUP BY city ORDER BY SUM(vehicle_count) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, mission_start_date DATE, mission_end_date DATE);
What is the lead time between two consecutive space missions
SELECT mission_start_date, LEAD(mission_start_date) OVER (ORDER BY mission_start_date) - mission_start_date AS lead_time FROM SpaceMissions;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(50)); INSERT INTO drugs (drug_id, drug_name) VALUES (1, 'DrugA'), (2, 'DrugB'); CREATE TABLE rd_expenditures (expenditure_id INT, drug_id INT, year INT, amount INT); INSERT INTO rd_expenditures (expenditure_id, drug_id, year, amount) VALUES (1, 1, 2020, 250000), (2, 1,...
What is the R&D expenditure for a specific drug in a given year?
SELECT r.amount FROM rd_expenditures r JOIN drugs d ON r.drug_id = d.drug_id WHERE d.drug_name = 'DrugA' AND r.year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE state_plants (state TEXT, num_plants INT); INSERT INTO state_plants (state, num_plants) VALUES ('California', 321), ('Texas', 456), ('New York', 123), ('Florida', 345);
Which states have more than 300 wastewater treatment plants?
SELECT state FROM state_plants WHERE num_plants > 300
gretelai_synthetic_text_to_sql
CREATE TABLE fleet (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), length FLOAT, year_built INT);
Show me the number of vessels in the fleet
SELECT COUNT(*) FROM fleet;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(255), department_id INT); CREATE TABLE publication (id INT, faculty_id INT, year INT, citations INT); INSERT INTO faculty (id, name, department_id) VALUES (1, 'John Doe', 1), (2, 'Jane Smith', 1), (3, 'Bob Johnson', 2); INSERT INTO publication (id, faculty_id, year, citations)...
What is the average number of citations per publication by department?
SELECT department.name, AVG(COUNT(publication.id)) as avg_citations_per_publication FROM department LEFT JOIN faculty ON department.id = faculty.department_id LEFT JOIN publication ON faculty.id = publication.faculty_id GROUP BY department.name;
gretelai_synthetic_text_to_sql
CREATE TABLE north_american_tourism (destination VARCHAR(255), continent VARCHAR(255), visitors INT); INSERT INTO north_american_tourism (destination, continent, visitors) VALUES ('New York City', 'North America', 8000000); INSERT INTO north_american_tourism (destination, continent, visitors) VALUES ('Los Angeles', 'No...
What are the top 5 most popular international destinations in North America, and their visitor counts?
SELECT destination, continent, visitors, RANK() OVER (PARTITION BY continent ORDER BY visitors DESC) as popularity_rank FROM north_american_tourism WHERE continent = 'North America' AND popularity_rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE SocialImpact (id INT, region VARCHAR(20), score FLOAT); INSERT INTO SocialImpact (id, region, score) VALUES (1, 'Northeast', 80.0), (2, 'Southeast', 85.0), (3, 'Midwest', 90.0), (4, 'Southwest', 70.0), (5, 'Northwest', 75.0);
What is the minimum and maximum social impact score?
SELECT MIN(score) as min_score, MAX(score) as max_score FROM SocialImpact;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), state VARCHAR(255), construction_year INT, is_green BOOLEAN); INSERT INTO green_buildings (building_id, building_name, state, construction_year, is_green) VALUES (1, 'Green Building 1', 'NY', 2008, true); INSERT INTO green_buildings (building_id...
How many green buildings are there in each state for buildings constructed before 2010?
SELECT state, COUNT(*) as green_buildings_count FROM green_buildings WHERE construction_year < 2010 AND is_green = true GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Workplace (WorkplaceID INT, WorkplaceName VARCHAR(50), UnionID INT); INSERT INTO Workplace (WorkplaceID, WorkplaceName, UnionID) VALUES (1, 'Workplace1', 1), (2, 'Workplace2', 1), (3, 'Workplace3', 2);
Count the number of workplaces per union
SELECT UnionID, COUNT(DISTINCT WorkplaceID) as NumWorkplaces FROM Workplace GROUP BY UnionID;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(100), age INT, crop VARCHAR(50), country VARCHAR(50)); INSERT INTO farmers (id, name, age, crop, country) VALUES (1, 'Juan', 45, 'corn', 'Mexico');
What is the average age of farmers who grow corn in Mexico?
SELECT AVG(age) FROM farmers WHERE crop = 'corn' AND country = 'Mexico'
gretelai_synthetic_text_to_sql
CREATE TABLE research_studies (id INT, study_title VARCHAR, publication_year INT, autonomous BOOLEAN);
Determine the percentage of autonomous driving research studies with a publication year after 2020.
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM research_studies WHERE publication_year > 2020) AS percentage FROM research_studies WHERE publication_year > 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE events_attendees_3 (event_id INT, attendee_id INT, event_date DATE); INSERT INTO events_attendees_3 (event_id, attendee_id, event_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2023-01-02'), (3, 3, '2022-02-01'), (4, 4, '2023-03-01');
Show the number of events and total attendees by month and year
SELECT YEAR(event_date) AS year, MONTH(event_date) AS month, COUNT(DISTINCT event_id) AS num_events, COUNT(DISTINCT attendee_id) AS num_attendees FROM events_attendees_3 GROUP BY year, month;
gretelai_synthetic_text_to_sql
CREATE TABLE patients_regions (patient_id INT, improvement CHAR(1), region VARCHAR(20)); INSERT INTO patients_regions (patient_id, improvement, region) VALUES (1, 'Y', 'Asia'), (2, 'N', 'Europe'), (3, 'Y', 'America');
How many patients improved in each region?
SELECT region, SUM(CASE WHEN improvement = 'Y' THEN 1 ELSE 0 END) as improved_patients FROM patients_regions GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE islamic_bank (id INT, bank_name VARCHAR(255)); CREATE TABLE microfinance_loans (id INT, islamic_bank_id INT, borrower_education DECIMAL(10, 2), loan_amount DECIMAL(10, 2));
Calculate the total number of microfinance loans and the total loan amount per borrower, grouped by Islamic bank and borrower education level.
SELECT i.bank_name, m.borrower_education, COUNT(m.id) as total_loans, SUM(m.loan_amount) as total_loan_amount FROM islamic_bank i JOIN microfinance_loans m ON i.id = m.islamic_bank_id GROUP BY i.bank_name, m.borrower_education;
gretelai_synthetic_text_to_sql
CREATE TABLE Albums (AlbumID int, Title varchar(100), ReleaseDate date, ArtistID int, Genre varchar(50)); INSERT INTO Albums (AlbumID, Title, ReleaseDate, ArtistID, Genre) VALUES (1, 'Fearless', '2008-11-11', 1, 'Country'), (2, 'Speak Now', '2010-10-25', 1, 'Pop'), (3, 'Red', '2012-10-22', 1, 'Pop'), (4, '1989', '2014-...
Delete the album with AlbumID 10 from the Albums table.
DELETE FROM Albums WHERE AlbumID = 10;
gretelai_synthetic_text_to_sql
CREATE TABLE GenreRevenue (Genre VARCHAR(50), ReleaseDate DATE, Revenue DECIMAL(10, 2)); INSERT INTO GenreRevenue (Genre, ReleaseDate, Revenue) VALUES ('Pop', '2020-01-01', 5000); INSERT INTO GenreRevenue (Genre, ReleaseDate, Revenue) VALUES ('Rock', '2020-01-01', 7000);
Show the total revenue for each genre in 2020.
SELECT Genre, SUM(Revenue) AS TotalRevenue FROM GenreRevenue WHERE ReleaseDate BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE venue (venue_id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(100));
Insert a new record into the "venue" table for a venue named "Metropolitan Museum" located in New York
INSERT INTO venue (venue_id, name, location) VALUES ((SELECT MAX(venue_id) FROM venue) + 1, 'Metropolitan Museum', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE GameScores (GameID int, GameName varchar(50), PlayerID int); INSERT INTO GameScores (GameID, GameName, PlayerID) VALUES (1, 'GameA', 1), (2, 'GameB', 1), (1, 'GameA', 2), (2, 'GameB', 2);
What is the number of unique games played by each player?
SELECT PlayerID, COUNT(DISTINCT GameName) FROM GameScores GROUP BY PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (meeting_id INT, meeting_location VARCHAR(255), meeting_date DATE, participants VARCHAR(255));
Insert new records into the 'defense_diplomacy' table for meetings held in Canada in 2022
INSERT INTO defense_diplomacy (meeting_id, meeting_location, meeting_date, participants) VALUES (1, 'Canada', '2022-01-01', 'Canada, USA'), (2, 'Canada', '2022-02-01', 'Canada, UK');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id int, material varchar(20), price decimal(5,2)); INSERT INTO products (product_id, material, price) VALUES (1, 'organic cotton', 25.99), (2, 'recycled polyester', 19.99), (3, 'organic cotton', 34.99), (4, 'sustainable silk', 79.99);
What is the price range for products made from sustainable materials?
SELECT material, MIN(price) min_price, MAX(price) max_price FROM products WHERE material in ('organic cotton', 'recycled polyester', 'sustainable silk') GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, total_menu_items INT, cuisine VARCHAR(255)); CREATE TABLE menus (menu_id INT, restaurant_id INT, menu_item_id INT); INSERT INTO restaurants VALUES (1, 10, 'Mexican'); INSERT INTO restaurants VALUES (2, 8, 'Chinese'); INSERT INTO menus VALUES (1, 1, 1); INSERT INTO menus VALU...
Show the number of menu items that are unique to each restaurant, along with the total number of menu items offered by each restaurant, grouped by the type of cuisine offered by the restaurant.
SELECT r.cuisine, r.restaurant_id, COUNT(DISTINCT m.menu_item_id) as unique_menu_items, SUM(m.menu_item_id) as total_menu_items FROM restaurants r INNER JOIN menus m ON r.restaurant_id = m.restaurant_id GROUP BY r.cuisine, r.restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, DonationDate, Amount) VALUES (1, 1, '202...
Who are the top 5 donors by total donation amount in 2022?
SELECT DonorName, SUM(Amount) as TotalDonation FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE YEAR(DonationDate) = 2022 GROUP BY DonorName ORDER BY TotalDonation DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteer_Hours_Monthly (VolunteerID INT, Month VARCHAR(10), Hours DECIMAL(10, 2));
List the total number of volunteers and total hours spent per month, from the 'Volunteer_Hours_Monthly' table, grouped by Month.
SELECT Month, COUNT(*) AS Number_Of_Volunteers, SUM(Hours) AS Total_Hours_Spent FROM Volunteer_Hours_Monthly GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling (id INT, cargo_id INT, handling_date DATE, tonnage INT, PRIMARY KEY(id));
What is the total tonnage of all cargo handled by the 'cargo_handling' table in the year 2021?
SELECT SUM(tonnage) FROM cargo_handling WHERE YEAR(handling_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE country_satellites (country VARCHAR(255), satellite_id INT, name VARCHAR(255), launch_date DATE);
How many satellites has each country launched in total?
SELECT country, COUNT(*) as total_launches FROM country_satellites GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_programs (program_id INT, program_name VARCHAR(50), num_students INT); INSERT INTO graduate_programs (program_id, program_name, num_students) VALUES (1, 'Computer Science', 50); INSERT INTO graduate_programs (program_id, program_name, num_students) VALUES (2, 'Mathematics', 30); INSERT INTO gradua...
Show the number of graduate students who have published academic papers in each program, ordered by the number of publications.
SELECT program_id, SUM(num_papers) as total_publications FROM students GROUP BY program_id ORDER BY total_publications DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleSales (id INT, vehicle_type VARCHAR(255), sale_date DATE, units_sold INT, country VARCHAR(255)); INSERT INTO VehicleSales (id, vehicle_type, sale_date, units_sold, country) VALUES (1, 'Gasoline', '2017-01-01', 500, 'USA'); INSERT INTO VehicleSales (id, vehicle_type, sale_date, units_sold, country) V...
What is the percentage of electric vehicles sold in North America in 2020?
SELECT (COUNT(*) FILTER (WHERE vehicle_type = 'Electric')) * 100.0 / COUNT(*) FROM VehicleSales WHERE sale_date >= '2020-01-01' AND country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees(id INT, department VARCHAR(20), position VARCHAR(20), salary INT, gender VARCHAR(10), full_time BOOLEAN);
What is the average salary of full-time employees by gender in the Mining department?
SELECT gender, AVG(salary) FROM Employees WHERE department = 'Mining' AND full_time = TRUE GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, continent VARCHAR(255), is_social_good BOOLEAN); INSERT INTO organizations (id, continent, is_social_good) VALUES (1, 'Oceania', true), (2, 'Antarctica', false), (3, 'Oceania', true), (4, 'Asia', true);
List all social good technology organizations in Oceania.
SELECT name FROM organizations WHERE continent = 'Oceania' AND is_social_good = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Athletes (AthleteID INT, TeamID INT, ParticipatesInWellbeingProgram BOOLEAN); INSERT INTO Athletes (AthleteID, TeamID, ParticipatesInWellbeingProgram) VALUES (1, 1, TRUE), (2, 1, FALSE), (3, 2, TRUE), (4, 2, TRUE), (5, 2, FALSE);
How many athletes participate in wellbeing programs per team?
SELECT T.TeamName, COUNT(A.AthleteID) AS AthleteCount FROM Teams T INNER JOIN Athletes A ON T.TeamID = A.TeamID WHERE A.ParticipatesInWellbeingProgram = TRUE GROUP BY T.TeamName;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); INSERT INTO mine (id, name, location) VALUES (1, 'Platinum Mine', 'Zimbabwe'), (2, 'Diamond Mine', 'Botswana'); CREATE TABLE temperature (id INT, mine_id INT, date DATE, temperature REAL); INSERT INTO temperature (id, mine_id, date, temperature) VALUES (1, 1, '2022-...
What is the minimum daily temperature recorded at each mine location in the last week?
SELECT mine_id, MIN(temperature) as min_temperature FROM temperature WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT PRIMARY KEY, DonorID INT, DonationAmount DECIMAL(5,2), DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate) VALUES (5, 5, 250.00, '2021-01-01'), (6, 5, 300.00, '2021-02-15'), (7, 6, 500.00, '2021-03-10'), (8, 6, 450.00, '2021-04-05'), (9, 7...
What is the average donation amount for donors who have donated more than once in New York?
SELECT DonorID, AVG(DonationAmount) FROM Donations WHERE DonorID IN (SELECT DonorID FROM Donations GROUP BY DonorID HAVING COUNT(DonationID) > 1) AND DonationDate BETWEEN '2021-01-01' AND CURDATE() GROUP BY DonorID;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (id INT, source VARCHAR(50), destination VARCHAR(50), weight FLOAT, ship_date DATE); INSERT INTO Shipments (id, source, destination, weight, ship_date) VALUES (3, 'Canada', 'Mexico', 900, '2022-01-05'); INSERT INTO Shipments (id, source, destination, weight, ship_date) VALUES (4, 'Canada', 'Mexic...
Find the top 3 heaviest shipments from Canada to Mexico since January 2022?
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY weight DESC) as rn FROM Shipments WHERE source = 'Canada' AND destination = 'Mexico' AND ship_date >= '2022-01-01') t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_date DATE, security_type VARCHAR(50), security_name VARCHAR(50), quantity INT, price DECIMAL(10, 2)); INSERT INTO transactions (id, transaction_date, security_type, security_name, quantity, price) VALUES (1, '2021-10-01', 'ETF', 'Tech Titans', 100, 100.00), (2, '2021-10-05...
List all transactions involving 'Tech Titans' ETF in October 2021.
SELECT * FROM transactions WHERE security_name = 'Tech Titans' AND transaction_date BETWEEN '2021-10-01' AND '2021-10-31';
gretelai_synthetic_text_to_sql
CREATE TABLE open_data_initiatives (name VARCHAR(255), state VARCHAR(255), description VARCHAR(255), url VARCHAR(255)); INSERT INTO open_data_initiatives (name, state, description, url) VALUES ('California Open Data Portal', 'California', 'Portal for California open data', 'https://data.ca.gov/'); INSERT INTO open_data...
List all the open data initiatives in California
SELECT * FROM open_data_initiatives WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (strategy_id INT, name VARCHAR(255)); CREATE TABLE asset_management_transactions (transaction_id INT, strategy_id INT, amount DECIMAL(10,2), trans_date DATE);
Which investment strategies have had a total transaction value of over 50000 in the past month in an asset management firm?
SELECT investment_strategies.name FROM investment_strategies INNER JOIN asset_management_transactions ON investment_strategies.strategy_id = asset_management_transactions.strategy_id WHERE asset_management_transactions.trans_date >= NOW() - INTERVAL '1 month' GROUP BY investment_strategies.name HAVING SUM(asset_managem...
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT); INSERT INTO routes (route_id, route_name) VALUES (101, 'Bus Route 101'), (102, 'Bus Route 102'); CREATE TABLE fare_collection (collection_id INT, passenger_type TEXT, route_id INT, fare DECIMAL); INSERT INTO fare_collection (collection_id, passenger_type, route_id, f...
Update the fare for bus route 102 to $3.50 for able-bodied passengers.
UPDATE fare_collection SET fare = 3.50 WHERE passenger_type = 'Able-bodied' AND route_id = 102;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_agency VARCHAR(50), mission_status VARCHAR(50)); INSERT INTO space_missions (id, mission_agency, mission_status) VALUES (1, 'NASA', 'completed'), (2, 'ESA', 'completed'), (3, 'NASA', 'in progress');
How many space missions have been completed by NASA?
SELECT COUNT(*) FROM space_missions WHERE mission_agency = 'NASA' AND mission_status = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_name VARCHAR(255), creation_date DATE, regulatory_actions INT); INSERT INTO projects (project_name, creation_date, regulatory_actions) VALUES ('ProjectA', '2021-03-01', 0), ('ProjectB', '2021-06-15', 1), ('ProjectC', '2021-01-10', 0), ('ProjectD', '2021-04-20', 0), ('ProjectE', '2021-07-0...
What is the total number of projects created in 'Q1 2021' and 'Q2 2021' that have not been associated with any regulatory actions?
SELECT COUNT(*) FROM projects WHERE (creation_date BETWEEN '2021-01-01' AND '2021-06-30') AND regulatory_actions = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (id INT, name VARCHAR(50), region VARCHAR(20), join_date DATE, monthly_usage INT);
List all broadband subscribers who joined after 2020-01-01 and their monthly usage in 'regional' regions.
SELECT name, region, monthly_usage FROM broadband_subscribers WHERE join_date > '2020-01-01' AND region = 'regional';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) V...
What is the average depth of coral reef habitats?
SELECT AVG(depth) FROM species WHERE habitat = 'Coral Reef';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(255), age INT); INSERT INTO Artists (id, name, age) VALUES (1, 'Taylor Swift', 32), (2, 'Billie Eilish', 20);
What is the average age of all artists?
SELECT AVG(age) FROM Artists;
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (id INT, name TEXT, mountainRange TEXT, constructionYear INT);
What is the average age of all dams in the 'Appalachian' mountain range that were built before 1950?
SELECT mountainRange, AVG(YEAR(CURRENT_DATE) - constructionYear) FROM Dams WHERE mountainRange = 'Appalachian' AND constructionYear < 1950 GROUP BY mountainRange;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, volunteer_name TEXT, program TEXT, state TEXT); INSERT INTO Volunteers (id, volunteer_name, program, state) VALUES (1, 'Alice', 'Feeding the Hungry', 'CA'), (2, 'Bob', 'Clothing Drive', 'CA'), (3, 'Charlie', 'Feeding the Hungry', 'NY'), (4, 'David', 'Clothing Drive', 'NY');
What is the average number of volunteers per program in California?
SELECT program, AVG(COUNT(*)) FROM Volunteers WHERE state = 'CA' GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, age INT, multiplayer BOOLEAN); INSERT INTO players (id, age, multiplayer) VALUES (1, 22, true); INSERT INTO players (id, age, multiplayer) VALUES (2, 30, false);
What is the average age difference between players who play multiplayer games and those who play single-player games?
SELECT AVG(CASE WHEN multiplayer THEN age ELSE NULL END) - AVG(CASE WHEN multiplayer THEN NULL ELSE age END) FROM players;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_fines (country VARCHAR(255), fine_amount INT);
Calculate the total number of regulatory fines for each country in the 'regulatory_fines' table, and display the results in descending order by the total fine amount.
SELECT r.country, SUM(r.fine_amount) as total_fines FROM regulatory_fines r GROUP BY r.country ORDER BY total_fines DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name TEXT, country TEXT); CREATE TABLE Meals (id INT, name TEXT, type TEXT, calories INT, RestaurantId INT, FOREIGN KEY (RestaurantId) REFERENCES Restaurants(id)); INSERT INTO Restaurants (id, name, country) VALUES (1, 'Restaurant A', 'UK'), (2, 'Restaurant B', 'UK'), (3, 'Restaurant C...
Find the maximum number of calories in vegan meals in restaurants located in the UK.
SELECT MAX(Meals.calories) FROM Meals JOIN Restaurants ON Meals.RestaurantId = Restaurants.id WHERE Meals.type = 'Vegan' AND Restaurants.country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE Product_Innovation (Id INT, Chemical_Id INT, New_Product BOOLEAN, Improved_Process BOOLEAN); INSERT INTO Product_Innovation (Id, Chemical_Id, New_Product, Improved_Process) VALUES (1, 1, TRUE, TRUE), (2, 2, FALSE, TRUE), (3, 3, TRUE, FALSE);
What are the chemical IDs of products that were both innovated and have improved processes?
SELECT Chemical_Id FROM Product_Innovation WHERE New_Product = TRUE AND Improved_Process = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, release_date DATE, song_length FLOAT); INSERT INTO songs VALUES (1, '2010-01-01', 500.3), (2, '2011-02-14', 450.2), (3, '2010-05-23', 600.5), (4, '2009-12-31', 400.1);
What is the release date of the song with the longest duration?
SELECT release_date FROM songs WHERE song_length = (SELECT MAX(song_length) FROM songs);
gretelai_synthetic_text_to_sql
CREATE TABLE world_cup (match_date DATE, home_team VARCHAR(100), away_team VARCHAR(100), spectators INT); INSERT INTO world_cup VALUES ('2018-06-14', 'Russia', 'Saudi Arabia', 78011), ('2018-06-15', 'Egypt', 'Uruguay', 45000), ('2018-06-16', 'Morocco', 'Iran', 39579), ('2018-06-17', 'Portugal', 'Spain', 62716);
What is the average number of spectators at the World Cup matches per team?
SELECT AVG(spectators) FROM world_cup WHERE home_team = ANY (SELECT team FROM (VALUES ('Russia'), ('Egypt'), ('Morocco'), ('Portugal')) AS t(team));
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT, num_schools INT, total_budget INT); INSERT INTO districts (district_id, district_name, num_schools, total_budget) VALUES (1, 'Downtown', 7, 5000000), (2, 'Uptown', 3, 2500000), (3, 'Harbor', 6, 4000000);
What is the average budget allocated to schools in each district that have more than 5 schools?
SELECT AVG(total_budget) FROM districts WHERE num_schools > 5 GROUP BY district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_ratings (id INT, vehicle_type VARCHAR(20), safety_rating DECIMAL(3,2)); INSERT INTO safety_ratings (id, vehicle_type, safety_rating) VALUES (1, 'EV', 4.5), (2, 'EV', 4.7), (3, 'Hybrid', 4.3), (4, 'Hybrid', 4.6), (5, 'Conventional', 4.2);
Calculate average safety rating of electric vehicles
SELECT AVG(safety_rating) FROM safety_ratings WHERE vehicle_type = 'EV';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), VesselType VARCHAR(100), PortID INT); INSERT INTO Vessels (VesselID, VesselName, VesselType, PortID) VALUES (1, 'Ever Ace', 'Container Ship', 1); CREATE TABLE Cargo (CargoID INT, CargoName VARCHAR(100), Quantity INT, VesselID INT); INSERT INTO Cargo (CargoI...
What is the total quantity of electronics transported by the Ever Ace?
SELECT SUM(Cargo.Quantity) FROM Cargo WHERE Cargo.VesselID = 1 AND Cargo.CargoName = 'Electronics';
gretelai_synthetic_text_to_sql
CREATE TABLE Potency (id INT, strain TEXT, growth_type TEXT, potency DECIMAL(5,2)); INSERT INTO Potency (id, strain, growth_type, potency) VALUES (1, 'Blue Dream', 'greenhouse', 16.5), (2, 'Girl Scout Cookies', 'greenhouse', 18.0), (3, 'Sour Diesel', 'greenhouse', 17.5), (4, 'Chem Dawg', 'greenhouse', 19.0);
What is the average potency of hybrid strains grown in Oregon greenhouses?
SELECT AVG(potency) as avg_potency FROM Potency WHERE growth_type = 'greenhouse' AND strain LIKE '%hybrid%';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID INT, PolicyType VARCHAR(255), PolicyholderID INT); INSERT INTO Claims VALUES (1, 'Auto', 1), (2, 'Home', 2), (3, 'Auto', 3), (4, 'Life', 4), (5, 'Auto', 5);
list the top 3 policy types with the highest number of claims, ordered by the number of claims in descending order
SELECT PolicyType, COUNT(*) as ClaimCount FROM Claims GROUP BY PolicyType ORDER BY ClaimCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(10), location VARCHAR(255), farmer_id INT); CREATE TABLE Crops (id INT PRIMARY KEY, type VARCHAR(255), acres FLOAT, farmer_id INT, FOREIGN KEY (farmer_id) REFERENCES Farmers(farmer_id));
Insert new data for a farmer and their crops in Australia
INSERT INTO Crops (id, type, acres, farmer_id) VALUES (6, 'cotton', 25.3, 4); INSERT INTO Farmers (id, name, age, gender, location, farmer_id) VALUES (4, 'James Smith', 45, 'Male', 'Australia', 6);
gretelai_synthetic_text_to_sql
CREATE TABLE Attractions (id INT, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO Attractions (id, name, continent) VALUES (1, 'Eiffel Tower', 'Europe'), (2, 'Colosseum', 'Europe'), (3, 'Niagara Falls', 'Americas'), (4, 'Great Wall', 'Asia'), (5, 'Taj Mahal', 'Asia'), (6, 'Sydney Opera House', 'Australia'), (7, '...
Display the names and number of attractions for each continent with more than 5 attractions.
SELECT continent, name, COUNT(*) as num_attractions FROM Attractions GROUP BY continent HAVING num_attractions > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, case_number VARCHAR(20), case_type VARCHAR(10), billing_amount DECIMAL(10,2)); INSERT INTO cases (id, case_number, case_type, billing_amount) VALUES (1, '12345', 'civil', 5000.00); INSERT INTO cases (id, case_number, case_type, billing_amount) VALUES (2, '54321', 'criminal', 3000.00); INSERT...
What is the total billing amount for cases with a 'civil' case type?
SELECT SUM(billing_amount) FROM cases WHERE case_type = 'civil';
gretelai_synthetic_text_to_sql
CREATE TABLE riders (rider_id INT, name VARCHAR(255), address VARCHAR(255)); INSERT INTO riders (rider_id, name, address) VALUES (2, 'Jane Doe', '456 Elm St');
Update rider 'Jane Doe's' address to '123 Main St'
UPDATE riders SET address = '123 Main St' WHERE name = 'Jane Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_vegan BOOLEAN, country VARCHAR(255));
Insert new records for 3 vegan skincare products into the database.
INSERT INTO products (product_id, product_name, is_vegan, country) VALUES (1, 'Rose Hip Oil', TRUE, 'Canada'), (2, 'Activated Charcoal Soap', TRUE, 'Mexico'), (3, 'Green Tea Toner', TRUE, 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name TEXT); CREATE TABLE volunteers (id INT, program_id INT, name TEXT); INSERT INTO programs (id, name) VALUES (1, 'Feeding the Hungry'), (2, 'Tutoring Kids'), (3, 'Cleaning the Environment'); INSERT INTO volunteers (id, program_id, name) VALUES (1, 1, 'John Doe'), (2, 1, 'Jane Smith'), ...
List all the programs with their IDs and total number of volunteers, ordered by the total number of volunteers in descending order.
SELECT ROW_NUMBER() OVER (ORDER BY total_volunteers DESC) AS rank, programs.id, programs.name, COUNT(volunteers.id) AS total_volunteers FROM programs LEFT JOIN volunteers ON programs.id = volunteers.program_id GROUP BY programs.id, programs.name ORDER BY total_volunteers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE RecycledMaterials (id INT, country VARCHAR(255), garment_type VARCHAR(255), quantity INT); INSERT INTO RecycledMaterials (id, country, garment_type, quantity) VALUES (1, 'France', 'T-Shirt', 1500), (2, 'Germany', 'T-Shirt', 2000), (3, 'Spain', 'Pants', 1200), (4, 'France', 'Dress', 800);
How many garments are made with recycled materials per country?
SELECT country, COUNT(*) FROM RecycledMaterials GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurant (restaurant_id INT, region VARCHAR(255)); INSERT INTO Restaurant (restaurant_id, region) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Northeast');
What is the total number of restaurants in each region?
SELECT r.region, COUNT(r.restaurant_id) as num_restaurants FROM Restaurant r GROUP BY r.region;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_info (patient_id INT, first_treatment_date DATE); INSERT INTO patient_info (patient_id, first_treatment_date) VALUES (1, '2022-01-15'), (2, '2021-06-01'), (3, '2022-10-05'), (4, NULL); CREATE TABLE therapy_sessions (patient_id INT, session_date DATE); INSERT INTO therapy_sessions (patient_id, sessi...
Find the first treatment date for each patient who started therapy in '2022'
SELECT patient_id, MIN(session_date) AS first_treatment_date FROM therapy_sessions WHERE patient_id IN (SELECT patient_id FROM patient_info WHERE first_treatment_date IS NULL OR first_treatment_date = '2022-01-01') GROUP BY patient_id;
gretelai_synthetic_text_to_sql
CREATE TABLE CountrySecurityBudget (Country VARCHAR(50), Year INT, Budget NUMERIC); INSERT INTO CountrySecurityBudget (Country, Year, Budget) VALUES ('USA', 2020, 20000), ('USA', 2021, 22000), ('China', 2020, 12000), ('China', 2021, 15000), ('India', 2020, 5000), ('India', 2021, 6000), ('Russia', 2020, 7000), ('Russia...
What are the top 5 countries with the highest cybersecurity budgets in the last 2 years?
SELECT Country, SUM(Budget) as Total_Budget FROM CountrySecurityBudget WHERE Year >= 2020 GROUP BY Country ORDER BY Total_Budget DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(255), contract_value DECIMAL(10,2), state VARCHAR(2), quarter INT);
What is the total value of defense contracts awarded to companies in California in Q1 2020?
SELECT SUM(contract_value) FROM defense_contracts WHERE state = 'CA' AND quarter = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_trenches (id INT, name VARCHAR(255), depth FLOAT);
What is the average depth of marine trenches deeper than 8000 meters?
SELECT AVG(depth) FROM marine_trenches WHERE depth > 8000;
gretelai_synthetic_text_to_sql
CREATE TABLE Innovations_Count (id INT, location VARCHAR(30), count INT); INSERT INTO Innovations_Count (id, location, count) VALUES (1, 'Middle East', 10);
What is the total number of military innovations in the 'Middle East'?
SELECT SUM(count) FROM Innovations_Count WHERE location = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Program TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Program) VALUES (1, 'Alice', 'Education'), (2, 'Bob', 'Health'), (3, 'Charlie', 'Education'); CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT); INSERT INTO VolunteerHours (Volunteer...
How many volunteers have contributed more than 100 hours in the 'Education' program?
SELECT COUNT(DISTINCT Volunteers.VolunteerID) FROM Volunteers JOIN VolunteerHours ON Volunteers.VolunteerID = VolunteerHours.VolunteerID WHERE Volunteers.Program = 'Education' GROUP BY Volunteers.VolunteerID HAVING SUM(VolunteerHours.Hours) > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation(state TEXT, savings INTEGER); INSERT INTO conservation(state, savings) VALUES ('Utah', 150), ('Wyoming', 180);
Update water conservation records for Utah and Wyoming.
UPDATE conservation SET savings = CASE WHEN state = 'Utah' THEN 185 WHEN state = 'Wyoming' THEN 190 ELSE savings END;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerationTrend (country VARCHAR(50), year INT, waste_quantity INT); INSERT INTO WasteGenerationTrend (country, year, waste_quantity) VALUES ('Brazil', 2018, 150000), ('Brazil', 2019, 160000), ('Brazil', 2020, 180000), ('Argentina', 2018, 120000), ('Argentina', 2019, 130000), ('Argentina', 2020, 15000...
What is the waste generation trend in South America between 2018 and 2020, grouped by year?
SELECT year, AVG(waste_quantity) FROM WasteGenerationTrend WHERE year BETWEEN 2018 AND 2020 AND country IN ('South America/Brazil', 'South America/Argentina') GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE facilities(name VARCHAR(50), state VARCHAR(20), build_year INT); INSERT INTO facilities(name, state, build_year) VALUES ('Facility1', 'Texas', 1995), ('Facility2', 'Texas', 1988), ('Facility3', 'Texas', 1992);
List all wastewater treatment facilities in Texas that were built before 1990.
SELECT name FROM facilities WHERE state = 'Texas' AND build_year < 1990;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_revenue (id INT, garment_type VARCHAR(20), customer_country VARCHAR(20), revenue INT);INSERT INTO sales_revenue (id, garment_type, customer_country, revenue) VALUES (1, 'Women''s', 'Australia', 50000), (2, 'Men''s', 'Australia', 35000), (3, 'Women''s', 'Canada', 40000);
What is the sum of sales revenue from 'Women's' garments in 'Australia'?
SELECT SUM(revenue) FROM sales_revenue WHERE garment_type = 'Women''s' AND customer_country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, founders TEXT, industry TEXT); INSERT INTO Companies (id, name, founders, industry) VALUES (1, 'EcoInnovate', 'Black, Female', 'Environment'); INSERT INTO Companies (id, name, founders, industry) VALUES (2, 'TechBoost', 'Asian, Male', 'Technology'); CREATE TABLE Investment_Rou...
What is the maximum funding amount received by a company founded by a Black entrepreneur?
SELECT MAX(r.funding_amount) FROM Companies c JOIN Investment_Rounds r ON c.id = r.company_id WHERE c.founders LIKE '%Black%';
gretelai_synthetic_text_to_sql
CREATE TABLE NutritionData (id INT, food_name VARCHAR(50), calories INT, protein INT, fat INT); INSERT INTO NutritionData (id, food_name, calories, protein, fat) VALUES (1, 'Apple', 95, 0, 0), (2, 'Broccoli', 55, 3.7, 0.4);
What is the average protein content for foods with a fat content of 0?
SELECT AVG(protein) as avg_protein FROM NutritionData WHERE fat = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE, donor_program VARCHAR, donor_country VARCHAR); INSERT INTO donations (id, donor_id, donation_amount, donation_date, donor_program, donor_country) VALUES (1, 101, '500', '2021-01-01', 'Education', 'USA'), (2, 102, '300', '2021-02-...
Which countries have the highest average donation amounts in the Education program?
SELECT d.donor_country, AVG(d.donation_amount) as avg_donation FROM donations d WHERE d.donor_program = 'Education' GROUP BY d.donor_country ORDER BY avg_donation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_structures (id INT, region VARCHAR(50), structure_type VARCHAR(50), num_structures INT); INSERT INTO humanitarian_structures (id, region, structure_type, num_structures) VALUES (1, 'Asia', 'School', 600), (2, 'Africa', 'School', 300), (3, 'Europe', 'Hospital', 700), (4, 'South America', 'Schoo...
Show the number of schools and hospitals in each region in the 'humanitarian_structures' table.
SELECT region, structure_type, SUM(num_structures) as total_structures FROM humanitarian_structures GROUP BY region, structure_type;
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_violations (id INT, state VARCHAR(255), year INT, number_of_violations INT); INSERT INTO traffic_violations (id, state, year, number_of_violations) VALUES (1, 'New York', 2021, 1000), (2, 'New York', 2020, 900), (3, 'California', 2021, 1200);
What is the total number of traffic violations in the state of New York for the year 2021?
SELECT SUM(number_of_violations) FROM traffic_violations WHERE state = 'New York' AND year = 2021;
gretelai_synthetic_text_to_sql