context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE ocean_acidification_study (species TEXT); INSERT INTO ocean_acidification_study (species) VALUES ('Coral'), ('Plankton'), ('Fish'), ('Sharks');
What is the total number of marine species in the ocean acidification study?
SELECT COUNT(*) FROM ocean_acidification_study;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (id INT, awarded_date DATE, contract_value FLOAT); INSERT INTO defense_contracts (id, awarded_date, contract_value) VALUES (1, '2020-01-01', 10000000), (2, '2021-06-15', 2000000), (3, '2020-12-31', 7000000), (4, '2019-04-01', 3000000);
Which defense contracts had a value over 5 million dollars in 2020?
SELECT * FROM defense_contracts WHERE contract_value > 5000000 AND YEAR(awarded_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sightings (species TEXT, location TEXT, date DATE); INSERT INTO whale_sightings (species, location, date) VALUES ('Blue Whale', 'Pacific Ocean', '2020-01-01'), ('Humpback Whale', 'Atlantic Ocean', '2019-12-31');
Find the number of whale sightings in the Pacific Ocean.
SELECT COUNT(*) FROM whale_sightings WHERE location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (country VARCHAR(50), continent VARCHAR(50), carbon_price NUMERIC(5,2)); INSERT INTO carbon_pricing (country, continent, carbon_price) VALUES ('Germany', 'Europe', 25.0), ('France', 'Europe', 30.0), ('Canada', 'North America', 40.0), ('Brazil', 'South America', 15.0), ('India', 'Asia', 5.0);
What is the average carbon pricing for the 'carbon_pricing' table by continent?
SELECT AVG(carbon_price) FROM carbon_pricing GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE org_communication (org_size VARCHAR(20), method VARCHAR(20)); INSERT INTO org_communication (org_size, method) VALUES ('small', 'email'), ('medium', 'phone'), ('large', 'video_conference'), ('extra_large', 'virtual_reality');
What are the unique communication methods used by organizations with size 'small' and 'large'?
SELECT DISTINCT method FROM org_communication WHERE org_size IN ('small', 'large');
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (ID INT, Violation VARCHAR(255), State VARCHAR(255)); INSERT INTO HealthEquityMetrics VALUES (1, 'Racial discrimination in healthcare', 'Florida'); INSERT INTO HealthEquityMetrics VALUES (2, 'Gender discrimination in healthcare', 'Florida');
What is the most common health equity metric violation in Florida?
SELECT Violation, COUNT(*) AS Count FROM HealthEquityMetrics WHERE State = 'Florida' GROUP BY Violation ORDER BY Count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (student_id INT, program_name VARCHAR(255), accommodation_type VARCHAR(255)); INSERT INTO Accommodations (student_id, program_name, accommodation_type) VALUES (1, 'Program A', 'Screen Reader'); INSERT INTO Accommodations (student_id, program_name, accommodation_type) VALUES (3, 'Program B', 'Braille Materials');
How many students with visual impairments received accommodations in each program?
SELECT program_name, COUNT(DISTINCT student_id) as total_students FROM Accommodations WHERE accommodation_type IN ('Screen Reader', 'Braille Materials') GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Species(id INT, name VARCHAR(50), status VARCHAR(20), country VARCHAR(30)); INSERT INTO Species(id, name, status, country) VALUES (1, 'Clownfish', 'Least Concern', 'Indonesia'), (2, 'Sea Turtle', 'Endangered', 'Philippines'), (3, 'Dolphin', 'Vulnerable', 'Malaysia');
What is the conservation status of marine species in Southeast Asian countries?
SELECT status, COUNT(*) FROM Species WHERE country IN ('Indonesia', 'Philippines', 'Malaysia', 'Thailand', 'Singapore') GROUP BY status;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistPopularity (id INT, artist VARCHAR(50), country VARCHAR(20), streams INT); INSERT INTO ArtistPopularity (id, artist, country, streams) VALUES (1, 'BTS', 'Japan', 2000000), (2, 'Blackpink', 'Japan', 1500000);
Who is the most popular artist in Japan based on the number of streams?
SELECT artist FROM ArtistPopularity WHERE country = 'Japan' AND streams = (SELECT MAX(streams) FROM ArtistPopularity WHERE country = 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE course_topics (course_id INT, course_name VARCHAR(50), topic VARCHAR(50)); INSERT INTO course_topics (course_id, course_name, topic) VALUES (1, 'SQL Fundamentals', 'Database Management'), (2, 'Python for Data Analysis', 'Programming'), (3, 'Open Pedagogy', 'Instructional Design'), (4, 'Lifelong Learning', 'Education Policy'), (5, 'Inclusive Teaching Strategies', 'Diversity, Equity, and Inclusion'); CREATE TABLE teacher_development_history (teacher_id INT, course_id INT, completion_date DATE); INSERT INTO teacher_development_history (teacher_id, course_id, completion_date) VALUES (1, 1, '2021-06-20'), (1, 3, '2021-11-15'), (2, 2, '2021-04-05'), (2, 5, '2021-12-10'), (3, 3, '2021-08-01'), (3, 4, '2021-11-25'), (4, 2, '2021-05-02'), (4, 4, '2021-09-20'), (5, 1, '2021-02-14'), (5, 5, '2021-07-01');
What is the distribution of professional development course topics for teachers?
SELECT topic, COUNT(DISTINCT teacher_id) AS num_teachers FROM course_topics JOIN teacher_development_history ON course_topics.course_id = teacher_development_history.course_id GROUP BY topic;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism_activities (activity_id INT, activity_name TEXT, country TEXT); INSERT INTO sustainable_tourism_activities (activity_id, activity_name, country) VALUES (1, 'Rainforest Hike', 'Costa Rica'), (2, 'Wildlife Safari', 'Kenya'), (3, 'Coral Reef Dive', 'Australia');
How many sustainable tourism activities are available in Costa Rica?
SELECT COUNT(*) FROM sustainable_tourism_activities WHERE country = 'Costa Rica';
gretelai_synthetic_text_to_sql
CREATE TABLE biosensors (id INT, type TEXT, output FLOAT, country TEXT); INSERT INTO biosensors (id, type, output, country) VALUES (1, 'Glucose', 120, 'USA'); INSERT INTO biosensors (id, type, output, country) VALUES (2, 'Cholesterol', 200, 'Canada');
Calculate the average biosensor output for each biosensor type, excluding any results from the USA.
SELECT country, type, AVG(output) FROM biosensors WHERE country != 'USA' GROUP BY country, type;
gretelai_synthetic_text_to_sql
CREATE TABLE usa_recycling_rates (state VARCHAR(50), recycling_rate NUMERIC(10,2), measurement_date DATE); INSERT INTO usa_recycling_rates (state, recycling_rate, measurement_date) VALUES ('California', 0.35, '2022-02-28'), ('Texas', 0.28, '2022-02-28');
Calculate the total recycling rate for each state in the USA in the last year.
SELECT state, SUM(recycling_rate) total_rate FROM usa_recycling_rates WHERE measurement_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY state, ROW_NUMBER() OVER (PARTITION BY state ORDER BY measurement_date DESC);
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name TEXT, state TEXT, contract_value FLOAT); INSERT INTO defense_contracts (contract_id, company_name, state, contract_value) VALUES (1, 'ABC Corp', 'California', 5000000);
What is the total value of defense contracts awarded to companies in California?
SELECT SUM(contract_value) FROM defense_contracts WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, PlayerName VARCHAR(100), Country VARCHAR(50), VRAdoption BOOLEAN); CREATE TABLE VR_Games (GameID INT PRIMARY KEY, PlayerID INT, VirtualCurrency INT); INSERT INTO Players VALUES (1, 'David', 'USA', TRUE); INSERT INTO VR_Games VALUES (1, 1, 1000);
Get the average virtual currency earned per player who has adopted VR technology.
SELECT AVG(V.VirtualCurrency) as AvgCurrencyEarned FROM Players P JOIN VR_Games V ON P.PlayerID = V.PlayerID WHERE P.VRAdoption = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (program_name VARCHAR(255), total_carbon_offsets INT);
What are the names of the top 3 carbon offset programs in the 'carbon_offset_programs' table, ranked by the total carbon offsets?
SELECT program_name FROM carbon_offset_programs ORDER BY total_carbon_offsets DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), technology VARCHAR(255)); INSERT INTO project (id, project_name, location, technology) VALUES (1, 'Genome Editing', 'Boston, MA', 'CRISPR');
List genetic research projects in the US utilizing CRISPR technology.
SELECT project_name FROM project WHERE location LIKE '%USA%' AND technology = 'CRISPR';
gretelai_synthetic_text_to_sql
CREATE TABLE loans (id INT, customer_id INT, loan_type VARCHAR(20), amount DECIMAL(10, 2), state VARCHAR(2)); INSERT INTO loans (id, customer_id, loan_type, amount, state) VALUES (1, 101, 'Socially Responsible', 10000, 'New York'); CREATE TABLE customers (id INT, first_name VARCHAR(20), last_name VARCHAR(20), city VARCHAR(20)); INSERT INTO customers (id, first_name, last_name, city) VALUES (101, 'Fatima', 'Ahmed', 'New York');
Identify the top 3 cities with the most socially responsible loans disbursed, along with the total amount disbursed in each city.
SELECT customers.city, SUM(loans.amount) FROM loans INNER JOIN customers ON loans.customer_id = customers.id WHERE loans.loan_type = 'Socially Responsible' GROUP BY customers.city ORDER BY SUM(loans.amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE City (id INT, name VARCHAR(50)); INSERT INTO City (id, name) VALUES (1, 'New York'); INSERT INTO City (id, name) VALUES (2, 'Los Angeles'); INSERT INTO City (id, name) VALUES (3, 'Toronto'); INSERT INTO City (id, name) VALUES (4, 'London'); INSERT INTO City (id, name) VALUES (5, 'Tokyo'); CREATE TABLE Policy (id INT, name VARCHAR(50), city_id INT, category VARCHAR(50), budget DECIMAL(10,2), start_date DATE, end_date DATE); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (1, 'Education', 3, 'Education', 1200000, '2021-01-01', '2023-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (2, 'Healthcare', 3, 'Healthcare', 1500000, '2020-01-01', '2022-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (3, 'Transportation', 4, 'Transportation', 2000000, '2019-01-01', '2024-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (4, 'Education', 4, 'Education', 1800000, '2020-01-01', '2023-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (5, 'Transportation', 5, 'Transportation', 1000000, '2021-01-01', '2024-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (6, 'Transportation', 3, 'Transportation', 1700000, '2022-01-01', '2025-12-31');
What is the total budget allocated for transportation policies in 'Toronto'?
SELECT SUM(budget) FROM Policy WHERE city_id = 3 AND category = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id TEXT, chemical_composition TEXT); INSERT INTO products (product_id, chemical_composition) VALUES ('XYZ-123', 'ABC, DEF'), ('ABC-456', 'GHI, JKL');
Update the chemical composition of product XYZ-123 with the new formula.
UPDATE products SET chemical_composition = 'MNO, PQR' WHERE product_id = 'XYZ-123';
gretelai_synthetic_text_to_sql
CREATE TABLE Users (UserID INT, UsedEthicalAI BOOLEAN, UsedTech4Good BOOLEAN, UsedAccessibleTech BOOLEAN); INSERT INTO Users (UserID, UsedEthicalAI, UsedTech4Good, UsedAccessibleTech) VALUES (1, true, true, true), (2, false, false, false), (3, true, true, true);
What is the total number of users who have used ethical AI, technology for social good, and accessible technology?
SELECT COUNT(*) FROM Users WHERE UsedEthicalAI = true AND UsedTech4Good = true AND UsedAccessibleTech = true;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, total_assets DECIMAL(10,2)); CREATE TABLE investments (client_id INT, investment_type VARCHAR(20)); INSERT INTO clients VALUES (1,50000),(2,80000),(3,60000),(4,90000); INSERT INTO investments VALUES (1,'US Equities'),(2,'Bonds'),(3,'US Equities'),(5,'International Equities');
What is the total assets of clients who have not invested in any asset type?
SELECT SUM(clients.total_assets) FROM clients LEFT JOIN investments ON clients.client_id = investments.client_id WHERE investments.client_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (id INT, name TEXT, continent TEXT, size INT, practice TEXT); INSERT INTO farms (id, name, continent, size, practice) VALUES (1, 'Smith Farm', 'Africa', 10, 'Agroecology'); INSERT INTO farms (id, name, continent, size, practice) VALUES (2, 'Jones Farm', 'Asia', 15, 'Agroecology'); INSERT INTO farms (id, name, continent, size, practice) VALUES (3, 'Brown Farm', 'South America', 20, 'Agroecology');
Find the average farm size for each continent where agroecology is practiced.
SELECT f.continent, AVG(f.size) FROM farms f WHERE f.practice = 'Agroecology' GROUP BY f.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT, Nationality TEXT); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Hokusai', 'Japan'); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (2, 'Takashi Murakami', 'Japan');
What are the names and IDs of all artists from Japan?
SELECT ArtistID, Name FROM Artists WHERE Nationality = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(20)); INSERT INTO employees (id, name, department) VALUES (1, 'Anna Smith', 'News'), (2, 'John Doe', 'News'), (3, 'Sara Connor', 'News'), (4, 'Mike Johnson', 'Sports'), (5, 'Emma White', 'Sports'), (6, 'Alex Brown', 'IT');
Show the number of employees in each department, sorted by the number of employees in descending order in the "employees" table.
SELECT department, COUNT(*) AS num_employees FROM employees GROUP BY department ORDER BY num_employees DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products (product_id, product_name, sales, certification) VALUES (1, 'Lipstick A', 6000, 'cruelty-free'), (2, 'Mascara B', 7000, 'not_certified'), (3, 'Foundation C', 8000, 'cruelty-free'); CREATE TABLE sourcing (product_id INT, country_code CHAR(2)); INSERT INTO sourcing (product_id, country_code) VALUES (1, 'IN'), (2, 'FR'), (3, 'AU'); CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(50)); INSERT INTO countries (country_code, country_name) VALUES ('IN', 'India'), ('US', 'United States');
Which cosmetic products sourced from the United States have sales above 6000 and are not certified cruelty-free?
SELECT products.product_name FROM products JOIN sourcing ON products.product_id = sourcing.product_id JOIN countries ON sourcing.country_code = countries.country_code WHERE products.sales > 6000 AND products.certification != 'cruelty-free' AND countries.country_name = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjectTimelines (id INT, project_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO DefenseProjectTimelines (id, project_name, start_date, end_date) VALUES (1, 'Project X', '2021-01-01', '2022-01-01'), (2, 'Project Y', '2021-02-01', '2023-02-01');
Insert new records into the DefenseProjectTimelines table
INSERT INTO DefenseProjectTimelines (id, project_name, start_date, end_date) VALUES (3, 'Project Z', '2022-03-01', '2024-03-01');
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists green_buildings; CREATE TABLE if not exists green_buildings.buildings (id INT, building_name VARCHAR, country VARCHAR, co2_emissions FLOAT); CREATE SCHEMA if not exists smart_cities; CREATE TABLE if not exists smart_cities.projects (id INT, project_name VARCHAR, location VARCHAR); INSERT INTO green_buildings.buildings (id, building_name, country, co2_emissions) VALUES (1, 'Green Building 1', 'USA', 100), (2, 'Green Building 2', 'Canada', 120); INSERT INTO smart_cities.projects (id, project_name, location) VALUES (1, 'Smart City 1', 'USA'), (2, 'Smart City 2', 'Germany');
What is the total number of green buildings and smart city projects in their respective schemas?
SELECT COUNT(*) FROM green_buildings.buildings UNION ALL SELECT COUNT(*) FROM smart_cities.projects;
gretelai_synthetic_text_to_sql
CREATE TABLE Mines (MineID INT, Location VARCHAR(30), LastInspection DATE); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (1, 'Peru', '2021-01-01'); INSERT INTO Mines (MineID, Location, LastInspection) VALUES (2, 'Brazil', '2021-04-01');
How many accidents occurred in the South American mines in the last quarter?
SELECT COUNT(*) FROM Mines WHERE Location LIKE 'South%' AND LastInspection >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE farm_data (farm_id INT, organic BOOLEAN);
Set the organic status to true for the farm with ID 305
UPDATE farm_data SET organic = true WHERE farm_id = 305;
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, user_id INT, vehicle_type VARCHAR(20), trip_distance FLOAT, trip_duration INT, departure_time TIMESTAMP, arrival_time TIMESTAMP, city VARCHAR(50));INSERT INTO trips (id, user_id, vehicle_type, trip_distance, trip_duration, departure_time, arrival_time, city) VALUES (4, 789, 'bus', 40.0, 60, '2022-01-04 14:00:00', '2022-01-04 15:00:00', 'Los Angeles');
What is the average trip distance and duration for each city?
SELECT city, AVG(trip_distance) as avg_distance, AVG(trip_duration) as avg_duration FROM trips GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (country VARCHAR(50), year INT, number_of_turbines INT); INSERT INTO wind_turbines (country, year, number_of_turbines) VALUES ('Germany', 2018, 28000), ('Germany', 2019, 29500), ('Germany', 2020, 31000), ('Germany', 2021, 32500);
How many wind turbines are installed in Germany as of 2020?
SELECT number_of_turbines FROM wind_turbines WHERE country = 'Germany' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, trip_duration_hours DECIMAL(5,2)); INSERT INTO public_transportation (trip_id, trip_start_time, trip_end_time, trip_duration_hours) VALUES (1, '2022-03-01 07:00:00', '2022-03-01 08:30:00', 1.5), (2, '2022-03-01 09:00:00', '2022-03-01 09:45:00', 0.75);
What is the maximum trip duration in hours for public transportation in Sydney?
SELECT MAX(trip_duration_hours) FROM public_transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name TEXT, impact_score FLOAT); INSERT INTO programs (program_id, program_name, impact_score) VALUES (1, 'Arts & Culture', 80.0), (2, 'Science & Technology', 85.0);
What was the average program impact score in H2 2023?
SELECT AVG(impact_score) as avg_impact_score FROM programs WHERE program_name IN ('Arts & Culture', 'Science & Technology') AND impact_score IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, name TEXT, location TEXT, area_ha FLOAT); INSERT INTO organic_farms (id, name, location, area_ha) VALUES (1, 'Farm A', 'Brazil', 3), (2, 'Farm B', 'Brazil', 4.5), (3, 'Farm C', 'Argentina', 2);
What is the total area (in hectares) of all organic farms in 'Brazil'?
SELECT SUM(area_ha) FROM organic_farms WHERE location = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name TEXT);CREATE TABLE emergencies (id INT, city_id INT, response_time INT);
What is the average response time for emergency calls in each city?
SELECT c.name, AVG(e.response_time) FROM cities c JOIN emergencies e ON c.id = e.city_id GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE SCHEMA FoodService;CREATE TABLE Sales (sales_id INT, menu_item_id INT, restaurant_id INT, quantity INT); INSERT INTO Sales (sales_id, menu_item_id, restaurant_id, quantity) VALUES (1, 1, 1, 50), (2, 2, 1, 30), (3, 3, 2, 40), (4, 4, 2, 60);
Which menu items were sold the most for each restaurant category?
SELECT restaurant_id, name, SUM(quantity) as total_sold FROM Sales JOIN MenuItems ON Sales.menu_item_id = MenuItems.menu_item_id GROUP BY restaurant_id, name ORDER BY total_sold DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE user_info (user_id INT, country VARCHAR(50)); INSERT INTO user_info (user_id, country) VALUES (1, 'USA'); INSERT INTO user_info (user_id, country) VALUES (2, 'Mexico'); INSERT INTO user_info (user_id, country) VALUES (3, 'Brazil');
How many users are from each country in the music streaming service?
SELECT country, COUNT(user_id) FROM user_info GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, community VARCHAR(50));
What is the average age of athletes in the "Athletes" table who are members of the underrepresented communities?
SELECT AVG(age) FROM athletes WHERE community IN ('LGBTQ+', 'Black', 'Indigenous', 'People of Color', 'Women');
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'GreenGoods', 'Consumer Goods', 88.5); INSERT INTO companies (id, name, sector, ESG_score) VALUES (2, 'EcoProducts', 'Consumer Goods', 87.0); INSERT INTO companies (id, name, sector, ESG_score) VALUES (3, 'SustainableBrand', 'Consumer Goods', 91.0);
List companies in the 'Consumer Goods' sector with ESG scores higher than 85.0.
SELECT * FROM companies WHERE sector = 'Consumer Goods' AND ESG_score > 85.0;
gretelai_synthetic_text_to_sql
CREATE TABLE agencies (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), budget DECIMAL(10, 2)); INSERT INTO agencies (id, name, type, budget) VALUES (1, 'Parks Department', 'Public Works', 500000.00), (2, 'Housing Department', 'Community Development', 750000.00);
Update the budget of the agency with id 1
UPDATE agencies SET budget = 550000.00 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date, IsFirstTimeDonor bit); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate, IsFirstTimeDonor) VALUES (1, 'Individual', 'USA', 5000, '2021-01-01', 1), (2, 'Organization', 'Canada', 7000, '2021-02-01', 0), (3, 'Individual', 'Mexico', 8000, '2021-03-01', 1);
What is the percentage of total donations made by first-time donors in 2021?
SELECT (SUM(CASE WHEN IsFirstTimeDonor = 1 THEN AmountDonated ELSE 0 END) / SUM(AmountDonated)) * 100 as Percentage FROM Donors WHERE YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_algorithms (algorithm_id INT, algorithm_name VARCHAR(255), safety_score FLOAT); INSERT INTO ai_algorithms (algorithm_id, algorithm_name, safety_score) VALUES (1, 'Algorithm A', 0.85), (2, 'Algorithm B', 0.92), (3, 'Algorithm C', 0.78);
What is the average safety score for each AI algorithm, ordered by the score in descending order?
SELECT AVG(safety_score) AS avg_safety_score, algorithm_name FROM ai_algorithms GROUP BY algorithm_name ORDER BY avg_safety_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE FloodResilience (id INT, project VARCHAR(20), region VARCHAR(20), cost FLOAT); INSERT INTO FloodResilience (id, project, region, cost) VALUES (1, 'FloodGate', 'South', 2000000.0), (2, 'Levee', 'South', 3000000.0), (3, 'FloodGate', 'South', 2500000.0);
What is the sum of all flood resilience investments in the South and their respective average costs?
SELECT project, SUM(cost) as total_cost FROM FloodResilience WHERE region = 'South' GROUP BY project;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, dob DATE, branch TEXT, state TEXT);CREATE TABLE accounts (account_id INT, client_id INT, account_type TEXT, balance DECIMAL);INSERT INTO clients VALUES (2, 'Jane Smith', '1990-01-10', 'Los Angeles', 'California');INSERT INTO accounts VALUES (102, 2, 'Checking', 5000);
What is the average account balance for clients living in California?
SELECT AVG(accounts.balance) FROM clients INNER JOIN accounts ON clients.client_id = accounts.client_id WHERE clients.state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Hiring (HireID INT, HireDate DATE); INSERT INTO Hiring (HireID, HireDate) VALUES (1, '2020-01-01'), (2, '2019-12-31'), (3, '2020-06-15'), (4, '2018-09-01');
How many employees were hired in Q1 2020?
SELECT COUNT(*) FROM Hiring WHERE HireDate BETWEEN '2020-01-01' AND '2020-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT, name VARCHAR(100), city VARCHAR(50), public BOOLEAN); INSERT INTO schools (id, name, city, public) VALUES (1, 'School 1', 'New York City', true); INSERT INTO schools (id, name, city, public) VALUES (2, 'School 2', 'New York City', false);
How many public schools are there in New York City?
SELECT COUNT(*) FROM schools WHERE city = 'New York City' AND public = true;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount INT); CREATE TABLE donors (id INT, name VARCHAR(30), cause_area VARCHAR(20)); INSERT INTO donors (id, name, cause_area) VALUES (1, 'Bob', 'disaster relief'), (2, 'Alice', 'housing'), (3, 'Charlie', 'education'); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 500), (2, 1, 500), (3, 2, 700);
Delete all records of donations made by volunteers with the name 'Bob'.
DELETE FROM donations WHERE donor_id IN (SELECT id FROM donors WHERE name = 'Bob');
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_training (id INT PRIMARY KEY, teacher_id INT, training_type VARCHAR(255), completed_date DATE);
Insert records for 2 teachers in the teacher_training table
INSERT INTO teacher_training (id, teacher_id, training_type, completed_date) VALUES (1, 201, 'Online Course', '2021-01-15'), (2, 202, 'Workshop', '2021-02-12');
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, artist VARCHAR(100), city VARCHAR(100), tickets_sold INT);
What is the average number of concert tickets sold per concert for concerts held in 'Paris'?
SELECT AVG(tickets_sold) FROM Concerts WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (org_id INT, org_name TEXT, org_location TEXT);
Update the org_location of 'Habitat for Humanity' to 'San Francisco' in the 'Organizations' table
UPDATE Organizations SET org_location = 'San Francisco' WHERE org_name = 'Habitat for Humanity';
gretelai_synthetic_text_to_sql
CREATE TABLE sea_cucumber_farms (id INT, name TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO sea_cucumber_farms (id, name, country, latitude, longitude) VALUES (1, 'Farm K', 'Philippines', 9.123456, 124.123456); INSERT INTO sea_cucumber_farms (id, name, country, latitude, longitude) VALUES (2, 'Farm L', 'Philippines', 10.123456, 125.123456); CREATE TABLE sea_cucumber_harvest_data (id INT, farm_id INT, timestamp TIMESTAMP, quantity INT); INSERT INTO sea_cucumber_harvest_data (id, farm_id, timestamp, quantity) VALUES (1, 1, '2022-05-01 00:00:00', 300); INSERT INTO sea_cucumber_harvest_data (id, farm_id, timestamp, quantity) VALUES (2, 1, '2022-05-02 00:00:00', 400); INSERT INTO sea_cucumber_harvest_data (id, farm_id, timestamp, quantity) VALUES (3, 2, '2022-05-01 00:00:00', 500); INSERT INTO sea_cucumber_harvest_data (id, farm_id, timestamp, quantity) VALUES (4, 2, '2022-05-02 00:00:00', 600);
How many sea cucumbers were harvested from each farm in the Philippines in the last month?
SELECT schd.farm_id, sf.name, SUM(schd.quantity) FROM sea_cucumber_harvest_data schd JOIN sea_cucumber_farms sf ON schd.farm_id = sf.id WHERE sf.country = 'Philippines' AND schd.timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY schd.farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensors (id INT, manufacturer VARCHAR(50), model VARCHAR(50), price FLOAT, quantity INT, date DATE);
Find the average biosensor price for a given manufacturer.
SELECT AVG(price) FROM biosensors WHERE manufacturer = 'Example Inc.' AND quantity > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE route_schedule (route_id INT, departure_time TIMESTAMP);
What is the earliest and latest departure time for each route, based on the 'route_schedule' table?
SELECT route_id, MIN(departure_time) as earliest_departure, MAX(departure_time) as latest_departure FROM route_schedule GROUP BY route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Student (StudentID INT, District VARCHAR(20)); INSERT INTO Student (StudentID, District) VALUES (1, 'OpenSchool'); INSERT INTO Student (StudentID, District) VALUES (2, 'ClosedSchool'); CREATE TABLE MentalHealth (StudentID INT, Issue DATE); INSERT INTO MentalHealth (StudentID, Issue) VALUES (1, '2020-01-01'); INSERT INTO MentalHealth (StudentID, Issue) VALUES (2, '2019-01-01');
Delete the record of the student with ID 3 from 'Student' table, if such a record exists.
DELETE FROM Student WHERE StudentID = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Support_Services (Student_ID INT, Student_Name TEXT, Service_Type TEXT, Disability_Type TEXT); INSERT INTO Support_Services (Student_ID, Student_Name, Service_Type, Disability_Type) VALUES (4, 'Olivia Lee', 'Tutoring', 'Visual Impairment'), (5, 'Lucas Kim', 'Tutoring', 'ADHD'), (6, 'Sophia Patel', 'Note Taking', 'Dyslexia');
How many students with visual impairments received tutoring support?
SELECT COUNT(*) FROM Support_Services WHERE Service_Type = 'Tutoring' AND Disability_Type = 'Visual Impairment';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_name TEXT, state TEXT, num_concerts INTEGER); INSERT INTO Artists (artist_name, state, num_concerts) VALUES ('Artist A', 'New York', 300), ('Artist B', 'New York', 400), ('Artist A', 'California', 500), ('Artist C', 'Texas', 200), ('Artist C', 'Florida', 600), ('Artist D', 'New York', 250), ('Artist D', 'California', 250), ('Artist D', 'Texas', 250);
What are the names of the artists who have performed in at least 3 different states and the total number of concerts they have held in these states?
SELECT artist_name, SUM(num_concerts) as total_concerts FROM Artists WHERE state IN ('New York', 'California', 'Texas', 'Florida') GROUP BY artist_name HAVING COUNT(DISTINCT state) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), continent VARCHAR(50), amount_spent DECIMAL(10,2)); INSERT INTO rural_infrastructure VALUES (1, 'Road Construction', 'Africa', 50000.00), (2, 'Bridge Building', 'Asia', 75000.00), (3, 'Water Supply', 'Europe', 60000.00), (4, 'Electricity Distribution', 'South America', 80000.00), (5, 'School Building', 'Oceania', 45000.00);
What is the average amount of money spent on rural infrastructure projects in the 'rural_infrastructure' table, partitioned by the continent and ordered by the average amount spent in ascending order?;
SELECT continent, AVG(amount_spent) as avg_amount_spent FROM rural_infrastructure GROUP BY continent ORDER BY avg_amount_spent ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (id INT, metric_name VARCHAR(255), score INT);
Update the 'health_equity_metrics' table and change the 'Score' to 85 where 'Metric_Name' is 'Racial Disparities'
UPDATE health_equity_metrics SET score = 85 WHERE metric_name = 'Racial Disparities';
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesign (GameID INT, Genre VARCHAR(10), Feature VARCHAR(20)); INSERT INTO GameDesign (GameID, Genre, Feature) VALUES (1, 'RPG', 'Character Customization'), (2, 'RPG', 'Storyline'), (3, 'Strategy', 'Resource Management'), (4, 'Strategy', 'Base Building');
What are the unique game design features found in RPG and strategy genres?
SELECT DISTINCT Genre, Feature FROM GameDesign WHERE Genre IN ('RPG', 'Strategy');
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock (species VARCHAR(50), dissolved_oxygen FLOAT); INSERT INTO fish_stock (species, dissolved_oxygen) VALUES ('Tilapia', 6.5), ('Tilapia', 8.0), ('Salmon', 7.5);
What is the minimum dissolved oxygen level for each species in the fish_stock table?
SELECT species, MIN(dissolved_oxygen) FROM fish_stock GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (id INT, country VARCHAR(255), innovation VARCHAR(255));
Show all military innovation records for 'Country D' except those related to 'Robotics'
SELECT * FROM military_innovation WHERE country = 'Country D' AND innovation != 'Robotics';
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (customer_id INT, month DATE, savings_balance DECIMAL(10,2));
Insert a new record into the financial_capability table for customer 1004 with a savings balance of 10000 in March 2022.
INSERT INTO financial_capability (customer_id, month, savings_balance) VALUES (1004, '2022-03-01', 10000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50), birth_date DATE, country VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name, birth_date, country) VALUES (1, 'Emily Carr', '1871-12-13', 'Canada'); CREATE TABLE Artworks (artwork_id INT, title VARCHAR(50), year_made INT, artist_id INT, price FLOAT); INSERT INTO Artworks (artwork_id, title, year_made, artist_id, price) VALUES (1, 'Totem Poles at Alert Bay', 1904, 1, 1500.0);
What is the minimum price of artworks created by Indigenous artists from Canada between 1950 and 2000?
SELECT MIN(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id WHERE Artists.country = 'Canada' AND Artists.artist_name = 'Emily Carr' AND Artworks.year_made BETWEEN 1950 AND 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), author_id INT, published_date DATE, country VARCHAR(50)); INSERT INTO news_articles (id, title, author_id, published_date, country) VALUES (1, 'News Article 1', 1, '2022-01-01', 'Canada'), (2, 'News Article 2', 2, '2022-01-02', 'USA'), (3, 'News Article 3', 3, '2023-02-15', 'United Kingdom'), (4, 'News Article 4', 4, '2022-05-23', 'Australia');
What is the total number of news articles published in the "news_articles" table by authors from the United Kingdom and Australia?
SELECT COUNT(*) FROM news_articles WHERE country IN ('United Kingdom', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE TroopDeployments (Id INT, Region VARCHAR(50), Troops INT, Operation VARCHAR(50), Date DATE); INSERT INTO TroopDeployments (Id, Region, Troops, Operation, Date) VALUES (1, 'Middle East', 1000, 'Operation1', '2021-01-01'); INSERT INTO TroopDeployments (Id, Region, Troops, Operation, Date) VALUES (2, 'Europe', 500, 'Operation2', '2021-02-15');
What is the maximum number of troops deployed for intelligence operations in each region?
SELECT MAX(Troops), Region FROM TroopDeployments GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, region VARCHAR(255), name VARCHAR(255), patient_capacity INT); INSERT INTO hospitals (id, region, name, patient_capacity) VALUES (1, 'Northeast', 'Hospital A', 100), (2, 'West', 'Hospital B', 150), (3, 'South', 'Hospital C', 120);
What is the average patient capacity for hospitals in each region, ordered by the average patient capacity?
SELECT region, AVG(patient_capacity) as avg_capacity FROM hospitals GROUP BY region ORDER BY avg_capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_source (id INT PRIMARY KEY, ingredient_id INT, supplier_id INT, source_country VARCHAR(100), quantity INT);CREATE TABLE ingredient (id INT PRIMARY KEY, name VARCHAR(100));CREATE TABLE product_ingredient (product_id INT, ingredient_id INT, FOREIGN KEY (product_id) REFERENCES product(id), FOREIGN KEY (ingredient_id) REFERENCES ingredient(id));
List the names of ingredients that are used in more than 5 products.
SELECT i.name FROM ingredient i JOIN product_ingredient pi ON i.id = pi.ingredient_id GROUP BY i.id HAVING COUNT(pi.product_id) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), location VARCHAR(255), production_figures DECIMAL(10,2)); INSERT INTO wells (well_id, well_name, location, production_figures) VALUES (1, 'Well A', 'North Sea', 12000.50), (2, 'Well B', 'North Sea', 15000.25), (3, 'Well C', 'Gulf of Mexico', 20000.00);
What were the average production figures for wells in the North Sea, grouped by quarter, for the years 2019 and 2020?
SELECT EXTRACT(QUARTER FROM date) AS quarter, AVG(production_figures) AS avg_production FROM wells WHERE location = 'North Sea' AND EXTRACT(YEAR FROM date) IN (2019, 2020) GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, year INT, country VARCHAR(50), investment DECIMAL(10,2)); INSERT INTO shariah_compliant_finance (id, year, country, investment) VALUES (1, 2020, 'Malaysia', 10000.00), (2, 2021, 'Malaysia', 12000.00), (3, 2020, 'Indonesia', 8000.00), (4, 2021, 'Indonesia', 9000.00);
What is the change in Shariah-compliant finance investments in Southeast Asia from 2020 to 2021?
SELECT LAG(investment, 1, 0) OVER (PARTITION BY country ORDER BY year) as prev_investment, investment, investment - LAG(investment, 1, 0) OVER (PARTITION BY country ORDER BY year) as change FROM shariah_compliant_finance WHERE year = 2021 AND country IN ('Malaysia', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Projects (id INT, name VARCHAR(100), state VARCHAR(50), type VARCHAR(50), cost FLOAT); INSERT INTO Infrastructure_Projects (id, name, state, type, cost) VALUES (1, 'Seawall Upgrade', 'California', 'Coastal Protection', 5000000); INSERT INTO Infrastructure_Projects (id, name, state, type, cost) VALUES (2, 'Road Repaving', 'California', 'Transportation', 2000000);
What is the maximum and minimum cost of resilience projects for each type?
SELECT type, MIN(cost), MAX(cost) FROM Infrastructure_Projects GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Adoption (Year INT, Country VARCHAR(255), Statistics FLOAT); INSERT INTO Adoption (Year, Country, Statistics) VALUES (2018, 'Japan', 120000), (2019, 'Japan', 150000), (2020, 'Japan', 200000);
List all electric vehicle adoption statistics for Japan, grouped by year.
SELECT Year, AVG(Statistics) FROM Adoption WHERE Country = 'Japan' GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE UnionInfo (UnionID INT, UnionName VARCHAR(50)); INSERT INTO UnionInfo (UnionID, UnionName) VALUES (1001, 'Retail Workers United'); INSERT INTO UnionInfo (UnionID, UnionName) VALUES (1002, 'Transport Workers Union'); CREATE TABLE CollectiveBargaining (CBAID INT, UnionID INT, AgreementDate DATE, ExpirationDate DATE); INSERT INTO CollectiveBargaining (CBAID, UnionID, AgreementDate, ExpirationDate) VALUES (1, 1001, '2018-01-01', '2021-12-31'); INSERT INTO CollectiveBargaining (CBAID, UnionID, AgreementDate, ExpirationDate) VALUES (2, 1002, '2019-06-15', '2022-06-14');
Examine the number of collective bargaining agreements per union, grouped by union and year
SELECT UnionID, YEAR(AgreementDate) as AgreementYear, COUNT(*) as CBACount FROM CollectiveBargaining GROUP BY UnionID, YEAR(AgreementDate);
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurant (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), city VARCHAR(255)); CREATE TABLE Inspection (id INT PRIMARY KEY, restaurant_id INT, date DATE, violation VARCHAR(255));
What are the names and types of restaurants in New York that have had a food safety violation in the last month?
SELECT r.name, r.type FROM Restaurant r INNER JOIN Inspection i ON r.id = i.restaurant_id WHERE r.city = 'New York' AND i.date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE agency_budgets (agency_id INT, fiscal_year INT, budget_amount INT);
Identify the federal agencies with the largest budget increases in the last 5 fiscal years.
SELECT agency_id, agency_name, ((MAX(budget_amount) - MIN(budget_amount)) * 100.0 / MIN(budget_amount)) AS budget_increase_percentage FROM agency_budgets JOIN agencies ON agency_budgets.agency_id = agencies.agency_id GROUP BY agency_id, agency_name ORDER BY budget_increase_percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (name VARCHAR(255), location VARCHAR(255), year_established INT, type VARCHAR(255)); INSERT INTO museums (name, location, year_established, type) VALUES ('Metropolitan Museum of Art', 'New York', 1870, 'Art'), ('British Museum', 'London', 1753, 'History'), ('Louvre Museum', 'Paris', 1793, 'Art'); CREATE TABLE attendance (museum_name VARCHAR(255), year INT, total_visitors INT); INSERT INTO attendance (museum_name, year, total_visitors) VALUES ('Metropolitan Museum of Art', 2020, 636761), ('British Museum', 2020, 580632), ('Louvre Museum', 2020, 2879000);
Which museums had the highest attendance in the year 2020?
SELECT museum_name, total_visitors FROM attendance WHERE year = 2020 ORDER BY total_visitors DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (ID INT PRIMARY KEY, RestingHeartRate INT); CREATE TABLE Workouts (ID INT PRIMARY KEY, UserID INT, HeartRate INT, Date DATE);
What is the maximum heart rate recorded during a workout for each user in the past year, and what is the difference between the maximum and resting heart rate for each user?
SELECT Users.Name, MAX(Workouts.HeartRate) AS MaxHeartRate, Users.RestingHeartRate, MAX(Workouts.HeartRate) - Users.RestingHeartRate AS HeartRateDifference FROM Users JOIN Workouts ON Users.ID = Workouts.UserID WHERE Workouts.Date >= DATEADD(year, -1, GETDATE()) GROUP BY Users.Name, Users.RestingHeartRate;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_stats (destination VARCHAR(20), visit_year INT); INSERT INTO visitor_stats (destination, visit_year) VALUES ('Egypt', 2019), ('Egypt', 2019), ('Egypt', 2020), ('Egypt', 2020), ('Egypt', 2021), ('Egypt', 2021), ('Egypt', 2021);
What is the total number of tourists who visited Egypt in 2019, 2020, and 2021?
SELECT SUM(visits) FROM (SELECT COUNT(*) AS visits FROM visitor_stats WHERE destination = 'Egypt' AND visit_year = 2019 UNION ALL SELECT COUNT(*) FROM visitor_stats WHERE destination = 'Egypt' AND visit_year = 2020 UNION ALL SELECT COUNT(*) FROM visitor_stats WHERE destination = 'Egypt' AND visit_year = 2021) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Farmers (id INT, name VARCHAR(50), Organic_Produce_id INT); INSERT INTO Sustainable_Farmers (id, name, Organic_Produce_id) VALUES (1, 'Green Acres', 3), (2, 'Sunny Meadows', 4);
List all suppliers from Sustainable_Farmers table who supply at least one item with more than 200 calories?
SELECT s.name FROM Sustainable_Farmers s JOIN Organic_Produce o ON s.Organic_Produce_id = o.id WHERE o.calories > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(50), gender VARCHAR(6)); INSERT INTO Artists (id, name, gender) VALUES (1, 'Brancusi', 'male'), (2, 'Moore', 'female'), (3, 'Rodin', 'male'), (4, 'Noguchi', 'female'); CREATE TABLE Sculptures (id INT, artist_id INT, price DECIMAL(5,2)); INSERT INTO Sculptures (id, artist_id, price) VALUES (1, 1, 20.50), (2, 2, 30.00), (3, 1, 25.00), (4, 4, 40.00);
Who are the top 3 female artists with the highest average sculpture price?
SELECT Artists.name, AVG(Sculptures.price) as avg_price FROM Artists JOIN Sculptures ON Artists.id = Sculptures.artist_id WHERE Artists.gender = 'female' GROUP BY Artists.name ORDER BY avg_price DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (id INTEGER, algorithm TEXT, bias_level TEXT, risk_score INTEGER, last_updated TIMESTAMP);
Calculate the minimum risk_score for records in the algorithmic_fairness table where the bias_level is 'low'
SELECT MIN(risk_score) FROM algorithmic_fairness WHERE bias_level = 'low';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationDate, DonationAmount) VALUES (1, '2022-03-22', 100.00), (2, '2022-03-23', 200.00), (3, '2022-03-24', 150.00);
What is the average donation per day for the current month?
SELECT AVG(DonationAmount) as AvgDonationPerDay FROM Donations WHERE DonationDate >= DATE_TRUNC('month', CURRENT_DATE) AND DonationDate < DATE_TRUNC('month', CURRENT_DATE + INTERVAL '1 month');
gretelai_synthetic_text_to_sql
CREATE TABLE Country (ID INT, Name VARCHAR(50)); INSERT INTO Country (ID, Name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil'), (5, 'Argentina'); CREATE TABLE Mission (ID INT, CountryID INT, Type VARCHAR(50), Year INT); INSERT INTO Mission (ID, CountryID, Type, Year) VALUES (1, 1, 'Peacekeeping', 2010), (2, 1, 'Peacekeeping', 2012), (3, 2, 'Peacekeeping', 2015), (4, 3, 'Peacekeeping', 2018), (5, 4, 'Peacekeeping', 2010), (6, 4, 'Peacekeeping', 2012), (7, 4, 'Peacekeeping', 2014), (8, 5, 'Peacekeeping', 2019), (9, 5, 'Peacekeeping', 2020);
Which countries have participated in more than two peacekeeping operations?
SELECT Country.Name FROM Country JOIN Mission ON Country.ID = Mission.CountryID WHERE Mission.Type = 'Peacekeeping' GROUP BY Country.Name HAVING COUNT(*) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Crops (name VARCHAR(50), farming_scale VARCHAR(50)); INSERT INTO Crops (name, farming_scale) VALUES ('Rice', 'Small-scale'), ('Cotton', 'Large-scale'), ('Potatoes', 'Small-scale');
Identify crops that are present in both small-scale and large-scale farming methods.
SELECT name FROM Crops WHERE farming_scale IN ('Small-scale', 'Large-scale') GROUP BY name HAVING COUNT(DISTINCT farming_scale) = 2
gretelai_synthetic_text_to_sql
CREATE TABLE student (id INT, name VARCHAR(255), department_id INT, ethnicity VARCHAR(255)); CREATE TABLE department (id INT, name VARCHAR(255), college VARCHAR(255));
What is the distribution of graduate students by ethnicity in each department of the College of Engineering?
SELECT d.name, s.ethnicity, COUNT(s.id) as count FROM student s JOIN department d ON s.department_id = d.id WHERE d.college = 'College of Engineering' GROUP BY d.name, s.ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (id INT, state VARCHAR(20), year INT, number_of_accidents INT); INSERT INTO accidents (id, state, year, number_of_accidents) VALUES (1, 'Texas', 2021, 1500), (2, 'Texas', 2022, 1650), (3, 'California', 2021, 1200);
How many traffic accidents occurred in the state of Texas during 2021 and 2022?
SELECT SUM(number_of_accidents) FROM accidents WHERE state = 'Texas' AND year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE labor_productivity (site_id INT, date DATE, workers_on_site INT, total_production FLOAT); INSERT INTO labor_productivity (site_id, date, workers_on_site, total_production) VALUES (1, '2021-01-01', 200, 5000), (1, '2021-01-02', 210, 5150), (2, '2021-01-01', 150, 3000), (2, '2021-01-02', 160, 3200), (5, '2021-01-01', 250, 6000), (5, '2021-01-02', 255, 6150);
Which sites have experienced a daily production increase between January 1st and January 2nd, 2021?
SELECT site_id, (tp2 - tp1) as production_increase FROM (SELECT site_id, total_production as tp1, lead(total_production) OVER (PARTITION BY site_id ORDER BY date) as tp2 FROM labor_productivity WHERE date IN ('2021-01-01', '2021-01-02')) tmp WHERE tp1 < tp2;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_id INT, cause VARCHAR(255), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, donor_id, cause, amount, donation_date) VALUES (1, 1001, 'Education', 5000, '2022-01-05'), (2, 1002, 'Health', 3000, '2022-03-15'), (3, 1003, 'Environment', 7000, '2022-01-30');
What is the total donation amount per cause in Q1 2022?
SELECT cause, SUM(amount) as total_donation FROM Donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY cause;
gretelai_synthetic_text_to_sql
CREATE TABLE Institutions (InstitutionID int, Name varchar(50), Type varchar(50), Location varchar(50), SustainableAgriculture bit); INSERT INTO Institutions (InstitutionID, Name, Type, Location, SustainableAgriculture) VALUES (1, 'Institution A', 'Microfinance', 'Southeast Asia', 1); CREATE TABLE Revenue (RevenueID int, InstitutionID int, Amount decimal(10,2)); INSERT INTO Revenue (RevenueID, InstitutionID, Amount) VALUES (1, 1, 1000000.00);
What is the total revenue of microfinance institutions in Southeast Asia that focus on sustainable agriculture?
SELECT SUM(R.Amount) FROM Revenue R INNER JOIN Institutions I ON R.InstitutionID = I.InstitutionID WHERE I.Type = 'Microfinance' AND I.Location = 'Southeast Asia' AND I.SustainableAgriculture = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, age INT, gender TEXT, state TEXT); INSERT INTO policyholders (id, name, age, gender, state) VALUES (1, 'John Doe', 36, 'Male', 'New York'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (2, 'Jane Smith', 42, 'Female', 'New York');
Update the gender of policyholder with id 1 to 'Female'.
UPDATE policyholders SET gender = 'Female' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement_initiatives (id INT, initiative_name VARCHAR(100), budget INT, city VARCHAR(50)); INSERT INTO community_engagement_initiatives (id, initiative_name, budget, city) VALUES (1, 'Youth Arts Festival', 50000, 'New York'), (2, 'Elder Cultural Exchange', 30000, 'Los Angeles');
What is the total budget for community engagement initiatives by city?
SELECT city, SUM(budget) as total_budget FROM community_engagement_initiatives GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE players_vr (player_id INT, vr_headset TEXT); INSERT INTO players_vr VALUES (1, 'Oculus Rift'), (2, 'HTC Vive'), (3, 'Valve Index'); CREATE TABLE games (game_id INT, game_name TEXT, genre TEXT); INSERT INTO games VALUES (1, 'Game 1', 'Simulation'), (2, 'Game 2', 'Action'); CREATE TABLE player_games (player_id INT, game_id INT, playtime INT); INSERT INTO player_games VALUES (1, 1, 10), (1, 2, 5), (2, 1, 8), (3, 1, 12);
What is the average playtime for players who have played games in the Simulation genre and own a VR headset?
SELECT AVG(player_games.playtime) FROM player_games JOIN players_vr ON player_games.player_id = players_vr.player_id JOIN games ON player_games.game_id = games.game_id WHERE players_vr.vr_headset IS NOT NULL AND games.genre = 'Simulation';
gretelai_synthetic_text_to_sql
CREATE TABLE case_outcomes (case_id INT, outcome TEXT, precedent TEXT); CREATE TABLE case_assignments (case_id INT, attorney_id INT, PRIMARY KEY (case_id, attorney_id));
Display the total number of cases and their respective outcomes
SELECT COUNT(*) as total_cases, outcome, COUNT(*) as count FROM case_outcomes GROUP BY outcome;
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Certified_Buildings (Building_ID INT, City VARCHAR(50), Certification_Date DATE, Square_Footage INT);
What is the total square footage of green-certified buildings in New York City constructed before 2010?
SELECT SUM(Square_Footage) FROM Green_Certified_Buildings WHERE City = 'New York' AND Certification_Date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, client_id INT, state VARCHAR(2), outcome VARCHAR(10)); INSERT INTO cases (case_id, client_id, state, outcome) VALUES (1, 1, 'TX', 'Win'), (2, 2, 'TX', 'Loss'), (3, 3, 'TX', 'Win'), (4, 4, 'CA', 'Win'), (5, 5, 'CA', 'Loss');
What is the most common outcome for cases in Texas?
SELECT outcome, COUNT(*) AS count FROM cases WHERE state = 'TX' GROUP BY outcome ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Incidents (facility VARCHAR(20), year INT, incidents INT); INSERT INTO Incidents (facility, year, incidents) VALUES ('Western', 2021, 3), ('Western', 2022, 1);
How many safety incidents were reported at the Western facility in 2021?
SELECT incidents FROM Incidents WHERE facility = 'Western' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'), (2, 'Green Line'), (3, 'Blue Line'); CREATE TABLE fare (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), collection_date DATE); INSERT INTO fare (fare_id, route_id, fare_amount, collection_date) VALUES (1, 1, 3.50, '2022-06-01'), (2, 1, 3.25, '2022-06-01'), (3, 2, 3.50, '2022-06-01'), (4, 2, 3.25, '2022-06-01'), (5, 3, 3.50, '2022-06-01'), (6, 3, 3.25, '2022-06-01');
What is the total fare collected from each route on June 1st, 2022?
SELECT route_name, SUM(fare_amount) FROM route JOIN fare ON route.route_id = fare.route_id WHERE collection_date = '2022-06-01' GROUP BY route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), published_date DATE);
Insert a new record into the 'articles' table with the title 'Artificial Intelligence in Journalism'
INSERT INTO articles (title) VALUES ('Artificial Intelligence in Journalism');
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(50), category VARCHAR(50), quantity_sold INT, price DECIMAL(5,2), month_sold INT, is_vegetarian BOOLEAN); INSERT INTO menu (menu_id, menu_name, category, quantity_sold, price, month_sold, is_vegetarian) VALUES (5, 'Vegetable Stir Fry', 'Asian', 20, 8.49, 1, true), (6, 'Grilled Vegetable Sandwich', 'Sandwiches', 15, 6.99, 1, true);
How many vegetarian menu items are available?
SELECT COUNT(*) FROM menu WHERE is_vegetarian = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Disability_Accommodations (country VARCHAR(255), budget INT); INSERT INTO Disability_Accommodations (country, budget) VALUES ('United States', 3000000), ('Canada', 2500000), ('Mexico', 2000000), ('Brazil', 2200000), ('Germany', 3500000);
What is the maximum budget allocated for disability accommodations in each country?
SELECT country, MAX(budget) FROM Disability_Accommodations GROUP BY country;
gretelai_synthetic_text_to_sql