context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE nba_assists (player_id INT, player_name TEXT, team_id INT, assists INT); INSERT INTO nba_assists (player_id, player_name, team_id, assists) VALUES (1, 'Luka Doncic', 18, 871), (2, 'James Harden', 17, 798);
Who has the highest number of assists in the 2022 NBA season for each team?
SELECT team_id, MAX(assists) OVER (PARTITION BY team_id ORDER BY team_id) AS highest_assists FROM nba_assists;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_sources (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_sources (id, name, country, capacity) VALUES (1, 'Wind', 'US', 150.1); INSERT INTO renewable_sources (id, name, country, capacity) VALUES (2, 'Solar', 'Spain', 50.1); INSERT INTO renewable_sources (id, name, country,...
List the total capacity (MW) of renewable energy sources in each country
SELECT country, SUM(capacity) FROM renewable_sources GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerGameStats (PlayerID INT, GamesPlayed INT); INSERT INTO PlayerGameStats (PlayerID, GamesPlayed) VALUES (1, 15), (2, 12), (3, 10), (4, 18), (5, 17), (6, 11), (7, 10), (8, 20), (9, 15), (10, 12), (11, 25), (12, 18), (13, 14), (14, 15), (15, 11), (16, 12), (17, 10), (18, 20), (19, 15), (20, 14); CREATE T...
What is the minimum number of games played by players from India?
SELECT MIN(PlayerGameStats.GamesPlayed) FROM PlayerGameStats JOIN PlayerLocation ON PlayerGameStats.PlayerID = PlayerLocation.PlayerID WHERE PlayerLocation.Location = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE players(id INT, name VARCHAR(50), country VARCHAR(50), last_login DATETIME); CREATE TABLE game_sessions(id INT, player_id INT, game_name VARCHAR(50), start_time DATETIME);
What is the number of active players in each country, defined as players who have played a game in the last month, grouped by country.
SELECT players.country, COUNT(DISTINCT players.id) as active_players FROM players JOIN game_sessions ON players.id = game_sessions.player_id WHERE start_time >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY players.country;
gretelai_synthetic_text_to_sql
CREATE TABLE matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), goals_home INT, goals_away INT);
How many goals has Messi scored in away matches?
SELECT SUM(goals_away) FROM matches WHERE away_team = 'Barcelona' AND player = 'Messi';
gretelai_synthetic_text_to_sql
CREATE TABLE factory_indonesia (factory VARCHAR(255), country VARCHAR(255), material VARCHAR(255), labor_cost DECIMAL(5,2)); INSERT INTO factory_indonesia (factory, country, material, labor_cost) VALUES ('Factory1', 'Indonesia', 'conventional cotton', 5.50), ('Factory2', 'Indonesia', 'recycled polyester', 4.75), ('Fact...
Delete factories in Indonesia that have a labor cost greater than $5.00 and do not use sustainable materials.
DELETE FROM factory_indonesia WHERE country = 'Indonesia' AND labor_cost > 5.00 AND material NOT IN ('organic cotton', 'recycled polyester');
gretelai_synthetic_text_to_sql
CREATE TABLE company_data (company_name VARCHAR(30), sector VARCHAR(20), min_salary INT); INSERT INTO company_data (company_name, sector, min_salary) VALUES ('CompanyX', 'Finance', 50000), ('CompanyY', 'Finance', 60000), ('CompanyZ', 'Retail', 40000);
What is the minimum salary in the 'finance' sector?
SELECT MIN(min_salary) FROM company_data WHERE sector = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_fashion (product_id INT, product_type VARCHAR(50), material_type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO ethical_fashion (product_id, product_type, material_type, price) VALUES (1, 'Ethical Fashion', 'Recycled Polyester', 50.00), (2, 'Ethical Fashion', 'Organic Cotton', 60.00), (3, 'Ethical F...
What is the average price of ethical fashion products made from recycled materials?
SELECT AVG(price) FROM ethical_fashion WHERE product_type = 'Ethical Fashion' AND material_type IN ('Recycled Polyester', 'Organic Cotton', 'Tencel');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (organization_name TEXT); INSERT INTO climate_finance (organization_name) VALUES ('Organization A'), ('Organization B'), ('Organization A'), ('Organization C'), ('Organization B'), ('Organization B');
Find the number of climate finance records for each organization, sorted by the number of records in descending order.
SELECT organization_name, COUNT(*) as records FROM climate_finance GROUP BY organization_name ORDER BY records DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (org_id INT PRIMARY KEY, name VARCHAR(255), industry VARCHAR(255), country VARCHAR(255)); INSERT INTO organization (org_id, name, industry, country) VALUES (2, 'Greenpeace Canada', 'Nonprofit', 'Canada');
What is the average donation to environmental nonprofits in Canada?
SELECT AVG(donation_amount) FROM (SELECT donation.amount AS donation_amount FROM donation JOIN organization ON donation.org_id = organization.org_id WHERE organization.country = 'Canada' AND organization.industry = 'Nonprofit' AND organization.name = 'Greenpeace Canada') AS donation_subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE middle_east_oil_production (country VARCHAR(255), year INT, oil_production FLOAT, gas_production FLOAT);
List the total production of oil and gas for each country in the Middle East for 2020.
SELECT country, SUM(oil_production) as total_oil_production, SUM(gas_production) as total_gas_production FROM middle_east_oil_production WHERE year = 2020 AND country IN ('Saudi Arabia', 'Iran', 'Iraq', 'UAE', 'Kuwait', 'Qatar') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ConcertID INT, ArtistID INT, ConcertDate DATE, Venue VARCHAR(100), TicketRevenue DECIMAL(10, 2)); INSERT INTO Concerts (ConcertID, ArtistID, ConcertDate, Venue, TicketRevenue) VALUES (1, 1, '2021-06-01', 'Stadium', 500000); INSERT INTO Concerts (ConcertID, ArtistID, ConcertDate, Venue, TicketReve...
What is the total revenue from concert ticket sales in 2021?
SELECT SUM(TicketRevenue) FROM Concerts WHERE YEAR(ConcertDate) = 2021;
gretelai_synthetic_text_to_sql
rides (id, driver_id, ride_date, distance, cost)
Delete records of drivers with no rides in the rides table for the month of January 2022.
DELETE FROM rides USING drivers WHERE rides.driver_id = drivers.id AND rides.ride_date < '2022-02-01' AND rides.ride_date >= '2022-01-01' AND drivers.name IS NOT NULL AND rides.distance IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (id INT, name VARCHAR(30), location VARCHAR(20), certified BOOLEAN); INSERT INTO businesses (id, name, location, certified) VALUES (1, 'Caribbean Eco Tours', 'Bahamas', TRUE), (2, 'Green Travel Jamaica', 'Jamaica', TRUE), (3, 'Eco Adventures', 'Puerto Rico', FALSE);
What is the total number of certified sustainable tourism businesses in the Caribbean?
SELECT COUNT(*) FROM businesses WHERE certified = TRUE AND location IN ('Bahamas', 'Jamaica', 'Puerto Rico', 'Cuba', 'Dominican Republic', 'Barbados', 'Haiti', 'Trinidad and Tobago');
gretelai_synthetic_text_to_sql
CREATE TABLE team_ticket_sales (id INT, team VARCHAR(50), revenue INT); INSERT INTO team_ticket_sales (id, team, revenue) VALUES (1, 'TeamA', 70000), (2, 'TeamA', 60000), (3, 'TeamB', 50000), (4, 'TeamB', 40000);
Which team had the highest average ticket sales revenue per game?
SELECT team, AVG(revenue) as avg_revenue_per_game FROM team_ticket_sales GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE music_concerts (concert_id INT, age INT, num_visitors INT); INSERT INTO music_concerts (concert_id, age, num_visitors) VALUES (1, 18, 200), (2, 25, 250), (3, 35, 300);
What is the total number of visitors at the "music_concerts" table by age group?
SELECT age, SUM(num_visitors) FROM music_concerts GROUP BY age;
gretelai_synthetic_text_to_sql
CREATE TABLE comments (id INT, post_id INT, user_id INT, text TEXT, created_date DATE); INSERT INTO comments (id, post_id, user_id, text, created_date) VALUES (1, 1, 7, 'Nice post!', '2022-11-05'), (2, 2, 7, 'Thank you.', '2022-11-06');
What is the rank of the most recent comment made by a user from Japan, ordered by created date?
SELECT c.text, c.user_id, ROW_NUMBER() OVER (ORDER BY created_date DESC) as rank FROM comments c WHERE c.country = 'Japan' AND c.created_date = (SELECT MAX(created_date) FROM comments WHERE country = 'Japan')
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, type TEXT, location TEXT, biomass FLOAT); INSERT INTO fish_farms (id, name, type, location, biomass) VALUES (1, 'Farm M', 'Fish', 'Norway', 25000.0), (2, 'Farm N', 'Fish', 'Canada', 18000.0);
What is the average biomass of fish in saltwater fish farms in the Northern Hemisphere?
SELECT AVG(biomass) FROM fish_farms WHERE type = 'Fish' AND location IN (SELECT location FROM fish_farms WHERE biomass IS NOT NULL GROUP BY location HAVING EXTRACT(HOUR FROM AVG(location)) < 12);
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, name TEXT, budget INT, start_date DATE, state TEXT); INSERT INTO campaigns (id, name, budget, start_date, state) VALUES (1, 'EndStigma', 50000, '2019-03-01', 'New York'); INSERT INTO campaigns (id, name, budget, start_date, state) VALUES (2, 'HealthyMinds', 75000, '2018-06-15', 'Californ...
What is the total budget of all campaigns in New York?
SELECT SUM(budget) FROM campaigns WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (model_name TEXT, safety_score INTEGER, quarter TEXT); INSERT INTO ai_safety (model_name, safety_score, quarter) VALUES ('ModelA', 88, 'Q1 2020'), ('ModelB', 92, 'Q2 2019'), ('ModelC', 75, 'Q1 2020'), ('ModelD', 95, 'Q4 2021');
Minimum safety score for AI models developed in Q1 of 2020?
SELECT MIN(safety_score) FROM ai_safety WHERE quarter = 'Q1 2020';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Industry TEXT); INSERT INTO Donors (DonorID, DonorName, Industry) VALUES (1, 'John Doe', 'Technology'), (2, 'Jane Smith', 'Finance'), (3, 'Leung Li', 'Technology'), (4, 'Kim Jae', 'Retail'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount INT, Donati...
What is the total amount donated by donors in the healthcare industry in the year 2020?
SELECT SUM(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Industry = 'Healthcare' AND DonationYear = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE train_delays (delay_id INT, train_id INT, delay_length INT, delay_reason VARCHAR); INSERT INTO train_delays VALUES (1, 123, 15, 'Mechanical failure');
What is the total number of train delays in Tokyo greater than 10 minutes?
SELECT COUNT(*) FROM train_delays WHERE delay_length > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE dysprosium_production (country VARCHAR(50), year INT, quantity INT); INSERT INTO dysprosium_production (country, year, quantity) VALUES ('China', 2017, 3800), ('United States', 2017, 600), ('Malaysia', 2017, 500), ('India', 2017, 400);
What is the maximum production of Dysprosium in 2017?
SELECT MAX(quantity) FROM dysprosium_production WHERE year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_professional_development (teacher_id INT, course_id INT, date DATE); INSERT INTO teacher_professional_development (teacher_id, course_id, date) VALUES (1, 1, '2022-03-01'), (2, 2, '2022-03-02'), (3, 3, '2022-03-03');
How many professional development courses were completed by teachers in 'Spring 2022'?
SELECT COUNT(DISTINCT course_id) FROM teacher_professional_development WHERE date = '2022-03-01';
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), status VARCHAR(255)); INSERT INTO machines (id, name, type, status) VALUES (1, 'Machine A', 'CNC', 'Operational'), (2, 'Machine B', 'Robotic Arm', 'Under Maintenance'), (3, 'Machine C', 'CNC', 'Operational'), (4, 'Machine D', 'Robotic Arm'...
Retrieve the number of machines of each type
SELECT type, COUNT(*) FROM machines GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, project_name VARCHAR(255), budget FLOAT, start_date DATE, country VARCHAR(50)); INSERT INTO economic_diversification (id, project_name, budget, start_date, country) VALUES (1, 'Technology Hub', 350000.00, '2017-05-01', 'Argentina'), (2, 'Sustainable Fashion', 250000.00, '2...
What is the average budget for economic diversification projects in Argentina that started in 2017?
SELECT AVG(budget) FROM economic_diversification WHERE country = 'Argentina' AND start_date BETWEEN '2017-01-01' AND '2017-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE WarehouseManagement (id INT, customer VARCHAR(255), revenue FLOAT, country VARCHAR(255), quarter INT, year INT);
What is the total revenue generated from warehouse management for customers in India in Q2 2022?
SELECT SUM(revenue) FROM WarehouseManagement WHERE country = 'India' AND quarter = 2 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, startup_id INT, investor_id INT, investment_date DATE, investment_amount FLOAT); INSERT INTO investments (id, startup_id, investor_id, investment_date, investment_amount) VALUES (1, 1, 101, '2010-01-01', 1000000); CREATE TABLE investors (id INT, name TEXT, location TEXT); INSERT INTO i...
Who are the top 5 investors by number of investments in startups in the Bay Area?
SELECT i.name, COUNT(i.id) as num_investments FROM investments AS inv JOIN investors AS i ON inv.investor_id = i.id WHERE i.location = 'San Francisco' GROUP BY i.id ORDER BY num_investments DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE EmissionsData (Continent VARCHAR(50), Year INT, CO2Emission DECIMAL(5,2), Population INT); INSERT INTO EmissionsData (Continent, Year, CO2Emission, Population) VALUES ('Asia', 2020, 5.3, 4600000000), ('Asia', 2019, 4.6, 4580000000), ('Africa', 2020, 2.1, 1300000000), ('Africa', 2019, 1.8, 1280000000);
List the top 2 continents with the highest CO2 emission per capita in 2019, and rank them.
SELECT Continent, AVG(CO2Emission/Population) as AvgCO2PerCapita, RANK() OVER (ORDER BY AVG(CO2Emission/Population) DESC) as Rank FROM EmissionsData WHERE Year = 2019 GROUP BY Continent HAVING COUNT(*) > 1 ORDER BY Rank;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, year INT, product_type VARCHAR(20), revenue FLOAT); INSERT INTO sales (id, year, product_type, revenue) VALUES (1, 2020, 'organic', 1000), (2, 2021, 'organic', 1200);
What is the percentage change in sales of organic products in the US between 2020 and 2021?
SELECT (revenue_2021 - revenue_2020) / revenue_2020 * 100 AS percentage_change FROM (SELECT (SELECT revenue FROM sales WHERE year = 2021 AND product_type = 'organic') AS revenue_2021, (SELECT revenue FROM sales WHERE year = 2020 AND product_type = 'organic') AS revenue_2020) AS organic_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, capacity INT, location TEXT); INSERT INTO projects (id, name, capacity, location) VALUES (1, 'Solar Farm 1.0', 1000, 'California'); INSERT INTO projects (id, name, capacity, location) VALUES (2, 'Wind Farm 1.0', 2000, 'Texas'); INSERT INTO projects (id, name, capacity, location...
Update the location of the project with id 2 to 'Texas Panhandle'
UPDATE projects SET location = 'Texas Panhandle' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (year INT, location VARCHAR(255), material VARCHAR(255), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (year, location, material, recycling_rate) VALUES (2021, 'California', 'Plastic', 0.35), (2021, 'California', 'Paper', 0.65), (2021, 'California', 'Glass', 0.55);
What is the average recycling rate for each material type in California in 2021?
SELECT material, AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates WHERE year = 2021 AND location = 'California' GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, plan_type VARCHAR(10), monthly_data_usage INT);
What is the average monthly data usage for postpaid mobile users?
SELECT AVG(monthly_data_usage) FROM mobile_subscribers WHERE plan_type = 'postpaid';
gretelai_synthetic_text_to_sql
CREATE TABLE base_stations (station_id INT, tech VARCHAR(10), location VARCHAR(20)); INSERT INTO base_stations (station_id, tech, location) VALUES (1, '5G', 'urban'), (2, '4G', 'rural'); CREATE TABLE locations (location VARCHAR(20), region VARCHAR(10)); INSERT INTO locations (location, region) VALUES ('urban', 'APAC'),...
What is the total number of 5G base stations in the APAC region, and how many of them are in rural areas?
SELECT SUM(bs.tech = '5G') AS total_5G, SUM(bs.tech = '5G' AND bs.location = 'rural') AS rural_5G FROM base_stations bs JOIN locations l ON bs.location = l.location WHERE l.region = 'APAC';
gretelai_synthetic_text_to_sql
CREATE TABLE museum_donations (donor_artist_id INT, museum_id INT, donation_value DECIMAL(10,2));
Create a view named "top_five_artists_by_donations" that displays the top 5 artists with the highest total donations to museums.
CREATE VIEW top_five_artists_by_donations AS SELECT donor_artist_id, SUM(donation_value) AS total_donated FROM museum_donations GROUP BY donor_artist_id ORDER BY total_donated DESC FETCH FIRST 5 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT); INSERT INTO players (id, name, age) VALUES (1, 'John Doe', 25), (2, 'Jane Smith', 17), (3, 'Marie Lee', 28);
Delete all players who are under 18 years old
DELETE FROM players WHERE age < 18;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, mental_health_score INT, improvement_1year INT); INSERT INTO students (student_id, mental_health_score, improvement_1year) VALUES (1, 60, 5), (2, 70, 10), (3, 50, 0), (4, 80, -2), (5, 40, 15);
What is the total number of students who have improved their mental health scores in the past year and their average improvement score?
SELECT SUM(improvement_1year), AVG(improvement_1year) FROM students WHERE improvement_1year > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (MHPId INT, Law VARCHAR(255), State VARCHAR(50)); INSERT INTO MentalHealthParity (MHPId, Law, State) VALUES (1, 'Parity Act 2020', 'California'), (2, 'Mental Health Equity Act 2018', 'Texas'), (3, 'Parity Law 2019', 'Florida');
List unique mental health parity laws by state.
SELECT DISTINCT State, Law FROM MentalHealthParity;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO timber_production (id, name, region) VALUES (1, 'Timber Inc.', 'Asia'), (2, 'WoodCo', 'Africa'), (3, 'Forest Ltd.', 'North America');
List all timber production sites located in 'Asia' or 'Africa' regions.
SELECT name FROM timber_production WHERE region IN ('Asia', 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE StapleCropProduction (id INT, crop VARCHAR(50), region VARCHAR(50), production DECIMAL(10,2)); INSERT INTO StapleCropProduction (id, crop, region, production) VALUES (1, 'Rice', 'Southeast Asia', 5.0); INSERT INTO StapleCropProduction (id, crop, region, production) VALUES (2, 'Wheat', 'Southeast Asia', 3.5...
What is the average production (in metric tons) of staple crops (rice, wheat, corn) in Southeast Asia and how many farms produce them?
SELECT AVG(production), COUNT(DISTINCT farm_id) FROM (SELECT farm_id, crop, production FROM StapleCropProduction WHERE region = 'Southeast Asia' AND crop IN ('Rice', 'Wheat', 'Corn')) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (branch TEXT, num_personnel INTEGER); INSERT INTO MilitaryPersonnel (branch, num_personnel) VALUES ('Army', 500000), ('Navy', 350000), ('AirForce', 300000), ('Marines', 200000);
What is the average number of military personnel in the Navy, Marines, and AirForce?
SELECT AVG(num_personnel) FROM MilitaryPersonnel WHERE branch IN ('Navy', 'Marines', 'AirForce');
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenses (drug_name VARCHAR(255), expense_date DATE, expenditure DECIMAL(10, 2)); INSERT INTO rd_expenses (drug_name, expense_date, expenditure) VALUES ('Drug 1', '2022-01-01', 5000), ('Drug 2', '2022-02-03', 7000), ('Drug 3', '2022-07-15', 6000), ('Drug 4', '2022-11-22', 8000);
What is the average R&D expenditure per drug in the last 12 months, ordered by the highest average expenditure first?
SELECT drug_name, AVG(expenditure) as avg_expenditure FROM rd_expenses WHERE expense_date >= DATEADD(month, -12, GETDATE()) GROUP BY drug_name ORDER BY avg_expenditure DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, user_location VARCHAR(50), workout_date DATE, avg_heart_rate INT); INSERT INTO workouts (id, user_location, workout_date, avg_heart_rate) VALUES (1, 'Sydney', '2022-01-01', 85), (2, 'Sydney', '2022-01-02', 75);
Delete all workouts of users from Sydney with avg_heart_rate below 80.
DELETE FROM workouts WHERE user_location = 'Sydney' AND avg_heart_rate < 80;
gretelai_synthetic_text_to_sql
CREATE TABLE ewaste (country VARCHAR(50), year INT, amount INT); INSERT INTO ewaste (country, year, amount) VALUES ('USA', 2021, 50000), ('Canada', 2021, 40000), ('Mexico', 2021, 30000);
What is the total waste generation in e-waste category for each country in 2021?'
SELECT country, SUM(amount) as total_ewaste FROM ewaste WHERE year = 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE TVShows (ShowID INT, Title VARCHAR(100), ProductionCompany VARCHAR(100));
Number of TV shows by production company?
SELECT ProductionCompany, COUNT(*) as Num_Shows FROM TVShows GROUP BY ProductionCompany;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_species (species_id INTEGER, species_name TEXT, max_depth FLOAT); INSERT INTO deep_sea_species (species_id, species_name, max_depth) VALUES (1, 'Anglerfish', 3000.0), (2, 'Giant Squid', 3000.0), (3, 'Vampire Squid', 2000.0);
What is the maximum depth a marine species can be found in the 'deep_sea_species' table?
SELECT MAX(max_depth) FROM deep_sea_species;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(50), department VARCHAR(50), sales FLOAT); INSERT INTO drugs (id, name, department, sales) VALUES (1, 'DrugA', 'Oncology', 100000), (2, 'DrugB', 'Oncology', 150000), (3, 'DrugC', 'Cardiology', 120000), (4, 'DrugD', 'Cardiology', 160000);
What is the average sales figure for each drug in the oncology department?
SELECT department, name, AVG(sales) as avg_sales FROM drugs WHERE department = 'Oncology' GROUP BY department, name;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug_name TEXT, rd_expenditure FLOAT, year INT); INSERT INTO clinical_trials (drug_name, rd_expenditure, year) VALUES ('DrugL', 9000000.0, 2020), ('DrugL', 7000000.0, 2019);
What was the total R&D expenditure for 'DrugL''s clinical trials in 2020?
SELECT drug_name, SUM(rd_expenditure) FROM clinical_trials WHERE drug_name = 'DrugL' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(50), number_of_devices INT); INSERT INTO regions (region_id, region_name, number_of_devices) VALUES (1, 'North', 600), (2, 'South', 400); CREATE TABLE region_investments (investment_id INT, region_id INT, investment_amount DECIMAL(10,2)); INSERT INTO region_inves...
What is the total number of network devices in each region and the total investment made in each region?
SELECT r.region_name, SUM(r.number_of_devices) as total_devices, SUM(ri.investment_amount) as total_investment FROM regions r JOIN region_investments ri ON r.region_id = ri.region_id GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE country (id INT, name VARCHAR(255)); CREATE TABLE fish_stock (country_id INT, species_id INT, biomass DECIMAL(10,2)); INSERT INTO country (id, name) VALUES (1, 'Norway'), (2, 'Chile'), (3, 'Canada'); INSERT INTO fish_stock (country_id, species_id, biomass) VALUES (1, 1, 3000.0), (1, 2, 2000.0), (2, 1, 4000...
What is the total biomass for fish in each country?
SELECT c.name, SUM(fs.biomass) AS total_biomass FROM country c JOIN fish_stock fs ON c.id = fs.country_id GROUP BY c.id, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_name VARCHAR(50), budget INT, region VARCHAR(50)); CREATE TABLE economic_impact (project_id INT, impact INT); INSERT INTO projects (project_id, project_name, budget, region) VALUES (1, 'Road Construction', 500000, 'Midwest'), (2, 'Bridge Building', 700000, 'Southeast'); IN...
What is the total economic impact of rural development projects in the 'rural_development' database, grouped by the region they are located in?
SELECT region, SUM(budget) + SUM(impact) FROM projects INNER JOIN economic_impact ON projects.project_id = economic_impact.project_id GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS disaster_prevention; CREATE TABLE disaster_prevention.projects (id INT, name VARCHAR(100), completed_date DATE, type VARCHAR(50)); INSERT INTO disaster_prevention.projects (id, name, completed_date, type) VALUES (1, 'Flood Mitigation Infrastructure', '2022-01-10', 'flood mitigation'), (2, 'E...
List the names and completion dates of flood mitigation projects in the 'disaster_prevention' schema
SELECT name, completed_date FROM disaster_prevention.projects WHERE type = 'flood mitigation';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT, name TEXT); CREATE TABLE matches (id INT, home_team INT, visiting_team INT, home_points INT, visiting_points INT, date DATE);
Find the average points scored by each team in their last five matches.
SELECT t.name, AVG(m.home_points + m.visiting_points) as avg_points FROM teams t INNER JOIN matches m ON t.id IN (m.home_team, m.visiting_team) WHERE m.date >= DATEADD(day, -30, CURRENT_DATE) GROUP BY t.name ORDER BY avg_points DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, mental_health_score INT, participated_in_pd BOOLEAN); INSERT INTO students (student_id, mental_health_score, participated_in_pd) VALUES (1, 75, true), (2, 80, false), (3, 60, true);
What is the average mental health score of students who have participated in professional development programs?
SELECT AVG(mental_health_score) FROM students WHERE participated_in_pd = true;
gretelai_synthetic_text_to_sql
CREATE TABLE continent (id INT, location TEXT, country TEXT);
Count the number of smart city projects in each continent
SELECT continent.location, COUNT(*) FROM continent JOIN smart_cities ON continent.country = smart_cities.location GROUP BY continent.location;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), is_public_works BOOLEAN); INSERT INTO Infrastructure (id, name, type, location, is_public_works) VALUES (1, 'Road A', 'Road', 'Texas', TRUE); INSERT INTO Infrastructure (id, name, type, location, is_public_works) VALUES (2...
Retrieve the number of public works projects in Texas
SELECT COUNT(*) FROM Infrastructure WHERE is_public_works = TRUE AND location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_locations (location_id INT PRIMARY KEY, location_name VARCHAR(255), country VARCHAR(255), ocean VARCHAR(255));
Insert a record for a salmon farm in Maine, USA
INSERT INTO farm_locations (location_id, location_name, country, ocean) VALUES (1, 'Maine Salmon Farm', 'United States', 'Atlantic Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category VARCHAR(255), case_duration INT); INSERT INTO cases (case_id, category, case_duration) VALUES (1, 'Family', 30), (2, 'Civil', 20), (3, 'Criminal', 60), (4, 'Family', 45), (5, 'Civil', 10);
What is the minimum case duration for cases in the civil category?
SELECT MIN(case_duration) FROM cases WHERE category = 'Civil';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, donation_date DATE);
How many unique donors did we have in each quarter of 2021?
SELECT DATE_FORMAT(donation_date, '%Y-%V') as quarter, COUNT(DISTINCT name) as unique_donors FROM donors WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, region VARCHAR(255), has_socially_responsible_loan BOOLEAN);
Calculate the percentage of customers in each region who have a socially responsible loan
SELECT region, (COUNT(*) FILTER (WHERE has_socially_responsible_loan = TRUE)) * 100.0 / COUNT(*) as percentage FROM customers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, project_name VARCHAR(50), budget FLOAT); INSERT INTO renewable_energy_projects (id, project_name, budget) VALUES (1, 'Solar Power', 350000.00), (2, 'Wind Power', 500000.00);
Update the budget of the 'Solar Power' project to $450,000 in the 'renewable_energy_projects' table.
UPDATE renewable_energy_projects SET budget = 450000.00 WHERE project_name = 'Solar Power';
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, category VARCHAR(255), subcategory VARCHAR(255), sustainability VARCHAR(50), price DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO garments (id, category, subcategory, sustainability, price, country) VALUES (1, 'Outerwear', 'Jackets', 'Eco-Friendly', 79.99, 'United States'); INSERT INTO...
What is the maximum retail price of eco-friendly denim jackets sold worldwide?
SELECT MAX(price) FROM garments WHERE category = 'Outerwear' AND subcategory = 'Jackets' AND sustainability = 'Eco-Friendly';
gretelai_synthetic_text_to_sql
CREATE TABLE player_demographics (player_id INT PRIMARY KEY, age INT, gender VARCHAR(10), location VARCHAR(50), join_date DATE);
List all players who joined after a specific date
SELECT * FROM player_demographics WHERE join_date > '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), word_count INT, category VARCHAR(255)); INSERT INTO news (title, author, word_count, category) VALUES ('Sample News', 'John Doe', 500, 'Politics');
What is the average word count for articles by 'John Doe'?
SELECT AVG(word_count) FROM news WHERE author = 'John Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE Country (Id INT, Name VARCHAR(50), StateId INT); INSERT INTO Country (Id, Name, StateId) VALUES (1, 'CountryA', 1); INSERT INTO Country (Id, Name, StateId) VALUES (2, 'CountryB', 2); CREATE TABLE State (Id INT, Name VARCHAR(50), Income FLOAT); INSERT INTO State (Id, Name, Income) VALUES (1, 'StateA', 45000...
What is the average income in each state?
SELECT s.Name AS StateName, AVG(s.Income) AS AverageIncome FROM State s JOIN Country c ON s.Id = c.StateId GROUP BY s.Name;
gretelai_synthetic_text_to_sql
use rural_health; CREATE TABLE medical_conditions (id int, patient_id int, county text, condition text); INSERT INTO medical_conditions (id, patient_id, county, condition) VALUES (1, 1, 'Green', 'Diabetes'); INSERT INTO medical_conditions (id, patient_id, county, condition) VALUES (2, 1, 'Green', 'Hypertension'); INSER...
How many medical conditions are reported in each rural county?
SELECT county, COUNT(DISTINCT condition) as condition_count FROM rural_health.medical_conditions GROUP BY county;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, severity TEXT, severity_score INT, discovered_at TIMESTAMP); INSERT INTO vulnerabilities (id, severity, severity_score, discovered_at) VALUES (1, 'low', 2, '2021-02-01 12:00:00'), (2, 'medium', 5, '2021-02-04 14:30:00'), (3, 'high', 8, '2021-02-05 10:15:00'), (4, 'critical', 10, '2...
What is the distribution of vulnerabilities by severity level in the last week?
SELECT severity, COUNT(*) AS vulnerability_count FROM vulnerabilities WHERE discovered_at >= NOW() - INTERVAL '1 week' GROUP BY severity;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft_accidents (id INT, country VARCHAR(50), accident_date DATE); INSERT INTO aircraft_accidents (id, country, accident_date) VALUES (1, 'France', '2017-01-10'), (2, 'Germany', '2018-03-22'), (3, 'Italy', '2019-05-15'), (4, 'Spain', '2020-07-02');
How many aircraft accidents occurred in the European Union between 2017 and 2020?
SELECT COUNT(*) as total_accidents FROM aircraft_accidents WHERE country IN ('France', 'Germany', 'Italy', 'Spain') AND YEAR(accident_date) BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY, name VARCHAR, description VARCHAR);
What is the name and description of the waste type with ID 3?
SELECT name, description FROM WasteTypes WHERE waste_type_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10), position VARCHAR(20), salary DECIMAL(10,2));
What is the maximum salary of faculty members in the Humanities department?
SELECT MAX(salary) FROM faculty WHERE department = 'Humanities';
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (id INT, price INT, has_pool BOOLEAN); INSERT INTO Properties (id, price, has_pool) VALUES (1, 500000, TRUE), (2, 400000, FALSE), (3, 700000, TRUE), (4, 600000, FALSE);
What is the average property price for properties with a pool?
SELECT AVG(price) AS avg_price_with_pool FROM Properties WHERE has_pool = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_subsidies (id INT, policy_name TEXT, start_date DATE, end_date DATE);
Update the 'housing_subsidies' table to reflect a new policy effective from '2023-01-01'.
UPDATE housing_subsidies SET start_date = '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount FLOAT); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2022-01-01', 200.00), (2, 2, '2022-02-14', 150.00), (3, 3, '2022-03-05', 100.00), (4, 1, '2022-04-01', 250.00); CREATE TABLE Donors (Don...
Who are the top 3 donors by total donation amount in descending order?
SELECT DonorName, SUM(DonationAmount) AS TotalDonation FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID GROUP BY DonorName ORDER BY TotalDonation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Materials (project_id INT, material_type VARCHAR(50), cost DECIMAL(10, 2), material_origin VARCHAR(50), project_state VARCHAR(50)); INSERT INTO Sustainable_Materials (project_id, material_type, cost, material_origin, project_state) VALUES (1, 'Recycled steel', 800.00, 'USA', 'California'); INSE...
What is the average cost of sustainable building materials used in projects initiated in California since 2020?
SELECT AVG(cost) FROM Sustainable_Materials WHERE project_state = 'California' AND YEAR(project_initiation_date) >= 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_responses (country VARCHAR(50), incident VARCHAR(50), status VARCHAR(15)); INSERT INTO incident_responses (country, incident, status) VALUES ('USA', 'Incident 1', 'Resolved'), ('Canada', 'Incident 2', 'In Progress'), ('Brazil', 'Incident 3', 'Resolved'), ('Mexico', 'Incident 4', 'In Progress'), ('...
What are the total number of security incidents in the incident_responses table for each country represented in the table? (Assuming the 'country' column exists in the incident_responses table)
SELECT country, COUNT(*) AS num_incidents FROM incident_responses GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (id INT, name VARCHAR(255), country VARCHAR(255), age INT); INSERT INTO Astronauts (id, name, country, age) VALUES (1, 'Rodolfo Neri Vela', 'Mexico', 74); INSERT INTO Astronauts (id, name, country, age) VALUES (2, 'Iván Bella', 'Argentina', 53); INSERT INTO Astronauts (id, name, country, age) VA...
Update the country of astronaut John Herrington to United States.
UPDATE Astronauts SET country = 'United States' WHERE id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesign (GameName VARCHAR(100), Genre VARCHAR(50), Developer VARCHAR(100)); INSERT INTO GameDesign VALUES ('Galactic Run', 'Runner', 'Space Corp');
Insert new game design data for the popular mobile game 'Galactic Run'.
INSERT INTO GameDesign (GameName, Genre, Developer) VALUES ('Galactic Run', 'Runner', 'Space Corp');
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_efforts (id INT PRIMARY KEY, location VARCHAR(50), start_date DATE, end_date DATE, effort_description VARCHAR(255));
Delete the 'Community Education' record in the 'conservation_efforts' table
DELETE FROM conservation_efforts WHERE effort_description = 'Community Education';
gretelai_synthetic_text_to_sql
CREATE TABLE bus_stops (stop_id INT PRIMARY KEY, stop_name TEXT, location TEXT);
Update the location of 'Bus Stop 123'
UPDATE bus_stops SET location = 'New Location' WHERE stop_name = 'Bus Stop 123';
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty_2 (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO Faculty_2 (id, name, department) VALUES (1, 'Carlos', 'Electrical Engineering'); CREATE TABLE Research_Grants_2 (id INT, faculty_id INT, grant_number INT, amount INT); INSERT INTO Research_Grants_2 (id, faculty_id, grant_number, amou...
How many research grants were awarded to each faculty member in the Electrical Engineering department?
SELECT Faculty_2.name, COUNT(Research_Grants_2.id) FROM Faculty_2 JOIN Research_Grants_2 ON Faculty_2.id = Research_Grants_2.faculty_id WHERE Faculty_2.department = 'Electrical Engineering' GROUP BY Faculty_2.name;
gretelai_synthetic_text_to_sql
CREATE TABLE upgrades (id INT, cost FLOAT, type TEXT); INSERT INTO upgrades (id, cost, type) VALUES (1, 500, 'Insulation'), (2, 1000, 'Insulation'), (3, 1500, 'Insulation'), (4, 50, 'HVAC'), (5, 100, 'HVAC'), (6, 150, 'HVAC');
Find the top 2 energy efficiency upgrades by cost for each type.
SELECT type, cost FROM (SELECT type, cost, RANK() OVER (PARTITION BY type ORDER BY cost DESC) as rn FROM upgrades) sub WHERE rn <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE public_pools (name TEXT, city TEXT, build_year INT); INSERT INTO public_pools (name, city, build_year) VALUES ('Pool A', 'Chicago', 1998), ('Pool B', 'Chicago', 2005);
Which public swimming pools in the city of Chicago were built before 2000?
SELECT name FROM public_pools WHERE city = 'Chicago' AND build_year < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), price DECIMAL(5,2)); INSERT INTO dishes (dish_id, dish_name, price) VALUES (1, 'Margherita Pizza', 12.99), (2, 'Chicken Alfredo', 15.99), (3, 'Caesar Salad', 9.99), (4, 'Garden Burger', 11.99), (5, 'Spaghetti Bolognese', 19.99);
Display dishes with a price range of $10-$20
SELECT dish_id, dish_name, price FROM dishes WHERE price BETWEEN 10 AND 20;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_type VARCHAR(20)); INSERT INTO customers (customer_id, customer_type) VALUES (1, 'Retail'), (2, 'Wholesale'), (3, 'Institutional'); CREATE TABLE transactions (transaction_date DATE, customer_id INT, transaction_value DECIMAL(10, 2)); INSERT INTO transactions (transactio...
What is the total transaction value per week for the past year for customers in the 'Institutional' customer type?
SELECT WEEK(transactions.transaction_date) as week, YEAR(transactions.transaction_date) as year, SUM(transactions.transaction_value) as total_transaction_value FROM transactions JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)...
gretelai_synthetic_text_to_sql
CREATE TABLE building_data (building_id INT, building_type VARCHAR(50), price_per_sq_ft FLOAT); INSERT INTO building_data (building_id, building_type, price_per_sq_ft) VALUES (1, 'Residential', 300.0), (2, 'Commercial', 500.0), (3, 'Residential', 400.0), (4, 'Commercial', 600.0), (5, 'Residential', 350.0);
What is the average price per square foot for each building type?
SELECT building_type, AVG(price_per_sq_ft) FROM building_data GROUP BY building_type;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50), organic BOOLEAN); INSERT INTO suppliers (id, name, country, organic) VALUES (1, 'Supplier A', 'India', true), (2, 'Supplier B', 'USA', false);
List all suppliers from India that provide organic ingredients.
SELECT suppliers.name FROM suppliers WHERE suppliers.country = 'India' AND suppliers.organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_id INT, name TEXT, type TEXT, rural BOOLEAN); CREATE TABLE states (state_code TEXT, state_name TEXT); INSERT INTO hospitals (hospital_id, name, type, rural) VALUES (1, 'Rural General Hospital', 'Hospital', TRUE), (2, 'Rural Clinic', 'Clinic', TRUE); INSERT INTO states (state_code, state...
List the number of rural hospitals and clinics in each state, ordered by the number of rural hospitals and clinics.
SELECT states.state_name, SUM(CASE WHEN hospitals.type = 'Hospital' THEN 1 ELSE 0 END) as num_hospitals, SUM(CASE WHEN hospitals.type = 'Clinic' THEN 1 ELSE 0 END) as num_clinics, SUM(CASE WHEN hospitals.type IN ('Hospital', 'Clinic') THEN 1 ELSE 0 END) as total_rural_healthcare_services FROM hospitals INNER JOIN state...
gretelai_synthetic_text_to_sql
CREATE TABLE ai_recommendations (id INT, recommendation_type TEXT, revenue FLOAT, recommendation_date DATE); INSERT INTO ai_recommendations (id, recommendation_type, revenue, recommendation_date) VALUES (1, 'AI Hotel', 700, '2022-01-03'), (2, 'AI Recommendation', 800, '2022-02-05');
What is the minimum revenue earned from AI-powered hotel recommendations in the last quarter?
SELECT MIN(revenue) FROM ai_recommendations WHERE recommendation_type = 'AI Hotel' AND recommendation_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE train_routes (id INT, route_name VARCHAR(255), fare DECIMAL(5, 2)); INSERT INTO train_routes (id, route_name, fare) VALUES (1, 'Route A', 2.75), (2, 'Route B', 3.50);
What is the total fare collected from passengers on trains in the NYC subway system?
SELECT SUM(fare) FROM train_routes WHERE route_name LIKE 'Route%';
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (vendor_id INT, vendor_name TEXT, location TEXT); INSERT INTO vendors (vendor_id, vendor_name, location) VALUES (1, 'ABC Organics', 'California'); CREATE TABLE products (product_id INT, product_name TEXT, price DECIMAL(5,2), vendor_id INT); INSERT INTO products (product_id, product_name, price, ven...
What is the average selling price of organic fruits sold by vendors located in California?
SELECT AVG(price) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE products.product_name LIKE '%organic fruit%' AND vendors.location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, price FLOAT, city VARCHAR(20), coowners INT); INSERT INTO properties (id, price, city, coowners) VALUES (1, 750000, 'Seattle', 2), (2, 850000, 'Seattle', 1), (3, 650000, 'Seattle', 3), (4, 950000, 'Portland', 1), (5, 550000, 'Seattle', 2);
What is the average property price for co-owned properties in the city of Seattle?
SELECT AVG(price) FROM properties WHERE city = 'Seattle' AND coowners > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales(id INT PRIMARY KEY, garment_type VARCHAR(50), quantity INT, sale_date DATE, customer_country VARCHAR(50)); INSERT INTO sales(id, garment_type, quantity, sale_date, customer_country) VALUES (1, 't-shirt', 10, '2022-01-01', 'USA'), (2, 'jeans', 8, '2022-02-01', 'Canada'), (3, 'dress', 5, '2022-03-01', ...
What is the total quantity of garments sold to customers in the US?
SELECT SUM(quantity) FROM sales WHERE customer_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE CarSales (Id INT, Vehicle VARCHAR(50), Year INT, QuantitySold INT); CREATE TABLE HybridVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Horsepower INT);
How many hybrid vehicles were sold in the 'CarSales' database in 2022?
SELECT COUNT(*) FROM CarSales WHERE Vehicle IN (SELECT Model FROM HybridVehicles WHERE Year = 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, country VARCHAR(50), production INT); INSERT INTO wells (well_id, country, production) VALUES (1, 'USA', 1000000), (2, 'USA', 2000000), (3, 'Canada', 1500000);
Calculate the percentage of total production for each well in a given country.
SELECT well_id, country, production, ROUND(100.0 * production / (SELECT SUM(production) FROM wells w2 WHERE w2.country = w.country) , 2) as pct_of_total FROM wells w;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, well_name VARCHAR(50), drill_year INT, location VARCHAR(50)); INSERT INTO wells (id, well_name, drill_year, location) VALUES (1, 'Well A', 2020, 'Region A'); INSERT INTO wells (id, well_name, drill_year, location) VALUES (2, 'Well B', 2019, 'Region B'); INSERT INTO wells (id, well_name, dril...
Find the total number of wells drilled in the year 2020
SELECT COUNT(*) FROM wells WHERE drill_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name TEXT, price DECIMAL(5, 2)); INSERT INTO products (id, name, price) VALUES (1, 'Product X', 100.00), (2, 'Product Y', 150.00), (3, 'Product Z', 80.00), (4, 'Product W', 120.00); CREATE TABLE sales (id INT, product TEXT, quantity INT, region TEXT); INSERT INTO sales (id, product, quant...
Find the top 5 products with the highest revenue in Asia.
SELECT products.name, SUM(sales.quantity * products.price) as revenue FROM sales INNER JOIN products ON sales.product = products.name WHERE sales.region = 'Asia' GROUP BY sales.product ORDER BY revenue DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, Name VARCHAR(50), ReleaseYear INT, Revenue INT, Rating INT); INSERT INTO Games (GameID, Name, ReleaseYear, Revenue, Rating) VALUES (1, 'Game1', 2019, 50000, 8); INSERT INTO Games (GameID, Name, ReleaseYear, Revenue, Rating) VALUES (2, 'Game2', 2020, 60000, 9); CREATE TABLE GameRatings (G...
What is the total revenue of games with a rating of 9 or higher?
SELECT SUM(Games.Revenue) FROM Games INNER JOIN GameRatings ON Games.GameID = GameRatings.GameID WHERE Games.Rating >= 9;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, funding FLOAT, founding_year INT); INSERT INTO startups VALUES (1, 'StartupD', 'FinTech', 4000000, 2018);
What is the minimum funding received by startups in the 'FinTech' sector founded after 2017?
SELECT MIN(funding) FROM startups WHERE industry = 'FinTech' AND founding_year > 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE meetings (id INT, department TEXT, date DATE); INSERT INTO meetings (id, department, date) VALUES (1, 'Education', '2015-01-01'); INSERT INTO meetings (id, department, date) VALUES (2, 'Education', '2016-01-01'); INSERT INTO meetings (id, department, date) VALUES (3, 'Finance', '2015-01-01');
How many public meetings have taken place in the Education department since 2015?
SELECT COUNT(*) FROM meetings WHERE department = 'Education' AND date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitats (id INT, country VARCHAR(255), region VARCHAR(255), habitat_amount INT);
What are the maximum wildlife habitat amounts in Oceania?
SELECT MAX(habitat_amount) FROM wildlife_habitats WHERE region = 'Oceania';
gretelai_synthetic_text_to_sql