context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE city_budgets (city VARCHAR(255), sector VARCHAR(255), budget INT); INSERT INTO city_budgets
What is the total budget allocated for education in 'City A'?
SELECT SUM(budget) FROM city_budgets WHERE city = 'City A' AND sector = 'education'
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (id INT, city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), capacity INT);
Delete all records from the 'landfill_capacity' table where the 'city' is 'Mumbai'
DELETE FROM landfill_capacity WHERE city = 'Mumbai';
gretelai_synthetic_text_to_sql
CREATE TABLE Consumers (id INT, country VARCHAR, aware_of_fair_labor BOOLEAN);
How many consumers in each country are aware of fair labor practices?
SELECT country, COUNT(*) as num_consumers, 100.0 * SUM(aware_of_fair_labor) / COUNT(*) as percentage_aware FROM Consumers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE worker (id INT, name TEXT, role TEXT, mine_id INT, is_part_time BOOLEAN);
What is the total number of workers in each mine, including part-time and full-time employees?
SELECT mine.name, COUNT(worker.id) as total_workers FROM mine LEFT JOIN worker ON mine.id = worker.mine_id GROUP BY mine.name;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_supplies (id INT, country VARCHAR(255), name VARCHAR(255), quantity INT); INSERT INTO medical_supplies (id, country, name, quantity) VALUES (1, 'Palestine', 'Medical Supply 1', 10), (2, 'Palestine', 'Medical Supply 2', 20), (3, 'Palestine', 'Medical Supply 1', 30);
What is the total number of medical supplies sent to Palestine and how many unique types of medical supplies were sent?
SELECT country, SUM(quantity) FROM medical_supplies GROUP BY country; SELECT country, COUNT(DISTINCT name) FROM medical_supplies GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales(ticket_id INT, sport VARCHAR(10), city VARCHAR(20), tickets INT); INSERT INTO ticket_sales(ticket_id, sport, city, tickets) VALUES (1, 'football', 'New York', 1000), (2, 'basketball', 'Los Angeles', 800), (3, 'football', 'Chicago', 1500), (4, 'basketball', 'New York', 1100), (5, 'football', 'L...
List the top 3 cities with the most ticket sales for each sport.
SELECT sport, city, SUM(tickets) AS total_tickets FROM ticket_sales GROUP BY sport, city HAVING COUNT(*) > 1 ORDER BY sport, SUM(tickets) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue(date DATE, cuisine VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO restaurant_revenue VALUES ('2022-01-01', 'Italian', 1200.00), ('2022-01-01', 'Mexican', 1500.00), ('2022-01-02', 'Italian', 1700.00), ('2022-01-02', 'Mexican', 1300.00);
What was the total revenue for each cuisine type in the month of January 2022?
SELECT cuisine, SUM(revenue) FROM restaurant_revenue WHERE date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE Fish (id INT, name VARCHAR(255), species VARCHAR(255), length FLOAT, weight FLOAT, habitat VARCHAR(255), conservation_status VARCHAR(255));
What is the average length of endangered fish species in the Pacific Ocean?
SELECT AVG(length) as avg_length FROM Fish WHERE conservation_status = 'Endangered' AND habitat LIKE '%Pacific%';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_projects (name TEXT, capacity INTEGER); INSERT INTO energy_efficiency_projects (name, capacity) VALUES ('Project A', 200), ('Project B', 900);
What is the total capacity of energy efficiency projects?
SELECT SUM(capacity) FROM energy_efficiency_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_type TEXT, attendance INT, admission_cost DECIMAL(10, 2));
What is the total number of attendees for events with free admission, categorized by event type?
SELECT event_type, SUM(attendance) FROM events WHERE admission_cost = 0 GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Humanitarian_Assistance (Country VARCHAR(100), Quarter INT, Year INT);
Find the countries that received humanitarian assistance in the most quarters.
SELECT Country, COUNT(DISTINCT Quarter) AS Quarters_Received FROM Humanitarian_Assistance GROUP BY Country ORDER BY Quarters_Received DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE species (scientific_name TEXT, common_name TEXT, conservation_status TEXT); INSERT INTO species (scientific_name, common_name, conservation_status) VALUES ('Yetidracus profundis', 'Yeti Shark', 'Vulnerable');
Update the conservation status of 'Yetidracus profundis' to 'Endangered'
UPDATE species SET conservation_status = 'Endangered' WHERE scientific_name = 'Yetidracus profundis';
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_laws (id INT, law VARCHAR(50), region VARCHAR(50), speed_limit INT); INSERT INTO maritime_laws (id, law, region, speed_limit) VALUES (1, 'Shipping Speed Regulations', 'Mediterranean Sea', 15);
Show legal speed limits for ships in the Mediterranean Sea.
SELECT speed_limit FROM maritime_laws WHERE region = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, country VARCHAR(255)); CREATE TABLE sales (id INT, country_id INT, revenue DECIMAL(10,2), sale_date DATE); INSERT INTO countries VALUES (1, 'USA'); INSERT INTO sales VALUES (1, 1, 500, '2022-01-01');
What is the total revenue generated by each country in the last year?
SELECT c.country, SUM(s.revenue) as total_revenue FROM sales s JOIN countries c ON s.country_id = c.id WHERE s.sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (id INT PRIMARY KEY, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); CREATE VIEW LocalCustomers AS SELECT * FROM Customers WHERE state IN ('NY', 'NJ', 'PA');
Which are the top 3 cities with the most local customers?
SELECT l.city, COUNT(l.id) as customer_count FROM LocalCustomers l GROUP BY l.city ORDER BY customer_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, program_name TEXT); CREATE TABLE Program_Volunteers (program_id INT, volunteer_id INT, hours INT);
What is the total number of volunteer hours in each program?
SELECT p.program_name, SUM(hours) as total_hours FROM Programs p JOIN Program_Volunteers v ON p.id = v.program_id GROUP BY p.program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE products_info (product VARCHAR(255), has_spf BOOLEAN, customer_rating DECIMAL(2,1), customer_review TEXT); INSERT INTO products_info (product, has_spf, customer_rating, customer_review) VALUES ('Foundation with SPF 15', TRUE, 4.2, 'Great coverage and sun protection'), ('Foundation without SPF', FALSE, 3.8,...
Get the customer ratings and reviews for foundation products with SPF
SELECT customer_rating, customer_review FROM products_info WHERE product LIKE '%SPF%';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, release_year INT, rating FLOAT, country TEXT); INSERT INTO movies (id, title, release_year, rating, country) VALUES (1, 'Movie1', 2011, 7.5, 'USA'), (2, 'Movie2', 2009, 8.2, 'Canada');
What is the average rating of movies produced in the US and released after 2010?
SELECT AVG(rating) FROM movies WHERE release_year > 2010 AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE farmer_country (farmer_id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO farmer_country (farmer_id, name, age, country) VALUES (1, 'Juan', 60, 'Mexico');
What is the maximum age of farmers in each country in the 'rural_development' database?
SELECT country, MAX(age) FROM farmer_country GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE indian_ocean_protected_areas (id INT, name TEXT, species_count INT); INSERT INTO indian_ocean_protected_areas (id, name, species_count) VALUES (1, 'Chagos Marine Park', 220), (2, 'Maldives Marine Protected Areas', 150), (3, 'Seychelles Marine Parks', 250);
What is the maximum number of marine species found in any marine protected area in the Indian Ocean?
SELECT MAX(species_count) FROM indian_ocean_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE underrepresented_countries (company_name VARCHAR(100), founder_country VARCHAR(50), founding_year INT, funding_amount INT);
Find the average funding amount for startups founded by individuals from underrepresented countries
SELECT AVG(funding_amount) FROM underrepresented_countries;
gretelai_synthetic_text_to_sql
CREATE TABLE strategies (id INT, name TEXT, region TEXT, investment FLOAT); INSERT INTO strategies (id, name, region, investment) VALUES (1, 'Microfinance', 'Southeast Asia', 50000.0), (2, 'Renewable Energy', 'Southeast Asia', 100000.0);
What is the average investment per strategy in the Southeast Asian region?
SELECT AVG(investment) FROM strategies WHERE region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_development (teacher_id INT, course_date DATE, subject_area VARCHAR(255)); INSERT INTO teacher_development (teacher_id, course_date, subject_area) VALUES (1, '2022-01-01', 'Math'), (2, '2022-02-15', 'Science'), (3, '2021-12-30', 'English'), (4, '2022-06-05', 'Math'), (5, '2021-11-01', 'Science');
Identify the number of teachers who have completed professional development courses in the last year, broken down by subject area.
SELECT subject_area, COUNT(*) FROM teacher_development WHERE course_date >= DATEADD(year, -1, GETDATE()) GROUP BY subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), region VARCHAR(50)); CREATE TABLE diseases (id INT, patient_id INT, name VARCHAR(50), diagnosis_date DATE, severity INT); INSERT INTO patients (id, name, age, gender, region) VALUES (1, 'James Smith', 65, 'Male', 'Rural Georgia'); INSERT INTO...
List the names of patients from rural Georgia who were diagnosed with a disease in 2019 and are above 40 years old.
SELECT patients.name FROM patients INNER JOIN diseases ON patients.id = diseases.patient_id WHERE patients.region = 'Rural Georgia' AND diseases.diagnosis_date BETWEEN '2019-01-01' AND '2019-12-31' AND patients.age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50), birth_date DATE, gender VARCHAR(50), country VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name, birth_date, gender, country) VALUES (1, 'Yayoi Kusama', '1929-03-22', 'Female', 'Japan'); CREATE TABLE Artworks (artwork_id INT, title VARCHAR(50), year_m...
How many artworks were created by female Japanese artists between 1920 and 1940?
SELECT COUNT(*) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id WHERE Artists.country = 'Japan' AND Artists.gender = 'Female' AND Artworks.year_made BETWEEN 1920 AND 1940;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, TotalDonations DECIMAL(10,2)); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2));
What is the total amount donated by each donor in the year 2020, sorted by the total donation amount in descending order?
SELECT D.DonorName, SUM(D.DonationAmount) as TotalDonations FROM Donations D JOIN Donors DON ON D.DonorID = DON.DonorID WHERE YEAR(D.DonationDate) = 2020 GROUP BY D.DonorName ORDER BY TotalDonations DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT); CREATE TABLE Menu (menu_id INT, item_name TEXT, price DECIMAL, restaurant_id INT, FOREIGN KEY (restaurant_id) REFERENCES Restaurants(restaurant_id)); INSERT INTO Restaurants (restaurant_id) VALUES (1),(2),(3); INSERT INTO Menu (menu_id, item_name, price, restaurant_id) VALU...
What are the top 3 menu items by revenue across all restaurants?
SELECT item_name, SUM(price) as total_revenue FROM Menu GROUP BY item_name ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), Country varchar(50)); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'USA'), (4, 'David', 'Mexico'), (5, 'Eva', 'USA'), (6, 'Frank', 'Brazil');
Which countries have more than 50 volunteers in the 'Volunteers' table?
SELECT Country, COUNT(*) as TotalVolunteers FROM Volunteers GROUP BY Country HAVING COUNT(*) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy_Projects (id INT, country VARCHAR(20), installed_capacity FLOAT); INSERT INTO Renewable_Energy_Projects (id, country, installed_capacity) VALUES (1, 'US', 1200.5), (2, 'Canada', 1500.2), (3, 'Mexico', 900.1);
What is the maximum installed capacity of a single renewable energy project?
SELECT MAX(installed_capacity) FROM Renewable_Energy_Projects;
gretelai_synthetic_text_to_sql
CREATE TABLE network_outages (outage_id INT, outage_date DATE, country VARCHAR(50), outage_duration DECIMAL(5,2));
What is the total number of network outages in each country over the past month?
SELECT country, SUM(outage_duration) as total_outage_duration FROM network_outages WHERE MONTH(outage_date) = MONTH(current_date) - 1 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (StreamID int, ArtistName varchar(100), Platform varchar(50), StreamsDate date, NumberOfStreams int); INSERT INTO Streams VALUES (1, 'Artist V', 'Spotify', '2022-01-01', 1500); INSERT INTO Streams VALUES (2, 'Artist W', 'Spotify', '2022-02-01', 1800); INSERT INTO Streams VALUES (3, 'Artist X', 'Spo...
What is the total number of streams for French artists on Spotify in 2022?
SELECT SUM(NumberOfStreams) as TotalStreams FROM Streams WHERE Platform = 'Spotify' AND Country = 'France' AND YEAR(StreamsDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (id INT, artist VARCHAR(50), country VARCHAR(50), streams INT); INSERT INTO streams (id, artist, country, streams) VALUES (1, 'Drake', 'USA', 10000000); INSERT INTO streams (id, artist, country, streams) VALUES (2, 'Taylor Swift', 'Canada', 8000000); INSERT INTO streams (id, artist, country, stream...
List all artists who have never streamed music in the United States.
SELECT DISTINCT artist FROM streams WHERE artist NOT IN (SELECT artist FROM streams WHERE country = 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationAmount FLOAT, Organization VARCHAR(50)); INSERT INTO Donations (DonationID, DonationAmount, Organization) VALUES (1, 1000000.00, 'Gates Foundation'), (2, 500000.00, 'African Charity');
Which organization received the largest donation in Africa?
SELECT Organization, MAX(DonationAmount) FROM Donations WHERE Country = 'Africa' GROUP BY Organization;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (vendorID INT, vendorName VARCHAR(50), country VARCHAR(50), ethicalPractice BOOLEAN); CREATE TABLE Products (productID INT, vendorID INT, productName VARCHAR(50), price DECIMAL(10,2));
List of vendors with ethical labor practices in South America and their average product price.
SELECT V.vendorName, AVG(P.price) FROM Vendors V INNER JOIN Products P ON V.vendorID = P.vendorID WHERE V.country = 'South America' AND V.ethicalPractice = TRUE GROUP BY V.vendorName;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_prices (menu_item VARCHAR(255), price DECIMAL(10, 2), restaurant_name VARCHAR(255)); INSERT INTO menu_prices (menu_item, price, restaurant_name) VALUES ('Curry', 16.99, 'Indian Bistro'), ('Samosa', 5.99, 'Indian Bistro'), ('Naan', 3.99, 'Indian Bistro');
List the menu items and their prices from 'Indian Bistro'
SELECT menu_item, price FROM menu_prices WHERE restaurant_name = 'Indian Bistro';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, customer_id INT, amount FLOAT); INSERT INTO investments (id, customer_id, amount) VALUES (1, 1, 10000), (2, 2, 15000), (3, 3, 8000), (4, 1, 12000); CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO customers (id, name, region) VALUES (1, 'John Smith', '...
What is the maximum investment amount for customers in the East region?
SELECT MAX(amount) FROM investments JOIN customers ON investments.customer_id = customers.id WHERE customers.region = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE crop (id INT, variety VARCHAR(255), farm_id INT);CREATE TABLE fertilization (id INT, crop_id INT, method VARCHAR(255), fertilization_date DATE);
Find the number of times a specific fertilization method has been used for each crop variety in the past 6 months
SELECT method, variety, COUNT(*) FROM fertilization JOIN crop ON fertilization.crop_id = crop.id WHERE fertilization_date >= DATEADD(month, -6, GETDATE()) AND method = 'Drip' GROUP BY method, variety;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(255), job_category VARCHAR(255), salary DECIMAL(10,2), ethnicity VARCHAR(255)); INSERT INTO employees (id, name, job_category, salary, ethnicity) VALUES (1, 'Juan Gonzalez', 'Software Engineer', 90000.00, 'Hispanic'), (2, 'María Rodríguez', 'Product Manager', 120000.00, 'Lat...
What is the average salary by job category for employees who identify as Latinx or Hispanic?
SELECT ethnicity, job_category, AVG(salary) as avg_salary FROM employees WHERE ethnicity = 'Hispanic' OR ethnicity = 'Latino' GROUP BY ethnicity, job_category;
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_tracking (id INT, county TEXT, cases INT); INSERT INTO infectious_disease_tracking (id, county, cases) VALUES (1, 'Los Angeles County', 100), (2, 'Orange County', 50);
What is the maximum number of infectious disease cases reported in a single county?
SELECT MAX(cases) FROM infectious_disease_tracking;
gretelai_synthetic_text_to_sql
CREATE TABLE Creative_AI (app_name TEXT, safety_score INT); INSERT INTO Creative_AI (app_name, safety_score) VALUES ('AI Painter', 70), ('AI Poet', 80), ('AI Music Composer', 75);
Which creative AI applications have a lower safety score than the average safety score for all creative AI applications?
SELECT app_name FROM Creative_AI WHERE safety_score < (SELECT AVG(safety_score) FROM Creative_AI);
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, cuisine TEXT, revenue FLOAT); INSERT INTO restaurants (id, name, cuisine, revenue) VALUES (1, 'Restaurant A', 'asian', 40000.00), (2, 'Restaurant B', 'italian', 50000.00), (3, 'Restaurant C', 'asian', 35000.00), (4, 'Restaurant D', 'italian', 60000.00), (5, 'Restaurant E', '...
What is the average revenue of restaurants in each cuisine type?
SELECT cuisine, AVG(revenue) FROM restaurants GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, release_year INT, director TEXT); INSERT INTO movies (id, title, release_year, director) VALUES (1, 'MovieA', 2010, 'Director1'), (2, 'MovieB', 2015, 'Director2'); CREATE TABLE directors (id INT, name TEXT, country TEXT); INSERT INTO directors (id, name, country) VALUES (1, 'Dir...
How many movies were released each year by directors from European countries?
SELECT release_year, COUNT(*) as count FROM movies INNER JOIN directors ON movies.director = directors.name WHERE directors.country IN ('France', 'Germany', 'Italy', 'Spain', 'UK') GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (flight_number VARCHAR(50) PRIMARY KEY, safety_rating VARCHAR(20), last_inspection_date DATE);
Insert a new record into the flight_safety table with the following data: flight_number = 'FL123', safety_rating = 'excellent', last_inspection_date = '2020-05-01'
INSERT INTO flight_safety (flight_number, safety_rating, last_inspection_date) VALUES ('FL123', 'excellent', '2020-05-01');
gretelai_synthetic_text_to_sql
CREATE TABLE datasets (dataset_id INT, name VARCHAR(50), fair INT, accuracy FLOAT); INSERT INTO datasets (dataset_id, name, fair, accuracy) VALUES (1, 'FairDataset1', 1, 0.85), (2, 'FairDataset2', 1, 0.92), (3, 'BiasedDataset1', 0, 0.78), (4, 'BiasedDataset2', 0, 0.72);
What is the average accuracy of models trained on fair datasets?
SELECT AVG(accuracy) FROM datasets WHERE fair = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE policy (policy_id INT, policy_holder VARCHAR(50), coverage_amount INT);
Insert new policy records for 'Bob Brown' with a coverage amount of 500000
INSERT INTO policy (policy_id, policy_holder, coverage_amount) SELECT NULL, 'Bob Brown', 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (id INT, product_id INT, size VARCHAR(10), quantity INT, source_continent VARCHAR(50)); INSERT INTO Inventory (id, product_id, size, quantity, source_continent) VALUES (1, 1, '2XL', 25, 'South America'), (2, 2, 'XS', 50, 'Africa');
What is the total quantity of unsold size 2XL and XL clothing items in the 'Inventory' table, for items sourced from South America?
SELECT SUM(quantity) FROM Inventory WHERE size IN ('2XL', 'XL') AND source_continent = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_threats (id INT, species_name VARCHAR(50), threat VARCHAR(50), year INT); INSERT INTO marine_species_threats (id, species_name, threat, year) VALUES (1, 'Bluefin Tuna', 'Overfishing', 2020); INSERT INTO marine_species_threats (id, species_name, threat, year) VALUES (2, 'Orange Roughy', 'Over...
What marine species were threatened by overfishing in 2020?
SELECT species_name FROM marine_species_threats WHERE threat = 'Overfishing' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE SCHEMA engineering; CREATE TABLE engineering.budget (id INT, item VARCHAR(100), country VARCHAR(50), budget FLOAT); INSERT INTO engineering.budget (id, item, country, budget) VALUES (1, 'Bioprocess Engineering', 'Japan', 6000000.00); INSERT INTO engineering.budget (id, item, country, budget) VALUES (2, 'Automati...
What is the minimum budget for bioprocess engineering in Japan?
SELECT MIN(budget) FROM engineering.budget WHERE item = 'Bioprocess Engineering' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(255), attendees INT); INSERT INTO Events (event_id, event_name, attendees) VALUES (1, 'Music Festival', 800), (2, 'Art Exhibition', 500), (3, 'Theater Performance', 300); CREATE TABLE Attendee_Demographics (attendee_id INT, attendee_race VARCHAR(255), event_id INT);...
Which cultural programs had the most diverse attendance in 2022?
SELECT E.event_name, COUNT(DISTINCT AD.attendee_race) as num_races FROM Events E JOIN Attendee_Demographics AD ON E.event_id = AD.event_id JOIN Event_Dates ED ON E.event_id = ED.event_id WHERE YEAR(ED.event_date) = 2022 GROUP BY E.event_name ORDER BY num_races DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE train_dates (model_name TEXT, train_year INTEGER); INSERT INTO train_dates (model_name, train_year) VALUES ('model1', 2018), ('model2', 2019), ('model3', 2021), ('model4', 2017);
How many explainable AI models were trained before 2020?
SELECT COUNT(*) FROM train_dates WHERE train_year < 2020 AND model_name IN (SELECT model_name FROM explainable_ai);
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, division VARCHAR(20), total_cost FLOAT); INSERT INTO Projects (id, division, total_cost) VALUES (1, 'water', 500000), (2, 'transportation', 300000), (3, 'water', 750000);
What is the maximum total cost of projects in the water division?
SELECT MAX(total_cost) FROM Projects WHERE division = 'water';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects_2 (project_id INT, project_name TEXT, country TEXT, technology TEXT); INSERT INTO renewable_projects_2 (project_id, project_name, country, technology) VALUES (1, 'Solar Farm 1', 'Australia', 'Solar'), (2, 'Wind Farm 2', 'Australia', 'Wind');
What is the total number of renewable energy projects in Australia?
SELECT COUNT(*) FROM renewable_projects_2 WHERE country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_spending (id INT PRIMARY KEY, year INT, category VARCHAR(50), amount FLOAT); INSERT INTO defense_spending (id, year, category, amount) VALUES (1, 2020, 'Military Innovation', 50000000); INSERT INTO defense_spending (id, year, category, amount) VALUES (2, 2019, 'Defense Diplomacy', 40000000);
What is the total spending on military innovation for the year 2020 in the 'defense_spending' table?
SELECT SUM(amount) FROM defense_spending WHERE year = 2020 AND category = 'Military Innovation';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_rights (record_id INT, union_name VARCHAR(50), issue VARCHAR(50), issue_date DATE, resolution_date DATE);CREATE VIEW union_labor_rights AS SELECT union_name, issue_date, resolution_date FROM labor_rights;
What is the average duration of labor rights issues for each union?
SELECT union_name, AVG(DATEDIFF(resolution_date, issue_date)) as avg_duration FROM union_labor_rights GROUP BY union_name;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, name VARCHAR(50), constructionDate DATE, location VARCHAR(50), energyConsumption DECIMAL(5,2), surfaceArea INT); INSERT INTO GreenBuildings (id, name, constructionDate, location, energyConsumption, surfaceArea) VALUES (1, 'Building A', '2005-01-01', 'Urban', 50.0, 1500), (2, 'Buildi...
Calculate the average energy consumption of buildings constructed before 2000 that are located in 'Rural' areas and have a surface area above 1000 square meters in the 'GreenBuildings' table.
SELECT AVG(energyConsumption) FROM GreenBuildings WHERE constructionDate < '2000-01-01' AND location = 'Rural' AND surfaceArea > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE airports (airport_id INT, airport_name VARCHAR(50), state VARCHAR(50), elevation INT);
List all the airports in California, along with their elevation.
SELECT airport_name, elevation FROM airports WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE MonthlyRevenue (restaurant_id INT, month INT, year INT, revenue INT); INSERT INTO MonthlyRevenue (restaurant_id, month, year, revenue) VALUES (10, 1, 2020, 1000), (10, 2, 2020, 1200);
What is the average monthly revenue for 'Nutritious Nosh' in 2020?
SELECT AVG(revenue) FROM MonthlyRevenue WHERE restaurant_id = 10 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (id INT, region VARCHAR(20), year INT, restored BOOLEAN); INSERT INTO HeritageSites (id, region, year, restored) VALUES (11, 'Oceania', 2018, TRUE); INSERT INTO HeritageSites (id, region, year, restored) VALUES (12, 'Oceania', 2020, TRUE);
How many heritage sites were restored in Oceania between 2018 and 2020?
SELECT COUNT(*) FROM HeritageSites WHERE region = 'Oceania' AND year BETWEEN 2018 AND 2020 AND restored = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE CommercialEfficiency (building_id INT, rating FLOAT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO CommercialEfficiency (building_id, rating, city, state) VALUES (1, 85.6, 'LosAngeles', 'CA'), (2, 90.2, 'NewYorkCity', 'NY');
What is the maximum energy efficiency rating for commercial buildings in the "CleanEnergy" schema?
SELECT MAX(rating) FROM CleanEnergy.CommercialEfficiency;
gretelai_synthetic_text_to_sql
CREATE TABLE vendor_contracts (vendor_id INT, vendor_name VARCHAR(50), contract_id INT, contract_value DECIMAL(10,2));
Update the vendor_contracts table to set the 'contract_value' to 50000 for any contract with a 'vendor_name' of 'DEF Contracting' and a 'contract_id' of 999
UPDATE vendor_contracts SET contract_value = 50000 WHERE vendor_name = 'DEF Contracting' AND contract_id = 999;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name TEXT, region TEXT, start_date DATE); INSERT INTO initiatives (id, name, region, start_date) VALUES (1, 'Initiative 1', 'rural India', '2015-01-01'), (2, 'Initiative 2', 'rural India', '2016-01-01'), (3, 'Initiative 3', 'urban India', '2015-01-01');
How many 'community development initiatives' have been implemented in 'rural India' since 2015?
SELECT COUNT(initiatives.id) FROM initiatives WHERE initiatives.region = 'rural India' AND initiatives.start_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE regulatory_fines (id INT, port_id INT, agency_id INT, fine_amount FLOAT, fine_date DATE); CREATE TABLE regulatory_agencies (agency_id INT, agency_name VARCHAR(50));
Calculate the total number of fines imposed on each port, grouped by regulatory agency and year.
SELECT r.agency_name, DATE_FORMAT(rf.fine_date, '%Y') as year, SUM(rf.fine_amount) as total_fines FROM regulatory_fines rf JOIN ports p ON rf.port_id = p.port_id JOIN regulatory_agencies r ON rf.agency_id = r.agency_id GROUP BY r.agency_name, year;
gretelai_synthetic_text_to_sql
CREATE TABLE areas (id INT, name VARCHAR(255), rural_designation VARCHAR(50)); INSERT INTO areas (id, name, rural_designation) VALUES (1, 'Area A', 'Rural'); CREATE TABLE life_expectancies (id INT, area_id INT, life_expectancy INT); INSERT INTO life_expectancies (id, area_id, life_expectancy) VALUES (1, 1, 72);
What are the five rural areas with the lowest life expectancy?
SELECT a.name, le.life_expectancy FROM areas a JOIN life_expectancies le ON a.id = le.area_id WHERE a.rural_designation = 'Rural' ORDER BY le.life_expectancy ASC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityStrategies (id INT, name VARCHAR(50), description TEXT); INSERT INTO CybersecurityStrategies (id, name, description) VALUES (1, 'Cloud Security', 'Implementing security measures for cloud infrastructure.'), (2, 'Data Privacy', 'Protecting sensitive data and ensuring data privacy.'), (3, 'Netwo...
Show the details of cybersecurity strategies related to 'Cloud Security' and 'Data Privacy'.
SELECT * FROM CybersecurityStrategies WHERE name IN ('Cloud Security', 'Data Privacy');
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (id INT, name TEXT, budget DECIMAL(10,2)); INSERT INTO Accommodations (id, name, budget) VALUES (1, 'Ramp', 10000.00), (2, 'Elevator', 20000.00), (3, 'Handrail', 5000.00);
How many disability accommodations are there in total, and what is the average budget spent on each accommodation?
SELECT COUNT(*) as total_accommodations, AVG(budget) as avg_budget_per_accommodation FROM Accommodations;
gretelai_synthetic_text_to_sql
CREATE TABLE patients_treatments (patient_id INT, treatment_type VARCHAR(50), duration INT, cost FLOAT); INSERT INTO patients_treatments (patient_id, treatment_type, duration, cost) VALUES (25, 'Psychotherapy', 12, 120); INSERT INTO patients_treatments (patient_id, treatment_type, duration, cost) VALUES (26, 'Medicatio...
What is the number of unique patients who have tried each treatment type, ranked by popularity?
SELECT treatment_type, COUNT(DISTINCT patient_id) as num_patients, RANK() OVER (ORDER BY COUNT(DISTINCT patient_id) DESC) as patient_rank FROM patients_treatments GROUP BY treatment_type ORDER BY num_patients DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor TEXT, amount INT, project_type TEXT, country TEXT); INSERT INTO donations (id, donor, amount, project_type, country) VALUES (1, 'Joseph Smith', 5000, 'community development', 'Guatemala'); INSERT INTO donations (id, donor, amount, project_type, country) VALUES (2, 'Grace Lee', 3000...
What are the total donations made to community development projects in Central America?
SELECT SUM(amount) FROM donations WHERE project_type = 'community development' AND country IN ('Guatemala', 'El Salvador', 'Honduras', 'Nicaragua', 'Costa Rica', 'Panama');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(10,2), cause TEXT, donation_date DATE); INSERT INTO donations (donor_id, donation_amount, cause, donation_date) VALUES (1, 2000, 'animal welfare', '2021-07-23');
Calculate the total donation amount for each cause in Q3 2021, ordered by total donation amount in descending order.
SELECT cause, SUM(donation_amount) as total_donation_amount FROM donations WHERE donation_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY cause ORDER BY total_donation_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (org_id INT, org_name TEXT, org_region TEXT); INSERT INTO organization (org_id, org_name, org_region) VALUES (1, 'South American Climate Finance Corporation', 'South America');
What is the average amount of climate finance provided by organizations based in South America in the last 5 years?
SELECT AVG(amount) FROM climate_finance JOIN organization ON climate_finance.org_id = organization.org_id WHERE organization.org_region = 'South America' AND climate_finance.date >= DATEADD(year, -5, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE SCHEMA FoodService;CREATE TABLE Inspections (inspection_id INT, restaurant_id INT, inspection_date DATE, violations INT); INSERT INTO Inspections (inspection_id, restaurant_id, inspection_date, violations) VALUES (1, 1, '2021-01-01', 3), (2, 1, '2021-04-01', 0), (3, 2, '2021-02-01', 2), (4, 2, '2021-05-01', 1);C...
What is the percentage of transactions with food safety violations for each restaurant in the past year?
SELECT restaurant_id, (COUNT(violations) * 100.00 / (SELECT COUNT(*) FROM Inspections WHERE inspection_date >= '2021-01-01')) as violation_percentage FROM Inspections WHERE inspection_date >= '2021-01-01' GROUP BY restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists schedules (schedule_id serial, city varchar(20), departure_time time); INSERT INTO schedules (city, departure_time) VALUES ('berlin', '07:00:00'), ('berlin', '07:15:00'), ('berlin', '07:30:00'), ('berlin', '07:45:00');
Update public transportation schedules for 'berlin' with a 15-minute delay
UPDATE schedules SET departure_time = schedules.departure_time + INTERVAL '15 minutes' WHERE city = 'berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), budget INT); INSERT INTO movies (id, title, genre, budget) VALUES (1, 'Movie1', 'Animated', 50000000), (2, 'Movie2', 'Action', 80000000), (3, 'Movie3', 'Animated', 70000000);
What's the average budget for animated movies?
SELECT AVG(budget) FROM movies WHERE genre = 'Animated';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'Kenya', 250.00, '2021-03-01'); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (2, 'Jane...
List the top 2 donors from Kenya based on their total donation amount in 2021.
SELECT name, SUM(donation_amount) AS total_donation FROM Donors WHERE country = 'Kenya' AND YEAR(donation_date) = 2021 GROUP BY name ORDER BY total_donation DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (destination_id INT, destination_name VARCHAR(50), region VARCHAR(20), sustainable_practices_score DECIMAL(3,1), PRIMARY KEY (destination_id));
Insert a new record into the "destinations" table with the following information: destination_id = 102, destination_name = 'Paris', region = 'Europe', sustainable_practices_score = 8.2
INSERT INTO destinations (destination_id, destination_name, region, sustainable_practices_score) VALUES (102, 'Paris', 'Europe', 8.2);
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (model_id INT, model_name TEXT, fairness_score FLOAT);
How many explainable AI models have a fairness score greater than 0.85 in the 'explainable_ai' table?
SELECT COUNT(*) FROM explainable_ai WHERE fairness_score > 0.85;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurant (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO Restaurant (id, name, type) VALUES (1, 'Fresh Harvest', 'Organic'); INSERT INTO Restaurant (id, name, type) VALUES (2, 'Green Living', 'Vegan'); INSERT INTO Restaurant (id, name, type) VALUES (3, 'Taste of Nature', 'Organic'); CREATE TABL...
What is the average price of vegan entrees served by organic restaurants?
SELECT AVG(MenuItem.price) FROM MenuItem INNER JOIN Restaurant ON MenuItem.restaurant_id = Restaurant.id WHERE Restaurant.type IN ('Organic', 'Vegan') AND MenuItem.category = 'Entrees' AND MenuItem.is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (state VARCHAR(2), year INT, accessibility FLOAT, affordability FLOAT);
Delete health equity metrics for Texas in 2020
DELETE FROM health_equity_metrics WHERE state = 'TX' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (region VARCHAR(255), production INTEGER, year INTEGER);
What is the total timber production for each region in the last 5 years?
SELECT region, SUM(production) FROM timber_production WHERE year BETWEEN YEAR(CURRENT_DATE)-5 AND YEAR(CURRENT_DATE) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE DisabilitySupportPrograms (ID INT, Program VARCHAR(50), Region VARCHAR(50), Budget FLOAT); INSERT INTO DisabilitySupportPrograms (ID, Program, Region, Budget) VALUES (1, 'Sign Language Interpretation', 'Pacific', 50000.0), (2, 'Assistive Technology Grant', 'Pacific', 75000.0);
What is the average budget allocated for disability support programs in the Pacific region?
SELECT AVG(Budget) FROM DisabilitySupportPrograms WHERE Region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Data (Id INT, City VARCHAR(50), Speed INT, Month VARCHAR(10)); INSERT INTO EV_Data (Id, City, Speed, Month) VALUES (1, 'SanFrancisco', 60, 'January'); INSERT INTO EV_Data (Id, City, Speed, Month) VALUES (2, 'NewYork', 50, 'January');
What was the average speed of electric vehicles in the month of January across all cities?
SELECT AVG(Speed) FROM EV_Data WHERE Month = 'January' AND City IN (SELECT City FROM EV_Data WHERE Type = 'Electric');
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_research_funding (id INT, sample_id VARCHAR(20), funding_amount FLOAT); CREATE TABLE biosensors (id INT, name VARCHAR(50), type VARCHAR(50), accuracy FLOAT); INSERT INTO genetic_research_funding (id, sample_id, funding_amount) VALUES (1, 'GD001', 50000.0), (2, 'GD002', 70000.0), (3, 'GD003', 30000....
Get samples with genetic research funding below average and related biosensor accuracy.
SELECT g.sample_id, g.funding_amount, b.accuracy FROM genetic_research_funding g, biosensors b WHERE g.funding_amount < (SELECT AVG(funding_amount) FROM genetic_research_funding) AND g.sample_id = b.id;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtHeritage (id INT, name VARCHAR(50), type VARCHAR(50), year INT, country VARCHAR(50)); INSERT INTO ArtHeritage (id, name, type, year, country) VALUES (1, 'Pottery', 'Art', 2000, 'Mexico'); INSERT INTO ArtHeritage (id, name, type, year, country) VALUES (2, 'Woven Baskets', 'Art', 1950, 'USA');
What is the total number of traditional art pieces in the 'ArtHeritage' table, grouped by country?
SELECT country, COUNT(*) as total_art_pieces FROM ArtHeritage GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DateJoined DATE, Age INT); INSERT INTO Members (MemberID, FirstName, LastName, DateJoined, Age) VALUES (1, 'John', 'Doe', '2020-01-01', 30), (2, 'Jane', 'Doe', '2019-01-01', 25);
What is the average age of members who joined in 2020?
SELECT AVG(Age) FROM Members WHERE YEAR(DateJoined) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, EventDate DATE, TotalAttendees INT, CommunityType VARCHAR(255), Genre VARCHAR(255)); INSERT INTO Events (EventID, EventDate, TotalAttendees, CommunityType, Genre) VALUES (1, '2023-02-01', 120, 'Underrepresented', 'Music'), (2, '2023-03-01', 80, 'Represented', 'Music');
How many events in the music genre had more than 100 attendees from underrepresented communities in 2023?
SELECT COUNT(*) FROM Events WHERE TotalAttendees > 100 AND CommunityType = 'Underrepresented' AND Genre = 'Music' AND YEAR(EventDate) = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), Country VARCHAR(50), DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, Country, DonationDate, Amount) VALUES (1, 'Jane Smith', 'United States', '2024-01-01', 50.00), (2, 'John Doe', 'Canada', '2024-02-01', 100.00), (3, 'Alice Johns...
What is the percentage of donations received from each country in 2024, ordered by percentage in descending order?
SELECT Country, SUM(Amount) * 100.0 / (SELECT SUM(Amount) FROM Donors WHERE YEAR(DonationDate) = 2024) AS Percentage FROM Donors WHERE YEAR(DonationDate) = 2024 GROUP BY Country ORDER BY Percentage DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics; CREATE TABLE if not exists genetics.research_projects (id INT, name VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO genetics.research_projects (id, name, funding) VALUES (1, 'CRISPR', 3000000.00), (2, 'Genome Sequencing', 2500000.00), (3, 'Stem Cell Research', 4000000.00);
Which genetic research projects have the highest average funding?
SELECT name, AVG(funding) as avg_funding FROM genetics.research_projects GROUP BY name ORDER BY avg_funding DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name TEXT, identity TEXT); INSERT INTO community_health_workers (worker_id, name, identity) VALUES (1, 'John Doe', 'Straight'), (2, 'Jane Smith', 'Lesbian'), (3, 'Maria Garcia', 'Bisexual');
What is the total number of community health workers who identify as LGBTQ+?
SELECT COUNT(*) FROM community_health_workers WHERE identity IN ('Lesbian', 'Gay', 'Bisexual', 'Transgender', 'Queer', 'Questioning');
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, age INT, gender TEXT, contribution FLOAT, location TEXT); INSERT INTO donors (id, name, age, gender, contribution, location) VALUES (1, 'Alice Johnson', 45, 'Female', 500.00, 'San Francisco'); INSERT INTO donors (id, name, age, gender, contribution, location) VALUES (2, 'Bob Brow...
What is the total contribution by each donor's gender?
SELECT gender, SUM(contribution) as total_contribution FROM donors GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, segment VARCHAR(20)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO customers (id, segment) VALUES (1, 'Retail'); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (1, 1, 1000, '2021-12-31');
Calculate the maximum transaction amount for the 'Retail' customer segment in the last year.
SELECT MAX(amount) FROM transactions JOIN customers ON transactions.customer_id = customers.id WHERE customers.segment = 'Retail' AND transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Sales (id INT, make VARCHAR(255), model VARCHAR(255), year INT, avg_speed FLOAT);
What is the average speed of electric vehicles in the US?
SELECT AVG(avg_speed) FROM EV_Sales WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_type VARCHAR(20), region VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO hotels (hotel_type, region, revenue) VALUES ('Economy', 'Paris', 6000.00), ('Luxury', 'Paris', 12000.00);
What is the total revenue from the 'Luxury' hotel type for the 'Paris' region in '2021'?
SELECT SUM(revenue) FROM hotels WHERE hotel_type = 'Luxury' AND region = 'Paris' AND EXTRACT(YEAR FROM timestamp) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE grad_students (id INT, name TEXT, department TEXT); INSERT INTO grad_students (id, name, department) VALUES (1, 'John Doe', 'Computer Science'), (2, 'Jane Smith', 'Mathematics'); CREATE TABLE research_grants (id INT, student_id INT, title TEXT, funding_amount INT); INSERT INTO research_grants (id, student_...
Who are the graduate students with the most research grants?
SELECT g.name, COUNT(r.id) AS grant_count, SUM(r.funding_amount) AS total_funding FROM grad_students g INNER JOIN research_grants r ON g.id = r.student_id GROUP BY g.name ORDER BY grant_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, name TEXT, state TEXT, community_service_hours INT); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (1, 'John Doe', 'Texas', 50); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (2, 'Jane Smith', 'Texas', NULL);
Delete offenders from Texas who have not completed any community service hours.
DELETE FROM offenders WHERE state = 'Texas' AND community_service_hours IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE gadolinium_prices (country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO gadolinium_prices (country, price) VALUES ('South Africa', 110.00), ('Egypt', 105.00), ('Nigeria', 115.00);
What is the average market price of Gadolinium produced in Africa?
SELECT AVG(price) FROM gadolinium_prices WHERE country IN ('South Africa', 'Egypt', 'Nigeria');
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), author_id INT); CREATE TABLE journalists (id INT, name VARCHAR(50), age INT, gender VARCHAR(10));
What is the distribution of news articles by gender of the author in the "articles" and "journalists" tables?
SELECT j.gender, COUNT(a.id) AS num_articles FROM articles a JOIN journalists j ON a.author_id = j.id GROUP BY j.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (strategy_id INT, strategy_name VARCHAR(50), AUM DECIMAL(10, 2), region VARCHAR(20)); INSERT INTO investment_strategies (strategy_id, strategy_name, AUM, region) VALUES (1, 'Equity', 5000000.00, 'Southeast'), (2, 'Bond', 3000000.00, 'Northeast'), (3, 'Real Estate', 7000000.00, 'Northw...
What is the total assets under management (AUM) for each region?
SELECT region, SUM(AUM) FROM investment_strategies GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE SupplyChainViolations (country TEXT, num_violations INT); INSERT INTO SupplyChainViolations (country, num_violations) VALUES ('Bangladesh', 50), ('Cambodia', 30), ('Vietnam', 20); CREATE TABLE ProductTransparency (product_id INT, recycled_materials BOOLEAN); INSERT INTO ProductTransparency (product_id, rec...
Which countries have supply chain violations and also produce products with recycled materials?
SELECT DISTINCT S1.country FROM SupplyChainViolations S1 INNER JOIN Products P1 ON S1.country = P1.country INNER JOIN ProductTransparency PT1 ON P1.product_id = PT1.product_id WHERE PT1.recycled_materials = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Name TEXT, InitialBudget DECIMAL(10,2));CREATE TABLE BudgetUpdates (UpdateID INT, ProgramID INT, NewBudget DECIMAL(10,2), UpdateDate DATE);
What is the total budget for each program in 2023, including any updates made to the budgets?
SELECT P.Name, SUM(CASE WHEN BU.UpdateDate = (SELECT MAX(UpdateDate) FROM BudgetUpdates BU2 WHERE BU2.ProgramID = BU.ProgramID) THEN BU.NewBudget ELSE P.InitialBudget END) as TotalBudget FROM Programs P LEFT JOIN BudgetUpdates BU ON P.ProgramID = BU.ProgramID GROUP BY P.ProgramID, P.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, email TEXT);CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE);
What is the average donation amount per donor, based on the 'donations' and 'donors' tables?
SELECT donors.name, AVG(donations.amount) FROM donors INNER JOIN donations ON donors.id = donations.donor_id GROUP BY donors.name;
gretelai_synthetic_text_to_sql
CREATE TABLE gas_wells (well_id INT, gas_production FLOAT); INSERT INTO gas_wells (well_id, gas_production) VALUES (1, 200), (2, 300), (3, 400), (4, 500), (5, 600);
Identify the well with the highest gas production in 2021
SELECT well_id, gas_production FROM (SELECT well_id, gas_production, ROW_NUMBER() OVER (ORDER BY gas_production DESC) as rank FROM gas_wells WHERE YEAR(timestamp) = 2021) t WHERE rank = 1;
gretelai_synthetic_text_to_sql