context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), mission_year INT, launch_country VARCHAR(50));
How many countries have successfully launched a space mission?
SELECT COUNT(DISTINCT launch_country) FROM space_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE Employee_Training (Employee_ID INT, Employee_Name VARCHAR(50), Department VARCHAR(50), Training_Type VARCHAR(50), Hours_Spent DECIMAL(5,2)); INSERT INTO Employee_Training (Employee_ID, Employee_Name, Department, Training_Type, Hours_Spent) VALUES (6, 'Alex Johnson', 'Marketing', 'Diversity and Inclusion', 5.00), (7, 'Taylor Lee', 'Marketing', 'Diversity and Inclusion', 4.00), (8, 'Jasmine Brown', 'Marketing', 'Cybersecurity', 7.00);
What is the average number of training hours for employees in the 'Marketing' department who have completed diversity and inclusion training?
SELECT AVG(Hours_Spent) FROM Employee_Training WHERE Department = 'Marketing' AND Training_Type = 'Diversity and Inclusion';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, country VARCHAR(255), asset_value DECIMAL(10,2));
What is the sum of all Shariah-compliant finance assets for the Middle East region?
SELECT SUM(asset_value) FROM shariah_compliant_finance WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE MarineSpecies (id INT, species VARCHAR(255), location VARCHAR(255)); INSERT INTO MarineSpecies (id, species, location) VALUES (1, 'Whale Shark', 'Indian Ocean'); INSERT INTO MarineSpecies (id, species, location) VALUES (2, 'Olive Ridley Turtle', 'Indian Ocean');
List all marine species in the Indian Ocean.
SELECT species FROM MarineSpecies WHERE location = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, launch_company VARCHAR(50));
How many space missions have been conducted by China in the last decade?
SELECT COUNT(*) FROM space_missions WHERE launch_company = 'China' AND launch_date >= DATE_SUB(CURDATE(), INTERVAL 10 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_materials (material_id INT, material VARCHAR(20), production_cost DECIMAL(10,2));
List all sustainable materials used in the manufacturing process with their associated production costs.
SELECT * FROM sustainable_materials;
gretelai_synthetic_text_to_sql
CREATE TABLE training_completed (id INT, employee_id INT, department VARCHAR(50), hours_trained INT);
What is the maximum number of hours of training completed by an employee in the HR department?
SELECT MAX(hours_trained) FROM training_completed WHERE department = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE ports(id INT, name VARCHAR(50), type VARCHAR(50), region VARCHAR(50)); CREATE TABLE cargo_handling(port_id INT, cargo_type VARCHAR(50), tonnage INT, handling_date DATE); INSERT INTO ports VALUES (1, 'Port of Santos', 'Seaport', 'Atlantic'); INSERT INTO cargo_handling VALUES (1, 'Fresh Fruits', 6000, '2022-03-15');
Which ports have handled more than 5000 tons of perishable goods in the last month?
SELECT ports.name FROM ports INNER JOIN cargo_handling ON ports.id = cargo_handling.port_id WHERE ports.region = 'Atlantic' AND cargo_type = 'Perishable' AND tonnage > 5000 AND cargo_handling.handling_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY ports.name HAVING COUNT(DISTINCT cargo_type) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), race VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO community_health_workers (id, name, race, salary) VALUES (1, 'John Doe', 'White', 60000.00), (2, 'Jane Smith', 'Black', 55000.00), (3, 'Jim Brown', 'Hispanic', 72000.00);
What is the total salary of community health workers by race?
SELECT race, SUM(salary) FROM community_health_workers GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE audience_demographics (id INT, country VARCHAR(50), age INT, engagement INT);INSERT INTO audience_demographics (id, country, age, engagement) VALUES (1, 'United States', 35, 80);INSERT INTO audience_demographics (id, country, age, engagement) VALUES (2, 'Brazil', 45, 95);
Which countries have the highest and lowest audience demographics engagement with climate change related news?
SELECT country, engagement FROM audience_demographics WHERE category = 'climate change' ORDER BY engagement DESC LIMIT 1;SELECT country, engagement FROM audience_demographics WHERE category = 'climate change' ORDER BY engagement ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE epl_stats (team TEXT, passes INT); INSERT INTO epl_stats (team, passes) VALUES ('Manchester City', 718), ('Liverpool', 694), ('Chelsea', 643);
What is the average number of passes per game in the 2022-2023 English Premier League?
SELECT AVG(passes) as avg_passes FROM epl_stats;
gretelai_synthetic_text_to_sql
CREATE TABLE CropYield (region VARCHAR(255), farming_method VARCHAR(255), yield INT); INSERT INTO CropYield (region, farming_method, yield) VALUES ('United States', 'Organic', 120), ('United States', 'Non-Organic', 150), ('Canada', 'Organic', 130), ('Canada', 'Non-Organic', 145);
Find the difference in crop yield between organic and non-organic farming methods in the United States.
SELECT farming_method, AVG(yield) FROM CropYield WHERE region = 'United States' GROUP BY farming_method;
gretelai_synthetic_text_to_sql
CREATE TABLE NationalSecurityThreats (Threat VARCHAR(50), Department VARCHAR(50)); INSERT INTO NationalSecurityThreats (Threat, Department) VALUES ('Terrorism', 'Department of Homeland Security'), ('Cyber Threats', 'Department of Defense'), ('Espionage', 'Federal Bureau of Investigation'), ('Transnational Organized Crime', 'Department of Justice'), ('Weapons of Mass Destruction', 'Central Intelligence Agency');
What are the unique national security threats and their respective departments?
SELECT Threat, Department FROM NationalSecurityThreats;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, product VARCHAR(255), is_recyclable BOOLEAN, has_natural_ingredients BOOLEAN, sales_amount DECIMAL(10, 2)); INSERT INTO products (id, product, is_recyclable, has_natural_ingredients, sales_amount) VALUES (1, 'Moisturizer', true, true, 25.99), (2, 'Cleanser', false, false, 15.99), (3, 'Serum', true, true, 35.99), (4, 'Toner', true, false, 12.99), (5, 'Scrub', false, true, 22.99);
Insert a new product 'Cream' with recyclable package, natural ingredients, and sales amount $400.00.
INSERT INTO products (product, is_recyclable, has_natural_ingredients, sales_amount) VALUES ('Cream', true, true, 400.00);
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, viewership INT); INSERT INTO tv_shows (id, title, release_year, viewership) VALUES (1, 'TVShowA', 2018, 5000000); INSERT INTO tv_shows (id, title, release_year, viewership) VALUES (2, 'TVShowB', 2019, 6000000); INSERT INTO tv_shows (id, title, release_year, viewership) VALUES (3, 'TVShowC', 2017, 4000000);
What's the release year and viewership count for the TV show with the highest viewership?
SELECT release_year, viewership FROM tv_shows ORDER BY viewership DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans (id INT, org_id INT, country VARCHAR(50), loan_amount DECIMAL(10,2)); INSERT INTO socially_responsible_loans (id, org_id, country, loan_amount) VALUES (1, 101, 'USA', 5000.00), (2, 101, 'USA', 7000.00), (3, 102, 'Canada', 3000.00), (4, 102, 'Canada', 4000.00), (5, 103, 'Mexico', 6000.00);
What is the total amount of socially responsible loans issued by each organization?
SELECT org_id, SUM(loan_amount) FROM socially_responsible_loans GROUP BY org_id;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (mission_id INT, name VARCHAR(50), agency VARCHAR(50), launch_date DATE); INSERT INTO SpaceMissions (mission_id, name, agency, launch_date) VALUES (1, 'Apollo 11', 'NASA', '1969-07-16'), (2, 'Shenzhou 7', 'CNSA', '2008-09-25'), (3, 'Mars Orbiter Mission', 'ISRO', '2013-11-05'), (4, 'Galileo', 'ESA', '1989-10-18'), (5, 'Vostok 1', 'Roscosmos', '1961-04-12');
What is the total number of space missions by each space agency?
SELECT agency, COUNT(mission_id) as total_missions FROM SpaceMissions GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), chatbot VARCHAR(50), rating FLOAT); INSERT INTO hotels (hotel_id, name, chatbot, rating) VALUES (1, 'Hotel X', 'Model A', 4.5), (2, 'Hotel Y', 'Model B', 4.2), (3, 'Hotel Z', 'Model A', 4.7), (4, 'Hotel W', 'Model C', 4.3), (5, 'Hotel V', 'Model A', 4.6), (6, 'Hotel U', 'Model D', 4.9);
What are the AI chatbot models with adoption count higher than 20, used by hotels in the hotels table and their average ratings?
SELECT chatbot, COUNT(hotel_id) as adoption_count, AVG(rating) as avg_rating FROM hotels GROUP BY chatbot HAVING adoption_count > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_id INT, region VARCHAR(255), funding_source VARCHAR(255)); INSERT INTO deep_sea_expeditions (expedition_id, region, funding_source) VALUES (1, 'Atlantic', 'National Science Foundation'), (2, 'Pacific', 'National Geographic');
Show the number of deep-sea expeditions in the Atlantic Ocean funded by the National Science Foundation.
SELECT COUNT(*) FROM deep_sea_expeditions WHERE region = 'Atlantic' AND funding_source = 'National Science Foundation';
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, hotel_type TEXT, agency TEXT, revenue FLOAT, booking_date DATE); INSERT INTO bookings (id, hotel_type, agency, revenue, booking_date) VALUES (1, 'Luxury', 'Expedia', 500, '2022-01-03'), (2, 'Economy', 'Booking.com', 300, '2022-01-05');
What is the total revenue from online travel agencies for luxury hotels in the last quarter?
SELECT SUM(revenue) FROM bookings WHERE hotel_type = 'Luxury' AND booking_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) AND agency IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50));
What is the average age of male and female readers?
SELECT gender, AVG(age) FROM readers GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policy_holder_name VARCHAR(50), policy_state VARCHAR(2)); INSERT INTO policies (policy_id, policy_holder_name, policy_state) VALUES (1001, 'John Smith', 'CA'), (1002, 'Jane Doe', 'NY'), (1003, 'Mike Johnson', 'CA');
How many policies were issued for customers living in 'California'?
SELECT COUNT(*) FROM policies WHERE policy_state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE solana_network (digital_asset_name TEXT, trading_volume DECIMAL(18,2), transaction_date DATE, network_name TEXT);
What is the monthly trading volume of the top 3 digital assets on the 'Solana' network in the last year?
SELECT DATE_TRUNC('month', transaction_date) as month, digital_asset_name, SUM(trading_volume) as monthly_trading_volume FROM solana_network WHERE network_name = 'Solana' AND digital_asset_name IN (SELECT digital_asset_name FROM solana_network GROUP BY digital_asset_name ORDER BY SUM(trading_volume) DESC LIMIT 3) AND transaction_date >= CURRENT_DATE - INTERVAL '1 year' GROUP BY month, digital_asset_name ORDER BY month, SUM(trading_volume) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, name VARCHAR(255), genre VARCHAR(255), playtime INT); INSERT INTO games (id, name, genre, playtime) VALUES (1, 'Game1', 'Shooter', 600), (2, 'Game2', 'RPG', 300), (3, 'Game3', 'Shooter', 1000), (4, 'Game4', 'RPG', 500), (5, 'Game5', 'Strategy', 700);
List the number of players who have played a game in each genre, ordered by the number of players in descending order.
SELECT genre, COUNT(DISTINCT id) as num_players FROM games GROUP BY genre ORDER BY num_players DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Jordan (id INT, name TEXT, type TEXT, location TEXT); INSERT INTO Jordan (id, name, type, location) VALUES (1, 'Center A', 'Health', 'Amman'); INSERT INTO Jordan (id, name, type, location) VALUES (2, 'Center B', 'Community', 'Irbid'); INSERT INTO Jordan (id, name, type, location) VALUES (3, 'Center C', 'Health', 'Zarqa');
What is the total number of health and community centers in Jordan, ordered by center type?
SELECT type, COUNT(*) AS center_count FROM Jordan GROUP BY type ORDER BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) VALUES (3, 'Sea Otter', 'Kelp Forest', 50.0);
Identify the maximum depth a marine species can live at?
SELECT MAX(depth) FROM species;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID int, ProductName varchar(50), ProductType varchar(50), Size int, Price decimal(5,2)); INSERT INTO Products (ProductID, ProductName, ProductType, Size, Price) VALUES (1, 'Eco Skinny Jeans', 'Women', 8, 65); INSERT INTO Products (ProductID, ProductName, ProductType, Size, Price) VALUES (2, 'Green Straight Leg Jeans', 'Women', 10, 70);
Find the average price per size for women's jeans in size 8, for all brands, and display the top 5 results.
SELECT AVG(Price) as AvgPrice, ProductType FROM Products WHERE ProductType = 'Women' AND Size = 8 GROUP BY ProductType ORDER BY AvgPrice DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives(region VARCHAR(20), year INT, initiative VARCHAR(50)); INSERT INTO conservation_initiatives VALUES ('California', 2015, 'Water rationing'), ('California', 2016, 'Mandatory water restrictions'), ('Nevada', 2017, 'Smart irrigation systems'), ('Nevada', 2018, 'Water-saving appliances'), ('Arizona', 2019, 'Greywater reuse'), ('Arizona', 2020, 'Drought-tolerant landscaping');
List the water conservation initiatives implemented in regions affected by severe droughts since 2015, ordered by region.
SELECT * FROM conservation_initiatives WHERE year >= 2015 AND region IN ('California', 'Nevada', 'Arizona') ORDER BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Waste (id INT, chemical_name VARCHAR(255), date DATE, quantity INT); INSERT INTO Waste (id, chemical_name, date, quantity) VALUES (1, 'Hydrochloric Acid', '2022-01-04', 25); INSERT INTO Waste (id, chemical_name, date, quantity) VALUES (2, 'Sulfuric Acid', '2022-01-06', 30); INSERT INTO Waste (id, chemical_name, date, quantity) VALUES (3, 'Nitric Acid', '2022-01-07', 40);
What is the maximum quantity of waste produced per day for each chemical?
SELECT chemical_name, MAX(quantity) as max_quantity FROM Waste GROUP BY chemical_name;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.satellites (id INT PRIMARY KEY, launch_year INT, country VARCHAR(50), name VARCHAR(50)); INSERT INTO aerospace.satellites (id, launch_year, country, name) VALUES (1, 2000, 'USA', 'Sat1'), (2, 2001, 'USA', 'Sat2'), (3, 2002, 'China', 'Sat3');
What is the number of satellites deployed per year?
SELECT launch_year, COUNT(*) as total_satellites FROM aerospace.satellites GROUP BY launch_year;
gretelai_synthetic_text_to_sql
CREATE TABLE retailers(retailer_id INT, name TEXT, last_audit_date DATE); INSERT INTO retailers(retailer_id, name, last_audit_date) VALUES (101, 'Fair Trade Co', '2020-05-01'), (102, 'Eco-Friendly Inc', '2021-08-12'), (103, 'Green Products Ltd', NULL), (104, 'Sustainable Goods Inc', '2022-02-28');
Delete retailers that have not been audited for ethical labor practices in the last 3 years
DELETE FROM retailers WHERE last_audit_date < (CURRENT_DATE - INTERVAL '3 years');
gretelai_synthetic_text_to_sql
CREATE TABLE student (student_id INT); INSERT INTO student (student_id) VALUES (1), (2), (3); CREATE TABLE teacher (teacher_id INT); INSERT INTO teacher (teacher_id) VALUES (101), (102), (103);
What is the total number of students and teachers in the 'Education' database?
SELECT COUNT(*) FROM student; SELECT COUNT(*) FROM teacher;
gretelai_synthetic_text_to_sql
CREATE TABLE Temperature (id INT, sensor_id INT, temperature DECIMAL(5,2), location VARCHAR(255)); INSERT INTO Temperature (id, sensor_id, temperature, location) VALUES (1, 1010, 40.1, 'RU-Krasnodar Krai');
What is the maximum temperature reading for all IoT sensors in "RU-Krasnodar Krai" and "UA-Crimea"?
SELECT MAX(temperature) FROM Temperature WHERE location IN ('RU-Krasnodar Krai', 'UA-Crimea');
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name TEXT, advisor TEXT, num_grants INT); INSERT INTO graduate_students (id, name, advisor, num_grants) VALUES (1, 'Charlie', 'Alice', 3); INSERT INTO graduate_students (id, name, advisor, num_grants) VALUES (2, 'David', 'Bob', 1);
List the top 5 graduate students with the highest number of research grants awarded in the past year, along with their advisors.
SELECT name, advisor FROM graduate_students ORDER BY num_grants DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (id INT, name TEXT, country TEXT, type TEXT, rooms INT, revenue INT); INSERT INTO Hotels (id, name, country, type, rooms, revenue) VALUES (1, 'Eco Hotel', 'Japan', 'Eco', 40, 20000);
What is the total revenue generated by hotels with less than 50 rooms in Tokyo?
SELECT SUM(revenue) FROM Hotels WHERE country = 'Japan' AND type = 'Eco' AND rooms < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE themes (id INT, article_id INT, topic VARCHAR(255));
Which topics were the most frequently published in the 'themes' table?
SELECT topic, COUNT(*) as articles_about_topic FROM themes GROUP BY topic ORDER BY articles_about_topic DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE wearable_data (id INT, member_id INT, hr INT, timestamp TIMESTAMP); CREATE VIEW avg_hr_by_day AS SELECT member_id, DATE(timestamp) day, AVG(hr) avg_hr FROM wearable_data GROUP BY member_id, day;
What is the average heart rate for each member in the past 3 days?
SELECT member_id, AVG(avg_hr) OVER (PARTITION BY member_id ORDER BY day ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) moving_avg FROM avg_hr_by_day;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchStations (station_name TEXT, location TEXT); INSERT INTO ResearchStations (station_name, location) VALUES ('Amundsen-Scott South Pole Station', 'Antarctic'), ('Ny-Ålesund Research Station', 'Arctic');
What are the names of all marine research stations in the Arctic and Antarctic regions?
SELECT station_name FROM ResearchStations WHERE location IN ('Arctic', 'Antarctic');
gretelai_synthetic_text_to_sql
CREATE TABLE Sales_Channels (channel_id INT, channel_name VARCHAR(50)); INSERT INTO Sales_Channels (channel_id, channel_name) VALUES (1, 'Online'), (2, 'Retail'), (3, 'Wholesale'); CREATE TABLE Sales_Channel_Revenue (sale_id INT, channel_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO Sales_Channel_Revenue (sale_id, channel_id, sale_date, revenue) VALUES (1, 1, '2022-04-01', 5000), (2, 2, '2022-04-02', 6000), (3, 1, '2022-05-01', 7000), (4, 2, '2022-05-02', 8000);
What was the total revenue for the 'Online' sales channel in Q2 2022?
SELECT S.channel_name, SUM(R.revenue) as total_revenue FROM Sales_Channel_Revenue R JOIN Sales_Channels S ON R.channel_id = S.channel_id WHERE S.channel_name = 'Online' AND R.sale_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY S.channel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name VARCHAR(20)); ALTER TABLE Visitors ADD COLUMN country_id INT, age INT; CREATE TABLE Event_Attendance (visitor_id INT, event_id INT);
What is the average age of visitors who attended events in Mexico?
SELECT AVG(Visitors.age) FROM Visitors JOIN Countries ON Visitors.country_id = Countries.id JOIN Event_Attendance ON Visitors.id = Event_Attendance.visitor_id WHERE Countries.name = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (id INT, patientID INT, condition VARCHAR(50), treatment VARCHAR(50), cost DECIMAL(5,2)); INSERT INTO MentalHealthParity (id, patientID, condition, treatment, cost) VALUES (1, 1001, 'Anxiety', 'Counseling', 80.00), (2, 1002, 'Depression', 'Medication', 100.00);
What is the total cost of mental health treatments for patients with anxiety?
SELECT patientID, SUM(cost) as 'TotalCost' FROM MentalHealthParity WHERE condition = 'Anxiety';
gretelai_synthetic_text_to_sql
CREATE TABLE movie_releases (title VARCHAR(255), release_year INT, genre VARCHAR(50), rating DECIMAL(3,2)); INSERT INTO movie_releases (title, release_year, genre, rating) VALUES ('Movie1', 2020, 'Action', 7.5), ('Movie2', 2020, 'Comedy', 8.2), ('Movie3', 2020, 'Drama', 6.8);
What are the top 3 genres by average rating for movies released in 2020?
SELECT genre, AVG(rating) avg_rating FROM movie_releases WHERE release_year = 2020 GROUP BY genre ORDER BY avg_rating DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE risk_assessments (id INT, region VARCHAR(255), risk_score INT); INSERT INTO risk_assessments (id, region, risk_score) VALUES (1, 'Middle East', 75); INSERT INTO risk_assessments (id, region, risk_score) VALUES (2, 'Asia', 50); INSERT INTO risk_assessments (id, region, risk_score) VALUES (5, 'Europe', 45); INSERT INTO risk_assessments (id, region, risk_score) VALUES (6, 'Europe', 48);
Calculate the average geopolitical risk score for the 'Europe' region in the 'risk_assessments' table
SELECT AVG(risk_score) FROM risk_assessments WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (permit_id INT, material_cost FLOAT, permit_state VARCHAR(20), permit_date DATE); INSERT INTO Permits (permit_id, material_cost, permit_state, permit_date) VALUES (1, 5000, 'California', '2022-01-01'), (2, 6000, 'California', '2022-01-15'), (3, 5500, 'California', '2022-03-01');
What is the average cost of sustainable building materials for permits issued in California in Q1 2022?
SELECT AVG(material_cost) FROM Permits WHERE permit_state = 'California' AND permit_date >= '2022-01-01' AND permit_date < '2022-04-01' AND material_cost > 0 AND permit_id IN (SELECT permit_id FROM Permits WHERE permit_state = 'California' AND permit_date >= '2022-01-01' AND permit_date < '2022-04-01' AND material_cost > 0 GROUP BY permit_id HAVING COUNT(*) = 1);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_race TEXT); INSERT INTO company (id, name, founding_year, founder_race) VALUES (1, 'EbonyTech', 2012, 'Black or African American'); INSERT INTO company (id, name, founding_year, founder_race) VALUES (2, 'Beta', 2015, 'White');
Find the maximum funding amount for startups founded by Black or African American entrepreneurs
SELECT MAX(funding_amount) FROM investment_rounds ir INNER JOIN company c ON ir.company_id = c.id WHERE c.founder_race = 'Black or African American';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (initiative_name VARCHAR(255), region VARCHAR(255)); INSERT INTO climate_communication (initiative_name, region) VALUES ('Public Awareness Campaign', 'Africa'), ('Educational Workshops', 'Asia'), ('Community Outreach Program', 'Africa');
How many climate communication initiatives have been implemented in Africa?
SELECT COUNT(*) FROM climate_communication WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Missions (ID INT, Mission_Name VARCHAR(255), Max_Altitude FLOAT); INSERT INTO Space_Missions (ID, Mission_Name, Max_Altitude) VALUES (1, 'Apollo 11', 363300);
What is the maximum altitude reached by any spacecraft in the Space_Missions table?
SELECT MAX(Max_Altitude) FROM Space_Missions;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, animal_name VARCHAR(255), preserve_name VARCHAR(255));
What is the maximum number of animals in the habitat_preservation table that have been relocated to a single preserve?
SELECT preserve_name, MAX(COUNT(animal_name)) FROM habitat_preservation GROUP BY preserve_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CultivatorStrains (cultivator_id INT, strain_name TEXT, PRIMARY KEY (cultivator_id, strain_name));
List the names of the top 5 cultivators with the highest number of unique strains.
SELECT cultivator_id, COUNT(DISTINCT strain_name) as unique_strains FROM CultivatorStrains GROUP BY cultivator_id ORDER BY unique_strains DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas_atlantic (area_name VARCHAR(255), min_depth DECIMAL(10,2), max_depth DECIMAL(10,2)); INSERT INTO marine_protected_areas_atlantic (area_name, min_depth, max_depth) VALUES ('Azores Nature Park', 25.00, 50.65), ('Bermuda Park', 50.00, 100.20), ('Galapagos Marine Reserve', 15.00, 300.00);
Which marine protected areas in the Atlantic Ocean have an average depth between 50 and 100 meters?
SELECT area_name FROM marine_protected_areas_atlantic WHERE min_depth BETWEEN 50.00 AND 100.00 AND max_depth BETWEEN 50.00 AND 100.00;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_activity_table (user_id INT, posts_per_day INT, date DATE); INSERT INTO daily_activity_table (user_id, posts_per_day, date) VALUES (1, 15, '2021-01-01'), (2, 22, '2021-01-01'), (3, 10, '2021-01-01'), (1, 25, '2021-01-02');
What is the maximum number of posts by a user in the "daily_activity_table"?
SELECT MAX(posts_per_day) FROM daily_activity_table;
gretelai_synthetic_text_to_sql
CREATE TABLE RecycledPolyesterGarments (id INT PRIMARY KEY, production_date DATE, sale_date DATE, sale_location VARCHAR(20)); INSERT INTO RecycledPolyesterGarments (id, production_date, sale_date, sale_location) VALUES (1, '2020-01-01', '2020-06-01', 'United States'), (2, '2020-03-15', '2020-11-28', 'Canada'), (3, '2019-12-20', '2021-02-03', 'United States');
How many garments made of recycled polyester were sold in the United States in the last year?
SELECT COUNT(*) FROM RecycledPolyesterGarments WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND sale_location = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE social_media(user_id INT, user_name VARCHAR(50), region VARCHAR(50), post_date DATE, hashtags BOOLEAN, likes INT);
Show the number of posts with and without hashtags in the 'social_media' table, for users in 'Asia'.
SELECT SUM(hashtags) as posts_with_hashtags, SUM(NOT hashtags) as posts_without_hashtags FROM social_media WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, state TEXT);CREATE TABLE employees (employee_id INT, employee_name TEXT, site_id INT, employee_type TEXT);
What is the total number of employees and contractors working in mining sites located in California and Texas?
SELECT SUM(e.employee_type = 'employee') AS total_employees, SUM(e.employee_type = 'contractor') AS total_contractors FROM employees e INNER JOIN mining_sites s ON e.site_id = s.site_id WHERE s.state IN ('California', 'Texas');
gretelai_synthetic_text_to_sql
CREATE TABLE news_stories (story_id INT, title VARCHAR(100), description TEXT, reporter_id INT); CREATE TABLE news_reporters (reporter_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), hire_date DATE);
List all news stories from the 'news_stories' table and their corresponding reporter names from the 'news_reporters' table.
SELECT news_stories.title, news_reporters.name FROM news_stories INNER JOIN news_reporters ON news_stories.reporter_id = news_reporters.reporter_id;
gretelai_synthetic_text_to_sql
CREATE TABLE copper_mine (site_id INT, country VARCHAR(50), num_employees INT, extraction_date DATE, quantity INT); INSERT INTO copper_mine (site_id, country, num_employees, extraction_date, quantity) VALUES (1, 'Africa', 65, '2018-01-02', 1500), (2, 'Africa', 55, '2018-12-31', 1700), (3, 'Africa', 70, '2018-03-04', 2100);
Calculate the maximum daily production quantity of copper for mining sites in Africa, for the year 2018, with over 50 employees.
SELECT country, MAX(quantity) as max_daily_copper_prod FROM copper_mine WHERE num_employees > 50 AND country = 'Africa' AND extraction_date >= '2018-01-01' AND extraction_date <= '2018-12-31' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, location TEXT, mental_health_score INT); INSERT INTO community_health_workers (id, name, location, mental_health_score) VALUES (1, 'David', 'California', 85), (2, 'Ella', 'Texas', 80), (3, 'Finn', 'California', 90);
What is the average mental health score for community health workers in California, ordered by their score?
SELECT location, AVG(mental_health_score) AS avg_mental_health_score FROM community_health_workers WHERE location IN ('California') GROUP BY location ORDER BY avg_mental_health_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (piece_id INT, title VARCHAR(50), year_created INT, artist_id INT); CREATE TABLE time_dim (date DATE, quarter_name VARCHAR(10));
How many art pieces were added to the 'art_pieces' table in Q1 2022?
SELECT COUNT(piece_id) FROM art_pieces JOIN time_dim ON art_pieces.year_created = time_dim.date WHERE time_dim.quarter_name = 'Q1' AND time_dim.date >= '2022-01-01' AND time_dim.date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE LaborCosts (CostID int, ProjectID int, LaborCost money, Date date, IsSustainable bit); CREATE TABLE Projects (ProjectID int, ProjectName varchar(255), State varchar(255), StartDate date, EndDate date);
What is the average labor cost per sustainable project in Washington State?
SELECT AVG(LaborCost) as AvgLaborCost FROM LaborCosts JOIN Projects ON LaborCosts.ProjectID = Projects.ProjectID WHERE State = 'Washington' AND IsSustainable = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, company_name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO companies (company_id, company_name, industry, founding_year, founder_gender) VALUES (1, 'BioWomen', 'Biotech', 2013, 'Female');
How many companies in the biotech sector were founded by women or non-binary individuals in the past decade?
SELECT COUNT(*) FROM companies WHERE industry = 'Biotech' AND (founder_gender = 'Female' OR founder_gender IS NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE mlb_hitters (hitter_id INT, hitter_name VARCHAR(50), position VARCHAR(10), season INT, home_runs INT); INSERT INTO mlb_hitters (hitter_id, hitter_name, position, season, home_runs) VALUES (1, 'Rickey Henderson', 'LF', 1985, 2), (2, 'Tim Raines', 'LF', 1983, 4);
What is the lowest number of home runs hit by a player in a single season in MLB, by position?
SELECT position, MIN(home_runs) FROM mlb_hitters GROUP BY position;
gretelai_synthetic_text_to_sql
CREATE TABLE factory (id INT, name TEXT, sector TEXT, country TEXT); INSERT INTO factory (id, name, sector, country) VALUES (1, 'FactoryA', 'automotive', 'France'), (2, 'FactoryB', 'aerospace', 'France'), (3, 'FactoryC', 'electronics', 'Germany'); CREATE TABLE production (factory_id INT, output REAL); INSERT INTO production (factory_id, output) VALUES (1, 1000), (1, 1200), (2, 1500), (3, 1800), (2, 2000), (2, 2200), (1, 1300);
What is the total production output for factories in the 'automotive' sector?
SELECT SUM(production.output) FROM production INNER JOIN factory ON production.factory_id = factory.id WHERE factory.sector = 'automotive';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, destination TEXT, usage INT); INSERT INTO virtual_tours (tour_id, tour_name, destination, usage) VALUES (1, 'Machu Picchu Virtual Tour', 'Peru', 15000), (2, 'Iguazu Falls Virtual Tour', 'Brazil', 12000), (3, 'Galapagos Islands Virtual Tour', 'Ecuador', 18000);
List the top 5 most popular tourist destinations in South America based on virtual tour usage.
SELECT destination, SUM(usage) as total_usage FROM virtual_tours GROUP BY destination ORDER BY total_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founder_id INT); INSERT INTO company (id, name, founder_id) VALUES (1, 'Acme Inc', 101), (2, 'Beta Corp', 102), (3, 'Gamma PLC', 103), (4, 'Delta Co', 104); CREATE TABLE investment (id INT, company_id INT, round INT); INSERT INTO investment (id, company_id, round) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 1), (4, 3, 1), (5, 3, 2), (6, 4, 1);
Identify the number of unique founders who have founded companies that have had at least two investment rounds.
SELECT COUNT(DISTINCT founder_id) FROM company WHERE id IN (SELECT company_id FROM investment GROUP BY company_id HAVING COUNT(DISTINCT round) >= 2)
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ai (hotel_id INT, hotel_location TEXT, ai_adoption_date DATE); INSERT INTO hotel_ai (hotel_id, hotel_location, ai_adoption_date) VALUES (1, 'Hotel South America', '2021-12-15'), (2, 'Hotel South America', '2022-02-01');
Hotel AI adoption rate in 'South America'?
SELECT (SUM(CASE WHEN ai_adoption_date IS NOT NULL THEN 1 ELSE 0 END) / COUNT(*)) * 100 AS adoption_rate FROM hotel_ai WHERE hotel_location = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID int, Name varchar(50), TotalBilling decimal(10,2)); INSERT INTO Attorneys (AttorneyID, Name, TotalBilling) VALUES (1, 'John Smith', 5000.00), (2, 'Jane Doe', 7000.00);
What is the total billing amount for each attorney, ordered from highest to lowest?
SELECT Name, TotalBilling FROM Attorneys ORDER BY TotalBilling DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE auto_shows (year INT, location VARCHAR(255), count INT); INSERT INTO auto_shows (year, location, count) VALUES (2019, 'Tokyo', 2), (2019, 'New York', 1);
How many auto shows took place in Tokyo in 2019?
SELECT count FROM auto_shows WHERE year = 2019 AND location = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE imagery_sensors (sensor_id INT, sensor_type VARCHAR(255), last_used_date DATE); INSERT INTO imagery_sensors (sensor_id, sensor_type, last_used_date) VALUES (1, 'visible', '2022-02-15'), (2, 'infrared', '2021-12-28'), (3, 'multispectral', '2022-03-05'), (4, 'hyperspectral', '2021-11-01');
Which satellite imagery analysis sensors have been used in Australia in the past year?
SELECT imagery_sensors.sensor_type FROM imagery_sensors WHERE imagery_sensors.last_used_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND imagery_sensors.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE inspections (inspection_id INT, restaurant_id INT, inspection_date DATE, violation_count INT);
Delete records of food safety inspections with violation_count equal to 0
DELETE FROM inspections WHERE violation_count = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT PRIMARY KEY, school_name TEXT, school_type TEXT, country TEXT, built_date DATE); INSERT INTO schools (id, school_name, school_type, country, built_date) VALUES (1, 'Primary School', 'Public', 'Afghanistan', '2020-01-01');
How many schools have been built per country in 2020 and 2021?
SELECT country, COUNT(*) as schools_built FROM schools WHERE built_date >= '2020-01-01' AND built_date < '2022-01-01' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name VARCHAR(50), country VARCHAR(50), start_date DATE, end_date DATE, operation_description TEXT);
Update the country column in the peacekeeping_operations table to proper case for all records in Asia
UPDATE peacekeeping_operations SET country = UPPER(SUBSTRING(country, 1, 1)) + LOWER(SUBSTRING(country, 2)) WHERE country = 'asia';
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility (id INT, disability VARCHAR(255), concern VARCHAR(255));
What are the unique technology accessibility concerns for people with hearing impairments in the accessibility table that are not present for people with visual impairments?
SELECT concern FROM accessibility WHERE disability = 'people with hearing impairments' EXCEPT (SELECT concern FROM accessibility WHERE disability = 'people with visual impairments');
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_investments (country VARCHAR(50), year INT, investments FLOAT); INSERT INTO renewable_investments VALUES ('China', 2010, 32000000000);
What are the top 5 countries with the highest increase in renewable energy investments from 2010 to 2020?
SELECT country, MAX(investments) - MIN(investments) AS total_increase FROM renewable_investments WHERE year IN (2010, 2020) GROUP BY country ORDER BY total_increase DESC LIMIT 5
gretelai_synthetic_text_to_sql
CREATE TABLE news (category VARCHAR(255), updated_at TIMESTAMP); INSERT INTO news (category, updated_at) VALUES ('Aquatic Farming', '2022-01-01 10:00:00'), ('Ocean Health', '2022-01-02 11:00:00'), ('Aquatic Farming', '2022-01-03 12:00:00');
How many times was the 'Aquatic Farming' category updated in the 'news' table?
SELECT COUNT(*) FROM (SELECT category, ROW_NUMBER() OVER (PARTITION BY category ORDER BY updated_at) AS row_number FROM news) AS subquery WHERE category = 'Aquatic Farming' AND row_number = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (id INT PRIMARY KEY, name VARCHAR(255), launch_date DATE, return_date DATE);
Which spacecraft has spent the most time in space?
SELECT name, ROUND(DATEDIFF('return_date', 'launch_date') / 60 / 60 / 24, 1) as days_in_space FROM Spacecrafts ORDER BY days_in_space DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (Id INT, Mine_Site VARCHAR(50), Incident_Type VARCHAR(50), Date DATE, Injuries INT); INSERT INTO Accidents (Id, Mine_Site, Incident_Type, Date, Injuries) VALUES (1, 'SiteA', 'Injury', '2020-01-01', 3); INSERT INTO Accidents (Id, Mine_Site, Incident_Type, Date, Injuries) VALUES (2, 'SiteB', 'Injury', '2020-01-02', 6);
How many work-related injuries were reported at each mine site in the first week of 2020, if any site had over 5 injuries, exclude it from the results?
SELECT Mine_Site, SUM(Injuries) as Total_Injuries FROM Accidents WHERE Incident_Type = 'Injury' AND Date >= '2020-01-01' AND Date < '2020-01-08' GROUP BY Mine_Site HAVING Total_Injuries < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name TEXT); CREATE TABLE workouts (id INT, user_id INT, workout_time TIME); INSERT INTO users (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO workouts (id, user_id, workout_time) VALUES (1, 1, '07:30:00'), (2, 1, '09:45:00'), (3, 2, '11:15:00');
How many users have workout records between 7:00 AM and 10:00 AM?
SELECT COUNT(DISTINCT users.id) FROM users JOIN workouts ON users.id = workouts.user_id WHERE workouts.workout_time BETWEEN '07:00:00' AND '10:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE covid_cases (case_id INT, date TEXT, county TEXT, state TEXT, status TEXT); INSERT INTO covid_cases (case_id, date, county, state, status) VALUES (1, '2022-01-01', 'Los Angeles', 'California', 'Active'); INSERT INTO covid_cases (case_id, date, county, state, status) VALUES (2, '2022-02-15', 'San Francisco', 'California', 'Recovered');
What is the number of new COVID-19 cases in the past 30 days in each county in California?
SELECT county, COUNT(*) FROM covid_cases WHERE state = 'California' AND date >= (CURRENT_DATE - INTERVAL '30 days') GROUP BY county;
gretelai_synthetic_text_to_sql
CREATE TABLE SkincareSales (ProductID INT, ProductName VARCHAR(50), Rating DECIMAL(2,1), UnitsSold INT, Country VARCHAR(20)); INSERT INTO SkincareSales (ProductID, ProductName, Rating, UnitsSold, Country) VALUES (1, 'Organic Cleanser', 4.3, 1200, 'Canada'); INSERT INTO SkincareSales (ProductID, ProductName, Rating, UnitsSold, Country) VALUES (2, 'Natural Moisturizer', 4.7, 1500, 'Canada');
What is the average rating of organic skincare products sold in Canada, with sales over 1000 units?
SELECT AVG(Rating) FROM SkincareSales WHERE ProductName LIKE '%organic%' AND Country = 'Canada' AND UnitsSold > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE player_game_hours (player_name TEXT, game TEXT, hours INT);
List players who have played more than 50 hours in 'VR Arena' game
SELECT player_name FROM player_game_hours WHERE game = 'VR Arena' AND hours > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), grants INT); INSERT INTO faculty (id, name, department, grants) VALUES (1, 'Sara Jones', 'Mathematics', 3), (2, 'Hugo Lee', 'Mathematics', 5), (3, 'Mara Patel', 'Mathematics', 2);
What is the average number of research grants per faculty member in the Mathematics department?
SELECT AVG(grants) FROM faculty WHERE department = 'Mathematics';
gretelai_synthetic_text_to_sql
CREATE TABLE artist_demographics (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), nationality VARCHAR(50));CREATE TABLE artwork (id INT, title VARCHAR(50), year INT, artist_id INT, medium VARCHAR(50));
Identify artists in the 'artist_demographics' table who are not associated with any artworks in the 'artwork' table.
SELECT ad.name FROM artist_demographics ad LEFT JOIN artwork a ON ad.id = a.artist_id WHERE a.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (project VARCHAR(50), region VARCHAR(50), co2_reduction FLOAT); INSERT INTO climate_adaptation (project, region, co2_reduction) VALUES ('Tree Planting', 'Latin America', 1000), ('Sea Wall', 'Latin America', 1500);
What is the average CO2 emission reduction for each climate adaptation project in Latin America, ordered by the reduction amount?
SELECT AVG(co2_reduction) as avg_reduction, project FROM climate_adaptation WHERE region = 'Latin America' GROUP BY project ORDER BY avg_reduction DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Brand_Rating (id INT, brand VARCHAR(255), product VARCHAR(255), rating INT, cruelty_free BOOLEAN); INSERT INTO Brand_Rating (id, brand, product, rating, cruelty_free) VALUES (1, 'Lush', 'Soak Stimulant Bath Bomb', 5, true), (2, 'The Body Shop', 'Born Lippy Strawberry Lip Balm', 4, true), (3, 'Estee Lauder', 'Advanced Night Repair Synchronized Recovery Complex II', 5, false), (4, 'Lush', 'Angels on Bare Skin Cleanser', 4, true), (5, 'The Body Shop', 'Tea Tree Skin Clearing Facial Wash', 3, true);
What is the average rating for cruelty-free products in each brand in the database?
SELECT brand, AVG(rating) as avg_rating FROM Brand_Rating WHERE cruelty_free = true GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE RetailSales (id INT, garment_type VARCHAR(20), sustainable BOOLEAN, revenue DECIMAL(10, 2)); INSERT INTO RetailSales (id, garment_type, sustainable, revenue) VALUES (1, 'Dress', TRUE, 75.50), (2, 'Shirt', FALSE, 45.25), (3, 'Pant', TRUE, 65.00), (4, 'Jacket', TRUE, 125.00), (5, 'Shirt', TRUE, 50.00), (6, 'Dress', FALSE, 50.99);
What was the total retail sales revenue for sustainable garments in 2021?
SELECT SUM(revenue) as total_revenue FROM RetailSales WHERE sustainable = TRUE AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, museum TEXT, added_date DATE); INSERT INTO artworks (id, museum, added_date) VALUES (1, 'New York', '2020-01-01'), (2, 'New York', '2021-01-01'), (3, 'New York', '2021-06-01'), (4, 'Chicago', '2022-01-01');
How many artworks were added to the New York museum in 2021?
SELECT COUNT(*) FROM artworks WHERE museum = 'New York' AND added_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, WorkoutName VARCHAR(50), WorkoutType VARCHAR(50), Duration INT, WorkoutDate DATE, MemberID INT);
What is the total number of minutes spent on cycling workouts in Texas in the last month?
SELECT SUM(Duration) FROM Workouts WHERE WorkoutType = 'Cycling' AND State = 'Texas' AND WorkoutDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (Employee_ID INT, Mine_ID INT, Age INT, Gender VARCHAR(10), Department VARCHAR(20), Hire_Date DATE); INSERT INTO Employees (Employee_ID, Mine_ID, Age, Gender, Department, Hire_Date) VALUES (101, 1, 32, 'Male', 'Mining', '2018-05-23'), (102, 1, 45, 'Female', 'Mining', '2017-08-11');
Calculate the average age of male and female employees in the mining department.
SELECT Department, AVG(Age) FROM Employees WHERE Gender IN ('Male', 'Female') AND Department = 'Mining' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (exhibition_id INT, exhibition_name VARCHAR(255)); INSERT INTO exhibitions (exhibition_id, exhibition_name) VALUES (1, 'Art of the Renaissance');
What is the total number of visitors for the "Art of the Renaissance" exhibition?
SELECT COUNT(*) FROM exhibitions WHERE exhibition_name = 'Art of the Renaissance';
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris_data (debris_id INT, name VARCHAR(255), removal_date DATE); INSERT INTO space_debris_data (debris_id, name, removal_date) VALUES (1, 'Debris 1', '2005-05-01'), (2, 'Debris 2', '2012-02-25'), (3, 'Debris 3', '2008-09-10');
Update the removal_date of space debris with id 1 to '2020-05-01' in the space_debris_data table
UPDATE space_debris_data SET removal_date = '2020-05-01' WHERE debris_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, initiative VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO climate_finance (id, initiative, location, funding) VALUES (1, 'Renewable Energy R&D', 'North America', 3000000);
Update the name of the initiative 'Renewable Energy R&D' to 'Clean Energy R&D' in North America.
UPDATE climate_finance SET initiative = 'Clean Energy R&D' WHERE initiative = 'Renewable Energy R&D' AND location = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_3 (project_id INT, region VARCHAR(20), initiatives INT); INSERT INTO ethical_ai_3 (project_id, region, initiatives) VALUES (1, 'South America', 30), (2, 'Australia', 40), (3, 'South America', 50), (4, 'Australia', 60);
What is the average number of ethical AI initiatives in South America and Australia?
SELECT AVG(initiatives) FROM ethical_ai_3 WHERE region IN ('South America', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE Textile_Certifications (id INT, fabric VARCHAR(20), certification VARCHAR(50), expiration_date DATE);
Create a table for tracking textile certifications and their expiration dates.
CREATE TABLE Textile_Certifications (id INT, fabric VARCHAR(20), certification VARCHAR(50), expiration_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_number INT, coverage_start_date DATE, agent_id INT, region VARCHAR(20)); INSERT INTO policies (policy_number, coverage_start_date, agent_id, region) VALUES (12345, '2020-01-02', 1001, 'Florida'); INSERT INTO policies (policy_number, coverage_start_date, agent_id, region) VALUES (67890, '2020-02-01', 1002, 'Florida'); CREATE TABLE agents (agent_id INT, name VARCHAR(50)); INSERT INTO agents (agent_id, name) VALUES (1001, 'Jose Garcia'); INSERT INTO agents (agent_id, name) VALUES (1002, 'Maria Rodriguez');
What is the name of the agent, policy number, and coverage start date for policies in the 'Florida' region with a coverage start date after '2020-01-01'?
SELECT agents.name, policies.policy_number, policies.coverage_start_date FROM policies INNER JOIN agents ON policies.agent_id = agents.agent_id WHERE policies.region = 'Florida' AND policies.coverage_start_date > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, region VARCHAR(20), attendee_count INT); INSERT INTO Events (event_id, region, attendee_count) VALUES (1, 'Midwest', 600), (2, 'Southeast', 400), (3, 'Northeast', 350);
What is the total number of attendees for events in the 'Midwest' region with an attendance of over 500?
SELECT SUM(attendee_count) FROM Events WHERE region = 'Midwest' AND attendee_count > 500
gretelai_synthetic_text_to_sql
CREATE TABLE dams (id INT, name TEXT, height_m FLOAT, purpose TEXT, location TEXT, built YEAR); INSERT INTO dams (id, name, height_m, purpose, location, built) VALUES (1, 'Hoover', 221, 'Hydroelectric', 'USA', 1936); INSERT INTO dams (id, name, height_m, purpose, location, built) VALUES (2, 'Three Gorges', 185, 'Hydroelectric', 'China', 2006);
What is the height and name of the tallest dam built before 1960?
SELECT name, height_m FROM dams WHERE built < 1960 ORDER BY height_m DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE product (id INT, name VARCHAR(255), category VARCHAR(50), size VARCHAR(50), fabric_id INT, sustainable BOOLEAN); INSERT INTO product (id, name, category, size, fabric_id, sustainable) VALUES (1, 'White Blouse', 'Tops', 'Small', 2, true);
What is the total quantity of products in each category that are made of sustainable fabric?
SELECT p.category, SUM(p.quantity) as total_quantity FROM (SELECT product_id, SUM(quantity) as quantity FROM inventory GROUP BY product_id) as i JOIN product p ON i.product_id = p.id JOIN fabric f ON p.fabric_id = f.id WHERE f.sustainable = true GROUP BY p.category;
gretelai_synthetic_text_to_sql
CREATE TABLE Conferences (id INT, name VARCHAR(255), location VARCHAR(255), num_speakers INT); INSERT INTO Conferences (id, name, location, num_speakers) VALUES (1, 'NeurIPS', 'USA', 200), (2, 'ICML', 'Canada', 150), (3, 'AAAI', 'USA', 300), (4, 'IJCAI', 'Australia', 250);
Which AI safety conferences had more than 30 speakers from the US?
SELECT location, COUNT(*) as us_speakers FROM Conferences WHERE location = 'USA' AND num_speakers > 30 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE diverse_units (unit_id INT, num_bedrooms INT, square_footage FLOAT); INSERT INTO diverse_units (unit_id, num_bedrooms, square_footage) VALUES (1, 3, 1200);
What is the minimum square footage of 3-bedroom units in the 'diverse' neighborhood?
SELECT MIN(square_footage) FROM diverse_units WHERE num_bedrooms = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10, 2), hire_date DATE); INSERT INTO employees (id, name, department, salary, hire_date) VALUES (1, 'John Doe', 'Marketing', 75000.00, '2018-01-01'); INSERT INTO employees (id, name, department, salary, hire_date) VALUES (2, 'Jane Smith', 'HR', 80000.00, '2019-05-15'); INSERT INTO employees (id, name, department, salary, hire_date) VALUES (3, 'Mike Johnson', 'IT', 85000.00, '2020-07-22');
Find the number of employees hired in 2020 from the 'hr' schema.
SELECT COUNT(*) FROM hr.employees WHERE YEAR(hire_date) = 2020;
gretelai_synthetic_text_to_sql