context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Users (user_id INT, username TEXT); CREATE TABLE Songs (song_id INT, title TEXT, genre TEXT, release_date DATE, price DECIMAL(5,2)); CREATE TABLE Purchases (purchase_id INT, user_id INT, song_id INT, purchase_date DATE);
Who are the top 5 users who have spent the most on R&B music?
SELECT Users.username, SUM(Songs.price) as total_spent FROM Users INNER JOIN Purchases ON Users.user_id = Purchases.user_id INNER JOIN Songs ON Purchases.song_id = Songs.song_id WHERE Songs.genre = 'R&B' GROUP BY Users.username ORDER BY total_spent DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, transaction_amt DECIMAL(10, 2)); INSERT INTO customers (customer_id, transaction_amt) VALUES (1, 200.00), (2, 300.50), (3, 150.25);
Find the top 2 customers by total transaction amount.
SELECT customer_id, SUM(transaction_amt) OVER (PARTITION BY customer_id) AS total_transaction_amt, RANK() OVER (ORDER BY SUM(transaction_amt) DESC) AS customer_rank FROM customers;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_events (id INT, name TEXT, city TEXT, type TEXT); INSERT INTO tourism_events (id, name, city, type) VALUES (1, 'Sustainable Travel Conference', 'New York', 'sustainable'); INSERT INTO tourism_events (id, name, city, type) VALUES (2, 'Green Tourism Expo', 'New York', 'sustainable');
Delete all records of sustainable tourism events in New York.
DELETE FROM tourism_events WHERE city = 'New York' AND type = 'sustainable';
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT, organization VARCHAR(255), year INT, amount DECIMAL(10,2));
What is the average amount of funding received by disaster relief organizations in the last 5 years?
SELECT AVG(amount) FROM funding WHERE organization LIKE '%disaster relief%' AND year > (SELECT MAX(year) FROM funding WHERE organization LIKE '%disaster relief%') - 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (ID INT PRIMARY KEY, Age INT, RestingHeartRate INT, LastLogin DATE); CREATE TABLE Workouts (UserID INT, Date DATE);
How many users have not logged any workouts in the past 30 days, and what is the average age and resting heart rate of these inactive users?
SELECT AVG(Users.Age) AS AvgAge, AVG(Users.RestingHeartRate) AS AvgRestingHeartRate FROM Users JOIN (SELECT UserID FROM Workouts WHERE Date >= DATEADD(day, -30, GETDATE()) GROUP BY UserID) AS RecentWorkouts ON Users.ID = RecentWorkouts.UserID WHERE Users.LastLogin IS NOT NULL AND Users.ID NOT IN (SELECT UserID FROM RecentWorkouts);
gretelai_synthetic_text_to_sql
CREATE TABLE member_data (member_id INT, age INT, gender VARCHAR(10)); INSERT INTO member_data (member_id, age, gender) VALUES (1, 27, 'Female'), (2, 32, 'Male'), (3, 26, 'Female'), (4, 28, 'Male'), (5, 31, 'Female'); CREATE TABLE member_heart_rate (member_id INT, heart_rate INT); INSERT INTO member_heart_rate (member_id, heart_rate) VALUES (1, 185), (2, 175), (3, 190), (4, 160), (5, 182);
What is the number of members in each age group who have a maximum heart rate greater than 180?
SELECT CASE WHEN age < 25 THEN '18-24' WHEN age < 35 THEN '25-34' WHEN age < 45 THEN '35-44' ELSE '45+' END AS age_range, COUNT(*) AS members_count FROM member_data mdata JOIN member_heart_rate mhr ON mdata.member_id = mhr.member_id WHERE mhr.heart_rate > 180 GROUP BY age_range;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int);
What is the minimum score for each player in the "Puzzle" genre?
SELECT PlayerName, MIN(Score) OVER(PARTITION BY PlayerID) as MinScore FROM PlayerScores WHERE Game = 'Puzzle';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(255)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, amount DECIMAL(10,2));
List all customers who have not made any transactions in the past month, along with their last transaction date and total transaction count.
SELECT c.customer_id, c.name, MAX(t.transaction_date) as last_transaction_date, COUNT(t.transaction_id) as total_transaction_count FROM customers c LEFT JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date IS NULL OR t.transaction_date < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY c.customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, category, price) VALUES (1, 'Natural', 25.99), (2, 'Organic', 30.49), (3, 'Natural', 29.99), (4, 'Conventional', 15.99);
What is the average price of products in the Natural category, ranked by average price in descending order?
SELECT AVG(price) as avg_price, category FROM products GROUP BY category ORDER BY avg_price DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, name TEXT, country TEXT, safety_score FLOAT); INSERT INTO ai_models (model_id, name, country, safety_score) VALUES (1, 'ModelA', 'US', 0.85), (2, 'ModelB', 'Canada', 0.90), (3, 'ModelC', 'US', 0.75);
What is the average safety score of models developed in the US?
SELECT AVG(safety_score) FROM ai_models WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE player_stats (player_id INT, name VARCHAR(100), is_active BOOLEAN, region VARCHAR(50));
Update the 'player_stats' table to set the 'is_active' column as true for players from the 'North America' region
UPDATE player_stats SET is_active = TRUE WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(50), has_vegan_options BOOLEAN);
Find the number of stores that carry "vegan options"
SELECT COUNT(*) FROM stores WHERE has_vegan_options = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_id INT, delivery_location VARCHAR(20), shipped_date DATE, weight FLOAT); INSERT INTO warehouse (id, name) VALUES (1, 'Seattle'), (2, 'NY'), (3, 'LA'); INSERT INTO shipment (id, warehouse_id, delivery_location, shipped_date, weight) VALUES (1, 1, 'Tokyo', '2021-03-28', 20.5), (2, 1, 'Tokyo', '2021-03-29', 15.3), (3, 2, 'LA', '2021-03-25', 12.2);
What is the average weight of packages shipped to 'Tokyo' in the last week of March 2021 from the 'Seattle' warehouse, if available?
SELECT AVG(weight) AS avg_weight FROM shipment WHERE warehouse_id = 1 AND delivery_location = 'Tokyo' AND shipped_date >= DATE_SUB('2021-03-31', INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE dysprosium_prices (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO dysprosium_prices (country, price, year) VALUES ('Malaysia', 145.00, 2018), ('Malaysia', 152.00, 2019), ('Malaysia', 160.00, 2020);
What was the highest price of dysprosium in Malaysia?
SELECT MAX(price) FROM dysprosium_prices WHERE country = 'Malaysia';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_stations (id INT, station_name TEXT, temperature DECIMAL(5,2), measurement_date DATE); INSERT INTO arctic_stations (id, station_name, temperature, measurement_date) VALUES (1, 'Station1', 15.2, '2020-01-01'); INSERT INTO arctic_stations (id, station_name, temperature, measurement_date) VALUES (2, 'Station2', -12.5, '2020-01-01');
What is the average temperature recorded for the 'arctic_stations' table in 2020?
SELECT AVG(temperature) FROM arctic_stations WHERE measurement_date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, first_name VARCHAR, last_name VARCHAR, email VARCHAR, phone_number VARCHAR, date_joined DATE); INSERT INTO Volunteers (id, first_name, last_name, email, phone_number, date_joined) VALUES (1, 'John', 'Doe', 'john.doe@email.com', '555-123-4567', '2021-05-01');
Add a new volunteer with sensitive information
INSERT INTO Volunteers (id, first_name, last_name, email, phone_number, date_joined) VALUES (2, 'Jane', 'Doe', 'jane.doe@email.com', 'REDACTED', '2021-06-01');
gretelai_synthetic_text_to_sql
CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(255)); CREATE TABLE patients (id INT, age INT, country VARCHAR(255)); INSERT INTO diagnoses (id, patient_id, condition) VALUES (1, 1, 'Anxiety'), (2, 2, 'Depression'), (3, 3, 'Bipolar'); INSERT INTO patients (id, age, country) VALUES (1, 35, 'USA'), (2, 42, 'Canada'), (3, 28, 'Mexico');
Which mental health conditions were diagnosed in the top 3 countries with the most diagnoses?
SELECT diagnoses.condition, patients.country FROM diagnoses JOIN patients ON diagnoses.patient_id = patients.id GROUP BY diagnoses.condition, patients.country ORDER BY COUNT(*) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id int, product_id int, sale_date date, revenue decimal(5,2)); CREATE TABLE products (product_id int, product_name varchar(255), is_upcycled boolean, country varchar(50)); INSERT INTO sales (sale_id, product_id, sale_date, revenue) VALUES (1, 1, '2022-02-04', 70.00); INSERT INTO products (product_id, product_name, is_upcycled, country) VALUES (1, 'Upcycled Tote Bag', true, 'Germany');
What is the daily sales revenue of upcycled products in Germany?
SELECT sale_date, SUM(revenue) AS daily_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE is_upcycled = true AND country = 'Germany' GROUP BY sale_date;
gretelai_synthetic_text_to_sql
CREATE TABLE edu_grants (grant_id INT, grant_amount DECIMAL(10,2), grant_recipient VARCHAR(50), recipient_identity VARCHAR(50)); INSERT INTO edu_grants (grant_id, grant_amount, grant_recipient, recipient_identity) VALUES (1, 35000.00, 'Prof. Rivera', 'Indigenous'), (2, 45000.00, 'Prof. Thompson', 'Native American'), (3, 55000.00, 'Prof. Wang', 'Asian'), (4, 65000.00, 'Prof. Lopez', 'Hispanic');
What is the total number of research grants awarded to faculty members in the College of Education who identify as Indigenous or Native American?
SELECT COUNT(*) FROM edu_grants WHERE grant_recipient LIKE '%College of Education%' AND recipient_identity IN ('Indigenous', 'Native American');
gretelai_synthetic_text_to_sql
CREATE TABLE lanthanum_production (country VARCHAR(50), year INT, quantity INT); INSERT INTO lanthanum_production (country, year, quantity) VALUES ('China', 2016, 150000), ('Australia', 2016, 12000), ('United States', 2016, 18000), ('Brazil', 2016, 9000), ('South Africa', 2016, 11000);
Which countries produced more than 10000 units of Lanthanum in 2016?
SELECT country FROM lanthanum_production WHERE year = 2016 AND quantity > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(50)); CREATE TABLE companies (id INT, name VARCHAR(50)); CREATE TABLE company_sites (id INT, company_id INT, site_id INT); CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), region_id INT, company_id INT); CREATE TABLE employees (id INT, site_id INT, role VARCHAR(50), quantity INT); CREATE TABLE contractors (id INT, site_id INT, quantity INT); CREATE TABLE minerals_extracted (id INT, site_id INT, quantity INT);
What is the total quantity of minerals extracted by each company in each region and the total number of employees, contractors, and mining sites for each company in each region?
SELECT r.name AS region, c.name AS company, SUM(me.quantity) AS total_minerals_extracted, COUNT(DISTINCT ms.id) AS total_sites, SUM(e.quantity + c.quantity) AS total_workforce FROM regions r INNER JOIN mining_sites ms ON r.id = ms.region_id INNER JOIN companies c ON ms.company_id = c.id INNER JOIN company_sites cs ON c.id = cs.company_id INNER JOIN mining_sites ms2 ON cs.site_id = ms2.id INNER JOIN (SELECT site_id, SUM(quantity) AS quantity FROM employees GROUP BY site_id) e ON ms2.id = e.site_id INNER JOIN (SELECT site_id, SUM(quantity) AS quantity FROM contractors GROUP BY site_id) c ON ms2.id = c.site_id INNER JOIN (SELECT site_id, SUM(quantity) AS quantity FROM minerals_extracted GROUP BY site_id) me ON ms2.id = me.site_id GROUP BY r.name, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_name TEXT, approval_year TEXT); INSERT INTO drug_approval (drug_name, approval_year) VALUES ('Drug1', 'Year1'), ('Drug2', 'Year2'), ('Drug3', 'Year3'), ('Drug4', 'Year1'), ('Drug5', 'Year3');
Which drugs have been approved in both 'Year1' and 'Year3'?
SELECT drug_name FROM drug_approval WHERE approval_year IN ('Year1', 'Year3') GROUP BY drug_name HAVING COUNT(DISTINCT approval_year) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE weight_loss (user_id INT, join_date DATE, weight_loss FLOAT); INSERT INTO weight_loss (user_id, join_date, weight_loss) VALUES (1, '2021-01-01', 5), (2, '2021-02-15', 7), (3, '2021-03-20', 9), (4, '2022-01-05', 6);
What is the average weight loss per month for users who joined in 2021?
SELECT AVG(weight_loss / (MONTHS_BETWEEN(join_date, TRUNC(join_date, 'YYYY')))) FROM weight_loss WHERE EXTRACT(YEAR FROM join_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Transportation_Dept (ID INT, Project VARCHAR(255), Budget FLOAT); INSERT INTO Transportation_Dept (ID, Project, Budget) VALUES (1, 'Road Construction', 2000000), (2, 'Bridge Repair', 1500000), (3, 'Traffic Light Installation', 500000);
What is the maximum budget allocated for a transportation project in the Transportation department?
SELECT MAX(Budget) FROM Transportation_Dept;
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_name TEXT, state_abbr TEXT); INSERT INTO states (state_name, state_abbr) VALUES ('Alabama', 'AL'), ('Alaska', 'AK'), ('Arizona', 'AZ'); CREATE TABLE mental_health_facilities (name TEXT, address TEXT, state TEXT); INSERT INTO mental_health_facilities (name, address, state) VALUES ('Facility1', 'Address1', 'AL'), ('Facility2', 'Address2', 'AK'), ('Facility3', 'Address3', 'AZ');
What is the number of mental health facilities in each state?
SELECT s.state_name, COUNT(m.name) AS num_facilities FROM states s INNER JOIN mental_health_facilities m ON s.state_abbr = m.state GROUP BY s.state_name;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, region TEXT); INSERT INTO countries (id, name, region) VALUES (1, 'Country1', 'Africa'), (2, 'Country2', 'Asia'), (3, 'Country3', 'Europe'); CREATE TABLE defense_diplomacy (id INT, country_id INT, year INT, amount INT); INSERT INTO defense_diplomacy (id, country_id, year, amount) VALUES (1, 1, 2019, 10000), (2, 2, 2020, 15000), (3, 1, 2020, 12000);
What is the total amount of defense diplomacy expenditure by country for the year 2020?
SELECT SUM(amount) FROM defense_diplomacy JOIN countries ON defense_diplomacy.country_id = countries.id WHERE countries.region IS NOT NULL AND defense_diplomacy.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE news_stories (id INT, title VARCHAR(100), content TEXT, topic VARCHAR(30)); CREATE TABLE audience_demographics (id INT, news_story_id INT, age INT, gender VARCHAR(10), location VARCHAR(50));
List all the news stories related to "climate change" and their corresponding audience demographics from the "news_stories" and "audience_demographics" tables.
SELECT news_stories.title, audience_demographics.age, audience_demographics.gender, audience_demographics.location FROM news_stories INNER JOIN audience_demographics ON news_stories.id = audience_demographics.news_story_id WHERE news_stories.topic = 'climate change';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), enrollment_date DATE); CREATE TABLE student_grants (student_id INT, grant_id INT); CREATE TABLE grants (id INT, title VARCHAR(100), year INT, amount FLOAT); INSERT INTO students (id, name, enrollment_date) VALUES (1, 'John Smith', '2021-08-22'), (2, 'Jane Doe', '2020-08-22'), (3, 'Alice Johnson', '2019-08-22'); INSERT INTO student_grants (student_id, grant_id) VALUES (2, 1), (2, 2), (3, 3); INSERT INTO grants (id, title, year, amount) VALUES (1, 'Grant 1', 2021, 5000.0), (2, 'Grant 2', 2020, 7000.0), (3, 'Grant 3', 2019, 6000.0);
Display the names of students who have not received any research grants, excluding students who enrolled in the past year.
SELECT students.name FROM students LEFT JOIN student_grants ON students.id = student_grants.student_id LEFT JOIN grants ON student_grants.grant_id = grants.id WHERE grants.id IS NULL AND students.enrollment_date < DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE SCHEMA socialmedia;CREATE TABLE posts (id INT, post_type VARCHAR(255), region VARCHAR(255), engagement INT);INSERT INTO posts (id, post_type, region, engagement) VALUES (1, 'video', 'Asia', 500), (2, 'image', 'Asia', 700);
Which content type received the most engagement in Asia in Q2 2022?
SELECT post_type, SUM(engagement) FROM socialmedia.posts WHERE region = 'Asia' AND EXTRACT(MONTH FROM timestamp) BETWEEN 4 AND 6 GROUP BY post_type ORDER BY SUM(engagement) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, subject_area VARCHAR(20), course_id VARCHAR(5)); INSERT INTO teacher_pd (teacher_id, subject_area, course_id) VALUES (1, 'Mathematics', 'C101'), (2, 'Science', 'C201'), (3, 'Mathematics', 'C102'), (4, 'English', 'C301'), (5, 'Science', 'C202'); CREATE TABLE courses (course_id VARCHAR(5), course_name VARCHAR(20)); INSERT INTO courses (course_id, course_name) VALUES ('C101', 'Algebra I'), ('C102', 'Geometry'), ('C201', 'Physics'), ('C202', 'Biology'), ('C301', 'Literature');
What is the number of professional development courses taken by teachers in each subject area?
SELECT subject_area, COUNT(*) FROM teacher_pd GROUP BY subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName text); INSERT INTO Donors VALUES (1, 'John Doe'); INSERT INTO Donors VALUES (2, 'Jane Smith');CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount numeric); INSERT INTO Donations VALUES (1, 1, 500); INSERT INTO Donations VALUES (2, 2, 1000);
What's the maximum donation amount and the corresponding donor name?
SELECT DonorName, MAX(DonationAmount) FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (ti_id INT, ti_report VARCHAR(50), ti_region VARCHAR(50), ti_date DATE); INSERT INTO threat_intelligence (ti_id, ti_report, ti_region, ti_date) VALUES (1, 'Report X', 'North America', '2022-01-01'), (2, 'Report Y', 'South America', '2022-02-01'), (3, 'Report Z', 'North America', '2022-03-01');
What is the total number of threat intelligence reports generated for the North American continent?
SELECT COUNT(*) FROM threat_intelligence WHERE ti_region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID int, CityName varchar(255), Population int, Country varchar(255)); INSERT INTO Cities (CityID, CityName, Population, Country) VALUES (1, 'Sydney', 5000000, 'Australia'), (2, 'Melbourne', 4500000, 'Australia');
What is the name of the largest city in Australia and its population?
SELECT CityName, Population FROM Cities WHERE Country = 'Australia' ORDER BY Population DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, type TEXT, irrigation_date DATE); INSERT INTO crops (id, type, irrigation_date) VALUES (1, 'Corn', '2022-06-01'), (2, 'Soybeans', '2022-06-03'), (3, 'Wheat', '2022-06-05'), (4, 'Cotton', '2022-06-07');
Identify the number of times each crop type has been irrigated in the past week.
SELECT type, COUNT(*) as irrigation_count FROM crops WHERE irrigation_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, Game VARCHAR(100)); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (1, 'James Lee', 18, 'Valorant'); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (2, 'Emily Wong', 19, 'Valorant'); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (3, 'Michael Brown', 20, 'Valorant');
What is the minimum age of players who have played the game 'Valorant'?
SELECT MIN(Age) FROM Players WHERE Game = 'Valorant';
gretelai_synthetic_text_to_sql
CREATE TABLE us_census (model_name TEXT, fairness_score FLOAT); INSERT INTO us_census (model_name, fairness_score) VALUES ('model1', 0.85), ('model2', 0.90), ('model3', 0.88);
What is the average fairness score for models trained on the 'us_census' dataset?
SELECT AVG(fairness_score) FROM us_census;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish VARCHAR(50), created_at TIMESTAMP);CREATE TABLE dish_categories (category_id INT, category VARCHAR(20));
How many vegan dishes were added to the menu in Q1 2022?
SELECT COUNT(*) as vegan_dishes_added FROM dishes d JOIN dish_categories dc ON d.dish_id = dc.category_id WHERE dc.category = 'vegan' AND DATE_PART('quarter', d.created_at) = 1 AND DATE_PART('year', d.created_at) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_urbanism (property_id INT, city VARCHAR(20), score FLOAT); INSERT INTO sustainable_urbanism (property_id, city, score) VALUES (1, 'Vancouver', 85.5), (2, 'Seattle', 80.0), (3, 'NYC', 75.5), (4, 'Berkeley', 88.0);
What is the maximum sustainable urbanism score in Berkeley?
SELECT MAX(score) FROM sustainable_urbanism WHERE city = 'Berkeley';
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Missions(id INT, mission_name VARCHAR(50), launch_date DATE, spacecraft_id INT);
Get the number of spacecraft that were launched on each space mission, ordered by the number of spacecraft.
SELECT mission_name, COUNT(*) as Number_of_Spacecraft FROM Space_Missions GROUP BY mission_name ORDER BY Number_of_Spacecraft DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(50), type VARCHAR(50), distance_from_earth FLOAT);
What is the average distance (in km) of all active satellites from the Earth's surface?
SELECT AVG(distance_from_earth) FROM satellites WHERE type = 'Active';
gretelai_synthetic_text_to_sql
CREATE TABLE company_profiles (company_name VARCHAR(255), founding_year INT, diversity_metric FLOAT);
Insert a new record into the "company_profiles" table with the following data: "Gamma Corp", 2015, 0.5
INSERT INTO company_profiles (company_name, founding_year, diversity_metric) VALUES ('Gamma Corp', 2015, 0.5);
gretelai_synthetic_text_to_sql
CREATE TABLE facility_schedule (id INT, facility_id INT, start_time TIMESTAMP, end_time TIMESTAMP); INSERT INTO facility_schedule (id, facility_id, start_time, end_time) VALUES (1, 1, '2022-01-01 09:00:00', '2022-01-01 11:00:00');
Update the end_time for all records in 'facility_schedule' table to 1 hour after the start_time
UPDATE facility_schedule SET end_time = DATE_ADD(start_time, INTERVAL 1 HOUR);
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50));CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50));CREATE TABLE visits (visit_id INT, vessel_id INT, port_id INT, visit_date DATE); INSERT INTO ports VALUES (1, 'PortA'), (2, 'PortB'), (3, 'PortC'); INSERT INTO vessels VALUES (101, 'VesselX'), (102, 'VesselY'), (103, 'VesselZ');
Identify vessels that visited a specific port ('PortA') more than once in the last 3 months.
SELECT v.vessel_name FROM visits v JOIN ports p ON v.port_id = p.port_id WHERE p.port_name = 'PortA' AND v.visit_date BETWEEN (CURRENT_DATE - INTERVAL '3 months') AND CURRENT_DATE GROUP BY v.vessel_name HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Property_Types (name VARCHAR(50), avg_sqft DECIMAL(5,2)); INSERT INTO Property_Types (name, avg_sqft) VALUES ('Apartment', 800.50), ('Townhouse', 1200.25), ('Single-Family Home', 1800.00);
What is the average square footage for properties in each property type category?
SELECT name, AVG(avg_sqft) FROM Property_Types GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_status (id INT, name VARCHAR(50), status VARCHAR(20), last_contact_date DATE, manufacturer VARCHAR(50)); INSERT INTO satellite_status (id, name, status, last_contact_date, manufacturer) VALUES (1, 'Sat1', 'Active', '2019-01-01', 'Manufacturer1'); INSERT INTO satellite_status (id, name, status, last_contact_date, manufacturer) VALUES (2, 'Sat2', 'Active', '2022-01-01', 'Manufacturer2');
Which is the latest active satellite for each manufacturer in the "satellite_status" table?
SELECT manufacturer, name, last_contact_date FROM (SELECT manufacturer, name, last_contact_date, ROW_NUMBER() OVER (PARTITION BY manufacturer ORDER BY last_contact_date DESC) as row_num FROM satellite_status WHERE status = 'Active') tmp WHERE row_num = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DonationDate DATE);
Delete records of donors who have not donated in the last 2 years from the 'Donors' table
DELETE FROM Donors WHERE DonationDate < DATE_SUB(CURDATE(), INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_projects (project_id INT, year INT, region VARCHAR(255)); INSERT INTO mitigation_projects VALUES (1, 2015, 'Middle East'), (2, 2017, 'Middle East');
How many climate mitigation projects were initiated in the Middle East between 2015 and 2017?
SELECT COUNT(*) FROM mitigation_projects WHERE region = 'Middle East' AND year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, condition VARCHAR(50));
What are the most common mental health conditions treated in adolescents?
SELECT condition, COUNT(patient_id) AS cases_count FROM patients WHERE age BETWEEN 13 AND 19 GROUP BY condition ORDER BY cases_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_data (satellite_id INT, name VARCHAR(100), launch_date DATE, country_of_origin VARCHAR(50), organization VARCHAR(100), function VARCHAR(50));
How many satellites were launched by each organization in the satellite_data table?
SELECT organization, COUNT(*) FROM satellite_data GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (permit_number INT, issuance_date DATE, permit_type VARCHAR(50), state VARCHAR(50)); INSERT INTO Building_Permits VALUES (6789, '2022-03-04', 'New Construction', 'Texas');
List all building permits issued in Texas in the last month, including permit number, issuance date, and type of permit.
SELECT permit_number, issuance_date, permit_type FROM Building_Permits WHERE state = 'Texas' AND issuance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 500.00, '2021-01-01'), (2, 2, 300.00, '2021-02-15'), (3, 3, 800.00, '2021-03-10');
How many individual donors made donations in 2021?
SELECT COUNT(DISTINCT donor_id) FROM donations WHERE YEAR(donation_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicCottonGarments (garment_id INT, production_cost DECIMAL(5,2)); INSERT INTO OrganicCottonGarments (garment_id, production_cost) VALUES (1, 25.50), (2, 30.00), (3, 28.75);
What is the average production cost of garments made from organic cotton?
SELECT AVG(production_cost) FROM OrganicCottonGarments;
gretelai_synthetic_text_to_sql
CREATE TABLE Obesity (State VARCHAR(50), Obesity_Rate FLOAT); INSERT INTO Obesity (State, Obesity_Rate) VALUES ('California', 25.3), ('Texas', 32.4);
What is the obesity rate in the United States by state?
SELECT State, AVG(Obesity_Rate) FROM Obesity GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE winter_olympics (id INT, athlete TEXT, country TEXT, medal TEXT); INSERT INTO winter_olympics (id, athlete, country, medal) VALUES (1, 'Alex Harvey', 'Canada', 'Gold'), (2, 'Justin Kripps', 'Canada', 'Silver'), (3, 'Kaillie Humphries', 'Canada', 'Bronze');
What is the total number of medals won by athletes from Canada in the Winter Olympics?
SELECT SUM(CASE WHEN medal = 'Gold' THEN 1 WHEN medal = 'Silver' THEN 0.5 ELSE 0.25 END) FROM winter_olympics WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists industry (industry_id INT, industry_name TEXT, total_workers INT); INSERT INTO industry (industry_id, industry_name, total_workers) VALUES (1, 'manufacturing', 5000), (2, 'technology', 7000), (3, 'healthcare', 6000);
What is the total number of workers in the 'manufacturing' industry?
SELECT SUM(total_workers) FROM industry WHERE industry_name = 'manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE meals (id INT, name TEXT, gluten_free BOOLEAN, restaurant_type TEXT); INSERT INTO meals (id, name, gluten_free, restaurant_type) VALUES (1, 'Grilled Chicken', true, 'casual dining'), (2, 'Pork Tacos', false, 'casual dining'), (3, 'Vegetable Stir Fry', true, 'casual dining'); CREATE TABLE nutrition (meal_id INT, calorie_count INT); INSERT INTO nutrition (meal_id, calorie_count) VALUES (1, 500), (2, 800), (3, 600);
What is the minimum calorie count for gluten-free meals at casual dining restaurants?
SELECT MIN(nutrition.calorie_count) FROM nutrition JOIN meals ON nutrition.meal_id = meals.id WHERE meals.gluten_free = true AND meals.restaurant_type = 'casual dining';
gretelai_synthetic_text_to_sql
CREATE TABLE Atlantic_Pollution_reports (report_id INTEGER, incident_location TEXT, reported_date DATE); INSERT INTO Atlantic_Pollution_reports (report_id, incident_location, reported_date) VALUES (1, 'Atlantic Ocean', '2021-01-01'), (2, 'Atlantic Ocean', '2021-02-15'), (3, 'Indian Ocean', '2021-03-12');
How many pollution incidents have been reported in the Atlantic ocean?
SELECT COUNT(*) FROM Atlantic_Pollution_reports WHERE incident_location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50), account_balance DECIMAL(10,2)); INSERT INTO customers (id, name, region, account_balance) VALUES (1, 'John Doe', 'New York', 50000.00); INSERT INTO customers (id, name, region, account_balance) VALUES (2, 'Jane Smith', 'Latin America', 60000.00); INSERT INTO customers (id, name, region, account_balance) VALUES (3, 'Bob Johnson', 'APAC', 30000.00); INSERT INTO customers (id, name, region, account_balance) VALUES (4, 'Alice Williams', 'APAC', 40000.00);
What is the number of customers in the 'Latin America' region with a high account balance?
SELECT COUNT(*) FROM customers WHERE region = 'Latin America' AND account_balance > 50000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_tracking (cargo_id INT, cargo_type VARCHAR(50), weight FLOAT); INSERT INTO cargo_tracking (cargo_id, cargo_type, weight) VALUES (1, 'CargoType1', 5000), (2, 'CargoType2', 7000), (3, 'CargoType3', 6000);
What is the minimum weight of a cargo in the 'cargo_tracking' table?
SELECT MIN(weight) FROM cargo_tracking;
gretelai_synthetic_text_to_sql
CREATE TABLE citizens (citizen_id INT PRIMARY KEY, state TEXT, feedback TEXT);CREATE TABLE feedback_categories (feedback_id INT PRIMARY KEY, category TEXT);
List the number of citizens who provided feedback on transportation policies in each state
SELECT c.state, COUNT(c.citizen_id) FROM citizens c INNER JOIN feedback_categories fc ON c.feedback = fc.feedback_id WHERE fc.category = 'Transportation' GROUP BY c.state;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO events (id, name, country) VALUES (1, 'Concert', 'USA'), (2, 'Play', 'Canada'), (3, 'Exhibit', 'USA'), (4, 'Festival', 'Canada'), (5, 'Workshop', 'USA');
Which countries have held the most unique events, and how many events have been held in each?
SELECT country, COUNT(DISTINCT id) FROM events GROUP BY country ORDER BY COUNT(DISTINCT id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE studios (id INT, name VARCHAR(50)); INSERT INTO studios (id, name) VALUES (1, 'Sony Pictures'); CREATE TABLE movies (id INT, title VARCHAR(50), studio_id INT, release_year INT, literacy_score INT); INSERT INTO movies (id, title, studio_id, release_year, literacy_score) VALUES (1, 'Movie 1', 1, 2005, 70), (2, 'Movie 2', 1, 2010, 80), (3, 'Movie 3', 1, 2015, 90);
What is the difference in media literacy scores between the first and last movies released by 'Sony Pictures'?
SELECT (MAX(literacy_score) OVER (PARTITION BY studio_id) - MIN(literacy_score) OVER (PARTITION BY studio_id)) as difference FROM movies WHERE studio_id = (SELECT id FROM studios WHERE name = 'Sony Pictures');
gretelai_synthetic_text_to_sql
CREATE TABLE prices (id INT, product VARCHAR(30), unit VARCHAR(10), price DECIMAL(5,2)); INSERT INTO prices (id, product, unit, price) VALUES (1, 'Salmon', 'pound', 15.99), (2, 'Shrimp', 'pound', 9.99), (3, 'Tuna', 'pound', 19.99), (4, 'West Coast Crab', 'pound', 24.99);
What is the average price of seafood per pound in the West coast?
SELECT AVG(price) FROM prices WHERE product LIKE '%West%' AND unit = 'pound';
gretelai_synthetic_text_to_sql
CREATE TABLE Songs (SongID INT, Title VARCHAR(100), Genre VARCHAR(50), ReleaseDate DATE);
How many streams did songs from the Pop genre receive in 2021?
SELECT SUM(StreamCount) FROM (SELECT StreamCount FROM Songs WHERE Genre = 'Pop' AND YEAR(ReleaseDate) = 2021) AS PopSongs;
gretelai_synthetic_text_to_sql
CREATE TABLE city_feedback (city VARCHAR(255), citizen_id INT, feedback TEXT); INSERT INTO city_feedback
Who provided the most citizen feedback in 'City J'?
SELECT citizen_id, COUNT(*) as feedback_count FROM city_feedback WHERE city = 'City J' GROUP BY citizen_id ORDER BY feedback_count DESC LIMIT 1
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_tracking ( voyage_date DATE, departure_port VARCHAR(255), destination_port VARCHAR(255), cargo_weight INT, vessel_name VARCHAR(255), status VARCHAR(255));
Update the cargo_tracking table and set the status as 'In Transit' for records where the voyage_date is within the last week
UPDATE cargo_tracking SET status = 'In Transit' WHERE voyage_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, fan_age INT); INSERT INTO fan_demographics (fan_id, fan_age) VALUES (1, 25), (2, 45), (3, 17), (4, 67);
How many fans are under 18 and over 65 in the fan_demographics table?
SELECT CASE WHEN fan_age < 18 THEN 'Under 18' ELSE 'Over 65' END as age_group, COUNT(*) as num_fans FROM fan_demographics GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication(project_name TEXT, country TEXT); INSERT INTO climate_communication(project_name, country) VALUES ('Project G', 'Canada'), ('Project H', 'Mexico');
Which countries have no climate communication projects?
SELECT country FROM climate_communication GROUP BY country HAVING COUNT(project_name) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, site_name TEXT, location TEXT, protection_level TEXT); INSERT INTO heritage_sites (id, site_name, location, protection_level) VALUES (1, 'Machu Picchu', 'Peru', 'UNESCO World Heritage Site'), (2, 'Chichen Itza', 'Mexico', 'UNESCO World Heritage Site');
List all heritage sites in South America with their corresponding protection levels.
SELECT site_name, protection_level FROM heritage_sites WHERE location LIKE '%%South America%%';
gretelai_synthetic_text_to_sql
DELETE m FROM maintenance m JOIN vehicles v ON m.vehicle_id = v.vehicle_id WHERE v.vehicle_id = 1; DELETE FROM vehicles WHERE vehicle_id = 1;
Delete the vehicle with vehicle_id 1 from the "vehicles" table and all related maintenance records.
DELETE m FROM maintenance m JOIN vehicles v ON m.vehicle_id = v.vehicle_id WHERE v.vehicle_id = 1; DELETE FROM vehicles WHERE vehicle_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_scores (worker_id INT, score INT, score_date DATE); INSERT INTO cultural_competency_scores (worker_id, score, score_date) VALUES (1, 80, '2021-01-01'), (1, 85, '2021-04-01'), (2, 90, '2021-02-01'), (2, 92, '2021-05-01'), (3, 70, '2021-03-01'), (3, 75, '2021-06-01');
What is the cultural competency score trend for each community health worker in the past year?
SELECT worker_id, score, score_date, LAG(score) OVER (PARTITION BY worker_id ORDER BY score_date) as prev_score FROM cultural_competency_scores;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue_trend (date TEXT, region TEXT, revenue FLOAT); INSERT INTO revenue_trend (date, region, revenue) VALUES ('2021-01-01', 'Africa', 1000), ('2021-01-02', 'Africa', 1500), ('2021-01-03', 'Africa', 1200), ('2021-01-04', 'Africa', 1700), ('2021-01-05', 'Africa', 2000);
What is the daily revenue trend for cultural heritage tours in Africa?
SELECT date, revenue, LAG(revenue, 1) OVER (ORDER BY date) AS previous_day_revenue FROM revenue_trend WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, title TEXT, creation_year INT, art_movement TEXT); INSERT INTO Artworks (artwork_id, title, creation_year, art_movement) VALUES (1, 'Water Lilies', 1906, 'Impressionism'), (2, 'The Persistence of Memory', 1931, 'Surrealism'), (3, 'The Scream', 1893, 'Expressionism');
What are the names of art movements that have more than 15 artworks and their respective total count?
SELECT Artworks.art_movement, COUNT(*) as total_count FROM Artworks GROUP BY Artworks.art_movement HAVING COUNT(*) > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), birth_date DATE, country VARCHAR(50)); INSERT INTO artists (id, name, birth_date, country) VALUES (1, 'Claude Monet', '1840-11-14', 'France'); CREATE TABLE paintings (id INT, artist_id INT, year INT); INSERT INTO paintings (id, artist_id, year) VALUES (1, 1, 1865);
Find the average number of years between the birth of an artist and the creation of their first painting for each country.
SELECT country, AVG(DATEDIFF(year, birth_date, MIN(year))) as avg_age_at_first_painting FROM artists a JOIN paintings p ON a.id = p.artist_id GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_company (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO mining_company (id, name, type) VALUES (1, 'ABC Mining', 'Coal'); INSERT INTO mining_company (id, name, type) VALUES (2, 'XYZ Mining', 'Iron');
What are the total quantities of coal and iron mined by each mining company?
SELECT name, SUM(CASE WHEN type = 'Coal' THEN quantity ELSE 0 END) as coal_quantity, SUM(CASE WHEN type = 'Iron' THEN quantity ELSE 0 END) as iron_quantity FROM mining_operation GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE public.emergency_responses (id serial PRIMARY KEY, state varchar(255), response_time int); INSERT INTO public.emergency_responses (state, response_time) VALUES ('Florida', 100), ('Florida', 110);
What is the minimum emergency response time in the state of Florida?
SELECT MIN(response_time) FROM public.emergency_responses WHERE state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE products_sustainable (product_id INT, product_category VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO products_sustainable (product_id, product_category, is_sustainable) VALUES (1, 'Clothing', true), (2, 'Electronics', false), (3, 'Clothing', true);
What is the percentage of products that are sustainably sourced in each product category?
SELECT product_category, (COUNT(*) FILTER (WHERE is_sustainable = true) OVER (PARTITION BY product_category) * 100.0 / COUNT(*) OVER (PARTITION BY product_category)) as percentage FROM products_sustainable;
gretelai_synthetic_text_to_sql
CREATE TABLE Urbanism_Policies (Property_ID INT, Urbanism_Policy VARCHAR(10)); INSERT INTO Urbanism_Policies (Property_ID, Urbanism_Policy) VALUES (1, 'Yes'), (2, 'No'), (3, 'Yes'), (4, 'No'); CREATE TABLE Properties (Property_ID INT, Urbanism_Policy VARCHAR(10)); INSERT INTO Properties (Property_ID, Urbanism_Policy) VALUES (1, 'Sustainable'), (2, 'Not Sustainable'), (3, 'Sustainable'), (4, 'Not Sustainable');
What is the total number of properties in areas with sustainable urbanism policies?
SELECT COUNT(*) FROM Properties p JOIN Urbanism_Policies up ON p.Property_ID = up.Property_ID WHERE Urbanism_Policy = 'Sustainable';
gretelai_synthetic_text_to_sql
CREATE TABLE ee_sites (id INT, site TEXT, visitors INT, year INT); INSERT INTO ee_sites VALUES (1, 'Auschwitz', 1000, 2022), (2, 'Red Square', 2000, 2022); CREATE TABLE we_sites (id INT, site TEXT, visitors INT, year INT); INSERT INTO we_sites VALUES (1, 'Eiffel Tower', 3000, 2022), (2, 'Colosseum', 4000, 2022);
How many tourists visited historical sites in Eastern Europe and Western Europe in the last year?
SELECT SUM(visitors) FROM ee_sites WHERE year = 2022 UNION ALL SELECT SUM(visitors) FROM we_sites WHERE year = 2022
gretelai_synthetic_text_to_sql
CREATE TABLE patient_treatment (patient_id INT, condition VARCHAR(50), treatment_date DATE); INSERT INTO patient_treatment (patient_id, condition, treatment_date) VALUES (1, 'Depression', '2020-02-14'); INSERT INTO patient_treatment (patient_id, condition, treatment_date) VALUES (2, 'Anxiety', '2019-06-21'); INSERT INTO patient_treatment (patient_id, condition, treatment_date) VALUES (3, 'Depression', '2021-08-05');
What is the earliest and latest treatment date for each patient in the patient_treatment table?
SELECT patient_id, MIN(treatment_date) AS earliest_treatment_date, MAX(treatment_date) AS latest_treatment_date FROM patient_treatment GROUP BY patient_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name TEXT, region TEXT, area FLOAT); INSERT INTO marine_protected_areas (id, name, region, area) VALUES (1, 'Ross Sea Marine Protected Area', 'Southern Ocean', 1594232);
What is the total area (in square kilometers) of marine protected areas in the Southern Ocean?
SELECT SUM(area) FROM marine_protected_areas WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE TouristArrivals (id INT, year INT, country TEXT, num_tourists INT); INSERT INTO TouristArrivals (id, year, country, num_tourists) VALUES (1, 2018, 'Japan', 31000000), (2, 2019, 'Japan', 32000000), (3, 2020, 'Japan', 9000000), (4, 2021, 'Japan', 12000000);
How many international tourists visited Japan in 2020 and 2021?
SELECT SUM(num_tourists) FROM TouristArrivals WHERE country = 'Japan' AND (year = 2020 OR year = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, founding_year INT, founder_race TEXT); INSERT INTO startups VALUES (1, 'Acme Inc', 2018, 'Asian'); INSERT INTO startups VALUES (2, 'Beta Corp', 2019, 'White'); INSERT INTO startups VALUES (3, 'Gamma Start', 2021, 'Black'); INSERT INTO startups VALUES (4, 'Delta Initiative', 2020, 'Latinx'); INSERT INTO startups VALUES (5, 'Epsilon Enterprises', 2017, 'Indigenous');
What is the number of startups founded by individuals from underrepresented racial groups in the last 5 years?
SELECT COUNT(*) FROM startups WHERE founding_year >= YEAR(CURRENT_DATE) - 5 AND founder_race IN ('Black', 'Latinx', 'Indigenous', 'Native Hawaiian', 'Pacific Islander');
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_ships (id INT, name TEXT, capacity INT, last_port TEXT); INSERT INTO cargo_ships (id, name, capacity, last_port) VALUES (1, 'Sealand Pride', 12000, 'New York');
What is the total capacity of cargo ships that have visited port 'New York'?
SELECT SUM(capacity) FROM cargo_ships WHERE last_port = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policy_type VARCHAR(20), issue_date DATE); INSERT INTO policies VALUES (1, 'Home', '2020-01-01'); INSERT INTO policies VALUES (2, 'Auto', '2019-05-15');
What is the total number of policies by policy type?
SELECT policy_type, COUNT(*) as total_policies FROM policies GROUP BY policy_type;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_fuel_efficiency (id INT, country VARCHAR(50), vehicle_type VARCHAR(50), fuel_efficiency FLOAT);
What is the average fuel efficiency of electric vehicles in Japan and South Korea?
SELECT country, AVG(fuel_efficiency) FROM vehicle_fuel_efficiency WHERE country IN ('Japan', 'South Korea') AND vehicle_type = 'electric' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (account_number INT, account_open_date DATE, account_type VARCHAR(50));
How many Shariah-compliant finance accounts were opened in each quarter?
SELECT QUARTER(account_open_date) AS quarter, COUNT(account_number) FROM shariah_compliant_finance WHERE account_type = 'Shariah-compliant' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE CustomerPreferences (CustomerID INT, ProductName VARCHAR(255), PreferenceScore INT); INSERT INTO CustomerPreferences (CustomerID, ProductName, PreferenceScore) VALUES (1, 'Foundation', 80), (2, 'Mascara', 85), (2, 'Lipstick', 70); CREATE TABLE Customers (CustomerID INT, FirstName VARCHAR(255), LastName VARCHAR(255), Email VARCHAR(255), RegistrationDate DATE); INSERT INTO Customers (CustomerID, FirstName, LastName, Email, RegistrationDate) VALUES (1, 'Jessica', 'Smith', 'jessica.smith@gmail.com', '2020-01-01'), (2, 'David', 'Johnson', 'david.johnson@yahoo.com', '2019-01-01');
Update the preference score for mascara to 80 for customer with ID 2.
UPDATE CustomerPreferences SET PreferenceScore = 80 WHERE CustomerID = 2 AND ProductName = 'Mascara';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_research_facilities (id INT, name TEXT, location TEXT, ocean TEXT); INSERT INTO marine_research_facilities (id, name, location, ocean) VALUES (1, 'Palmer Station', 'Antarctica', 'Southern'), (2, 'McMurdo Station', 'Antarctica', 'Southern');
List all marine research facilities in the Southern Ocean.
SELECT * FROM marine_research_facilities WHERE ocean = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE regional_water_savings (id INT, region VARCHAR(30), savings_percentage FLOAT); INSERT INTO regional_water_savings (id, region, savings_percentage) VALUES (1, 'RegionA', 0.15), (2, 'RegionB', 0.12), (3, 'RegionC', 0.18);
What is the percentage of water saved through water conservation initiatives in each region?
SELECT region, savings_percentage FROM regional_water_savings;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department_id INT, department_name TEXT); CREATE TABLE financials (financial_id INT, department_id INT, financial_date DATE, financial_amount FLOAT); INSERT INTO financials (financial_id, department_id, financial_date, financial_amount) VALUES (1, 1, '2023-01-07', 5000.00), (2, 2, '2023-01-20', 8000.00), (3, 3, '2023-01-31', 3000.00);
What was the total financial contribution by each department for Q1 2023?
SELECT department_name, SUM(financial_amount) as total_financial_contribution FROM financials f JOIN departments d ON f.department_id = d.department_id WHERE financial_date BETWEEN '2023-01-01' AND '2023-01-31' GROUP BY department_name;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name TEXT, industry TEXT); INSERT INTO workers (id, name, industry) VALUES (1, 'Alice', 'electronics'), (2, 'Bob', 'textile'); CREATE TABLE training_programs (id INT, worker_id INT, program TEXT); INSERT INTO training_programs (id, worker_id, program) VALUES (1, 1, 'Automation'), (2, 1, 'AI'), (3, 2, 'Automation');
How many workers have been trained in automation in the electronics industry?
SELECT COUNT(*) FROM workers w JOIN training_programs tp ON w.id = tp.worker_id WHERE w.industry = 'electronics' AND tp.program = 'Automation';
gretelai_synthetic_text_to_sql
CREATE TABLE FashionBrands (id INT, name VARCHAR(25)); CREATE TABLE BrandRatings (id INT, brand_id INT, rating INT);
What is the distribution of customer ratings for each fashion brand?
SELECT FashionBrands.name, AVG(BrandRatings.rating) as avg_rating, STDDEV(BrandRatings.rating) as stddev_rating FROM FashionBrands INNER JOIN BrandRatings ON FashionBrands.id = BrandRatings.brand_id GROUP BY FashionBrands.name;
gretelai_synthetic_text_to_sql
CREATE TABLE video_views (id INT, user_id INT, video_id INT, watch_time INT, video_type TEXT, view_date DATE); INSERT INTO video_views (id, user_id, video_id, watch_time, video_type, view_date) VALUES (1, 1, 1, 60, 'educational', '2022-03-01'); INSERT INTO video_views (id, user_id, video_id, watch_time, video_type, view_date) VALUES (2, 2, 2, 90, 'entertainment', '2022-03-03');
What is the total watch time for educational videos in Africa in the last week?
SELECT SUM(watch_time) FROM video_views WHERE video_type = 'educational' AND view_date >= DATEADD(week, -1, GETDATE()) AND country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (VolunteerID INT, Country VARCHAR(50), Activity VARCHAR(50), Hours INT); INSERT INTO VolunteerHours (VolunteerID, Country, Activity, Hours) VALUES (1, 'India', 'Arts and Culture', 70), (2, 'Bangladesh', 'Education', 40), (3, 'Nepal', 'Arts and Culture', 80), (4, 'Pakistan', 'Sports', 60);
What are the top 3 countries with the highest total volunteer hours in arts and culture activities?
SELECT Country, SUM(Hours) AS TotalHours FROM VolunteerHours WHERE Activity = 'Arts and Culture' GROUP BY Country ORDER BY TotalHours DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_2021(drug_name TEXT, quarter INT, year INT, revenue FLOAT); INSERT INTO sales_2021(drug_name, quarter, year, revenue) VALUES('DrugA', 1, 2021, 120000), ('DrugB', 1, 2021, 180000), ('DrugC', 1, 2021, 150000), ('DrugD', 1, 2021, 160000);
What was the total sales revenue for each drug in Q1 2021?
SELECT drug_name, SUM(revenue) FROM sales_2021 WHERE quarter = 1 AND year = 2021 GROUP BY drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Parks( park_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), area FLOAT, created_date DATE); INSERT INTO Parks (park_id, name, location, area, created_date) VALUES (1, 'Central Park', 'NYC', 843.00, '2000-01-01'), (2, 'Prospect Park', 'NYC', 585.00, '2000-01-02'), (3, 'Golden Gate Park', 'San Francisco', 1017.00, '2000-01-03');
Delete the record with park_id 1 from the 'Parks' table
DELETE FROM Parks WHERE park_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists programs (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO programs (id, name, type) VALUES (1, 'Painting', 'Visual Arts'), (2, 'Sculpture', 'Visual Arts'), (3, 'Printmaking', 'Visual Arts'), (4, 'Photography', 'Visual Arts');
What is the total number of visual arts programs?
SELECT COUNT(*) FROM programs WHERE type = 'Visual Arts';
gretelai_synthetic_text_to_sql
CREATE TABLE juvenile_cases (id INT, agency VARCHAR(255), state VARCHAR(255), year INT, cases_handled INT); INSERT INTO juvenile_cases (id, agency, state, year, cases_handled) VALUES (1, 'Dallas PD', 'Texas', 2020, 500), (2, 'Houston PD', 'Texas', 2020, 600), (3, 'Austin PD', 'Texas', 2020, 400);
What is the total number of juvenile cases handled by each law enforcement agency in the state of Texas in 2020?
SELECT agency, SUM(cases_handled) FROM juvenile_cases WHERE state = 'Texas' AND year = 2020 GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name TEXT, immigrant BOOLEAN); INSERT INTO founders (id, name, immigrant) VALUES (1, 'Hugo', TRUE), (2, 'Irene', FALSE), (3, 'Joseph', TRUE), (4, 'Karen', FALSE);
What is the number of startups founded by immigrants?
SELECT COUNT(*) FROM founders WHERE immigrant = TRUE;
gretelai_synthetic_text_to_sql