context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE destination (destination_code CHAR(5), destination_name VARCHAR(50)); INSERT INTO destination VALUES ('PARIS', 'Paris'), ('LOND', 'London'); CREATE TABLE visitor_stats (destination_code CHAR(5), arrival_age INT); INSERT INTO visitor_stats VALUES ('PARIS', 35), ('PARIS', 37), ('LOND', 40), ('LOND', 42);
What is the average arrival age for each destination?
SELECT destination_code, AVG(arrival_age) OVER (PARTITION BY destination_code) FROM visitor_stats;
gretelai_synthetic_text_to_sql
CREATE TABLE org_donations (donation_id INT, amount DECIMAL(10,2)); INSERT INTO org_donations (donation_id, amount) VALUES (1, 5000.00), (2, 3000.00), (3, 7000.00);
What is the total amount of donations received by the organization?
SELECT SUM(amount) FROM org_donations;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city TEXT, date DATE, waste_kg INT); INSERT INTO waste_generation (city, date, waste_kg) VALUES ('Nairobi', '2022-03-01', 600), ('Nairobi', '2022-03-02', 650), ('Nairobi', '2022-03-03', 700);
What is the total waste generation in metric tons for the month of March 2022 in the city of Nairobi?
SELECT SUM(waste_kg / 1000) FROM waste_generation WHERE city = 'Nairobi' AND date BETWEEN '2022-03-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL, donor_country TEXT);
List the top 3 countries with the highest average donation per donor
SELECT donor_country, AVG(donation_amount) AS avg_donation FROM donations GROUP BY donor_country ORDER BY avg_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE football_athletes (athlete_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50));
What is the average age of athletes who participated in the World Cup from the 'football_athletes' table?
SELECT AVG(age) FROM football_athletes WHERE participated_in_world_cup = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE job_applications (id INT, applicant_name VARCHAR(50), department VARCHAR(50), application_source VARCHAR(50), application_date DATE, applicant_region VARCHAR(50)); INSERT INTO job_applications (id, applicant_name, department, application_source, application_date, applicant_region) VALUES (1, 'Jane Doe', 'IT', 'LinkedIn', '2022-02-12', 'Northeast'); INSERT INTO job_applications (id, applicant_name, department, application_source, application_date, applicant_region) VALUES (2, 'Bob Smith', 'HR', 'Indeed', '2022-05-04', 'Midwest');
What is the total number of job applicants per source, by employee's region, for the year 2022?
SELECT applicant_region, application_source, COUNT(*) as total_applicants FROM job_applications WHERE YEAR(application_date) = 2022 GROUP BY applicant_region, application_source;
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, ClientName VARCHAR(100), Region VARCHAR(50)); INSERT INTO Clients (ClientID, ClientName, Region) VALUES (1, 'JK Lender', 'Europe'), (2, 'Islamic Trust', 'Europe'); CREATE TABLE Loans (LoanID INT, ClientID INT, InterestRate DECIMAL(10,2), LastLoanDate DATE); INSERT INTO Loans (LoanID, ClientID, InterestRate, LastLoanDate) VALUES (1, 1, 0.05, '2021-01-01'), (2, 2, 0.07, '2021-06-15');
Update the interest rate of loans for clients in the European region who have taken loans more than 3 months ago.
UPDATE Loans SET InterestRate = 0.06 WHERE LastLoanDate < DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND ClientID IN (SELECT ClientID FROM Clients WHERE Region = 'Europe');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT, TotalDonation DECIMAL); INSERT INTO Donors VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00), (3, 'Mike Johnson', 600.00), (4, 'Sara Jones', 200.00);
List the names and total donations for the top 3 donors.
SELECT Name, TotalDonation FROM (SELECT Name, TotalDonation, RANK() OVER (ORDER BY TotalDonation DESC) as Rank FROM Donors) d WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_banks (bank_id INT, bank_name VARCHAR(50), merged_or_acquired BOOLEAN);
Find all Shariah-compliant banks that have merged or been acquired
SELECT bank_name FROM shariah_compliant_banks WHERE merged_or_acquired = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, community_name TEXT, community_size INT, region TEXT, funding FLOAT);
What is the total amount of funding received by 'community_development' table where the 'community_name' is 'peace_village'?
SELECT SUM(funding) FROM community_development WHERE community_name = 'peace_village';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities ( id INT PRIMARY KEY, name VARCHAR(255), population INT, region VARCHAR(255), language VARCHAR(255)); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (1, 'Community A', 500, 'Arctic', 'Language A'); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (2, 'Community B', 700, 'Arctic', 'Language B');
What is the minimum population for indigenous communities in the Arctic?
SELECT MIN(population) FROM indigenous_communities WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_launches (id INT, launch_year INT, launch_country VARCHAR(50), satellite_name VARCHAR(50));
How many satellites were launched in the 2010s?
SELECT COUNT(*) FROM satellite_launches WHERE launch_year BETWEEN 2010 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_revenue (id INT, category VARCHAR(50), subcategory VARCHAR(50), is_sustainable BOOLEAN, revenue DECIMAL(5,2)); INSERT INTO sales_revenue (id, category, subcategory, is_sustainable, revenue) VALUES (1, 'Accessories', 'Hats', FALSE, 120.00), (2, 'Accessories', 'Scarves', TRUE, 210.00), (3, 'Accessories', 'Belts', FALSE, 150.00), (4, 'Accessories', 'Jewelry', TRUE, 320.00), (5, 'Accessories', 'Sunglasses', FALSE, 260.00);
Sum the sales revenue of sustainable accessories
SELECT SUM(revenue) FROM sales_revenue WHERE is_sustainable = TRUE AND category = 'Accessories';
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(100), last_medical_checkup DATE); INSERT INTO astronauts (astronaut_id, name, last_medical_checkup) VALUES (1, 'Mark Watney', '2022-03-15'), (2, 'Melissa Lewis', '2022-04-10'), (3, 'Rick Martinez', '2021-05-22');
Which astronauts have not had a medical check-up in the last 12 months?
SELECT a.name FROM astronauts a LEFT JOIN (SELECT astronaut_id FROM astronauts WHERE last_medical_checkup >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH)) am ON a.astronaut_id = am.astronaut_id WHERE am.astronaut_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, country VARCHAR(2), Erbium_sold FLOAT, revenue FLOAT, datetime DATETIME); INSERT INTO suppliers (id, country, Erbium_sold, revenue, datetime) VALUES (1, 'CA', 150.0, 2500.0, '2021-01-01 10:00:00'), (2, 'CA', 200.0, 3000.0, '2021-01-15 14:30:00');
List the number of Erbium transactions and total revenue for suppliers from Canada, grouped by month in 2021.
SELECT DATE_FORMAT(datetime, '%Y-%m') AS month, COUNT(DISTINCT id) AS num_transactions, SUM(revenue) AS total_revenue FROM suppliers WHERE country = 'CA' AND YEAR(datetime) = 2021 AND Erbium_sold IS NOT NULL GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft(id INT, name VARCHAR(50), manufacturer VARCHAR(50), destination VARCHAR(50), mass FLOAT); INSERT INTO spacecraft VALUES(1, 'Perseverance Rover', 'Stellar Systems', 'Mars', 1050.), (2, 'Spirit Rover', 'Stellar Systems', 'Mars', 174.);
What is the percentage of spacecraft manufactured by 'Stellar Systems' that are for Mars missions?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM spacecraft WHERE manufacturer = 'Stellar Systems') FROM spacecraft WHERE manufacturer = 'Stellar Systems' AND destination = 'Mars';
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Buildings (project_name TEXT, completion_date DATE); INSERT INTO Sustainable_Buildings (project_name, completion_date) VALUES ('Solar Panel Installation', '2022-06-01'), ('Green Roof Construction', '2021-12-15'), ('Sustainable Building Design', '2020-11-30');
Which sustainable building projects were completed before January 1, 2021?
SELECT project_name, completion_date FROM Sustainable_Buildings WHERE completion_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (sales_id INT, drug_name VARCHAR(255), quantity_sold INT, sales_date DATE, region VARCHAR(255));
Delete all sales records with a quantity of 200 from the 'sales_data' table.
DELETE FROM sales_data WHERE quantity_sold = 200;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 70000.00), (2, 'Marketing', 55000.00), (3, 'Marketing', 58000.00), (4, 'HR', 60000.00), (5, 'HR', 62000.00);
What is the average salary for employees in each department?
SELECT Department, AVG(Salary) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_rooms (room_id INT, room_type VARCHAR(20), price DECIMAL(5,2), is_eco_friendly BOOLEAN); INSERT INTO hotel_rooms (room_id, room_type, price, is_eco_friendly) VALUES (1, 'Standard', 100, FALSE), (2, 'Deluxe', 150, FALSE), (3, 'Eco-friendly Standard', 120, TRUE), (4, 'Eco-friendly Deluxe', 180, TRUE);
What is the total revenue for eco-friendly hotel rooms?
SELECT SUM(price) FROM hotel_rooms WHERE is_eco_friendly = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policy_trends (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE);
How many clean energy policy trends were implemented in India in the last 3 years?
SELECT COUNT(*) FROM clean_energy_policy_trends WHERE location LIKE '%India%' AND start_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name VARCHAR(255), state VARCHAR(255)); CREATE TABLE safety_violations (id INT, union_id INT, violation_count INT); INSERT INTO unions (id, name, state) VALUES (1, 'SEIU', 'New York'); INSERT INTO safety_violations (id, union_id, violation_count) VALUES (1, 1, 50);
How many workplace safety violations were recorded for each union in New York?
SELECT u.name, SUM(sv.violation_count) as total_violations FROM unions u JOIN safety_violations sv ON u.id = sv.union_id WHERE u.state = 'New York' GROUP BY u.name;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name TEXT, approval_year INT, R_D_expenses FLOAT); INSERT INTO drugs (drug_id, drug_name, approval_year, R_D_expenses) VALUES (1001, 'DrugA', 2017, 1200000), (1002, 'DrugB', 2018, 1500000), (1003, 'DrugC', 2017, 1300000), (1004, 'DrugD', 2018, 1100000); CREATE TABLE sales (sale_id INT, drug_id INT, sale_date DATE, revenue FLOAT); INSERT INTO sales (sale_id, drug_id, sale_date, revenue) VALUES (1, 1001, '2017-02-15', 15000), (2, 1001, '2018-03-18', 22000), (3, 1002, '2018-01-25', 18000), (4, 1002, '2018-02-14', 19000), (5, 1003, '2017-06-05', 25000);
What is the total sales revenue for drugs with approval in H1 2017 and H1 2018?
SELECT d.drug_name, SUM(s.revenue) as total_revenue FROM drugs d JOIN sales s ON d.drug_id = s.drug_id WHERE EXTRACT(MONTH FROM s.sale_date) BETWEEN 1 AND 6 AND d.approval_year IN (2017, 2018) GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, category VARCHAR(10), price DECIMAL(5,2), attendance INT); INSERT INTO events (id, category, price, attendance) VALUES (1, 'music', 20.00, 600), (2, 'dance', 15.00, 400), (3, 'music', 25.00, 800);
What is the average ticket price for events in the 'music' category with attendance greater than 500?
SELECT AVG(price) FROM events WHERE category = 'music' AND attendance > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE user_visits (id INT, user_id INT, visit_date DATE, country VARCHAR(255)); INSERT INTO user_visits (id, user_id, visit_date, country) VALUES
What are the top 3 countries with the most user visits in the past month?
SELECT country, COUNT(DISTINCT user_id) as num_visits FROM user_visits WHERE visit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country ORDER BY num_visits DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE location_revenue (location VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO location_revenue (location, revenue) VALUES ('Chicago', 9000.00), ('Houston', 8000.00), ('Philadelphia', 7000.00), ('Phoenix', 6000.00), ('San Antonio', 5000.00);
What was the total revenue for each restaurant location in the last 30 days?
SELECT location, SUM(revenue) as total_revenue FROM location_revenue WHERE location_revenue.location IN (SELECT location FROM restaurant_revenue WHERE date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)) GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Debris (Debris_ID INT, Diameter FLOAT, Mass FLOAT); INSERT INTO Space_Debris (Debris_ID, Diameter, Mass) VALUES (1, 5.0, 100.0), (2, 1.2, 5.0);
What is the total mass of space debris larger than 1 cm in size?
SELECT SUM(Mass) FROM Space_Debris WHERE Diameter > 1.0;
gretelai_synthetic_text_to_sql
CREATE TABLE Company_Launches (company VARCHAR(50), satellite_count INT, successful_missions INT); INSERT INTO Company_Launches (company, satellite_count, successful_missions) VALUES ('SpaceX', 200, 180), ('India', 150, 140), ('United Kingdom', 100, 90);
Which companies have launched the most satellites and have more than 7 successful space missions?
SELECT company FROM Company_Launches WHERE satellite_count > 75 AND successful_missions > 7 GROUP BY company ORDER BY satellite_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, species VARCHAR(255), population INT); INSERT INTO animal_population (id, species, population) VALUES (1, 'Tiger', 500), (2, 'Elephant', 2000), (3, 'Lion', 800), (4, 'Giraffe', 1500);
What is the total population of animals in the 'animal_population' table, grouped by their species and sorted by the total count in ascending order?
SELECT species, SUM(population) as total FROM animal_population GROUP BY species ORDER BY total ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, name VARCHAR(255), city VARCHAR(255), date DATE);
How many events were held in each city last year?
SELECT city, COUNT(*) FROM Events WHERE date >= '2021-01-01' AND date < '2022-01-01' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (Program varchar(50), Allocation numeric(10,2)); INSERT INTO Budget (Program, Allocation) VALUES ('ProgramA', 5000.00), ('ProgramB', 3000.00);
What is the total budget allocated to ProgramB, and what percentage of the total budget does it represent?
SELECT Program, Allocation, (Allocation / SUM(Allocation) OVER ()) * 100 AS BudgetPercentage FROM Budget WHERE Program = 'ProgramB';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR, size INT, co_ownership BOOLEAN, num_bedrooms INT);
What is the sum of square footage of co-ownership properties in Berlin with more than 2 bedrooms?
SELECT SUM(size) FROM properties WHERE city = 'Berlin' AND co_ownership = TRUE AND num_bedrooms > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), owner_group VARCHAR(255));CREATE TABLE Inventory (id INT, dispensary_id INT, weight DECIMAL(10, 2), product_type VARCHAR(255), month INT, year INT);INSERT INTO Dispensaries (id, name, city, state, owner_group) VALUES (1, 'NuWay', 'Los Angeles', 'CA', 'Historically Underrepresented');INSERT INTO Inventory (id, dispensary_id, weight, product_type, month, year) VALUES (1, 1, 75, 'concentrate', 1, 2022);
What was the total weight of cannabis concentrate sold by dispensaries owned by historically underrepresented communities in the state of California in the month of January 2022?
SELECT d.name, SUM(i.weight) as total_weight FROM Dispensaries d JOIN Inventory i ON d.id = i.dispensary_id WHERE d.state = 'CA' AND d.owner_group = 'Historically Underrepresented' AND i.product_type = 'concentrate' AND i.month = 1 AND i.year = 2022 GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (name TEXT, country TEXT, capacity FLOAT); INSERT INTO wind_farms (name, country, capacity) VALUES ('Windpark Nordsee', 'Germany', 330.0), ('BARD Offshore 1', 'Germany', 400.0);
What is the average capacity (MW) of wind farms in Germany?
SELECT AVG(capacity) FROM wind_farms WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE SmartContracts (contract_address VARCHAR(40), contract_creator VARCHAR(40), gas_used INT, num_transactions INT); INSERT INTO SmartContracts (contract_address, contract_creator, gas_used, num_transactions) VALUES ('0x123', 'Alice', 60000, 10), ('0x456', 'Bob', 45000, 15), ('0x789', 'Alice', 55000, 12);
Identify smart contracts with an average gas usage above 75000 in the 'SmartContracts' table, partitioned by contract creator and ordered by the lowest average gas usage in ascending order.
SELECT contract_creator, contract_address, AVG(gas_used) as avg_gas_usage, RANK() OVER (PARTITION BY contract_creator ORDER BY AVG(gas_used)) as rank FROM SmartContracts GROUP BY contract_creator, contract_address HAVING avg_gas_usage > 75000 ORDER BY contract_creator, rank;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_reserve (id INT, name TEXT, area_ha FLOAT, region TEXT);
What is the minimum area of wildlife habitat reserves in hectares for reserves in the subarctic region?
SELECT MIN(area_ha) FROM wildlife_reserve WHERE region = 'subarctic';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (country VARCHAR(50), investment FLOAT, year INT); INSERT INTO climate_adaptation (country, investment, year) VALUES ('India', 1000000, 2010), ('China', 2000000, 2011), ('Brazil', 1500000, 2012);
Find the total investment in climate adaptation for the top 3 countries with the highest investment since 2010, ordered by investment amount?
SELECT SUM(investment) as total_investment, country FROM climate_adaptation WHERE year >= 2010 GROUP BY country ORDER BY total_investment DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Age INT, Gender VARCHAR(10), Name VARCHAR(50), Nationality VARCHAR(50));
What is the distribution of astronauts' nationalities?
SELECT Nationality, COUNT(*) FROM Astronauts GROUP BY Nationality;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_artists (artist_id INT, name VARCHAR(50), age INT, country VARCHAR(50), art_type VARCHAR(50));
What is the average number of art pieces per artist in the 'traditional_artists' table?
SELECT AVG(art_count) FROM (SELECT artist_id, COUNT(*) OVER (PARTITION BY artist_id) AS art_count FROM traditional_artists) t;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, condition TEXT, state TEXT, treated_year INT); INSERT INTO patients (id, name, age, condition, state, treated_year) VALUES (1, 'John Doe', 35, 'Depression', 'CA', 2021), (2, 'Jane Smith', 40, 'Anxiety', 'NY', 2021);
What is the most common mental health condition among patients from California in 2021?
SELECT condition, COUNT(*) AS count FROM patients WHERE state = 'CA' AND treated_year = 2021 GROUP BY condition ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Company (id INT, name VARCHAR(50), industry VARCHAR(50), founding_year INT); INSERT INTO Company (id, name, industry, founding_year) VALUES (1, 'GovTech', 'Government', 2018); INSERT INTO Company (id, name, industry, founding_year) VALUES (2, 'HealthInnovate', 'Healthcare', 2017); CREATE TABLE Employees (id INT, company_id INT, first_name VARCHAR(50), last_name VARCHAR(50), gender VARCHAR(10), role VARCHAR(50), hire_date DATE); INSERT INTO Employees (id, company_id, first_name, last_name, gender, role, hire_date) VALUES (1, 1, 'Ahmed', 'Khan', 'Male', 'Software Engineer', '2019-01-01'); INSERT INTO Employees (id, company_id, first_name, last_name, gender, role, hire_date) VALUES (2, 1, 'Sofia', 'Gonzalez', 'Female', 'Data Scientist', '2019-02-15');
How many employees work in each company and their job roles?
SELECT company_id, role, COUNT(*) as employee_count FROM Employees GROUP BY company_id, role;
gretelai_synthetic_text_to_sql
CREATE TABLE ResilienceProjects (ProjectID int, Sector varchar(10), Budget int); INSERT INTO ResilienceProjects (ProjectID, Sector, Budget) VALUES (1, 'Water', 500000), (2, 'Transport', 800000), (3, 'Energy', 600000);
What is the minimum budget for a resilience project in the 'Energy' sector?
SELECT MIN(Budget) AS MinBudget FROM ResilienceProjects WHERE Sector = 'Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE fishing_vessels (id INT, name VARCHAR(255), sea VARCHAR(50), method VARCHAR(50)); INSERT INTO fishing_vessels (id, name, sea, method) VALUES (1, 'Sea Queen', 'Mediterranean', 'Non-sustainable'), (2, 'Poseidon', 'Aegean', 'Sustainable');
Find the total number of fishing vessels in the Mediterranean and Aegean seas that use non-sustainable fishing methods.
SELECT SUM(sea IN ('Mediterranean', 'Aegean')) FROM fishing_vessels WHERE method = 'Non-sustainable';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name VARCHAR(255)); INSERT INTO Countries (id, name) VALUES (1, 'Italy'), (2, 'France'), (3, 'Spain'), (4, 'Germany'), (5, 'UK'); CREATE TABLE Hotels (id INT, country_id INT, name VARCHAR(255), score INT); INSERT INTO Hotels (id, country_id, name, score) VALUES (1, 1, 'Hotel A', 85), (2, 1, 'Hotel B', 90), (3, 2, 'Hotel C', 80), (4, 2, 'Hotel D', 88), (5, 3, 'Hotel E', 92), (6, 3, 'Hotel F', 85), (7, 4, 'Hotel G', 82), (8, 4, 'Hotel H', 95), (9, 5, 'Hotel I', 87), (10, 5, 'Hotel J', 93);
What is the average cultural heritage preservation score for hotels in Italy in 2022?
SELECT AVG(h.score) as avg_score FROM Hotels h JOIN Countries c ON h.country_id = c.id WHERE c.name = 'Italy' AND h.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, name VARCHAR(100), country VARCHAR(50), type VARCHAR(50)); INSERT INTO renewable_projects (id, name, country, type) VALUES (1, 'Project 1', 'France', 'Wind Farm'), (2, 'Project 2', 'France', 'Solar Plant');
Find the total number of Renewable Energy Projects in France
SELECT COUNT(*) FROM renewable_projects WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales_5 (id INT, region VARCHAR, year INT, value FLOAT);
Increase the value of military equipment sales by 10% for 'Asia-Pacific' in 2020
UPDATE military_sales_5 SET value = value * 1.10 WHERE region = 'Asia-Pacific' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Songs (SongID INT, Artist VARCHAR(50), NumOfSongs INT); INSERT INTO Songs VALUES (1, 'Artist A', 120), (2, 'Artist B', 150), (3, 'Artist C', 170), (4, 'Artist D', 200), (5, 'Artist E', 250), (6, 'Artist F', 100), (7, 'Artist G', 180), (8, 'Artist H', 130);
Find the total number of songs per artist in descending order.
SELECT Artist, SUM(NumOfSongs) FROM Songs GROUP BY Artist ORDER BY SUM(NumOfSongs) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, company_id INT, region VARCHAR(255), investment_type VARCHAR(255)); INSERT INTO investments (id, company_id, region, investment_type) VALUES (1, 1, 'Europe', 'Clean Technology'), (2, 1, 'North America', 'Fossil Fuels'), (3, 2, 'Asia', 'Clean Technology');
Who are the top 5 regions with the highest number of investments in clean technology?
SELECT region, COUNT(*) AS investment_count FROM investments WHERE investment_type = 'Clean Technology' GROUP BY region ORDER BY investment_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE art_works (id INT, name VARCHAR(255), category VARCHAR(255), city VARCHAR(255), views INT); INSERT INTO art_works (id, name, category, city, views) VALUES (1, 'Painting 1', 'painting', 'New York', 1000); INSERT INTO art_works (id, name, category, city, views) VALUES (2, 'Sculpture 1', 'sculpture', 'Los Angeles', 800);
What is the most popular art category in 'New York'?
SELECT category, MAX(views) FROM art_works WHERE city = 'New York' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00), (3, 'Alice Johnson', 700.00);
What is the total donation amount by each donor in descending order?
SELECT DonorName, SUM(DonationAmount) OVER (PARTITION BY DonorName ORDER BY DonorName) AS TotalDonation FROM Donors ORDER BY TotalDonation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, PolicyStartDate DATE); INSERT INTO Policyholders (PolicyID, PolicyholderName, PolicyStartDate) VALUES (1, 'John Doe', '2022-01-01'), (2, 'Jane Smith', '2022-02-01'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimDate DATE); INSERT INTO Claims (ClaimID, PolicyID, ClaimDate) VALUES (1, 1, '2022-01-15'), (2, 1, '2022-02-10'), (3, 2, '2022-02-20');
List all policyholders who have filed a claim in the last 30 days, including their policy ID and policyholder name.
SELECT Policyholders.PolicyID, Policyholders.PolicyholderName FROM Policyholders INNER JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Claims.ClaimDate >= DATEADD(day, -30, GETDATE()) ORDER BY Policyholders.PolicyID;
gretelai_synthetic_text_to_sql
CREATE TABLE AdaptationProjects (ID INT, Country VARCHAR(255), Year INT, Projects INT); INSERT INTO AdaptationProjects (ID, Country, Year, Projects) VALUES (1, 'Indonesia', 2010, 3), (2, 'Philippines', 2010, 4), (3, 'Vietnam', 2010, 5), (4, 'Thailand', 2010, 6), (5, 'Malaysia', 2010, 7);
What is the total number of climate adaptation projects in Southeast Asian countries since 2010?
SELECT SUM(Projects) FROM AdaptationProjects WHERE Country IN ('Indonesia', 'Philippines', 'Vietnam', 'Thailand', 'Malaysia') AND Year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_programs (program_id INT, program_name VARCHAR(50), country VARCHAR(50));
Determine the number of financial capability programs in each country
SELECT country, COUNT(*) FROM financial_capability_programs GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE SkincareBrands (brand_id INT, brand TEXT, cruelty_free BOOLEAN); INSERT INTO SkincareBrands (brand_id, brand, cruelty_free) VALUES (1, 'Sukin', true); CREATE TABLE SkincareSales (sale_id INT, brand_id INT, sale_price DECIMAL(5,2), sale_date DATE, country TEXT); INSERT INTO SkincareSales (sale_id, brand_id, sale_price, sale_date, country) VALUES (1, 1, 29.99, '2021-06-17', 'Australia');
What is the total revenue for cruelty-free skincare brands in Australia in 2021?
SELECT SUM(sale_price) FROM SkincareBrands sb JOIN SkincareSales ss ON sb.brand_id = ss.brand_id WHERE sb.cruelty_free = true AND ss.country = 'Australia' AND ss.sale_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE forest_areas (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), area FLOAT);
Delete all records from the forest_areas table where the region is 'Pacific Northwest'
DELETE FROM forest_areas WHERE region = 'Pacific Northwest';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (vessel_id VARCHAR(10), name VARCHAR(20), type VARCHAR(20), max_speed FLOAT, cargo_capacity INT, country VARCHAR(20)); INSERT INTO Vessels (vessel_id, name, type, max_speed, cargo_capacity, country) VALUES ('1', 'Vessel A', 'Cargo', 20.5, 5000, 'Indonesia'), ('2', 'Vessel B', 'Tanker', 15.2, 0, 'Nigeria'), ('3', 'Vessel C', 'Tanker', 18.1, 0, 'Brazil'), ('4', 'Vessel D', 'Cargo', 12.6, 6000, 'Indonesia'), ('5', 'Vessel E', 'Cargo', 16.2, 4500, 'Canada');
What is the average cargo capacity of Indonesian vessels?
SELECT AVG(cargo_capacity) FROM Vessels WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable');
Update the conservation status of a marine species in the 'marine_species' table
UPDATE marine_species SET conservation_status = 'Endangered' WHERE species_name = 'Leatherback Sea Turtle';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), status VARCHAR(50)); CREATE TABLE cargo (cargo_id INT, vessel_id INT, cargo_type VARCHAR(50), weight INT);
What is the total cargo weight handled by each vessel?
SELECT V.vessel_name, SUM(weight) AS total_weight FROM cargo C JOIN vessels V ON C.vessel_id = V.vessel_id GROUP BY vessel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE country_investments (investment_id INT, country VARCHAR(10), investment_amount FLOAT);
Find the total number of network infrastructure investments in each country
SELECT country, SUM(investment_amount) FROM country_investments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyIncidents (IncidentId INT, Name TEXT, Type TEXT, Year INT, Country TEXT); INSERT INTO SafetyIncidents (IncidentId, Name, Type, Year, Country) VALUES (1, 'IncidentA', 'Algorithmic Bias', 2017, 'Brazil'), (2, 'IncidentB', 'Lack of Explainability', 2018, 'Argentina'), (3, 'IncidentC', 'Data Privacy', 2019, 'Colombia');
How many AI safety incidents were recorded in South America between 2018 and 2020?
SELECT COUNT(*) FROM SafetyIncidents WHERE Type = 'AI Safety' AND Year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Mediations (MediatorName TEXT, Outcome TEXT, Cases INT); INSERT INTO Mediations (MediatorName, Outcome, Cases) VALUES ('John', 'Success', 20), ('John', 'Failure', 5), ('Jane', 'Success', 30), ('Jane', 'Failure', 8), ('Mike', 'Success', 15), ('Mike', 'Failure', 3);
List the number of successful and unsuccessful mediation cases by mediator name
SELECT MediatorName, SUM(CASE WHEN Outcome = 'Success' THEN Cases ELSE 0 END) AS SuccessfulCases, SUM(CASE WHEN Outcome = 'Failure' THEN Cases ELSE 0 END) AS UnsuccessfulCases FROM Mediations GROUP BY MediatorName;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (agency VARCHAR(100), report_count INT);
List the number of threat intelligence reports issued by each intelligence agency
SELECT agency, SUM(report_count) FROM threat_intelligence GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id VARCHAR(20), name VARCHAR(20)); INSERT INTO vessels (id, name) VALUES ('VES007', 'VESSEL007'), ('VES008', 'VESSEL008'); CREATE TABLE cargo (vessel_id VARCHAR(20), weight INT); INSERT INTO cargo (vessel_id, weight) VALUES ('VES007', 12000), ('VES007', 15000), ('VES007', 14000), ('VES008', 16000), ('VES008', 17000), ('VES008', 18000);
What is the average cargo weight for VESSEL007?
SELECT AVG(weight) FROM cargo WHERE vessel_id = 'VES007';
gretelai_synthetic_text_to_sql
CREATE TABLE fraud (fraud_id INT, country VARCHAR(50), fraud_date DATE); INSERT INTO fraud (fraud_id, country, fraud_date) VALUES (1, 'US', '2022-01-10'), (2, 'UK', '2022-02-15'), (3, 'US', '2022-03-01');
How many fraud cases were reported in the US in H1 2022?
SELECT COUNT(*) as num_fraud_cases FROM fraud WHERE country = 'US' AND fraud_date BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Workers (id INT, factory_id INT, country VARCHAR(50), hourly_wage DECIMAL(4,2));CREATE TABLE Factories (id INT, name VARCHAR(50), certification VARCHAR(20)); INSERT INTO Workers (id, factory_id, country, hourly_wage) VALUES (1, 1001, 'Bangladesh', 2.50), (2, 1002, 'Cambodia', 2.25), (3, 1003, 'India', 2.75), (4, 1004, 'Vietnam', 2.10); INSERT INTO Factories (id, name, certification) VALUES (1001, 'Green Valley', 'green'), (1002, 'Eco Fields', 'not_certified'), (1003, 'Sustainable Peak', 'blue'), (1004, 'Fast Fashion Inc', 'not_certified');
What is the minimum hourly wage for workers in factories with 'green' certification?
SELECT MIN(hourly_wage) as min_wage FROM Workers JOIN Factories ON Workers.factory_id = Factories.id WHERE certification = 'green';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (labor_hour_id INT, project_id INT, task_type VARCHAR(50), labor_hours DECIMAL(10, 2)); INSERT INTO labor_hours (labor_hour_id, project_id, task_type, labor_hours) VALUES (1, 1, 'Framing', 500.00);
How many labor hours have been spent on each type of construction task across all projects?
SELECT lh.task_type, SUM(lh.labor_hours) as total_labor_hours FROM labor_hours lh GROUP BY lh.task_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (CompanyID INT, CompanyName VARCHAR(50), ExitStrategyType VARCHAR(30));
What is the count of companies in each exit strategy type?
SELECT C.ExitStrategyType, COUNT(C.CompanyID) AS CompanyCount FROM Companies C GROUP BY C.ExitStrategyType;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_compliance (id INT PRIMARY KEY, vessel_id INT, regulation_id INT, compliance_date DATE, is_compliant BOOLEAN);
Insert a new regulatory compliance record into the "regulatory_compliance" table
INSERT INTO regulatory_compliance (id, vessel_id, regulation_id, compliance_date, is_compliant) VALUES (1, 4, 101, '2021-12-31', true);
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists trains (train_id serial primary key,name varchar(255),line_id int);CREATE TABLE if not exists train_passengers (passenger_id serial primary key,train_id int,passengers int,time_of_day varchar(255));
What is the average number of passengers per train during rush hour on the Yellow Line?
SELECT AVG(passengers) FROM trains t JOIN train_passengers p ON t.train_id = p.train_id WHERE t.line_id = 2 AND time_of_day = 'rush hour';
gretelai_synthetic_text_to_sql
CREATE TABLE KPOP_GROUPS (id INT, group_name VARCHAR(100), genre VARCHAR(50), total_sales INT); INSERT INTO KPOP_GROUPS (id, group_name, genre, total_sales) VALUES (1, 'BTS', 'K-pop', 90000000), (2, 'Blackpink', 'K-pop', 65000000), (3, 'EXO', 'K-pop', 50000000);
What's the highest grossing K-pop group of all time?
SELECT group_name, total_sales FROM KPOP_GROUPS ORDER BY total_sales DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.satellites (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), launch_date DATE); INSERT INTO aerospace.satellites (id, country, name, launch_date) VALUES (1, 'USA', 'Sat1', '2000-01-01'), (2, 'USA', 'Sat2', '2001-01-01'), (3, 'China', 'Sat3', '2002-01-01');
How many satellites were deployed per year by each country?
SELECT EXTRACT(YEAR FROM launch_date) as launch_year, country, COUNT(*) as total_satellites FROM aerospace.satellites GROUP BY launch_year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_diagnosis_l (patient_id INT, diagnosis VARCHAR(50), age INT, treatment_center VARCHAR(50)); INSERT INTO patient_diagnosis_l (patient_id, diagnosis, age, treatment_center) VALUES (12, 'Depression', 30, 'clinic_l'), (13, 'Bipolar Disorder', 40, 'clinic_l');
What are the average ages of patients diagnosed with 'Depression' and 'Bipolar Disorder' in 'clinic_l'?
SELECT AVG(age) FROM patient_diagnosis_l WHERE diagnosis = 'Depression' AND treatment_center = 'clinic_l'; SELECT AVG(age) FROM patient_diagnosis_l WHERE diagnosis = 'Bipolar Disorder' AND treatment_center = 'clinic_l';
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (id INT, aircraft_model VARCHAR(50), accident_year INT); INSERT INTO flight_safety (id, aircraft_model, accident_year) VALUES (1, 'B747', 2000), (2, 'A320', 2005), (3, 'B747', 2010), (4, 'A320', 2015), (5, 'B737', 2010);
Which aircraft models have the most accidents?
SELECT aircraft_model, COUNT(*) FROM flight_safety GROUP BY aircraft_model ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO sports_teams (team_id, team_name) VALUES (1, 'TeamA'), (2, 'TeamB'), (3, 'TeamC'); CREATE TABLE ticket_sales (ticket_id INT, team_id INT, price DECIMAL(5,2)); INSERT INTO ticket_sales (ticket_id, team_id, price) VALUES (1, 1, 75.50), (2, 1, 85.20), (3, 2, 65.00), (4, 2, 75.00);
List the teams that have not made any ticket sales
SELECT s.team_name FROM sports_teams s LEFT JOIN ticket_sales t ON s.team_id = t.team_id WHERE t.ticket_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE german_tourism (country VARCHAR(50), year INT, expenses DECIMAL(6,2)); INSERT INTO german_tourism (country, year, expenses) VALUES ('Germany', 2019, 600.0), ('Germany', 2019, 350.0), ('France', 2019, 700.0);
How many international tourists visited Germany and spent more than 500 EUR in 2019?
SELECT COUNT(*) FROM german_tourism WHERE country = 'Germany' AND year = 2019 AND expenses > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE farm (farm_id INT, farm_name TEXT, region TEXT); INSERT INTO farm (farm_id, farm_name, region) VALUES (1, 'FarmA', 'region1'), (2, 'FarmB', 'region1'), (3, 'FarmC', 'region2'); CREATE TABLE crop_production (production_id INT, farm_id INT, crop_name TEXT, quantity INT); INSERT INTO crop_production (production_id, farm_id, crop_name, quantity) VALUES (1, 1, 'Corn', 500), (2, 1, 'Potatoes', 200), (3, 2, 'Corn', 700), (4, 2, 'Beans', 300), (5, 3, 'Carrots', 400);
What is the total quantity of crops produced by each farm in 'region1'?
SELECT f.farm_name, SUM(cp.quantity) as total_quantity FROM farm f INNER JOIN crop_production cp ON f.farm_id = cp.farm_id WHERE f.region = 'region1' GROUP BY f.farm_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Bakery (bakery_item VARCHAR(50), type VARCHAR(20), price DECIMAL(5,2), revenue DECIMAL(5,2)); INSERT INTO Bakery (bakery_item, type, price, revenue) VALUES ('Almond Croissant', 'Gluten-free', 2.99, 0), ('Chocolate Chip Cookie', 'Gluten-free', 2.49, 0), ('Blueberry Muffin', 'Gluten-free', 3.49, 0);
What is the total revenue generated from gluten-free dishes?
SELECT SUM(price * revenue) FROM Bakery WHERE type = 'Gluten-free';
gretelai_synthetic_text_to_sql
CREATE TABLE Tunnel_Construction (tunnel_id INT, tunnel_name VARCHAR(50), location VARCHAR(50), construction_date DATE);
List the names and locations of all tunnels in the Tunnel_Construction table
SELECT tunnel_name, location FROM Tunnel_Construction WHERE tunnel_type = 'Tunnel';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name TEXT, location TEXT); INSERT INTO species (id, name, location) VALUES (1, 'Species A', 'Mediterranean Sea'); INSERT INTO species (id, name, location) VALUES (2, 'Species B', 'Caribbean Sea');
How many marine species are registered in the Caribbean sea in the species table?
SELECT COUNT(*) FROM species WHERE location = 'Caribbean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, country TEXT); INSERT INTO companies (id, name, country) VALUES (1, 'Alpha', 'United Kingdom'), (2, 'Beta', 'United Kingdom'), (3, 'Gamma', 'Canada'), (4, 'Delta', 'Australia'); CREATE TABLE ad_spend (company_id INT, amount DECIMAL, date DATE); INSERT INTO ad_spend (company_id, amount, date) VALUES (1, 1500, '2022-02-01'), (1, 1200, '2022-02-05'), (2, 1800, '2022-02-03'), (3, 800, '2022-02-04'), (4, 1000, '2022-03-04');
What is the sum of all advertising spend by companies from the United Kingdom, in February 2022?
SELECT SUM(ad_spend.amount) FROM ad_spend JOIN companies ON ad_spend.company_id = companies.id WHERE companies.country = 'United Kingdom' AND ad_spend.date >= '2022-02-01' AND ad_spend.date <= '2022-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, state VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, state) VALUES (1, 3.5, 'NY'), (2, 4.2, 'NY'), (3, 3.8, 'NJ'), (4, 5.0, 'CA'), (5, 4.5, 'DELHI');
What is the average mobile data usage for customers in Delhi?
SELECT AVG(data_usage) FROM mobile_subscribers WHERE state = 'DELHI';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, age INT, gender TEXT); INSERT INTO clients VALUES (1, 'John Doe', 35, 'Male'), (2, 'Jane Smith', 45, 'Female'), (3, 'Bob Johnson', 50, 'Male'); CREATE TABLE investments (client_id INT, investment_type TEXT); INSERT INTO investments VALUES (1, 'Stocks'), (1, 'Bonds'), (2, 'Stocks'), (2, 'Bonds'), (3, 'Bonds');
What is the average age of clients who invested only in bonds?
SELECT AVG(c.age) FROM clients c INNER JOIN investments i ON c.client_id = i.client_id WHERE i.investment_type = 'Bonds' GROUP BY c.client_id HAVING COUNT(DISTINCT i.investment_type) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_violations (violation_id INT, violation_type VARCHAR(255)); INSERT INTO traffic_violations (violation_id, violation_type) VALUES (1, 'Speeding'), (2, 'Running Red Light');
What are the different types of traffic violations and their counts?
SELECT violation_type, COUNT(violation_id) FROM traffic_violations GROUP BY violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), HireDate DATE, Training VARCHAR(30)); INSERT INTO Employees (EmployeeID, Gender, HireDate, Training) VALUES (1, 'Male', '2020-01-01', 'Onboarding'), (2, 'Female', '2021-01-01', 'Onboarding');
What is the percentage of female employees who were hired in the last 12 months and have completed onboarding training?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE Gender = 'Female' AND HireDate >= DATEADD(month, -12, GETDATE()))) FROM Employees WHERE Gender = 'Female' AND Training = 'Onboarding';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide_categories (id INT, initiative_category VARCHAR(50), region VARCHAR(50));INSERT INTO digital_divide_categories (id, initiative_category, region) VALUES (1, 'Internet Access', 'Asia'), (2, 'Computer Literacy', 'Europe'), (3, 'Broadband Infrastructure', 'Americas');
What is the distribution of digital divide initiative categories across different regions?
SELECT region, COUNT(*) as initiative_count FROM digital_divide_categories GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, years_of_experience INT, professional_development_course_completion_date DATE, teaching_subject VARCHAR(255)); INSERT INTO teachers (teacher_id, years_of_experience, professional_development_course_completion_date, teaching_subject) VALUES (1, 18, '2022-01-01', 'Mathematics'), (2, 12, '2021-12-15', 'Science'), (3, 20, '2022-03-05', 'English');
What is the count of professional development courses completed by teachers who have been teaching for over 15 years, in the past year, broken down by their teaching subjects?
SELECT teaching_subject, COUNT(*) as courses_completed FROM teachers WHERE years_of_experience > 15 AND professional_development_course_completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY teaching_subject;
gretelai_synthetic_text_to_sql
CREATE TABLE civil_engineering_projects (id INT, name VARCHAR(255), location VARCHAR(255), budget FLOAT, project_type VARCHAR(255)); INSERT INTO civil_engineering_projects (id, name, location, budget, project_type) VALUES (1, 'Bridge', 'New York', 8000000, 'Transportation'), (2, 'Tunnel', 'London', 12000000, 'Transportation'), (3, 'Water_Treatment_Plant', 'Paris', 10000000, 'Environmental');
What is the maximum and minimum budget for each type of civil engineering project?
SELECT project_type, MIN(budget) as min_budget, MAX(budget) as max_budget FROM civil_engineering_projects GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE member_demographics (member_id INT, age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(20));
What is the count of members by gender and city in the 'member_demographics' table?
SELECT gender, city, COUNT(*) FROM member_demographics GROUP BY gender, city;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_production (site VARCHAR(20), state VARCHAR(20), co2_emission INT, production INT); INSERT INTO co2_production (site, state, co2_emission, production) VALUES ('SiteA', 'QLD', 2500, 1500), ('SiteB', 'NSW', 3000, 2000), ('SiteC', 'QLD', 2000, 1800);
What is the ratio of CO2 emissions to coal production per site in QLD?
SELECT site, co2_emission/production FROM co2_production WHERE state = 'QLD';
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT PRIMARY KEY, seller VARCHAR(255), buyer VARCHAR(255), equipment_type VARCHAR(255), quantity INT);
Delete all military equipment sales records where the seller is "XYZ Corp".
DELETE FROM military_sales WHERE seller = 'XYZ Corp';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_region (id INT, crop_type VARCHAR(255), country VARCHAR(255), region VARCHAR(255), temperature FLOAT, precipitation FLOAT); INSERT INTO crop_region (id, crop_type, country, region, temperature, precipitation) VALUES (1, 'Corn', 'Brazil', 'North', 20.0, 1000.0); INSERT INTO crop_region (id, crop_type, country, region, temperature, precipitation) VALUES (2, 'Soybean', 'Brazil', 'South', 18.0, 1200.0);
What is the average temperature and precipitation for crops in Brazil by region?
SELECT region, AVG(temperature) AS avg_temperature, AVG(precipitation) AS avg_precipitation FROM crop_region WHERE country = 'Brazil' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (hotel_id INT, location TEXT, has_virtual_tour BOOLEAN); INSERT INTO virtual_tours (hotel_id, location, has_virtual_tour) VALUES (1, 'Rio de Janeiro', true), (2, 'Rio de Janeiro', false), (3, 'Sao Paulo', true);
How many hotels offer virtual tours in 'Rio de Janeiro'?
SELECT COUNT(*) FROM virtual_tours WHERE location = 'Rio de Janeiro' AND has_virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_regions(attorney_id INT, region VARCHAR(20)); INSERT INTO attorney_regions(attorney_id, region) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'), (5, 'West'), (6, 'North'); CREATE TABLE handled_cases(attorney_id INT, case_id INT); INSERT INTO handled_cases(attorney_id, case_id) VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106);
Which attorneys have not handled any cases in the 'East' region?
SELECT h.attorney_id FROM attorney_regions h LEFT JOIN handled_cases i ON h.attorney_id = i.attorney_id WHERE h.region = 'East' AND i.attorney_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (user_id INT, song_id INT, duration FLOAT, date DATE, artist VARCHAR(255));
What is the longest streaming session by artist in 'music_streaming' table?
SELECT artist, MAX(duration) as max_duration FROM music_streaming GROUP BY artist;
gretelai_synthetic_text_to_sql
CREATE TABLE platforms (platform_id INT, platform_name TEXT, region TEXT); INSERT INTO platforms (platform_id, platform_name, region) VALUES (1, 'A', 'North Sea'), (2, 'B', 'North Sea'); CREATE TABLE production (platform_id INT, year INT, oil_production FLOAT); INSERT INTO production (platform_id, year, oil_production) VALUES (1, 2020, 100000), (1, 2021, 120000), (2, 2020, 150000), (2, 2021, 180000);
Find the average oil production for each platform in the past year
SELECT p.platform_name, AVG(p.oil_production) AS avg_oil_production FROM production p JOIN platforms pl ON p.platform_id = pl.platform_id WHERE p.year = (SELECT MAX(year) FROM production) GROUP BY p.platform_id;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_speeds (speed_id INT, area VARCHAR(255), speed DECIMAL(10,2)); INSERT INTO broadband_speeds (speed_id, area, speed) VALUES (1, 'Rural USA', 50.00), (2, 'Urban USA', 120.00), (3, 'Rural Canada', 35.00), (4, 'Urban Canada', 180.00);
What is the average broadband speed in rural and urban areas?
SELECT area, AVG(speed) AS avg_speed FROM broadband_speeds GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (1, 1, '2023-02-01'), (2, 2, '2023-02-02'), (3, 3, '2023-02-03');
What is the total number of workouts done by female members in the last week?
SELECT COUNT(*) FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.Gender = 'Female' AND Workouts.WorkoutDate >= CURDATE() - INTERVAL 1 WEEK;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (project_name TEXT, city TEXT, country TEXT, capacity INTEGER); INSERT INTO renewable_energy (project_name, city, country, capacity) VALUES ('Solar Farm 1', 'Seattle', 'USA', 50000);
What is the total installed capacity of renewable energy projects in the city of Seattle?
SELECT SUM(capacity) FROM renewable_energy WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (name VARCHAR(255), type VARCHAR(255), flag_state VARCHAR(255)); CREATE TABLE inspections (inspection_id INT, vessel_name VARCHAR(255), inspection_date DATE); CREATE TABLE mediterranean_sea (name VARCHAR(255), region_type VARCHAR(255)); INSERT INTO vessels (name, type, flag_state) VALUES ('VESSEL1', 'Cargo', 'Italy'), ('VESSEL2', 'Passenger', 'Spain'); INSERT INTO inspections (inspection_id, vessel_name, inspection_date) VALUES (1, 'VESSEL1', '2022-01-01'), (2, 'VESSEL3', '2022-02-01'); INSERT INTO mediterranean_sea (name, region_type) VALUES ('VESSEL1', 'Mediterranean Sea');
Which vessels have been inspected for maritime law compliance in the Mediterranean sea?'
SELECT vessels.name FROM vessels INNER JOIN mediterranean_sea ON vessels.name = mediterranean_sea.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (manufacturer VARCHAR(20), name VARCHAR(30), mass FLOAT); INSERT INTO Spacecraft (manufacturer, name, mass) VALUES ('SpaceCorp', 'Voyager 1', 778.0), ('SpaceCorp', 'Voyager 2', 778.0);
What is the average mass of spacecraft manufactured by SpaceCorp?
SELECT AVG(mass) FROM Spacecraft WHERE manufacturer = 'SpaceCorp';
gretelai_synthetic_text_to_sql