context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE EquipmentFailures (EquipmentType TEXT, FailureCount INT, Year INT); INSERT INTO EquipmentFailures (EquipmentType, FailureCount, Year) VALUES ('Aircraft', 150, 2019), ('Vehicles', 120, 2019), ('Naval', 80, 2019), ('Electronic', 90, 2019);
What is the number of military equipment failures in 2019 categorized by equipment type?
SELECT EquipmentType, FailureCount FROM EquipmentFailures WHERE Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), material_id INT, is_sustainable BOOLEAN);CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), location VARCHAR(255));INSERT INTO products (product_id, name, material_id, is_sustainable) VALUES (1, 'Sustainable T-Shirt', 1, true), (2, 'Conventional T-Shirt...
Identify the top 3 countries in Europe with the highest percentage of sustainable products in their inventory.
SELECT suppliers.location, AVG(products.is_sustainable) as avg_sustainability FROM products JOIN suppliers ON products.supplier_id = suppliers.supplier_id WHERE suppliers.location LIKE 'Europe%' GROUP BY suppliers.location ORDER BY avg_sustainability DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimeline (TimelineID INT, Practice TEXT, State TEXT, Duration INT); INSERT INTO ProjectTimeline VALUES (1, 'Green Roofs', 'Texas', 90), (2, 'Solar Panels', 'California', 120), (3, 'Insulation', 'Texas', 60);
What is the average project timeline for sustainable building practices in Texas?
SELECT AVG(Duration) FROM ProjectTimeline WHERE Practice = 'Green Roofs' AND State = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_sessions (id INT, patient_id INT, approach VARCHAR(50), session_date DATE); CREATE VIEW ptsd_therapy_sessions AS SELECT approach, COUNT(*) as count FROM therapy_sessions WHERE patient_id IN (SELECT id FROM patients WHERE condition = 'PTSD') GROUP BY approach ORDER BY count DESC LIMIT 1;
What is the most common therapy approach for patients with PTSD?
SELECT * FROM ptsd_therapy_sessions;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), region VARCHAR(255), completion_date DATE); INSERT INTO rural_infrastructure (id, project_name, region, completion_date) VALUES (1, 'Rural Electrification', 'Amazonas', '2022-05-01');
Update the 'rural_infrastructure' table to reflect the correct 'completion_date' for project 'Rural Electrification' in the 'Amazonas' region.
UPDATE rural_infrastructure SET completion_date = '2022-12-31' WHERE project_name = 'Rural Electrification' AND region = 'Amazonas';
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, name TEXT, region TEXT); INSERT INTO Users (user_id, name, region) VALUES (1, 'User1', 'North'), (2, 'User2', 'South'), (3, 'User3', 'North');
How many users are from each region?
SELECT region, COUNT(*) as num_users FROM Users GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (id INT PRIMARY KEY, name VARCHAR(255), family VARCHAR(255));
Create a table named 'fish_species'
CREATE TABLE fish_species (id INT PRIMARY KEY, name VARCHAR(255), family VARCHAR(255));
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (initiative_id INT, initiative_start_date DATE, initiative_end_date DATE, budget FLOAT, region VARCHAR(50), status VARCHAR(50)); INSERT INTO initiative (initiative_id, initiative_start_date, initiative_end_date, budget, region, status) VALUES (5, '2019-01-01', '2020-12-31', 60000.0, 'R5', 'compl...
How many community development initiatives were completed in the last 2 years, categorized by project type, region, and status, with a budget over 50000?
SELECT EXTRACT(YEAR FROM initiative_end_date) - EXTRACT(YEAR FROM initiative_start_date) AS years_diff, region, status, project_type, COUNT(*) AS num_initiatives FROM initiative WHERE initiative_end_date >= (CURRENT_DATE - INTERVAL '2 years') AND budget > 50000 GROUP BY region, status, project_type, years_diff ORDER BY...
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (id INT, name VARCHAR(255), category VARCHAR(255));
Update the name of the dish "Chicken Tikka Masala" to "Tikka Masala with Chicken"
UPDATE menu_items SET name = 'Tikka Masala with Chicken' WHERE name = 'Chicken Tikka Masala';
gretelai_synthetic_text_to_sql
CREATE TABLE DroneMilitary (Country VARCHAR(255), Branch VARCHAR(255)); INSERT INTO DroneMilitary (Country, Branch) VALUES ('USA', 'Air Force'), ('USA', 'Navy'), ('Israel', 'Air Force'), ('Turkey', 'Air Force');
List the countries and their military branches that use drone technology.
SELECT Country FROM DroneMilitary WHERE Branch IN ('Air Force', 'Navy');
gretelai_synthetic_text_to_sql
CREATE TABLE yellow_red_cards (player_id INT, player_name VARCHAR(50), country VARCHAR(50), card_type VARCHAR(50)); INSERT INTO yellow_red_cards (player_id, player_name, country, card_type) VALUES (1, 'Harry Kane', 'England', 'Yellow'), (2, 'Luka Modric', 'Croatia', 'Yellow'), (3, 'Lionel Messi', 'Argentina', 'Red'), (...
What is the total number of yellow and red cards issued to players from different countries in the 2022 FIFA World Cup?
SELECT country, SUM(CASE WHEN card_type = 'Yellow' THEN 1 ELSE 0 END) as yellow_cards, SUM(CASE WHEN card_type = 'Red' THEN 1 ELSE 0 END) as red_cards FROM yellow_red_cards GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (restaurant_id INT, item_name TEXT, item_type TEXT, diet TEXT); INSERT INTO menu (restaurant_id, item_name, item_type, diet) VALUES (1, 'Spaghetti', 'Entree', 'Vegetarian'), (1, 'Quinoa Salad', 'Entree', 'Vegan'), (1, 'Garden Burger', 'Entree', 'Vegan'), (2, 'Tofu Stir Fry', 'Entree', 'Vegan'), (2, 'V...
Delete all menu items from Restaurant E that are not vegan or vegetarian.
DELETE FROM menu WHERE restaurant_id = 5 AND diet NOT IN ('Vegan', 'Vegetarian');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_name VARCHAR(50), department_name VARCHAR(50), salary DECIMAL(10,2));
How many employees in the employees table have a salary that is higher than the median salary in their department?
SELECT COUNT(*) FROM employees AS e1 WHERE salary > (SELECT AVG(salary) FROM (SELECT salary FROM employees AS e2 WHERE e1.department_name = e2.department_name ORDER BY salary LIMIT 2) AS e3);
gretelai_synthetic_text_to_sql
CREATE TABLE Innovation (id INT, project VARCHAR(255), region VARCHAR(255), year INT, cost INT); INSERT INTO Innovation (id, project, region, year, cost) VALUES (1, 'Precision Farming', 'Rural North', 2013, 2000000), (2, 'Drip Irrigation', 'Urban East', 2017, 3000000), (3, 'Soil Sensor', 'Rural South', 2015, 1000000), ...
Determine the number of agricultural innovation projects in the 'Innovation' table, grouped by type, that have a cost above the average?
SELECT SUBSTRING(project, 1, INSTR(project, ' ')-1) as project_type, COUNT(*) as num_projects FROM Innovation WHERE cost > (SELECT AVG(cost) FROM Innovation) GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE africa_sourcing (id INT, material VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO africa_sourcing (id, material, country, quantity) VALUES (1, 'recycled polyester', 'Egypt', 1500);
What is the total quantity of sustainable materials sourced from Africa?
SELECT SUM(quantity) FROM africa_sourcing WHERE material = 'recycled polyester';
gretelai_synthetic_text_to_sql
CREATE TABLE MultimodalHubs (hub_id INT, address VARCHAR(30), PRIMARY KEY (hub_id));
Delete records in the 'MultimodalHubs' table where 'hub_id' is 300
DELETE FROM MultimodalHubs WHERE hub_id = 300;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (student_id INT, region VARCHAR(20), accommodation_date DATE); INSERT INTO Accommodations (student_id, region, accommodation_date) VALUES (1, 'West Coast', '2020-01-01'), (2, 'East Coast', '2019-12-31'), (3, 'West Coast', '2020-02-01'), (4, 'Southwest', '2019-01-01');
How many students received accommodations in "Southwest" region in 2019?
SELECT COUNT(*) FROM Accommodations WHERE region = 'Southwest' AND EXTRACT(YEAR FROM accommodation_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, name VARCHAR(50), un_locode VARCHAR(10)); INSERT INTO ports (port_id, name, un_locode) VALUES (1, 'Port of Rotterdam', 'NLRTM'), (2, 'Port of Amsterdam', 'NLAMS');
What is the name of the port with UN/LOCODE 'NLRTM' in the 'ports' table?
SELECT name FROM ports WHERE un_locode = 'NLRTM';
gretelai_synthetic_text_to_sql
CREATE SCHEMA carbon_offsets; CREATE TABLE projects (project_name VARCHAR(255), region VARCHAR(255), investment_amount INT); INSERT INTO projects (project_name, region, investment_amount) VALUES ('Tropical Forest Conservation', 'Asia', 5000000), ('Wind Power Generation', 'Europe', 8000000), ('Soil Carbon Sequestration'...
Find the average investment amount for carbon offset projects in each region, excluding oceanic projects.
SELECT region, AVG(investment_amount) FROM carbon_offsets.projects WHERE region != 'Oceania' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE MunicipalityA (WasteQuantity INT, GenerationDate DATE); INSERT INTO MunicipalityA (WasteQuantity, GenerationDate) VALUES (500, '2021-01-01'), (600, '2021-02-01'), (700, '2021-03-01');
What is the average waste generation rate per month in the 'MunicipalityA'?
SELECT AVG(WasteQuantity) FROM (SELECT WasteQuantity, ROW_NUMBER() OVER (PARTITION BY EXTRACT(MONTH FROM GenerationDate) ORDER BY GenerationDate) as rn FROM MunicipalityA) tmp WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy_Projects (id INT, project_name VARCHAR(30), state VARCHAR(20), completion_year INT); INSERT INTO Renewable_Energy_Projects (id, project_name, state, completion_year) VALUES (1, 'Solar Farm 1', 'California', 2016), (2, 'Wind Farm 2', 'California', 2017), (3, 'Geothermal Plant 3', 'Californi...
How many renewable energy projects have been completed in the state of California since 2015?
SELECT COUNT(*) FROM Renewable_Energy_Projects WHERE state = 'California' AND completion_year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, strain_name VARCHAR(255), dispensary_name VARCHAR(255), state VARCHAR(255), production_weight INT, production_date DATE);
What is the total weight of Blue Dream strain produced in Oregon in Q1 of 2023?
SELECT SUM(production_weight) FROM production WHERE strain_name = 'Blue Dream' AND state = 'Oregon' AND production_date BETWEEN '2023-01-01' AND '2023-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, city VARCHAR(20), trip_date DATE, mode VARCHAR(20), distance INT); INSERT INTO trips VALUES (1, 'nyc', '2022-01-01', 'subway', 10); INSERT INTO trips VALUES (2, 'nyc', '2022-01-05', 'bus', 15); INSERT INTO trips VALUES (3, 'la', '2022-01-10', 'light_rail', 8);
What is the total number of public transportation trips taken in 'nyc' in the last 30 days?
SELECT SUM(distance) FROM trips WHERE city = 'nyc' AND trip_date >= DATEADD(day, -30, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE space_exploration (id INT, name VARCHAR(50), max_speed FLOAT, launch_date DATE); INSERT INTO space_exploration (id, name, max_speed, launch_date) VALUES (1, 'Voyager 1', 17000, '1977-09-05'); INSERT INTO space_exploration (id, name, max_speed, launch_date) VALUES (2, 'New Horizons', 14000, '2006-01-19');
What is the average speed of spacecraft in the "space_exploration" table, ordered by speed in descending order?
SELECT AVG(max_speed) AS avg_speed FROM (SELECT max_speed, ROW_NUMBER() OVER (ORDER BY max_speed DESC) as row_num FROM space_exploration) tmp WHERE row_num = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_productivity (id INT, region VARCHAR(20), industry VARCHAR(20), productivity FLOAT); INSERT INTO labor_productivity (id, region, industry, productivity) VALUES (1, 'Asia-Pacific', 'mining', 2.5), (2, 'Americas', 'mining', 3.2), (3, 'Europe', 'mining', 1.8);
What is the minimum labor productivity in the mining industry?
SELECT MIN(productivity) FROM labor_productivity WHERE industry = 'mining';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name VARCHAR(255), leader_country VARCHAR(255), start_date DATE); INSERT INTO peacekeeping_operations (operation_id, operation_name, leader_country, start_date) VALUES (1, 'Operation X', 'Country A', '2020-01-01'), (2, 'Operation Y', 'Country B', '2019-0...
List all peacekeeping operations led by African countries in 2020.
SELECT operation_name FROM peacekeeping_operations INNER JOIN countries ON peacekeeping_operations.leader_country = countries.country WHERE countries.country LIKE '%Africa%' AND YEAR(start_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_name VARCHAR(50), region VARCHAR(50)); INSERT INTO cities (city_name, region) VALUES ('Chicago', 'North'), ('Detroit', 'North'), ('New York', 'East Coast'), ('Boston', 'East Coast'); CREATE TABLE recycling_rates (city_name VARCHAR(50), region VARCHAR(50), recycling_rate DECIMAL(5,2)); INSERT I...
Which cities have a recycling rate lower than the average recycling rate for all cities in the 'North' region?
SELECT city_name FROM recycling_rates WHERE region = 'North' AND recycling_rate < (SELECT AVG(recycling_rate) FROM recycling_rates WHERE region = 'North');
gretelai_synthetic_text_to_sql
CREATE TABLE drills (id SERIAL PRIMARY KEY, department VARCHAR(255), drill_date DATE); INSERT INTO drills (department, drill_date) VALUES ('Police', '2022-03-01'), ('Fire', '2022-03-01'), ('Police', '2022-06-15'), ('Fire', '2022-06-15');
What is the total number of disaster response drills performed by the police and fire departments in 2022?
SELECT COUNT(id) as total_drills FROM drills WHERE department IN ('Police', 'Fire') AND drill_date >= '2022-01-01' AND drill_date < '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE trip_duration (destination_country VARCHAR(50), visitor_country VARCHAR(50), avg_duration FLOAT); INSERT INTO trip_duration (destination_country, visitor_country, avg_duration) VALUES ('South Africa', 'Asia', 10.5);
What is the average trip duration for tourists visiting South Africa from Asia?
SELECT avg_duration FROM trip_duration WHERE destination_country = 'South Africa' AND visitor_country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE SpeciesObservations (year INT, species TEXT); INSERT INTO SpeciesObservations (year, species) VALUES (2000, 'Polar Bear'), (2000, 'Arctic Fox'), (2001, 'Polar Bear'), (2001, 'Arctic Fox'), (2001, 'Beluga Whale'), (2002, 'Polar Bear'), (2002, 'Arctic Fox'), (2002, 'Beluga Whale'), (2002, 'Reindeer'), (2003,...
How many unique species have been observed per year in the Arctic?
SELECT year, COUNT(DISTINCT species) FROM SpeciesObservations GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Textiles (brand VARCHAR(20), fabric_type VARCHAR(20)); INSERT INTO Textiles (brand, fabric_type) VALUES ('Eco-friendly Fashions', 'Organic Cotton'), ('Eco-friendly Fashions', 'Recycled Polyester'), ('Fab Fashions', 'Viscose'), ('Fab Fashions', 'Recycled Polyester'), ('Fab Fashions', 'Hemp'), ('Green Vision...
Compare the number of sustainable fabric types used by brands 'Green Visions' and 'Ethical Fashions' in the 'Textiles' table.
SELECT COUNT(DISTINCT fabric_type) FROM Textiles WHERE brand = 'Green Visions' INTERSECT SELECT COUNT(DISTINCT fabric_type) FROM Textiles WHERE brand = 'Ethical Fashions';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 78.3), (2, 'healthcare', 81.5), (3, 'technology', 84.1); CREATE TABLE investments (id INT, company_id INT, investment_date DATE); INSERT INTO investments (id, company_id, invest...
What's the average ESG rating of companies in the technology sector that have received investments since 2020?
SELECT AVG(companies.ESG_rating) FROM companies INNER JOIN investments ON companies.id = investments.company_id WHERE companies.sector = 'technology' AND investments.investment_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); CREATE TABLE humanitarian_aid (aid_id INT, year INT, amount INT, region_id INT); INSERT INTO regions VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'); INSERT INTO humanitarian_aid VALUES (1, 2015, 100, 1), (2, 2016, 150, 1), (3, 2015, 200, 2), (4, 2016, 250...
What is the average annual humanitarian aid expenditure for each region in the 'humanitarian_aid' and 'regions' tables?
SELECT r.region_name, AVG(h.amount) as avg_annual_expenditure FROM regions r JOIN humanitarian_aid h ON r.region_id = h.region_id GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT PRIMARY KEY, date_awarded DATE, type VARCHAR(255), amount DECIMAL(10,2));
Calculate the total amount of restorative justice grants awarded per year
SELECT YEAR(date_awarded) AS year, SUM(amount) AS total_amount FROM grants WHERE type = 'Restorative Justice' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT PRIMARY KEY, region_name VARCHAR(50)); CREATE TABLE regional_sales (id INT PRIMARY KEY, plan_id INT, region_id INT, quantity INT); INSERT INTO regions (id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO regional_sales (id, plan_id, region_id, quantity)...
Show the total revenue for each region in the "regional_sales" and "regions" tables, considering only regions with at least one sale.
SELECT r.region_name, SUM(regional_sales.quantity * plans.monthly_cost) AS total_revenue FROM regional_sales INNER JOIN plans ON regional_sales.plan_id = plans.id INNER JOIN regions ON regional_sales.region_id = regions.id GROUP BY regions.region_name HAVING COUNT(regions.id) > 0;
gretelai_synthetic_text_to_sql
CREATE SCHEMA CarbonOffset; CREATE TABLE Initiatives (initiative_id INT, name VARCHAR(50), location VARCHAR(50), initiative_type VARCHAR(20), carbon_offset FLOAT); INSERT INTO Initiatives (initiative_id, name, location, initiative_type, carbon_offset) VALUES (1, 'Tree Planting A', 'City A', 'Tree Planting', 500.0), (2,...
What is the average carbon offset of initiatives in the 'CarbonOffset' schema, grouped by initiative type?
SELECT initiative_type, AVG(carbon_offset) FROM CarbonOffset.Initiatives GROUP BY initiative_type;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, material TEXT, country TEXT); INSERT INTO products (product_id, name, material, country) VALUES (1, 'Organic Cotton Shirt', 'Organic Cotton', 'India'), (2, 'Regular Cotton Shirt', 'Cotton', 'China'); CREATE TABLE countries (country TEXT, region TEXT); INSERT INTO countr...
How many products are made from 'Organic Cotton' in each country?
SELECT countries.country, COUNT(*) as product_count FROM products INNER JOIN countries ON products.country = countries.country WHERE products.material = 'Organic Cotton' GROUP BY countries.country;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_show (id INT, title VARCHAR(100), genre VARCHAR(20), average_viewership INT); INSERT INTO tv_show (id, title, genre, average_viewership) VALUES (1, 'Stranger Things', 'Horror', 15000000);
What is the average viewership for TV shows in the horror genre?
SELECT AVG(average_viewership) FROM tv_show WHERE genre = 'Horror';
gretelai_synthetic_text_to_sql
CREATE TABLE city_data (city_name VARCHAR(50), state VARCHAR(50), country VARCHAR(50), population INT); INSERT INTO city_data (city_name, state, country, population) VALUES ('CityN', 'StateN', 'CountryB', 300000), ('CityO', 'StateO', 'CountryB', 400000), ('CityP', 'StateP', 'CountryC', 500000);
What is the minimum population size for cities in the "city_data" table that are located in 'CountryB'?
SELECT MIN(population) FROM city_data WHERE country = 'CountryB';
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_exchanges (exchange_name TEXT, country TEXT, daily_transaction_value INTEGER); INSERT INTO decentralized_exchanges (exchange_name, country, daily_transaction_value) VALUES ('Uniswap', 'US', 15000000), ('Sushiswap', 'US', 8000000);
What is the total transaction value for decentralized exchanges in the US?
SELECT SUM(daily_transaction_value) FROM decentralized_exchanges WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT, name VARCHAR(50), hectares FLOAT, country VARCHAR(50)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Amazon Rainforest', 55000000.0, 'Brazil'); CREATE TABLE Timber_Production (id INT, forest_id INT, year INT, production_cubic_meters INT); INSERT INTO Timber_Production (id,...
Which forests in Russia have more than 10 distinct years of timber production data?
SELECT forest_id FROM Timber_Production WHERE forest_id IN (SELECT id FROM Forests WHERE country = 'Russia') GROUP BY forest_id HAVING COUNT(DISTINCT year) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (dapp_id INT, name VARCHAR(100), platform VARCHAR(50)); INSERT INTO dapps (dapp_id, name, platform) VALUES (1, 'SingularityNET', 'Cardano'), (2, 'OccamFi', 'Cardano'), (3, 'Liqwid', 'Cardano');
How many decentralized applications are on the Cardano platform?
SELECT COUNT(*) FROM dapps WHERE platform = 'Cardano';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite_Weight_OneWeb (id INT, name VARCHAR(50), manufacturer VARCHAR(50), weight INT); INSERT INTO Satellite_Weight_OneWeb (id, name, manufacturer, weight) VALUES (1, 'OneWeb 1', 'OneWeb', 150), (2, 'OneWeb 2', 'OneWeb', 155), (3, 'OneWeb 3', 'OneWeb', 160);
What is the average weight of satellites launched by OneWeb?
SELECT AVG(weight) FROM Satellite_Weight_OneWeb WHERE manufacturer = 'OneWeb';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(100)); INSERT INTO countries (country_id, country_name) VALUES (1, 'Canada'), (2, 'USA'), (3, 'Brazil'); CREATE TABLE tree_species (species_id INT, species_name VARCHAR(100), avg_carbon_sequestration_rate DECIMAL(5,2)); INSERT INTO tree_species (species_id, s...
What is the total volume of timber produced per year by country and species?
SELECT c.country_name, ts.species_name, tp.year, SUM(tp.volume) as total_volume FROM timber_production tp JOIN countries c ON tp.country_id = c.country_id JOIN tree_species ts ON tp.species_id = ts.species_id GROUP BY c.country_name, ts.species_name, tp.year;
gretelai_synthetic_text_to_sql
CREATE TABLE costs (id INT, project VARCHAR(50), country VARCHAR(50), cost FLOAT); INSERT INTO costs (id, project, country, cost) VALUES (1, 'Bioprocess1', 'Spain', 80000); INSERT INTO costs (id, project, country, cost) VALUES (2, 'Bioprocess2', 'Spain', 90000); INSERT INTO costs (id, project, country, cost) VALUES (3,...
What is the maximum bioprocess engineering cost for projects in Spain?
SELECT MAX(cost) FROM costs WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist_id INT, location TEXT, price DECIMAL); INSERT INTO concerts (id, artist_id, location, price) VALUES (1, 1, 'New York, USA', 200);
Find the concert with the highest ticket price.
SELECT * FROM concerts ORDER BY price DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Development (id INT, country VARCHAR(50), year INT, cost FLOAT); INSERT INTO Community_Development (id, country, year, cost) VALUES (1, 'Peru', 2017, 20000.0), (2, 'Brazil', 2018, 30000.0), (3, 'Peru', 2019, 25000.0);
What was the average cost of rural community development initiatives in Peru in 2017?
SELECT AVG(cost) FROM Community_Development WHERE country = 'Peru' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (province VARCHAR(50), year INT, project VARCHAR(50), status VARCHAR(50));
How many infrastructure projects were completed in the top 5 provinces with the most completed projects?
SELECT project FROM (SELECT province, project, ROW_NUMBER() OVER(PARTITION BY province ORDER BY COUNT(*) DESC) as rn FROM RuralInfrastructure WHERE status = 'completed' GROUP BY province, project) WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE fans (id INT PRIMARY KEY, age INT, gender VARCHAR(255), location VARCHAR(255)); INSERT INTO fans (id, age, gender, location) VALUES (1, 25, 'Female', 'Los Angeles'); INSERT INTO fans (id, age, gender, location) VALUES (2, 35, 'Male', 'New York'); INSERT INTO fans (id, age, gender, location) VALUES (3, 30, ...
Show the number of fans from each location
SELECT location, COUNT(*) FROM fans GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes (process_id INT, process_name VARCHAR(255), waste_generated INT); INSERT INTO manufacturing_processes (process_id, process_name, waste_generated) VALUES (1, 'Process E', 100), (2, 'Process F', 150), (3, 'Process G', 200), (4, 'Process H', 250);
Calculate the total waste produced by each manufacturing process
SELECT process_name, SUM(waste_generated) as total_waste_generated FROM manufacturing_processes GROUP BY process_name;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, region VARCHAR(255), preservation_status VARCHAR(255)); INSERT INTO habitat_preservation (id, region, preservation_status) VALUES (1, 'Asia', 'Critical'), (2, 'Africa', 'Vulnerable'), (3, 'South America', 'Stable');
Delete all records from the 'habitat_preservation' table where the preservation status is 'Critical' and the region is 'Asia'.
DELETE FROM habitat_preservation WHERE preservation_status = 'Critical' AND region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (1, 'John', 'Doe', 'Assembly', 60000.00), (2, 'Jane', 'Doe', 'Quality', 55000.00), (3, 'Mike', 'Smith', '...
What is the average salary of employees who work in the 'Quality' department?
SELECT AVG(Salary) FROM Employees WHERE Department = 'Quality';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_specs (vehicle_name VARCHAR(50), vehicle_type VARCHAR(20), horsepower INT);
What is the average horsepower of sedans and SUVs combined in the 'vehicle_specs' table?
SELECT AVG(horsepower) FROM vehicle_specs WHERE vehicle_type IN ('Sedan', 'SUV');
gretelai_synthetic_text_to_sql
CREATE TABLE AstronautData (id INT, name VARCHAR(50), country VARCHAR(50), height FLOAT, weight FLOAT, blood_pressure FLOAT); INSERT INTO AstronautData (id, name, country, height, weight, blood_pressure) VALUES (1, 'John', 'USA', 180, 80, 120), (2, 'Jane', 'Canada', 170, 70, 110), (3, 'Alex', 'USA', 190, 90, 130);
What are the average medical metrics for astronauts from 'USA'?
SELECT AVG(height), AVG(weight), AVG(blood_pressure) FROM AstronautData WHERE country = 'USA';
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 in each industry category?
SELECT C.Industry, AVG(I.InvestmentAmount) AS AvgInvestmentAmount FROM Companies C JOIN Investments I ON C.CompanyID = I.CompanyID GROUP BY C.Industry;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (id INT, name TEXT, issue_date DATE, material TEXT); INSERT INTO Permits (id, name, issue_date, material) VALUES (1, 'High-Rise Construction', '2023-02-01', 'Concrete'), (2, 'Townhome Construction', '2023-03-15', 'Wood');
List the name and material of all the building permits issued in the last 3 months.
SELECT name, material FROM Permits WHERE issue_date > (CURRENT_DATE - INTERVAL '3 months')
gretelai_synthetic_text_to_sql
CREATE TABLE FashionTrends (trend_id INT, category VARCHAR(255), popularity INT, sustainability_score DECIMAL(3,2));CREATE TABLE FabricSources (source_id INT, fabric_type VARCHAR(255), country_of_origin VARCHAR(255), ethical_rating DECIMAL(3,2));CREATE TABLE Garments (garment_id INT, trend_id INT, fabric_source_id INT)...
What is the average sustainability score for Tropical Wear trends that use Hemp as their fabric type?
SELECT AVG(sustainability_score) FROM TropicalWearHempTrends;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255));CREATE TABLE mobile_subscribers (id INT, state_id INT, monthly_data_usage DECIMAL(10,2));
What is the average monthly data usage per mobile subscriber for each state, excluding those subscribers with a monthly data usage of 0?
SELECT s.name, AVG(ms.monthly_data_usage) as avg_data_usage FROM states s INNER JOIN mobile_subscribers ms ON s.id = ms.state_id WHERE ms.monthly_data_usage > 0 GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE community (id INT, name TEXT, location TEXT, investment_amount INT); INSERT INTO community (id, name, location, investment_amount) VALUES (1, 'Kirumba', 'Uganda', 5000), (2, 'Bangangte', 'Cameroon', 8000), (3, 'Mpumalanga', 'South Africa', 12000);
What is the average agricultural innovation investment per community in Africa?
SELECT AVG(investment_amount) FROM community WHERE location LIKE 'Africa%'
gretelai_synthetic_text_to_sql
CREATE TABLE Students (ID INT, Name VARCHAR(50), Program VARCHAR(50), Grade FLOAT); INSERT INTO Students (ID, Name, Program, Grade) VALUES (1, 'John Doe', 'Data Science', 85.6), (2, 'Jane Smith', 'Computer Science', 88.2);
What is the average grade of all students enrolled in the 'Data Science' program?
SELECT AVG(Grade) FROM Students WHERE Program = 'Data Science';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name TEXT, country TEXT); INSERT INTO players (player_id, name, country) VALUES (1, 'Okazaki', 'Japan'), (2, 'Iniesta', 'Spain'), (3, 'Matsui', 'Japan'); CREATE TABLE goals (goal_id INT, player_id INT, league TEXT, goals INT); INSERT INTO goals (goal_id, player_id, league, goals) VA...
What is the maximum number of goals scored in a single game by a player from Japan?
SELECT MAX(goals) FROM goals JOIN players ON goals.player_id = players.player_id WHERE players.country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE centers (id INT, name TEXT, region TEXT); INSERT INTO centers (id, name, region) VALUES (1, 'Center A', 'southeast'); INSERT INTO centers (id, name, region) VALUES (2, 'Center B', 'southwest'); INSERT INTO centers (id, name, region) VALUES (3, 'Center C', 'northwest');
What is the total number of community health centers in 'southeast' and 'southwest' regions?
SELECT 'Total Community Health Centers', COUNT(*) FROM ( (SELECT * FROM centers WHERE region IN ('southeast', 'southwest')) );
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (team_id INT, team_name VARCHAR(50), total_sales DECIMAL(10,2)); INSERT INTO ticket_sales (team_id, team_name, total_sales) VALUES (1, 'Team A', 45000.00), (2, 'Team B', 32000.00), (3, 'Team C', 50000.00), (4, 'Team D', 42000.00), (5, 'Team E', 38000.00);
List the top 3 teams with the highest total ticket sales, along with their total sales, in descending order.
SELECT team_name, total_sales FROM (SELECT team_name, total_sales, ROW_NUMBER() OVER (ORDER BY total_sales DESC) AS rank FROM ticket_sales) AS team_ranks WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE UNESCO_Heritage_Sites (id INT, site VARCHAR(100), year INT); INSERT INTO UNESCO_Heritage_Sites (id, site, year) VALUES (1, 'Colosseum', 1980), (2, 'Great Wall', 1987), (3, 'Alhambra', 1984), (4, 'Machu Picchu', 1983), (5, 'Petra', 1985);
What are the names of the heritage sites that were added to the list in the last 3 years, along with the year they were added?
SELECT site, year FROM UNESCO_Heritage_Sites WHERE year >= YEAR(CURRENT_DATE) - 3;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT, model VARCHAR(50), battery_capacity INT);
Update records in the 'electric_vehicles' table where the 'battery_capacity' is less than 70
UPDATE electric_vehicles SET battery_capacity = 75 WHERE battery_capacity < 70;
gretelai_synthetic_text_to_sql
CREATE TABLE funds (company_id INT, funding_amount DECIMAL(10, 2), funding_date DATE); INSERT INTO funds VALUES (1, 500000, '2022-01-01'); INSERT INTO funds VALUES (2, 300000, '2021-06-15');
Display the names of companies that have not received any funding
SELECT company_name FROM companies LEFT JOIN funds ON companies.company_id = funds.company_id WHERE funds.funding_amount IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationDate DATE, Amount DECIMAL(10,2));
Find the number of new donors each month in the past year, and the total amount donated by new donors each month.
SELECT DATEPART(month, DonationDate) AS Month, DATEPART(year, DonationDate) AS Year, COUNT(DISTINCT DonorID) AS NewDonors, SUM(Amount) AS TotalDonated FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE()) GROUP BY DATEPART(month, DonationDate), DATEPART(year, DonationDate);
gretelai_synthetic_text_to_sql
CREATE TABLE Training (Employee_ID INT, Training_Type VARCHAR(50), Hours_Spent DECIMAL(5,2)); INSERT INTO Training (Employee_ID, Training_Type, Hours_Spent) VALUES (3, 'Technical Skills', 8.00), (4, 'Technical Skills', 10.00), (5, 'Technical Skills', 6.00), (9, 'Technical Skills', 9.00), (10, 'Technical Skills', 7.00);
What is the total number of hours spent on technical skills training for employees in the 'Finance' department?
SELECT SUM(Hours_Spent) FROM Training WHERE Employee_ID IN (SELECT Employee_ID FROM Employee WHERE Department = 'Finance');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, country VARCHAR(255), name VARCHAR(255), skill VARCHAR(255)); INSERT INTO volunteers (id, country, name, skill) VALUES (1, 'Jordan', 'Volunteer 1', 'Skill 1'), (2, 'Jordan', 'Volunteer 2', 'Skill 2'), (3, 'Jordan', 'Volunteer 3', 'Skill 1'), (4, 'Jordan', 'Volunteer 4', 'Skill 3');
What is the total number of volunteers in Jordan and the number of unique skills they have?
SELECT country, COUNT(*) FROM volunteers GROUP BY country; SELECT country, COUNT(DISTINCT skill) FROM volunteers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE county (name VARCHAR(50), population INT, poverty_rate FLOAT); INSERT INTO county (name, population, poverty_rate) VALUES ('Greenfield', 25000, 15.5); INSERT INTO county (name, population, poverty_rate) VALUES ('Pineville', 18000, 18.0); INSERT INTO county (name, population, poverty_rate) VALUES ('Riverton...
Identify the bottom 3 rural counties with the highest percentage of residents living below the poverty line.
SELECT name, poverty_rate FROM county ORDER BY poverty_rate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_engagement (engagement_id INT, tour_id INT, engagement_time FLOAT); INSERT INTO virtual_tour_engagement (engagement_id, tour_id, engagement_time) VALUES (1, 1, 15.5), (2, 2, 20.0), (3, 3, 18.3), (4, 4, 12.7), (5, 5, 19.8); CREATE TABLE tour_region (tour_id INT, region TEXT); INSERT INTO tour_r...
What is the average virtual tour engagement time in Africa?
SELECT AVG(engagement_time) FROM virtual_tour_engagement INNER JOIN tour_region ON virtual_tour_engagement.tour_id = tour_region.tour_id WHERE tour_region.region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE AstroPhysicsResearch (id INT, project_name VARCHAR(30), cost FLOAT, duration INT);
What is the total cost of astrophysics research projects with a duration over 3 years?
SELECT SUM(cost) FROM AstroPhysicsResearch WHERE duration > 3 AND project_name LIKE 'Astro%';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (id INT, brand VARCHAR(255), country VARCHAR(255)); INSERT INTO Brands (id, brand, country) VALUES (1, 'BrandA', 'USA'), (2, 'BrandB', 'Canada'), (3, 'BrandC', 'Mexico'); CREATE TABLE Sales (id INT, brand_id INT, product VARCHAR(255), quantity INT, transparent_supply_chain BOOLEAN); INSERT INTO Sale...
What is the total quantity of products sold through transparent supply chains, by brand and country?
SELECT s.country, b.brand, SUM(s.quantity) AS total_quantity FROM Sales s JOIN Brands b ON s.brand_id = b.id WHERE s.transparent_supply_chain = true GROUP BY s.country, b.brand;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_for_social_good_budget (initiative_id INT, initiative_name VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO tech_for_social_good_budget (initiative_id, initiative_name, region, budget) VALUES (1, 'Smart city project', 'Asia', 1000000), (2, 'Green technology initiative', 'Europe', ...
What is the total budget for technology for social good initiatives in 'Asia' and 'Europe'?
SELECT SUM(budget) as total_budget, region FROM tech_for_social_good_budget WHERE region IN ('Asia', 'Europe') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE country_emissions (country_name VARCHAR(50), co2_emissions DECIMAL(10,2));
Which countries have the highest CO2 emissions from garment manufacturing?
SELECT country_name, co2_emissions FROM country_emissions ORDER BY co2_emissions DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists mobility_data (mobility_type varchar(20), city varchar(20), date date); INSERT INTO mobility_data (mobility_type, city, date) VALUES ('multimodal', 'madrid', '2019-12-31'), ('multimodal', 'madrid', '2020-01-01'), ('multimodal', 'madrid', '2020-01-02');
Delete all multimodal mobility records for 'madrid' before 2020-01-01
DELETE FROM mobility_data WHERE mobility_type = 'multimodal' AND city = 'madrid' AND date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Country_Feed (Country TEXT, Year INT, Fish_Weight FLOAT, Feed_Conversion_Ratio FLOAT); INSERT INTO Country_Feed (Country, Year, Fish_Weight, Feed_Conversion_Ratio) VALUES ('China', 2019, 1200000, 1.2), ('Indonesia', 2019, 800000, 1.3), ('India', 2019, 600000, 1.1), ('China', 2020, 1400000, 1.15), ('Indones...
What is the total fish weight and feed conversion ratio for each country in 2020?
SELECT Country, SUM(Fish_Weight) OVER (PARTITION BY Country) AS Total_Fish_Weight, Feed_Conversion_Ratio FROM Country_Feed WHERE Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name TEXT, ocean_basin TEXT);
What are the names of the marine species in the Pacific Ocean?
SELECT species_name FROM marine_species WHERE ocean_basin = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(50), developer_id INT, gas_price DECIMAL(10,2), network VARCHAR(50)); INSERT INTO smart_contracts (contract_id, name, developer_id, gas_price, network) VALUES (1, 'BSCContract1', 1, 21000, 'Binance Smart Chain'), (2, 'BSCContract2', 2, 19000, 'Binance Smart Ch...
What are the names and gas prices of smart contracts on the Binance Smart Chain with gas prices above the average?
SELECT smart_contracts.name, smart_contracts.gas_price FROM smart_contracts WHERE smart_contracts.network = 'Binance Smart Chain' AND smart_contracts.gas_price > (SELECT AVG(smart_contracts.gas_price) FROM smart_contracts WHERE smart_contracts.network = 'Binance Smart Chain');
gretelai_synthetic_text_to_sql
CREATE TABLE recent_tournament (player_id INT, player_name TEXT, score INT, country TEXT);
What was the maximum score of players from Europe in the 'recent_tournament' table?
SELECT MAX(score) FROM recent_tournament WHERE country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR(100), rural BOOLEAN); INSERT INTO hospitals (hospital_id, hospital_name, rural) VALUES (1, 'Rural Hospital A', true), (2, 'Urban Hospital B', false);
Update the hospital name for hospital_id 1.
UPDATE hospitals SET hospital_name = 'New Rural Hospital A' WHERE hospital_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (id INT, region VARCHAR(20), investment_date DATE, amount DECIMAL(10,2)); INSERT INTO network_investments (id, region, investment_date, amount) VALUES (1, 'Europe', '2022-01-01', 50000.00), (2, 'Asia', '2022-02-01', 75000.00), (3, 'Europe', '2022-03-01', 60000.00), (4, 'Africa', '2022-0...
Update the network investment amount to $52,000 for the record with the investment date of '2022-04-01' in the 'Africa' region.
UPDATE network_investments SET amount = 52000 WHERE region = 'Africa' AND investment_date = '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE drought_declarations_canada (province VARCHAR(50), year INT); INSERT INTO drought_declarations_canada (province, year) VALUES ('Ontario', 2000), ('Alberta', 2003), ('British Columbia', 2006);
How many droughts have been declared in Canada since 2000?
SELECT COUNT(*) FROM drought_declarations_canada WHERE year >= 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE flight_hours (flight_id INT, model_id INT, flight_hours INT);
What is the total number of flight hours for each aircraft model in the flight_hours table?
SELECT model_id, SUM(flight_hours) as total_flight_hours FROM flight_hours GROUP BY model_id;
gretelai_synthetic_text_to_sql
CREATE TABLE program_volunteers (program_id INT, volunteer_id INT); INSERT INTO program_volunteers (program_id, volunteer_id) VALUES (100, 1), (100, 2), (200, 3); CREATE TABLE program_donors (program_id INT, donor_id INT); INSERT INTO program_donors (program_id, donor_id) VALUES (100, 4), (100, 5), (200, 6);
How many volunteers and donors are there for each program?
SELECT p.name, COUNT(DISTINCT v.id) AS num_volunteers, COUNT(DISTINCT d.id) AS num_donors FROM programs p LEFT JOIN program_volunteers v ON p.id = v.program_id LEFT JOIN program_donors d ON p.id = d.program_id GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE papers (id INT, student_id INT, title VARCHAR(100)); INSERT INTO students VALUES (1, 'Dana', 'Arts and Sciences'), (2, 'Eli', 'Arts and Sciences'), (3, 'Fiona', 'Arts and Sciences'); INSERT INTO papers VALUES (1, 1, 'Paper 1'), (2, 1...
List the top 5 most productive graduate students in terms of published papers in the College of Arts and Sciences, excluding students who have not published any papers.
SELECT student_id, COUNT(*) AS paper_count FROM papers GROUP BY student_id ORDER BY paper_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE donor_org (donor_id INT, org_id INT, donation_year INT); INSERT INTO donor_org (donor_id, org_id, donation_year) VALUES (1, 1, 2019), (2, 1, 2020), (3, 1, 2021), (4, 2, 2019), (5, 2, 2020), (6, 2, 2021), (7, 3, 2019), (8, 3, 2020), (9, 3, 2021);
How many unique donors have donated to each organization in the past 3 years?
SELECT org_id, COUNT(DISTINCT donor_id) num_donors FROM donor_org WHERE donation_year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY org_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics.product_safety (product_id INT, country VARCHAR(50), is_cruelty_free BOOLEAN); INSERT INTO cosmetics.product_safety (product_id, country, is_cruelty_free) VALUES (1, 'UK', true), (2, 'France', false), (3, 'Germany', true), (4, 'Italy', true), (5, 'Spain', false);
What percentage of products are certified cruelty-free in the UK?
SELECT (SUM(is_cruelty_free) * 100.0 / COUNT(*)) as cruelty_free_percentage FROM cosmetics.product_safety WHERE country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production (id INT, well_id INT, state VARCHAR(20), year INT, oil_volume FLOAT); INSERT INTO oil_production (id, well_id, state, year, oil_volume) VALUES (1, 1, 'North Dakota', 2019, 1200000); INSERT INTO oil_production (id, well_id, state, year, oil_volume) VALUES (2, 2, 'Texas', 2020, 1500000); INSER...
List the names of all wells that produced more than 1,000,000 barrels of oil in North Dakota in 2019
SELECT well_id, well_name, oil_volume FROM wells w INNER JOIN oil_production op ON w.id = op.well_id WHERE state = 'North Dakota' AND year = 2019 AND oil_volume > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), country VARCHAR(20), quantity INT, year INT); INSERT INTO production (element, country, quantity, year) VALUES ('Cerium', 'South Africa', 120000, 2015), ('Cerium', 'South Africa', 130000, 2016), ('Cerium', 'South Africa', 140000, 2017);
What is the total quantity of 'Cerium' produced by 'South Africa' before 2018?
SELECT SUM(quantity) FROM production WHERE element = 'Cerium' AND country = 'South Africa' AND year < 2018;
gretelai_synthetic_text_to_sql
SAME AS ABOVE
What is the average salary for employees who identify as female, hired between 2019 and 2021, and work in the IT department?
SELECT AVG(Salary) FROM Employees WHERE Gender = 'Female' AND HireYear BETWEEN 2019 AND 2021 AND Department = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor VARCHAR(50), country VARCHAR(50), year INT, amount INT); INSERT INTO donations (id, donor, country, year, amount) VALUES (1, 'John Doe', 'India', 2020, 500), (2, 'Jane Smith', 'India', 2021, 750), (3, 'John Doe', 'India', 2021, 1000);
How many unique attendees have donated to performing arts programs in India in the last 2 years?
SELECT COUNT(DISTINCT donor) FROM donations WHERE country = 'India' AND event IN ('Theater', 'Dance', 'Music') AND year BETWEEN 2020 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (community_policing_id INT, is_active BOOLEAN);
Insert a new record with an community_policing_id of 6 and is_active set to 'false' into the 'community_policing' table
INSERT INTO community_policing (community_policing_id, is_active) VALUES (6, false);
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (MetricID INT, Region VARCHAR(255), MetricValue INT, ReportDate DATE); INSERT INTO HealthEquityMetrics (MetricID, Region, MetricValue, ReportDate) VALUES (1, 'Northeast', 85, '2022-01-01'); INSERT INTO HealthEquityMetrics (MetricID, Region, MetricValue, ReportDate) VALUES (2, 'Southeast...
What is the total health equity metric for each region in 2022?
SELECT Region, SUM(MetricValue) FROM HealthEquityMetrics WHERE YEAR(ReportDate) = 2022 GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), phone_number VARCHAR(15), created_at TIMESTAMP);
Delete a customer record from the customers table
DELETE FROM customers WHERE customer_id = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy TEXT, risk_score FLOAT); INSERT INTO investment_strategies (id, strategy, risk_score) VALUES (1, 'Equity Investment', 6.5), (2, 'Real Estate Investment', 4.8), (3, 'Bond Investment', 3.2);
What is the highest risk investment strategy and its associated risk score?
SELECT strategy, MAX(risk_score) FROM investment_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (drug_name VARCHAR(255), sales_quantity INT, sales_amount DECIMAL(10,2)); INSERT INTO SalesData (drug_name, sales_quantity, sales_amount) VALUES ('DrugK', 200, 30000.00), ('DrugL', 100, 15000.00), ('DrugM', 150, 25000.00);
What is the average sales quantity and sales amount for each drug, unpivoted and with a total row?
SELECT drug_name, 'sales_quantity' as metric, AVG(sales_quantity) as value FROM SalesData GROUP BY drug_name UNION ALL SELECT drug_name, 'sales_amount' as metric, AVG(sales_amount) as value FROM SalesData GROUP BY drug_name UNION ALL SELECT 'Total', AVG(value) as value FROM (SELECT drug_name, 'sales_quantity' as metric...
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_development (id INT, project VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);
Update the 'infrastructure_development' table to reflect a new end date of January 1, 2024 for project 'E'
UPDATE infrastructure_development SET end_date = '2024-01-01' WHERE project = 'E';
gretelai_synthetic_text_to_sql
CREATE TABLE performance_attendance (id INT, city VARCHAR(20), year INT, genre VARCHAR(20), attendance INT); INSERT INTO performance_attendance (id, city, year, genre, attendance) VALUES (1, 'Tokyo', 2018, 'dance', 500), (2, 'Rio de Janeiro', 2019, 'dance', 600), (3, 'New York', 2019, 'dance', 450), (4, 'Paris', 2018, ...
What is the average attendance at dance performances in Rio de Janeiro in 2019?
SELECT AVG(attendance) FROM performance_attendance WHERE city = 'Rio de Janeiro' AND genre = 'dance' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE PowerPlants (id INT, state CHAR(2), capacity FLOAT, fuel VARCHAR(10));CREATE TABLE CarbonEmissions (id INT, powerplant_id INT, year INT, emissions FLOAT);
Find the total carbon emissions for each state from the PowerPlants and CarbonEmissions tables
SELECT p.state, SUM(ce.emissions) as total_emissions FROM PowerPlants p INNER JOIN CarbonEmissions ce ON p.id = ce.powerplant_id GROUP BY p.state;
gretelai_synthetic_text_to_sql