context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE carbon_offset_initiatives (id INT, name TEXT, city TEXT, launch_date DATE); INSERT INTO carbon_offset_initiatives (id, name, city, launch_date) VALUES (1, 'Initiative 1', 'Tokyo', '2018-01-01'); INSERT INTO carbon_offset_initiatives (id, name, city, launch_date) VALUES (2, 'Initiative 2', 'Tokyo', '2019-01...
How many carbon offset initiatives were launched in the city of Tokyo in 2018?
SELECT COUNT(*) FROM carbon_offset_initiatives WHERE city = 'Tokyo' AND launch_date <= '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO hospitals (id, name, location) VALUES (1, 'Rural Hospital A', 'Rural Town A'); INSERT INTO hospitals (id, name, location) VALUES (2, 'Rural Hospital B', 'Rural Town B'); CREATE TABLE clinics (id INT, name VARCHAR(50), location VARCHAR(...
What is the total number of hospitals and clinics in the rural health database?
SELECT COUNT(*) FROM hospitals UNION SELECT COUNT(*) FROM clinics;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, district_id INT); INSERT INTO teachers (teacher_id, teacher_name, district_id) VALUES (1, 'Mrs. Doe', 1), (2, 'Mr. Smith', 2), (3, 'Ms. Johnson', 3); CREATE TABLE professional_development (program_id INT, program_name TEXT, teacher_id INT); INSERT INTO professio...
How many professional development programs have been attended by teachers in the 'Suburbs' district?
SELECT COUNT(*) FROM professional_development pd JOIN teachers t ON pd.teacher_id = t.teacher_id WHERE t.district_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (investment_id INT, sector VARCHAR(50), investment_amount INT, investment_date DATE); INSERT INTO investments (investment_id, sector, investment_amount, investment_date) VALUES (1, 'Education', 500000, '2022-01-01'), (2, 'Education', 600000, '2023-02-01'), (3, 'Education', 400000, '2024-03-01')...
What is the total number of investments in the education sector, broken down by year?
SELECT EXTRACT(YEAR FROM investment_date) as year, COUNT(*) as total_investments FROM investments WHERE sector = 'Education' GROUP BY year ORDER BY year ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE stellar_nodes (node_id VARCHAR(50), quorum_percentage DECIMAL(5,2));
What is the minimum number of nodes required to form a quorum on the Stellar network?
SELECT MIN(quorum_percentage) FROM stellar_nodes HAVING COUNT(*) >= (SELECT COUNT(*) FROM stellar_nodes) * 0.5;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Program varchar(50), Hours numeric(5,2)); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours) VALUES (1, 'Alice', 'ProgramA', 20.00), (2, 'Bob', 'ProgramB', 30.00);
Find the volunteer with the highest number of hours volunteered in each program?
SELECT Name, Program, MAX(Hours) OVER (PARTITION BY Program) AS MaxHours FROM Volunteers;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, employment_status VARCHAR(50)); INSERT INTO Employees (id, name, department, salary, employment_status) VALUES (1, 'John Doe', 'Mining', 75000.00, 'Full-time'), (2, 'Jane Smith', 'HR', 60000.00, 'Full-time'), (3, 'Mike Johnson', 'Mi...
What is the total number of employees in the Mining department and their average salary?
SELECT department, COUNT(*), AVG(salary) FROM Employees WHERE department = 'Mining' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment_defense (veteran_id INT, industry VARCHAR(50), employed BOOLEAN); INSERT INTO veteran_employment_defense (veteran_id, industry, employed) VALUES (1, 'Defense', TRUE), (2, 'Defense', FALSE); CREATE TABLE veteran_employment_private (veteran_id INT, industry VARCHAR(50), employed BOOLEAN); ...
Compare veteran employment statistics in the defense industry with the private sector
SELECT SUM(employed) FROM veteran_employment_defense WHERE employed = TRUE; SELECT SUM(employed) FROM veteran_employment_private WHERE employed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_usage (id INT, tech_type TEXT, tech_usage_date DATE, conflict TEXT); INSERT INTO military_tech_usage (id, tech_type, tech_usage_date, conflict) VALUES (1, 'Drones', '2020-02-01', 'Conflict A'), (2, 'Armored Vehicles', '2019-11-15', 'Conflict B');
List all military technologies that were used in the last 2 military conflicts, including the technology type and conflict date.
SELECT mt.tech_type, mt.tech_usage_date FROM military_tech_usage mt WHERE mt.tech_usage_date >= '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT PRIMARY KEY, user_id INT, content TEXT, created_at TIMESTAMP);
Retrieve the number of posts per day for the last 7 days
SELECT DATE_TRUNC('day', created_at) AS day, COUNT(*) FROM posts WHERE created_at >= NOW() - INTERVAL '7 days' GROUP BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_driving_tests (company VARCHAR(255), city VARCHAR(255), autonomous_level VARCHAR(255), test_date DATE);
Insert a new row into the 'autonomous_driving_tests' table with the following values: 'Waymo', 'Phoenix', 'Level 4', '2022-05-01'
INSERT INTO autonomous_driving_tests (company, city, autonomous_level, test_date) VALUES ('Waymo', 'Phoenix', 'Level 4', '2022-05-01');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50)); CREATE TABLE labor_certifications (certification_id INT, certification_name VARCHAR(50)); CREATE TABLE product_labor_certifications (product_id INT, certification_id INT); INSERT INTO products (product_id, product_name) VALUES (1, 'Eco Hoodie'), (2, 'Sus...
Which products in the products table have been certified by a specific certification in the labor_certifications table?
SELECT p.product_name FROM products p INNER JOIN product_labor_certifications plc ON p.product_id = plc.product_id INNER JOIN labor_certifications lc ON plc.certification_id = lc.certification_id WHERE lc.certification_name = 'Fair Trade';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (volunteer_id INT, registration_date DATE, state VARCHAR(20)); INSERT INTO Volunteers (volunteer_id, registration_date, state) VALUES (1, '2022-01-01', 'California'), (2, '2022-01-02', 'Texas');
How many volunteers were registered in 'California' in the table 'Volunteers'?
SELECT COUNT(*) FROM Volunteers WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, investment_date DATE, investment_amount FLOAT); INSERT INTO network_investments (investment_id, investment_date, investment_amount) VALUES (1, '2022-01-01', 500000); INSERT INTO network_investments (investment_id, investment_date, investment_amount) VALUES (2, '2022-...
What is the total number of network infrastructure investments made in the last quarter?
SELECT SUM(investment_amount) FROM network_investments WHERE investment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GameType VARCHAR(10)); INSERT INTO Players (PlayerID, Age, GameType) VALUES (1, 25, 'Action'), (2, 30, 'RPG'), (3, 22, 'Action'), (4, 28, 'Action'), (5, 20, 'Action');
What is the standard deviation of the age of players who play Action games?
SELECT STDDEV(Age) FROM Players WHERE GameType = 'Action';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_loans (loan_id INT, customer_id INT, amount DECIMAL(10, 2), issue_date DATE); INSERT INTO shariah_compliant_loans (loan_id, customer_id, amount, issue_date) VALUES (3, 106, 5500.00, '2021-02-15'), (4, 107, 6500.00, '2021-02-28');
List the names and Shariah-compliant loan amounts for customers who have received Shariah-compliant loans in February 2021.
SELECT name, amount FROM customers c INNER JOIN shariah_compliant_loans s ON c.customer_id = s.customer_id WHERE MONTH(issue_date) = 2 AND YEAR(issue_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalExperiences (experience_id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO DigitalExperiences (experience_id, date, revenue) VALUES (1, '2022-01-01', 50.00), (2, '2022-02-01', 75.00), (3, '2022-03-01', 100.00);
What is the total revenue generated from digital museum experiences in the last quarter?
SELECT SUM(revenue) FROM DigitalExperiences WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE FairTradeFactories (id INT, country VARCHAR(50), certification_date DATE);
List the top 5 countries with the highest number of fair trade certified factories.
SELECT country, COUNT(*) as num_factories FROM FairTradeFactories GROUP BY country ORDER BY num_factories DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50)); CREATE TABLE fleet_officers (officer_id INT, officer_name VARCHAR(50)); CREATE TABLE vessel_assignments (assignment_id INT, vessel_id INT, officer_id INT);
List all vessels and their corresponding fleet management officer's name, even if a vessel has no assigned officer.
SELECT v.vessel_name, coalesce(fo.officer_name, 'Unassigned') as officer_name FROM vessels v LEFT JOIN vessel_assignments va ON v.vessel_id = va.vessel_id LEFT JOIN fleet_officers fo ON va.officer_id = fo.officer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels(id INT, name TEXT, country TEXT, rating FLOAT, pool BOOLEAN, revenue FLOAT);
What is the total revenue generated by 'hotels' in 'South America' that offer 'pool' facilities?
SELECT SUM(revenue) FROM hotels WHERE country = 'South America' AND pool = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE EventPlayers (event VARCHAR(100), category VARCHAR(50), players INT);
What is the average number of players per eSports event in the 'Strategy' category?
SELECT AVG(players) FROM EventPlayers WHERE category = 'Strategy';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, city VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, gender, age, city, country) VALUES (1, 'David', 'Male', 20, 'New York', 'USA'); INSERT INTO users (id, name, gender, age, city, country) VALUES (2, 'Eva', 'Female', 25, 'Los An...
What is the total number of users from India and China?
SELECT country, COUNT(*) as total_users FROM users WHERE country IN ('India', 'China') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE tourist_sites (id INT PRIMARY KEY, name TEXT, country TEXT, visitor_count INT);
Delete all records from the "tourist_sites" table where the "country" is "Brazil" and the "visitor_count" is less than 5000
DELETE FROM tourist_sites WHERE country = 'Brazil' AND visitor_count < 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (quarter TEXT, material TEXT, rate DECIMAL(3,2)); INSERT INTO recycling_rates (quarter, material, rate) VALUES ('Q1 2021', 'plastic', 0.30), ('Q1 2021', 'paper', 0.45), ('Q2 2022', 'plastic', 0.31), ('Q2 2022', 'paper', 0.46), ('Q3 2022', 'plastic', NULL), ('Q3 2022', 'paper', NULL);
Update the recycling rate for 'paper' to 48% in 'recycling_rates' table for Q3 2022.
UPDATE recycling_rates SET rate = 0.48 WHERE quarter = 'Q3 2022' AND material = 'paper';
gretelai_synthetic_text_to_sql
CREATE TABLE TimePeriod (id INT, name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO TimePeriod (id, name, start_date, end_date) VALUES (1, 'Month', '2022-01-01', '2022-01-31'); CREATE TABLE MiningWater (id INT, mining_company_id INT, time_period_id INT, quantity INT); INSERT INTO MiningWater (id, mining_co...
Get the total amount of water used and waste generated per month by 'XYZ Mining'.
SELECT t.name, SUM(w.quantity) AS water_quantity, SUM(wa.quantity) AS waste_quantity FROM TimePeriod t, MiningWater w, MiningWaste wa, MiningCompany mc WHERE t.id = w.time_period_id AND t.id = wa.time_period_id AND mc.id = w.mining_company_id AND mc.id = wa.mining_company_id AND mc.name = 'XYZ Mining' GROUP BY t.name;
gretelai_synthetic_text_to_sql
CREATE TABLE bases (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO bases (id, name, state) VALUES (1, 'Fort Irwin', 'California'), (2, 'Edwards AFB', 'California');
How many military bases are there in California?
SELECT COUNT(*) FROM bases WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists visitor_stats (visitor_id INT, arrival_age INT, continent VARCHAR(10)); INSERT INTO visitor_stats (visitor_id, arrival_age, continent) VALUES (1, 35, 'Europe'), (2, 28, 'Asia'), (3, 42, 'Americas'), (4, 22, 'Africa'), (5, 31, 'Australia');
What is the average arrival age of visitors for each continent?
SELECT AVG(arrival_age) as avg_age, continent FROM visitor_stats GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE SouthernOcean (species_name TEXT, taxonomic_class TEXT); INSERT INTO SouthernOcean (species_name, taxonomic_class) VALUES ('Krill', 'Crustacea'), ('Blue Whale', 'Mammalia'); CREATE TABLE Taxonomy (taxonomic_class TEXT, class_count INTEGER); INSERT INTO Taxonomy (taxonomic_class, class_count) VALUES ('Crust...
Identify the number of marine species in the Southern Ocean by taxonomic class.
SELECT Taxonomy.taxonomic_class, Taxonomy.class_count FROM Taxonomy INNER JOIN SouthernOcean ON Taxonomy.taxonomic_class = SouthernOcean.taxonomic_class;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, product TEXT, production_volume INT); INSERT INTO mines (id, name, location, product, production_volume) VALUES (1, 'Black Thunder', 'United States', 'Coal', 20000);
What is the average production volume of coal per mine in the United States?
SELECT AVG(production_volume) FROM mines WHERE location = 'United States' AND product = 'Coal';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, country TEXT, transaction_amount DECIMAL); INSERT INTO clients (client_id, name, country, transaction_amount) VALUES (1, 'John Doe', 'United States', 500.00); INSERT INTO clients (client_id, name, country, transaction_amount) VALUES (2, 'Jane Smith', 'Canada', 350.00); IN...
Delete transactions from clients living in the United States.
DELETE FROM clients WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants(id INT, name VARCHAR(255), last_inspection_date DATE); INSERT INTO restaurants (id, name, last_inspection_date) VALUES (1, 'Restaurant A', '2021-06-01'), (2, 'Restaurant B', '2022-03-15'), (3, 'Restaurant C', '2021-11-30');
Which restaurants have had a food safety violation in the past year?
SELECT name FROM restaurants WHERE last_inspection_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE AND FIND_IN_SET('violation', inspection_details) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_details(infrastructure_id INT, esg_score FLOAT, region VARCHAR(10));
Avg. ESG score for European sustainable infrastructure?
SELECT AVG(esg_score) FROM infrastructure_details WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (country VARCHAR(20), revenue INT); INSERT INTO carbon_pricing (country, revenue) VALUES ('European Union', 50000), ('UK', 30000);
What is the total carbon pricing revenue in the European Union and the UK, and what is the percentage contribution of each?
SELECT c1.country, c1.revenue, (c1.revenue * 100.0 / SUM(c1.revenue)) as percentage FROM carbon_pricing c1 WHERE c1.country IN ('European Union', 'UK') GROUP BY c1.country;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_size FLOAT, ocean VARCHAR(255)); INSERT INTO marine_protected_areas (name, area_size, ocean) VALUES ('Hawaiian Islands', 137030, 'Pacific');
What is the average size of all marine protected areas in the Pacific Ocean?
SELECT AVG(area_size) FROM marine_protected_areas WHERE ocean = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE CyberStrategy (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, organization_id INT); CREATE TABLE Organization (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255)); INSERT INTO Organization (id, name, type) VALUES (1, 'NSA', 'Intelligence');
List cybersecurity strategies, their implementing organizations, and types
SELECT s.name, o.name AS organization_name, o.type FROM CyberStrategy s INNER JOIN Organization o ON s.organization_id = o.id WHERE o.type = 'Intelligence';
gretelai_synthetic_text_to_sql
CREATE TABLE CaseResolutions (CaseID INT, Resolution VARCHAR(20), Year INT); INSERT INTO CaseResolutions (CaseID, Resolution, Year) VALUES (1, 'Restorative Justice', 2021), (2, 'Probation', 2021), (3, 'Restorative Justice', 2022), (4, 'Incarceration', 2022);
What is the percentage of cases that were resolved through restorative justice, by year?
SELECT Year, COUNT(*) FILTER (WHERE Resolution = 'Restorative Justice') * 100.0 / COUNT(*) AS Percentage FROM CaseResolutions GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE Product (id INT, productName VARCHAR(50), price DECIMAL(5,2)); INSERT INTO Product (id, productName, price) VALUES (4, 'Blush', 14.99), (5, 'Foundation', 29.99), (6, 'Lip Liner', 16.99); CREATE TABLE SafetyRecord (id INT, productId INT, safetyRating VARCHAR(10), reportDate DATE); INSERT INTO SafetyRecord (...
What is the average report age for products that have a safety rating of 'Excellent'?
SELECT AVG(DATEDIFF(day, S.reportDate, GETDATE())) as avgReportAge FROM SafetyRecord S WHERE S.safetyRating = 'Excellent';
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategies (company_name VARCHAR(100), exit_type VARCHAR(50), exit_year INT);
List the names of all startups that have exited through an IPO
SELECT company_name FROM exit_strategies WHERE exit_type = 'IPO';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers(subscriber_id INT, made_complaint BOOLEAN); INSERT INTO mobile_subscribers(subscriber_id, made_complaint) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, FALSE); CREATE TABLE broadband_subscribers(subscriber_id INT, made_complaint BOOLEAN); INSERT INTO broadband_subscribers(subscriber_id, m...
What is the percentage of mobile and broadband subscribers who have made a complaint in the last 6 months?
SELECT (SELECT COUNT(*) FROM (SELECT subscriber_id FROM mobile_subscribers WHERE made_complaint = TRUE UNION SELECT subscriber_id FROM broadband_subscribers WHERE made_complaint = TRUE)) * 100.0 / (SELECT COUNT(*) FROM (SELECT subscriber_id FROM mobile_subscribers UNION SELECT subscriber_id FROM broadband_subscribers))...
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRatesAPAC (id INT, country VARCHAR(50), region VARCHAR(50), recycling_rate FLOAT); INSERT INTO RecyclingRatesAPAC (id, country, region, recycling_rate) VALUES (1, 'China', 'APAC', 25.6), (2, 'Japan', 'APAC', 34.7), (3, 'India', 'APAC', 22.3);
Update the recycling rate for Japan to 35.5% in the RecyclingRatesAPAC table.
UPDATE RecyclingRatesAPAC SET recycling_rate = 0.355 WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO campaigns (id, name, start_date, end_date) VALUES (3, 'Embrace Yourself', '2021-07-01', '2021-12-31'); INSERT INTO campaigns (id, name, start_date, end_date) VALUES (4, 'Mental Health for All', '2021-07-01', '2021-12-31');
What mental health campaigns were active in the second half of 2021?
SELECT name FROM campaigns WHERE start_date <= '2021-07-01' AND end_date >= '2021-07-01'
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, employees INT, founding_date DATE, founder_minority TEXT);
What is the total number of employees for companies founded by underrepresented minorities in the tech sector?
SELECT SUM(employees) FROM companies WHERE industry = 'Tech' AND founder_minority IN ('African American', 'Hispanic', 'Native American');
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(50), price DECIMAL(5,2));
Add a new menu item 'Veggie Burger' with a price of 13.50
INSERT INTO menu_items (item_name, price) VALUES ('Veggie Burger', 13.50);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, PromotionDate DATE);
Calculate the percentage of employees who received a promotion in the last 6 months, and display the result with two decimal places.
SELECT ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees) , 2) AS PromotionPercentage FROM Employees WHERE PromotionDate >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'London'); CREATE TABLE properties (id INT, city_id INT); INSERT INTO properties (id, city_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3), (7, 3);
How many properties are there in each city, ordered by the number of properties in descending order?
SELECT city_id, COUNT(*) as num_properties FROM properties GROUP BY city_id ORDER BY num_properties DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_units (id INT, neighborhood TEXT, city TEXT, state TEXT, price FLOAT, is_affordable BOOLEAN);
Which neighborhood in Austin has the most affordable housing?
SELECT neighborhood, COUNT(*) as total_affordable FROM housing_units WHERE city = 'Austin' AND is_affordable = TRUE GROUP BY 1 HAVING total_affordable > (SELECT AVG(total_affordable) FROM (SELECT COUNT(*) as total_affordable FROM housing_units WHERE city = 'Austin' AND is_affordable = TRUE GROUP BY neighborhood) as sub...
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftLaunches (id INT, name VARCHAR(50), company VARCHAR(50), launch_date DATE, apogee FLOAT);
What is the average altitude of spacecrafts launched by 'Blue Origin'?
SELECT company, AVG(apogee) FROM SpacecraftLaunches WHERE company = 'Blue Origin' GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationTrips(id INT, mode VARCHAR(20), city VARCHAR(20), autonomous BOOLEAN);
What is the percentage of public transportation trips taken by autonomous vehicles in Tokyo?
SELECT mode, ROUND(COUNT(*)*100.0/SUM(COUNT(*)) OVER (PARTITION BY city) , 2) as percentage FROM TransportationTrips WHERE city = 'Tokyo' AND autonomous = TRUE GROUP BY mode ORDER BY percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTestingVehicle (TestID INT, Vehicle VARCHAR(20), TestResult VARCHAR(10)); CREATE TABLE AutonomousDrivingData (TestID INT, Vehicle VARCHAR(20), MaxSpeed FLOAT, MinSpeed FLOAT);
Show the vehicles that passed safety tests and were also tested in autonomous driving research.
SELECT Vehicle FROM SafetyTestingVehicle STV JOIN AutonomousDrivingData ADD ON STV.Vehicle = ADD.Vehicle WHERE STV.TestResult = 'Pass';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, program VARCHAR(50), country VARCHAR(50)); CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(50), program VARCHAR(50), country VARCHAR(50)); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (1, 15...
What is the total number of volunteers and total donation amount for each program in Mexico?
SELECT p.program, COUNT(DISTINCT v.volunteer_name) as num_volunteers, SUM(d.donation_amount) as total_donations FROM Donations d INNER JOIN Volunteers v ON d.program = v.program INNER JOIN Programs p ON d.program = p.program WHERE d.country = 'Mexico' GROUP BY p.program;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255), opt_in_targeted_ads BOOLEAN);
Determine the number of users who have opted in to targeted advertising in 'Russia'.
SELECT COUNT(*) AS num_users
gretelai_synthetic_text_to_sql
CREATE TABLE assistive_tech (id INT, name VARCHAR(255), type VARCHAR(255), distribution_date DATE); CREATE TABLE communities (id INT, name VARCHAR(255), region VARCHAR(255));
What are the names and types of assistive technologies that have been distributed in underrepresented communities in the last 5 years?
SELECT assistive_tech.name, assistive_tech.type FROM assistive_tech INNER JOIN communities ON assistive_tech.distribution_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 5 YEAR) WHERE communities.region = 'Underrepresented';
gretelai_synthetic_text_to_sql
CREATE TABLE Weather (location VARCHAR(255), temperature DECIMAL(5,2), time DATETIME); INSERT INTO Weather (location, temperature, time) VALUES ('Arctic', 5.0, '2022-01-01 12:00:00'), ('Arctic', 4.5, '2022-01-02 12:00:00');
What is the maximum water temperature in the Arctic region?
SELECT MAX(temperature) FROM Weather WHERE location = 'Arctic' AND time BETWEEN '2022-01-01' AND '2022-01-02';
gretelai_synthetic_text_to_sql
CREATE TABLE network_stats (stat_id INT, coin VARCHAR(10), value DECIMAL(20,2)); INSERT INTO network_stats (stat_id, coin, value) VALUES (1, 'Bitcoin', 834563.45), (2, 'Bitcoin', 843546.23), (3, 'Bitcoin', 854364.21);
What is the average block size in the Bitcoin network?
SELECT AVG(value) FROM network_stats WHERE coin = 'Bitcoin';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (department VARCHAR(100), year INT, num_veterans INT, total_employees INT);
Which department has the highest veteran employment rate in 2020?
SELECT department, (num_veterans/total_employees)*100 AS veteran_rate FROM veteran_employment WHERE year = 2020 ORDER BY veteran_rate DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE movies_revenue (movie_id INT, title VARCHAR(255), release_year INT, revenue INT); INSERT INTO movies_revenue (movie_id, title, release_year, revenue) VALUES (1, 'Inception', 2010, 825), (2, 'Avatar', 2009, 2788), (3, 'Parasite', 2019, 258), (4, 'The Lion King', 2019, 1657);
What is the total revenue of movies released in 2019?
SELECT SUM(revenue) as total_revenue FROM movies_revenue WHERE release_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, region TEXT, program_count INT); INSERT INTO programs (id, region, program_count) VALUES (1, 'Asian', 10), (2, 'African', 8), (3, 'European', 12), (4, 'American', 15);
What is the maximum number of evidence-based policy making programs in the Asian region?
SELECT MAX(program_count) FROM programs WHERE region = 'Asian';
gretelai_synthetic_text_to_sql
CREATE TABLE Production(garment_id INT, recycled_material_weight INT); INSERT INTO Production(garment_id, recycled_material_weight) VALUES (1, 5), (2, 3);
What is the total weight of recycled materials used in the production of garments?
SELECT SUM(recycled_material_weight) FROM Production;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INTEGER, name TEXT); INSERT INTO marine_species (id, name) VALUES (1, 'Coral'), (2, 'Clownfish'), (3, 'Sea Star'), (4, 'Tuna'), (5, 'Polar Bear'), (6, 'Narwhal'), (7, 'Walrus'), (8, 'Beluga Whale');
How many marine species are there in total?
SELECT COUNT(*) FROM marine_species;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseDiplomacy (nation VARCHAR(50), year INT, spending FLOAT); INSERT INTO DefenseDiplomacy (nation, year, spending) VALUES ('France', 2016, 300000000), ('Germany', 2016, 350000000), ('United Kingdom', 2016, 400000000), ('Italy', 2016, 280000000), ('Spain', 2016, 330000000);
What is the average defense diplomacy spending for Western European nations in 2016?
SELECT AVG(spending) FROM DefenseDiplomacy WHERE nation IN ('France', 'Germany', 'United Kingdom', 'Italy', 'Spain') AND year = 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE vancouver_owners (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO vancouver_owners (id, name, type) VALUES (1, 'John Doe', 'individual'), (2, 'Jane Smith', 'individual'), (3, 'ABC Corp', 'company'); CREATE TABLE property_co_owners (id INT, property_id INT, owner_id INT); INSERT INTO property_co_ow...
Who are the top 5 property co-owners in Vancouver with the most properties?
SELECT vancouver_owners.name, COUNT(properties.id) AS property_count FROM vancouver_owners INNER JOIN property_co_owners ON vancouver_owners.id = property_co_owners.owner_id INNER JOIN properties ON property_co_owners.property_id = properties.id GROUP BY vancouver_owners.name ORDER BY property_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intel (report_date DATE);
How many threat intelligence reports were created in the threat_intel table for each month in 2021?
SELECT EXTRACT(MONTH FROM report_date), COUNT(*) FROM threat_intel WHERE report_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY EXTRACT(MONTH FROM report_date);
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (institution_id INT, institution_name VARCHAR(50), loan_amount DECIMAL(10, 2)); INSERT INTO socially_responsible_lending (institution_id, institution_name, loan_amount) VALUES (1, 'XYZ Foundation', 3000.00), (2, 'Green Lending Group', 4000.00), (3, 'Community Development Fund',...
Find the top 3 socially responsible lending institutions with the highest average loan amounts, and display their names and average loan amounts.
SELECT institution_name, AVG(loan_amount) AS avg_loan_amount FROM socially_responsible_lending GROUP BY institution_name ORDER BY avg_loan_amount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists industry (industry_id INT, industry_name TEXT, total_workers INT); INSERT INTO industry (industry_id, industry_name, total_workers) VALUES (1, 'manufacturing', 5000), (2, 'technology', 7000), (3, 'healthcare', 6000), (4, 'finance', 4000), (5, 'retail', 3000);
What is the industry with the most workers?
SELECT industry_name, MAX(total_workers) FROM industry;
gretelai_synthetic_text_to_sql
CREATE TABLE WellExplorationCosts (well_id INT, drill_year INT, exploration_cost REAL); INSERT INTO WellExplorationCosts (well_id, drill_year, exploration_cost) VALUES (1, 2008, 2000000), (2, 2012, 3000000), (3, 2015, 1500000);
What is the total exploration cost in the 'ArabianSea' for wells drilled after 2010?
SELECT SUM(exploration_cost) FROM WellExplorationCosts WHERE region = 'ArabianSea' AND drill_year > 2010
gretelai_synthetic_text_to_sql
CREATE TABLE soil_samples (id INT, sample_location VARCHAR(50), nitrogen FLOAT, phosphorus FLOAT, potassium FLOAT, pH FLOAT, timestamp TIMESTAMP); INSERT INTO soil_samples (id, sample_location, nitrogen, phosphorus, potassium, pH, timestamp) VALUES (1, 'Field 1', 0.3, 0.2, 0.5, 6.5, '2022-01-01 10:00:00');
What is the maximum nitrogen level and corresponding sample location for soil samples with a pH less than 6.5?
SELECT sample_location, MAX(nitrogen) FROM soil_samples WHERE pH < 6.5 GROUP BY sample_location HAVING MAX(nitrogen);
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor VARCHAR(255), project_type VARCHAR(255), amount INT, date DATE); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (9, 'ImpactFirst', 'renewable_energy', 350000, '2021-10-07'); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (1...
What's the total investment in 'renewable_energy' projects by 'ImpactFirst' before 2022?
SELECT SUM(amount) FROM investments WHERE investor = 'ImpactFirst' AND project_type = 'renewable_energy' AND date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, employment_status VARCHAR(50)); INSERT INTO employees (id, name, department, salary, employment_status) VALUES (1, 'John Doe', 'IT', 75000.0, 'Full-time'), (2, 'Jane Smith', 'IT', 80000.0, 'Part-time'), (3, 'Alice Johnson', 'IT', 90...
What is the average salary of developers in the IT department, grouped by their employment status?
SELECT employment_status, AVG(salary) FROM employees INNER JOIN positions ON employees.department = positions.department AND employees.name = positions.name WHERE positions.name = 'Developer' GROUP BY employment_status;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_incidents (id INT, country VARCHAR(255), incidents INT); INSERT INTO pollution_incidents (id, country, incidents) VALUES (1, 'USA', 50), (2, 'China', 80), (3, 'Japan', 30), (4, 'India', 60), (5, 'Indonesia', 70);
Which countries have the most pollution incidents in the ocean?
SELECT country, SUM(incidents) as total_incidents FROM pollution_incidents GROUP BY country ORDER BY total_incidents DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (Id INT, DonorName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); INSERT INTO Donations (Id, DonorName, DonationAmount, DonationDate) VALUES (1, 'John Doe', 50.00, '2021-01-01'), (2, 'Jane Smith', 100.00, '2021-01-02'), (3, 'John Doe', 200.00, '2021-01-03');
Calculate total donations by donor
SELECT DonorName, SUM(DonationAmount) OVER(PARTITION BY DonorName) AS TotalDonations FROM Donations;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(100), SustainabilityScore INT, TotalSales DECIMAL(10,2)); INSERT INTO Brands (BrandID, BrandName, SustainabilityScore, TotalSales) VALUES (1, 'Brand X', 85, 50000), (2, 'Brand Y', 92, 65000), (3, 'Brand Z', 78, 42000);
List the top 3 sustainable brands by sales in the US.
SELECT BrandName, SustainabilityScore, TotalSales FROM (SELECT BrandName, SustainabilityScore, TotalSales, ROW_NUMBER() OVER (ORDER BY TotalSales DESC) as rn FROM Brands WHERE Country = 'US') t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites_stone_tools (site_id INT, artifact_count INT); INSERT INTO excavation_sites_stone_tools (site_id, artifact_count) VALUES (1, 35), (2, 28), (3, 40);
Which excavation sites have the highest number of artifacts from the 'Stone Tools' category?
SELECT site_id FROM excavation_sites_stone_tools WHERE artifact_count = (SELECT MAX(artifact_count) FROM excavation_sites_stone_tools);
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (employment_id INT, employment_date DATE, company TEXT, job_category TEXT, is_veteran BOOLEAN); INSERT INTO veteran_employment (employment_id, employment_date, company, job_category, is_veteran) VALUES (1, '2022-04-01', 'ACME Inc', 'Engineering', true), (2, '2022-05-15', 'Beta Corp', 'Ma...
What is the percentage of veteran employment in the defense industry, by job category, for each quarter in the past year?
SELECT DATE_FORMAT(employment_date, '%Y-%m') as quarter, job_category, ROUND(100.0 * SUM(CASE WHEN is_veteran THEN 1 ELSE 0 END) / COUNT(*), 2) as pct_veteran_employment FROM veteran_employment WHERE employment_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY quarter, job_category;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, strain VARCHAR(50), state VARCHAR(50), year INT, yield FLOAT); INSERT INTO production (id, strain, state, year, yield) VALUES (1, 'OG Kush', 'Washington', 2021, 3.5), (2, 'Girl Scout Cookies', 'Washington', 2021, 4.2), (3, 'Sour Diesel', 'California', 2021, 3.0);
What was the minimum production yield (in pounds) for the strain 'Girl Scout Cookies' in the state of Washington in 2021?
SELECT MIN(yield) FROM production WHERE strain = 'Girl Scout Cookies' AND state = 'Washington' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT); INSERT INTO routes (route_id, route_name) VALUES (101, 'Bus Route 101'), (201, 'Train Route 201'), (203, 'Train Route 203'); CREATE TABLE fare_collection (collection_id INT, passenger_type TEXT, route_id INT, fare DECIMAL); INSERT INTO fare_collection (collection_id,...
What is the total fare collected from passengers with disabilities for train route 203?
SELECT SUM(fare) FROM fare_collection JOIN routes ON fare_collection.route_id = routes.route_id WHERE passenger_type = 'Wheelchair' AND routes.route_name = 'Train Route 203';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE menu_categories (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO menu_categories (id, name) VALUES (1, 'Appetizers'), (2, 'Entrees'), (3, 'Desserts'); INSERT INTO menu_items (id, name, category) VALUES (1, 'Bruschet...
List all the menu items and their categories
SELECT menu_items.name, menu_categories.name AS category FROM menu_items JOIN menu_categories ON menu_items.category = menu_categories.id;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, sale_date DATE, region VARCHAR(20), equipment_type VARCHAR(30), revenue DECIMAL(10,2));
What is the 3-month moving average of military equipment sales by region?
SELECT region, AVG(revenue) OVER (PARTITION BY region ORDER BY sale_date ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) as moving_avg FROM military_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_outcomes (attorney_id INT, total_cases INT, successful_cases INT); INSERT INTO attorney_outcomes (attorney_id, total_cases, successful_cases) VALUES (1, 15, 12), (2, 10, 8), (3, 8, 6);
What is the total number of cases handled by attorneys with a success rate greater than 75%?
SELECT SUM(total_cases) FROM attorney_outcomes WHERE successful_cases / total_cases > 0.75;
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentFacilities (FacilityID INT, FacilityName VARCHAR(255), Address VARCHAR(255), City VARCHAR(255), State VARCHAR(255), ZipCode VARCHAR(10)); INSERT INTO WastewaterTreatmentFacilities (FacilityID, FacilityName, Address, City, State, ZipCode) VALUES (1, 'Blue Ridge Wastewater Treatment Plant'...
Which water conservation initiatives were implemented in California during 2022?
SELECT InitiativeName FROM WaterConservationInitiatives WHERE FacilityID = 3 AND StartDate <= '2022-12-31' AND EndDate >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (id INT, name TEXT, country TEXT, city TEXT, reviews INT); INSERT INTO Hotels (id, name, country, city, reviews) VALUES (1, 'Eco Hotel', 'France', 'Paris', -75);
Identify hotels with a high number of negative reviews in Paris.
SELECT name FROM Hotels WHERE city = 'Paris' AND reviews < 0 GROUP BY name HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturing_Tools (id INT PRIMARY KEY, tool_name VARCHAR(100), quantity INT, vendor VARCHAR(100)); INSERT INTO Manufacturing_Tools (id, tool_name, quantity, vendor) VALUES (1, 'Drill', 5, 'Stanley'); INSERT INTO Manufacturing_Tools (id, tool_name, quantity, vendor) VALUES (2, 'Wrench', 3, 'Snap-on'); INS...
Which tools are provided by Stanley or Bosch?
SELECT * FROM Manufacturing_Tools WHERE vendor IN ('Stanley', 'Bosch');
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseDiplomacy (id INT PRIMARY KEY, event VARCHAR(100), country VARCHAR(50), year INT, participants INT); INSERT INTO DefenseDiplomacy (id, event, country, year, participants) VALUES (4, 'Military Training Exchange', 'Colombia', 2020, 15);
How many defense diplomacy events occurred in South America in 2020?
SELECT COUNT(*) FROM DefenseDiplomacy WHERE country LIKE '%South America%' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id VARCHAR(10), well_location VARCHAR(20)); CREATE TABLE production (well_id VARCHAR(10), production_count INT);
Insert a new record for well 'H08' in 'Siberia' with a production count of 12000.
INSERT INTO wells (well_id, well_location) VALUES ('H08', 'Siberia'); INSERT INTO production (well_id, production_count) VALUES ('H08', 12000);
gretelai_synthetic_text_to_sql
CREATE TABLE package_types (id INT, name VARCHAR(255), max_weight FLOAT); INSERT INTO package_types (id, name, max_weight) VALUES (1, 'Envelope', 1.0), (2, 'Small Box', 50.0), (3, 'Medium Box', 100.0), (4, 'Large Box', 200.0), (5, 'Pallet', 500.0);
List the top 5 heaviest packages shipped in May 2022
SELECT packages.id, packages.weight, package_types.name FROM packages JOIN package_types ON packages.id = package_types.id WHERE packages.weight IN (SELECT weight FROM (SELECT packages.weight FROM packages JOIN warehouse_routes ON packages.id = warehouse_routes.package_id JOIN warehouses ON warehouse_routes.warehouse_i...
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor VARCHAR(255), project_type VARCHAR(255), amount INT, date DATE); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (15, 'SustainableFund', 'waste_management', 700000, '2021-08-25'); INSERT INTO investments (id, investor, project_type, amount, date) VALU...
What's the total investment in 'waste_management' projects by 'SustainableFund' in 2021?
SELECT SUM(amount) FROM investments WHERE investor = 'SustainableFund' AND project_type = 'waste_management' AND date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE cases_by_judge (case_id INT, judge_id INT, open_date DATE); INSERT INTO cases_by_judge (case_id, judge_id, open_date) VALUES (1, 1, '2022-01-05'), (2, 2, '2022-03-10'), (3, 1, '2022-04-01');
What is the number of cases handled by each judge, in the last quarter?
SELECT cases_by_judge.judge_id, COUNT(*) as num_cases FROM cases_by_judge WHERE open_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY cases_by_judge.judge_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (Id INT, Name VARCHAR(50), LaunchYear INT, Country VARCHAR(50)); INSERT INTO Satellites (Id, Name, LaunchYear, Country) VALUES (1, 'Sat1', 2018, 'USA'), (2, 'Sat2', 2019, 'USA'), (3, 'Sat3', 2020, 'USA'), (4, 'Sat4', 2020, 'China'), (5, 'Sat5', 2020, 'Russia'), (6, 'Sat6', 2018, 'Germany'), (7, ...
What are the names of all satellites launched by China?
SELECT Name FROM Satellites WHERE Country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerKills (PlayerID INT, GameMode VARCHAR(255), Kills INT, Country VARCHAR(255)); INSERT INTO PlayerKills (PlayerID, GameMode, Kills, Country) VALUES (1, 'Capture the Flag', 15, 'United States'), (2, 'Deathmatch', 28, 'Canada');
What is the average number of kills per game for players from the United States and Canada, partitioned by game mode?
SELECT GameMode, AVG(Kills) as AvgKills FROM PlayerKills WHERE Country IN ('United States', 'Canada') GROUP BY GameMode, Country WITH ROLLUP;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_data (country VARCHAR(50), capacity FLOAT); INSERT INTO landfill_data (country, capacity) VALUES ('India', 1200000), ('China', 2500000), ('Indonesia', 800000);
What is the average landfill capacity (in cubic meters) for countries in the Asia-Pacific region?
SELECT AVG(capacity) FROM landfill_data WHERE country IN ('India', 'China', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, username VARCHAR(20), email VARCHAR(50), country VARCHAR(20)); CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_time TIMESTAMP); CREATE TABLE comments (comment_id INT, post_id INT, user_id INT, comment TEXT, comment_time TIMESTAMP); CREATE TABLE reactions (reaction_id IN...
What is the average number of posts, comments, and reactions for users from the USA and India in the social_media database?
SELECT AVG(posts), AVG(comments), AVG(reactions) FROM (SELECT u.country, COUNT(p.post_id) AS posts, COUNT(c.comment_id) AS comments, COUNT(r.reaction_id) AS reactions FROM users u LEFT JOIN posts p ON u.user_id = p.user_id LEFT JOIN comments c ON p.post_id = c.post_id LEFT JOIN reactions r ON p.post_id = r.post_id WHER...
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT, policy_id INT); INSERT INTO claims (claim_id, policy_id) VALUES (1, 1001), (2, 1002), (3, 1003), (4, 1002), (5, 1004), (6, 1004);
What is the count of claims for policy number 1004?
SELECT COUNT(*) FROM claims WHERE policy_id = 1004;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_contracts (contract_id INT, equipment_id INT, manufacturer VARCHAR(50), contract_value FLOAT, contract_date DATE); INSERT INTO military_equipment_contracts VALUES (1, 1, 'Rheinmetall AG', 10000000, '2021-05-15');
Identify military equipment manufacturers in Africa with the highest contract values since 2020.
SELECT manufacturer, MAX(contract_value) FROM military_equipment_contracts WHERE contract_date >= '2020-01-01' AND country IN (SELECT country FROM countries WHERE region = 'Africa') GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, Europium_monthly_production FLOAT, timestamp TIMESTAMP); INSERT INTO mine (id, name, location, Europium_monthly_production, timestamp) VALUES (1, 'Australian Mine', 'Australia', 120.5, '2021-03-01'), (2, 'Californian Mine', 'USA', 150.3, '2021-03-01'), (3, 'Brazilian...
What is the maximum monthly production of Europium from all mines in 2021?
SELECT MAX(Europium_monthly_production) FROM mine WHERE EXTRACT(YEAR FROM timestamp) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Student_Accommodations (student_id INT, accommodation_type TEXT, cost DECIMAL(5,2), academic_year INT); CREATE VIEW Physical_Disability_Accommodations AS SELECT * FROM Student_Accommodations WHERE accommodation_type LIKE '%physical disability%'; CREATE VIEW Total_Physical_Disability_Accommodations_Cost AS ...
What is the total cost of accommodations provided to students with physical disabilities in the current academic year?
SELECT Total_Physical_Disability_Accommodations_Cost.SUM(cost) FROM Physical_Disability_Accommodations INNER JOIN Total_Physical_Disability_Accommodations_Cost ON Physical_Disability_Accommodations.accommodation_type = Total_Physical_Disability_Accommodations_Cost.accommodation_type WHERE Physical_Disability_Accommodat...
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturer (id INT, name VARCHAR(255), country VARCHAR(255), year_founded INT); INSERT INTO Manufacturer (id, name, country, year_founded) VALUES (1, 'Boeing', 'USA', 1916); INSERT INTO Manufacturer (id, name, country, year_founded) VALUES (2, 'Airbus', 'Europe', 1970); INSERT INTO Manufacturer (id, name...
What is the average year of foundation for manufacturers based in the United States?
SELECT AVG(year_founded) FROM Manufacturer WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE DamLevee (id INT, type VARCHAR(10), region VARCHAR(20), cost FLOAT); INSERT INTO DamLevee (id, type, region, cost) VALUES (1, 'Dam', 'West', 15000000.0), (2, 'Levee', 'West', 8000000.0), (3, 'Dam', 'West', 12000000.0);
What is the total number of dams and levees in the West and their respective average construction costs?
SELECT type, COUNT(*), AVG(cost) as avg_cost FROM DamLevee WHERE region = 'West' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE product_education (product_id INT, educational_material VARCHAR(500));
Create a table named 'product_education'
CREATE TABLE product_education (product_id INT, educational_material VARCHAR(500));
gretelai_synthetic_text_to_sql
CREATE TABLE Users (id INT, age INT, gender VARCHAR(10), country VARCHAR(50)); INSERT INTO Users (id, age, gender, country) VALUES (1, 25, 'Male', 'USA'); INSERT INTO Users (id, age, gender, country) VALUES (2, 35, 'Female', 'Canada'); INSERT INTO Users (id, age, gender, country) VALUES (3, 42, 'Male', 'Nigeria');
How many users are there from Africa who are older than 30?
SELECT COUNT(*) FROM Users WHERE country LIKE '%%Africa' AND age > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(50), category VARCHAR(50), cost FLOAT, start_date DATE, end_date DATE, status VARCHAR(20)); INSERT INTO Projects (id, name, category, cost, start_date, end_date, status) VALUES (1, 'Dam Reconstruction', 'Water Supply', 500000, '2017-04-01', '2019-04-01', 'Completed'), (2, 'Wa...
What was the minimum cost of 'Transportation' projects in 2020, excluding projects with a duration of more than 1 year?
SELECT MIN(cost) FROM Projects WHERE category = 'Transportation' AND YEAR(start_date) = 2020 AND DATEDIFF(end_date, start_date) <= 365;
gretelai_synthetic_text_to_sql
CREATE TABLE HumanitarianAssistance (id INT, year INT, country VARCHAR(255), assistance VARCHAR(255));
What is the total number of humanitarian assistance provided by the African Union in 2021, partitioned by country?
SELECT country, SUM(1) as total_assistance FROM HumanitarianAssistance WHERE year = 2021 AND country IN ('African Union member countries') GROUP BY country;
gretelai_synthetic_text_to_sql