context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, country VARCHAR(50), news_preference VARCHAR(50)); INSERT INTO readers (id, name, age, country, news_preference) VALUES (1, 'John Doe', 35, 'Canada', 'Sports'), (2, 'Jane Smith', 28, 'Canada', 'Politics'), (3, 'Jim Brown', 45, 'United States', 'Sports'), (4, 'Emma Green', 22, 'United Kingdom', 'Politics');
|
What is the minimum age of readers who prefer political news in the United Kingdom?
|
SELECT MIN(age) FROM readers WHERE country = 'United Kingdom' AND news_preference = 'Politics';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_production (site_name VARCHAR(50), year INT, waste_amount FLOAT); INSERT INTO waste_production (site_name, year, waste_amount) VALUES ('Site A', 2021, 150.5), ('Site A', 2022, 160.7), ('Site B', 2021, 125.7), ('Site B', 2022, 130.5), ('Site C', 2021, 200.3), ('Site C', 2022, 210.9), ('Site D', 2021, 75.9), ('Site D', 2022, 80.1);
|
Calculate the percentage change in chemical waste production per site, year over year.
|
SELECT site_name, ((waste_amount - LAG(waste_amount) OVER (PARTITION BY site_name ORDER BY year))/ABS(LAG(waste_amount) OVER (PARTITION BY site_name ORDER BY year))) * 100 as pct_change FROM waste_production;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExcavationSites (id INT, site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ExcavationSites (id, site_name, country) VALUES (1, 'Old Site', 'Egypt');
|
Update the excavation site name to "New Site" for all records in the "ExcavationSites" table where the country is "Egypt".
|
UPDATE ExcavationSites SET site_name = 'New Site' WHERE country = 'Egypt';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, GenderIdentity VARCHAR(20), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, GenderIdentity, Department) VALUES (1, 'Male', 'IT'), (2, 'Female', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Genderqueer', 'HR'), (5, 'Female', 'Marketing'), (6, 'Transgender', 'HR');
|
How many employees identify as transgender or non-binary and work in the HR department?
|
SELECT COUNT(*) FROM Employees WHERE GenderIdentity IN ('Transgender', 'Non-binary') AND Department = 'HR';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labs (id INT, name VARCHAR(100), location VARCHAR(50)); CREATE TABLE projects (id INT, lab_id INT, name VARCHAR(100), domain VARCHAR(50)); INSERT INTO labs (id, name, location) VALUES (1, 'LabA', 'US'), (2, 'LabB', 'UK'), (3, 'LabC', 'FR'); INSERT INTO projects (id, lab_id, name, domain) VALUES (1, 1, 'Project1', 'Bioinformatics'), (2, 1, 'Project2', 'Bioinformatics'), (3, 1, 'Project3', 'Bioinformatics'), (4, 2, 'Project4', 'Bioinformatics'), (5, 3, 'Project5', 'Bioengineering');
|
List the names and locations of genetic research labs with at least 3 projects in 'Bioinformatics'?
|
SELECT labs.name, labs.location FROM labs INNER JOIN (SELECT lab_id, COUNT(*) as project_count FROM projects WHERE domain = 'Bioinformatics' GROUP BY lab_id) as subquery ON labs.id = subquery.lab_id WHERE subquery.project_count >= 3;
|
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', 2020, 'Black'); INSERT INTO startups VALUES (4, 'Delta Initiative', 2020, 'Latinx');
|
How many startups were founded by underrepresented racial groups in 2020?
|
SELECT COUNT(*) FROM startups WHERE founding_year = 2020 AND founder_race IN ('Black', 'Latinx', 'Indigenous', 'Native Hawaiian', 'Pacific Islander');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (year INT, country VARCHAR(50), vehicle_type VARCHAR(50), quantity INT); INSERT INTO Sales (year, country, vehicle_type, quantity) VALUES (2021, 'USA', 'Electric', 500000);
|
How many electric vehicles were sold in the US in 2021?
|
SELECT SUM(quantity) FROM Sales WHERE year = 2021 AND country = 'USA' AND vehicle_type = 'Electric';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_rounds (company_id INT, round_number INT, funding_amount INT); INSERT INTO funding_rounds (company_id, round_number, funding_amount) VALUES (1, 1, 5000000), (1, 2, 7000000), (1, 3, 10000000), (2, 1, 3000000), (2, 2, 4000000), (3, 1, 9000000), (3, 2, 11000000);
|
What is the difference in funding amount between the latest and earliest round for each company?
|
SELECT company_id, MAX(funding_amount) - MIN(funding_amount) AS funding_difference FROM funding_rounds GROUP BY company_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_ethics (developer VARCHAR(255), principle VARCHAR(255)); INSERT INTO ai_ethics (developer, principle) VALUES ('Microsoft', 'Fairness'), ('Google', 'Accountability'), ('Microsoft', 'Transparency');
|
Delete all records in the 'ai_ethics' table where the 'developer' column is 'Microsoft'
|
DELETE FROM ai_ethics WHERE developer = 'Microsoft';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, post_date DATE); INSERT INTO posts (id, post_date) VALUES (1, '2022-01-02'), (2, '2022-01-03'), (3, '2022-01-03'), (4, '2022-01-05'), (5, '2022-01-06'), (6, '2022-01-07'), (7, '2022-01-08'), (8, '2022-01-09'), (9, '2022-01-10');
|
What is the most common day of the week for posts?
|
SELECT DATEPART(dw, post_date) AS day_of_week, COUNT(*) AS num_posts FROM posts GROUP BY DATEPART(dw, post_date) ORDER BY num_posts DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameReleases (GameID INT, GameType VARCHAR(20), Year INT); INSERT INTO GameReleases (GameID, GameType, Year) VALUES (1, 'VR', 2018);
|
What is the total number of VR games released before 2020?
|
SELECT COUNT(*) FROM GameReleases WHERE GameType = 'VR' AND Year < 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE art_pieces (piece_id INT, title VARCHAR(50), year_created INT, artist_id INT); CREATE TABLE artists (artist_id INT, name VARCHAR(50), age INT, gender VARCHAR(10));
|
Who are the artists who created pieces in the 1960s in the 'art_pieces' table?
|
SELECT artists.name FROM artists JOIN art_pieces ON artists.artist_id = art_pieces.artist_id WHERE art_pieces.year_created BETWEEN 1960 AND 1969;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarineFish (id INT, species VARCHAR(255), weight FLOAT, length FLOAT); INSERT INTO MarineFish (id, species, weight, length) VALUES (1, 'Shark', 350.5, 250.3); INSERT INTO MarineFish (id, species, weight, length) VALUES (2, 'Marlin', 200.3, 300.6); INSERT INTO MarineFish (id, species, weight, length) VALUES (3, 'Tuna', 180.2, 200.7);
|
Show the average length of fish for each species in the 'MarineFish' table
|
SELECT species, AVG(length) FROM MarineFish GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CosmeticsPackaging (product_id INT, weight DECIMAL(5,2), is_plastic BOOLEAN, sales_date DATE, country VARCHAR(50));
|
What is the average weight of plastic packaging used in cosmetics products in the United States in the last year?
|
SELECT AVG(weight) FROM CosmeticsPackaging WHERE is_plastic = TRUE AND sales_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ts_funding_me(initiative VARCHAR(50), funding INT); INSERT INTO ts_funding_me VALUES ('Tech for Peace', 5000000), ('Tech for Refugees', 4000000); CREATE TABLE ts_funding_africa(initiative VARCHAR(50), funding INT); INSERT INTO ts_funding_africa VALUES ('Africa Tech for All', 6000000), ('Tech for Rural Africa', 3000000);
|
List the top 2 technology for social good initiatives in the Middle East and Africa, by total funding.
|
SELECT initiative, SUM(funding) AS total_funding FROM ts_funding_me GROUP BY initiative UNION ALL SELECT initiative, SUM(funding) AS total_funding FROM ts_funding_africa GROUP BY initiative ORDER BY total_funding DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_reduction_practices (id INT, country VARCHAR(50), practice VARCHAR(100), start_date DATE); INSERT INTO waste_reduction_practices (id, country, practice, start_date) VALUES (1, 'India', 'Waste Reduction', '2019-01-01');
|
What is the average expenditure per visitor in Asia for countries that have implemented waste reduction practices since 2019?
|
SELECT AVG(t2.total_expenditure/t2.international_visitors) as avg_expenditure, wrp.country FROM waste_reduction_practices wrp JOIN tourism_spending t2 ON wrp.country = t2.country WHERE t2.year >= YEAR(wrp.start_date) AND t2.continent = 'Asia' GROUP BY wrp.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grant_amounts (id INT, student_id INT, amount DECIMAL(10,2)); INSERT INTO grant_amounts (id, student_id, amount) VALUES (1, 1, 25000.00), (2, 2, 30000.00), (3, 3, 20000.00);
|
What is the total grant amount awarded to graduate students from the 'Sciences' department?
|
SELECT SUM(amount) FROM grant_amounts WHERE student_id IN (SELECT id FROM research_grants WHERE department = 'Sciences');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (id, name, department) VALUES (1, 'John Doe', 'IT'); INSERT INTO employees (id, name, department) VALUES (2, 'Jane Smith', 'HR');
|
List the names of all employees who have the same department as 'Jane Smith'.
|
SELECT e1.name FROM employees e1, employees e2 WHERE e1.department = e2.department AND e2.name = 'Jane Smith';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT PRIMARY KEY, brand_name VARCHAR(255), brand_country VARCHAR(100));
|
Delete all records from the 'brands' table where 'brand_country' is 'France'
|
DELETE FROM brands WHERE brand_country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Neighborhoods (neighborhood_id INT, name VARCHAR(50));CREATE TABLE Units (unit_id INT, neighborhood_id INT, num_bedrooms INT, rent INT);
|
What is the maximum rent for 3-bedroom units in each neighborhood?
|
SELECT n.name, MAX(u.rent) as max_rent FROM Units u JOIN Neighborhoods n ON u.neighborhood_id = n.neighborhood_id WHERE u.num_bedrooms = 3 GROUP BY n.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (article_id INT, author_id INT, title VARCHAR(100), pub_date DATE); CREATE TABLE months (month_name VARCHAR(10)); INSERT INTO months (month_name) VALUES ('January'), ('February'), ('March'), ('April'), ('May'), ('June'), ('July'), ('August'), ('September'), ('October'), ('November'), ('December');
|
Find the total number of articles published in 'articles' table for each month in '2022', with a cross join on 'months' table containing months of the year.
|
SELECT months.month_name, COUNT(articles.article_id) FROM articles CROSS JOIN months WHERE YEAR(articles.pub_date) = 2022 GROUP BY months.month_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (name VARCHAR(255), species VARCHAR(255));
|
What is the total number of species in the marine protected areas?
|
SELECT COUNT(DISTINCT species) FROM marine_protected_areas;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members_ext(id INT, name VARCHAR(50), gender VARCHAR(10), age INT, membership_type VARCHAR(20), wearable_device VARCHAR(20)); INSERT INTO members_ext(id, name, gender, age, membership_type, wearable_device) VALUES (1, 'John Doe', 'Male', 30, 'Gym', 'Smartwatch'), (2, 'Jane Doe', 'Female', 35, 'Swimming', NULL);
|
Get the list of members who have either a gym membership or use wearable technology but not both.
|
SELECT id, name FROM members_ext WHERE (membership_type = 'Gym' AND wearable_device IS NULL) OR (membership_type IS NULL AND wearable_device IS NOT NULL)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport) VALUES (1, 'Usain Bolt', 'Athletics'); INSERT INTO athletes (athlete_id, name, sport) VALUES (2, 'Simone Biles', 'Gymnastics');
|
List the athletes and their sports in the 'athletes' table.
|
SELECT name, sport FROM athletes;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie_financials (id INT, title VARCHAR(255), release_year INT, genre VARCHAR(255), budget INT, gross INT); INSERT INTO movie_financials (id, title, release_year, genre, budget, gross) VALUES (1, 'MovieA', 2015, 'Comedy', 15000000, 45000000), (2, 'MovieB', 2016, 'Action', 25000000, 60000000), (3, 'MovieC', 2017, 'Comedy', 20000000, 50000000), (4, 'MovieD', 2018, 'Drama', 10000000, 30000000), (5, 'MovieE', 2019, 'Comedy', 30000000, 75000000), (6, 'MovieF', 2020, 'Comedy', 22000000, 65000000);
|
Calculate the average budget and total gross for comedy movies released between 2015 and 2020, grouped by release year.
|
SELECT release_year, genre, AVG(budget) AS avg_budget, SUM(gross) AS total_gross FROM movie_financials WHERE genre = 'Comedy' AND release_year BETWEEN 2015 AND 2020 GROUP BY release_year, genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_consumers (consumer_id INT, name TEXT, country TEXT);
|
How many consumers in the 'ethical_consumers' table are from a specific country (e.g., India)?
|
SELECT COUNT(*) FROM ethical_consumers WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rare_earth_elements (id INT, mining_site_id INT, element VARCHAR(255), quantity INT); INSERT INTO rare_earth_elements (id, mining_site_id, element, quantity) VALUES (1, 1, 'Neodymium', 100);
|
What is the average quantity of Neodymium produced by mining sites with more than 10 entries in the rare_earth_elements table, grouped by mining_site_id?
|
SELECT mining_site_id, AVG(quantity) FROM rare_earth_elements WHERE element = 'Neodymium' GROUP BY mining_site_id HAVING COUNT(*) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie (id INT, title VARCHAR(100), director VARCHAR(50), production_budget INT); INSERT INTO movie (id, title, director, production_budget) VALUES (1, 'Inception', 'Christopher Nolan', 160000000);
|
Which director has the highest average budget for their movies, and how many movies have they directed?
|
SELECT director, AVG(production_budget) AS avg_budget, COUNT(*) AS num_movies FROM movie GROUP BY director ORDER BY avg_budget DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (id INT, factory_name VARCHAR(50), region VARCHAR(50)); INSERT INTO Factories (id, factory_name, region) VALUES (1, 'Northeast Factory A', 'Northeast'); INSERT INTO Factories (id, factory_name, region) VALUES (2, 'Northeast Factory B', 'Northeast'); CREATE TABLE Workers (id INT, factory_id INT, name VARCHAR(50), age INT, industry_4_0_training BOOLEAN); INSERT INTO Workers (id, factory_id, name, age, industry_4_0_training) VALUES (1, 1, 'John Doe', 35, TRUE); INSERT INTO Workers (id, factory_id, name, age, industry_4_0_training) VALUES (2, 1, 'Jane Smith', 45, TRUE); INSERT INTO Workers (id, factory_id, name, age, industry_4_0_training) VALUES (3, 2, 'Mike Johnson', 55, FALSE); INSERT INTO Workers (id, factory_id, name, age, industry_4_0_training) VALUES (4, 2, 'Emily Brown', 65, TRUE);
|
Show the number of workers in each age group (0-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, 90-99, 100-109) who have been trained in Industry 4.0 technologies, across factories located in the 'Northeast' region.
|
SELECT FLOOR(Workers.age / 10) * 10 AS age_group, COUNT(Workers.id) FROM Workers INNER JOIN Factories ON Workers.factory_id = Factories.id WHERE Workers.age >= 0 AND Workers.age <= 109 AND Factories.region = 'Northeast' AND Workers.industry_4_0_training = TRUE GROUP BY age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME, content TEXT, hashtags TEXT, network VARCHAR(255)); INSERT INTO posts (id, user_id, timestamp, content, hashtags, network) VALUES (6, 3, '2023-01-25 10:00:00', 'Reduce, reuse, recycle!', '#sustainability', 'environment'), (7, 4, '2023-02-10 15:00:00', 'Climate change is real!', '#climatechange', 'environment');
|
Get the number of posts with hashtags '#sustainability' or '#climatechange' in the 'environment' network for the last 30 days.
|
SELECT COUNT(*) FROM posts WHERE hashtags LIKE '%#sustainability%' OR hashtags LIKE '%#climatechange%' AND network = 'environment' AND timestamp >= NOW() - INTERVAL 30 DAY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_per_area(area_id INT, ocean VARCHAR(255), num_species INT);INSERT INTO marine_species_per_area(area_id, ocean, num_species) VALUES (1, 'Pacific Ocean', 100), (2, 'Pacific Ocean', 120), (3, 'Pacific Ocean', 150), (4, 'Pacific Ocean', 180);
|
What is the average number of marine species per marine protected area in the Pacific Ocean?
|
SELECT AVG(num_species) FROM marine_species_per_area WHERE ocean = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, first_name TEXT, last_name TEXT, donation_amount FLOAT);
|
Insert a new record into the 'donors' table for a donor with the first name 'Clara', last name 'Lee', and a donation amount of 500.00.
|
INSERT INTO donors (first_name, last_name, donation_amount) VALUES ('Clara', 'Lee', 500.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health.therapists (therapist_id INT, first_name VARCHAR(50), last_name VARCHAR(50), gender VARCHAR(50), country VARCHAR(50)); CREATE TABLE mental_health.treatments (treatment_id INT, patient_id INT, therapist_id INT, treatment_type VARCHAR(50), country VARCHAR(50)); INSERT INTO mental_health.therapists (therapist_id, first_name, last_name, gender, country) VALUES (7, 'Anna', 'Schmidt', 'Female', 'Germany'); INSERT INTO mental_health.treatments (treatment_id, patient_id, therapist_id, treatment_type, country) VALUES (8, 1005, 7, 'IPT', 'Germany');
|
Who are the therapists in Germany that provide interpersonal psychotherapy (IPT)?
|
SELECT t.therapist_id, t.first_name, t.last_name FROM mental_health.therapists t JOIN mental_health.treatments tr ON t.therapist_id = tr.therapist_id WHERE tr.treatment_type = 'IPT' AND t.country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_ai (id INT, country VARCHAR(2), project_leader VARCHAR(10)); INSERT INTO ethical_ai (id, country, project_leader) VALUES (1, 'US', 'John'), (2, 'CA', 'Sarah'), (3, 'US', 'Emma'), (4, 'CA', 'Liam');
|
What is the total number of ethical AI projects in the US and Canada, and how many of those are led by women?
|
SELECT COUNT(*) FROM ethical_ai WHERE country IN ('US', 'CA') AND project_leader = 'woman';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Users (id INT, age INT, gender VARCHAR(10)); INSERT INTO Users (id, age, gender) VALUES (1, 27, 'Female'), (2, 31, 'Male'); CREATE TABLE Workouts (id INT, userId INT, heartRate INT, duration INT); INSERT INTO Workouts (id, userId, heartRate, duration) VALUES (1, 1, 145, 30), (2, 1, 150, 45), (3, 2, 160, 60), (4, 2, 155, 40);
|
What is the average heart rate of users aged 25-34 during their workouts?
|
SELECT AVG(heartRate) FROM Workouts JOIN Users ON Workouts.userId = Users.id WHERE Users.age BETWEEN 25 AND 34;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), renewable_energy BOOLEAN); CREATE TABLE employees (employee_id INT, factory_id INT, name VARCHAR(100), position VARCHAR(100), salary INT); INSERT INTO factories (factory_id, name, location, renewable_energy) VALUES (1, 'ABC Factory', 'New York', TRUE), (2, 'XYZ Factory', 'California', FALSE), (3, 'LMN Factory', 'Texas', TRUE); INSERT INTO employees (employee_id, factory_id, name, position, salary) VALUES (1, 1, 'John Doe', 'Engineer', 70000), (2, 1, 'Jane Smith', 'Manager', 80000), (3, 2, 'Mike Johnson', 'Operator', 60000), (4, 3, 'Sara Brown', 'Engineer', 75000);
|
What is the average salary of employees working in factories that use renewable energy sources?
|
SELECT AVG(employees.salary) FROM factories INNER JOIN employees ON factories.factory_id = employees.factory_id WHERE factories.renewable_energy = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(20), assets DECIMAL(10,2)); INSERT INTO customers (id, name, region, assets) VALUES (1, 'John Doe', 'Southwest', 50000.00), (2, 'Jane Smith', 'Northeast', 75000.00);
|
What is the total assets value for customers in region 'Southwest'?
|
SELECT SUM(assets) FROM customers WHERE region = 'Southwest';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA city; CREATE SCHEMA county; CREATE SCHEMA state; CREATE TABLE city.transparency_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE county.transparency_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE state.transparency_data (id INT, name VARCHAR(255), is_open BOOLEAN); INSERT INTO city.transparency_data (id, name, is_open) VALUES (1, 'budget', true), (2, 'council_meetings', true); INSERT INTO county.transparency_data (id, name, is_open) VALUES (1, 'budget', false), (2, 'council_meetings', true); INSERT INTO state.transparency_data (id, name, is_open) VALUES (1, 'budget', true), (2, 'council_meetings', false);
|
Find the total number of open data sets related to transparency in 'city', 'county', and 'state' schemas.
|
SELECT COUNT(*) FROM ( (SELECT * FROM city.transparency_data WHERE is_open = true) UNION (SELECT * FROM county.transparency_data WHERE is_open = true) UNION (SELECT * FROM state.transparency_data WHERE is_open = true) ) AS combined_transparency_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CosmeticsBrands (brand_id INT, brand TEXT, sustainability_score DECIMAL(3,1), uses_recycled_packaging BOOLEAN); INSERT INTO CosmeticsBrands (brand_id, brand, sustainability_score, uses_recycled_packaging) VALUES (1, 'Lush', 4.8, true); CREATE TABLE BrandCountry (brand_id INT, country TEXT); INSERT INTO BrandCountry (brand_id, country) VALUES (1, 'Germany');
|
Find the average sustainability score of cosmetics brands that use recycled packaging in the EU.
|
SELECT AVG(cb.sustainability_score) FROM CosmeticsBrands cb JOIN BrandCountry bc ON cb.brand_id = bc.brand_id WHERE cb.uses_recycled_packaging = true AND bc.country LIKE 'EU%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Streams (location TEXT, genre TEXT, num_streams INTEGER); INSERT INTO Streams (location, genre, num_streams) VALUES ('Texas', 'Pop', 500000), ('Texas', 'Rock', 600000), ('Texas', 'Jazz', 400000);
|
What are the unique genres of music streamed in Texas and the total number of streams for those genres?
|
SELECT DISTINCT genre, SUM(num_streams) as total_streams FROM Streams WHERE location = 'Texas' GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE program (id INT, name VARCHAR(50), start_year INT, end_year INT); INSERT INTO program (id, name, start_year, end_year) VALUES (1, 'Green City Initiative', 2005, 2015), (2, 'Public Art Program', 2008, 2022), (3, 'Safe Streets', 2010, 2020), (4, 'Youth Mentorship', 2018, 2025);
|
What are the names of the programs in the 'government_programs' database that have been active for more than 5 years but less than 10 years?
|
SELECT name FROM program WHERE end_year > 2010 AND start_year < 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, date DATE, disease VARCHAR(20), gender VARCHAR(10)); INSERT INTO cases (case_id, date, disease, gender) VALUES (1, '2020-01-01', 'Tuberculosis', 'Male'), (2, '2020-02-15', 'Tuberculosis', 'Female');
|
What is the number of tuberculosis cases reported by gender?
|
SELECT gender, COUNT(*) as tb_cases_in_2020 FROM cases WHERE date BETWEEN '2020-01-01' AND '2020-12-31' AND disease = 'Tuberculosis' GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ProductInnovationByRegion (ProductID INT, Lab VARCHAR(255), InnovationDate DATETIME, Region VARCHAR(255));
|
How many new products have been developed in the Africa region in the past year?
|
SELECT COUNT(*) FROM ProductInnovationByRegion WHERE Region = 'Africa' AND InnovationDate BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR) AND CURRENT_DATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE art_sales (id INT, art_name VARCHAR(50), artist_nationality VARCHAR(50), price DECIMAL(10, 2));
|
What is the average price of Italian paintings sold at auctions?
|
SELECT AVG(price) as avg_price FROM art_sales WHERE artist_nationality = 'Italian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (ID INT, MissionName VARCHAR(50), Duration INT); INSERT INTO SpaceMissions VALUES (1, 'Apollo 11', 195), (2, 'Apollo 13', 142);
|
What is the minimum duration of a space mission?
|
SELECT MIN(Duration) FROM SpaceMissions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmers (id INT, name TEXT, revenue REAL, country TEXT);
|
Find the number of farmers in each country and the total revenue for each country?
|
SELECT country, COUNT(DISTINCT id) as num_farmers, SUM(revenue) as total_revenue FROM Farmers GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_heart_rates (user_id INT, avg_heart_rate INT);
|
Find the top 3 users with the highest average heart rate during their workouts
|
SELECT user_id, AVG(avg_heart_rate) as avg_heart_rate FROM user_heart_rates GROUP BY user_id ORDER BY avg_heart_rate DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MuseumRevenue (id INT, region VARCHAR(20), year INT, revenue FLOAT); INSERT INTO MuseumRevenue (id, region, year, revenue) VALUES (21, 'South Asia', 2023, 100000); INSERT INTO MuseumRevenue (id, region, year, revenue) VALUES (22, 'South Asia', 2023, 150000);
|
What is the total revenue of museums in South Asia in 2023?
|
SELECT SUM(revenue) FROM MuseumRevenue WHERE region = 'South Asia' AND year = 2023;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Paintings (PaintingID INT, Title VARCHAR(50), ArtistID INT, YearCreated INT); INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated) VALUES (1, 'Starry Night Sketch', 1, 1889);
|
Update the title of the painting with PaintingID 1 to 'The Starry Night'.
|
UPDATE Paintings SET Title = 'The Starry Night' WHERE PaintingID = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (id INT, country VARCHAR(255), sector VARCHAR(255), emissions FLOAT);
|
What is the total CO2 emissions in Canada, and how does it break down by sector?
|
SELECT sector, SUM(emissions) FROM co2_emissions WHERE country = 'Canada' GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City_Districts (name VARCHAR(50), properties_available INT); INSERT INTO City_Districts (name, properties_available) VALUES ('Downtown', 300), ('Uptown', 250), ('Midtown', 400);
|
What is the total number of properties available for co-ownership in each city district?
|
SELECT name, SUM(properties_available) FROM City_Districts GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10), State VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender, State) VALUES (1, 34, 'Female', 'California'), (2, 42, 'Male', 'Texas'), (3, 50, 'Female', 'California'), (4, 48, 'Male', 'New York'), (5, 30, 'Female', 'California'), (6, 45, 'Male', 'Florida'), (7, 55, 'Female', 'New York'), (8, 60, 'Male', 'Texas');
|
What is the difference in average age between community health workers who identify as male and those who identify as female, by state?
|
SELECT State, AVG(CASE WHEN Gender = 'Male' THEN Age END) - AVG(CASE WHEN Gender = 'Female' THEN Age END) as AgeDifference FROM CommunityHealthWorkers WHERE Gender IN ('Male', 'Female') GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shots_per_match (player VARCHAR(100), shots INT); INSERT INTO shots_per_match (player, shots) VALUES ('Serena Williams', 50), ('Venus Williams', 45);
|
What is the average number of shots taken by Serena Williams per tennis match?
|
SELECT AVG(shots) FROM shots_per_match WHERE player = 'Serena Williams';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), min_depth FLOAT); INSERT INTO marine_species (species_id, species_name, min_depth) VALUES (1, 'Spinner Dolphin', 250), (2, 'Clownfish', 10), (3, 'Shark', 100);
|
What is the minimum depth observed for any species in the 'marine_species' table?
|
SELECT MIN(min_depth) FROM marine_species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transactions (TransactionID INT, PlayerID INT, Amount DECIMAL(10, 2), TransactionYear INT); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionYear) VALUES (1, 1, 100, 2019), (2, 2, 150, 2018), (3, 3, 200, 2019), (4, 4, 75, 2019), (5, 5, 250, 2018);
|
What is the total revenue generated by male players in 2019?
|
SELECT SUM(Transactions.Amount) FROM Transactions JOIN Players ON Transactions.PlayerID = Players.PlayerID WHERE Players.Gender = 'Male' AND Transactions.TransactionYear = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE textiles (id SERIAL PRIMARY KEY, product_id INTEGER, fabric_type VARCHAR(20), is_sustainable BOOLEAN, price DECIMAL(5,2)); INSERT INTO textiles (product_id, fabric_type, is_sustainable, price) VALUES (1, 'organic_cotton', true, 15.00), (2, 'polyester', false, 10.00), (3, 'recycled_polyester', true, 12.00), (4, 'hemp', true, 20.00), (5, 'silk', false, 30.00);
|
Determine the average price of sustainable textiles
|
SELECT AVG(price) FROM textiles WHERE is_sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_count INT, has_funding_over_1m BOOLEAN); INSERT INTO companies (id, name, industry, founder_count, has_funding_over_1m) VALUES (1, 'GreenTech', 'Clean Energy', 2, true); INSERT INTO companies (id, name, industry, founder_count, has_funding_over_1m) VALUES (2, 'EduCode', 'EdTech', 1, false); CREATE TABLE funds (company_id INT, funding_amount INT); INSERT INTO funds (company_id, funding_amount) VALUES (1, 1500000); INSERT INTO funds (company_id, funding_amount) VALUES (2, 600000);
|
How many founders are there in companies that have received funding over 1M?
|
SELECT COUNT(*) FROM companies WHERE has_funding_over_1m = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO Restaurants (id, name, type) VALUES (1, 'Green Garden', 'Vegan'); INSERT INTO Restaurants (id, name, type) VALUES (2, 'Bistro Bella', 'Italian'); INSERT INTO Restaurants (id, name, type) VALUES (3, 'Taqueria Tina', 'Mexican'); INSERT INTO Restaurants (id, name, type) VALUES (4, 'Sushi Bar', 'Asian'); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), price DECIMAL(5,2), organic BOOLEAN); INSERT INTO Menu (id, restaurant_id, dish, price, organic) VALUES (1, 1, 'Quinoa Salad', 12.99, true); INSERT INTO Menu (id, restaurant_id, dish, price, organic) VALUES (2, 1, 'Tofu Stir Fry', 14.50, false);
|
What is the minimum price of organic dishes in Asian restaurants?
|
SELECT MIN(price) FROM Menu WHERE organic = true AND restaurant_id IN (SELECT id FROM Restaurants WHERE type LIKE '%Asian%');
|
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, 1500, 'education', '2020-10-15'); CREATE TABLE donors (donor_id INT, donor_name TEXT); INSERT INTO donors (donor_id, donor_name) VALUES (1, 'Jane Smith');
|
What is the total number of donors who have donated to education or human rights causes in H2 2020?
|
SELECT COUNT(DISTINCT donors.donor_id) FROM donations JOIN donors ON donations.donor_id = donors.donor_id WHERE cause IN ('education', 'human rights') AND donation_date BETWEEN '2020-07-01' AND '2020-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_positions (id INT, satellite_name VARCHAR(50), latitude DECIMAL(8,4), longitude DECIMAL(8,4), altitude INT, timestamp TIMESTAMP);
|
Identify potential satellite collisions in the next 7 days?
|
SELECT a.satellite_name, b.satellite_name, TIMESTAMPDIFF(DAY, a.timestamp, b.timestamp) AS days_difference FROM satellite_positions a JOIN satellite_positions b ON a.satellite_name != b.satellite_name WHERE ABS(a.latitude - b.latitude) < 0.001 AND ABS(a.longitude - b.longitude) < 0.001 AND ABS(a.altitude - b.altitude) < 10 AND TIMESTAMPDIFF(DAY, a.timestamp, b.timestamp) BETWEEN 0 AND 7;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT, sport VARCHAR(20), price DECIMAL(5,2)); INSERT INTO games (id, sport, price) VALUES (1, 'Basketball', 120.50); INSERT INTO games (id, sport, price) VALUES (2, 'Soccer', 35.00); INSERT INTO games (id, sport, price) VALUES (3, 'Soccer', 42.30);
|
Delete all records related to soccer from the games table.
|
DELETE FROM games WHERE sport = 'Soccer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE banks (id INT PRIMARY KEY, bank_name VARCHAR(255), region_id INT); CREATE TABLE shariah_compliance (id INT PRIMARY KEY, bank_id INT, certification_date DATE); CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE VIEW bank_views AS SELECT banks.bank_name, shariah_compliance.certification_date, regions.country FROM banks INNER JOIN shariah_compliance ON banks.id = shariah_compliance.bank_id INNER JOIN regions ON banks.region_id = regions.id;
|
List the names of financial institutions in Canada that have been certified as Shariah-compliant and the certification dates.
|
SELECT bank_views.bank_name, bank_views.certification_date FROM bank_views WHERE bank_views.country = 'Canada' AND bank_views.certification_date IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Social_Good_Orgs (Org_Name VARCHAR(50), Completed_Projects INT);
|
List the top 3 organizations working on technology for social good in Asia by the number of projects they have completed.
|
SELECT Org_Name, RANK() OVER(ORDER BY Completed_Projects DESC) as Rank FROM Social_Good_Orgs WHERE Continent = 'Asia' GROUP BY Org_Name HAVING COUNT(*) >= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists agroecology; use agroecology; CREATE TABLE agroecology_projects (id INT, name TEXT, location TEXT); CREATE TABLE organizations (id INT, name TEXT, project_id INT); INSERT INTO agroecology_projects (id, name, location) VALUES (1, 'Project 7', 'City O'), (2, 'Project 8', 'City P'); INSERT INTO organizations (id, name, project_id) VALUES (1, 'Org 7', 1), (2, 'Org 8', 2);
|
List all agroecology projects in the 'agroecology' schema, along with their associated organization names and locations.
|
SELECT agroecology_projects.name, organizations.name, agroecology_projects.location FROM agroecology.agroecology_projects INNER JOIN agroecology.organizations ON agroecology_projects.id = organizations.project_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (country VARCHAR(50), year INT, population INT, waste_amount INT);
|
What is the waste generation amount for each country in 'waste_generation'?
|
SELECT country, SUM(waste_amount) as total_waste_amount FROM waste_generation GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workers (id INT, factory_id INT, country VARCHAR(50), hourly_wage DECIMAL(4,2));CREATE TABLE Factories (id INT, name VARCHAR(50), certification VARCHAR(20)); INSERT INTO Workers (id, factory_id, country, hourly_wage) VALUES (1, 1001, 'Bangladesh', 2.50), (2, 1002, 'Cambodia', 2.25), (3, 1003, 'India', 2.75), (4, 1004, 'Vietnam', 2.10); INSERT INTO Factories (id, name, certification) VALUES (1001, 'Green Valley', 'fair_trade'), (1002, 'Eco Fields', 'not_certified'), (1003, 'Sustainable Peak', 'fair_trade'), (1004, 'Fast Fashion Inc', 'not_certified');
|
List the number of workers and their average hourly wage per country, for factories with 'fair_trade' certification.
|
SELECT country, AVG(hourly_wage) as avg_wage, COUNT(DISTINCT id) as worker_count FROM Workers JOIN Factories ON Workers.factory_id = Factories.id WHERE certification = 'fair_trade' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (dish_id INT, dish VARCHAR(50), category VARCHAR(50), calories INT);CREATE TABLE categories (category_id INT, category VARCHAR(50));
|
What are the total calories of the dishes in the appetizer category?
|
SELECT c.category, SUM(d.calories) as total_calories FROM dishes d JOIN categories c ON d.category = c.category WHERE c.category = 'appetizer' GROUP BY c.category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BridgeCosts (State TEXT, Year INTEGER, ConstructionCost REAL); INSERT INTO BridgeCosts (State, Year, ConstructionCost) VALUES ('Florida', 2015, 1800000.0), ('Florida', 2016, 1900000.0), ('Florida', 2017, 2000000.0), ('Florida', 2018, 2100000.0), ('Florida', 2019, 2200000.0), ('Florida', 2020, 2300000.0), ('Georgia', 2015, 1850000.0), ('Georgia', 2016, 1950000.0), ('Georgia', 2017, 2050000.0), ('Georgia', 2018, 2150000.0), ('Georgia', 2019, 2250000.0), ('Georgia', 2020, 2350000.0), ('South Carolina', 2015, 1900000.0), ('South Carolina', 2016, 2000000.0), ('South Carolina', 2017, 2100000.0), ('South Carolina', 2018, 2200000.0), ('South Carolina', 2019, 2300000.0), ('South Carolina', 2020, 2400000.0);
|
What was the total construction cost for bridge projects in Florida, Georgia, and South Carolina from 2015 to 2020?
|
SELECT State, SUM(ConstructionCost) as TotalCost FROM BridgeCosts WHERE State IN ('Florida', 'Georgia', 'South Carolina') GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers_gender (teacher_id INT, region VARCHAR(20), event_attended BOOLEAN, gender VARCHAR(10)); INSERT INTO teachers_gender (teacher_id, region, event_attended, gender) VALUES (1, 'North', true, 'Female'), (2, 'North', false, 'Male'), (3, 'South', true, 'Female');
|
What is the percentage of teachers who attended a professional development event in each region, broken down by gender?
|
SELECT region, gender, 100.0 * AVG(event_attended) as percentage FROM teachers_gender GROUP BY region, gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE historical_sites (id INT, name VARCHAR(255), city VARCHAR(255)); CREATE TABLE preservation_funding (id INT, site_id INT, funding_year INT); INSERT INTO historical_sites (id, name, city) VALUES (1, 'Statue of Liberty', 'New York City'), (2, 'Ellis Island', 'New York City'), (3, 'Federal Hall', 'New York City'), (4, 'Castle Clinton', 'New York City'); INSERT INTO preservation_funding (id, site_id, funding_year) VALUES (1, 1, 2012), (2, 1, 2015), (3, 1, 2018), (4, 2, 2013), (5, 2, 2016), (6, 2, 2019), (7, 3, 2014), (8, 3, 2017), (9, 3, 2020), (10, 4, 2015), (11, 4, 2018), (12, 4, 2021);
|
How many historical sites in New York City have received funding for preservation in the last decade, broken down by year?
|
SELECT f.funding_year, COUNT(*) FROM preservation_funding f JOIN historical_sites s ON f.site_id = s.id WHERE s.city = 'New York City' AND f.funding_year BETWEEN YEAR(CURRENT_DATE) - 10 AND YEAR(CURRENT_DATE) GROUP BY f.funding_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), policyholder_state VARCHAR(20)); INSERT INTO claims (policyholder_id, claim_amount, policyholder_state) VALUES (1, 500.00, 'New York'), (2, 600.00, 'New York'), (3, 700.00, 'New York');
|
What is the average claim amount paid to policyholders in 'New York'?
|
SELECT AVG(claim_amount) FROM claims WHERE policyholder_state = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, district VARCHAR(20), participated_in_llp BOOLEAN, year INT); INSERT INTO students (student_id, district, participated_in_llp, year) VALUES (1, 'Riverside', TRUE, 2021), (2, 'Riverside', FALSE, 2021), (3, 'Riverside', TRUE, 2021);
|
What is the percentage of students in the "Riverside" school district who participated in lifelong learning programs last year?
|
SELECT (COUNT(*) FILTER (WHERE participated_in_llp = TRUE)) * 100.0 / COUNT(*) FROM students WHERE district = 'Riverside' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Project_Timeline (id INT, project VARCHAR(30), phase VARCHAR(20), start_date DATE, end_date DATE, labor_cost FLOAT, is_sustainable BOOLEAN); INSERT INTO Project_Timeline (id, project, phase, start_date, end_date, labor_cost, is_sustainable) VALUES (1, 'Green Tower', 'Planning', '2021-05-01', '2021-07-31', 50000.00, true), (2, 'Solar Park', 'Design', '2021-01-01', '2021-03-31', 35000.00, false), (3, 'Wind Farm', 'Construction', '2022-06-01', '2022-09-30', 30000.00, true);
|
What is the average labor cost for sustainable projects?
|
SELECT AVG(labor_cost) FROM Project_Timeline WHERE is_sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_tech (tech_name VARCHAR(255), year INT, budget INT, region VARCHAR(255)); INSERT INTO military_tech (tech_name, year, budget, region) VALUES ('Stealth Fighter Jet', 2010, 200000000, 'Asia-Pacific'), ('Cyber Security System', 2015, 150000000, 'Asia-Pacific');
|
Showcase the number of military technologies developed per year and their corresponding budget in the Asia-Pacific region
|
SELECT year, SUM(budget) FROM military_tech WHERE region = 'Asia-Pacific' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menus(menu_name VARCHAR(255),item_name VARCHAR(255),price DECIMAL(5,2));INSERT INTO Menus(menu_name,item_name,price) VALUES('Brunch','Organic Avocado Toast',10.00),('Lunch','Chicken Caesar Wrap',8.50);
|
Update the 'price' of 'Organic Avocado Toast' to '12.50' in the 'Brunch' menu.
|
UPDATE Menus SET price = 12.50 WHERE menu_name = 'Brunch' AND item_name = 'Organic Avocado Toast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (ExhibitionID INT, Exhibition VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Exhibition) VALUES (1, 'Modern Art'), (2, 'Classic Art'); CREATE TABLE Visits (VisitID INT, VisitorID INT, ExhibitionID INT, InstallationID INT); INSERT INTO Visits (VisitID, VisitorID, ExhibitionID, InstallationID) VALUES (1, 1, 1, 1), (2, 2, 1, NULL), (3, 3, 2, 3);
|
What is the percentage of visitors who engaged with installations, partitioned by exhibition?
|
SELECT Exhibition, COUNT(VisitorID) * 100.0 / (SELECT COUNT(DISTINCT VisitorID) FROM Visits V2 WHERE V2.ExhibitionID = V.ExhibitionID) AS EngagementPercentage FROM Visits V GROUP BY ExhibitionID, Exhibition;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spanish_farms (farmer_id INT, fish_species TEXT, stocking_density FLOAT); INSERT INTO spanish_farms (farmer_id, fish_species, stocking_density) VALUES (1, 'Tuna', 2.5), (2, 'Sardines', 1.8), (3, 'Tuna', 2.0);
|
What is the minimum stocking density of Tuna in Spanish farms?
|
SELECT MIN(stocking_density) FROM spanish_farms WHERE fish_species = 'Tuna';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE program_categories (id INT, category VARCHAR(50), impact INT); INSERT INTO program_categories (id, category, impact) VALUES (1, 'Education', 200), (2, 'Healthcare', 300), (3, 'Environment', 150);
|
What was the total program impact by program category in H1 2023?
|
SELECT category, SUM(impact) FROM program_categories WHERE category IN ('Education', 'Healthcare', 'Environment') GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MusicSales (SaleID INT, Genre VARCHAR(10), SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID, Genre, SalesAmount) VALUES (1, 'Jazz', 12.99), (2, 'Rock', 15.00), (3, 'Pop', 19.45);
|
What is the total revenue generated from digital music sales in the Jazz genre?
|
SELECT SUM(SalesAmount) FROM MusicSales WHERE Genre = 'Jazz';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factory_scores (id INT, factory_id INT, score INT, date DATE); INSERT INTO factory_scores (id, factory_id, score, date) VALUES (1, 1, 80, '2022-01-01'), (2, 2, 90, '2022-01-03'), (3, 1, 85, '2022-02-01');
|
Calculate the average ethical manufacturing score for each factory in Q1 2022.
|
SELECT factory_id, AVG(score) as avg_score FROM factory_scores WHERE DATE_FORMAT(date, '%Y-%m') BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY factory_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE esports_events (id INT, year INT, region VARCHAR(20), revenue INT); INSERT INTO esports_events (id, year, region, revenue) VALUES (1, 2018, 'North America', 1000000), (2, 2019, 'Europe', 2000000), (3, 2020, 'Asia', 1500000), (4, 2021, 'Oceania', 2500000);
|
What is the total revenue generated by esports events in Asia and Oceania?
|
SELECT SUM(revenue) FROM esports_events WHERE region IN ('Asia', 'Oceania');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artist (id INT, name VARCHAR(100)); CREATE TABLE song (id INT, title VARCHAR(100), artist_id INT, genre VARCHAR(50), collaboration VARCHAR(100)); INSERT INTO artist (id, name) VALUES (1, 'Artist1'); INSERT INTO song (id, title, artist_id, genre, collaboration) VALUES (1, 'Song1', 1, 'Pop', 'Artist2');
|
Who are the top 5 music artists with the most number of songs, including collaborations, in the Pop genre?
|
SELECT artist.name, COUNT(*) as song_count FROM artist INNER JOIN song ON artist.id = song.artist_id WHERE song.genre = 'Pop' GROUP BY artist.name ORDER BY song_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, model VARCHAR(100), manufacturer VARCHAR(100), year_manufactured INT); CREATE TABLE flight_safety (id INT PRIMARY KEY, aircraft_model VARCHAR(100), manufacturer VARCHAR(100), severity VARCHAR(50), report_date DATE);
|
List all aircraft models and their manufacturers from the aircraft_manufacturing table that have never had a safety incident recorded in the flight_safety table
|
SELECT aircraft_manufacturing.model, aircraft_manufacturing.manufacturer FROM aircraft_manufacturing LEFT JOIN flight_safety ON aircraft_manufacturing.model = flight_safety.aircraft_model WHERE flight_safety.id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicles (id INT, city VARCHAR(20), type VARCHAR(20), is_electric BOOLEAN, daily_distance INT); INSERT INTO vehicles VALUES (1, 'tokyo', 'sedan', true, 30); INSERT INTO vehicles VALUES (2, 'tokyo', 'suv', true, 40); INSERT INTO vehicles VALUES (3, 'osaka', 'truck', false, 50);
|
What is the minimum distance traveled by an electric vehicle in 'tokyo'?
|
SELECT MIN(daily_distance) FROM vehicles WHERE city = 'tokyo' AND is_electric = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE publications (title VARCHAR(50), journal VARCHAR(50), year INT, student_id INT); INSERT INTO publications VALUES ('Paper1', 'Journal of Computer Science', 2020, 123); CREATE TABLE students (student_id INT, name VARCHAR(50), program VARCHAR(50)); INSERT INTO students VALUES (123, 'Jane Smith', 'Graduate');
|
List all unique journals where graduate students have published in the last 3 years.
|
SELECT DISTINCT journal FROM publications p JOIN students s ON p.student_id = s.student_id WHERE program = 'Graduate' AND year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), DonorType varchar(50), AmountDonated float); INSERT INTO Donors (DonorID, DonorName, Country, DonorType, AmountDonated) VALUES (1, 'John Doe', 'USA', 'Individual', 15000.00), (2, 'Jane Smith', 'Canada', 'Individual', 20000.00), (3, 'African Corporation', 'Africa', 'Corporation', 40000.00);
|
What is the total amount donated by corporations in Africa in 2020?
|
SELECT SUM(AmountDonated) FROM Donors WHERE Country = 'Africa' AND YEAR(DonationDate) = 2020 AND DonorType = 'Corporation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (ManufacturerID INT, Name VARCHAR(50)); INSERT INTO Manufacturers (ManufacturerID, Name) VALUES (1, 'Boeing'), (2, 'Lockheed Martin'); CREATE TABLE Aircraft (AircraftID INT, ManufacturerID INT, Status VARCHAR(20)); INSERT INTO Aircraft (AircraftID, ManufacturerID, Status) VALUES (1, 1, 'Active'), (2, 1, 'Maintenance'), (3, 2, 'Active');
|
What is the total number of military aircraft by manufacturer, including those currently under maintenance?
|
SELECT M.Name, COUNT(A.AircraftID) as Total FROM Manufacturers M LEFT JOIN Aircraft A ON M.ManufacturerID = A.ManufacturerID GROUP BY M.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, school_type VARCHAR(50), score INT); INSERT INTO student_mental_health (student_id, school_type, score) VALUES (1, 'Private', 75), (2, 'Public', 80), (3, 'Private', 70);
|
What is the average mental health score for students in private and public schools?
|
SELECT school_type, AVG(score) as avg_score FROM student_mental_health GROUP BY school_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, location VARCHAR(255), year INT, completed BOOLEAN);
|
What is the total number of community development projects completed in Africa in the past decade?
|
SELECT SUM(completed) FROM community_development WHERE location LIKE '%Africa%' AND completed = TRUE AND year > (SELECT MAX(year) FROM community_development WHERE location LIKE '%Africa%' AND completed = TRUE) - 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE driver (driver_id INT, driver_name TEXT);CREATE TABLE fare (fare_id INT, driver_id INT, fare_amount DECIMAL); INSERT INTO driver (driver_id, driver_name) VALUES (1, 'Driver1'), (2, 'Driver2'), (3, 'Driver3'), (4, 'Driver4'), (5, 'Driver5'); INSERT INTO fare (fare_id, driver_id, fare_amount) VALUES (1, 1, 5.00), (2, 1, 5.00), (3, 2, 3.00), (4, 2, 3.00), (5, 3, 2.00), (6, 3, 2.00), (7, 4, 8.00), (8, 5, 6.00);
|
Who is the driver with the lowest average fare?
|
SELECT d.driver_name, AVG(f.fare_amount) as avg_fare FROM driver d JOIN fare f ON d.driver_id = f.driver_id GROUP BY d.driver_id ORDER BY avg_fare ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AgriculturalInnovations (id INT PRIMARY KEY, name VARCHAR(100), year INT); INSERT INTO AgriculturalInnovations (id, name, year) VALUES (1, 'Precision Agriculture', 2018), (2, 'Vertical Farming', 2020), (3, 'Genetic Engineering', 2019), (4, 'Drone Pollination', 2021);
|
What are the names of all agricultural innovation projects initiated in 2020 or later?
|
SELECT name FROM AgriculturalInnovations WHERE year >= 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50)); CREATE TABLE voyages (id INT, vessel_id INT, start_port_id INT, end_port_id INT, distance FLOAT, travel_time FLOAT, voyage_date DATE);
|
Find the total number of hours spent at sea, grouped by vessel and month.
|
SELECT v.vessel_name, DATE_FORMAT(voyages.voyage_date, '%Y-%m') as time_period, SUM(voyages.travel_time) as total_hours_at_sea FROM vessels JOIN voyages ON vessels.vessel_id = voyages.vessel_id GROUP BY v.vessel_name, time_period;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE open_pedagogy_resources (resource_id INT, access_date DATE); INSERT INTO open_pedagogy_resources (resource_id, access_date) VALUES (1, '2021-12-01'), (2, '2021-12-02'), (3, '2021-12-03');
|
What is the total number of open pedagogy resources accessed in 'Winter 2021'?
|
SELECT COUNT(DISTINCT resource_id) FROM open_pedagogy_resources WHERE access_date = '2021-12-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(20)); INSERT INTO wells (well_id, well_name, region) VALUES (1, 'Well A', 'onshore'); INSERT INTO wells (well_id, well_name, region) VALUES (2, 'Well B', 'offshore'); INSERT INTO wells (well_id, well_name, region) VALUES (3, 'Well C', 'antarctic');
|
How many wells are there in the 'antarctic' region in 2025?
|
SELECT COUNT(*) FROM wells WHERE region = 'antarctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm2Table (supplier_id INT, product_id INT); CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(50)); CREATE TABLE Products (product_id INT, product_name VARCHAR(50)); CREATE TABLE EcoLabels (eco_label_id INT, eco_label VARCHAR(50)); CREATE TABLE ProductEcoLabels (product_id INT, eco_label_id INT); INSERT INTO Suppliers (supplier_id, supplier_name) VALUES (1, 'Local Farm'), (2, 'Small Dairy'), (3, 'Free Range Ranch'); INSERT INTO Products (product_id, product_name) VALUES (1, 'Eggs'), (2, 'Milk'), (3, 'Beef'), (4, 'Chicken'); INSERT INTO Farm2Table (supplier_id, product_id) VALUES (1, 1), (1, 3), (2, 2), (2, 4), (3, 3); INSERT INTO EcoLabels (eco_label_id, eco_label) VALUES (1, 'Free Range'), (2, 'Grass Fed'), (3, 'Conventional'), (4, 'Certified Organic'); INSERT INTO ProductEcoLabels (product_id, eco_label_id) VALUES (1, 1), (2, 3), (3, 2), (3, 1), (4, 3);
|
List all suppliers and their associated products in 'Farm2Table', along with their eco-labels if applicable?
|
SELECT s.supplier_name, p.product_name, el.eco_label FROM Suppliers s INNER JOIN Farm2Table ft ON s.supplier_id = ft.supplier_id INNER JOIN Products p ON ft.product_id = p.product_id INNER JOIN ProductEcoLabels pel ON p.product_id = pel.product_id INNER JOIN EcoLabels el ON pel.eco_label_id = el.eco_label_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artifacts (id INT, excavation_site_name VARCHAR(255), artifact_type VARCHAR(255), artifact_weight FLOAT);
|
What is the distribution of artifact weights for pottery and stone tools found at the "Grand Canyon" excavation site?
|
SELECT artifact_type, AVG(artifact_weight) AS avg_weight FROM artifacts WHERE excavation_site_name = 'Grand Canyon' AND artifact_type IN ('pottery', 'stone_tool') GROUP BY artifact_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meals (id INT, name VARCHAR(255), country VARCHAR(255), avg_calories FLOAT, supplier_id INT);
|
Find the top 3 most caloric meals and their suppliers.
|
SELECT m.name, m.country, m.supplier_id, AVG(m.avg_calories) as avg_calories FROM meals m GROUP BY m.name, m.country, m.supplier_id ORDER BY avg_calories DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE removal (id INT, year INT, mineral TEXT, quantity INT); INSERT INTO removal (id, year, mineral, quantity) VALUES (1, 2014, 'Mineral X', 600); INSERT INTO removal (id, year, mineral, quantity) VALUES (2, 2015, 'Mineral Y', 800);
|
What is the total quantity of mineral Y extracted in Year 2015?
|
SELECT SUM(quantity) FROM removal WHERE year = 2015 AND mineral = 'Mineral Y';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerAchievements (AchievementID SERIAL PRIMARY KEY, PlayerID INT, AchievementName VARCHAR(100), AchievementDate DATE);
|
Create a table for tracking player achievements
|
INSERT INTO PlayerAchievements (PlayerID, AchievementName, AchievementDate) VALUES (1, 'Level 10 Reached', '2022-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE continent (continent_id INT, name VARCHAR(50)); INSERT INTO continent (continent_id, name) VALUES (1, 'Asia'), (2, 'South America'); CREATE TABLE year (year_id INT, year INT); INSERT INTO year (year_id, year) VALUES (1, 2020), (2, 2019); CREATE TABLE supplies (supply_id INT, type VARCHAR(50), continent_id INT, year_id INT, quantity INT); INSERT INTO supplies (supply_id, type, continent_id, year_id, quantity) VALUES (1, 'Food', 2, 1, 800), (2, 'Water', 2, 1, 600), (3, 'Medical', 1, 1, 1000);
|
How many disaster relief supplies were sent to 'South America' in the year 2020?
|
SELECT SUM(quantity) FROM supplies WHERE continent_id = 2 AND year_id = 1;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.