context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE song_details (song_id INT, genre VARCHAR(20)); INSERT INTO song_details (song_id, genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'), (4, 'Pop'), (5, 'Rock'), (6, 'Jazz'); CREATE TABLE genres (genre VARCHAR(20)); INSERT INTO genres (genre) VALUES ('Pop'), ('Rock'), ('Jazz'), ('Country'), ('Hip Hop');
Which genres are missing from the 'song_details' table?
SELECT genres.genre FROM genres LEFT JOIN song_details ON genres.genre = song_details.genre WHERE song_details.song_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (facility_id INT, facility_type VARCHAR(20), province_abbr VARCHAR(2)); INSERT INTO facilities (facility_id, facility_type, province_abbr) VALUES (1, 'Mental Health Clinic', 'ON'), (2, 'Hospital', 'QC'), (3, 'Mental Health Clinic', 'BC');
What is the number of mental health facilities in each province of Canada?
SELECT province_abbr, COUNT(*) as mental_health_facilities FROM facilities WHERE facility_type = 'Mental Health Clinic' GROUP BY province_abbr;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, supplier_id INT, category VARCHAR(50), quantity INT, price DECIMAL(10,2)); INSERT INTO sales (id, supplier_id, category, quantity, price) VALUES (1, 1, 'Electronics', 10, 50.00), (2, 2, 'Machinery', 5, 1000.00), (3, 3, 'Electronics', 8, 75.00);
What was the total revenue for each supplier in Q2 2021?
SELECT supplier_id, SUM(quantity * price) as total_revenue FROM sales WHERE DATE_FORMAT(order_date, '%Y-%m') BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY supplier_id;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_rates (id INT, operation VARCHAR(255), environmental_impact DECIMAL(10,2));
Find mining operations that have a higher than average environmental impact
SELECT operation FROM environmental_impact_rates WHERE environmental_impact > (SELECT AVG(environmental_impact) FROM environmental_impact_rates);
gretelai_synthetic_text_to_sql
CREATE TABLE brands (country TEXT, commits_to_circula_economy BOOLEAN); INSERT INTO brands (country, commits_to_circula_economy) VALUES ('Germany', TRUE), ('France', TRUE), ('Spain', FALSE), ('Italy', TRUE), ('United Kingdom', TRUE);
How many clothing brands in Europe have committed to circular economy principles?
SELECT COUNT(*) FROM brands WHERE country IN ('Germany', 'France', 'Spain', 'Italy', 'United Kingdom') AND commits_to_circula_economy = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(50)); CREATE TABLE peacekeeping_operations (operation_id INT, operation_name VARCHAR(50), country_id INT); INSERT INTO countries VALUES (1, 'USA'), (2, 'China'), (3, 'India'); INSERT INTO peacekeeping_operations VALUES (1, 'MINUSTAH', 1), (2, 'UNMIL', 1), (3,...
What's the total number of peacekeeping operations conducted by each country in the 'peacekeeping_operations' and 'countries' tables?
SELECT c.country_name, COUNT(p.operation_id) as operations_conducted FROM countries c JOIN peacekeeping_operations p ON c.country_id = p.country_id GROUP BY c.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); INSERT INTO restaurants (restaurant_id, name) VALUES (16, 'Bistro Francais'); CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), is_vegetarian BOOLEAN); INSERT INTO menu_items (menu_item_id, name, price, is_vegetarian) VALUE...
What is the average price of menu items at 'Bistro Francais' that are not vegetarian?
SELECT AVG(price) FROM menu_items WHERE menu_items.restaurant_id = 16 AND is_vegetarian = false;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, genre_id INT, sale_date DATE, revenue DECIMAL(5,2));
What is the total revenue by genre, for the current month?
SELECT g.genre, SUM(s.revenue) AS total_revenue FROM genres g JOIN sales s ON g.genre_id = s.genre_id WHERE s.sale_date >= DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) GROUP BY g.genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), Mass FLOAT); INSERT INTO Spacecraft (SpacecraftID, Name, Manufacturer, Mass) VALUES (1, 'Starship', 'SpaceX', 12000000), (2, 'Crew Dragon', 'SpaceX', 12000);
What is the total mass of spacecraft manufactured by SpaceX?
SELECT SUM(s.Mass) FROM Spacecraft s WHERE s.Manufacturer = 'SpaceX';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_providers (id INT, region TEXT, provider_type TEXT); INSERT INTO mental_health_providers (id, region, provider_type) VALUES (1, 'North', 'Psychiatrist'), (2, 'South', 'Therapist');
What is the total number of mental health providers in the Southern region?
SELECT COUNT(*) FROM mental_health_providers WHERE region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS public.bridges (id SERIAL PRIMARY KEY, name TEXT, length REAL, age INT); INSERT INTO public.bridges (name, length, age) SELECT 'ExampleBridge1', 500.0, 10 FROM generate_series(1, 10); INSERT INTO public.bridges (name, length, age) SELECT 'ExampleBridge2', 700.0, 5 FROM generate_series(1, 10);
What is the average age of all bridges in the "bridges" table?
SELECT AVG(age) FROM public.bridges;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotel (hotel_type TEXT, occupancy_rate NUMERIC); INSERT INTO Hotel (hotel_type, occupancy_rate) VALUES ('Eco-Hotel', 85.3), ('Boutique-Hotel', 78.1), ('Luxury-Hotel', 69.5);
What is the average occupancy rate for each hotel type?
SELECT hotel_type, AVG(occupancy_rate) FROM Hotel GROUP BY hotel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, office VARCHAR(20)); CREATE TABLE cases (case_id INT, attorney_id INT, practice_area VARCHAR(20), billing_amount DECIMAL(10, 2), open_date DATE); INSERT INTO attorneys (attorney_id, office) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'New York'); INSERT INTO ...
Calculate the total billing amount for cases in the 'Immigration Law' practice area that were opened in the first quarter of 2022, for attorneys located in the 'New York' office.
SELECT SUM(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE practice_area = 'Immigration Law' AND QUARTER(open_date) = 1 AND YEAR(open_date) = 2022 AND office = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Fabrics (fabric_id INT, fabric_type VARCHAR(50)); INSERT INTO Fabrics (fabric_id, fabric_type) VALUES (1, 'Cotton'), (2, 'Polyester'), (3, 'Rayon'); CREATE TABLE Emissions (emission_id INT, fabric_id INT, year INT, co2_emission INT); INSERT INTO Emissions (emission_id, fabric_id, year, co2_emission) VALUES...
What is the average CO2 emission for each fabric type in 2021?
SELECT F.fabric_type, AVG(E.co2_emission) as avg_co2_emission FROM Emissions E JOIN Fabrics F ON E.fabric_id = F.fabric_id WHERE E.year = 2021 GROUP BY F.fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, Title TEXT, Genre TEXT);
Add an artwork 'The Persistence of Memory' by Salvador Dalí and assign it to the Surrealism genre.
INSERT INTO Artworks (ArtworkID, Title, Genre) VALUES (3, 'The Persistence of Memory', 'Surrealism');
gretelai_synthetic_text_to_sql
CREATE TABLE RegionDigitalDivide (RegionID INT PRIMARY KEY, RegionName VARCHAR(100), DigitalDivideIndex DECIMAL(5,2)); INSERT INTO RegionDigitalDivide (RegionID, RegionName, DigitalDivideIndex) VALUES (1, 'North America', 0.35), (2, 'South America', 0.45), (3, 'Europe', 0.25), (4, 'Asia', 0.15), (5, 'Africa', 0.55);
What is the minimum digital divide index for each region?
SELECT RegionName, MIN(DigitalDivideIndex) as MinDigitalDivideIndex FROM RegionDigitalDivide GROUP BY RegionName;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(255), country VARCHAR(255), speed FLOAT); INSERT INTO Vessels (id, name, country, speed) VALUES (1, 'VesselA', 'Japan', 20.5); INSERT INTO Vessels (id, name, country, speed) VALUES (2, 'VesselB', 'Japan', 22.3); CREATE TABLE Arrivals (vessel_id INT, destination VARCHAR(255), a...
What is the average speed of vessels arriving from Japan to the USA?
SELECT AVG(Vessels.speed) FROM Vessels INNER JOIN Arrivals ON Vessels.id = Arrivals.vessel_id WHERE Vessels.country = 'Japan' AND Arrivals.destination = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Country_Art_Count (country TEXT, art_count INT); INSERT INTO Country_Art_Count (country, art_count) VALUES ('Japan', 2); INSERT INTO Country_Art_Count (country, art_count) VALUES ('India', 3);
Display the number of unique traditional art forms in each country.
SELECT country, COUNT(*) AS unique_art_forms FROM (SELECT DISTINCT name, country FROM Traditional_Arts) AS unique_arts GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (name VARCHAR(255), city VARCHAR(255), date DATE); INSERT INTO Exhibitions (name, city, date) VALUES ('Modern Art', 'New York', '2023-03-01'), ('Contemporary Art', 'Los Angeles', '2022-04-01'), ('Classic Art', 'Chicago', '2023-02-01'), ('Impressionism', 'Paris', '2022-05-01');
Delete all exhibitions that took place in 2022.
DELETE FROM Exhibitions WHERE YEAR(date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (PersonnelID INT, PersonnelBranch VARCHAR(20), PersonnelCountry VARCHAR(30), PersonnelCount INT); INSERT INTO MilitaryPersonnel (PersonnelID, PersonnelBranch, PersonnelCountry, PersonnelCount) VALUES (1, 'Army', 'USA', 500000), (2, 'Navy', 'USA', 350000), (3, 'Air Force', 'Canada', 20000)...
What is the total number of military personnel by branch for each country?
SELECT PersonnelBranch, PersonnelCountry, SUM(PersonnelCount) as Total FROM MilitaryPersonnel GROUP BY PersonnelBranch, PersonnelCountry;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, contractor VARCHAR(255), project VARCHAR(255), start_year INT); INSERT INTO defense_projects (id, contractor, project, start_year) VALUES (1, 'BAE Systems', 'Armored Vehicle Development', 2016), (2, 'BAE Systems', 'Naval Warfare Systems', 2017), (3, 'BAE Systems', 'Cybersecurity S...
How many defense projects has BAE Systems been involved in since 2015?
SELECT COUNT(*) FROM defense_projects WHERE contractor = 'BAE Systems' AND start_year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(20), state VARCHAR(2)); INSERT INTO attorneys (id, name, state) VALUES (1, 'Smith', 'NY'), (2, 'Garcia', 'CA'), (3, 'Kim', 'IL'); CREATE TABLE cases (id INT, attorney_id INT, case_type VARCHAR(10));
How many cases were handled by each attorney in the 'New York' state?
SELECT attorneys.name, COUNT(*) as num_cases FROM attorneys INNER JOIN cases ON attorneys.id = cases.attorney_id WHERE attorneys.state = 'NY' GROUP BY attorneys.name;
gretelai_synthetic_text_to_sql
CREATE TABLE research (research_id INT PRIMARY KEY, description TEXT, date DATE);
Update the 'description' column for 'research_id' 2001 in the 'research' table to 'Bioinformatics research on gene sequencing'
WITH cte1 AS (UPDATE research SET description = 'Bioinformatics research on gene sequencing' WHERE research_id = 2001) SELECT * FROM cte1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (id INT, weapon_system VARCHAR(255), country VARCHAR(255), year INT);
Get the total spending on military innovation by each country for the year 2019
SELECT country, SUM(year) FROM military_innovation WHERE year = 2019 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_response.hospitals (id INT, name VARCHAR(50), capacity INT, location VARCHAR(50));
How many hospitals are present in the 'disaster_response' schema?
SELECT COUNT(*) FROM disaster_response.hospitals;
gretelai_synthetic_text_to_sql
CREATE TABLE content (content_id INT, content_type VARCHAR(20), language VARCHAR(20), length_minutes FLOAT); INSERT INTO content VALUES (1, 'documentary', 'Arabic', 60.5);
What is the average length of videos in Arabic language?
SELECT AVG(length_minutes) FROM content WHERE language = 'Arabic';
gretelai_synthetic_text_to_sql
CREATE TABLE crop (id INT, name VARCHAR(255), variety VARCHAR(255)); CREATE TABLE irrigation (id INT, crop_id INT, water_consumption INT, timestamp TIMESTAMP, event_type VARCHAR(255)); INSERT INTO crop VALUES (1, 'Corn', 'Sweet Corn'), (2, 'Corn', 'Field Corn'); INSERT INTO irrigation VALUES (1, 1, 100, '2022-03-01 10:...
Find the number of automated irrigation events and corresponding water consumption for each crop variety in the past week.
SELECT c.variety, COUNT(i.id) as num_events, SUM(i.water_consumption) as total_water_consumption FROM crop c INNER JOIN irrigation i ON c.id = i.crop_id WHERE i.event_type = 'Automated' AND i.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW() GROUP BY c.variety;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, State CHAR(2), IsSustainable BOOLEAN, Cost DECIMAL(10,2)); INSERT INTO Projects (ProjectID, State, IsSustainable, Cost) VALUES (1, 'TX', true, 500000.00), (2, 'NY', false, 350000.00), (3, 'TX', true, 700000.00), (4, 'TX', true, 800000.00), (5, 'CA', false, 600000.00);
What are the names and total costs of the top 3 most expensive sustainable projects in Texas?
SELECT Projects.ProjectID, Projects.State, SUM(Projects.Cost) AS TotalCost FROM Projects WHERE Projects.State = 'TX' AND Projects.IsSustainable = true GROUP BY Projects.ProjectID, Projects.State ORDER BY TotalCost DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), location VARCHAR(50), environmental_impact_score INT); INSERT INTO mining_operations (id, name, location, environmental_impact_score) VALUES (1, 'Goldmine 1', 'USA', 50), (2, 'Silvermine 2', 'Canada', 25); CREATE TABLE employees (id INT, name VARCHAR(50), job_ti...
List all mining operations with their respective environmental impact scores and the number of employees at each operation.
SELECT m.name, m.environmental_impact_score, COUNT(e.id) as num_employees FROM mining_operations m LEFT JOIN employees e ON m.id = e.operation_id GROUP BY m.id;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT PRIMARY KEY, species VARCHAR(30), name VARCHAR(20), population INT);
Update the 'population' field to 200 in the 'animal_population' table for all records where the 'species' is 'Canis lupus'
UPDATE animal_population SET population = 200 WHERE species = 'Canis lupus';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255), industry VARCHAR(255), opted_out BOOLEAN);
How many users have opted out of targeted advertising in the past week, in the gaming industry, in Canada?
SELECT COUNT(*) FROM users WHERE country = 'Canada' AND industry = 'gaming' AND opted_out = TRUE AND last_updated_time > DATE_SUB(NOW(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping (mapping_id INT, region VARCHAR(255), area INT); CREATE VIEW arctic_indian_mapping AS SELECT * FROM ocean_floor_mapping WHERE region IN ('Arctic ocean', 'Indian ocean');
Get the total area of the ocean floor mapped in the Arctic and Indian oceans
SELECT region, SUM(area) FROM arctic_indian_mapping GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramImpact (program_id INT, program_focus VARCHAR(50), impact_score DECIMAL(10,2), program_date DATE); INSERT INTO ProgramImpact (program_id, program_focus, impact_score, program_date) VALUES (1, 'Diversity and Inclusion', 80.00, '2021-01-01'), (2, 'Accessibility', 85.00, '2021-02-01'), (3, 'Education',...
What was the average program impact score for programs focused on diversity and inclusion in 2021?
SELECT AVG(impact_score) AS avg_impact_score FROM ProgramImpact WHERE program_focus = 'Diversity and Inclusion' AND program_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Sensor (sensor_id INT, location VARCHAR(20), last_seen DATE);
List all sensors and their last known location for the past week.
SELECT sensor_id, location, MAX(last_seen) FROM Sensor WHERE last_seen >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY sensor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Work_Type (id INT, type VARCHAR(20)); CREATE TABLE Labor (work_type_id INT, cost INT);
What is the average labor cost for each type of construction work?
SELECT Work_Type.type, AVG(Labor.cost) AS avg_cost FROM Work_Type INNER JOIN Labor ON Work_Type.id = Labor.work_type_id GROUP BY Work_Type.type;
gretelai_synthetic_text_to_sql
CREATE TABLE indian_marine_life (species VARCHAR(255), count INT); INSERT INTO indian_marine_life (species, count) VALUES ('Turtle', 150), ('Seabird', 250); CREATE TABLE southern_ocean_marine_life (species VARCHAR(255), count INT); INSERT INTO southern_ocean_marine_life (species, count) VALUES ('Penguin', 400), ('Albat...
What is the total number of marine reptiles and birds observed in the Indian and Southern Oceans?
SELECT SUM(count) FROM (SELECT count FROM indian_marine_life WHERE species IN ('Turtle', 'Seabird') UNION ALL SELECT count FROM southern_ocean_marine_life WHERE species IN ('Penguin', 'Albatross'));
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, city TEXT, price FLOAT);
Insert a new virtual tour of the British Museum in London with a price of 12 euros.
INSERT INTO virtual_tours (tour_id, tour_name, city, price) VALUES (4, 'British Museum Tour', 'London', 12);
gretelai_synthetic_text_to_sql
CREATE TABLE Arctic_Ocean (id INT, species VARCHAR(20), biomass INT); INSERT INTO Arctic_Ocean (id, species, biomass) VALUES (1, 'Cod', 5000), (2, 'Herring', 4000), (3, 'Pollock', 3000);
What is the total biomass of fish species in the Arctic Ocean?
SELECT SUM(biomass) FROM Arctic_Ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE resource_access (student_id INT, resource_id INT); INSERT INTO resource_access (student_id, resource_id) VALUES (1, 201), (1, 202), (2, 201), (3, 203), (3, 204), (4, 201);
Which open pedagogy resources were accessed by the most students?
SELECT resource_id, COUNT(*) OVER (PARTITION BY resource_id) AS students_accessed FROM resource_access ORDER BY students_accessed DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Legal_Service_Providers_Types (ID INT, Provider_Type VARCHAR(30), Total_Providers INT); INSERT INTO Legal_Service_Providers_Types (ID, Provider_Type, Total_Providers) VALUES (1, 'Legal Aid', 100), (2, 'Public Defender', 50), (3, 'Community Legal Clinic', 25);
What is the total number of legal service providers by type?
SELECT Provider_Type, SUM(Total_Providers) FROM Legal_Service_Providers_Types GROUP BY Provider_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50), eco_friendly BOOLEAN); CREATE TABLE orders (id INT, supplier_id INT, order_value DECIMAL(10,2)); INSERT INTO suppliers (id, name, country, eco_friendly) VALUES (1, 'Supplier A', 'France', TRUE), (2, 'Supplier B', 'Germany', FALSE); INSERT INTO order...
What is the total revenue generated by suppliers located in France who supply eco-friendly materials?
SELECT SUM(orders.order_value) FROM suppliers INNER JOIN orders ON suppliers.id = orders.supplier_id WHERE suppliers.country = 'France' AND suppliers.eco_friendly = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, name VARCHAR(50), rank VARCHAR(50), branch VARCHAR(50)); INSERT INTO military_personnel (id, name, rank, branch) VALUES (1, 'John Doe', 'Captain', 'Air Force'); INSERT INTO military_personnel (id, name, rank, branch) VALUES (2, 'Jane Smith', 'Lieutenant', 'Air Force');
What is the total number of military personnel in the 'air force' branch?
SELECT COUNT(*) FROM military_personnel WHERE branch = 'Air Force';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO wells (id, name, location) VALUES (1, 'Well A', 'Gippsland Basin');
List all unique well names in the Gippsland Basin.
SELECT DISTINCT name FROM wells WHERE location = 'Gippsland Basin';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (ocean TEXT, min_depth FLOAT, max_depth FLOAT); INSERT INTO ocean_depths (ocean, min_depth, max_depth) VALUES ('Atlantic Ocean', 1800.0, 9210.0), ('Pacific Ocean', 1600.0, 10994.0), ('Indian Ocean', 3000.0, 7450.0);
What is the minimum and maximum depth of the Atlantic Ocean?
SELECT ocean, MIN(min_depth) AS min_depth, MAX(max_depth) AS max_depth FROM ocean_depths GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE ResourcesDepleted (ResourceDepletedID INT, Operation VARCHAR(50), Quarter INT, Year INT, Quantity DECIMAL(10,2)); INSERT INTO ResourcesDepleted (ResourceDepletedID, Operation, Quarter, Year, Quantity) VALUES (1, 'Coal', 1, 2021, 500); INSERT INTO ResourcesDepleted (ResourceDepletedID, Operation, Quarter, Y...
What is the total amount of resources depleted in Q1 2021 for all mining operations?
SELECT SUM(Quantity) FROM ResourcesDepleted WHERE Quarter = 1 AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_cases (case_id INT PRIMARY KEY AUTO_INCREMENT, client_id INT, case_type VARCHAR(50), total_cost DECIMAL(10,2));
Calculate the average total cost for all cases in the 'criminal_cases' table where the case type is 'theft'.
SELECT AVG(total_cost) FROM criminal_cases WHERE case_type = 'theft';
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id integer, department text, incident text, timestamp timestamp); INSERT INTO incidents (id, department, incident, timestamp) VALUES (1, 'HR', 'Malware', '2022-05-01 10:00:00'), (2, 'IT', 'Phishing', '2022-05-02 11:00:00'), (3, 'HR', 'Insider Threat', '2022-05-03 12:00:00'), (4, 'IT', 'Malware',...
What is the percentage of malware-related incidents reported in each department in the last month?
SELECT department, 100.0 * SUM(CASE WHEN incident = 'Malware' THEN 1 ELSE 0 END) / COUNT(*) as malware_percentage FROM incidents WHERE timestamp >= DATEADD(month, -1, CURRENT_TIMESTAMP) GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, last_donation_date DATE, donation DECIMAL(10,2)); INSERT INTO donors (id, name, last_donation_date, donation) VALUES (1, 'John Doe', '2021-01-15', 200.00), (2, 'Jane Smith', '2021-06-01', 300.00);
List all unique donors who have not donated in the last 6 months, along with their last donation amount and date?
SELECT id, name, last_donation_date, donation FROM donors WHERE last_donation_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND id NOT IN (SELECT id FROM donors WHERE last_donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH));
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, name VARCHAR(50), cost DECIMAL(10,2), type VARCHAR(20)); INSERT INTO agricultural_projects (id, name, cost, type) VALUES (1, 'Precision Farming', 15000.00, 'Automation'); INSERT INTO agricultural_projects (id, name, cost, type) VALUES (2, 'Vertical Farming', 22000.00, 'Hydrop...
Show agricultural innovation projects and their respective technology types from the 'rural_development' database
SELECT name, type FROM agricultural_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, title VARCHAR(50), location VARCHAR(50), movement VARCHAR(20));
Find the number of unique locations where 'Dadaism' exhibitions were held.
SELECT COUNT(DISTINCT location) FROM Exhibitions WHERE movement = 'Dadaism';
gretelai_synthetic_text_to_sql
CREATE TABLE ProductIngredients (product_id INT, is_vegan BOOLEAN); INSERT INTO ProductIngredients (product_id, is_vegan) VALUES (1, true);
What is the maximum preference rating for vegan products?
SELECT MAX(preference_rating) as max_preference_rating FROM CustomerPreferences INNER JOIN ProductIngredients ON CustomerPreferences.product_id = ProductIngredients.product_id WHERE is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255), dish_ingredients TEXT); INSERT INTO menu (dish_id, dish_name, dish_type, dish_ingredients) VALUES (1, 'Quinoa Salad', 'Vegetarian', 'quinoa, lettuce, tomato, cucumber, avocado'), (2, 'Chicken Sandwich', 'Non-Vegetarian', 'chicken, bread, le...
Find the top 3 sustainable ingredients and their total usage in dishes
SELECT i.ingredient_name, SUM(LENGTH(m.dish_ingredients) - LENGTH(REPLACE(m.dish_ingredients, i.ingredient_name, ''))) / LENGTH(i.ingredient_name) AS total_usage FROM ingredients i JOIN menu m ON FIND_IN_SET(i.ingredient_name, m.dish_ingredients) > 0 WHERE i.is_sustainable = true GROUP BY i.ingredient_name ORDER BY tot...
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousResearch (Id INT, Organization VARCHAR(255), Focus VARCHAR(255), Country VARCHAR(255)); INSERT INTO AutonomousResearch (Id, Organization, Focus, Country) VALUES (3, 'Audi Autonomous Driving', 'Autonomous Driving', 'Germany');
What are the autonomous driving research organizations in Germany?
SELECT Organization, Country FROM AutonomousResearch WHERE Country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE eco_tours (tour_id INT, name VARCHAR(255), country VARCHAR(255), price FLOAT, eco_friendly BOOLEAN); INSERT INTO eco_tours (tour_id, name, country, price, eco_friendly) VALUES (1, 'Rainforest Adventure', 'Costa Rica', 120.0, true), (2, 'Volcano Hike', 'Costa Rica', 80.0, true), (3, 'Beach Cleanup', 'Costa ...
What is the minimum price of eco-friendly tours in Costa Rica?
SELECT MIN(price) FROM eco_tours WHERE country = 'Costa Rica' AND eco_friendly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (id INT, chemical VARCHAR(255), score INT); INSERT INTO EnvironmentalImpact (id, chemical, score) VALUES (1, 'ChemA', 5), (2, 'ChemB', 8);
Calculate the average environmental impact score for each chemical type.
SELECT chemical, AVG(score) FROM EnvironmentalImpact GROUP BY chemical
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name TEXT, cuisine TEXT); INSERT INTO Restaurants (id, name, cuisine) VALUES (1, 'Golden Palace', 'Chinese'), (2, 'La Trattoria', 'Italian'); CREATE TABLE Menu (id INT, name TEXT, category TEXT, price FLOAT, restaurant_id INT); CREATE TABLE Orders (id INT, menu_id INT, order_date DATE,...
Rank dishes by popularity, considering only orders from the last month, for each category in Chinese restaurants?
SELECT menu.name, menu.category, SUM(orders.quantity) as total_quantity, ROW_NUMBER() OVER (PARTITION BY menu.category ORDER BY SUM(orders.quantity) DESC) as rank FROM Orders JOIN Menu ON Orders.menu_id = Menu.id JOIN Restaurants ON Menu.restaurant_id = Restaurants.id WHERE Restaurants.cuisine = 'Chinese' AND Orders.or...
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (MetricID INT, MetricValue INT, Year INT); INSERT INTO HealthEquityMetrics (MetricID, MetricValue, Year) VALUES (1, 80, 2016), (2, 85, 2017), (3, 75, 2018), (4, 90, 2019), (5, 95, 2020);
What is the trend in health equity metrics over the last 5 years?
SELECT Year, AVG(MetricValue) OVER (ORDER BY Year ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) AS AvgMetricValue FROM HealthEquityMetrics;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_sanctuary (id INT, species VARCHAR(20), population INT); INSERT INTO wildlife_sanctuary (id, species, population) VALUES (1, 'Tiger', 50), (2, 'Elephant', 300), (3, 'Lion', 75);
What is the total number of animals in the 'wildlife_sanctuary' table, separated by species?
SELECT species, SUM(population) FROM wildlife_sanctuary GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE Packages (id INT, warehouse_id INT, destination_state TEXT, weight FLOAT); INSERT INTO Packages (id, warehouse_id, destination_state, weight) VALUES (1, 11, 'WA', 70.2), (2, 11, 'QLD', 85.6), (3, 11, 'VIC', 60.1); CREATE TABLE Warehouses (id INT, name TEXT, city TEXT, state TEXT); INSERT INTO Warehouses (i...
What is the maximum weight of packages shipped from the Sydney warehouse to each destination state?
SELECT destination_state, MAX(weight) FROM Packages JOIN Warehouses ON Packages.warehouse_id = Warehouses.id WHERE Warehouses.name = 'Sydney Warehouse' GROUP BY destination_state;
gretelai_synthetic_text_to_sql
CREATE TABLE louisiana_rural_dental_clinics (clinic_id INT, clinic_name VARCHAR(255), rural BOOLEAN); INSERT INTO louisiana_rural_dental_clinics VALUES (1, 'Dental Clinic A', true), (2, 'Dental Clinic B', false);
How many dental clinics are there in rural areas of Louisiana?
SELECT COUNT(*) FROM louisiana_rural_dental_clinics WHERE rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Gender) VALUES (1, 25, 'Male'); INSERT INTO Players (PlayerID, Age, Gender) VALUES (2, 30, 'Female'); CREATE TABLE match_results (MatchID INT, PlayerID INT, Result VARCHAR(5)); INSERT INTO match_results (MatchID, Playe...
Calculate the average age of players who won in 'match_results' table.
SELECT AVG(Age) FROM Players JOIN match_results ON Players.PlayerID = match_results.PlayerID WHERE Result = 'Win';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255), old_location VARCHAR(255), new_location VARCHAR(255), gender VARCHAR(10));
Retrieve the number of users who changed their location in the last 30 days
SELECT COUNT(*) FROM users WHERE old_location IS NOT NULL AND new_location IS NOT NULL AND old_location != new_location AND created_at >= NOW() - INTERVAL '30 days';
gretelai_synthetic_text_to_sql
CREATE TABLE WildlifeSightings (Location VARCHAR(255), Date DATE, Species VARCHAR(255), Quantity INT); INSERT INTO WildlifeSightings (Location, Date, Species, Quantity) VALUES ('Tundra National Park', '2021-01-01', 'Polar Bear', 1), ('Arctic Circle', '2021-01-01', 'Arctic Fox', 2);
What is the total quantity of wildlife sightings in 2021, separated by species?
SELECT Species, SUM(Quantity) FROM WildlifeSightings WHERE YEAR(Date) = 2021 GROUP BY Species;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (incident_id INT, union_id INT, incident_date DATE, incident_status VARCHAR(255)); CREATE TABLE unions (union_id INT, union_name VARCHAR(255)); INSERT INTO unions (union_id, union_name) VALUES (123, 'Transportation Workers Union'); INSERT INTO unions (union_id, union_name) VALUES (456, 'Co...
How many workplace safety incidents were reported by 'Transportation Workers Union' in 2020?
SELECT COUNT(*) FROM safety_incidents s WHERE s.union_id = (SELECT u.union_id FROM unions u WHERE u.union_name = 'Transportation Workers Union') AND s.incident_date BETWEEN '2020-01-01' AND '2020-12-31' AND s.incident_status = 'Reported';
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, state VARCHAR(2), policy_type VARCHAR(20), age INT); INSERT INTO policyholders (id, state, policy_type, age) VALUES (1, 'FL', 'Life', 25), (2, 'FL', 'Health', 30), (3, 'FL', 'Health', 40);
What is the minimum age for health insurance policyholders in Florida?
SELECT MIN(age) FROM policyholders WHERE state = 'FL' AND policy_type = 'Health';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(20), LaunchDate DATE, Manufacturer VARCHAR(20), Status VARCHAR(20)); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, Manufacturer, Status) VALUES (1, 'Sentinel-1', '2012-04-03', 'Thales Alenia Space', 'Active'); INSERT INTO Satellites (SatelliteID, Name, Lau...
Retrieve the names and manufacturers of satellites launched before 2015.
SELECT Name, Manufacturer FROM Satellites WHERE LaunchDate < '2015-01-01'
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, subject_area VARCHAR(255)); INSERT INTO teachers (teacher_id, subject_area) VALUES (1, 'Math'), (2, 'English'), (3, 'Science'), (4, 'Math'); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), subject_area VARCHAR(255)); INSERT INTO courses (course_id, course_name, subj...
How many teachers have completed professional development courses in each subject area?
SELECT t.subject_area, COUNT(DISTINCT c.teacher_id) as num_teachers FROM completions c JOIN teachers t ON c.teacher_id = t.teacher_id JOIN courses co ON c.course_id = co.course_id GROUP BY t.subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation (id INT, location VARCHAR(255), region VARCHAR(255), score INT);
Show the average water conservation score for each region
SELECT region, AVG(score) as avg_score FROM water_conservation GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), brand VARCHAR(255), price DECIMAL(10, 2), sale_date DATE); INSERT INTO products VALUES (1, 'ProductA', 'BrandX', 50, '2022-01-01'), (2, 'ProductB', 'BrandX', 75, '2022-01-03'), (3, 'ProductC', 'BrandY', 60, '2022-01-02');
What is the moving average of product prices for each brand over the last 30 days?
SELECT brand, AVG(price) OVER (PARTITION BY brand ORDER BY sale_date ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) as moving_avg FROM products;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers_na (name TEXT, location TEXT, country TEXT); INSERT INTO healthcare_providers_na (name, location, country) VALUES ('Provider A', 'Rural AB', 'Canada'), ('Provider B', 'Rural ON', 'Canada'), ('Provider C', 'Rural NY', 'USA'), ('Provider D', 'Rural TX', 'USA');
List the top 2 provinces in Canada and the US with the highest number of rural healthcare providers.
SELECT country, location, COUNT(*) AS provider_count FROM healthcare_providers_na WHERE country IN ('Canada', 'USA') AND location LIKE 'Rural%' GROUP BY country, location ORDER BY provider_count DESC LIMIT 2
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, location) VALUES (1, 'Jane Doe', 35, 'Female', 'Rural Texas'), (2, 'Pedro Alvarez', 42, 'Male', 'Rural Mexico');
Show all farmers from 'Rural Mexico'
SELECT * FROM farmers WHERE location = 'Rural Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, origin_country VARCHAR(255), destination_country VARCHAR(255), delivery_time INT); INSERT INTO shipments (id, origin_country, destination_country, delivery_time) VALUES (1, 'Egypt', 'South Africa', 20), (2, 'Nigeria', 'South Africa', 30);
What is the delivery time range for shipments within Africa?
SELECT MIN(delivery_time) as min_delivery_time, MAX(delivery_time) as max_delivery_time FROM shipments WHERE origin_country IN (SELECT destination_country FROM shipments) AND destination_country IN (SELECT origin_country FROM shipments);
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(255)); INSERT INTO countries (id, name) VALUES (1, 'Canada'), (2, 'USA'); CREATE TABLE tree_species (id INT, name VARCHAR(255), country_id INT); INSERT INTO tree_species (id, name, country_id) VALUES (1, 'Douglas Fir', 1), (2, 'Redwood', 2); CREATE TABLE trees (id INT, age I...
What is the average age of all tree species per country?
SELECT AVG(age) avg_age, s.name tree_species, c.name country FROM trees t JOIN tree_species s ON t.tree_species_id = s.id JOIN countries c ON s.country_id = c.id GROUP BY s.name, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id VARCHAR(10), name VARCHAR(20), city VARCHAR(10), country VARCHAR(10)); INSERT INTO warehouses (id, name, city, country) VALUES ('EWR-WH-01', 'Newark Warehouse', 'Newark', 'USA'); CREATE TABLE inventory (item VARCHAR(10), warehouse_id VARCHAR(10), quantity INT); INSERT INTO inventory (item, w...
What is the total quantity of item 'Smartphone' in warehouse 'EWR-WH-01'?
SELECT SUM(quantity) FROM inventory WHERE item = 'Smartphone' AND warehouse_id = 'EWR-WH-01';
gretelai_synthetic_text_to_sql
CREATE TABLE permits (permit_id INT, project_id INT, city VARCHAR(255), state VARCHAR(255), issue_date DATE);
What is the total number of building permits issued in the state of California in 2019?
SELECT COUNT(*) FROM permits WHERE state = 'California' AND YEAR(issue_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(5,2), hire_date DATE);
Insert a new employee record for 'Jose Rodriguez' in the Marketing department with a salary of $60,000 and a hire_date of '2021-05-01'.
INSERT INTO employees (name, department, salary, hire_date) VALUES ('Jose Rodriguez', 'Marketing', 60000.00, '2021-05-01');
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50), establishment_date DATE); INSERT INTO suppliers (id, name, country, establishment_date) VALUES (1, 'Supplier C', 'India', '2005-06-01'); INSERT INTO suppliers (id, name, country, establishment_date) VALUES (2, 'Supplier D', 'China', '2018-03-17');
Which retailers are located in countries with suppliers that produce garments made from natural fabrics?
SELECT retailers.name FROM retailers JOIN suppliers ON retailers.country = suppliers.country WHERE suppliers.id IN (SELECT garments.fabric_id FROM garments JOIN fabrics ON garments.fabric_id = fabrics.id WHERE fabrics.type = 'Natural');
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, severity VARCHAR(255), software VARCHAR(255), vulnerability_id INT);
What is the distribution of vulnerabilities by severity and software, in the last quarter, with a count of unique vulnerabilities?
SELECT software, severity, COUNT(DISTINCT vulnerability_id) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 3 MONTH) GROUP BY software, severity;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_biomass (species TEXT, location TEXT, biomass FLOAT); INSERT INTO fish_biomass (species, location, biomass) VALUES ('Tuna', 'Bay of Bengal', 1200000.0), ('Swordfish', 'Bay of Bengal', 900000.0), ('Marlin', 'Bay of Bengal', 700000.0);
What is the total biomass of all fish species in the Bay of Bengal?
SELECT SUM(biomass) FROM fish_biomass WHERE location = 'Bay of Bengal';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_maintenance (id INT, country VARCHAR(50), cost FLOAT); INSERT INTO military_equipment_maintenance (id, country, cost) VALUES (1, 'India', 900000), (2, 'India', 950000), (3, 'India', 850000);
How many military equipment maintenance records are there for India?
SELECT COUNT(*) FROM military_equipment_maintenance WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_atlantic (species_name TEXT, population NUMERIC); INSERT INTO marine_species_atlantic (species_name, population) VALUES ('Blue Whale', '150000'); INSERT INTO marine_species_atlantic (species_name, population) VALUES ('Dolphin', '500000');
What is the number of marine species in the Atlantic Ocean with a population greater than 100000?
SELECT COUNT(*) FROM marine_species_atlantic WHERE population > 100000 AND region = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), production_output INT); CREATE TABLE employees (employee_id INT, factory_id INT, name VARCHAR(100), position VARCHAR(100)); INSERT INTO factories (factory_id, name, location, production_output) VALUES (1, 'ABC Factory', 'New York', 5500),...
What is the maximum production output of factories that are located in a specific country and have more than 5 employees?
SELECT MAX(factories.production_output) FROM factories INNER JOIN (SELECT factory_id FROM employees GROUP BY factory_id HAVING COUNT(*) > 5) AS employees_count ON factories.factory_id = employees_count.factory_id WHERE factories.location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(100), country VARCHAR(50), violations INT); INSERT INTO factories (id, name, country, violations) VALUES (1, 'AsiaTech Factory', 'China', 15), (2, 'Bright Future Factory', 'Bangladesh', 20), (3, 'Unity Factory', 'Vietnam', 10);
Identify factories in Asia with the highest number of labor rights violations.
SELECT name, country, MAX(violations) as max_violations FROM factories WHERE country IN ('China', 'Bangladesh', 'Vietnam') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), sport VARCHAR(20)); CREATE TABLE tournaments (id INT, player_id INT, name VARCHAR(50), location VARCHAR(50), year INT);
Show the top 5 table tennis players by the number of tournaments won
SELECT players.name, COUNT(*) as won_tournaments FROM players JOIN tournaments ON players.id = tournaments.player_id GROUP BY players.name ORDER BY won_tournaments DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_category VARCHAR(255), project_name VARCHAR(255), num_volunteers INT, volunteer_year INT); INSERT INTO projects (project_id, project_category, project_name, num_volunteers, volunteer_year) VALUES (1, 'Education', 'Coding for Kids', 20, 2022), (2, 'Education', 'Web Developm...
How many volunteers were added to each project category in the 'projects' table in 2022 and 2023?
SELECT project_category, SUM(num_volunteers) AS total_volunteers FROM projects WHERE volunteer_year IN (2022, 2023) GROUP BY project_category;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRatesEU (country VARCHAR(50), year INT, rate DECIMAL(5,2)); INSERT INTO RecyclingRatesEU (country, year, rate) VALUES ('Germany', 2017, 60.5), ('Germany', 2018, 61.2), ('Germany', 2019, 62.1), ('France', 2017, 55.4), ('France', 2018, 56.2), ('France', 2019, 57.1);
Calculate the average recycling rate in the European Union over the past 5 years.
SELECT AVG(rate) FROM RecyclingRatesEU WHERE country IN ('Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE Investments (id INT, company_id INT, investment_amount INT, investment_date DATE); CREATE TABLE Companies (id INT, name TEXT, industry TEXT, country TEXT, founder_gender TEXT); INSERT INTO Companies (id, name, industry, country, founder_gender) VALUES (1, 'Acme Inc', 'Tech', 'USA', 'Female'); INSERT INTO C...
Find the average investment amount for each industry.
SELECT industry, AVG(investment_amount) as avg_investment_amount FROM Investments i JOIN Companies c ON i.company_id = c.id GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE courts (id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(2)); CREATE TABLE court_cases (id INT PRIMARY KEY, case_number VARCHAR(50), court_id INT, FOREIGN KEY (court_id) REFERENCES courts(id));
Delete the court case with id 2
DELETE FROM court_cases WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameGenre TEXT); INSERT INTO PlayerGames (PlayerID, GameID, GameGenre) VALUES (1, 1, 'Action'), (1, 2, 'RPG'), (2, 3, 'Strategy'), (2, 4, 'Simulation'), (3, 5, 'FPS'), (3, 6, 'FPS'), (4, 7, 'Action'), (4, 8, 'RPG'), (5, 9, 'Strategy'), (5, 10, 'Simulation'), (6, 11, '...
Find the number of players who have played games from only one genre.
SELECT COUNT(DISTINCT PlayerID) FROM (SELECT PlayerID FROM PlayerGames GROUP BY PlayerID HAVING COUNT(DISTINCT GameGenre) = 1) AS SingleGenrePlayers;
gretelai_synthetic_text_to_sql
CREATE TABLE budget (year INT, category VARCHAR(255), amount INT); INSERT INTO budget (year, category, amount) VALUES (2018, 'Education', 50000), (2018, 'Healthcare', 70000), (2018, 'Transport', 30000), (2019, 'Education', 55000), (2019, 'Healthcare', 75000), (2019, 'Transport', 35000), (2020, 'Education', 60000), (202...
What is the percentage of the total budget allocated to healthcare in each year?
SELECT year, (SUM(CASE WHEN category = 'Healthcare' THEN amount ELSE 0 END) / SUM(amount)) * 100 as healthcare_percentage FROM budget GROUP BY year
gretelai_synthetic_text_to_sql
CREATE TABLE fares (fare_id INT, fare_date DATE, fare DECIMAL); INSERT INTO fares VALUES (1, '2022-01-01', 2.5); INSERT INTO fares VALUES (2, '2022-01-01', 2.5); INSERT INTO fares VALUES (3, '2022-01-02', 3.0); INSERT INTO fares VALUES (4, '2022-01-02', 3.0); INSERT INTO fares VALUES (5, '2022-01-02', 3.0);
What is the total fare collected on each day of the week?
SELECT DATE_FORMAT(fares.fare_date, '%W') as day_of_week, SUM(fares.fare) FROM fares GROUP BY day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE project_employment (project_name VARCHAR(255), num_workers INT);
What is the maximum number of workers employed on a single project in the 'project_employment' table?
select max(num_workers) as max_workers from project_employment;
gretelai_synthetic_text_to_sql
CREATE TABLE toronto_public_libraries (library_id INT, library_name TEXT, city TEXT, country TEXT, daily_borrows INT); INSERT INTO toronto_public_libraries (library_id, library_name, city, country, daily_borrows) VALUES (1, 'Toronto Public Library - Northern District', 'Toronto', 'Canada', 1200); INSERT INTO toronto_pu...
What is the maximum number of books borrowed in a single day from public libraries in Toronto, Canada?
SELECT MAX(daily_borrows) FROM toronto_public_libraries;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, program_name TEXT, donation_amount DECIMAL); INSERT INTO programs (id, program_name, donation_amount) VALUES (1, 'Education', 120.00); INSERT INTO programs (id, program_name, donation_amount) VALUES (2, 'Healthcare', 80.00);
List the programs with an average donation higher than $100?
SELECT program_name FROM programs WHERE donation_amount > (SELECT AVG(donation_amount) FROM programs) GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Services (Year INT, Region VARCHAR(20), Service VARCHAR(20), Quantity INT); INSERT INTO Services (Year, Region, Service, Quantity) VALUES (2020, 'South', 'Healthcare', 1200), (2020, 'North', 'Education', 1500), (2020, 'East', 'Healthcare', 1000);
What is the total number of services provided in each region in 2020?
SELECT Region, SUM(Quantity) FROM Services WHERE Year = 2020 GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists rural_healthcare; use rural_healthcare; CREATE TABLE hospitals (id int, name varchar(255), num_doctors int); CREATE TABLE clinics (id int, name varchar(255), num_nurses int);
List the hospitals and clinics in 'rural_healthcare' schema that have more than 50 healthcare professionals?
SELECT name, 'hospital' as type FROM hospitals h WHERE h.num_doctors > 50 UNION SELECT name, 'clinic' as type FROM clinics c WHERE c.num_nurses > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety_testing (vehicle_id INT, vehicle_name VARCHAR(50), horsepower INT, safety_rating FLOAT);
Delete records of vehicles with horsepower greater than 300 from the vehicle_safety_testing table.
DELETE FROM vehicle_safety_testing WHERE horsepower > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, name VARCHAR(20), school_district VARCHAR(25)); INSERT INTO teachers (teacher_id, name, school_district) VALUES (1, 'Jamal Johnson', 'Central Riverland'), (2, 'Sophia Rodriguez', 'Eastern Shorelines'), (3, 'Mohammad Ahmed', 'Central Riverland'), (4, 'Emily Wong', 'Western Hills');...
What is the minimum number of hours spent on professional development by teachers in the 'Eastern Shorelines' district?
SELECT MIN(hours) FROM teacher_pd INNER JOIN teachers ON teacher_pd.teacher_id = teachers.teacher_id WHERE teachers.school_district = 'Eastern Shorelines';
gretelai_synthetic_text_to_sql
CREATE TABLE ContributorsToPolicy (id INT, contributor_name VARCHAR(50), country VARCHAR(50), contributions INT, year INT);
Who were the top 3 contributors to evidence-based policy making in Canada in 2018?
SELECT contributor_name, ROW_NUMBER() OVER (ORDER BY contributions DESC) AS rank FROM ContributorsToPolicy WHERE country = 'Canada' AND year = 2018 AND rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (Department VARCHAR(20)); INSERT INTO Departments (Department) VALUES ('IT'), ('HR'), ('Finance');
How many male and female employees work in each department?
SELECT Departments.Department, Employees.Gender, COUNT(*) FROM Departments INNER JOIN Employees ON Departments.Department = Employees.Department GROUP BY Departments.Department, Employees.Gender;
gretelai_synthetic_text_to_sql