context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE developers (developer_id INT, developer_name VARCHAR(100), developer_country VARCHAR(50), date_of_birth DATE); CREATE TABLE decentralized_apps (app_id INT, app_name VARCHAR(100), developer_id INT, app_category VARCHAR(50)); INSERT INTO developers VALUES (1, 'Chinedu', 'Nigeria', '1995-06-23'); INSERT INTO ...
Determine the number of decentralized applications and their categories created by developers from Africa in 2020.
SELECT d.developer_country, COUNT(*) as num_apps, app_category FROM developers d JOIN decentralized_apps da ON d.developer_id = da.developer_id WHERE d.date_of_birth BETWEEN '1980-01-01' AND '2000-12-31' AND d.developer_country IN ('Nigeria', 'Morocco', 'Egypt', 'South Africa', 'Kenya') GROUP BY d.developer_country, ap...
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor VARCHAR(255), project_type VARCHAR(255), amount INT, date DATE); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (21, 'GreenCapital', 'reforestation', 550000, '2022-04-15'); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (22...
How much was invested in 'reforestation' projects in Q2 2022 by 'GreenCapital'?
SELECT SUM(amount) FROM investments WHERE investor = 'GreenCapital' AND project_type = 'reforestation' AND date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSuppliers (supplier_id INT, supplier_country VARCHAR(20), CO2_emissions_reduction FLOAT); CREATE TABLE Fabrics (fabric_id INT, fabric_type VARCHAR(20), supplier_id INT); INSERT INTO TextileSuppliers (supplier_id, supplier_country, CO2_emissions_reduction) VALUES (1, 'Italy', 15.2);
What is the average CO2 emissions reduction achieved per sustainable fabric type, grouped by textile supplier?
SELECT Fabrics.fabric_type, AVG(TextileSuppliers.CO2_emissions_reduction) as avg_reduction FROM Fabrics JOIN TextileSuppliers ON Fabrics.supplier_id = TextileSuppliers.supplier_id GROUP BY Fabrics.fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, year INT, region VARCHAR(20), equipment_type VARCHAR(30), revenue DECIMAL(10,2));
What is the total revenue of military equipment sales in the Asia-Pacific region for each year?
SELECT year, SUM(revenue) as total_revenue FROM military_sales WHERE region = 'Asia-Pacific' GROUP BY year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT, name VARCHAR(255), budget FLOAT); INSERT INTO genetics.research_projects (id, name, budget) VALUES (1, 'ProjectA', 800000.0), (2, 'ProjectB', 1200000.0), (3, 'ProjectC', 1500000.0);
Which genetic research projects have a budget over 1000000?
SELECT name FROM genetics.research_projects WHERE budget > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE thulium_prices (year INT, country TEXT, price FLOAT); INSERT INTO thulium_prices (year, country, price) VALUES (2017, 'Indonesia', 126.3), (2018, 'Indonesia', 135.2), (2019, 'Indonesia', 142.9), (2020, 'Indonesia', 150.1), (2021, 'Indonesia', 155.8), (2022, 'Indonesia', 162.3);
What is the maximum price of thulium in Indonesia in the last 5 years?
SELECT MAX(price) FROM thulium_prices WHERE country = 'Indonesia' AND year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, platform VARCHAR(20), total_hours_played INT);CREATE TABLE game_sessions (id INT, player_id INT, session_duration INT);
What is the total number of hours spent playing games by players, grouped by their preferred gaming platform?
SELECT p.platform, SUM(gs.session_duration) AS total_hours_played FROM players p INNER JOIN game_sessions gs ON p.id = gs.player_id GROUP BY p.platform;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, category VARCHAR(20), publication_date DATE); INSERT INTO news_articles (id, category, publication_date) VALUES (1, 'investigative', '2022-01-05'), (2, 'politics', '2022-02-10'), (3, 'investigative', '2022-01-15'), (4, 'politics', '2022-03-01');
What is the total number of articles published in the 'politics' category after January 2022?
SELECT COUNT(*) FROM news_articles WHERE category = 'politics' AND publication_date > '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ArtistID INT, Artist TEXT, TicketsSold INT, Country TEXT, Year INT); INSERT INTO Concerts (ArtistID, Artist, TicketsSold, Country, Year) VALUES (1, 'Ed Sheeran', 70000, 'UK', 2020); INSERT INTO Concerts (ArtistID, Artist, TicketsSold, Country, Year) VALUES (2, 'Harry Styles', 60000, 'UK', 2020);
How many concert tickets were sold in the UK in 2020?
SELECT SUM(TicketsSold) FROM Concerts WHERE Country = 'UK' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (year INT, quarter INT, amount INT); INSERT INTO waste_generation (year, quarter, amount) VALUES (2018, 1, 300), (2018, 2, 350), (2018, 3, 325), (2018, 4, 375), (2019, 1, 400), (2019, 2, 450), (2019, 3, 425), (2019, 4, 475), (2020, 1, 500), (2020, 2, 550), (2020, 3, 525), (2020, 4, 575), (...
What is the total waste generation in the first half of the years between 2018 and 2021?
SELECT SUM(amount) FROM waste_generation WHERE year BETWEEN 2018 AND 2021 AND quarter <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, artist_name VARCHAR(50), last_exhibition_year INT);
List all artists who have not held any exhibitions in the last 2 years, ordered alphabetically by last name.
SELECT artist_name FROM artists WHERE last_exhibition_year < YEAR(CURRENT_DATE) - 2 OR last_exhibition_year IS NULL ORDER BY SUBSTRING(artist_name, INSTR(artist_name, ' ') + 1);
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShowInfo (ID INT, Show VARCHAR(255), Location VARCHAR(255), Year INT); INSERT INTO AutoShowInfo (ID, Show, Location, Year) VALUES (1, 'GreenTech', 'Detroit', 2022), (2, 'GreenTech', 'Tokyo', 2023), (3, 'EcoExpo', 'Paris', 2022);
What are the auto show locations for the 'GreenTech' auto show in 2022?
SELECT Location FROM AutoShowInfo WHERE Show = 'GreenTech' AND Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(100), location VARCHAR(50), completion_date DATE); INSERT INTO renewable_projects (project_id, project_name, location, completion_date) VALUES (1, 'Solar Farm 1', 'Central', '2018-01-01'); INSERT INTO renewable_projects (project_id, project_name, loc...
How many renewable energy projects were completed before 2019 in the 'Central' region?
SELECT COUNT(*) FROM renewable_projects WHERE location = 'Central' AND completion_date < '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE canada_tourists (id INT, visited_us BOOLEAN); INSERT INTO canada_tourists VALUES (1, true), (2, false), (3, true); CREATE TABLE us_tourists (id INT, visited_canada BOOLEAN); INSERT INTO us_tourists VALUES (1, true), (2, false), (3, true);
What is the percentage of tourists visiting national parks in Canada that also visited the United States?
SELECT 100.0 * COUNT(DISTINCT ct.id) / COUNT(DISTINCT us_tourists.id) FROM canada_tourists ct INNER JOIN us_tourists ON ct.id = us_tourists.id WHERE ct.visited_us = true AND us_tourists.visited_canada = true;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, country VARCHAR(50), amount FLOAT, sector VARCHAR(50), region VARCHAR(50));
Who are the top 5 countries receiving climate finance for mitigation projects in the Asia-Pacific region?
SELECT cf.country, SUM(cf.amount) FROM climate_finance cf WHERE cf.sector = 'mitigation' AND cf.region = 'Asia-Pacific' GROUP BY cf.country ORDER BY SUM(cf.amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE AnimalData2(species VARCHAR(20), population INT, order_class VARCHAR(20)); INSERT INTO AnimalData2 VALUES ('Dolphin', 50, 'Marine Mammal'), ('Whale', 30, 'Marine Mammal'), ('Seal', 70, 'Marine Mammal');
What is the average population size of 'Marine Mammals'?
SELECT AVG(population) FROM AnimalData2 WHERE order_class = 'Marine Mammal';
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (Year INT, Category VARCHAR(20), Amount INT); INSERT INTO Budget (Year, Category, Amount) VALUES (2020, 'Healthcare', 15000000), (2020, 'Education', 20000000);
What is the total budget allocated to healthcare and education in 2020?
SELECT SUM(Amount) FROM Budget WHERE Year = 2020 AND Category IN ('Healthcare', 'Education');
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, name VARCHAR(20), volume FLOAT); INSERT INTO warehouses (id, name, volume) VALUES (1, 'Warehouse A', 1500), (2, 'Warehouse B', 2000);
What is the total volume of warehouse A in cubic meters?
SELECT SUM(volume) FROM warehouses WHERE name = 'Warehouse A';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, brand_id INT, quantity INT); CREATE TABLE brands (id INT, name VARCHAR(255), is_natural BOOLEAN);
Show the top 5 brands by sales of natural products
SELECT b.name, SUM(s.quantity) as total_sales FROM brands b INNER JOIN sales s ON b.id = s.brand_id WHERE b.is_natural = TRUE GROUP BY b.name ORDER BY total_sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_affordability (index FLOAT, city VARCHAR(20));
What is the average housing affordability index in Sydney?
SELECT AVG(index) FROM housing_affordability WHERE city = 'Sydney';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 150.00, '2022-03-01'), (2, 2, 50.00, '2021-12-31'), (3, 1, 200.00, '2022-05-15');
List the top 3 donors by total donation amount in 2022?
SELECT donor_id, SUM(donation_amount) as total_donation FROM donations GROUP BY donor_id ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, vendor VARCHAR(50), quantity INT, species VARCHAR(50), price DECIMAL(5,2)); INSERT INTO sales (id, vendor, quantity, species, price) VALUES (1, 'Seafood Haven', 20, 'Salmon', 12.99), (2, 'Sea Bounty', 30, 'Tilapia', 9.49);
Find the total revenue generated from the sale of 'Tilapia' from the 'sales' table.
SELECT SUM(quantity * price) FROM sales WHERE species = 'Tilapia';
gretelai_synthetic_text_to_sql
CREATE TABLE science_accommodations (student_id INT, semester VARCHAR(10));CREATE TABLE mathematics_accommodations (student_id INT, semester VARCHAR(10)); INSERT INTO science_accommodations VALUES (12, 'fall 2021'), (13, 'fall 2021'), (14, 'fall 2021'); INSERT INTO mathematics_accommodations VALUES (13, 'fall 2021'), (...
Find the number of students who received accommodations in the science department but did not receive any accommodations in the mathematics department during the fall 2021 semester.
SELECT COUNT(*) FROM (SELECT student_id FROM science_accommodations WHERE semester = 'fall 2021' EXCEPT SELECT student_id FROM mathematics_accommodations WHERE semester = 'fall 2021') AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE user_streams (user_id INT, artist_id INT, stream_date DATE); CREATE TABLE festival_performances (artist_id INT, performance_date DATE);
How many unique users have streamed songs from artists who have not performed at any music festivals in the last two years?
SELECT COUNT(DISTINCT u.user_id) FROM user_streams u LEFT JOIN festival_performances f ON u.artist_id = f.artist_id WHERE f.artist_id IS NULL AND u.stream_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing (id INT, year INT, cost FLOAT);
What was the total cost of manufacturing spacecrafts in 2022?
SELECT SUM(cost) FROM SpacecraftManufacturing WHERE year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name TEXT, country TEXT); CREATE TABLE container_movements (id INT, port_id INT, container_type TEXT, quantity INT); INSERT INTO ports (id, name, country) VALUES (1, 'Port of Vancouver', 'Canada'), (2, 'Port of Montreal', 'Canada'); INSERT INTO container_movements (id, port_id, container_typ...
Which ports in Canada have processed the most TEUs (twenty-foot equivalent units) for refrigerated containers?
SELECT p.name, SUM(cm.quantity) FROM ports p JOIN container_movements cm ON p.id = cm.port_id WHERE p.country = 'Canada' AND cm.container_type = 'Refrigerated' GROUP BY p.name ORDER BY SUM(cm.quantity) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (id INT PRIMARY KEY, farm_id INT, record_date DATE, temperature FLOAT, precipitation FLOAT); INSERT INTO weather_data (id, farm_id, record_date, temperature, precipitation) VALUES (1, 401, '2022-05-01', 25.6, 12.3); INSERT INTO weather_data (id, farm_id, record_date, temperature, precipitation...
What is the maximum temperature recorded at farm ID 401 in the past month?
SELECT MAX(temperature) FROM weather_data WHERE farm_id = 401 AND record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (state VARCHAR(20), year INT, permits INT); INSERT INTO building_permits VALUES ('Ohio', 2021, 1200), ('Ohio', 2020, 1100), ('Florida', 2021, 1500);
How many building permits were issued in Ohio in 2020?
SELECT permits FROM building_permits WHERE state = 'Ohio' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), gender VARCHAR(10)); INSERT INTO employees (id, name, gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'), (3, 'Alice Johnson', 'Female'), (4, 'Bob Brown', 'Male');
How many male employees are there in the company?
SELECT COUNT(*) FROM employees WHERE gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE TVShows (ShowId INT, ShowName VARCHAR(100), Genre VARCHAR(50), ReleaseYear INT, Seasons INT); CREATE TABLE TVShowStreaming (ShowId INT, PlatformId INT, StartDate DATETIME, EndDate DATETIME); CREATE TABLE Awards (AwardId INT, ShowId INT, AwardName VARCHAR(100), Year INT); CREATE TABLE StreamingPlatforms (Pl...
List all TV shows, along with the number of awards they have won, that are currently streaming on a platform with a subscription cost higher than 9.99 USD, and were released in the last 5 years.
SELECT TVShows.ShowName, COUNT(Awards.AwardId) AS AwardsWon FROM TVShows LEFT JOIN TVShowStreaming ON TVShows.ShowId = TVShowStreaming.ShowId LEFT JOIN Awards ON TVShows.ShowId = Awards.ShowId LEFT JOIN StreamingPlatforms ON TVShowStreaming.PlatformId = StreamingPlatforms.PlatformId WHERE TVShows.ReleaseYear >= YEAR(CU...
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibits (exhibit_id INT, country VARCHAR(50), city VARCHAR(50)); INSERT INTO Exhibits (exhibit_id, country, city) VALUES (1, 'USA', 'New York'), (2, 'USA', 'Los Angeles'), (3, 'Canada', 'Toronto');
What is the total number of art exhibits in each country?
SELECT country, COUNT(*) as num_exhibits FROM Exhibits GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE StrainTestDates (StrainName VARCHAR(255), THCResult DECIMAL(5,2), TestDate DATE); INSERT INTO StrainTestDates (StrainName, THCResult, TestDate) VALUES ('Strain A', 20.0, '2022-01-01'), ('Strain B', 22.0, '2022-01-02'), ('Strain C', 25.0, '2022-01-03'), ('Purple Haze', 18.0, '2022-01-04'), ('Strain E', 21.0...
Get the average THC content for strains tested in the last 30 days, excluding 'Purple Haze'.
SELECT AVG(THCResult) FROM StrainTestDates WHERE StrainName != 'Purple Haze' AND TestDate >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE SCHEMA news;CREATE TABLE NewsSource (title varchar(255), author varchar(255), region varchar(10));INSERT INTO NewsSource (title, author, region) VALUES ('Article1', 'Author1', 'central'), ('Article2', 'Author2', 'central'), ('Article3', 'Author3', 'eastern'), ('Opinion1', 'Author4', 'central');
List the titles and authors of all investigative journalism articles and opinion pieces published by news sources in the central region.
SELECT title, author FROM news.NewsSource WHERE (type = 'investigative' OR type = 'opinion') AND region = 'central'
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_training (state VARCHAR(50), session_count INT); INSERT INTO sustainable_training (state, session_count) VALUES ('State 1', 15), ('State 2', 20), ('State 3', 25);
What is the number of training sessions conducted on sustainable farming practices in each state?
SELECT state, session_count FROM sustainable_training;
gretelai_synthetic_text_to_sql
CREATE TABLE Policies (Policy_Type TEXT, Duration INT); INSERT INTO Policies (Policy_Type, Duration) VALUES ('Auto', 36), ('Home', 12), ('Auto', 24), ('Home', 24);
What is the minimum policy duration for each policy type?
SELECT Policy_Type, MIN(Duration) FROM Policies GROUP BY Policy_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255), author VARCHAR(255), date DATE, topic VARCHAR(255)); CREATE TABLE news (id INT, title VARCHAR(255), description TEXT, topic VARCHAR(255), date DATE);
What is the total number of articles and news items published in the articles and news tables on the topic 'media literacy'?
SELECT COUNT(*) FROM articles WHERE topic = 'media literacy' UNION ALL SELECT COUNT(*) FROM news WHERE topic = 'media literacy';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, museum VARCHAR(10), num_visitors INT); INSERT INTO events (id, museum, num_visitors) VALUES (1, 'Met', 1500), (2, 'MoMA', 1200);
How many unique visitors have attended events at the Met and MoMA?
SELECT COUNT(DISTINCT e.museum) FROM events e WHERE e.museum IN ('Met', 'MoMA');
gretelai_synthetic_text_to_sql
CREATE TABLE investments_2 (investment_id INT, strategy VARCHAR(20), return_rate DECIMAL(10,2)); INSERT INTO investments_2 (investment_id, strategy, return_rate) VALUES (1, 'Stock', 0.12), (2, 'Bond', 0.05), (3, 'Real Estate', 0.07);
Which investment strategies have a return rate above the average return rate?
SELECT strategy FROM investments_2 WHERE return_rate > (SELECT AVG(return_rate) FROM investments_2);
gretelai_synthetic_text_to_sql
CREATE TABLE sports_team_a_ticket_sales (sale_id INT, sale_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sports_team_a_ticket_sales (sale_id, sale_date, quantity, price) VALUES (1, '2022-01-01', 100, 50.00), (2, '2022-01-02', 120, 55.00), (3, '2022-01-03', 150, 60.00); CREATE TABLE sports_team_b_ticket_sale...
Find the INTERSECT of 'sports_team_a_ticket_sales' and 'sports_team_b_ticket_sales' tables
SELECT * FROM sports_team_a_ticket_sales INTERSECT SELECT * FROM sports_team_b_ticket_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE CORAL_REEFS (REGION TEXT, THREAT_LEVEL TEXT); INSERT INTO CORAL_REEFS (REGION, THREAT_LEVEL) VALUES ('Pacific Ocean', 'Threatened'), ('Atlantic Ocean', 'Threatened'), ('Indian Ocean', 'Not Threatened'), ('Southern Ocean', 'Not Threatened'), ('Arctic Ocean', 'Not Threatened');
Determine the percentage of coral reefs in the Pacific Ocean, Atlantic Ocean, and Indian Ocean that are under threat.
SELECT REGION, THREAT_LEVEL, COUNT(*) OVER (PARTITION BY THREAT_LEVEL) * 100.0 / SUM(COUNT(*)) OVER () AS PERCENTAGE FROM CORAL_REEFS WHERE THREAT_LEVEL <> 'Not Threatened' ORDER BY REGION;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), category_id INT, last_sold DATE); INSERT INTO dishes VALUES (1, 'Pizza Margherita', 1, '2022-04-15'); INSERT INTO dishes VALUES (2, 'Chole Bhature', 2, '2022-04-20');
Identify dishes that have not been sold for the past 30 days and their categories.
SELECT d.dish_name, c.category_name FROM dishes d JOIN categories c ON d.category_id = c.category_id WHERE last_sold < DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE purchases (purchase_id INT, customer_id INT, sales_amount DECIMAL(5,2)); INSERT INTO purchases VALUES (1, 1, 200.00), (2, 1, 150.00), (3, 2, 300.00), (4, 3, 50.00), (5, 4, 100.00), (6, 4, 250.00), (7, 5, 50.00), (8, 5, 100.00); INSERT IN...
List the top 5 customers by total sales
SELECT customers.customer_name, SUM(purchases.sales_amount) FROM customers JOIN purchases ON customers.customer_id = purchases.customer_id GROUP BY customers.customer_id ORDER BY SUM(purchases.sales_amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), material VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO products (id, name, material, price) VALUES (1, 'T-Shirt', 'Organic Cotton', 30.00), (2, 'Hoodie', 'Organic Cotton', 60.00);
What is the average price of products made with organic cotton?
SELECT AVG(price) FROM products WHERE material = 'Organic Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE violations (violation_id INT, country_id INT, amount FLOAT);
List maritime law violations and corresponding fines by country.
SELECT c.name, v.amount FROM violations v JOIN countries c ON v.country_id = c.country_id ORDER BY amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE FishFarming (id INT, species VARCHAR(20), weight FLOAT, farm_location VARCHAR(30));
Calculate the average 'weight' of 'Tuna' in the 'FishFarming' table, grouped by 'farm_location'
SELECT farm_location, AVG(weight) FROM FishFarming WHERE species = 'Tuna' GROUP BY farm_location;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_organic BOOLEAN); INSERT INTO products (product_id, product_name, is_organic) VALUES (1, 'Apples', TRUE), (2, 'Bananas', FALSE); CREATE TABLE sales (sale_id INT, product_id INT, revenue INT); INSERT INTO sales (sale_id, product_id, revenue) VALUES (1,...
Find the total revenue of organic products
SELECT SUM(sales.revenue) FROM sales INNER JOIN products ON sales.product_id = products.product_id WHERE products.is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, home_team TEXT, away_team TEXT, home_goals INT, away_goals INT, game_date DATE); INSERT INTO games (game_id, home_team, away_team, home_goals, away_goals, game_date) VALUES (1, 'Montreal Canadiens', 'Toronto Maple Leafs', 4, 3, '2022-01-01'), (2, 'Boston Bruins', 'New York Rangers', 2, ...
Delete all hockey games that were played before a certain date.
DELETE FROM games WHERE game_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(100), sport VARCHAR(50), position VARCHAR(50), jersey_number INT); INSERT INTO athletes (athlete_id, name, sport, position, jersey_number) VALUES (1, 'Ravi Patel', 'Cricket', 'Batsman', 17);
Update the jersey number of a specific athlete to a new value.
UPDATE athletes SET jersey_number = 18 WHERE athlete_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (incident_id INT, location VARCHAR(255), severity INT, timestamp TIMESTAMP); INSERT INTO cybersecurity_incidents (incident_id, location, severity, timestamp) VALUES (1, 'France', 8, '2022-03-05 10:30:00'), (2, 'Germany', 5, '2022-03-07 14:20:00'), (3, 'Italy', 9, '2022-03-10 08:15:0...
Identify cybersecurity incidents in Europe with a severity level above 7 in the last month.
SELECT * FROM cybersecurity_incidents WHERE location LIKE 'Europe%' AND severity > 7 AND timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2017, 'Praseodymium', 6000);
What is the production quantity of Praseodymium in 2017?
SELECT quantity FROM production WHERE element = 'Praseodymium' AND year = 2017
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Development_Fund(farmer_id INT, farmer_name VARCHAR(50), country VARCHAR(50), funding FLOAT); INSERT INTO Rural_Development_Fund(farmer_id, farmer_name, country, funding) VALUES (1, 'John Doe', 'Nigeria', 10000), (2, 'Jane Smith', 'Kenya', 15000);
What is the number of farmers who received support from the 'Rural Development Fund' in 'Africa' and their total funding?
SELECT COUNT(*), SUM(funding) as total_funding FROM Rural_Development_Fund WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE water_treatment_plant (plant_id INT, state VARCHAR(50), year INT, month INT, water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id, state, year, month, water_consumption) VALUES (1, 'Texas', 2019, 8, 12345.6), (2, 'Texas', 2019, 8, 23456.7), (3, 'Texas', 2019, 8, 34567.8);
What is the total water consumption for the month of August for all water treatment plants in the state of Texas in 2019?
SELECT SUM(water_consumption) as total_water_consumption FROM water_treatment_plant WHERE state = 'Texas' AND year = 2019 AND month = 8;
gretelai_synthetic_text_to_sql
CREATE TABLE student_proficiency (student_id INT, subject VARCHAR(255), proficiency INT); INSERT INTO student_proficiency (student_id, subject, proficiency) VALUES (1, 'Math', 1), (2, 'Science', 1), (3, 'English', 0), (4, 'Math', 1), (5, 'Science', 0), (6, 'English', 1);
What is the percentage of students who have achieved proficiency in each subject?
SELECT subject, AVG(proficiency) * 100 AS percentage_proficient FROM student_proficiency GROUP BY subject;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_name TEXT, disease_area TEXT, rd_cost INTEGER); INSERT INTO rd_expenditure (drug_name, disease_area, rd_cost) VALUES ('DrugA', 'Oncology', 20000000), ('DrugB', 'Cardiovascular', 15000000), ('DrugC', 'Oncology', 30000000), ('DrugD', 'Neurology', 25000000);
What is the total R&D expenditure for each disease area?
SELECT disease_area, SUM(rd_cost) FROM rd_expenditure GROUP BY disease_area;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (country VARCHAR(50), year INT, event_count INT); INSERT INTO defense_diplomacy (country, year, event_count) VALUES ('Canada', 2015, 3), ('Canada', 2015, 4), ('Canada', 2016, 5), ('Canada', 2016, 6);
What is the total number of defense diplomacy events conducted by Canada in 2015 and 2016?
SELECT SUM(event_count) FROM defense_diplomacy WHERE country = 'Canada' AND year IN (2015, 2016);
gretelai_synthetic_text_to_sql
CREATE TABLE systems (system_id INT, system_name VARCHAR(255), ip_address VARCHAR(255), vulnerability_score INT); INSERT INTO systems (system_id, system_name, ip_address, vulnerability_score) VALUES (1, 'Web Server 1', '192.168.1.1', 7); INSERT INTO systems (system_id, system_name, ip_address, vulnerability_score) VALU...
What are the top 5 most vulnerable systems in the organization?
SELECT system_name, ip_address, vulnerability_score FROM systems ORDER BY vulnerability_score DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (country VARCHAR(50), continent VARCHAR(50), year INT, patent_id INT); INSERT INTO military_innovation (country, continent, year, patent_id) VALUES ('China', 'Asia', 2020, 123), ('Japan', 'Asia', 2020, 456), ('China', 'Asia', 2020, 789), ('India', 'Asia', 2020, 321), ('South Korea', 'As...
What is the number of military innovation patents filed by each country in Asia in 2020?
SELECT country, COUNT(DISTINCT patent_id) FROM military_innovation WHERE continent = 'Asia' AND year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name VARCHAR(255), country VARCHAR(255), duration INT); INSERT INTO virtual_tours (tour_id, tour_name, country, duration) VALUES (1, 'Virtual Tour Tokyo', 'Japan', 60); INSERT INTO virtual_tours (tour_id, tour_name, country, duration) VALUES (2, 'Virtual Tour Barcelona', 'S...
List the number of virtual tours in Japan and Spain.
SELECT country, COUNT(*) FROM virtual_tours GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_type TEXT, attendance INT, admission_cost DECIMAL(10, 2));
What is the difference in attendance between free and paid events, grouped by event type?
SELECT event_type, SUM(CASE WHEN admission_cost = 0 THEN attendance ELSE 0 END) - SUM(CASE WHEN admission_cost > 0 THEN attendance ELSE 0 END) AS net_attendance FROM events GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_supplies (id INT PRIMARY KEY, region_id INT, medical_supplies INT, delivery_date DATE); INSERT INTO medical_supplies (id, region_id, medical_supplies, delivery_date) VALUES (1, 1, 1000, '2021-12-31'); INSERT INTO medical_supplies (id, region_id, medical_supplies, delivery_date) VALUES (2, 2, 2000, ...
What is the total number of medical supplies delivered to region_id 2 in the medical_supplies table, excluding the records with delivery dates before '2022-01-01'?
SELECT SUM(medical_supplies) FROM medical_supplies WHERE region_id = 2 AND delivery_date >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Compliance_Policies (id INT PRIMARY KEY, policy_name VARCHAR(255), category VARCHAR(50), description TEXT, last_reviewed DATE); INSERT INTO Compliance_Policies (id, policy_name, category, description, last_reviewed) VALUES (3, 'Endpoint protection', 'Endpoint security', 'Ensure endpoint security measures a...
What is the average number of policies per category in the Compliance_Policies table?
SELECT AVG(COUNT(*)) OVER () FROM Compliance_Policies GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE pacific_ocean_temperature (date DATE, temperature FLOAT, ocean VARCHAR(50));
What is the maximum and minimum temperature for the 'Pacific Ocean' in each month?
SELECT DATE_FORMAT(date, '%Y-%m') AS month, MAX(temperature), MIN(temperature) FROM pacific_ocean_temperature WHERE ocean = 'Pacific Ocean' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE us_flu_vaccinations (id INT, patient_name VARCHAR(50), healthcare_provider VARCHAR(50), state VARCHAR(20), vaccine_type VARCHAR(50), date DATE); INSERT INTO us_flu_vaccinations (id, patient_name, healthcare_provider, state, vaccine_type, date) VALUES (1, 'Emma', 'New York Hospital', 'New York', 'Flu', '202...
What is the total number of flu vaccinations administered in the US, grouped by state and month, in 2020?
SELECT state, MONTH(date) as month, COUNT(*) as num_vaccinations FROM us_flu_vaccinations WHERE vaccine_type = 'Flu' AND YEAR(date) = 2020 GROUP BY state, month;
gretelai_synthetic_text_to_sql
CREATE TABLE av_models (model_name VARCHAR(255), autonomy_level INT);
Update the autonomy_level of an autonomous vehicle model in the av_models table.
WITH updated_level AS (UPDATE av_models SET autonomy_level = 4 WHERE model_name = 'AutoLux S') SELECT * FROM updated_level;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founding_year INT, industry TEXT, founder_veteran_status TEXT, funding FLOAT);
What is the trend in funding received by startups founded by veterans in the transportation sector over time?
SELECT founding_year, AVG(funding) FROM companies WHERE industry = 'transportation' AND founder_veteran_status = 'veteran' GROUP BY founding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_reports (id INT, concern VARCHAR(255), date DATE);
Find the top 3 most common AI safety concerns reported in the past month.
SELECT concern, COUNT(*) OVER (PARTITION BY concern ORDER BY COUNT(*) DESC) as rank FROM ai_safety_reports WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY concern;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), data_limit INT, price DECIMAL(5,2));
Add a new mobile plan to the 'mobile_plans' table
INSERT INTO mobile_plans (plan_id, plan_name, data_limit, price) VALUES (2001, 'Unlimited Data', 10000, 59.99);
gretelai_synthetic_text_to_sql
CREATE TABLE salespeople (salesperson_id INT, salesperson_name TEXT); CREATE TABLE sales (sale_id INT, salesperson_id INT, sale_date DATE, revenue FLOAT);
Find the daily average revenue for each salesperson in January 2022.
SELECT s.salesperson_name, AVG(s.revenue) FROM sales s JOIN salespeople sp ON s.salesperson_id = sp.salesperson_id WHERE s.sale_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY s.salesperson_id, s.salesperson_name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, athlete_count INT, attendees INT);
How many unique athletes participated in events with over 10,000 attendees in the 'events' table?
SELECT COUNT(DISTINCT athlete_count) FROM events WHERE attendees > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO restaurants (id, name, category) VALUES (1, 'Restaurant A', 'Mexican'), (2, 'Restaurant B', 'Italian'), (3, 'Restaurant C', 'Chinese'); CREATE TABLE inspections (restaurant_id INT, score INT, date DATE); INSERT INTO inspections (re...
What is the average food safety score for each restaurant category?
SELECT r.category, AVG(i.score) as avg_score FROM restaurants r JOIN inspections i ON r.id = i.restaurant_id GROUP BY r.category;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO users (id, name, location) VALUES (1, 'Alice', 'Canada'); INSERT INTO users (id, name, location) VALUES (2, 'Bob', 'USA'); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '...
How many users are there in each country, and what is the total number of posts for users in each country?
SELECT u.location, COUNT(DISTINCT u.id) as user_count, COUNT(p.id) as post_count FROM users u JOIN posts p ON u.id = p.user_id GROUP BY u.location;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_materials (material_id INT, material_name VARCHAR(50), price DECIMAL(5,2), product_type VARCHAR(20)); INSERT INTO sustainable_materials (material_id, material_name, price, product_type) VALUES (1, 'Organic Cotton', 5.50, 'Women'), (2, 'Recycled Polyester', 6.20, 'Women'), (3, 'Tencel', 7.00, 'W...
What is the average price of sustainable materials used in manufacturing women's clothing?
SELECT AVG(price) FROM sustainable_materials WHERE product_type = 'Women';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), age INT, state VARCHAR(2)); INSERT INTO artists (id, name, age, state) VALUES (1, 'Artist1', 60, 'NY'), (2, 'Artist2', 55, 'CA'); CREATE TABLE fellowships (id INT, artist_id INT, year INT, title VARCHAR(50)); INSERT INTO fellowships (id, artist_id, year, title) VALUES (1,...
What is the average age of artists who have received the National Heritage Fellowship award, grouped by their state of origin?
SELECT a.state, AVG(a.age) as avg_age FROM artists a JOIN fellowships f ON a.id = f.artist_id GROUP BY a.state;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (MovieTitle VARCHAR(50), Genre VARCHAR(50), ReleaseYear INT); INSERT INTO Movies (MovieTitle, Genre, ReleaseYear) VALUES ('The Shawshank Redemption', 'Drama', 1994), ('The Godfather', 'Crime', 1972), ('Pulp Fiction', 'Crime', 1994), ('The Dark Knight', 'Crime', 2008), ('Star Wars: Episode IV - A New...
What is the distribution of genres in the Media database?
SELECT Genre, COUNT(*) as GenreCount FROM Movies GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatCategories (EntryID INT, Category VARCHAR(255), Year INT); INSERT INTO ThreatCategories (EntryID, Category, Year) VALUES (1, 'Malware', 2022); INSERT INTO ThreatCategories (EntryID, Category, Year) VALUES (2, 'Phishing', 2022);
What are the top 5 threat categories by count in 2022?
SELECT Category, COUNT(*) AS Count FROM ThreatCategories WHERE Year = 2022 GROUP BY Category ORDER BY Count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, country VARCHAR(50), operation_date DATE); INSERT INTO peacekeeping_operations (operation_id, country, operation_date) VALUES (1, 'Bangladesh', '2012-01-01'), (2, 'Ethiopia', '2013-06-15'), (3, 'Rwanda', '2015-12-25'), (4, 'India', '2010-05-03'), (5, 'Pakistan', '...
How many peacekeeping operations have been conducted by country in the past 10 years?
SELECT co.country, COUNT(po.operation_id) as num_operations FROM peacekeeping_operations po JOIN countries co ON po.country = co.country WHERE po.operation_date >= '2011-01-01' GROUP BY co.country;
gretelai_synthetic_text_to_sql
CREATE TABLE endpoint_issues (id INT, asset_type VARCHAR(50), issue_count INT, issue_date DATE);
What is the total number of security incidents and vulnerabilities in the 'endpoint' asset type in the last quarter?
SELECT asset_type, SUM(issue_count) as total_issues FROM endpoint_issues WHERE asset_type = 'endpoint' AND issue_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY asset_type;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_revenue (sales_rep_id INT, sale_date DATE, revenue DECIMAL(10,2));INSERT INTO sales_revenue (sales_rep_id, sale_date, revenue) VALUES (1, '2022-01-01', 1000), (1, '2022-02-01', 1500), (1, '2022-03-01', 1200), (2, '2022-01-01', 1800), (2, '2022-02-01', 2000), (2, '2022-03-01', 2200), (3, '2022-01-01',...
What is the total revenue generated by each sales representative in the last quarter?
SELECT sales_rep_id, SUM(revenue) as total_revenue FROM sales_revenue WHERE sale_date >= '2022-01-01' AND sale_date <= '2022-03-01' GROUP BY sales_rep_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, ocean TEXT);
How many marine protected areas are there in the Indian Ocean?
SELECT COUNT(*) FROM marine_protected_areas WHERE ocean = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name TEXT, ocean TEXT, endemic BOOLEAN); INSERT INTO marine_species (species_name, ocean, endemic) VALUES ('Species C', 'Arctic Ocean', TRUE); INSERT INTO marine_species (species_name, ocean, endemic) VALUES ('Species D', 'Arctic Ocean', FALSE);
What is the total number of marine species observed in the Arctic Ocean, and how many of these species are endemic to the Arctic?
SELECT COUNT(*) AS total_species, SUM(endemic) AS endemic_species FROM marine_species WHERE ocean = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name VARCHAR(255), location VARCHAR(255), last_accident_date DATE); INSERT INTO mines (id, name, location, last_accident_date) VALUES (1, 'Mine A', 'Australia', '2021-01-15'), (2, 'Mine B', 'Canada', '2020-06-20'), (3, 'Mine C', 'Australia', '2021-02-10'), (4, 'Mine D', 'USA', NULL);
How many accidents happened at the mines in Australia in the last 12 months?
SELECT COUNT(m.id) as total_accidents FROM mines m WHERE m.location = 'Australia' AND m.last_accident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 78.3), (2, 'finance', 65.2), (3, 'healthcare', 90.5), (4, 'healthcare', 85.1);
What's the maximum ESG score in the 'healthcare' sector?
SELECT MAX(ESG_score) FROM companies WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE power_plants (id INT, name TEXT, location TEXT, capacity FLOAT); INSERT INTO power_plants (id, name, location, capacity) VALUES (1, 'Hanover Wind Farm', 'Germany', 50.0), (2, 'Bremen Wind Farm', 'Germany', 75.0);
What is the total installed capacity of wind power plants in Germany?
SELECT SUM(capacity) FROM power_plants WHERE location = 'Germany' AND type = 'wind';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, type TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_energy (id, type, country, capacity) VALUES (1, 'Wind Turbine', 'France', 2.2), (2, 'Solar Panel', 'Spain', 3.2), (3, 'Wind Turbine', 'France', 2.5), (4, 'Wind Turbine', 'Germany', 2.8);
Calculate the average capacity of wind turbines installed in France.
SELECT AVG(capacity) FROM renewable_energy WHERE type = 'Wind Turbine' AND country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), section VARCHAR(50), rating DECIMAL(3,2)); INSERT INTO articles (id, title, section, rating) VALUES (1, 'Article1', 'Entertainment', 4.5); INSERT INTO articles (id, title, section, rating) VALUES (2, 'Article2', 'Politics', 3.2); INSERT INTO articles (id, title, sectio...
What is the average rating of articles published in the 'Entertainment' section?
SELECT AVG(rating) FROM articles WHERE section = 'Entertainment';
gretelai_synthetic_text_to_sql
CREATE TABLE UnionH(union_name VARCHAR(10), member_id INT, salary INT); INSERT INTO UnionH(union_name, member_id, salary) VALUES('Union1', 8001, 50000), ('Union1', 8002, 60000), ('Union2', 8003, 55000), ('Union2', 8004, 65000), ('Union3', 8005, 45000);
Find the top 2 union names with the highest average salary.
SELECT union_name, AVG(salary) FROM UnionH GROUP BY union_name ORDER BY AVG(salary) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE MedicalCheckups (id INT, astronaut_name VARCHAR(255), checkup_date DATE, duration INT); INSERT INTO MedicalCheckups (id, astronaut_name, checkup_date, duration) VALUES (1, 'Mark Watney', '2022-01-01', 45), (2, 'Melissa Lewis', '2022-02-15', 60);
What was the maximum medical checkup duration for astronauts who had medical checkups in '2022'?
SELECT MAX(duration) FROM MedicalCheckups WHERE checkup_date >= '2022-01-01' AND checkup_date < '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE terbium_prices (continent VARCHAR(10), price DECIMAL(5,2), year INT); INSERT INTO terbium_prices (continent, price, year) VALUES ('Africa', 320.00, 2020), ('Africa', 310.00, 2019), ('Africa', 330.00, 2018);
What is the minimum price of terbium produced in Africa?
SELECT MIN(price) FROM terbium_prices WHERE continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSuppliers (SupplierID INT, SupplierName TEXT, SustainabilityRating INT); INSERT INTO TextileSuppliers (SupplierID, SupplierName, SustainabilityRating) VALUES (1, 'Supplier A', 85), (2, 'Supplier B', 90), (3, 'Supplier C', 70);
Delete textile suppliers with low sustainability ratings
DELETE FROM TextileSuppliers WHERE SustainabilityRating < 80;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, name TEXT, hired_date DATE, language TEXT, cultural_competency_score INT);
What is the average cultural competency score for community health workers who speak English?
SELECT AVG(cultural_competency_score) FROM community_health_workers WHERE language = 'English';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, is_organic BOOLEAN, price DECIMAL, source_country TEXT); INSERT INTO products (product_id, name, is_organic, price, source_country) VALUES (1, 'Lipstick', TRUE, 25.99, 'USA'); INSERT INTO products (product_id, name, is_organic, price, source_country) VALUES (2, 'Eye Sha...
What is the maximum price of organic cosmetics sourced from the United States?
SELECT MAX(price) FROM products WHERE is_organic = TRUE AND source_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE industries (name VARCHAR(255), workforce_count INT); CREATE TABLE workforce (industry VARCHAR(255), gender VARCHAR(255), percentage DECIMAL(10,2)); INSERT INTO industries (name) VALUES ('Technology'), ('Healthcare'), ('Finance'), ('Education'), ('Retail'); INSERT INTO workforce (industry, gender, percentag...
What is the average percentage of women in the workforce in each industry?
SELECT industry, AVG(percentage) FROM workforce WHERE gender = 'Women' GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mine_name TEXT, location TEXT, material TEXT, quantity INT, date DATE); INSERT INTO mining_operations (id, mine_name, location, material, quantity, date) VALUES (7, 'Iron Citadel', 'Russia', 'iron', 10000, '2017-01-01');
Find the number of mines in Russia that mined iron in 2017
SELECT COUNT(DISTINCT mine_name) FROM mining_operations WHERE material = 'iron' AND location = 'Russia' AND date = '2017-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE AgriInnov (id INT, metric VARCHAR(255), crop VARCHAR(255), country VARCHAR(255)); INSERT INTO AgriInnov (id, metric, crop, country) VALUES (1, 'Yield', 'Rice', 'Indonesia'), (2, 'Harvest Time', 'Rice', 'Indonesia');
Delete all agricultural innovation metrics related to rice in Indonesia.
DELETE FROM AgriInnov WHERE crop = 'Rice' AND country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (Country VARCHAR(255), Programs INT); INSERT INTO Countries (Country, Programs) VALUES ('India', 15), ('China', 10), ('Brazil', 20), ('SouthAfrica', 12);
How many community education programs were held in each country, in descending order by the number of programs?
SELECT Country, COUNT(Programs) as NumPrograms FROM Countries GROUP BY Country ORDER BY NumPrograms DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (permit_id INT, state VARCHAR(255), issue_date DATE); INSERT INTO Permits (permit_id, state, issue_date) VALUES (1, 'California', '2021-01-01'), (2, 'Texas', '2021-02-01');
How many building permits were issued in the state of California in 2021?
SELECT COUNT(permit_id) FROM Permits WHERE state = 'California' AND YEAR(issue_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), menu_type VARCHAR(20), price DECIMAL(5,2), is_gluten_free BOOLEAN); INSERT INTO menus (menu_id, menu_name, menu_type, price, is_gluten_free) VALUES (1, 'Quinoa Salad', 'Vegetarian', 9.99, true), (2, 'Margherita Pizza', 'Non-vegetarian', 12.99, false), (3, 'Tofu St...
What is the maximum price of gluten-free menu items?
SELECT MAX(price) FROM menus WHERE is_gluten_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, site_id INT, species_name TEXT); INSERT INTO marine_species (species_id, site_id, species_name) VALUES (1, 1, 'Anglerfish'), (2, 3, 'Giant Squid'), (3, 1, 'Oceanic Trench Snailfish');
How many marine species were observed at 'Research Site A'?
SELECT COUNT(*) FROM marine_species WHERE site_id = (SELECT site_id FROM marine_sites WHERE site_name = 'Research Site A');
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(255), publish_date DATE, location VARCHAR(50)); INSERT INTO news_articles (id, title, publish_date, location) VALUES (1, 'Article1', '2022-03-01', 'Japan'), (2, 'Article2', '2021-08-05', 'Japan'), (3, 'Article3', '2020-08-03', 'Japan');
What is the oldest news article in Japan?
SELECT title, publish_date FROM news_articles WHERE location = 'Japan' ORDER BY publish_date ASC LIMIT 1;
gretelai_synthetic_text_to_sql
game_stats(game_id, player_id, score, date_played)
List the top 10 games with the highest scores
SELECT game_id, MAX(score) as highest_score FROM game_stats GROUP BY game_id ORDER BY highest_score DESC LIMIT 10;
gretelai_synthetic_text_to_sql