context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE researchers (id INT, name VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO researchers (id, name, sector, funding) VALUES (1, 'Alice', 'genetic research', 2000000), (2, 'Bob', 'bioprocess engineering', 1500000), (3, 'Charlie', 'genetic research', 2500000);
Who are the top 2 researchers with the most funding in the 'genetic research' sector?
SELECT name FROM researchers WHERE sector = 'genetic research' ORDER BY funding DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimelineByHalf (ProjectID int, Region varchar(20), Half int, OnTime bit); INSERT INTO ProjectTimelineByHalf (ProjectID, Region, Half, OnTime) VALUES (1, 'Southern', 1, 1), (2, 'Northern', 1, 0), (3, 'Southern', 1, 1);
Calculate the percentage of projects completed on time, in the Southern region, for the first half of 2021.
SELECT Region, PERCENTAGE(SUM(OnTime) OVER (PARTITION BY Region) / COUNT(*) OVER (PARTITION BY Region)) as PercentageOnTime FROM ProjectTimelineByHalf WHERE Region = 'Southern' AND Half = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (DishID INT, Name VARCHAR(50), WastePercentage DECIMAL(3,2), LocallySourced BOOLEAN); INSERT INTO Dishes (DishID, Name, WastePercentage, LocallySourced) VALUES (1, 'Chicken Curry', 0.35, FALSE), (2, 'Vegetable Lasagna', 0.25, TRUE), (3, 'Fish Tacos', 0.40, FALSE);
Which menu items have a high waste percentage and are not locally sourced?
SELECT Name FROM Dishes WHERE WastePercentage > 0.3 AND LocallySourced = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (product_id INT, product_name VARCHAR(50), category VARCHAR(50)); INSERT INTO shariah_compliant_finance (product_id, product_name, category) VALUES (1, 'Musharakah', 'Profit and Loss Sharing'), (2, 'Ijarah', 'Leasing'), (3, 'Murabahah', 'Cost Plus'), (4, 'Takaful', 'Insurance');
List all Shariah-compliant financial products and their respective categories, ordered by product name.
SELECT product_name, category FROM shariah_compliant_finance ORDER BY product_name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), cultural_competency_score INT); INSERT INTO community_health_workers (id, name, cultural_competency_score) VALUES (1, 'John Doe', 90), (2, 'Jane Smith', 85);
Which community health workers have the highest cultural competency score?
SELECT name, cultural_competency_score, RANK() OVER (ORDER BY cultural_competency_score DESC) as rank FROM community_health_workers;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (region VARCHAR(255), year INT, total_consumption INT); INSERT INTO water_usage (region, year, total_consumption) VALUES ('North', 2018, 5000), ('North', 2019, 5500), ('South', 2018, 6000), ('South', 2019, 6500); CREATE TABLE drought_info (region VARCHAR(255), year INT, severity INT); INSERT INTO drought_info (region, year, severity) VALUES ('North', 2018, 3), ('North', 2019, 5), ('South', 2018, 2), ('South', 2019, 4);
What is the total water consumption in regions with severe droughts in 2019?
SELECT SUM(w.total_consumption) FROM water_usage w JOIN drought_info d ON w.region = d.region WHERE w.year = 2019 AND d.severity = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_generators (country VARCHAR(20), capacity FLOAT); INSERT INTO solar_generators (country, capacity) VALUES ('Italy', 1000.0), ('Italy', 1500.0), ('Italy', 2000.0);
What is the minimum installed capacity (in MW) of solar energy generators in Italy?
SELECT MIN(capacity) FROM solar_generators WHERE country = 'Italy';
gretelai_synthetic_text_to_sql
CREATE TABLE chilean_farms (farmer_id INT, farm_location TEXT, farming_method TEXT, biomass FLOAT); INSERT INTO chilean_farms (farmer_id, farm_location, farming_method, biomass) VALUES (1, 'Santiago', 'Offshore cages', 300.4), (2, 'Valparaiso', 'Flow-through', 250.0), (3, 'Concepcion', 'Offshore cages', 400.5);
What is the total biomass of fish in Chilean farms that grow fish in offshore cages?
SELECT SUM(biomass) FROM chilean_farms WHERE farming_method = 'Offshore cages';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (initiative_id INT, initiative_name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE);
List all smart city initiatives in the USA with their respective start dates and end dates.
SELECT initiative_name, start_date, end_date FROM smart_cities WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE daily_visitor_count (date DATE, exhibition_id INT, visitor_count INT); INSERT INTO daily_visitor_count (date, exhibition_id, visitor_count) VALUES ('2022-01-01', 5, 200);
What is the minimum number of visitors for the "Photography" exhibition in the first quarter of 2022?
SELECT MIN(visitor_count) FROM daily_visitor_count WHERE exhibition_id = 5 AND date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO space_missions (id, mission_name, start_date, end_date) VALUES (1, 'Apollo 11', '1969-07-16', '1969-07-24'), (2, 'Mars Rover', '2004-01-04', '2019-02-13'), (3, 'Apollo 13', '1970-04-11', '1970-04-17');
What is the total duration (in days) of each space mission?
SELECT mission_name, DATEDIFF(end_date, start_date) OVER (PARTITION BY mission_name) as TotalDuration FROM space_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, technology VARCHAR(20), region VARCHAR(50), investment_amount INT); INSERT INTO network_investments (investment_id, technology, region, investment_amount) VALUES (1, '4G', 'North', 10000), (2, '5G', 'North', 20000), (3, '3G', 'South', 15000), (4, '5G', 'East', 25000), (5, 'Fiber', 'West', 40000), (6, 'Cable', 'West', 20000), (7, 'DSL', 'East', 18000), (8, 'Fiber', 'North', 50000);
List the regions that have invested in Fiber network infrastructure, and the respective investment amounts.
SELECT technology, region, investment_amount FROM network_investments WHERE technology = 'Fiber';
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation_projects (id INT, project_name VARCHAR(50), budget FLOAT); INSERT INTO agricultural_innovation_projects (id, project_name, budget) VALUES (1, 'Drip Irrigation', 250000.00), (2, 'Livestock Genetics', 320000.00), (3, 'Crop Sensors', 400000.00);
Which agricultural innovation projects have a budget greater than the average budget in the 'agricultural_innovation_projects' table?
SELECT project_name FROM agricultural_innovation_projects WHERE budget > (SELECT AVG(budget) FROM agricultural_innovation_projects);
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (id INT, plant_id INT, incident_date DATE); CREATE TABLE manufacturing_plants (id INT, plant_name VARCHAR(100), country VARCHAR(50)); INSERT INTO manufacturing_plants (id, plant_name, country) VALUES (1, 'Nigeria Plant 1', 'Nigeria'), (2, 'Nigeria Plant 2', 'Nigeria'); INSERT INTO safety_incidents (id, plant_id, incident_date) VALUES (1, 1, '2018-01-01'), (2, 1, '2018-05-15'), (3, 2, '2018-12-28');
How many safety incidents occurred in chemical manufacturing plants in Nigeria in the year 2018?
SELECT COUNT(*) FROM safety_incidents JOIN manufacturing_plants ON safety_incidents.plant_id = manufacturing_plants.id WHERE manufacturing_plants.country = 'Nigeria' AND EXTRACT(YEAR FROM incident_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS defense_security;CREATE TABLE IF NOT EXISTS defense_security.Intelligence_Agencies (id INT PRIMARY KEY, agency_name VARCHAR(255), location VARCHAR(255), budget INT);INSERT INTO defense_security.Intelligence_Agencies (id, agency_name, location, budget) VALUES (1, 'Central Intelligence Agency (CIA)', 'Virginia', 15000000000);
Show me the average budget of intelligence agencies in the 'Intelligence_Agencies' table.
SELECT AVG(budget) FROM defense_security.Intelligence_Agencies;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (Employee_ID INT PRIMARY KEY, First_Name VARCHAR(30), Last_Name VARCHAR(30), Department VARCHAR(30), Salary DECIMAL(10, 2)); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Salary) VALUES (1, 'Kevin', 'Garcia', 'Finance', 70000.00); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Salary) VALUES (2, 'Lucy', 'Gonzalez', 'Finance', 75000.00);
What is the highest salary for an employee in the Finance department?
SELECT MAX(Salary) FROM Employees WHERE Department = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_conditions (condition_id INT, name VARCHAR(255), description VARCHAR(255)); CREATE TABLE patients (patient_id INT, age INT, gender VARCHAR(10), condition VARCHAR(255), ethnicity VARCHAR(255)); CREATE TABLE therapy_sessions (session_id INT, patient_id INT, therapist_id INT, session_date DATE); CREATE TABLE communities (community_id INT, name VARCHAR(255), type VARCHAR(255));
What is the most common mental health condition treated in the last 12 months in Pacific Islander community and the average age of patients with this condition?
SELECT mental_health_conditions.name, AVG(patients.age) FROM patients JOIN therapy_sessions ON patients.patient_id = therapy_sessions.patient_id JOIN mental_health_conditions ON patients.condition = mental_health_conditions.condition JOIN communities ON patients.community_id = communities.community_id WHERE communities.type = 'Pacific Islander' AND therapy_sessions.session_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY patients.condition ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (SiteID INT, Pollutant VARCHAR(50), AmountDecimal FLOAT, Measurement VARCHAR(50), Date DATE, AllowedLimitDecimal FLOAT); ALTER TABLE MineSites ADD CONSTRAINT FK_SiteID FOREIGN KEY (SiteID) REFERENCES EnvironmentalImpact(SiteID);
Identify mine sites where mercury pollution exceeds the allowed limit.
SELECT MineSites.Name, EnvironmentalImpact.Pollutant, EnvironmentalImpact.AmountDecimal FROM MineSites JOIN EnvironmentalImpact ON MineSites.SiteID = EnvironmentalImpact.SiteID WHERE EnvironmentalImpact.Pollutant = 'Mercury' AND EnvironmentalImpact.AmountDecimal > EnvironmentalImpact.AllowedLimitDecimal;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish VARCHAR(50), category VARCHAR(50));CREATE TABLE orders (order_id INT, dish_id INT, price DECIMAL(5,2));
What is the total revenue for each dish category?
SELECT c.category, SUM(o.price) as total_revenue FROM dishes d JOIN orders o ON d.dish_id = o.dish_id GROUP BY c.category;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_institutions (institution_id INT, institution_name TEXT, region TEXT);CREATE TABLE loans (loan_id INT, institution_id INT, loan_amount DECIMAL, is_socially_responsible BOOLEAN);
What is the total amount of socially responsible loans issued by financial institutions in the Asia Pacific region?
SELECT SUM(loan_amount) FROM loans JOIN financial_institutions ON loans.institution_id = financial_institutions.institution_id WHERE is_socially_responsible = TRUE AND region = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_trainings (region VARCHAR(50), trainings INT); INSERT INTO cultural_competency_trainings (region, trainings) VALUES ('Northeast', 300), ('Southeast', 250), ('Midwest', 200), ('Southwest', 180), ('West', 350);
Delete all cultural competency trainings for the Midwest?
DELETE FROM cultural_competency_trainings WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (provider_id INT, name TEXT, state TEXT, cultural_competency_score INT); INSERT INTO healthcare_providers (provider_id, name, state, cultural_competency_score) VALUES (1, 'Ms. Emily Davis', 'TX'), (2, 'Mr. Jose Garcia', 'TX');
Calculate the percentage of healthcare providers with low cultural competency scores.
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM healthcare_providers) AS percentage FROM healthcare_providers WHERE cultural_competency_score < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE MakeupProducts (product_id INT, product_name VARCHAR(100), category VARCHAR(50), vegan BOOLEAN); CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(100), product_id INT);
List all vegan makeup products and their respective suppliers.
SELECT MakeupProducts.product_name, Suppliers.supplier_name FROM MakeupProducts INNER JOIN Suppliers ON MakeupProducts.product_id = Suppliers.product_id WHERE MakeupProducts.vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_players (player_id INT, player_name VARCHAR(50), position VARCHAR(50), team VARCHAR(50));
Delete the record of the athlete with 'athlete_id' 152 from the 'baseball_players' table
DELETE FROM baseball_players WHERE player_id = 152;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, country_code CHAR(2)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE);
Find the daily average transaction amount for the top 10 customers with the highest transaction values in Q1 2022?
SELECT AVG(transaction_amount) FROM (SELECT transaction_amount FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY customer_id ORDER BY SUM(transaction_amount) DESC LIMIT 10) AS top_customers;
gretelai_synthetic_text_to_sql
CREATE TABLE shipwrecks (name VARCHAR(255), location VARCHAR(255));
What is the total number of shipwrecks in the Caribbean Sea?
SELECT COUNT(*) FROM shipwrecks WHERE location = 'Caribbean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralClinicA (patient_id INT, age INT, gender VARCHAR(10)); INSERT INTO RuralClinicA (patient_id, age, gender) VALUES (1, 45, 'Female'), (2, 60, 'Female'), (3, 35, 'Male');
Update the age of patient 3 in 'RuralClinicA' to 40
UPDATE RuralClinicA SET age = 40 WHERE patient_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, Country TEXT, Attendees INT); INSERT INTO Events (EventID, Country, Attendees) VALUES (1, 'Spain', 200), (2, 'France', 300), (3, 'Spain', 250);
What is the average number of attendees per event in Spain?
SELECT AVG(Attendees) FROM Events WHERE Country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE ClinicalTrials (trial_id INT, drug_name VARCHAR(255), trial_status VARCHAR(255)); INSERT INTO ClinicalTrials (trial_id, drug_name, trial_status) VALUES (1, 'DrugA', 'Completed'), (2, 'DrugA', 'Failed'), (3, 'DrugB', 'Completed'), (4, 'DrugC', 'In Progress');
How many clinical trials were conducted for each drug in the 'ClinicalTrials' table, unpivoted and with a total row?
SELECT drug_name, 'trial_count' as metric, COUNT(*) as value FROM ClinicalTrials GROUP BY drug_name UNION ALL SELECT 'Total', COUNT(*) as value FROM ClinicalTrials;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_cars (year INT, make VARCHAR(50), model VARCHAR(50), horsepower INT); INSERT INTO sports_cars (year, make, model, horsepower) VALUES (2015, 'Ferrari', '488 GTB', 661), (2016, 'Lamborghini', 'Huracan', 602), (2017, 'McLaren', '720S', 710), (2018, 'Porsche', '911 GT2 RS', 690);
What is the average horsepower of sports cars released between 2015 and 2018?
SELECT AVG(horsepower) FROM sports_cars WHERE year BETWEEN 2015 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (id INT, name VARCHAR(255), rating INT, category VARCHAR(255)); INSERT INTO cosmetics (id, name, rating, category) VALUES (1, 'Lip Balm 1', 1, 'Lip Balm'), (2, 'Lip Balm 2', 5, 'Lip Balm'), (3, 'Lip Balm 3', 3, 'Lip Balm'), (4, 'Lip Balm 4', 4, 'Lip Balm');
Update the rating of all lip balms to 3
UPDATE cosmetics SET rating = 3 WHERE category = 'Lip Balm';
gretelai_synthetic_text_to_sql
CREATE TABLE mine_productivity (company VARCHAR(255), state VARCHAR(255), year INT, total_tons FLOAT, employees INT); INSERT INTO mine_productivity (company, state, year, total_tons, employees) VALUES ('ABC Mining', 'Colorado', 2015, 250000, 500), ('ABC Mining', 'Colorado', 2016, 275000, 550), ('DEF Mining', 'Wyoming', 2015, 300000, 600), ('DEF Mining', 'Wyoming', 2016, 325000, 650);
What is the total tons of minerals extracted and the average number of employees for each company in each state?
SELECT company, state, SUM(total_tons) as total_tons, AVG(employees) as avg_employees FROM mine_productivity GROUP BY company, state;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT, revenue FLOAT, date DATE); INSERT INTO Dispensaries (id, name, state, revenue, date) VALUES (1, 'Dispensary A', 'OR', 250000.00, '2021-01-01'), (2, 'Dispensary B', 'OR', 300000.00, '2021-02-01'), (3, 'Dispensary C', 'OR', 150000.00, '2021-03-01'), (4, 'Dispensary D', 'OR', 400000.00, '2021-04-01'), (5, 'Dispensary E', 'OR', 200000.00, '2021-01-01');
What was the total revenue for each dispensary in Oregon, broken down by quarter in 2021?
SELECT name, DATE_TRUNC('quarter', date) AS quarter, SUM(revenue) FROM Dispensaries WHERE state = 'OR' GROUP BY name, quarter ORDER BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, state VARCHAR(20)); INSERT INTO green_buildings (id, state) VALUES (1, 'New York'), (2, 'California');
Retrieve the number of green buildings in the state of New York.
SELECT COUNT(*) FROM green_buildings WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), City VARCHAR(50), State VARCHAR(50), Capacity INT); INSERT INTO Warehouses (WarehouseID, WarehouseName, City, State, Capacity) VALUES (1, 'Warehouse A', 'Los Angeles', 'CA', 60000), (2, 'Warehouse B', 'Dallas', 'TX', 80000), (3, 'Warehouse C', 'Miami', 'FL', 40000);
Find the total capacity of warehouses in California and Texas.
SELECT SUM(Capacity) FROM Warehouses WHERE State IN ('CA', 'TX');
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ai (hotel_id INT, hotel_name TEXT, ai_adoption_date DATE); INSERT INTO hotel_ai (hotel_id, hotel_name, ai_adoption_date) VALUES (1, 'Hotel Asia', '2021-12-15'), (2, 'Hotel Asia', '2022-02-01');
Number of hotel adoptions of AI in 'Asia' since 2020?
SELECT COUNT(*) FROM hotel_ai WHERE ai_adoption_date >= '2020-01-01' AND hotel_name IN (SELECT hotel_name FROM hotels WHERE hotel_location = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name VARCHAR(100), organization_id INT, cause VARCHAR(50), hours DECIMAL(5, 2)); CREATE TABLE organizations (id INT, name VARCHAR(100), mission_area VARCHAR(50), state VARCHAR(50)); INSERT INTO volunteers VALUES (1, 'James Smith', 3, 'Art and Culture', 25); INSERT INTO volunteers VALUES (2, 'Emily Johnson', 4, 'Environment', 22);
List all volunteers who have contributed more than 20 hours in total, along with their corresponding organization names and the causes they supported, for mission areas Art and Culture and Environment.
SELECT v.name, o.name as organization_name, v.cause, SUM(v.hours) as total_hours FROM volunteers v INNER JOIN organizations o ON v.organization_id = o.id WHERE o.mission_area IN ('Art and Culture', 'Environment') GROUP BY v.name, v.organization_id, v.cause HAVING SUM(v.hours) > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE Peacekeeping_Operations (Nation VARCHAR(50), Continent VARCHAR(50), Personnel INT); INSERT INTO Peacekeeping_Operations (Nation, Continent, Personnel) VALUES ('Australia', 'Asia-Pacific', 1500), ('Indonesia', 'Asia-Pacific', 2000), ('Japan', 'Asia-Pacific', 1750);
What is the minimum number of personnel contributed to peacekeeping operations by countries in the Asia-Pacific region?
SELECT MIN(Personnel) FROM Peacekeeping_Operations WHERE Continent = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Farming (location VARCHAR(50), crop VARCHAR(50), yield INT, timestamp TIMESTAMP);
What is the total yield of apples in Washington in the past year?
SELECT SUM(yield) FROM Farming WHERE location = 'Washington' AND crop = 'apples' AND timestamp > NOW() - INTERVAL '1 year';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(255), country VARCHAR(255));CREATE TABLE extraction (company_id INT, mineral VARCHAR(255), amount INT);
Which minerals were extracted in quantities greater than 500 tons by companies that have mining operations in Russia?
SELECT DISTINCT e.mineral FROM extraction e JOIN company c ON e.company_id = c.id WHERE c.country = 'Russia' AND e.amount > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT, city VARCHAR(50), organization VARCHAR(50), type VARCHAR(50), year INT); INSERT INTO community_engagement (id, city, organization, type, year) VALUES (1, 'City M', 'Organization A', 'Cultural Festival', 2018), (2, 'City N', 'Organization B', 'Language Workshop', 2019), (3, 'City O', 'Organization C', 'Art Exhibition', 2020);
Remove the 'community_engagement' record for 'City M' from the 'community_engagement' table
DELETE FROM community_engagement WHERE city = 'City M';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name TEXT, ocean TEXT); CREATE VIEW marine_protected_areas_count AS SELECT ocean, COUNT(*) FROM marine_protected_areas GROUP BY ocean;
What percentage of marine protected areas are in the Indian ocean?
SELECT 100.0 * SUM(CASE WHEN ocean = 'Indian' THEN 1 ELSE 0 END) / (SELECT COUNT(*) FROM marine_protected_areas_count) FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (material VARCHAR(255), year INT, rate FLOAT); INSERT INTO recycling_rates (material, year, rate) VALUES ('Plastic', 2019, 12.0), ('Glass', 2019, 22.0), ('Paper', 2019, 35.0), ('Metal', 2019, 45.0);
What is the recycling rate in percentage for each material type in 2019?
SELECT r.material, AVG(r.rate) as avg_rate FROM recycling_rates r WHERE r.year = 2019 GROUP BY r.material;
gretelai_synthetic_text_to_sql
CREATE TABLE government_spending (state VARCHAR(20), category VARCHAR(20), amount INT); INSERT INTO government_spending (state, category, amount) VALUES ('New York', 'Healthcare', 180000000), ('California', 'Healthcare', 250000000), ('Texas', 'Healthcare', 220000000), ('Florida', 'Healthcare', 160000000), ('Pennsylvania', 'Healthcare', 140000000);
List all states and their respective percentage of total government spending on healthcare.
SELECT state, ROUND(100.0*SUM(CASE WHEN category = 'Healthcare' THEN amount ELSE 0 END)/SUM(amount), 1) AS healthcare_percentage FROM government_spending GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name TEXT, country TEXT); INSERT INTO founders (id, name, country) VALUES (1, 'John Doe', 'USA'); INSERT INTO founders (id, name, country) VALUES (2, 'Jane Smith', 'Canada'); INSERT INTO founders (id, name, country) VALUES (3, 'Alice', 'India'); INSERT INTO founders (id, name, country) VALUES (4, 'Bob', 'USA');
Find the number of unique founders from each country.
SELECT country, COUNT(DISTINCT name) FROM founders GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Grants (GrantID INT, OrganizationID INT, Country TEXT, GrantYear INT); CREATE TABLE Organizations (OrganizationID INT, OrganizationName TEXT); INSERT INTO Grants (GrantID, OrganizationID, Country, GrantYear) VALUES (1, 1, 'France', 2018), (2, 2, 'Germany', 2019), (3, 1, 'France', 2020); INSERT INTO Organizations (OrganizationID, OrganizationName) VALUES (1, 'Greenpeace'), (2, 'Doctors Without Borders');
How many organizations received grants in France and Germany between 2018 and 2020?
SELECT COUNT(DISTINCT o.OrganizationID) FROM Grants g JOIN Organizations o ON g.OrganizationID = o.OrganizationID WHERE g.Country IN ('France', 'Germany') AND g.GrantYear BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers(id INT, region VARCHAR(10)); CREATE TABLE usage(subscriber_id INT, usage_date DATE, data_usage INT);
Which broadband subscribers in the Southeast region have had the most usage in the past year?
SELECT subscribers.id, SUM(usage.data_usage) as total_usage FROM subscribers JOIN usage ON subscribers.id = usage.subscriber_id WHERE subscribers.region = 'Southeast' AND usage.usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY subscribers.id ORDER BY total_usage DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA CityData; CREATE TABLE CitySatisfaction (Service varchar(255), Year int, Satisfaction int); INSERT INTO CitySatisfaction (Service, Year, Satisfaction) VALUES ('Public Transportation', 2022, 7), ('Public Transportation', 2022, 8), ('Waste Management', 2022, 9), ('Waste Management', 2022, 6);
What is the average citizen satisfaction rating for public transportation and waste management services combined, in the 'CityData' schema's 'CitySatisfaction' table, for the year 2022?
SELECT AVG(Satisfaction) FROM CityData.CitySatisfaction WHERE Year = 2022 AND Service IN ('Public Transportation', 'Waste Management');
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, shipment_type VARCHAR(10), revenue DECIMAL(10,2)); INSERT INTO shipments (id, shipment_type, revenue) VALUES (1, 'domestic', 500.00), (2, 'international', 800.00), (3, 'expedited', 1000.00);
What is the total revenue generated from expedited shipments?
SELECT SUM(revenue) FROM shipments WHERE shipment_type = 'expedited';
gretelai_synthetic_text_to_sql
CREATE TABLE product_pricing(id INT, product_name VARCHAR(50), price FLOAT, product_category VARCHAR(50), supplier_country VARCHAR(30)); INSERT INTO product_pricing(id, product_name, price, product_category, supplier_country) VALUES (2, 'Moisturizer', 35.00, 'Skincare', 'Canada');
What is the maximum price of a skincare product in Canada?
SELECT MAX(price) FROM product_pricing WHERE product_category = 'Skincare' AND supplier_country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, gender TEXT, years_of_experience INT); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount INT);
What is the total billing amount for cases handled by attorneys who identify as female and have at least 5 years of experience?
SELECT SUM(cases.billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.gender = 'female' AND attorneys.years_of_experience >= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE AstronautMissions (country TEXT, astronaut TEXT, num_missions INTEGER); INSERT INTO AstronautMissions (country, astronaut, num_missions) VALUES ('USA', 'John Glenn', 2), ('USA', 'Neil Armstrong', 2), ('USA', 'Mae Jemison', 1), ('Russia', 'Yuri Gagarin', 1), ('China', 'Yang Liwei', 1), ('India', 'Rakesh Sharma', 1);
What is the average number of missions per astronaut for each country?
SELECT country, AVG(num_missions) FROM AstronautMissions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Routes (id INT, route VARCHAR(50), distance INT, timestamp DATE); INSERT INTO Routes (id, route, distance, timestamp) VALUES (1, 'LA-NY', 2500, '2021-08-01'), (2, 'NY-LA', 2500, '2021-08-02'), (3, 'Chicago-Houston', 1500, '2021-08-03'), (4, 'Houston-Chicago', 1500, '2021-08-04'), (5, 'Seattle-Miami', 3500, '2021-08-05');
List the routes with the longest average distance for shipments in August 2021
SELECT route, AVG(distance) FROM Routes WHERE timestamp BETWEEN '2021-08-01' AND '2021-08-31' GROUP BY route ORDER BY AVG(distance) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_patents (id INT PRIMARY KEY, patent_name VARCHAR(50), inventor VARCHAR(50), filing_date DATE, country VARCHAR(50)); INSERT INTO ai_patents (id, patent_name, inventor, filing_date, country) VALUES (1, 'Neural Network Patent', 'Charlie', '2022-01-01', 'USA'), (2, 'Reinforcement Learning Patent', 'Diana', '2023-02-15', 'Canada'), (3, 'Explainable AI Patent', 'Eli', '2022-07-01', 'Germany');
Who are the inventors of patents filed in 'Germany' and when were the patents filed?
SELECT inventor, filing_date FROM ai_patents WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (id INT, project_name VARCHAR(20), project_location VARCHAR(20), project_type VARCHAR(20)); INSERT INTO climate_projects (id, project_name, project_location, project_type) VALUES (1, 'Communication Project 1', 'Sub-Saharan Africa', 'Climate Communication'), (2, 'Mitigation Project 1', 'Asia', 'Climate Mitigation'), (3, 'Communication Project 2', 'Sub-Saharan Africa', 'Climate Communication');
Delete all records related to climate communication projects in Sub-Saharan Africa from the climate_projects table.
DELETE FROM climate_projects WHERE project_location = 'Sub-Saharan Africa' AND project_type = 'Climate Communication';
gretelai_synthetic_text_to_sql
CREATE TABLE flu_vaccinations (patient_id INT, location VARCHAR(20)); INSERT INTO flu_vaccinations (patient_id, location) VALUES (1, 'Rural'); INSERT INTO flu_vaccinations (patient_id, location) VALUES (2, 'Urban');
What is the total number of flu vaccinations administered in rural areas?
SELECT COUNT(*) FROM flu_vaccinations WHERE location = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-02'), (3, 3, '2022-02-01'), (4, 4, '2022-03-01');
How many unique users posted content in each month?
SELECT MONTH(post_date), COUNT(DISTINCT user_id) FROM posts GROUP BY MONTH(post_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(100), Nationality VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Francisco Goya', 'Spanish'); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (2, 'M.F. Husain', 'Indian'); CREATE TABLE ArtWorks (ArtWorkID INT PRIMARY KEY, Title VARCHAR(100), YearCreated INT, ArtistID INT, FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)); INSERT INTO ArtWorks (ArtWorkID, Title, YearCreated, ArtistID) VALUES (1, 'Saturn Devouring His Son', 1823, 1); INSERT INTO ArtWorks (ArtWorkID, Title, YearCreated, ArtistID) VALUES (2, 'Horses and Tiger', 1960, 2);
List artworks by artists from India or Spain, excluding those created before 1900.
SELECT ArtWorks.Title FROM ArtWorks INNER JOIN Artists ON ArtWorks.ArtistID = Artists.ArtistID WHERE Artists.Nationality IN ('Indian', 'Spanish') AND ArtWorks.YearCreated > 1900;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, state TEXT, country TEXT); INSERT INTO clients (client_id, state, country) VALUES (1, 'Toronto', 'Canada'), (2, 'Miami', 'USA'), (3, 'Vancouver', 'Canada'); CREATE TABLE cases (case_id INT, client_id INT, opened_date DATE); INSERT INTO cases (case_id, client_id, opened_date) VALUES (1, 1, '2022-04-01'), (2, 1, '2022-06-15'), (3, 2, '2021-12-31');
How many cases were opened in Q2 2022 for clients in Ontario, Canada?
SELECT COUNT(*) FROM cases WHERE client_id IN (SELECT client_id FROM clients WHERE country = 'Canada' AND state = 'Toronto') AND opened_date >= '2022-04-01' AND opened_date < '2022-07-01'
gretelai_synthetic_text_to_sql
CREATE TABLE matches (id INT, game VARCHAR(10), player VARCHAR(50), kills INT, deaths INT, match_date DATE); INSERT INTO matches (id, game, player, kills, deaths, match_date) VALUES (1, 'Call of Duty', 'John', 30, 10, '2022-06-15');
Find the top 3 players with the highest number of kills in 'Call of Duty' matches in the last month.
SELECT player, SUM(kills) AS total_kills FROM (SELECT player, kills, ROW_NUMBER() OVER (PARTITION BY player ORDER BY kills DESC, match_date DESC) rn FROM matches WHERE game = 'Call of Duty' AND match_date >= DATEADD(month, -1, GETDATE())) sub WHERE rn <= 3 GROUP BY player;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name VARCHAR(50)); CREATE TABLE cargo_equipment (id INT, port_id INT, type VARCHAR(50), quantity INT);
Find the total number of cargo handling equipment across all ports.
SELECT SUM(quantity) FROM cargo_equipment;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (id INT, name TEXT, category TEXT, rating INT); INSERT INTO dapps (id, name, category, rating) VALUES (11, 'App5', 'Social Networking', 80);
What is the regulatory rating for 'App5' in the 'Social Networking' category?
SELECT rating FROM dapps WHERE name = 'App5';
gretelai_synthetic_text_to_sql
CREATE TABLE construction_hours (worker_id INT, city VARCHAR(20), hours_worked INT, work_date DATE); INSERT INTO construction_hours (worker_id, city, hours_worked, work_date) VALUES (1, 'Mumbai', 8, '2020-01-01'); INSERT INTO construction_hours (worker_id, city, hours_worked, work_date) VALUES (2, 'Mumbai', 10, '2021-01-03');
Show the total construction hours worked in 'Mumbai' for the month of 'January' in 2020 and 2021.
SELECT SUM(hours_worked) FROM construction_hours WHERE city = 'Mumbai' AND EXTRACT(MONTH FROM work_date) = 1 AND (EXTRACT(YEAR FROM work_date) = 2020 OR EXTRACT(YEAR FROM work_date) = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, name VARCHAR(255)); INSERT INTO excavation_sites (id, name) VALUES (1, 'Site X');
What are the artifact types and their quantities from site X?
SELECT artifact_type, COUNT(*) FROM artifacts JOIN excavation_sites ON artifacts.excavation_site_id = excavation_sites.id
gretelai_synthetic_text_to_sql
CREATE TABLE legal_technology_patents (patent_id INT, year INT, gender VARCHAR(10)); INSERT INTO legal_technology_patents (patent_id, year, gender) VALUES (1, 2020, 'Female'), (2, 2019, 'Male'), (3, 2018, 'Female'), (4, 2017, 'Female'), (5, 2016, 'Male');
How many legal technology patents were granted to women-led teams in the past 5 years?
SELECT COUNT(*) FROM legal_technology_patents WHERE gender = 'Female' AND year >= 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Cultural_Events (id INT, city VARCHAR(50), attendance INT); CREATE VIEW Tokyo_Events AS SELECT * FROM Cultural_Events WHERE city = 'Tokyo';
What is the maximum number of visitors at a cultural event in Tokyo?
SELECT MAX(attendance) FROM Tokyo_Events;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, program VARCHAR(20), score INT); INSERT INTO student_mental_health (student_id, program, score) VALUES (1, 'remote_learning', 75), (2, 'remote_learning', 80), (3, 'in_person', 85), (4, 'in_person', 90);
What is the minimum mental health score for students in the 'in_person' program?
SELECT MIN(score) FROM student_mental_health WHERE program = 'in_person';
gretelai_synthetic_text_to_sql
CREATE TABLE epl_players (player_id INT, player_name VARCHAR(50), nationality VARCHAR(50), team_name VARCHAR(50));
Which soccer players in the 'epl_players' table are from England?
SELECT player_name FROM epl_players WHERE nationality = 'England';
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, ota_name VARCHAR(25), region VARCHAR(20));
Create a table named 'otas' to store data about online travel agencies
CREATE TABLE otas (ota_id INT, ota_name VARCHAR(25), region VARCHAR(20));
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerationByContinent (continent VARCHAR(255), year INT, waste_quantity INT); INSERT INTO WasteGenerationByContinent (continent, year, waste_quantity) VALUES ('Asia', 2022, 1500000), ('Africa', 2022, 1200000), ('Europe', 2022, 1800000); CREATE TABLE RecyclingRatesByContinent (continent VARCHAR(255), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRatesByContinent (continent, year, recycling_rate) VALUES ('Asia', 2022, 0.45), ('Africa', 2022, 0.55), ('Europe', 2022, 0.65);
What is the total waste generation and recycling rate for each continent in the year 2022?
SELECT wg.continent, wg.year, wg.waste_quantity, rr.recycling_rate FROM WasteGenerationByContinent wg INNER JOIN RecyclingRatesByContinent rr ON wg.continent = rr.continent WHERE wg.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionCosts (id INT, garment_id INT, material VARCHAR(20), cost DECIMAL(5,2));CREATE TABLE Garments (id INT, name VARCHAR(50)); INSERT INTO ProductionCosts (id, garment_id, material, cost) VALUES (1, 1001, 'organic_cotton', 25.99), (2, 1002, 'organic_cotton', 22.49), (3, 1003, 'recycled_polyester', 18.99); INSERT INTO Garments (id, name) VALUES (1001, 'Eco T-Shirt'), (1002, 'Green Sweater'), (1003, 'Circular Hoodie');
What is the average production cost of garments in the 'organic_cotton' material?
SELECT AVG(cost) FROM ProductionCosts JOIN Garments ON ProductionCosts.garment_id = Garments.id WHERE material = 'organic_cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, units_sold INT); INSERT INTO sales (sale_id, product_id, sale_date, units_sold) VALUES (1, 1, '2022-01-01', 200), (2, 2, '2022-01-02', 150), (3, 3, '2022-01-03', 250), (4, 1, '2022-01-04', 300), (5, 2, '2022-01-05', 120), (6, 3, '2022-01-06', 270), (7, 1, '2022-01-07', 280), (8, 2, '2022-01-08', 180), (9, 3, '2022-01-09', 300), (10, 1, '2022-01-10', 350);
How many units of each product were sold in the top 10 best-selling days?
SELECT product_id, SUM(units_sold) AS total_units_sold FROM (SELECT product_id, sale_date, units_sold, ROW_NUMBER() OVER (ORDER BY units_sold DESC) AS sale_rank FROM sales) AS top_sales WHERE sale_rank <= 10 GROUP BY product_id;
gretelai_synthetic_text_to_sql
CREATE SCHEMA uk_ireland_schema;CREATE TABLE uk_ireland_schema.hospitals (country VARCHAR(20), hospital_type VARCHAR(20), num_hospitals INT);INSERT INTO uk_ireland_schema.hospitals (country, hospital_type, num_hospitals) VALUES ('United Kingdom', 'Public Hospitals', 6000), ('Ireland', 'Public Hospitals', 1000);
Find the number of public hospitals in the United Kingdom and Ireland.
SELECT country, num_hospitals FROM uk_ireland_schema.hospitals WHERE (country = 'United Kingdom' OR country = 'Ireland') AND hospital_type = 'Public Hospitals';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category VARCHAR(50), billing_amount INT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Civil Litigation', 7000);
Display the minimum billing amount for cases in the 'Personal Injury' category
SELECT MIN(billing_amount) FROM cases WHERE category = 'Personal Injury';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_orgs (id INT, name VARCHAR(255), city VARCHAR(255)); INSERT INTO cultural_orgs (id, name, city) VALUES (1, 'Louvre Museum', 'Paris'), (2, 'Pompidou Centre', 'Paris'), (3, 'Versailles Palace', 'Paris'); CREATE TABLE events (id INT, org_id INT, attendees INT); INSERT INTO events (id, org_id, attendees) VALUES (1, 1, 15000), (2, 1, 12000), (3, 2, 8000), (4, 3, 7000), (5, 3, 6000);
What is the average attendance at events organized by cultural organizations in Paris?
SELECT AVG(e.attendees) FROM events e JOIN cultural_orgs o ON e.org_id = o.id WHERE o.city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(255), recycling_rate FLOAT); INSERT INTO recycling_rates (country, recycling_rate) VALUES ('Poland', 0.42), ('Czech Republic', 0.38), ('Romania', 0.20);
What is the recycling rate for Eastern Europe?
SELECT AVG(recycling_rate) FROM recycling_rates WHERE country IN ('Poland', 'Czech Republic', 'Romania');
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_programs (id INT, program_name VARCHAR(255), client_gender VARCHAR(10), date DATE);
How many financial capability programs were offered to female clients in Q3 2021?
SELECT COUNT(*) FROM financial_capability_programs WHERE client_gender = 'female' AND date BETWEEN '2021-07-01' AND '2021-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), is_fraudulent BOOLEAN); INSERT INTO transactions (id, customer_id, amount, is_fraudulent) VALUES (1, 1, 100.00, true), (2, 2, 200.00, false), (3, 3, 300.00, false);
What is the total number of fraudulent transactions in the past month?
SELECT COUNT(*) FROM transactions WHERE is_fraudulent = true AND transaction_date >= CURRENT_DATE - INTERVAL '1 month';
gretelai_synthetic_text_to_sql
CREATE TABLE r_d_expenditure (drug_name TEXT, expenditure INTEGER, approval_year TEXT); INSERT INTO r_d_expenditure (drug_name, expenditure, approval_year) VALUES ('Drug1', 3000, 'Year1'), ('Drug2', 4000, 'Year2'), ('Drug3', 5000, 'Year2'), ('Drug4', 6000, 'Year3');
What are the total R&D expenditures for all drugs approved in 'Year2'?
SELECT SUM(expenditure) FROM r_d_expenditure WHERE approval_year = 'Year2';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (brand TEXT, category TEXT, revenue FLOAT); INSERT INTO Revenue (brand, category, revenue) VALUES ('BrandA', 'Women''s Clothing', 50000), ('BrandB', 'Men''s Clothing', 35000), ('BrandC', 'Women''s Clothing', 60000), ('BrandD', 'Women''s Clothing', 45000);
Find the top 3 fashion brands with the highest revenue in the women's clothing category.
SELECT brand, SUM(revenue) as total_revenue FROM Revenue WHERE category = 'Women''s Clothing' GROUP BY brand ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, sector VARCHAR(255)); INSERT INTO security_incidents (id, sector) VALUES (1, 'finance'), (2, 'retail');
What is the total number of security incidents in the 'finance' sector?
SELECT COUNT(*) FROM security_incidents WHERE sector = 'finance';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (city VARCHAR(20), year INT, initiatives INT); INSERT INTO circular_economy (city, year, initiatives) VALUES ('Toronto', 2019, 5), ('Montreal', 2019, 4), ('Vancouver', 2019, 6), ('Calgary', 2019, 3), ('Ottawa', 2019, 5);
What is the number of circular economy initiatives by city in Canada in 2019?
SELECT city, SUM(initiatives) as total_initiatives FROM circular_economy WHERE year = 2019 GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE social_good_providers (provider VARCHAR(20), region VARCHAR(20), impact FLOAT); INSERT INTO social_good_providers (provider, region, impact) VALUES ('Tech for Good Africa', 'Africa', 7.50), ('Ashoka Africa', 'Africa', 8.20), ('Social Tech Trust Africa', 'Africa', 8.00);
Who are the top 2 technology providers for social good in Africa?
SELECT provider FROM social_good_providers WHERE region = 'Africa' ORDER BY impact DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, type TEXT, date DATE); INSERT INTO accommodations (id, student_id, type, date) VALUES (1, 4, 'screen reader', '2022-04-01'); INSERT INTO accommodations (id, student_id, type, date) VALUES (2, 5, 'note taker', '2022-05-01');
How many students with visual impairments have utilized screen readers as accommodations in the past year?
SELECT COUNT(DISTINCT student_id) FROM accommodations WHERE type = 'screen reader' AND date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) AND EXISTS (SELECT * FROM students WHERE students.id = accommodations.student_id AND students.disability = 'visual impairment');
gretelai_synthetic_text_to_sql
CREATE TABLE CountryInfo (Country VARCHAR(20), HeritageSites INT, CommunityEvents INT); INSERT INTO CountryInfo VALUES ('Brazil', 5, 3), ('Argentina', 2, 1); CREATE TABLE HeritageSites (Country VARCHAR(20), SiteName VARCHAR(30)); INSERT INTO HeritageSites VALUES ('Brazil', 'Iguazu Falls'), ('Argentina', 'Perito Moreno Glacier'); CREATE TABLE CommunityEngagement (Country VARCHAR(20), EventName VARCHAR(30)); INSERT INTO CommunityEngagement VALUES ('Brazil', 'Carnival'), ('Argentina', 'Tango Festival');
Display community engagement events and heritage sites in each country.
SELECT i.Country, h.SiteName, e.EventName FROM CountryInfo i JOIN HeritageSites h ON i.Country = h.Country JOIN CommunityEngagement e ON i.Country = e.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE social_impact_investments (id INT, country VARCHAR(50), category VARCHAR(50), transaction_value FLOAT); INSERT INTO social_impact_investments (id, country, category, transaction_value) VALUES (1, 'United States', 'ESG1', 5000.0), (2, 'Canada', 'ESG2', 7000.0), (3, 'United Kingdom', 'ESG1', 10000.0), (4, 'Germany', 'ESG3', 3000.0); CREATE TABLE esg_categories (id INT, category VARCHAR(50)); INSERT INTO esg_categories (id, category) VALUES (1, 'ESG1'), (2, 'ESG2'), (3, 'ESG3');
What is the average transaction value for social impact investments in specific countries and ESG categories?
SELECT AVG(transaction_value) FROM social_impact_investments WHERE country IN ('United States', 'Canada') AND category IN ('ESG1', 'ESG2')
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, city VARCHAR(50), country VARCHAR(50)); INSERT INTO Warehouse (id, city, country) VALUES (1, 'Hong Kong', 'China'); CREATE TABLE Shipment (id INT, quantity INT, warehouse_id INT, destination_country VARCHAR(50)); INSERT INTO Shipment (id, quantity, warehouse_id, destination_country) VALUES (1, 500, 1, 'USA');
What is the total quantity of items shipped from Hong Kong to the USA?
SELECT SUM(quantity) FROM Shipment INNER JOIN Warehouse ON Shipment.warehouse_id = Warehouse.id WHERE Warehouse.city = 'Hong Kong' AND Shipment.destination_country = 'USA';
gretelai_synthetic_text_to_sql
use rural_health; CREATE TABLE staff (id int, name text, title text, state text); INSERT INTO staff (id, name, title, state) VALUES (1, 'Dr. John', 'Doctor', 'MO'); INSERT INTO staff (id, name, title, state) VALUES (2, 'Nurse Lisa', 'Nurse', 'MO'); INSERT INTO staff (id, name, title, state) VALUES (3, 'Dr. Mark', 'Doctor', 'KS');
List the total count of doctors and nurses in each state?
SELECT title, COUNT(*) as total, state FROM rural_health.staff GROUP BY state, title;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), game_id INT, kills_per_game DECIMAL(10, 2)); INSERT INTO players (id, name, country, game_id, kills_per_game) VALUES (1, 'Player1', 'Japan', 1, 12.5), (2, 'Player2', 'Japan', 1, 15.0), (3, 'Player3', 'USA', 1, 18.0);
What is the average number of kills per game for players from Japan in the game "Call of Duty"?
SELECT AVG(kills_per_game) FROM players WHERE country = 'Japan' AND game_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genomic Solutions', 'USA', 5000000), (2, 'BioTech Innovations', 'Europe', 7000000), (3, 'Medical Innovations', 'UK', 6000000), (4, 'Innovative Biotech', 'India', 8000000), (5, 'BioGenesis', 'France', 9000000);
What is the total funding received by biotech startups located in France?
SELECT SUM(funding) FROM startups WHERE location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255)); CREATE TABLE returns (id INT PRIMARY KEY, product_id INT, customer_id INT, return_date DATE, FOREIGN KEY (product_id) REFERENCES products(id), FOREIGN KEY (customer_id) REFERENCES customers(id)); CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), is_ethical BOOLEAN, FOREIGN KEY (category) REFERENCES categories(name)); CREATE TABLE categories (name VARCHAR(255) PRIMARY KEY); CREATE VIEW returned_ethical_clothing AS SELECT customers.name AS customer_name, SUM(quantity) AS total_returned_quantity FROM returns JOIN products ON returns.product_id = products.id JOIN categories ON products.category = categories.name WHERE categories.name = 'Clothing' AND products.is_ethical = TRUE GROUP BY customers.name;
Who are the top 5 customers with the highest total quantity of returns for ethically produced clothing items?
SELECT customer_name, total_returned_quantity FROM returned_ethical_clothing ORDER BY total_returned_quantity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Incidents (IncidentID INT PRIMARY KEY, IncidentType VARCHAR(50), ResponseTime INT);
Delete all records in the 'Incidents' table where the 'IncidentType' is 'TrafficAccident' and the 'ResponseTime' is greater than 120 minutes
DELETE FROM Incidents WHERE IncidentType = 'TrafficAccident' AND ResponseTime > 120;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity(city VARCHAR(20), year INT, capacity INT); INSERT INTO landfill_capacity VALUES('Rio de Janeiro', 2022, 600000);
Delete the record of landfill capacity for the city of Rio de Janeiro in 2022.
DELETE FROM landfill_capacity WHERE city = 'Rio de Janeiro' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStock (farm_id INT, date DATE, action VARCHAR(10), quantity INT); INSERT INTO FarmStock (farm_id, date, action, quantity) VALUES (2, '2020-01-01', 'added', 300), (2, '2020-01-05', 'added', 250);
How many fish were added to the Salmon farm each month in 2020?
SELECT EXTRACT(MONTH FROM date) month, SUM(quantity) quantity FROM FarmStock WHERE farm_id = 2 AND YEAR(date) = 2020 AND action = 'added' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(50), model VARCHAR(50), year INT, location VARCHAR(50)); INSERT INTO machines (id, name, model, year, location) VALUES (1, 'Machine A', 'Model X', 2015, 'USA'), (2, 'Machine B', 'Model Y', 2017, 'Canada'), (3, 'Machine C', 'Model Z', 2019, 'Mexico');
List all machines located in the USA
SELECT * FROM machines WHERE location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, district_id INT, exam_date DATE, mental_health_score INT); INSERT INTO student_mental_health (student_id, district_id, exam_date, mental_health_score) VALUES (1, 101, '2022-01-01', 85), (2, 101, '2022-02-15', 82), (3, 102, '2022-03-03', 90), (4, 102, '2022-04-07', 92), (5, 103, '2022-05-02', 78);
What is the average mental health score for students who took the exam on or after the 15th day of the month, ordered by district_id and then by the average mental health score?
SELECT district_id, AVG(mental_health_score) as avg_score FROM student_mental_health WHERE DAY(exam_date) >= 15 GROUP BY district_id ORDER BY district_id, avg_score;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50)); INSERT INTO players VALUES (1, 'Amina'); INSERT INTO players VALUES (2, 'Brian'); INSERT INTO players VALUES (3, 'Chloe');
Insert new records for players 'Diana' and 'Eric' with player_ids 4 and 5 respectively in the 'players' table.
INSERT INTO players (player_id, name) VALUES (4, 'Diana'), (5, 'Eric');
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalAssets (AssetId INT, AssetName VARCHAR(50), RegulatorId INT); CREATE TABLE Regulators (RegulatorId INT, RegulatorName VARCHAR(50), Region VARCHAR(50)); INSERT INTO DigitalAssets (AssetId, AssetName, RegulatorId) VALUES (1, 'ETH', 1); INSERT INTO DigitalAssets (AssetId, AssetName, RegulatorId) VALUES (2, 'BTC', 2); INSERT INTO Regulators (RegulatorId, RegulatorName, Region) VALUES (1, 'Regulator1', 'EU'); INSERT INTO Regulators (RegulatorId, RegulatorName, Region) VALUES (2, 'Regulator2', 'US'); INSERT INTO Regulators (RegulatorId, RegulatorName, Region) VALUES (3, 'Regulator3', 'US');
List all digital assets and their regulatory status in the US.
SELECT da.AssetName, r.RegulatorName FROM DigitalAssets da INNER JOIN Regulators r ON da.RegulatorId = r.RegulatorId WHERE r.Region = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS vessel_safety (id INT PRIMARY KEY, vessel_name VARCHAR(255), safety_inspection_date DATE); INSERT INTO vessel_safety (id, vessel_name, safety_inspection_date) VALUES (1, 'SS Great Britain', '2021-03-15'), (2, 'Queen Mary 2', '2021-06-23'), (3, 'Titanic', '2021-09-11'), (4, 'Canberra', '2020-12-10'), (5, 'France', '2020-08-18');
How many safety inspections were performed in 2020 and 2021?
SELECT COUNT(*) FROM vessel_safety WHERE YEAR(safety_inspection_date) IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE samarium_production (id INT, name VARCHAR(255), element VARCHAR(10), country VARCHAR(100), production_date DATE, quantity FLOAT); INSERT INTO samarium_production (id, name, element, country, production_date, quantity) VALUES (1, 'Company A', 'Sm', 'China', '2022-01-01', 800.0), (2, 'Company B', 'Sm', 'Australia', '2022-02-01', 900.0), (3, 'Company C', 'Sm', 'Malaysia', '2022-03-01', 1000.0);
Update the Samarium production quantity to 1000.0 for the row with the latest production date.
UPDATE samarium_production SET quantity = 1000.0 WHERE id = (SELECT id FROM samarium_production WHERE production_date = (SELECT MAX(production_date) FROM samarium_production));
gretelai_synthetic_text_to_sql