context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE player_stats (id INT, player TEXT, time_on_field INT, game INT); INSERT INTO player_stats (id, player, time_on_field, game) VALUES (1, 'Messi', 300, 202201), (2, 'Messi', 310, 202202), (3, 'Messi', 290, 202203), (4, 'Ronaldo', 280, 202201), (5, 'Ronaldo', 295, 202202), (6, 'Ronaldo', 305, 202203);
What is the average time spent on the field by players in the last 10 games?
SELECT player, AVG(time_on_field) FROM player_stats WHERE game >= 202201 AND game <= 202210 GROUP BY player;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, name TEXT, city TEXT, balance_usd FLOAT);
List all mobile subscribers with unpaid balances in city Z
SELECT name, city, balance_usd FROM mobile_subscribers
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_health_metrics (metric_id INT PRIMARY KEY, metric_name VARCHAR(255), metric_value FLOAT, measurement_date DATE); INSERT INTO ocean_health_metrics (metric_id, metric_name, metric_value, measurement_date) VALUES (1, 'Dissolved oxygen', 6.5, '2022-01-01'), (2, 'pH', 8.1, '2022-01-02'), (3, 'Temperature', 15.2, '2022-01-03'), (4, 'Salinity', 34.8, '2022-01-04');
Create a view named "health_trends" with columns "metric_name", "latest_value", and "one_year_ago_value". Only include metrics with measurement dates within the last year.
CREATE VIEW health_trends AS SELECT metric_name, MAX(metric_value) AS latest_value, (SELECT metric_value FROM ocean_health_metrics ohm2 WHERE ohm2.metric_name = ohm.metric_name AND ohm2.measurement_date = DATE_SUB(CURDATE(), INTERVAL 1 YEAR)) AS one_year_ago_value FROM ocean_health_metrics ohm WHERE measurement_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY metric_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CityBudget (CityName VARCHAR(50), Service VARCHAR(50), Budget INT, Population INT); INSERT INTO CityBudget (CityName, Service, Budget, Population) VALUES ('CityA', 'Waste Collection', 5000000, 600000), ('CityA', 'Street Lighting', 7000000, 600000), ('CityB', 'Water Supply', 8000000, 800000), ('CityB', 'Road Maintenance', 9000000, 800000);
What is the total budget allocated for each service in cities with a population greater than 500000?
SELECT Service, SUM(Budget) OVER(PARTITION BY Service) as TotalBudget FROM CityBudget WHERE Population > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (Id INT, Age INT, Gender VARCHAR(10)); CREATE TABLE Workouts (Id INT, MemberId INT, Duration INT, Date DATE); INSERT INTO Members (Id, Age, Gender) VALUES (1, 25, 'Female'), (2, 32, 'Male'), (3, 45, 'Female'), (4, 28, 'Non-binary'); INSERT INTO Workouts (Id, MemberId, Duration, Date) VALUES (1, 1, 60, '2022-10-01'), (2, 1, 45, '2022-10-02'), (3, 2, 90, '2022-10-01'), (4, 2, 75, '2022-10-03'), (5, 3, 120, '2022-10-01'), (6, 3, 150, '2022-10-02');
What is the maximum duration of a workout for each member in October?
SELECT MemberId, MAX(Duration) FROM Workouts GROUP BY MemberId;
gretelai_synthetic_text_to_sql
CREATE TABLE user_steps (user_id INT, date DATE, steps INT);
Count the number of users who have a step count greater than 10000 for at least 10 days in the last 14 days.
SELECT COUNT(DISTINCT user_id) FROM user_steps WHERE steps > 10000 GROUP BY user_id HAVING COUNT(DISTINCT date) >= 10 AND date >= CURDATE() - INTERVAL 14 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (CompanyID INT, CompanyName VARCHAR(50), Industry VARCHAR(30)); CREATE TABLE Investments (InvestmentID INT, InvestorID INT, CompanyID INT, InvestmentAmount DECIMAL(10, 2));
What is the average investment amount for companies in the biotechnology industry?
SELECT C.Industry, AVG(I.InvestmentAmount) AS AvgInvestmentAmount FROM Companies C JOIN Investments I ON C.CompanyID = I.CompanyID WHERE C.Industry = 'Biotechnology' GROUP BY C.Industry;
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Statistics (id INT, employee_count INT, year INT, state VARCHAR(20)); INSERT INTO Labor_Statistics (id, employee_count, year, state) VALUES (1, 15000, 2015, 'Texas'), (2, 16000, 2016, 'Texas'), (3, 18000, 2017, 'Texas'), (4, 19000, 2018, 'Texas'), (5, 20000, 2019, 'Texas'), (6, 22000, 2020, 'Texas');
What is the average construction labor employment in the state of Texas between 2015 and 2020?
SELECT AVG(employee_count) FROM Labor_Statistics WHERE state = 'Texas' AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (id INT, city TEXT, views INT, clicks INT); INSERT INTO virtual_tours (id, city, views, clicks) VALUES (1, 'New York', 100, 50), (2, 'Los Angeles', 150, 75), (3, 'Paris', 200, 100);
Identify the top 3 cities with the highest virtual tour engagement.
SELECT city, (views + clicks) as engagement FROM virtual_tours GROUP BY city ORDER BY engagement DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, date DATE, system TEXT, vulnerability TEXT, severity TEXT);INSERT INTO vulnerabilities (id, date, system, vulnerability, severity) VALUES (1, '2021-01-02', 'webserver', 'SQL injection', 'high'); CREATE TABLE systems (id INT, system TEXT, location TEXT);INSERT INTO systems (id, system, location) VALUES (1, 'webserver', 'USA');
Identify systems with the highest number of high severity vulnerabilities.
SELECT s.system, s.location, COUNT(v.id) as high_vulnerabilities FROM systems s JOIN vulnerabilities v ON s.system = v.system WHERE v.severity = 'high' GROUP BY s.system, s.location ORDER BY high_vulnerabilities DESC FETCH FIRST 5 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, category TEXT, is_organic BOOLEAN, is_vegan BOOLEAN, sugar_grams FLOAT); INSERT INTO products (id, category, is_organic, is_vegan, sugar_grams) VALUES (1, 'dessert', true, true, 12.5), (2, 'dessert', false, true, 15.0), (3, 'dessert', true, false, 8.0), (4, 'dessert', false, false, 10.0);
What is the average sugar content in organic vegan desserts?
SELECT AVG(sugar_grams) FROM products WHERE is_organic = true AND is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_circle_permits (company VARCHAR(255), region VARCHAR(255), permit_number INT);
Show unique drilling permits issued to GHI Oil & Gas in the Arctic Circle.
SELECT DISTINCT permit_number FROM arctic_circle_permits WHERE company = 'GHI Oil & Gas';
gretelai_synthetic_text_to_sql
CREATE TABLE Founders (id INT, name TEXT, gender TEXT); INSERT INTO Founders (id, name, gender) VALUES (1, 'Alex', 'Male'); INSERT INTO Founders (id, name, gender) VALUES (2, 'Taylor', 'Non-binary'); CREATE TABLE Companies (id INT, name TEXT, founder_id INT, funding_received BOOLEAN); INSERT INTO Companies (id, name, founder_id, funding_received) VALUES (1, 'GreenTech', 1, TRUE); INSERT INTO Companies (id, name, founder_id, funding_received) VALUES (2, 'EcoSolutions', 2, TRUE);
Show the number of unique founders who have founded companies that have received funding.
SELECT COUNT(DISTINCT Founders.name) FROM Founders INNER JOIN Companies ON Founders.id = Companies.founder_id WHERE Companies.funding_received = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT, created_at DATETIME); INSERT INTO articles (id, title, category, likes, created_at) VALUES (1, 'Climate crisis: 12 years to save the planet', 'climate change', 100, '2022-01-01 10:30:00');
What are the total likes received by articles in each category, ordered from most to least?
SELECT category, SUM(likes) as total_likes FROM articles GROUP BY category ORDER BY total_likes DESC
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, region VARCHAR(50), investment_date DATE, amount DECIMAL(10, 2)); INSERT INTO network_investments (investment_id, region, investment_date, amount) VALUES (1, 'North', '2021-07-01', 50000), (2, 'South', '2021-08-15', 45000), (3, 'East', '2021-09-30', 60000), (4, 'West', '2021-07-20', 55000), (5, 'North', '2021-08-05', 47000);
What is the total network investment for each region in Q3 2021?
SELECT region, SUM(amount) AS total_investment FROM network_investments WHERE investment_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), level INT);
Update 'players' level to 12 where name is 'Jessica'
UPDATE players SET level = 12 WHERE name = 'Jessica';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, material VARCHAR(20), price DECIMAL(5,2), market VARCHAR(20)); INSERT INTO products (product_id, material, price, market) VALUES (1, 'organic cotton', 70.00, 'Middle East'), (2, 'sustainable wood', 80.00, 'Asia'), (3, 'recycled polyester', 60.00, 'Europe'), (4, 'organic linen', 90.00, 'Middle East');
What is the minimum price of products made from sustainable materials in the Middle Eastern market?
SELECT MIN(price) FROM products WHERE market = 'Middle East' AND material IN ('organic cotton', 'sustainable wood', 'recycled polyester', 'organic linen');
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (astronaut_name VARCHAR(30), age INT, first_mission_date DATE, nationality VARCHAR(20)); INSERT INTO Astronauts (astronaut_name, age, first_mission_date, nationality) VALUES ('Astronaut3', 45, '2005-01-01', 'India');
What is the average age of astronauts from India during their first space mission?
SELECT AVG(age) FROM Astronauts WHERE nationality = 'India' AND first_mission_date = (SELECT MIN(first_mission_date) FROM Astronauts WHERE nationality = 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjects (state VARCHAR(20), capacity FLOAT); INSERT INTO RenewableEnergyProjects (state, capacity) VALUES ('StateA', 150.0), ('StateB', 200.0), ('StateC', 250.0), ('StateD', 300.0);
What is the total installed capacity of renewable energy projects per state?
SELECT state, SUM(capacity) FROM RenewableEnergyProjects GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, program VARCHAR(50), country VARCHAR(50)); CREATE TABLE Programs (id INT, program VARCHAR(50), country VARCHAR(50)); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (1, 120.00, '2021-03-01', 'Health', 'Colombia'); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (2, 200.00, '2021-03-02', 'Education', 'Colombia'); INSERT INTO Programs (id, program, country) VALUES (1, 'Health', 'Colombia'); INSERT INTO Programs (id, program, country) VALUES (2, 'Education', 'Colombia');
What is the average donation per month for each program in Colombia?
SELECT p.program, EXTRACT(MONTH FROM d.donation_date) as month, AVG(d.donation_amount) as avg_donation_per_month FROM Donations d INNER JOIN Programs p ON d.program = p.program WHERE d.country = 'Colombia' GROUP BY p.program, month;
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation (state VARCHAR(255), year INT, success BOOLEAN, initiative_id INT); INSERT INTO water_conservation (state, year, success, initiative_id) VALUES ('California', 2018, true, 1001), ('California', 2018, false, 1002), ('California', 2019, true, 2001), ('California', 2019, true, 2002), ('New York', 2018, false, 3001), ('New York', 2018, true, 3002), ('New York', 2019, true, 4001), ('New York', 2019, false, 4002);
What is the percentage of water conservation initiatives that were successful in each state, for the years 2018 and 2019, and what was the total number of initiatives for each state during those years?
SELECT state, SUM(success) as total_successes, COUNT(initiative_id) as total_initiatives, 100.0 * SUM(success) / COUNT(initiative_id) as success_percentage FROM water_conservation WHERE year IN (2018, 2019) GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Drought_Impact_Area (id INT, area VARCHAR(30), year INT, impact FLOAT, state VARCHAR(20)); INSERT INTO Drought_Impact_Area (id, area, year, impact, state) VALUES (1, 'Area1', 2014, 5.6, 'StateZ'), (2, 'Area2', 2015, 6.2, 'StateY'), (3, 'Area3', 2017, 4.1, 'StateY');
Show all drought-impacted areas in 'StateY' since 2015
SELECT DISTINCT area FROM Drought_Impact_Area WHERE state = 'StateY' AND year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(255), country VARCHAR(255), rating FLOAT);
What is the average rating of movies produced in each country?
SELECT country, AVG(rating) AS avg_rating FROM Movies GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk (id INT, region VARCHAR(255), assessment TEXT); INSERT INTO geopolitical_risk (id, region, assessment) VALUES (1, 'Americas', 'Medium Risk'); INSERT INTO geopolitical_risk (id, region, assessment) VALUES (2, 'Europe', 'Low Risk');
Show geopolitical risk assessments for the Americas
SELECT region, assessment FROM geopolitical_risk WHERE region = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (id INT, name VARCHAR(255), category VARCHAR(255), budget FLOAT); INSERT INTO smart_cities (id, name, category, budget) VALUES (1, 'Intelligent Transport', 'traffic_management', 5000000.0); INSERT INTO smart_cities (id, name, category, budget) VALUES (2, 'Smart Grid', 'energy_efficiency', 8000000.0); INSERT INTO smart_cities (id, name, category, budget) VALUES (3, 'Smart Lighting', 'public_safety', 3000000.0); INSERT INTO smart_cities (id, name, category, budget) VALUES (4, 'Smart Waste Management', 'waste_management', 4000000.0); INSERT INTO smart_cities (id, name, category, budget) VALUES (5, 'Smart Water Management', 'water_management', 2000000.0);
What is the difference in budget between the most expensive and least expensive smart city technology adoption projects, and their respective categories?
SELECT least_expensive.name AS least_expensive_project, least_expensive.category AS least_expensive_category, most_expensive.name AS most_expensive_project, most_expensive.category AS most_expensive_category, most_expensive.budget - least_expensive.budget AS budget_difference FROM (SELECT name, category, budget, ROW_NUMBER() OVER (ORDER BY budget ASC) AS row_num FROM smart_cities) AS least_expensive JOIN (SELECT name, category, budget, ROW_NUMBER() OVER (ORDER BY budget DESC) AS row_num FROM smart_cities) AS most_expensive ON least_expensive.row_num = 1 AND most_expensive.row_num = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Public_Services( service_id INT PRIMARY KEY, service_name VARCHAR(255), location VARCHAR(255), budget FLOAT, created_date DATE);
Add a new record to the 'Public_Services' table
INSERT INTO Public_Services (service_id, service_name, location, budget, created_date) VALUES (4, 'Public Transportation', 'Seattle', 9000000.00, '2022-01-04');
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (name VARCHAR(50), location VARCHAR(50), avg_depth FLOAT);
What are the names of the deepest ocean trenches in the Atlantic Ocean?
SELECT name FROM ocean_trenches WHERE location = 'Atlantic Ocean' ORDER BY avg_depth DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, transaction_date DATE, quantity_sold INT, payment_method VARCHAR(255), region VARCHAR(255));
What is the average quantity of garments sold online per day in the 'New York' region?
SELECT AVG(quantity_sold / 365.25) as avg_quantity_sold_online_per_day FROM sales WHERE region = 'New York' AND payment_method IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_name VARCHAR(255), region VARCHAR(255), incident_date DATETIME); INSERT INTO security_incidents (id, incident_name, region, incident_date) VALUES (1, 'Phishing', 'South America', '2022-01-05'), (2, 'Data Breach', 'Europe', '2022-01-06');
How many security incidents were recorded in 'South America' in the last month?
SELECT COUNT(*) FROM security_incidents WHERE region = 'South America' AND incident_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, country TEXT, stars INT, has_accessibility BOOLEAN); INSERT INTO hotels (hotel_id, name, country, stars, has_accessibility) VALUES (1, 'India Palace', 'India', 4, TRUE), (2, 'Economy Inn', 'India', 2, FALSE);
What is the count of 4-star hotels in India that promote accessibility features?
SELECT COUNT(*) FROM hotels WHERE country = 'India' AND stars = 4 AND has_accessibility = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), prevalence FLOAT);
What are the most common mental health conditions in the US?
SELECT name FROM mental_health_conditions WHERE country = 'United States' GROUP BY name ORDER BY SUM(prevalence) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, City VARCHAR(50), HeartRate INT); INSERT INTO Workouts (WorkoutID, MemberID, City, HeartRate) VALUES (1,1,'New York',120),(2,2,'Los Angeles',130),(3,3,'Chicago',100);
What is the maximum heart rate recorded during workouts in each city?
SELECT City, MAX(HeartRate) FROM Workouts GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE police_officers (id INT, division VARCHAR(10), rank VARCHAR(10)); INSERT INTO police_officers (id, division, rank) VALUES (1, 'north', 'sergeant'), (2, 'south', 'officer'), (3, 'north', 'captain');
What is the total number of police officers in 'north' and 'south' divisions?
SELECT COUNT(*) FROM police_officers WHERE division IN ('north', 'south');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'Nigeria'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3, 'Alice Johnson', 'Kenya');CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount decimal(10, 2)); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 5000); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (2, 2, 1000); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (3, 2, 1500); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (4, 3, 2000);
What is the average donation amount from donors in Africa?
SELECT AVG(Donations.DonationAmount) FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.Country IN ('Nigeria', 'Kenya');
gretelai_synthetic_text_to_sql
CREATE TABLE seafood_exports (id INT, export_date DATE, export_country TEXT, import_country TEXT, quantity INT); INSERT INTO seafood_exports (id, export_date, export_country, import_country, quantity) VALUES (1, '2022-01-01', 'Canada', 'USA', 500); INSERT INTO seafood_exports (id, export_date, export_country, import_country, quantity) VALUES (2, '2022-01-15', 'Canada', 'USA', 600);
What was the total amount of seafood exported from Canada to the US in Q1 2022?
SELECT SUM(quantity) FROM seafood_exports WHERE export_country = 'Canada' AND import_country = 'USA' AND export_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), status VARCHAR(50)); CREATE TABLE vessel_movements (movement_id INT, vessel_id INT, port_id INT, movement_date DATE);
Which vessels arrived at the Port of Singapore in the last 30 days?
SELECT V.vessel_name FROM vessels V JOIN vessel_movements VM ON V.vessel_id = VM.vessel_id WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Port of Singapore') AND movement_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, ExhibitionName VARCHAR(255), Category VARCHAR(255), Visitors INT); INSERT INTO Exhibitions (ExhibitionID, ExhibitionName, Category, Visitors) VALUES (1, 'Digital Art Exhibition', 'Digital Art', 1500), (2, 'Interactive Art Exhibition', 'Digital Art', 800);
What is the maximum number of visitors for exhibitions in the "Digital Art" category?
SELECT MAX(Visitors) FROM Exhibitions WHERE Category = 'Digital Art';
gretelai_synthetic_text_to_sql
CREATE TABLE mineral_survey (id INT, mine_name VARCHAR, mineral VARCHAR, percentage_composition DECIMAL); INSERT INTO mineral_survey (id, mine_name, mineral, percentage_composition) VALUES (1, 'Crystal Mine', 'Quartz', 45.00), (2, 'Gemstone Gulch', 'Emerald', 75.00), (3, 'Ore Mountain', 'Gold', 90.00), (4, 'Granite Grove', 'Granite', 100.00);
How many unique mineral types are there in the 'mineral_survey' table?
SELECT COUNT(DISTINCT mineral) FROM mineral_survey;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), data_usage FLOAT, city VARCHAR(50));
What is the monthly data usage for the top 5 customers in the city of Seattle?
SELECT data_usage FROM customers WHERE city = 'Seattle' AND id IN (SELECT id FROM (SELECT id FROM customers WHERE city = 'Seattle' ORDER BY data_usage DESC LIMIT 5) subquery) ORDER BY data_usage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_id INT, building_type VARCHAR(20), state VARCHAR(20)); INSERT INTO building_permits (permit_id, building_type, state) VALUES (1, 'Residential', 'California'), (2, 'Commercial', 'California'), (3, 'Residential', 'Texas'), (4, 'Commercial', 'Texas');
What is the total number of permits issued for commercial buildings in the state of Texas?
SELECT COUNT(*) FROM building_permits WHERE building_type = 'Commercial' AND state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_months (month VARCHAR(255), id INTEGER); INSERT INTO arctic_months (month, id) VALUES ('January', 1), ('February', 2), ('March', 3); CREATE TABLE water_temperature (month_id INTEGER, value FLOAT);
What is the average water temperature in the Arctic Ocean by month?
SELECT m.month, AVG(t.value) FROM water_temperature t JOIN arctic_months m ON t.month_id = m.id GROUP BY m.month;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, country VARCHAR(50)); INSERT INTO wells (well_id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil'), (5, 'Nigeria'), (6, 'Norway');
Find the top 5 countries with the highest number of wells.
SELECT country, COUNT(*) as num_wells FROM wells GROUP BY country ORDER BY num_wells DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE MineType (id INT, name VARCHAR(255)); INSERT INTO MineType (id, name) VALUES (1, 'Open Pit'), (2, 'Underground'); CREATE TABLE MineLocation (id INT, name VARCHAR(255)); INSERT INTO MineLocation (id, name) VALUES (1, 'Mountain X'), (2, 'Hill Y'); CREATE TABLE GoldMine (mine_type_id INT, mine_location_id INT); INSERT INTO GoldMine (mine_type_id, mine_location_id) VALUES (1, 1), (2, 2);
List all unique mine types and their locations where gold is being mined.
SELECT DISTINCT mt.name AS mine_type, ml.name AS location FROM MineType mt, MineLocation ml, GoldMine gm WHERE mt.id = gm.mine_type_id AND ml.id = gm.mine_location_id;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness (id INT, state VARCHAR(20), date DATE, drill_type VARCHAR(20), quantity INT);
How many disaster preparedness drills have been conducted in the state of Florida in the past year?
SELECT SUM(quantity) FROM DisasterPreparedness WHERE state = 'Florida' AND date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, post_text TEXT); CREATE TABLE users (id INT, privacy_setting VARCHAR(20)); INSERT INTO users (id, privacy_setting) VALUES (1, 'medium'), (2, 'high'), (3, 'low'); INSERT INTO posts (id, user_id, post_text) VALUES (1, 1, 'Hello World!'), (2, 2, 'Goodbye World!'), (3, 3, 'This is a private post.');
Add a new table for storing the number of likes on each post
CREATE TABLE post_likes (id INT, post_id INT, likes INT);
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), cost FLOAT, space_agency_id INT); CREATE TABLE space_agencies (id INT, name VARCHAR(50));
What are the top 5 most expensive space missions and the space agency that funded them?
SELECT m.name, a.name as space_agency FROM space_missions m JOIN space_agencies a ON m.space_agency_id = a.id ORDER BY m.cost DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(50), salary INT, contributed_to_accessibility BOOLEAN); INSERT INTO developers (developer_id, name, salary, contributed_to_accessibility) VALUES (1, 'Diana', 80000, TRUE), (2, 'Elijah', 85000, FALSE), (3, 'Fiona', 70000, TRUE);
What is the average salary of developers who have contributed to open-source projects focused on technology accessibility, and what is the average salary of developers who have not contributed to such projects?
SELECT AVG(salary) FROM developers WHERE contributed_to_accessibility = TRUE; SELECT AVG(salary) FROM developers WHERE contributed_to_accessibility = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE aquaculture_farms (farm_name VARCHAR(50), location VARCHAR(50), region VARCHAR(50));
List all the aquaculture farms located in Southeast Asia.
SELECT farm_name, location FROM aquaculture_farms WHERE region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(50), country VARCHAR(20)); INSERT INTO artist (artist_id, artist_name, country) VALUES (1, 'Artist A', 'USA'), (2, 'Artist B', 'Canada'); CREATE TABLE song (song_id INT, song_name VARCHAR(50), artist_id INT, length INT); INSERT INTO song (song_id, song_name, artist_id, length) VALUES (1, 'Song 1', 1, 180), (2, 'Song 2', 2, 210);
What is the average length (in seconds) of songs released by artists from the USA?
SELECT AVG(s.length) FROM artist a JOIN song s ON a.artist_id = s.artist_id WHERE a.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Port of Long Beach'), (2, 'Port of Los Angeles'); CREATE TABLE vessel (vessel_id INT, vessel_name VARCHAR(50), port_id INT); INSERT INTO vessel (vessel_id, vessel_name, port_id) VALUES (1, 'Vessel C', 1), (2, 'Vessel D', 2), (3, 'Vessel C', 2), (4, 'Vessel E', 1);
What are the names of vessels that have visited both the Port of Long Beach and the Port of Los Angeles?
SELECT DISTINCT vessel_name FROM vessel WHERE port_id IN (1, 2) AND vessel_name IN (SELECT vessel_name FROM vessel WHERE port_id = 1 INTERSECT SELECT vessel_name FROM vessel WHERE port_id = 2)
gretelai_synthetic_text_to_sql
CREATE TABLE genetics_research (id INT, project_name VARCHAR(50), lead_name VARCHAR(50), lead_email VARCHAR(50)); INSERT INTO genetics_research (id, project_name, lead_name, lead_email) VALUES (1, 'Project C', 'Emma White', 'emmawhite@email.com'); INSERT INTO genetics_research (id, project_name, lead_name, lead_email) VALUES (2, 'Project D', 'Oliver Black', 'oliverblack@email.com');
Who is the lead researcher for the genetic research project 'Project C' in Canada?
SELECT lead_name FROM genetics_research WHERE project_name = 'Project C' AND lead_email LIKE '%.ca';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, position TEXT, team TEXT, fielding_percentage DECIMAL(3,2)); INSERT INTO players (id, name, position, team, fielding_percentage) VALUES (1, 'John Doe', 'Outfielder', 'Team A', 0.98), (2, 'Jane Smith', 'Outfielder', 'Team B', 0.97), (3, 'Mike Johnson', 'Outfielder', 'Team C', 0.99);
Who had the highest fielding percentage among outfielders in the 2020 season?
SELECT name, MAX(fielding_percentage) FROM players WHERE position = 'Outfielder' AND year = 2020 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, organization VARCHAR(255), operation_name VARCHAR(255), start_date DATE); INSERT INTO peacekeeping_operations (id, organization, operation_name, start_date) VALUES (1, 'African Union', 'African Union Mission in Somalia', '2007-01-01');
What is the total number of peacekeeping operations initiated by the African Union?
SELECT COUNT(*) FROM peacekeeping_operations WHERE organization = 'African Union';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), age INT, game_preference VARCHAR(20)); CREATE TABLE esports_events (id INT, event_name VARCHAR(50), date DATE, player_id INT); INSERT INTO players (id, name, age, game_preference) VALUES (1, 'John Doe', 25, 'VR'); INSERT INTO esports_events (id, event_name, date, player_id) VALUES (1, 'GameX', '2023-06-01', 1);
What are the game preferences of players who have participated in esports events?
SELECT players.game_preference FROM players INNER JOIN esports_events ON players.id = esports_events.player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Dysprosium_Production (Year INT, Quantity INT); INSERT INTO Dysprosium_Production (Year, Quantity) VALUES (2015, 1000), (2016, 1200), (2017, 1400), (2018, 1600), (2019, 1800), (2020, 2000);
List the top 3 years with the highest Dysprosium production.
SELECT Year, Quantity FROM Dysprosium_Production ORDER BY Quantity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE music_genres (genre VARCHAR(255), country VARCHAR(255), revenue FLOAT); INSERT INTO music_genres (genre, country, revenue) VALUES ('Pop', 'Canada', 9000.0), ('Rock', 'Canada', 7000.0), ('Jazz', 'Canada', 4000.0);
Update the revenue for the Pop genre in Canada for the year 2021 to 9500.0
UPDATE music_genres SET revenue = 9500.0 WHERE genre = 'Pop' AND country = 'Canada' AND YEAR(event_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyIncidents (IncidentID INT, VesselID INT, IncidentLocation VARCHAR(50), IncidentDate DATE); INSERT INTO SafetyIncidents (IncidentID, VesselID, IncidentLocation, IncidentDate) VALUES (1, 1, 'Europe', '2021-01-01'), (2, 1, 'Europe', '2021-02-01'), (3, 2, 'Europe', '2021-03-01'), (4, 3, 'Europe', '2021-04-01'), (5, 3, 'Europe', '2021-05-01'), (6, 1, 'Europe', '2021-07-01'), (7, 2, 'Europe', '2021-08-01'), (8, 4, 'Europe', '2021-09-01'), (9, 4, 'Europe', '2021-10-01'), (10, 5, 'Europe', '2021-11-01'), (11, 5, 'Europe', '2021-12-01');
What is the total number of safety incidents in European waters for each quarter?
SELECT DATE_FORMAT(IncidentDate, '%Y-%m') AS Quarter, IncidentLocation, COUNT(*) AS TotalIncidents FROM SafetyIncidents WHERE IncidentLocation = 'Europe' GROUP BY Quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, country VARCHAR(20)); INSERT INTO mobile_customers (customer_id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'USA'), (5, 'Canada');
How many mobile customers are there in each country?
SELECT country, COUNT(*) FROM mobile_customers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, region_name VARCHAR(50)); INSERT INTO regions (id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'); CREATE TABLE product_types (id INT, product_type VARCHAR(50)); INSERT INTO product_types (id, product_type) VALUES (1, 'Stocks'), (2, 'Bonds'); CREATE TABLE transactions (region_id INT, product_type_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (region_id, product_type_id, transaction_amount) VALUES (1, 1, 200.00), (1, 1, 300.00), (2, 1, 100.00), (2, 1, 400.00), (1, 2, 50.00), (1, 2, 150.00), (2, 2, 75.00), (2, 2, 225.00);
What is the average transaction amount for each region and product type?
SELECT r.region_name, p.product_type, AVG(t.transaction_amount) as avg_transaction_amount FROM regions r JOIN transactions t ON r.id = t.region_id JOIN product_types p ON t.product_type_id = p.id GROUP BY r.region_name, p.product_type;
gretelai_synthetic_text_to_sql
CREATE TABLE storage_facilities (facility_id INT, name TEXT, location TEXT, safety_violation_flag BOOLEAN);
What are the names and locations of all chemical storage facilities that have received a safety violation in the past year?
SELECT name, location FROM storage_facilities WHERE safety_violation_flag = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (region VARCHAR(255), stock_count INT); INSERT INTO Farm (region, stock_count) VALUES ('North Pacific', 2200), ('North Pacific', 1800), ('South China Sea', 2500);
List the farms in the North Pacific region with a stock count greater than 2000?
SELECT * FROM Farm WHERE region = 'North Pacific' AND stock_count > 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (Id INT, Name VARCHAR(100)); CREATE TABLE CommunityEvent (Id INT, CountryId INT, EventType VARCHAR(50), StartDate DATE, EndDate DATE, Quantity INT);
Identify the top 3 countries with the most community engagement events, and display the number of events, start and end dates for each event, and the event type.
SELECT CountryId, Name, EventType, StartDate, EndDate, Quantity FROM (SELECT CountryId, Name, EventType, StartDate, EndDate, Quantity, ROW_NUMBER() OVER (PARTITION BY CountryId ORDER BY Quantity DESC) as RowNum FROM Country c JOIN CommunityEvent ce ON c.Id = ce.CountryId) x WHERE RowNum <= 3 ORDER BY Quantity DESC, StartDate;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, developer_name VARCHAR(255)); CREATE TABLE decentralized_exchanges (exchange_name VARCHAR(255), developer_id INT, transaction_count INT, trading_volume DECIMAL(10, 2));
Find the total number of transactions and trading volume for each developer in the 'developers' and 'decentralized_exchanges' tables.
SELECT d.developer_name, SUM(de.transaction_count) as total_transactions, SUM(de.trading_volume) as total_volume FROM developers d INNER JOIN decentralized_exchanges de ON d.developer_id = de.developer_id GROUP BY d.developer_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT PRIMARY KEY, name VARCHAR(255), vessel_type VARCHAR(255), year_built INT); INSERT INTO vessels (id, name, vessel_type, year_built) VALUES (1, 'ABC Tanker', 'Tanker', 2000), (2, 'DEF Bulker', 'Bulker', 2010);
Delete records in the vessels table where the vessel_type is 'Tanker' and the year_built is before 2005
DELETE FROM vessels WHERE vessel_type = 'Tanker' AND year_built < 2005;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT, country TEXT, year INT, status TEXT); INSERT INTO schools (id, country, year, status) VALUES (1, 'Nigeria', 2018, 'Built'), (2, 'Kenya', 2019, 'Repaired'), (3, 'Nigeria', 2020, 'Built');
Find the total number of schools built or repaired in Nigeria and Kenya between 2018 and 2020?
SELECT COUNT(*) FROM schools WHERE country IN ('Nigeria', 'Kenya') AND year BETWEEN 2018 AND 2020 AND status IN ('Built', 'Repaired');
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (model VARCHAR(255), manufacturer VARCHAR(255)); CREATE TABLE Accidents (aircraft_model VARCHAR(255), manufacturer VARCHAR(255), accident_date DATE); INSERT INTO Aircraft (model, manufacturer) VALUES ('ModelA', 'Manufacturer1'); INSERT INTO Aircraft (model, manufacturer) VALUES ('ModelB', 'Manufacturer2'); INSERT INTO Accidents (aircraft_model, manufacturer, accident_date) VALUES ('ModelA', 'Manufacturer1', '2019-01-01'); INSERT INTO Accidents (aircraft_model, manufacturer, accident_date) VALUES ('ModelB', 'Manufacturer2', '2018-01-01');
What are the names and manufacturers of aircraft involved in accidents in 2019?
SELECT Aircraft.model, Aircraft.manufacturer FROM Aircraft INNER JOIN Accidents ON Aircraft.model = Accidents.aircraft_model WHERE Accidents.accident_date >= '2019-01-01' AND Accidents.accident_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Region (ID INT, Name VARCHAR(50)); INSERT INTO Region (ID, Name) VALUES (1, 'North America'), (2, 'Europe'), (3, 'Asia'), (4, 'Africa'), (5, 'South America'); CREATE TABLE ResearchPapers (ID INT, Title VARCHAR(100), PublishedDate DATE, Author VARCHAR(50), Region VARCHAR(50)); INSERT INTO ResearchPapers (ID, Title, PublishedDate, Author, Region) VALUES (1, 'AD Research 1', '2021-01-15', 'A. Smith', 'North America'), (2, 'AD Research 2', '2022-03-20', 'B. Johnson', 'Europe'), (3, 'AD Research 3', '2020-12-12', 'C. Lee', 'Asia'), (4, 'AD Research 4', '2021-05-08', 'D. Patel', 'Africa'), (5, 'AD Research 5', '2020-11-01', 'E. Chen', 'South America');
What is the total number of autonomous driving research papers published in the last two years by region?
SELECT Region, COUNT(*) as Total_Papers FROM ResearchPapers WHERE PublishedDate >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, country VARCHAR(50)); INSERT INTO wells (well_id, country) VALUES (1, 'Nigeria'), (2, 'Angola'), (3, 'Gabon');
Compare the number of wells drilled in Nigeria and Angola.
SELECT 'Nigeria' as country, COUNT(*) as num_wells FROM wells WHERE country = 'Nigeria' UNION ALL SELECT 'Angola' as country, COUNT(*) as num_wells FROM wells WHERE country = 'Angola';
gretelai_synthetic_text_to_sql
CREATE TABLE VRHardwareOceania (HardwareID INT, HardwareName VARCHAR(100), AdoptionRevenue DECIMAL(10,2), Country VARCHAR(50)); INSERT INTO VRHardwareOceania (HardwareID, HardwareName, AdoptionRevenue, Country) VALUES (1, 'VR Headset A', 500.00, 'Australia'), (2, 'VR Headset B', 700.00, 'New Zealand'), (3, 'VR Headset C', 600.00, 'Papua New Guinea');
What is the minimum adoption revenue of virtual reality hardware in Oceania?
SELECT MIN(AdoptionRevenue) FROM VRHardwareOceania WHERE Country = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_activities (region VARCHAR(50), crop VARCHAR(50), planting_date DATE); INSERT INTO farm_activities VALUES ('West Coast', 'Wheat', '2022-04-01'); INSERT INTO farm_activities VALUES ('West Coast', 'Corn', '2022-05-01'); INSERT INTO farm_activities VALUES ('East Coast', 'Rice', '2022-06-01'); INSERT INTO farm_activities VALUES ('East Coast', 'Wheat', '2022-04-01'); INSERT INTO farm_activities VALUES ('East Coast', 'Corn', '2022-05-01');
What is the distribution of crops in 'farm_activities' table per region?
SELECT region, crop, COUNT(*) OVER (PARTITION BY region, crop) AS count FROM farm_activities;
gretelai_synthetic_text_to_sql
CREATE TABLE programs_q4_2022 (id INT, program_name VARCHAR(50), participants INT, donation_amount DECIMAL(10,2)); INSERT INTO programs_q4_2022 (id, program_name, participants, donation_amount) VALUES (1, 'Program M', 600, 8000.00), (2, 'Program N', 400, 7000.00), (3, 'Program O', 800, 9000.00), (4, 'Program P', 300, 6000.00), (5, 'Program Q', 700, 10000.00);
What's the total donation amount for each program in Q4 2022, only for programs with more than 500 participants?
SELECT program_name, SUM(donation_amount) as total_donation FROM programs_q4_2022 WHERE participants > 500 GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (ID INT PRIMARY KEY, Name VARCHAR(50)); CREATE TABLE Workouts (ID INT PRIMARY KEY, UserID INT, Duration DECIMAL(10,2), Date DATE);
What is the total number of workouts and the total duration of workouts for each user in the past month?
SELECT Users.Name, COUNT(Workouts.ID) AS TotalWorkouts, SUM(Workouts.Duration) AS TotalDuration FROM Users JOIN Workouts ON Users.ID = Workouts.UserID WHERE Workouts.Date >= DATEADD(month, -1, GETDATE()) GROUP BY Users.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE CityPolicy (CityName VARCHAR(50), Policy VARCHAR(50), ImplementationYear INT, PolicyImpact DECIMAL(3,2)); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('Delhi', 'Traffic Improvement', 2019, 0.12); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('Delhi', 'Waste Management', 2020, 0.20); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('Tokyo', 'Park Enhancement', 2019, 0.15); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('Tokyo', 'Transit Expansion', 2020, 0.30); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('RioDeJaneiro', 'Education Reform', 2018, 0.18); INSERT INTO CityPolicy (CityName, Policy, ImplementationYear, PolicyImpact) VALUES ('RioDeJaneiro', 'Healthcare Access', 2019, 0.25);
What is the average policy impact for each city?
SELECT CityName, AVG(PolicyImpact) as AveragePolicyImpact FROM CityPolicy GROUP BY CityName;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(255), launch_date DATE, location VARCHAR(255), type VARCHAR(255));
Create a new table named 'space_debris'
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(255), launch_date DATE, location VARCHAR(255), type VARCHAR(255));
gretelai_synthetic_text_to_sql
CREATE TABLE Disease (name VARCHAR(50), prevalence FLOAT); INSERT INTO Disease (name, prevalence) VALUES ('Brazil', 0.2), ('Argentina', 0.01);
What is the prevalence of malaria in South America?
SELECT AVG(prevalence) FROM Disease WHERE name IN ('Brazil', 'Argentina');
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, name VARCHAR(255));
Insert a new excavation site named "La Santana" into the excavation_sites table.
INSERT INTO excavation_sites (id, name) VALUES ((SELECT MAX(id) FROM excavation_sites) + 1, 'La Santana');
gretelai_synthetic_text_to_sql
CREATE TABLE UnionMembers (MemberID INT, UnionID INT, Gender VARCHAR(10)); INSERT INTO UnionMembers (MemberID, UnionID, Gender) VALUES (1, 1001, 'Female'); INSERT INTO UnionMembers (MemberID, UnionID, Gender) VALUES (2, 1002, 'Male'); CREATE TABLE UnionContracts (ContractID INT, UnionID INT, NegotiationDate DATE); INSERT INTO UnionContracts (ContractID, UnionID, NegotiationDate) VALUES (1, 1001, '2021-03-15'); INSERT INTO UnionContracts (ContractID, UnionID, NegotiationDate) VALUES (2, 1002, '2020-09-01');
Calculate the number of female and male members in unions that negotiated a contract within the last year, grouped by gender
SELECT u.Gender, COUNT(u.MemberID) as Total FROM UnionMembers u INNER JOIN UnionContracts c ON u.UnionID = c.UnionID WHERE c.NegotiationDate >= DATEADD(year, -1, GETDATE()) GROUP BY u.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, name VARCHAR(255)); CREATE TABLE artifacts (id INT, excavation_site_id INT, year INT, type VARCHAR(255));
Find the number of artifacts excavated in 2020 from each excavation site.
SELECT es.name, COUNT(a.id) as artifact_count FROM excavation_sites es JOIN artifacts a ON es.id = a.excavation_site_id WHERE a.year = 2020 GROUP BY es.name;
gretelai_synthetic_text_to_sql
CREATE TABLE network_towers (tower_id INT, upgrade_date DATE); INSERT INTO network_towers (tower_id, upgrade_date) VALUES (1, '2020-01-01'), (2, '2020-06-15'), (3, '2019-12-31');
List all the towers that have not been upgraded in the last year.
SELECT * FROM network_towers WHERE upgrade_date < DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'editorial'), (2, 'sales'), (3, 'marketing');
Find the number of employees in the 'editorial' department
SELECT COUNT(*) FROM departments WHERE name = 'editorial';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers(SupplierID INT, Name VARCHAR(50), Type VARCHAR(50));CREATE TABLE MeatProducts(ProductID INT, SupplierID INT, ProductName VARCHAR(50), Quantity INT);INSERT INTO Suppliers VALUES (1, 'MeatCo', 'Meat Supplier'), (2, 'FreshFruits', 'Fruit Supplier');INSERT INTO MeatProducts VALUES (1, 1, 'Beef', 200), (2, 1, 'Chicken', 300), (3, 2, 'Apples', 500);
Display the names of suppliers that exclusively provide meat products?
SELECT Name FROM Suppliers WHERE SupplierID NOT IN (SELECT SupplierID FROM MeatProducts EXCEPT SELECT SupplierID FROM MeatProducts WHERE ProductName = 'Beef' OR ProductName = 'Chicken');
gretelai_synthetic_text_to_sql
CREATE TABLE london_transport (route_id INT, company VARCHAR(20), vehicle_type VARCHAR(10)); INSERT INTO london_transport (route_id, company, vehicle_type) VALUES (1, 'Bus Company', 'Bus'), (2, 'Bus Company', 'Bus'), (3, 'Train Company', 'Train'), (4, 'Train Company', 'Train');
How many routes are there in the London public transportation system for each vehicle type?
SELECT vehicle_type, COUNT(DISTINCT route_id) FROM london_transport GROUP BY vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (route_name VARCHAR(20), fare_date DATE, fare FLOAT); INSERT INTO fares (route_name, fare_date, fare) VALUES ('Green Line', '2021-04-01', 1.75), ('Blue Line', '2021-04-02', 3.25), ('Blue Line', '2021-04-03', 3.30), ('Blue Line', '2021-04-04', 3.20), ('Blue Line', '2021-04-05', 3.15), ('Blue Line', '2021-04-06', 3.10), ('Blue Line', '2021-04-07', 3.25);
What was the average fare for the 'Blue Line' in April 2021?
SELECT AVG(fare) FROM fares WHERE route_name = 'Blue Line' AND fare_date BETWEEN '2021-04-01' AND '2021-04-30';
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (dapp_id INT, name VARCHAR(50), network VARCHAR(50)); INSERT INTO dapps (dapp_id, name, network) VALUES (1, 'DApp1', 'Ethereum'), (2, 'DApp2', 'EOS'); CREATE TABLE regulatory_frameworks (framework_id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO regulatory_frameworks (framework_id, name, region) VALUES (1, 'GDPR', 'European Union'), (2, 'CCPA', 'United States');
List the decentralized applications and their respective regulatory frameworks in the European Union.
SELECT dapps.name, regulatory_frameworks.name FROM dapps INNER JOIN regulatory_frameworks ON dapps.network = regulatory_frameworks.region WHERE regulatory_frameworks.region = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (name TEXT, country TEXT); INSERT INTO marine_mammals (name, country) VALUES ('Bottlenose Dolphin', 'United States'); INSERT INTO marine_mammals (name, country) VALUES ('Blue Whale', 'Indonesia');
Which country has the highest number of marine mammal species?'
SELECT country, COUNT(*) AS total_species FROM marine_mammals GROUP BY country ORDER BY total_species DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE co_owned_prices (id INT, city VARCHAR(20), listing_price DECIMAL(10,2)); INSERT INTO co_owned_prices (id, city, listing_price) VALUES (1, 'New York', 1000000.00), (2, 'Seattle', 700000.00), (3, 'Oakland', 600000.00);
What is the lowest listing price for co-owned properties in each city?
SELECT city, MIN(listing_price) FROM co_owned_prices GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE union_bargaining_co (id INT, union_name TEXT, state TEXT, members INT, involved_in_bargaining BOOLEAN); INSERT INTO union_bargaining_co (id, union_name, state, members, involved_in_bargaining) VALUES (1, 'Union P', 'Colorado', 400, true), (2, 'Union Q', 'Colorado', 300, false), (3, 'Union R', 'Colorado', 500, true);
What is the average number of members in unions that are involved in collective bargaining in Colorado?
SELECT AVG(members) FROM union_bargaining_co WHERE state = 'Colorado' AND involved_in_bargaining = true;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, network VARCHAR(255), implementation_date DATE); INSERT INTO regulatory_frameworks (framework_id, network, implementation_date) VALUES (1, 'cardano', '2022-03-01'), (2, 'polkadot', '2022-02-01'); CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(255), network VARCHAR(255), creation_date DATE); INSERT INTO smart_contracts (contract_id, name, network, creation_date) VALUES (1, 'Contract1', 'cardano', '2022-03-15'), (2, 'Contract2', 'polkadot', '2022-02-15');
What are the names of the smart contracts in the 'cardano' network that were created after the regulatory framework was implemented?
SELECT name FROM smart_contracts WHERE network = 'cardano' AND creation_date > (SELECT implementation_date FROM regulatory_frameworks WHERE network = 'cardano');
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contract_deployments (contract_name TEXT, country TEXT, deployment_date DATE); INSERT INTO smart_contract_deployments (contract_name, country, deployment_date) VALUES ('Ethereum', 'Argentina', '2021-10-15'), ('EOS', 'Argentina', '2021-07-20');
What is the total number of smart contract deployments in Argentina during Q3 2021?
SELECT COUNT(*) FROM smart_contract_deployments WHERE country = 'Argentina' AND deployment_date >= '2021-07-01' AND deployment_date < '2021-10-01';
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(20), crop VARCHAR(20), quantity INT); INSERT INTO production VALUES ('US', 'Corn', 350), ('US', 'Soybeans', 120), ('Brazil', 'Corn', 80), ('Brazil', 'Soybeans', 150);
What is the total production of corn in the US and soybeans in Brazil?
SELECT SUM(quantity) FROM production WHERE country = 'US' AND crop = 'Corn' UNION SELECT SUM(quantity) FROM production WHERE country = 'Brazil' AND crop = 'Soybeans';
gretelai_synthetic_text_to_sql
CREATE TABLE product_sustainability (id INT PRIMARY KEY, product_name VARCHAR(255), material VARCHAR(255), carbon_footprint DECIMAL(5,2)); INSERT INTO product_sustainability (id, product_name, material, carbon_footprint) VALUES (1, 'T-Shirt', 'Organic Cotton', 8.2), (2, 'Pants', 'Recycled Polyester', 9.8), (3, 'Jacket', 'Organic Cotton', 11.3);
Update the product_sustainability table to set carbon_footprint to 7.5 for all products with material as 'Organic Cotton'
UPDATE product_sustainability SET carbon_footprint = 7.5 WHERE material = 'Organic Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE volleyball (team VARCHAR(50), won INT, lost INT);
What is the number of games played and won by each team, in the volleyball table?
SELECT team, SUM(won) AS games_won, SUM(lost) AS games_played FROM volleyball GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE coachella (year INT, revenue FLOAT); INSERT INTO coachella (year, revenue) VALUES (2017, 114.6), (2018, 147.3), (2019, 212.3), (2022, 250.0);
What was the revenue for the 2019 Coachella festival?
SELECT revenue FROM coachella WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_arts (id INT PRIMARY KEY, name TEXT, location TEXT);
Delete the traditional art record for 'Australia' with id 5
DELETE FROM traditional_arts WHERE id = 5 AND location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE video_views (video VARCHAR(255), channel VARCHAR(255), views INT, view_date DATE); INSERT INTO video_views (video, channel, views, view_date) VALUES ('Video1', 'Channel1', 10000, '2022-01-01'), ('Video2', 'Channel1', 12000, '2022-01-02'), ('Video3', 'Channel2', 15000, '2022-01-03'), ('Video4', 'Channel1', 11000, '2022-01-04'); ALTER TABLE video_views ADD CONSTRAINT chk_view_date CHECK (view_date >= DATEADD(month, -1, GETDATE()));
Show the number of daily views for each video on a specific channel over the last month.
SELECT channel, video, DATEADD(day, DATEDIFF(day, 0, view_date), 0) as view_date, ROW_NUMBER() OVER (PARTITION BY channel, DATEADD(day, DATEDIFF(day, 0, view_date), 0) ORDER BY views DESC) as rank FROM video_views WHERE channel = 'Channel1' ORDER BY view_date;
gretelai_synthetic_text_to_sql
CREATE TABLE complaints (product_name TEXT, launch_year INTEGER, complaint_count INTEGER); INSERT INTO complaints (product_name, launch_year, complaint_count) VALUES ('ProductA', 2021, 15), ('ProductB', 2020, 5), ('ProductC', 2019, 2);
Number of complaints for cosmetic products launched since 2020?
SELECT SUM(complaint_count) FROM complaints WHERE launch_year >= 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID int, ExperienceYears int, PrecedentID int); INSERT INTO Cases (CaseID, ExperienceYears, PrecedentID) VALUES (1, 12, 100), (2, 8, 101), (3, 8, 102), (4, 12, 101), (5, 4, 103), (6, 4, 104), (7, 12, 105);
Display the number of unique legal precedents cited in cases, grouped by the attorney's experience years.
SELECT ExperienceYears, COUNT(DISTINCT PrecedentID) FROM Cases GROUP BY ExperienceYears;
gretelai_synthetic_text_to_sql
CREATE TABLE coral_reefs (reef_name TEXT, min_depth_m INT, max_depth_m INT); INSERT INTO coral_reefs (reef_name, min_depth_m, max_depth_m) VALUES ('Great Barrier Reef', 0, 50), ('Coral Garden', 200, 500), ('Midnight Express', 700, 1000);
What is the minimum depth required for cold-water corals to grow?
SELECT MIN(min_depth_m) FROM coral_reefs WHERE min_depth_m > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (state VARCHAR(50), score INT); INSERT INTO health_equity_metrics (state, score) VALUES ('California', 85), ('Texas', 75), ('New York', 90), ('Florida', 80), ('Illinois', 70);
Update the average health equity metric score for New York to 95?
UPDATE health_equity_metrics SET score = 95 WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE samarium_production (year INT, region VARCHAR(20), quantity INT); INSERT INTO samarium_production (year, region, quantity) VALUES (2015, 'Brazil', 1500), (2015, 'Argentina', 1200), (2016, 'Brazil', 1700), (2016, 'Argentina', 1400);
What is the total quantity of Samarium produced annually in South America?
SELECT SUM(quantity) FROM samarium_production WHERE region IN ('Brazil', 'Argentina') GROUP BY year;
gretelai_synthetic_text_to_sql