context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE SupportPrograms (program_id INT, program_name VARCHAR(255), cost DECIMAL(10, 2)); INSERT INTO SupportPrograms (program_id, program_name, cost) VALUES (2001, 'Buddy Program', 1500.00), (2002, 'Mentorship Program', 2500.00), (2003, 'Tutoring Program', 3500.00), (2004, 'Counseling Program', 4500.00);
What are the total costs of support programs for 'Mentorship Program' and 'Tutoring Program' from the 'SupportPrograms' table?
SELECT SUM(cost) FROM SupportPrograms WHERE program_name IN ('Mentorship Program', 'Tutoring Program');
gretelai_synthetic_text_to_sql
CREATE TABLE FlightSafety(flight_number VARCHAR(10), safety_record INT); INSERT INTO FlightSafety VALUES('BB123', 99),('BB456', 97);
What is the maximum safety record for flights 'BB123' and 'BB456'?
SELECT MAX(safety_record) FROM FlightSafety WHERE flight_number IN ('BB123', 'BB456');
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT, product TEXT, num_employees INT); INSERT INTO mines (id, name, location, production_volume, product, num_employees) VALUES (1, 'Bronze Basin', 'Australia', 8000, 'Bronze', 400);
How many employees work at the 'Bronze Basin' mine?'
SELECT num_employees FROM mines WHERE name = 'Bronze Basin';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(50), data_plan VARCHAR(20), state VARCHAR(50)); INSERT INTO mobile_subscribers (id, name, data_plan, state) VALUES (15, 'Jasmine Smith', 'Limited', 'TX'); INSERT INTO mobile_subscribers (id, name, data_plan, state) VALUES (16, 'Kevin Lewis', 'Limited', 'TX');
How many mobile subscribers are there in Texas with a data plan that is not unlimited?
SELECT COUNT(*) FROM mobile_subscribers WHERE data_plan != 'Unlimited' AND state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE SmartCities (CityID INT, CityName VARCHAR(255), InitiativeName VARCHAR(255), StartDate DATE); INSERT INTO SmartCities (CityID, CityName, InitiativeName, StartDate) VALUES (1, 'City B', 'Smart Grid Initiative', '2020-01-01');
List all smart city initiatives in 'City B' with their respective start dates.
SELECT CityName, InitiativeName, StartDate FROM SmartCities WHERE CityName = 'City B';
gretelai_synthetic_text_to_sql
CREATE TABLE flu_shots (patient_id INT, shot_date DATE, state VARCHAR(2)); INSERT INTO flu_shots (patient_id, shot_date, state) VALUES (1, '2020-11-05', 'IL'), (2, '2020-12-10', 'IL');
How many patients have not received a flu shot in Illinois as of December 2020?
SELECT COUNT(*) - (SELECT COUNT(*) FROM flu_shots WHERE state = 'IL' AND MONTH(shot_date) <= 12 AND YEAR(shot_date) = 2020) AS num_no_flu_shot FROM flu_shots WHERE state = 'IL';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_mortgages (mortgage_id INT, customer_id INT); INSERT INTO shariah_compliant_mortgages (mortgage_id, customer_id) VALUES (1, 4), (2, 5), (3, 6);
How many customers have a Shariah-compliant mortgage?
SELECT COUNT(DISTINCT customer_id) FROM shariah_compliant_mortgages;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(30), location VARCHAR(10), growing_season VARCHAR(10));
How many farmers in the 'urban' area are growing crops in the 'dry' season?
SELECT COUNT(*) FROM farmers WHERE location = 'urban' AND growing_season = 'dry';
gretelai_synthetic_text_to_sql
CREATE TABLE Brown_Investment_Group (id INT, sector VARCHAR(20), risk_score INT); INSERT INTO Brown_Investment_Group (id, sector, risk_score) VALUES (1, 'Agriculture', 50), (2, 'Manufacturing', 40);
What is the maximum risk score of Brown Investment Group's portfolio in the agriculture sector?
SELECT MAX(risk_score) FROM Brown_Investment_Group WHERE sector = 'Agriculture';
gretelai_synthetic_text_to_sql
CREATE TABLE access_to_justice_grants (id INT, organization_name TEXT, city TEXT, state TEXT, award_year INT, grant_amount INT);
Delete all access to justice grants awarded to organizations in Washington D.C. in 2020.
DELETE FROM access_to_justice_grants WHERE state = 'District of Columbia' AND city = 'Washington' AND award_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Flag (flag_id INT PRIMARY KEY, flag_country VARCHAR(255)); INSERT INTO Flag (flag_id, flag_country) VALUES (2, 'Canada'); CREATE TABLE Vessel (vessel_id INT PRIMARY KEY, vessel_name VARCHAR(255), flag_id INT, average_speed DECIMAL(5,2)); CREATE TABLE Region (region_id INT PRIMARY KEY, region_name VARCHAR(2...
What is the average speed of vessels with Canadian flag in the Pacific Ocean?
SELECT AVG(V.average_speed) FROM Vessel V JOIN Flag F ON V.flag_id = F.flag_id JOIN Region R ON V.region_id = R.region_id WHERE F.flag_country = 'Canada' AND R.region_name = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (collection VARCHAR(20), co2_emissions INT); INSERT INTO emissions (collection, co2_emissions) VALUES ('Spring 2022', 15000);
What is the total CO2 emissions for the garment manufacturing process in the 'Spring 2022' collection?
SELECT co2_emissions FROM emissions WHERE collection = 'Spring 2022';
gretelai_synthetic_text_to_sql
CREATE TABLE Contracts (ID INT, Contractor VARCHAR(255), ContractValue FLOAT); INSERT INTO Contracts VALUES (1, 'ABC Company', 2000000), (2, 'XYZ Corporation', 2500000), (3, 'DEF Industries', 3000000), (4, 'ABC Company', 1800000), (5, 'GHI Services', 1500000);
Who are the top 3 contractors with the highest number of contracts?
SELECT Contractor, COUNT(*) OVER (PARTITION BY Contractor) AS ContractCount, RANK() OVER (PARTITION BY NULL ORDER BY COUNT(*) DESC) AS ContractRank FROM Contracts WHERE ContractValue > 1000000 GROUP BY Contractor HAVING ContractCount = (SELECT MAX(ContractCount) FROM Contracts WHERE Contractor = Contracts.Contractor) F...
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (treatment_id INT, treatment_cost FLOAT, treatment_date DATE); INSERT INTO wastewater_treatment (treatment_id, treatment_cost, treatment_date) VALUES (1, 50.2, '2022-01-01'), (2, 60.3, '2022-01-02'), (3, 70.4, '2022-01-03');
Delete the wastewater_treatment record with the lowest treatment_cost value.
DELETE FROM wastewater_treatment WHERE treatment_cost = (SELECT MIN(treatment_cost) FROM wastewater_treatment);
gretelai_synthetic_text_to_sql
CREATE TABLE student_info (student_id INT, name VARCHAR(255)); INSERT INTO student_info (student_id, name) VALUES (1, 'Jane Doe'); INSERT INTO student_info (student_id, name) VALUES (2, 'Jim Smith'); CREATE TABLE student_accommodations (student_id INT, department VARCHAR(255), date DATE); INSERT INTO student_accommodat...
List the names and IDs of students who have received accommodations in both the academic and residential departments.
SELECT s.student_id, s.name FROM student_info s JOIN student_accommodations sa1 ON s.student_id = sa1.student_id JOIN student_accommodations sa2 ON s.student_id = sa2.student_id WHERE sa1.department <> sa2.department AND sa1.department IN ('Academic', 'Residential') GROUP BY s.student_id, s.name HAVING COUNT(DISTINCT s...
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, country VARCHAR(50), type VARCHAR(50), budget INT); INSERT INTO projects (id, country, type, budget) VALUES (1, 'Argentina', 'Precision Agriculture', 50000), (2, 'Brazil', 'Drip Irrigation', 75000);
What is the total number of agricultural innovation projects and their budgets for each South American country?
SELECT country, COUNT(*), SUM(budget) FROM projects WHERE country IN ('Argentina', 'Brazil', 'Chile', 'Colombia', 'Peru') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (id INT, system VARCHAR(255), organizations INT); INSERT INTO indigenous_food_systems (id, system, organizations) VALUES (1, 'Navajo', 30), (2, 'Cherokee', 40), (3, 'Maya', 50), (4, 'Maori', 60);
Which indigenous food systems have the most community-based organizations in the 'indigenous_food_systems' table?
SELECT system, organizations FROM indigenous_food_systems ORDER BY organizations DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_category VARCHAR(50), sale_date DATE, region VARCHAR(50), revenue DECIMAL(10, 2)); INSERT INTO sales (id, product_category, sale_date, region, revenue) VALUES (1, 'Electronics', '2022-01-05', 'Southeast', 5000.00), (2, 'Fashion', '2022-03-10', 'Southeast', 6000.00);
What is the highest selling product category in Q1 2022 for the Southeast region?
SELECT product_category, MAX(revenue) FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND region = 'Southeast' GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID int, EventName varchar(100), EventDate date, VenueName varchar(100)); INSERT INTO Events (EventID, EventName, EventDate, VenueName) VALUES (1, 'Concert A', '2019-01-01', 'Symphony Hall'), (2, 'Concert B', '2019-12-31', 'Symphony Hall'), (3, 'Play X', '2018-12-31', 'Symphony Hall');
What is the total number of concerts held at Symphony Hall in 2019?
SELECT COUNT(*) FROM Events WHERE VenueName = 'Symphony Hall' AND YEAR(EventDate) = 2019 AND EventName LIKE 'Concert%';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_panels (id INT, name VARCHAR(255), efficiency FLOAT); INSERT INTO solar_panels (id, name, efficiency) VALUES (1, 'SolarPanel A', 18.5), (2, 'SolarPanel B', 20.3), (3, 'SolarPanel C', 21.0), (4, 'SolarPanel D', 19.1);
What is the name and efficiency of the solar panel with the highest efficiency in Japan?
SELECT name, MAX(efficiency) FROM solar_panels WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(255), last_active DATE); INSERT INTO employees (id, name, last_active) VALUES (1, 'John Doe', '2016-01-01'), (2, 'Jane Smith', '2021-02-01'), (3, 'Bob Johnson', '2018-05-01');
Delete all the records in the table of government employees who have not been active for the past 5 years.
DELETE FROM employees WHERE last_active < NOW() - INTERVAL '5 years';
gretelai_synthetic_text_to_sql
CREATE TABLE basketball_matches (match_id INT, season INT, tickets_sold INT); INSERT INTO basketball_matches (match_id, season, tickets_sold) VALUES (1, 2018, 35000), (2, 2018, 38000), (3, 2019, 42000);
What is the average number of tickets sold for basketball matches per season?
SELECT AVG(tickets_sold) FROM basketball_matches GROUP BY season;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (strategy_id INT, strategy_name VARCHAR(50), customer_id INT); INSERT INTO investment_strategies (strategy_id, strategy_name, customer_id) VALUES (1, 'Conservative', 1), (2, 'Aggressive', 2); CREATE TABLE investment_accounts (account_id INT, customer_id INT, balance DECIMAL(10, 2)); I...
What is the total assets under management for a specific investment strategy?
SELECT SUM(investment_accounts.balance) FROM investment_accounts JOIN investment_strategies ON investment_accounts.customer_id = investment_strategies.customer_id WHERE investment_strategies.strategy_name = 'Conservative';
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, order_date DATE, region VARCHAR(50)); CREATE TABLE order_details (order_id INT, menu_id INT, quantity_sold INT); CREATE TABLE menu (menu_id INT, menu_name VARCHAR(255), is_spicy BOOLEAN, price DECIMAL(5,2)); INSERT INTO orders (order_id, order_date, region) VALUES (1, '2022-01-01', 'E...
Show the number of spicy menu items sold in the East region.
SELECT SUM(quantity_sold) as total_sold FROM order_details od JOIN menu m ON od.menu_id = m.menu_id WHERE is_spicy = TRUE AND region = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE mars_rovers_temperatures (rover_name TEXT, temperature FLOAT); INSERT INTO mars_rovers_temperatures (rover_name, temperature) VALUES ('Spirit', 20.5), ('Opportunity', 15.2), ('Curiosity', 10.1);
What is the difference in temperature between the hottest and coldest Mars Rovers?
SELECT MAX(temperature) - MIN(temperature) as temperature_difference FROM mars_rovers_temperatures;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health (id INT, student_id INT, program VARCHAR(50), score INT); INSERT INTO mental_health (id, student_id, program, score) VALUES (1, 1001, 'Lifelong Learning', 70), (2, 1002, 'Lifelong Learning', 75), (3, 1003, 'Lifelong Learning', 60), (4, 1004, 'Traditional Program', 80);
What is the minimum mental health score for students in the lifelong learning program?
SELECT MIN(score) as min_score FROM mental_health WHERE program = 'Lifelong Learning';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies(id INT, name TEXT, funding_amount INT); CREATE TABLE Executives(id INT, company_id INT, gender TEXT); INSERT INTO Companies VALUES (1, 'TechCo', 5000000), (2, 'GreenTech', 7000000); INSERT INTO Executives VALUES (1, 1, 'Female'), (2, 1, 'Female'), (3, 1, 'Male'), (4, 2, 'Female'), (5, 2, 'F...
What is the average funding amount for companies with at least 3 female executives?
SELECT AVG(Companies.funding_amount) FROM Companies INNER JOIN (SELECT company_id FROM Executives WHERE gender = 'Female' GROUP BY company_id HAVING COUNT(*) >= 3) AS FemaleExecs ON Companies.id = FemaleExecs.company_id;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, employment_status VARCHAR(50), gender VARCHAR(10)); INSERT INTO employees (id, name, department, salary, employment_status, gender) VALUES (1, 'John Doe', 'IT', 75000.0, 'Full-time', 'Male'), (2, 'Jane Smith', 'IT', 80000.0, 'Part-t...
What is the percentage of employees in each department who are female?
SELECT departments.name, (COUNT(CASE WHEN employees.gender = 'Female' THEN 1 END) * 100.0 / COUNT(employees.id)) AS percentage FROM departments INNER JOIN employees ON departments.name = employees.department GROUP BY departments.name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, plan_name TEXT); CREATE TABLE broadband_subscribers (subscriber_id INT, plan_name TEXT);
How many unique subscribers have both mobile and broadband plans?
SELECT COUNT(DISTINCT mobile_subscribers.subscriber_id) FROM mobile_subscribers INNER JOIN broadband_subscribers ON mobile_subscribers.subscriber_id = broadband_subscribers.subscriber_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(30)); CREATE TABLE properties (id INT, city VARCHAR(20), green_certified BOOLEAN); INSERT INTO cities (id, name) VALUES (1, 'Seattle'), (2, 'Portland'), (3, 'Vancouver'); INSERT INTO properties (id, city, green_certified) VALUES (101, 'Seattle', true), (102, 'Seattle', false), ...
Find the number of green-certified buildings in each city.
SELECT cities.name, COUNT(properties.id) FROM cities INNER JOIN properties ON cities.name = properties.city WHERE properties.green_certified = true GROUP BY cities.name;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, region TEXT, life_expectancy INT); INSERT INTO countries (id, name, region, life_expectancy) VALUES (1, 'Japan', 'Asia', 85); INSERT INTO countries (id, name, region, life_expectancy) VALUES (2, 'India', 'Asia', 69);
What is the life expectancy in each country in the Asian region?
SELECT name, region, life_expectancy FROM countries WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (chemical VARCHAR(20), score INT); INSERT INTO environmental_impact (chemical, score) VALUES ('chemical B', 60); INSERT INTO environmental_impact (chemical, score) VALUES ('chemical B', 70);
What is the average environmental impact score for chemical B?
SELECT avg(score) as avg_score FROM environmental_impact WHERE chemical = 'chemical B';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (ingredient VARCHAR(255), quantity INT, organic BOOLEAN); INSERT INTO inventory (ingredient, quantity, organic) VALUES ('Flour', 1000, FALSE), ('Tomatoes', 2000, TRUE), ('Cheese', 3000, FALSE);
What is the inventory level for each organic ingredient used in the menu?
SELECT ingredient, quantity FROM inventory WHERE organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicHousing (Ward text, ConstructionDate date); INSERT INTO PublicHousing (Ward, ConstructionDate) VALUES ('Ward1', '2020-01-01'), ('Ward2', '2021-01-01');
How many public housing units were constructed in each ward for the last 2 years?
SELECT Ward, COUNT(*) as Units, DATE_TRUNC('year', ConstructionDate) as Year FROM PublicHousing WHERE ConstructionDate >= DATEADD(year, -2, CURRENT_DATE) GROUP BY Ward, Year;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(30)); INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (1, 'John Doe', 35, 'Male', 'Caucasian', 'Non-Hispanic');
Update an existing patient record in the patients table.
UPDATE patients SET age = 36 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, name TEXT, rating FLOAT, country TEXT, implementation_date DATE); INSERT INTO projects (project_id, name, rating, country, implementation_date) VALUES (1, 'Solar Farm', 1.8, 'Germany', '2020-01-01'), (2, 'Wind Turbine', 2.2, 'France', '2019-01-01'), (3, 'Geothermal Plant', 2.0, 'G...
What is the average energy efficiency rating for renewable energy projects implemented in the last two years by country?
SELECT country, AVG(rating) FROM projects WHERE implementation_date >= DATEADD(year, -2, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE tourist_visits (id INT, country TEXT, visit_date DATE); INSERT INTO tourist_visits (id, country, visit_date) VALUES (1, 'Spain', '2022-01-01');
How many tourists visited Spain in the last year, broken down by month?
SELECT DATE_TRUNC('month', visit_date) AS month, COUNT(*) FROM tourist_visits WHERE country = 'Spain' AND visit_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE Sales (id INT, dispensary_id INT, weight DECIMAL, sale_date DATE, product_type TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Washington'); INSERT INTO Sales (id, dispensary_id, weight, sale_date, product_type) VALUES ...
What is the total weight of cannabis flower sold by dispensaries in Washington in Q2 2022?
SELECT SUM(s.weight) FROM Dispensaries d INNER JOIN Sales s ON d.id = s.dispensary_id WHERE d.state = 'Washington' AND s.product_type = 'flower' AND s.sale_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Threat_Intelligence ( id INT, threat_type VARCHAR(30), created_date DATE ); INSERT INTO Threat_Intelligence (id, threat_type, created_date) VALUES (1, 'Cyber Threat', '2022-01-01'), (2, 'Physical Threat', '2022-02-01'), (3, 'Cyber Threat', '2022-05-01');
How many threat intelligence records were created in the last week?
SELECT COUNT(*) FROM Threat_Intelligence WHERE created_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT PRIMARY KEY, GameName VARCHAR(50), GamingCommunity VARCHAR(50)); CREATE TABLE GameSessions (SessionID INT PRIMARY KEY, GameName VARCHAR(50), Playtime MINUTE, FOREIGN KEY (GameName) REFERENCES Games(GameName)); INSERT INTO Games (GameID, GameName, GamingCommunity) VALUES (1, 'WorldOfWarcra...
What is the total playtime (in minutes) for each game in the "PCGamingCommunity"?
SELECT GameName, SUM(Playtime) FROM GameSessions JOIN Games ON GameSessions.GameName = Games.GameName WHERE Games.GamingCommunity = 'PCGamingCommunity' GROUP BY GameName;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_levels (location TEXT, pollution_level INTEGER); INSERT INTO pollution_levels (location, pollution_level) VALUES ('Gulf of Mexico', 5000), ('Mariana Trench', 8000), ('Atlantic Ocean', 2000);
Update the pollution_level for 'Mariana Trench' to 9000.
UPDATE pollution_levels SET pollution_level = 9000 WHERE location = 'Mariana Trench';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (equipment_type VARCHAR(255), maintenance_cost DECIMAL(10,2), maintenance_incident_date DATE);
List the military equipment types that had the highest maintenance costs per incident in 2020
SELECT equipment_type, AVG(maintenance_cost) AS avg_cost_per_incident FROM equipment_maintenance WHERE EXTRACT(YEAR FROM maintenance_incident_date) = 2020 GROUP BY equipment_type ORDER BY avg_cost_per_incident DESC
gretelai_synthetic_text_to_sql
CREATE TABLE shuttle_missions (id INT, shuttle VARCHAR(255), flight_hours INT); INSERT INTO shuttle_missions (id, shuttle, flight_hours) VALUES (1, 'Atlantis', 4848), (2, 'Columbia', 3005);
What is the sum of flight hours for all Space Shuttle missions?
SELECT SUM(flight_hours) FROM shuttle_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE artists_rio (artist_id INT, name VARCHAR(50), city VARCHAR(50), pieces INT);
Find the number of artists who have created more pieces than the average number of pieces created by artists in Rio de Janeiro.
SELECT COUNT(*) FROM artists_rio WHERE pieces > (SELECT AVG(pieces) FROM artists_rio WHERE city = 'Rio de Janeiro');
gretelai_synthetic_text_to_sql
CREATE TABLE educational_institutions (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO educational_institutions (id, name, type, location) VALUES (1, 'School A', 'Primary School', 'City X'), (2, 'University B', 'University', 'City Y'); CREATE TABLE medical_facilities (id INT, name VARC...
What is the total number of educational institutions and medical facilities in 'disaster_response' database?
SELECT COUNT(*) FROM educational_institutions UNION ALL SELECT COUNT(*) FROM medical_facilities;
gretelai_synthetic_text_to_sql
CREATE TABLE gym_locations (id INT, location_name VARCHAR(50), state VARCHAR(50), city VARCHAR(50), members INT);
How many members have an active membership in each state?
SELECT state, COUNT(DISTINCT member_name) AS active_members FROM gym_locations JOIN gym_memberships ON gym_locations.location_name = gym_memberships.location WHERE end_date > CURDATE() GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50)); INSERT INTO vessels (vessel_id, vessel_name) VALUES (1, 'Vessel1'), (2, 'Vessel2'), (3, 'Vessel3'); CREATE TABLE port_visits (visit_id INT, vessel_id INT, port_id INT); INSERT INTO port_visits (visit_id, vessel_id, port_id) VALUES (1, 1, 1), (2, 2, 2), (3, ...
List the names of all vessels that have visited port 'NY'
SELECT DISTINCT vessel_name FROM vessels v JOIN port_visits pv ON v.vessel_id = pv.vessel_id WHERE pv.port_id = (SELECT port_id FROM ports WHERE port_name = 'NY');
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (farmer_id INT, name TEXT, location TEXT, crop_yield INT, year INT); INSERT INTO farmers (farmer_id, name, location, crop_yield, year) VALUES (1, 'John Doe', 'Smithville', 500, 2020); INSERT INTO farmers (farmer_id, name, location, crop_yield, year) VALUES (2, 'Jane Smith', 'Brownfield', 600, 2020)...
What was the average crop yield in 2020 for farmers in the 'rural_development' schema?
SELECT AVG(crop_yield) FROM farmers WHERE year = 2020 AND location LIKE 'rural_development%';
gretelai_synthetic_text_to_sql
CREATE TABLE JusticeTechnologyGrants (ID INT, GrantID VARCHAR(20), JusticeDistrict VARCHAR(20), Amount INT, Year INT); INSERT INTO JusticeTechnologyGrants (ID, GrantID, JusticeDistrict, Amount, Year) VALUES (1, 'JTG2015', 'North Valley', 15000, 2015), (2, 'JTG2016', 'South Peak', 20000, 2016), (3, 'JTG2017', 'East Rive...
How many justice technology grants were awarded to organizations in each justice district?
SELECT JusticeDistrict, COUNT(*) FROM JusticeTechnologyGrants GROUP BY JusticeDistrict;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (name VARCHAR(255), visitor_count INT, accommodation_spend DECIMAL(10,2)); INSERT INTO Country (name, visitor_count, accommodation_spend) VALUES ('Canada', 15000, 85.67), ('France', 20000, 70.54);
What is the average international visitor spending on accommodation per day in Canada and France?
SELECT AVG(accommodation_spend) FROM Country WHERE name IN ('Canada', 'France')
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, state VARCHAR(255), year INT, number_of_crimes INT); INSERT INTO crimes (id, state, year, number_of_crimes) VALUES (1, 'Texas', 2020, 150000), (2, 'California', 2020, 200000);
How many crimes were reported in the state of Texas in 2020?
SELECT SUM(number_of_crimes) FROM crimes WHERE state = 'Texas' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, founding_year INT, founder_gender TEXT); INSERT INTO startup (id, name, founding_year, founder_gender) VALUES (1, 'Acme Inc', 2010, 'Female'); INSERT INTO startup (id, name, founding_year, founder_gender) VALUES (2, 'Beta Corp', 2015, 'Male'); INSERT INTO startup (id, name, foun...
Identify the earliest founding year among startups with at least one female founder
SELECT MIN(founding_year) FROM startup WHERE founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE resources_depleted (operation_id INT, resource VARCHAR(50), quantity_depleted INT); INSERT INTO resources_depleted (operation_id, resource, quantity_depleted) VALUES (1, 'Coal', 1000), (1, 'Iron Ore', 2000), (2, 'Gold', 500), (2, 'Silver', 1000), (3, 'Copper', 1500);
What is the total amount of resources depleted for each mining operation?
SELECT mining_operations.operation_name, SUM(resources_depleted.quantity_depleted) AS total_resources_depleted FROM mining_operations INNER JOIN resources_depleted ON mining_operations.operation_id = resources_depleted.operation_id GROUP BY mining_operations.operation_name;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (household_id INT, region VARCHAR(255), usage FLOAT, date DATE); INSERT INTO water_usage (household_id, region, usage, date) VALUES (1, 'Los Angeles', 500, '2022-01-01'); INSERT INTO water_usage (household_id, region, usage, date) VALUES (1, 'Los Angeles', 600, '2022-02-01');
What is the average monthly water usage per household in the Los Angeles region for the past year?
SELECT AVG(usage) FROM (SELECT usage, DATE_TRUNC('month', date) AS month FROM water_usage WHERE region = 'Los Angeles' AND date >= '2021-01-01' AND date < '2022-01-01' GROUP BY month, usage ORDER BY month) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, name TEXT, safety_violation BOOLEAN, union_affiliation TEXT);
Insert new records of workplaces, including safety violations and union affiliations.
INSERT INTO workplaces (id, name, safety_violation, union_affiliation) VALUES (5, 'RST Industries', TRUE, 'Union C'), (6, 'UVW Corporation', FALSE, 'Union D');
gretelai_synthetic_text_to_sql
CREATE TABLE Media (id INT, title VARCHAR(255), type VARCHAR(255), region VARCHAR(255)); INSERT INTO Media (id, title, type, region) VALUES (1, 'Content1', 'Video', 'North America'), (2, 'Content2', 'Audio', 'Europe'), (3, 'Content3', 'Video', 'Asia'), (4, 'Content4', 'Text', 'Africa');
What is the distribution of media types by region?
SELECT region, type, COUNT(*) as num_contents FROM Media GROUP BY region, type;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, ProjectName VARCHAR(50), StartDate DATE, EndDate DATE, Region VARCHAR(50)); INSERT INTO Projects (ProjectID, ProjectName, StartDate, EndDate, Region) VALUES (1, 'Project A', '2022-01-01', '2023-12-31', 'Asia-Pacific'), (2, 'Project B', '2022-03-15', '2024-02-28', 'Europe'), (3, 'Pr...
What are the defense projects with a duration of more than 3 years in the European region?
SELECT ProjectName FROM Projects WHERE DATEDIFF(day, StartDate, EndDate) > 1095 AND Region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, name VARCHAR(20), population INT, population_density FLOAT); INSERT INTO regions (region_id, name, population, population_density) VALUES (1, 'Rural', 10000, 25.0), (2, 'Urban', 50000, 200.0); CREATE TABLE hospitals (hospital_id INT, region_id INT, beds INT); INSERT INTO hospitals (...
What is the correlation between the population density and the number of available hospital beds per capita in rural areas?
SELECT correlation(r.population_density, (h.beds + c.beds) / r.population) FROM regions r JOIN hospitals h ON r.region_id = h.region_id JOIN clinics c ON r.region_id = c.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE department_open_pedagogy (department_id INT, project_count INT);
What is the maximum number of open pedagogy projects per department?
SELECT department_id, MAX(project_count) as max_projects FROM department_open_pedagogy;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturing (id INT, garment_type VARCHAR(20), country VARCHAR(20), year INT); INSERT INTO Manufacturing (id, garment_type, country, year) VALUES (1, 'Dress', 'Bangladesh', 2020), (2, 'Shirt', 'Bangladesh', 2020), (3, 'Pant', 'Bangladesh', 2020), (4, 'Dress', 'Bangladesh', 2021);
How many unique garment types were manufactured in Bangladesh in 2020?
SELECT COUNT(DISTINCT garment_type) as unique_garment_types FROM Manufacturing WHERE country = 'Bangladesh' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_state VARCHAR(255)); CREATE TABLE cases (case_id INT, attorney_id INT);
How many cases were handled by attorneys in each state, based on the 'attorney_state' column in the 'attorneys' table?
SELECT a.attorney_state, COUNT(c.case_id) FROM attorneys a INNER JOIN cases c ON a.attorney_id = c.attorney_id GROUP BY a.attorney_state;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, date DATE, severity VARCHAR(10), ip VARCHAR(15), country VARCHAR(30)); INSERT INTO vulnerabilities (id, date, severity, ip, country) VALUES (1, '2021-01-01', 'critical', '192.168.1.100', 'Brazil');
What is the rank of each country based on the number of critical vulnerabilities in the last 60 days?
SELECT country, RANK() OVER (ORDER BY critical_vulnerability_count DESC) as country_rank FROM (SELECT country, COUNT(*) as critical_vulnerability_count FROM vulnerabilities WHERE severity = 'critical' AND date >= (CURRENT_DATE - INTERVAL '60' DAY) GROUP BY country) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_sales (id INT, vehicle_type VARCHAR(20), year INT, quantity INT); INSERT INTO autonomous_sales (id, vehicle_type, year, quantity) VALUES (1, 'autonomous', 2019, 2000), (2, 'autonomous', 2020, 3000), (3, 'autonomous', 2021, 5000);
Calculate the total number of autonomous vehicles sold in 2021
SELECT SUM(quantity) FROM autonomous_sales WHERE vehicle_type = 'autonomous' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, genre VARCHAR(20)); INSERT INTO artists (artist_id, genre) VALUES (1, 'Latin'), (2, 'Pop'), (3, 'Rock'), (4, 'Jazz'), (5, 'Folk'); CREATE TABLE albums (album_id INT, artist_id INT, release_date DATE); INSERT INTO albums (album_id, artist_id, release_date) VALUES (1, 2, '2021-04-12')...
How many albums were released in total by Pop artists in 2021?
SELECT COUNT(albums.album_id) FROM albums INNER JOIN artists ON albums.artist_id = artists.artist_id WHERE artists.genre = 'Pop' AND albums.release_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'), (2, 'Green Line'), (3, 'Blue Line'), (4, 'Yellow Line'); CREATE TABLE fare (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), collection_date DATE); INSERT INTO fare (fare_id, route_id, fare_am...
What is the latest fare collection date for 'Yellow Line'?
SELECT MAX(collection_date) FROM fare WHERE route_id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, location_id INT, item_id INT, quantity INT, date DATE); CREATE TABLE menu (item_id INT, item_name VARCHAR(50), category VARCHAR(50), cuisine VARCHAR(50), price DECIMAL(5,2));
List the most popular dish in each cuisine type.
SELECT menu.cuisine, menu.item_name, SUM(orders.quantity) as total_quantity FROM orders JOIN menu ON orders.item_id = menu.item_id GROUP BY menu.cuisine, menu.item_id ORDER BY total_quantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE pasture_farms (id INT, farm_name VARCHAR(50), state VARCHAR(20), num_animals INT); INSERT INTO pasture_farms (id, farm_name, state, num_animals) VALUES (1, 'Farm 1', 'Wisconsin', 50), (2, 'Farm 2', 'Wisconsin', 75), (3, 'Farm 3', 'Wisconsin', 100), (4, 'Farm 4', 'Wisconsin', 125), (5, 'Farm 5', 'Wisconsin'...
What is the minimum and maximum number of animals on pasture-based farms in Wisconsin?
SELECT state, MIN(num_animals) as min_animals, MAX(num_animals) as max_animals FROM pasture_farms WHERE state = 'Wisconsin';
gretelai_synthetic_text_to_sql
CREATE TABLE games (stadium TEXT, attendance INT); INSERT INTO games (stadium, attendance) VALUES ('Estadio Nacional', 65000), ('Estadio Nacional', 70000), ('Wembley Stadium', 80000);
What is the average attendance for games played at 'Estadio Nacional'?
SELECT AVG(attendance) FROM games WHERE stadium = 'Estadio Nacional';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(5,2), rating DECIMAL(2,1), is_vegan BOOLEAN);
Find the average rating and price of vegan cosmetics
SELECT AVG(price), AVG(rating) FROM products WHERE is_vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_item VARCHAR(30), is_vegetarian BOOLEAN, calorie_count INT); INSERT INTO menu (menu_id, menu_item, is_vegetarian, calorie_count) VALUES (1, 'Vegetable Lasagna', true, 500), (2, 'Beef Burger', false, 800);
What is the total calorie count for vegetarian options?
SELECT SUM(calorie_count) FROM menu WHERE is_vegetarian = true;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE accommodations (id INT PRIMARY KEY, name VARCHAR(255), country_id INT, eco_friendly BOOLEAN);CREATE TABLE reviews (id INT PRIMARY KEY, accommodation_id INT, review TEXT, FOREIGN KEY (accommodation_id) REFERENCES accommodations(id));
What are the names and reviews of eco-friendly accommodations in Canada?
SELECT accommodations.name, reviews.review FROM accommodations JOIN reviews ON accommodations.id = reviews.accommodation_id WHERE accommodations.eco_friendly = true AND accommodations.country_id = (SELECT id FROM countries WHERE name = 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_status (species TEXT, status TEXT);
How many marine species are threatened with extinction?
SELECT COUNT(*) FROM marine_species_status WHERE status = 'Threatened';
gretelai_synthetic_text_to_sql
CREATE TABLE social_media (user_id INT, post_id INT, post_date DATE, likes INT);
What is the maximum number of likes for a single post in the 'social_media' table?
SELECT MAX(likes) FROM social_media;
gretelai_synthetic_text_to_sql
CREATE TABLE Cost (id INT, is_organic BOOLEAN, category VARCHAR(20), price INT); INSERT INTO Cost (id, is_organic, category, price) VALUES (1, true, 'snack', 4), (2, false, 'snack', 6), (3, true, 'dessert', 5);
What is the minimum price for organic snacks?
SELECT MIN(price) FROM Cost WHERE is_organic = true AND category = 'snack';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), StartDate DATE); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, SignUpDate DATE, Hours DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, StartDate) VALUES (1, 'ProgramA', '2023-01-01'), (2, 'ProgramB', '2023-01-01'), (3, 'ProgramC', '2...
What is the average number of volunteer hours per program in 2023, ranked in ascending order?
SELECT p.ProgramName, AVG(v.Hours) AS AvgHoursPerProgram FROM Programs p JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE YEAR(v.SignUpDate) = 2023 GROUP BY p.ProgramName ORDER BY AvgHoursPerProgram ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, State VARCHAR(2), ParityStatus VARCHAR(10));
Create a table named 'MentalHealthParity'
CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, State VARCHAR(2), ParityStatus VARCHAR(10));
gretelai_synthetic_text_to_sql
CREATE TABLE login_attempts (id INT, user_name VARCHAR(255), success BOOLEAN, login_time TIMESTAMP); INSERT INTO login_attempts (id, user_name, success, login_time) VALUES (1, 'user1', false, '2022-06-01 10:00:00'), (2, 'user2', false, '2022-06-02 11:00:00');
Calculate the moving average of failed login attempts, for each user, over the last 7 days.
SELECT user_name, AVG(CASE WHEN success = false THEN 1 ELSE 0 END) OVER (PARTITION BY user_name ORDER BY login_time ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as moving_average FROM login_attempts WHERE login_time >= DATE(NOW()) - INTERVAL '7 days';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, project VARCHAR(50), year INT, budget FLOAT); INSERT INTO defense_projects (id, project, year, budget) VALUES (1, 'Project Z', 2019, 1100000), (2, 'Project Z', 2020, 1300000);
What was the budget for defense project Z in 2019 and 2020?
SELECT project, year, budget FROM defense_projects WHERE project = 'Project Z';
gretelai_synthetic_text_to_sql
CREATE TABLE garages (garage_id INT, garage_name VARCHAR(255)); INSERT INTO garages (garage_id, garage_name) VALUES (1, 'Bronx'), (2, 'Manhattan'), (3, 'Queens'); CREATE TABLE service (service_id INT, garage_id INT, service_date DATE); INSERT INTO service (service_id, garage_id, service_date) VALUES (1, 1, '2021-12-15'...
How many vehicles were serviced in the Queens garage on February 15th, 2022?
SELECT COUNT(*) FROM service WHERE garage_id = 3 AND service_date = '2022-02-15';
gretelai_synthetic_text_to_sql
CREATE TABLE Publications (ID INT, Author VARCHAR(50), Journal VARCHAR(50), Year INT, CitationCount INT); INSERT INTO Publications (ID, Author, Journal, Year, CitationCount) VALUES (1, 'John Doe', 'Journal of Machine Learning', 2021, 50), (2, 'Jane Smith', 'Journal of Mathematics', 2019, 40);
Which author has the most publications in the 'Journal of Machine Learning' in the past three years?
SELECT Author, COUNT(*) AS PublicationCount FROM Publications WHERE Journal = 'Journal of Machine Learning' AND Year >= 2019 GROUP BY Author ORDER BY PublicationCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, city VARCHAR(20)); INSERT INTO hotels (id, city) VALUES (1, 'Tokyo'), (2, 'Osaka'), (3, 'Tokyo');
How many hotels are there in Tokyo?
SELECT COUNT(*) FROM hotels WHERE city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE Geopolitical_Risk_Assessments (country VARCHAR(255), year INT, risk_level INT); INSERT INTO Geopolitical_Risk_Assessments (country, year, risk_level) VALUES ('Egypt', 2022, 3), ('Nigeria', 2022, 5);
Which countries in 'Africa' had geopolitical risk assessments in '2022'?
SELECT DISTINCT country FROM Geopolitical_Risk_Assessments WHERE year = 2022 AND country IN ('Egypt', 'Nigeria', 'South Africa', 'Algeria');
gretelai_synthetic_text_to_sql
CREATE TABLE investigative_reports (article_id INT, article_topic VARCHAR(50), investigation_length INT, publication_date DATE);
What is the distribution of article lengths in 'investigative_reports' table?
SELECT investigation_length, COUNT(*) FROM investigative_reports GROUP BY investigation_length;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT, risk_score FLOAT);
Insert a new company into the 'renewable_energy' sector with id 6, ESG rating 8.5 and risk score 2.0
INSERT INTO companies (id, sector, ESG_rating, risk_score) VALUES (6, 'renewable_energy', 8.5, 2.0);
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (campaign_id INT, name TEXT, condition TEXT, start_date DATE, end_date DATE); INSERT INTO campaigns (campaign_id, name, condition, start_date, end_date) VALUES (1, 'Break the Stigma', 'Depression', '2018-01-01', '2018-12-31'); INSERT INTO campaigns (campaign_id, name, condition, start_date, end_d...
List the names and number of campaigns for public awareness campaigns related to depression, ordered by the number of campaigns in descending order.
SELECT name, COUNT(*) as total FROM campaigns WHERE condition = 'Depression' GROUP BY name ORDER BY total DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO attorneys (attorney_id, name, city) VALUES (1, 'Maria Rodriguez', 'Miami'); CREATE TABLE cases (case_id INT, attorney_id INT, outcome VARCHAR(50)); INSERT INTO cases (case_id, attorney_id, outcome) VALUES (1, NULL, 'Settled'), (2,...
Update the outcome of case #3 to 'Under Appeal' if handled by attorney Maria Rodriguez from the city of Miami.
UPDATE cases SET outcome = 'Under Appeal' WHERE case_id = 3 AND attorney_id IN (SELECT attorney_id FROM attorneys WHERE name = 'Maria Rodriguez' AND city = 'Miami');
gretelai_synthetic_text_to_sql
CREATE TABLE HumanitarianAssistance (Country VARCHAR(50), Year INT, Amount FLOAT); INSERT INTO HumanitarianAssistance (Country, Year, Amount) VALUES ('USA', 2018, 8112000);
What was the total humanitarian assistance provided by the US in 2018?
SELECT Amount FROM HumanitarianAssistance WHERE Country = 'USA' AND Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT);CREATE TABLE policing_events (id INT, district_id INT, year INT, type TEXT);
What is the total number of community policing events held in each district in 2021?
SELECT d.name, COUNT(pe.id) FROM districts d JOIN policing_events pe ON d.id = pe.district_id WHERE pe.year = 2021 GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicHealthPolicies (PolicyID INT, State VARCHAR(20), Year INT, Policy VARCHAR(100)); INSERT INTO PublicHealthPolicies (PolicyID, State, Year, Policy) VALUES (1, 'California', 2020, 'COVID-19 Mask Mandate'); INSERT INTO PublicHealthPolicies (PolicyID, State, Year, Policy) VALUES (2, 'California', 2019, 'F...
How many public health policies were implemented in California in 2020?
SELECT COUNT(*) FROM PublicHealthPolicies WHERE State = 'California' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE solo_exhibitions (id INT, city VARCHAR(20), year INT, artist_origin VARCHAR(30), num_artworks INT); INSERT INTO solo_exhibitions (id, city, year, artist_origin, num_artworks) VALUES (1, 'Berlin', 2018, 'German', 10), (2, 'Berlin', 2019, 'African diaspora', 15), (3, 'Berlin', 2020, 'German', 12), (4, 'Berli...
What is the minimum number of artworks displayed in solo exhibitions by artists from African diaspora in Berlin in the last 3 years?
SELECT MIN(num_artworks) FROM solo_exhibitions WHERE city = 'Berlin' AND artist_origin = 'African diaspora' AND year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistStreams(id INT, artist VARCHAR(20), genre VARCHAR(10), year INT, streams INT);
What is the number of unique artists who have streamed in the "latin" genre for each year?
SELECT year, COUNT(DISTINCT artist) FROM ArtistStreams WHERE genre = 'latin' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, type VARCHAR(50), animals INT); INSERT INTO animal_population (id, type, animals) VALUES (1, 'Forest', 500), (2, 'Savannah', 750), (3, 'Wetlands', 450); CREATE TABLE education (id INT, type VARCHAR(50), programs INT); INSERT INTO education (id, type, programs) VALUES (1, 'Forest'...
What is the total number of animals in all habitats, and how many community education programs are there in total?
SELECT SUM(animals) as total_animals, SUM(programs) as total_programs FROM animal_population, education;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_depths (name VARCHAR(255), basin VARCHAR(255), depth FLOAT); INSERT INTO marine_species_depths (name, basin, depth) VALUES ('Species1', 'Atlantic', 123.45), ('Species2', 'Pacific', 567.89), ('Species3', 'Indian', 345.67), ('Species4', 'Atlantic', 789.10);
What is the maximum depth reached by any marine species in the Atlantic basin?
SELECT MAX(depth) as max_depth FROM marine_species_depths WHERE basin = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (id INT PRIMARY KEY, location VARCHAR(255), pH DECIMAL(3,2), timestamp TIMESTAMP); INSERT INTO ocean_acidification (id, location, pH, timestamp) VALUES (1, 'Pacific Ocean', 7.8, '2021-08-01 12:00:00'), (2, 'Atlantic Ocean', 8.0, '2021-08-02 15:30:00');
Create a view for ocean acidification data
CREATE VIEW ocean_acidification_view AS SELECT * FROM ocean_acidification;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, location VARCHAR(50), type VARCHAR(50), quantity INT, weight FLOAT); INSERT INTO Warehouse (id, location, type, quantity, weight) VALUES (1, 'USA', 'non-perishable', 300, 12.5), (2, 'Canada', 'perishable', 250, 11.0), (3, 'France', 'non-perishable', 500, 13.2), (4, 'Germany', 'perishable...
What is the total weight of perishable items in the Sydney warehouse?
SELECT SUM(weight) FROM Warehouse WHERE location = 'Sydney' AND type = 'perishable';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (name VARCHAR(255), tribe VARCHAR(255), crop VARCHAR(255)); INSERT INTO farmers (name, tribe, crop) VALUES ('Kaew Tawee', 'Karen', 'rice'), ('Nongluck Panya', 'Karen', 'corn'), ('Pinit Duangmanee', 'Karen', 'rice'), ('Thippawan Duangmanee', 'Karen', 'rice'), ('Chanin Tawee', 'Karen', 'cassava');
What is the total number of farmers in the Karen community who grow rice?
SELECT COUNT(*) FROM farmers WHERE tribe = 'Karen' AND crop = 'rice';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_inventory (id INT, make VARCHAR(20), model VARCHAR(20), is_electric BOOLEAN); INSERT INTO vehicle_inventory (id, make, model, is_electric) VALUES (1, 'Tesla', 'Model 3', true), (2, 'Ford', 'Mustang', false), (3, 'Chevrolet', 'Bolt', true);
How many electric vehicles are available in the vehicle_inventory table?
SELECT COUNT(*) FROM vehicle_inventory WHERE is_electric = true;
gretelai_synthetic_text_to_sql
CREATE TABLE agency (id INT, name VARCHAR(255)); INSERT INTO agency (id, name) VALUES (1, 'Transportation'); INSERT INTO agency (id, name) VALUES (2, 'Education'); CREATE TABLE budget (id INT, agency_id INT, year INT, amount INT); INSERT INTO budget (id, agency_id, year, amount) VALUES (1, 1, 2022, 50000); INSERT INTO ...
What is the total budget allocated to each agency in the year 2022?
SELECT agency.name, SUM(budget.amount) as total_budget FROM agency JOIN budget ON agency.id = budget.agency_id WHERE budget.year = 2022 GROUP BY agency.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment (EquipmentID INT, EquipmentName VARCHAR(100), DeliveryDate DATE); INSERT INTO Equipment (EquipmentID, EquipmentName, DeliveryDate) VALUES (1, 'Tank', '2020-01-01'); INSERT INTO Equipment (EquipmentID, EquipmentName, DeliveryDate) VALUES (2, 'Missile', '2019-07-01'); CREATE TABLE Contracts (Contra...
List all contracts that started after the equipment was delivered
SELECT Equipment.EquipmentName, Contracts.ContractValue, Contracts.StartDate FROM Equipment INNER JOIN Contracts ON Equipment.EquipmentID = Contracts.EquipmentID WHERE Contracts.StartDate > Equipment.DeliveryDate;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT, quarter INT, year INT); INSERT INTO production (id, country, element, quantity, quarter, year) VALUES (1, 'China', 'Ytterbium', 400, 1, 2021), (2, 'China', 'Ytterbium', 450, 2, 2021), (3, 'USA', 'Ytterbium', 300, 1, 2021), (4, 'U...
Calculate the percentage of global Ytterbium production for each quarter.
SELECT country, (quantity * 100.0 / world_quantity) as pct FROM production, world_production WHERE element = 'Ytterbium' AND production.element = world_production.element AND production.quarter = world_production.quarter AND production.year = world_production.year GROUP BY country, world_quantity, quarter, year;
gretelai_synthetic_text_to_sql