context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE mobile_revenue (revenue_id INT, revenue_date DATE, revenue_amount FLOAT, revenue_type VARCHAR(20)); INSERT INTO mobile_revenue (revenue_id, revenue_date, revenue_amount, revenue_type) VALUES (1, '2021-07-12', 50000, 'Mobile'), (2, '2021-07-28', 75000, 'Broadband'); CREATE TABLE broadband_revenue (revenue_i...
What is the total revenue from mobile and broadband services for the month of July 2021?
SELECT SUM(revenue_amount) FROM mobile_revenue WHERE revenue_date BETWEEN '2021-07-01' AND '2021-07-31' UNION ALL SELECT SUM(revenue_amount) FROM broadband_revenue WHERE revenue_date BETWEEN '2021-07-01' AND '2021-07-31';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, gender VARCHAR(10), condition VARCHAR(50), therapy_date DATE, improvement BOOLEAN);
What is the average age of patients who experienced improvement after therapy?
SELECT AVG(age) FROM patients WHERE improvement = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, size TEXT, quantity INT, sale_date DATE); INSERT INTO sales (id, product_id, size, quantity, sale_date) VALUES (1, 1001, 'XS', 25, '2021-09-01'), (2, 1002, 'XXL', 30, '2021-09-15'), (3, 1003, 'M', 40, '2021-09-20'), (4, 1004, 'L', 50, '2021-09-25');
What is the maximum quantity of clothes sold in a single day?
SELECT MAX(quantity) FROM sales;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID INT PRIMARY KEY, CountryName TEXT, Continent TEXT); INSERT INTO Countries (CountryID, CountryName, Continent) VALUES (1, 'United States', 'North America'); INSERT INTO Countries (CountryID, CountryName, Continent) VALUES (2, 'United Kingdom', 'Europe'); INSERT INTO Countries (CountryID...
What is the median donation amount for donors from Africa?
SELECT AVG(AmountDonated) FROM (SELECT AmountDonated FROM Donors INNER JOIN Donors_Countries ON Donors.DonorID = Donors_Countries.DonorID WHERE Donors_Countries.CountryName = 'Nigeria' ORDER BY AmountDonated) AS DonorAmounts WHERE (ROW_NUMBER() OVER (ORDER BY AmountDonated) IN ((COUNT(*) + 1) / 2, (COUNT(*) + 2) / 2));
gretelai_synthetic_text_to_sql
CREATE TABLE ClothingItems (id INT, fair_trade_certified BOOLEAN); INSERT INTO ClothingItems VALUES (1, true), (2, false), (3, true), (4, true), (5, false);
What is the total number of fair trade certified clothing items?
SELECT COUNT(*) FROM ClothingItems WHERE fair_trade_certified = true;
gretelai_synthetic_text_to_sql
CREATE TABLE vr_games_4 (id INT, player TEXT, game TEXT, playtime INT); INSERT INTO vr_games_4 (id, player, game, playtime) VALUES (1, 'Kevin', 'Superhot', 70), (2, 'Lara', 'Beat Saber', 110), (3, 'Kevin', 'Arizona Sunshine', 90);
What is the total playtime of player 'Kevin' in the VR game 'Superhot'?
SELECT SUM(playtime) FROM vr_games_4 WHERE player = 'Kevin' AND game = 'Superhot';
gretelai_synthetic_text_to_sql
CREATE TABLE indian_ocean_reserves (reserve_name VARCHAR(255), avg_depth FLOAT); INSERT INTO indian_ocean_reserves (reserve_name, avg_depth) VALUES ('Maldives', 100.0), ('Andaman Islands', 200.0);
What is the average depth of all marine reserves in the Indian Ocean?
SELECT AVG(avg_depth) FROM indian_ocean_reserves;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sightings (species TEXT, location TEXT, date DATE); INSERT INTO whale_sightings (species, location, date) VALUES ('Beluga Whale', 'Arctic Ocean', '2018-01-01'), ('Narwhal', 'Arctic Ocean', '2020-05-15');
Show all whale sightings in the Arctic Ocean in the last 5 years.
SELECT * FROM whale_sightings WHERE location = 'Arctic Ocean' AND date >= (SELECT CURRENT_DATE - INTERVAL '5 years');
gretelai_synthetic_text_to_sql
CREATE VIEW AverageMentalHealthByMonth AS SELECT DATE_TRUNC('month', AssessmentDate) AS Month, AVG(MentalHealthScore) AS AverageScore FROM StudentsMentalHealth GROUP BY Month; SELECT * FROM AverageMentalHealthByMonth;
Display data from the view
SELECT * FROM AverageMentalHealthByMonth;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name TEXT, organization_id INT, budget FLOAT, status TEXT); INSERT INTO Projects (id, name, organization_id, budget, status) VALUES (1, 'Disaster Response', 1, 250000, 'Completed'), (2, 'Rebuilding Infrastructure', 2, 450000, 'In Progress');
What's the name and status of the projects with a budget over 400000?
SELECT Projects.name, Projects.status FROM Projects WHERE Projects.budget > 400000;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeData (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2));
Insert a new record into the EmployeeData table for an employee named 'Ali' Ahmed, working in the 'Admin' department with a salary of 50000.
INSERT INTO EmployeeData (EmployeeID, FirstName, LastName, Department, Salary) VALUES (5, 'Ali', 'Ahmed', 'Admin', 50000);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_projects (id INT, name TEXT, location TEXT, budget FLOAT); INSERT INTO rural_projects (id, name, location, budget) VALUES (1, 'Water Supply', 'Kenya', 500000.00), (2, 'Electricity Grid', 'Tanzania', 200000.00), (3, 'Road Construction', 'Uganda', NULL);
How many rural infrastructure projects are there in total for each country, including those with a budget of 0?
SELECT location, COUNT(*) FROM rural_projects GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE md_projects (quarter VARCHAR(5), state VARCHAR(10), project_value FLOAT); INSERT INTO md_projects (quarter, state, project_value) VALUES ('Q1 2022', 'Maryland', 12000000), ('Q2 2022', 'Maryland', 15000000), ('Q3 2022', 'Maryland', 16000000), ('Q4 2022', 'Maryland', 18000000);
What was the total value of construction projects in Maryland in Q2 2022?
SELECT project_value FROM md_projects WHERE quarter = 'Q2 2022' AND state = 'Maryland';
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalExhibits (ExhibitID INT, Title VARCHAR(50), Curator VARCHAR(50), City VARCHAR(50)); INSERT INTO DigitalExhibits (ExhibitID, Title, Curator, City) VALUES (1, 'Digital Art Museum', 'Alice Johnson', 'Tokyo'); INSERT INTO DigitalExhibits (ExhibitID, Title, Curator, City) VALUES (2, 'Virtual Reality Expe...
Who are the curators of digital exhibits in Asia?
SELECT DigitalExhibits.Curator FROM DigitalExhibits WHERE DigitalExhibits.City = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Fans (fan_id INT, fan_name VARCHAR(50), favorite_sport_id INT); CREATE TABLE Sports (sport_id INT, sport_name VARCHAR(50)); CREATE TABLE Tickets (ticket_id INT, fan_id INT, sport_id INT, quantity INT, purchase_date DATE);
Identify fans who have never purchased tickets for basketball games.
SELECT fan_name FROM Fans LEFT JOIN Tickets ON Fans.fan_id = Tickets.fan_id AND Sports.sport_id = 1 WHERE Tickets.ticket_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID int, ProgramName varchar(255)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(255), ProgramID int, VolunteerDate date); INSERT INTO Volunteers (VolunteerID, Volunt...
Which programs did volunteer 'Zoe' engage with in 2022?
SELECT DISTINCT ProgramName FROM Volunteers V JOIN Programs P ON V.ProgramID = P.ProgramID WHERE VolunteerName = 'Zoe';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_prods (product_id INT, name VARCHAR(50), price DECIMAL(5,2), supplier VARCHAR(50)); INSERT INTO organic_prods VALUES (1, 'Organic Tofu', 5.99, 'EcoFarm'); INSERT INTO organic_prods VALUES (2, 'Organic Almond Butter', 8.99, 'EcoFarm'); CREATE TABLE uk_suppliers (product_id INT, supplier VARCHAR(50),...
Determine the total revenue generated by each supplier for organic products in the UK.
SELECT s.supplier, SUM(op.price) FROM organic_prods op JOIN uk_suppliers us ON op.product_id = us.product_id JOIN (SELECT supplier FROM uk_suppliers GROUP BY supplier) s ON op.supplier = s.supplier WHERE us.uk_location = 1 AND op.name LIKE '%organic%' GROUP BY s.supplier;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, call_time TIMESTAMP, location VARCHAR(20));
What is the maximum number of emergency calls made in the "east" district, for the month of January?
SELECT MAX(COUNT(*)) FROM emergency_calls WHERE location = 'east' AND EXTRACT(MONTH FROM call_time) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name TEXT); CREATE TABLE workers (worker_id INT, worker_name TEXT, salary INT, region_id INT, industry_id INT); CREATE TABLE industries (industry_id INT, industry_name TEXT); INSERT INTO regions VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO ...
What is the maximum salary of workers in the 'retail' industry in the 'North' region?
SELECT MAX(salary) FROM workers INNER JOIN regions ON workers.region_id = regions.region_id INNER JOIN industries ON workers.industry_id = industries.industry_id WHERE regions.region_name = 'North' AND industries.industry_name = 'retail';
gretelai_synthetic_text_to_sql
CREATE TABLE OIL_PRODUCTION (WELL_NAME VARCHAR(255), PRODUCTION_DATE DATE, QUANTITY INT);
What is the daily production quantity of the 'MOUNTAIN_OIL' well in the 'OIL_PRODUCTION' table?
SELECT QUANTITY FROM OIL_PRODUCTION WHERE WELL_NAME = 'MOUNTAIN_OIL' AND PRODUCTION_DATE = CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, FirstName varchar(50), LastName varchar(50)); INSERT INTO Donors (DonorID, FirstName, LastName) VALUES (1, 'John', 'Doe'), (2, 'Jane', 'Smith'), (3, 'Alice', 'Johnson'), (4, 'Bob', 'Brown'), (5, 'Charlie', 'Williams'); CREATE TABLE Donations (DonationID int, DonorID int, Amount decimal...
Find the top 5 donors by total donations, considering only donors who have donated more than $1000 in total?
SELECT D.FirstName, D.LastName, SUM(D.Amount) as TotalDonated FROM Donors D INNER JOIN Donations ON D.DonorID = Donations.DonorID GROUP BY D.DonorID HAVING TotalDonated > 1000 ORDER BY TotalDonated DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), ethnicity VARCHAR(20)); INSERT INTO community_health_workers (worker_id, name, ethnicity) VALUES (1, 'Ana Garcia', 'Hispanic'), (2, 'Juan Hernandez', 'Hispanic'), (3, 'Mark Johnson', 'Non-Hispanic');
Who are the community health workers serving the Non-Hispanic population?
SELECT * FROM community_health_workers WHERE ethnicity = 'Non-Hispanic';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (WarehouseID int, WarehouseName varchar(255), Region varchar(255));CREATE TABLE Shipments (ShipmentID int, WarehouseID int, Pallets int, ShippedDate datetime); INSERT INTO Warehouses (WarehouseID, WarehouseName, Region) VALUES (1, 'W1', 'Asia-Pacific'); INSERT INTO Shipments (ShipmentID, Warehou...
List the number of pallets shipped to each warehouse in the Asia-Pacific region in the past month, excluding warehouses with fewer than 50 shipments.
SELECT w.WarehouseName, SUM(s.Pallets) as TotalPallets FROM Warehouses w INNER JOIN Shipments s ON w.WarehouseID = s.WarehouseID WHERE w.Region = 'Asia-Pacific' AND s.ShippedDate >= DATEADD(month, -1, GETDATE()) GROUP BY w.WarehouseName HAVING COUNT(*) >= 50;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.patents (id INT, company VARCHAR(100), filing_date DATE);INSERT INTO biosensors.patents (id, company, filing_date) VALUES (1, 'CompanyA', '2018-03-15'), (2, 'CompanyB', '2019-08-01'), (3, 'CompanyC', '2020-02-20');
How many biosensor technology patents have been filed in the last 5 years by company?
SELECT company, COUNT(*) as patents_filed FROM biosensors.patents WHERE filing_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, ProjectName VARCHAR(50), Spending INT, SpendingDate DATE); INSERT INTO Projects (ProjectID, ProjectName, Spending, SpendingDate) VALUES (1, 'ProjectA', 15000, '2022-01-01'), (2, 'ProjectB', 20000, '2022-02-15'), (3, 'ProjectA', 12000, '2022-03-03');
What is the total amount spent on each project in 'Projects' table for the year 2022?
SELECT ProjectName, EXTRACT(YEAR FROM SpendingDate) AS Year, SUM(Spending) AS TotalSpending FROM Projects WHERE EXTRACT(YEAR FROM SpendingDate) = 2022 GROUP BY ProjectName, Year
gretelai_synthetic_text_to_sql
CREATE TABLE AccessibleTech (location VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO AccessibleTech (location, budget) VALUES ('Africa', 50000.00), ('Asia', 75000.00), ('Europe', 120000.00), ('SouthAmerica', 60000.00), ('NorthAmerica', 150000.00);
What is the average budget for accessible technology projects in Africa?
SELECT AVG(budget) FROM AccessibleTech WHERE location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(255), country VARCHAR(255), funding FLOAT, date DATE); INSERT INTO startups (id, name, country, funding, date) VALUES (1, 'StartupA', 'India', 5000000, '2020-01-01'); INSERT INTO startups (id, name, country, funding, date) VALUES (2, 'StartupB', 'India', 7000000, '2019-01-01'...
What is the total funding received by biotech startups in India, grouped by year?
SELECT country, YEAR(date) AS year, SUM(funding) FROM startups WHERE country = 'India' GROUP BY year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_missions (country VARCHAR(255), mission VARCHAR(255), personnel INT); INSERT INTO peacekeeping_missions (country, mission, personnel) VALUES ('USA', 'Mission1', 100), ('USA', 'Mission2', 150), ('China', 'Mission1', 200), ('China', 'Mission3', 250), ('France', 'Mission2', 120), ('France', 'Miss...
What is the average number of military personnel per peacekeeping mission for each country?
SELECT country, AVG(personnel) as avg_personnel_per_mission FROM peacekeeping_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID int, Name varchar(50), Title varchar(50), YearsOfExperience int); INSERT INTO Attorneys (AttorneyID, Name, Title, YearsOfExperience) VALUES (1, 'John Doe', 'Senior Partner', 20); INSERT INTO Attorneys (AttorneyID, Name, Title, YearsOfExperience) VALUES (2, 'Jane Smith', 'Associate', 5...
What is the average billing amount for cases handled by attorneys with 'Senior Partner' title?
SELECT AVG(BillingAmount) FROM Cases INNER JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.Title = 'Senior Partner';
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (city_name VARCHAR(255), make VARCHAR(255), model VARCHAR(255), sales INT); INSERT INTO electric_vehicles (city_name, make, model, sales) VALUES ('Los Angeles', 'Tesla', 'Model S', 1500), ('New York', 'Chevrolet', 'Bolt', 1000);
What is the total number of electric vehicles sold in each city, broken down by make and model?
SELECT city_name, make, model, SUM(sales) as total_sales FROM electric_vehicles GROUP BY city_name, make, model;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchStations (id INT, name VARCHAR(50), capacity INT, country VARCHAR(50)); INSERT INTO ResearchStations (id, name, capacity, country) VALUES (1, 'Station A', 50, 'Norway');CREATE TABLE IndigenousCommunities (id INT, name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO IndigenousCommuniti...
What is the name of the research station with the lowest capacity in a country with an indigenous community population greater than 200?
SELECT name FROM ResearchStations r WHERE r.capacity = (SELECT MIN(capacity) FROM ResearchStations) AND r.country = ANY(SELECT ic.region FROM IndigenousCommunities ic WHERE ic.population > 200);
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farms (id INT, urban_region_id INT); CREATE TABLE urban_regions (id INT, name VARCHAR(50)); CREATE TABLE weather (id INT, region_id INT, year INT, rainfall FLOAT, temperature FLOAT);
What is the average annual rainfall and temperature for each urban farm in the "urban_farms", "urban_regions", and "weather" tables?
SELECT urban_farms.id AS farm_id, urban_regions.name AS region, AVG(weather.rainfall) AS avg_rainfall, AVG(weather.temperature) AS avg_temperature FROM urban_farms INNER JOIN urban_regions ON urban_farms.urban_region_id = urban_regions.id INNER JOIN weather ON urban_regions.id = weather.region_id GROUP BY urban_farms.i...
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_name TEXT, in_circulation INTEGER, circulation_date DATE); INSERT INTO digital_assets (asset_name, in_circulation, circulation_date) VALUES ('Bitcoin', 18750000, '2022-02-01'), ('Ethereum', 115500000, '2022-02-01');
What is the total number of digital assets in circulation in India as of 2022-02-01?
SELECT SUM(in_circulation) FROM digital_assets WHERE circulation_date = '2022-02-01' AND asset_name IN ('Bitcoin', 'Ethereum');
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR, location VARCHAR, years_of_experience INT); INSERT INTO Farmers (id, name, location, years_of_experience) VALUES (1, 'Sophia Garcia', 'Madrid', 10), (2, 'Mohammad Al-Said', 'Cairo', 12), (3, 'Park Soo-jin', 'Seoul', 8); CREATE TABLE Crops (id INT, farmer_id INT, crop_name VAR...
Which farmers grow fruits or nuts in the agriculture database?
SELECT f.name, COUNT(DISTINCT c.crop_name) as unique_fruits_or_nuts_count FROM Farmers f JOIN Crops c ON f.id = c.farmer_id WHERE c.crop_type IN ('fruit', 'nut') GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (employee_id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO Employees (employee_id, name, gender, department, salary) VALUES (1, 'John Doe', 'Male', 'Mining', 50000), (2, 'Jane Smith', 'Female', 'Mining', 55000), (3, 'Alice Johnson', 'Female...
What is the average salary of male and female employees in the mining department?
SELECT gender, AVG(salary) as avg_salary FROM Employees WHERE department = 'Mining' GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT, year INT, topic TEXT, author TEXT); INSERT INTO articles (id, title, year, topic, author) VALUES (1, 'Article1', 1970, 'Politics', 'James Johnson'), (2, 'Article2', 1980, 'Sports', 'Mary Davis'), (3, 'Article3', 1975, 'Politics', 'Michael Brown');
Delete all articles about politics written by men in the '70s.
DELETE FROM articles WHERE author IN ('James Johnson', 'Michael Brown') AND topic = 'Politics' AND year = 1970;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, is_cruelty_free BOOLEAN, has_natural_ingredients BOOLEAN);
What is the total number of cruelty-free products with natural ingredients?
SELECT COUNT(*) FROM Products WHERE is_cruelty_free = TRUE AND has_natural_ingredients = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_sales (sale_date DATE, item VARCHAR(50), sales INT); INSERT INTO daily_sales (sale_date, item, sales) VALUES ('2022-01-01', 'Pizza Margherita', 15), ('2022-01-01', 'Spaghetti Bolognese', 10); CREATE VIEW item_sales AS SELECT item, sale_date FROM daily_sales GROUP BY item, sale_date;
Find the menu items that had sales every day in the last week?
SELECT item FROM item_sales WHERE sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() GROUP BY item HAVING COUNT(DISTINCT sale_date) = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (ticket_id INT, ticket_price DECIMAL(5,2), exhibition_id INT); INSERT INTO tickets (ticket_id, ticket_price, exhibition_id) VALUES (1, 20.00, 1), (2, 25.00, 2), (3, 15.00, 1);
What was the total revenue generated by each exhibition?
SELECT e.exhibition_name, SUM(t.ticket_price) FROM exhibitions e JOIN tickets t ON e.exhibition_id = t.exhibition_id GROUP BY e.exhibition_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai (country VARCHAR(20), year INT, courses INT); INSERT INTO ethical_ai (country, year, courses) VALUES ('China', 2020, 15), ('India', 2020, 12), ('Japan', 2020, 18);
How many ethical AI courses were offered in Asia in 2020?
SELECT SUM(courses) FROM ethical_ai WHERE country = 'Asia' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE attacks (attack_type VARCHAR(255), ip_address VARCHAR(255), attack_date DATE); INSERT INTO attacks (attack_type, ip_address, attack_date) VALUES ('DDOS', '192.168.1.1', '2022-06-01'), ('DDOS', '192.168.1.2', '2022-06-01'), ('Phishing', '192.168.1.3', '2022-06-02'), ('Phishing', '192.168.1.4', '2022-06-02')...
Find the number of unique IP addresses involved in each type of attack, for the last month, partitioned by attack type and day?
SELECT attack_type, attack_date, COUNT(DISTINCT ip_address) as unique_ip_addresses FROM attacks WHERE attack_date >= DATEADD(month, -1, GETDATE()) GROUP BY attack_type, attack_date;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(20), country VARCHAR(20), in_service BOOLEAN);
Delete all records in the 'military_equipment' table where 'country' is 'China'
DELETE FROM military_equipment WHERE country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, founding_date DATE, founding_team TEXT, total_funding FLOAT, exit_status TEXT); INSERT INTO startups (id, name, founding_date, founding_team, total_funding, exit_status) VALUES (1, 'Acme Inc', '2010-01-01', 'John, Jane', 5000000, 'IPO');
What is the success rate (exit or IPO) of startups founded by BIPOC founders?
SELECT COUNT(*) / (SELECT COUNT(*) FROM startups WHERE founding_team LIKE '%, BIPOC%') AS success_rate FROM startups WHERE exit_status IS NOT NULL AND founding_team LIKE '%, BIPOC%';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralDevelopment_InfrastructureProjects (id INT PRIMARY KEY, name VARCHAR(100), status VARCHAR(20), evaluation_date DATE); INSERT INTO RuralDevelopment_InfrastructureProjects (id, name, status, evaluation_date) VALUES (1, 'Water Treatment Plant', 'completed', NULL), (2, 'Renewable Energy Center', 'in_progr...
Find the projects that have been completed in both the 'rural_development' and 'urban_development' databases.
SELECT RuralDevelopment_InfrastructureProjects.name FROM RuralDevelopment_InfrastructureProjects INNER JOIN UrbanDevelopment_InfrastructureProjects ON RuralDevelopment_InfrastructureProjects.name = UrbanDevelopment_InfrastructureProjects.name WHERE RuralDevelopment_InfrastructureProjects.status = 'completed' AND UrbanD...
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT PRIMARY KEY, name TEXT, location TEXT, date DATE);
Update the date of the community engagement event in 'Nigeria' with id 2
UPDATE community_engagement SET date = '2023-12-31' WHERE id = 2 AND location = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (id INT, country VARCHAR(50), capacity FLOAT, timestamp TIMESTAMP); INSERT INTO energy_storage (id, country, capacity, timestamp) VALUES (1, 'United States', 1200.5, '2022-01-01 00:00:00');
What is the total energy storage capacity (in MWh) for the United States as of January 1, 2022?
SELECT country, SUM(capacity) as total_capacity FROM energy_storage WHERE country = 'United States' AND timestamp = '2022-01-01 00:00:00' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE tool (category VARCHAR(20), tool VARCHAR(20), score INT); INSERT INTO tool (category, tool, score) VALUES ('AI', 'Chatbot', 85), ('AI', 'Image Recognition', 90), ('Data', 'Data Visualization', 80), ('Data', 'Data Analysis', 85);
What is the score for the tool with the highest score in the Data category?
SELECT score FROM tool WHERE category = 'Data' AND tool = (SELECT tool FROM tool WHERE category = 'Data' AND score = (SELECT MAX(score) FROM tool WHERE category = 'Data'));
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (Program TEXT, Impact DECIMAL); INSERT INTO Programs (Program, Impact) VALUES ('Tree Planting', 1000); INSERT INTO Programs (Program, Impact) VALUES ('Food Bank', 2000);
Which programs had the most impact in the last three months?
SELECT Program, Impact FROM Programs WHERE Program IN (SELECT Program FROM Volunteers WHERE VolunteerDate >= DATEADD(month, -3, GETDATE()) GROUP BY Program HAVING COUNT(*) >= (SELECT AVG(COUNT(*)) FROM Volunteers WHERE VolunteerDate >= DATEADD(month, -3, GETDATE()) GROUP BY Program));
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy_projects (project_id INT, student_id INT, school_id INT, hours_spent INT); INSERT INTO open_pedagogy_projects (project_id, student_id, school_id, hours_spent) VALUES (1, 1, 1, 10), (2, 2, 1, 12), (3, 3, 2, 15), (4, 4, 2, 18), (5, 5, 3, 20), (6, 6, 3, 22);
What is the maximum number of hours spent on open pedagogy projects by students in each school?
SELECT schools.school_name, MAX(open_pedagogy_projects.hours_spent) as max_hours FROM schools JOIN open_pedagogy_projects ON schools.school_id = open_pedagogy_projects.school_id GROUP BY schools.school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_visits (id INT, vessel_id INT, port_id INT, visit_date DATE); INSERT INTO vessel_visits (id, vessel_id, port_id, visit_date) VALUES (1, 1, 3, '2021-02-10'); INSERT INTO vessel_visits (id, vessel_id, port_id, visit_date) VALUES (2, 2, 3, '2021-02-12');
What is the number of unique vessels that visited the port of Los Angeles in February 2021?
SELECT COUNT(DISTINCT vessel_id) FROM vessel_visits WHERE port_id = (SELECT id FROM ports WHERE name = 'Los Angeles') AND visit_date BETWEEN '2021-02-01' AND '2021-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, heart_rate INT); INSERT INTO users (id, age, heart_rate) VALUES (1, 25, 80), (2, 30, 90), (3, 27, 75);
What is the average heart rate of users aged 25-30?
SELECT AVG(heart_rate) FROM users WHERE age BETWEEN 25 AND 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(100), DonationAmount DECIMAL(10,2), DonationDate DATE, DonorState VARCHAR(50));
What's the minimum donation amount made by donors from Texas in the third quarter of 2021?
SELECT MIN(DonationAmount) FROM Donors WHERE DonorState = 'Texas' AND QUARTER(DonationDate) = 3 AND YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductIngredients (product VARCHAR(255), ingredient VARCHAR(255));
Which beauty products contain the ingredient 'paraben'?
SELECT DISTINCT product FROM ProductIngredients WHERE ingredient = 'paraben';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists startups; USE startups; CREATE TABLE if not exists companies (id INT, name VARCHAR(100), industry VARCHAR(100), location VARCHAR(100)); CREATE TABLE if not exists funding (id INT, company_id INT, source VARCHAR(100), amount DECIMAL(10,2)); INSERT INTO companies (id, name, industry, location)...
List all biotech startups that have received funding from venture capital firms based in Silicon Valley, along with the funding amounts.
SELECT companies.name, funding.source, SUM(funding.amount) FROM startups.companies INNER JOIN startups.funding ON companies.id = funding.company_id WHERE companies.industry = 'Biotech' AND location = 'California' AND source LIKE 'VC Firm%' GROUP BY companies.name, funding.source;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(255)); INSERT INTO events (event_id, event_name) VALUES (1, 'Family Day'); CREATE TABLE visitors_events (visitor_id INT, event_id INT, age INT); INSERT INTO visitors_events (visitor_id, event_id, age) VALUES (1, 1, 10), (2, 1, 12), (3, 1, 8);
What is the minimum age of visitors who participated in the "Family Day" event?
SELECT MIN(age) FROM visitors_events WHERE event_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_patents (id INT, patent_number VARCHAR(255), title VARCHAR(255), inventor VARCHAR(255), filing_date DATE, country VARCHAR(255));
Number of patents filed in clean energy in 2020
SELECT COUNT(*) FROM clean_energy_patents WHERE filing_date >= '2020-01-01' AND filing_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (ImpactID INT, MineID INT, Year INT, ImpactScore INT); INSERT INTO EnvironmentalImpact (ImpactID, MineID, Year, ImpactScore) VALUES (1, 1, 2019, 50); INSERT INTO EnvironmentalImpact (ImpactID, MineID, Year, ImpactScore) VALUES (2, 1, 2018, 55); INSERT INTO EnvironmentalImpact (ImpactID,...
Delete all environmental impact records for mine with ID 3 in the year 2019.
DELETE FROM EnvironmentalImpact WHERE MineID = 3 AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (id INT, initiative_type VARCHAR(20), start_year INT, end_year INT);
Delete records in circular_economy_initiatives where initiative_type is 'Composting'
WITH data_to_delete AS (DELETE FROM circular_economy_initiatives WHERE initiative_type = 'Composting' RETURNING *) DELETE FROM circular_economy_initiatives WHERE id IN (SELECT id FROM data_to_delete);
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, founded_year INT, industry TEXT, total_funding DECIMAL(10,2)); INSERT INTO startups (id, name, founded_year, industry, total_funding) VALUES (1, 'Acme Inc', 2010, 'Tech', 1500000.00); INSERT INTO startups (id, name, founded_year, industry, total_funding) VALUES (2, 'Beta Corp', ...
What is the total funding for startups in the 'Sustainability' industry founded before 2017?
SELECT SUM(total_funding) FROM startups WHERE industry = 'Sustainability' AND founded_year < 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE Festivals (id INT, artist_id INT, country VARCHAR(255));
List all artists who have performed in a music festival in the United Kingdom.
SELECT Artists.name FROM Artists INNER JOIN Festivals ON Artists.id = Festivals.artist_id WHERE Festivals.country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Name VARCHAR(50), Specialty VARCHAR(50)); CREATE TABLE Cases (WorkerID INT, CaseID INT, CaseType VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (1, 'John Doe', 'Mental Health'); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Sp...
Display the number of unique specialties for community health workers.
SELECT COUNT(DISTINCT Specialty) FROM CommunityHealthWorkers;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments(city VARCHAR(20), investment_date DATE, amount DECIMAL(10,2)); INSERT INTO network_investments(city, investment_date, amount) VALUES ('New York', '2021-01-01', 150000.00), ('New York', '2021-02-15', 120000.00), ('Chicago', '2021-04-01', 180000.00);
Find the top 5 cities with the highest total network investment in the first quarter of 2021.
SELECT city, SUM(amount) FROM network_investments WHERE investment_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY city ORDER BY SUM(amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (site_id INT, site_name TEXT); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type TEXT); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'); INSERT INTO artifacts (artifact_id, site_id, artifact_type) VALUES (1, 1, 'wooden'...
Which sites have both wooden and stone artifacts?
SELECT e.site_name FROM excavation_sites e JOIN artifacts a ON e.site_id = a.site_id WHERE a.artifact_type IN ('wooden', 'stone') GROUP BY e.site_id HAVING COUNT(DISTINCT a.artifact_type) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (id INT PRIMARY KEY, model VARCHAR(50), engine VARCHAR(50)); INSERT INTO aircraft (id, model, engine) VALUES (101, '747', 'CFM56'), (102, 'A320', 'IAE V2500'), (103, 'A350', 'Rolls-Royce Trent XWB'), (104, '787', 'GE GEnx'), (105, '737', 'CFM56');
Update the engine model of aircraft with ID 105 to CFM LEAP
UPDATE aircraft SET engine = 'CFM LEAP' WHERE id = 105;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_revenue (date DATE, restaurant_id INT, revenue FLOAT); INSERT INTO daily_revenue VALUES ('2021-01-01', 1, 500), ('2021-01-02', 1, 700), ('2021-01-03', 1, 600), ('2021-01-01', 2, 800), ('2021-01-02', 2, 900), ('2021-01-03', 2, 700);
What is the daily revenue trend for a specific restaurant?
SELECT date, revenue FROM daily_revenue WHERE restaurant_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Factory_Location (id INT, factory_id INT, area VARCHAR(255), workers INT); INSERT INTO Factory_Location (id, factory_id, area, workers) VALUES (1, 1001, 'Urban', 200), (2, 1002, 'Rural', 150);
How many workers are there in factories located in urban areas compared to rural areas?
SELECT area, SUM(workers) FROM Factory_Location GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, TotalDonation DECIMAL); CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT);
Show the total number of volunteers and total amount donated in each country, ordered by the total donation amount in descending order.
SELECT V.Country, COUNT(DISTINCT V.VolunteerID) as Volunteers, SUM(D.TotalDonation) as TotalDonation FROM Volunteers V JOIN Donors D ON V.Country = D.Country GROUP BY V.Country ORDER BY TotalDonation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE African_Countries (country VARCHAR(20), production FLOAT); INSERT INTO African_Countries (country, production) VALUES ('Morocco', 650.3); INSERT INTO African_Countries (country, production) VALUES ('Senegal', 420.1);
Which African countries have the highest sustainable seafood production?
SELECT country, production FROM African_Countries WHERE production IN (SELECT MAX(production) FROM African_Countries WHERE production <= 650.3);
gretelai_synthetic_text_to_sql
CREATE TABLE car_sharing (program_id INT, program_type VARCHAR(20)); INSERT INTO car_sharing (program_id, program_type) VALUES (1, 'Round-trip'), (2, 'One-way'), (3, 'Peer-to-peer'), (4, 'Corporate'), (5, 'Fractional');
What is the total number of car-sharing programs in Toronto?
SELECT COUNT(*) as num_programs FROM car_sharing WHERE program_type IN ('Round-trip', 'One-way', 'Peer-to-peer', 'Corporate', 'Fractional');
gretelai_synthetic_text_to_sql
CREATE TABLE squid_biomass (species TEXT, biomass REAL, ocean TEXT); INSERT INTO squid_biomass (species, biomass, ocean) VALUES ('Giant Squid', 750.0, 'Indian'), ('Colossal Squid', 1000.0, 'Indian'), ('Humboldt Squid', 500.0, 'Pacific');
What is the total biomass of squids in the Indian Ocean?
SELECT SUM(biomass) FROM squid_biomass WHERE ocean = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_violations (violation_id INT, region VARCHAR(255), number INT); INSERT INTO mental_health_parity_violations (violation_id, region, number) VALUES (1, 'Northeast', 10), (2, 'Southeast', 15), (3, 'Midwest', 20), (4, 'West', 5), (5, 'Northeast', 8), (6, 'Southeast', 12), (7, 'Midwest', 18...
What is the minimum number of mental health parity violations for facilities in the Western region?
SELECT MIN(number) as min_violations FROM mental_health_parity_violations WHERE region = 'West';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT, created_at DATETIME); INSERT INTO articles (id, title, category, likes, created_at) VALUES (1, 'Climate crisis: 12 years to save the planet', 'climate change', 100, '2022-01-01 10:30:00');
What is the most common category for articles with more than 50 likes?
SELECT category, COUNT(*) as article_count FROM articles WHERE likes > 50 GROUP BY category ORDER BY article_count DESC LIMIT 1
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name TEXT, conservation_status TEXT, is_being_researched INTEGER);
How many marine species are currently being researched?
SELECT COUNT(*) FROM marine_species WHERE is_being_researched = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(255), age INT, country VARCHAR(255)); INSERT INTO players (id, name, age, country) VALUES (1, 'John Doe', 25, 'USA'), (2, 'Jane Doe', 30, 'Canada'), (3, 'Jim Brown', 30, 'Canada'), (4, 'Jamie Smith', 28, 'USA');
What is the number of players living in each country?
SELECT country, COUNT(DISTINCT id) AS players_count FROM players GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Customer_Sizes (clothing_category VARCHAR(20), size VARCHAR(10), count INT); INSERT INTO Customer_Sizes (clothing_category, size, count) VALUES ('Tops', 'XS', 500), ('Tops', 'S', 700), ('Tops', 'M', 900), ('Tops', 'L', 800), ('Tops', 'XL', 600), ('Bottoms', 'S', 400), ('Bottoms', 'M', 500), ('Bottoms', 'L'...
Display the least common size in the 'Customer_Sizes' table, across all clothing categories.
SELECT size, MIN(count) FROM Customer_Sizes GROUP BY size;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai_papers (author_id INT, author_name VARCHAR(255), num_citations INT); INSERT INTO explainable_ai_papers (author_id, author_name, num_citations) VALUES ('1', 'Jane Smith', '100');
What is the distribution of citations for explainable AI papers by author?
SELECT author_name, num_citations, NTILE(5) OVER (ORDER BY num_citations DESC) as citation_group FROM explainable_ai_papers;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (report_id INT, report_date DATE); INSERT INTO threat_intelligence (report_id, report_date) VALUES (1, '2022-01-05'); INSERT INTO threat_intelligence (report_id, report_date) VALUES (2, '2022-02-12'); INSERT INTO threat_intelligence (report_id, report_date) VALUES (3, '2022-03-20');
Determine the number of threat intelligence reports created each month in 2022.
SELECT DATE_FORMAT(report_date, '%Y-%m') AS month, COUNT(report_id) FROM threat_intelligence GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Galleries (GalleryID int, Name varchar(50), EstablishDate date); INSERT INTO Galleries VALUES (1, 'Gallery A', '2005-01-01'); INSERT INTO Galleries VALUES (2, 'Gallery B', '2008-05-15'); CREATE TABLE Artworks (ArtworkID int, Name varchar(50), Price decimal(5,2), GalleryID int, ArtCountry varchar(20)); INSE...
What is the average price of Japanese artworks sold in galleries established since 2000?
SELECT AVG(Price) FROM (SELECT Price FROM Artworks WHERE ArtCountry = 'Japan' AND GalleryID IN (SELECT GalleryID FROM Galleries WHERE EstablishDate >= '2000-01-01')) AS art_gallery_data;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, region VARCHAR(255), certification VARCHAR(255)); INSERT INTO factories (factory_id, region, certification) VALUES (1, 'Asia', 'fair trade'), (2, 'Africa', 'not fair trade'), (3, 'Asia', 'fair trade'), (4, 'Europe', 'fair trade'), (5, 'South America', 'fair trade');
Which region has the most factories with fair trade certification?
SELECT region, COUNT(*) as factory_count FROM factories WHERE certification = 'fair trade' GROUP BY region ORDER BY factory_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, location VARCHAR(10), item VARCHAR(10), quantity INT); INSERT INTO warehouses (id, location, item, quantity) VALUES (1, 'NY', 'A101', 200), (2, 'NJ', 'A101', 300), (3, 'CA', 'B203', 150), (4, 'NY', 'C304', 50), (5, 'MX', 'B203', 250), (6, 'IN', 'A101', 400);
What is the total quantity of items in warehouse 1, 4, and 6?
SELECT SUM(quantity) FROM warehouses WHERE id IN (1, 4, 6);
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (id INT, name VARCHAR(255), transaction_volume DECIMAL(10, 2)); INSERT INTO digital_assets (id, name, transaction_volume) VALUES (1, 'Asset 1', 1000.50), (2, 'Asset 2', 1500.25), (3, 'Asset 3', 2000.00); CREATE TABLE transactions (id INT, digital_asset_id INT, transaction_date DATE); INSERT ...
What's the total transaction volume for digital assets in the last month?
SELECT SUM(transaction_volume) FROM digital_assets JOIN transactions ON digital_assets.id = transactions.digital_asset_id WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE HempGarments (id INT, production_cost DECIMAL(5,2), production_location TEXT); INSERT INTO HempGarments (id, production_cost, production_location) VALUES (1, 40.00, 'Europe'), (2, 42.00, 'Europe'), (3, 38.00, 'Asia'), (4, 39.00, 'Europe');
What is the average production cost of garments made with hemp in Europe?
SELECT AVG(production_cost) FROM HempGarments WHERE production_location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID INT, Department VARCHAR(20), TrainingType VARCHAR(20), TrainingHours DECIMAL(10,2), TrainingDate DATE); INSERT INTO EmployeeTraining (EmployeeID, Department, TrainingType, TrainingHours, TrainingDate) VALUES (1, 'IT', 'Diversity and Inclusion', 2.00, '2022-01-15'), (2, 'IT', 'D...
What is the number of diversity and inclusion training hours for each employee in the IT department?
SELECT EmployeeID, Department, SUM(TrainingHours) FROM EmployeeTraining WHERE Department = 'IT' AND TrainingType = 'Diversity and Inclusion' GROUP BY EmployeeID, Department;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerability_resolution_time (id INT, sector VARCHAR(255), severity FLOAT, resolution_date DATE, detection_date DATE); INSERT INTO vulnerability_resolution_time (id, sector, severity, resolution_date, detection_date) VALUES (1, 'education', 8.5, '2021-03-01', '2021-01-15');
What is the average number of days taken to resolve a vulnerability in the education sector, for vulnerabilities with a severity of 8 or higher?
SELECT AVG(DATEDIFF(resolution_date, detection_date)) FROM vulnerability_resolution_time WHERE sector = 'education' AND severity >= 8;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health.campaigns (campaign_id INT, campaign_name VARCHAR(255), country VARCHAR(255)); INSERT INTO mental_health.campaigns (campaign_id, campaign_name, country) VALUES (1, 'End the Stigma', 'Canada'), (2, 'Mental Health Matters', 'USA'), (3, 'Break the Barrier', 'Canada'); CREATE TABLE mental_health....
List all campaigns in Canada and their respective budgets.
SELECT c.campaign_name, cb.budget FROM mental_health.campaigns c INNER JOIN mental_health.campaign_budgets cb ON c.campaign_id = cb.campaign_id WHERE c.country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, age INT, race VARCHAR(255), cultural_competency_trained BOOLEAN); INSERT INTO community_health_workers (worker_id, age, race, cultural_competency_trained) VALUES (1, 35, 'Asian', true), (2, 40, 'Black', false), (3, 45, 'White', true);
What is the number of community health workers who have received cultural competency training by race?
SELECT race, COUNT(worker_id) FROM community_health_workers WHERE cultural_competency_trained = true GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE ev_sales(id INT, manufacturer VARCHAR(20), model VARCHAR(20), year INT, units_sold INT);
What is the market share of electric vehicle manufacturers in Germany for the year 2020?
SELECT manufacturer, 100.0 * SUM(units_sold) / (SELECT SUM(units_sold) FROM ev_sales WHERE year = 2020) AS market_share FROM ev_sales WHERE year = 2020 GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255)); INSERT INTO users (id, country) VALUES (1, 'United States'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil');
How many users are from each country?
SELECT country, COUNT(*) FROM users GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE nd_recycling_programs (city varchar(255), start_year int, end_year int, program_name varchar(255)); INSERT INTO nd_recycling_programs (city, start_year, end_year, program_name) VALUES ('New Delhi', 2015, 2017, 'Paper Recycling'), ('New Delhi', 2018, 2020, 'Plastic Recycling'), ('New Delhi', 2021, 2023, 'Me...
What are the recycling programs implemented in the city of New Delhi between 2015 and 2025?
SELECT program_name FROM nd_recycling_programs WHERE city = 'New Delhi' AND start_year BETWEEN 2015 AND 2025;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (region VARCHAR(50), year INT, capacity INT); INSERT INTO LandfillCapacity (region, year, capacity) VALUES ('North America/East', 2022, 5000000), ('North America/West', 2022, 7000000), ('North America/Central', 2022, 6000000);
What is the total landfill capacity in North America as of 2022, separated by region?
SELECT region, SUM(capacity) FROM LandfillCapacity WHERE year = 2022 AND region IN ('North America/East', 'North America/West', 'North America/Central') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(50), region VARCHAR(50), avg_depth DECIMAL(5,2)); INSERT INTO marine_species (id, name, region, avg_depth) VALUES (1, 'Giant Clam', 'Indian Ocean', 15.00), (2, 'Whale Shark', 'Indian Ocean', 70.00); CREATE TABLE ocean_depth_scale (id INT, name VARCHAR(50), value DECIMAL...
What are the marine species and their average depths in the Indian Ocean?
SELECT marine_species.name, marine_species.avg_depth FROM marine_species INNER JOIN ocean_depth_scale ON marine_species.avg_depth = ocean_depth_scale.value WHERE ocean_depth_scale.name = 'Meters' AND marine_species.region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE community_projects (id INT, name VARCHAR(100), completed INT, country VARCHAR(50)); INSERT INTO community_projects (id, name, completed, country) VALUES (1, 'Projeto X', 1, 'Brazil');
What is the number of community projects in each country that have been completed?
SELECT country, COUNT(*) FROM community_projects WHERE completed = 1 GROUP BY country
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, product VARCHAR(255), severity INT); INSERT INTO vulnerabilities (id, product, severity) VALUES (1, 'ProductA', 5), (2, 'ProductB', 9), (3, 'ProductA', 3);
How many high-severity vulnerabilities exist for each software product?
SELECT product, COUNT(*) as high_severity_vulnerabilities FROM vulnerabilities WHERE severity >= 8 GROUP BY product;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_initiatives ( id INT PRIMARY KEY, region VARCHAR(255), initiative_name VARCHAR(255), initiative_description TEXT, start_date DATE, end_date DATE); INSERT INTO recycling_initiatives (id, region, initiative_name, initiative_description, start_date, end_date) VALUES (1, 'Africa', 'Plastic Bottle Col...
Select active recycling initiatives
SELECT * FROM active_recycling_initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(50), location VARCHAR(50), co2_emissions INT); INSERT INTO factories (id, name, location, co2_emissions) VALUES (1, 'EcoFactory', 'Germany', 100), (2, 'SmartTech', 'France', 120), (3, 'GreenInnovations', 'France', 90);
What is the average CO2 emissions of factories in Germany and France?
SELECT AVG(co2_emissions) FROM factories WHERE location IN ('Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (id INT, site_name VARCHAR(50), region VARCHAR(50), year INT, amount DECIMAL(5, 2)); INSERT INTO Funding (id, site_name, region, year, amount) VALUES (1, 'Site A', 'Region Z', 2017, 25000);
What is the average funding received by heritage sites in 'Region Z' for the last 5 years?
SELECT AVG(amount) FROM Funding WHERE region = 'Region Z' AND year BETWEEN 2017 AND 2021 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, city VARCHAR(50), digital_exhibits_duration INT, visit_year INT); INSERT INTO Visitors (id, city, digital_exhibits_duration, visit_year) VALUES (1, 'Chicago', 150, 2022);
What is the total duration (in minutes) that visitors spent on digital exhibits in Chicago?
SELECT SUM(digital_exhibits_duration) FROM Visitors WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE languages (id INT, language VARCHAR(50), region VARCHAR(50), num_speakers INT);
Add new endangered language to the languages table
INSERT INTO languages (id, language, region, num_speakers) VALUES (5, 'Ainu', 'Japan', 500)
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (id INT, country VARCHAR, timestamp TIMESTAMP, sentiment FLOAT);
What is the distribution of sentiment scores for creative AI applications in different countries?
SELECT country, PERCENT_RANK() OVER (PARTITION BY country ORDER BY timestamp, sentiment) FROM creative_ai;
gretelai_synthetic_text_to_sql
CREATE TABLE CityBudget (BudgetID INT PRIMARY KEY, Department VARCHAR(50), BudgetAmount DECIMAL(10, 2)); INSERT INTO CityBudget (BudgetID, Department, BudgetAmount) VALUES (1, 'Public Works', 250000.00), (2, 'Education', 750000.00), (3, 'Parks and Recreation', 150000.00), (4, 'Police', 600000.00), (5, 'Fire', 550000.00...
Which departments have a budget over $500,000?
SELECT Department FROM CityBudget WHERE BudgetAmount > 500000.00;
gretelai_synthetic_text_to_sql