context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE species (species_id INT, species_name TEXT);CREATE TABLE carbon_sequestration (sequestration_id INT, species_id INT, sequestration_rate FLOAT, year INT); INSERT INTO species (species_id, species_name) VALUES (1, 'Oak'), (2, 'Pine'), (3, 'Maple'); INSERT INTO carbon_sequestration (sequestration_id, species_...
What is the total carbon sequestered for each species in 2011?
SELECT species_id, species_name, SUM(sequestration_rate) FROM carbon_sequestration JOIN species ON carbon_sequestration.species_id = species.species_id WHERE year = 2011 GROUP BY species_id, species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, community INT, hours_per_week FLOAT); INSERT INTO volunteers (volunteer_id, community, hours_per_week) VALUES (1, 1, 5.0), (2, 0, 8.0), (3, 1, 3.0), (4, 0, 4.0), (5, 1, 6.0);
What is the total number of volunteer hours contributed by individuals from underrepresented communities?
SELECT SUM(hours_per_week) FROM volunteers WHERE community = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (region VARCHAR(255), initiative_cost INT, date DATE); INSERT INTO circular_economy_initiatives (region, initiative_cost, date) VALUES ('Midwest', 50000, '2021-01-01'), ('Midwest', 55000, '2021-01-02'), ('Midwest', 40000, '2021-01-01'), ('Midwest', 45000, '2021-01-02');
What is the total initiative cost for circular economy initiatives, in the Midwest region, per day, in descending order?
SELECT region, date, SUM(initiative_cost) OVER (PARTITION BY date ORDER BY date DESC) as total_initiative_cost FROM circular_economy_initiatives WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_cotton_garments (id INT, production_cost DECIMAL); INSERT INTO organic_cotton_garments (id, production_cost) VALUES (1, 25.00), (2, 30.50), (3, 28.75);
What is the average production cost for organic cotton garments?
SELECT AVG(production_cost) FROM organic_cotton_garments;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name TEXT, production INT, year INT, country TEXT); INSERT INTO crops (id, name, production, year, country) VALUES (1, 'Soybean', 3000, 2016, 'Brazil'); INSERT INTO crops (id, name, production, year, country) VALUES (2, 'Soybean', 2500, 2017, 'Argentina'); INSERT INTO crops (id, name, produc...
What is the minimum production of 'Soybean' for 'South American' countries from 2016 to 2018?
SELECT MIN(production) as min_production, country FROM crops WHERE name = 'Soybean' AND year BETWEEN 2016 AND 2018 AND country IN ('Brazil', 'Argentina', 'Bolivia') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (id INT, name VARCHAR(255), cuisine VARCHAR(255), calories INT); INSERT INTO dishes (id, name, cuisine, calories) VALUES (1, 'Chicken Tikka Masala', 'Indian', 800), (2, 'Pizza Margherita', 'Italian', 600), (3, 'Pad Thai', 'Thai', 700), (4, 'Beef Empanadas', 'Argentinian', 400), (5, 'Sushi Roll', 'Ja...
What is the name and total calorie count for the 2 dishes with the lowest calorie count for each cuisine type?
SELECT cuisine, name, SUM(calories) as total_calories FROM dishes WHERE calories IN (SELECT MIN(calories) FROM dishes WHERE cuisine = dishes.cuisine) GROUP BY cuisine, name HAVING COUNT(*) <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE algo_fairness_scores (algorithm_name VARCHAR(255), location VARCHAR(255), score DECIMAL(5,4));
Rank algorithmic fairness scores for US algorithms from highest to lowest.
SELECT algorithm_name, ROW_NUMBER() OVER (ORDER BY score DESC) as rank FROM algo_fairness_scores WHERE location = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (City_Name VARCHAR(50), Country VARCHAR(50)); INSERT INTO Cities (City_Name, Country) VALUES ('Cape Town', 'South Africa'), ('Nairobi', 'Kenya'), ('Marrakech', 'Morocco'); CREATE TABLE Visitors (Visitor_ID INT, City_Name VARCHAR(50), Visit_Year INT); INSERT INTO Visitors (Visitor_ID, City_Name, Visi...
What is the number of international visitors to each city in Africa per year?
SELECT C.Continent, C.Country, V.City_Name, V.Visit_Year, COUNT(V.Visitor_ID) AS Num_Visitors FROM Visitors V JOIN Cities C ON V.City_Name = C.City_Name JOIN Countries CO ON C.Country = CO.Country GROUP BY C.Continent, C.Country, V.City_Name, V.Visit_Year ORDER BY V.Visit_Year;
gretelai_synthetic_text_to_sql
CREATE TABLE advocacy (id INT, campaign VARCHAR(50), launch_date DATE, end_date DATE); INSERT INTO advocacy (id, campaign, launch_date, end_date) VALUES (1, 'Child Rights', '2021-01-01', '2021-12-31'), (2, 'Gender Equality', '2021-02-01', '2021-12-31');
Update the end date of the 'Child Rights' campaign in the 'advocacy' table to '2022-12-31'.
UPDATE advocacy SET end_date = '2022-12-31' WHERE campaign = 'Child Rights';
gretelai_synthetic_text_to_sql
CREATE TABLE MaintenanceRequests (RequestID int, RequestDate date, RequestRegion varchar(50)); INSERT INTO MaintenanceRequests (RequestID, RequestDate, RequestRegion) VALUES (1, '2022-01-15', 'Northeast'), (2, '2022-03-01', 'Midwest'), (3, '2022-04-10', 'South'), (4, '2022-07-05', 'West'), (5, '2022-11-28', 'Northeast'...
What is the total number of military equipment maintenance requests submitted per region?
SELECT RequestRegion, COUNT(*) as NumRequests FROM MaintenanceRequests GROUP BY RequestRegion;
gretelai_synthetic_text_to_sql
CREATE TABLE mediterranean_sea (id INT, well_name VARCHAR(255), drill_date DATE, daily_production_gas FLOAT);
What is the maximum daily production rate of gas wells in the Mediterranean Sea that were drilled after 2016?
SELECT MAX(daily_production_gas) as max_daily_production_gas FROM mediterranean_sea WHERE drill_date > '2016-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, program VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Programs (id, program, budget) VALUES (1, 'Feeding America', 10000.00); CREATE TABLE Donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, program_id INT); INSERT INTO Donations (id, donor_name...
What is the total budget for each program, and how much of it has been spent?
SELECT program, budget, SUM(donation_amount) as total_donation_amount, budget - SUM(donation_amount) as remaining_budget FROM Programs p INNER JOIN Donations d ON p.id = d.program_id GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE dissolved_oxygen (date DATE, level FLOAT); INSERT INTO dissolved_oxygen (date, level) VALUES ('2021-01-01', 6.5), ('2021-01-02', 6.8);
What is the maximum and minimum dissolved oxygen levels for each month in 2021?
SELECT EXTRACT(MONTH FROM date) as month, MAX(level) as max_level, MIN(level) as min_level FROM dissolved_oxygen WHERE date >= '2021-01-01' AND date <= '2021-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Ingredient_Inventory (ingredient_id INT, ingredient_name VARCHAR(255), quantity INT, purchase_price DECIMAL(5,2)); INSERT INTO Ingredient_Inventory (ingredient_id, ingredient_name, quantity, purchase_price) VALUES (1, 'Chickpeas', 50, 1.25), (2, 'Chicken Breast', 100, 3.50), (3, 'Quinoa', 75, 2.25);
Calculate the average inventory quantity for ingredients with a purchase price greater than $2
SELECT AVG(quantity) AS avg_inventory_quantity FROM Ingredient_Inventory WHERE purchase_price > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, Membership VARCHAR(20), JoinDate DATE); INSERT INTO Members (MemberID, Name, Age, Membership, JoinDate) VALUES (5, 'Linda Brown', 30, 'Platinum', '2022-06-15'), (6, 'David Garcia', 40, 'Gold', '2022-07-03'), (7, 'Sophia Thompson', 25, 'Silver', '2022-07-10'...
How many new members have joined in the current month?
SELECT COUNT(*) FROM Members WHERE MONTH(JoinDate) = MONTH(GETDATE()) AND YEAR(JoinDate) = YEAR(GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT, budget INT, created_at DATETIME); INSERT INTO department (id, name, budget, created_at) VALUES (1, 'education', 500000, '2021-01-01'), (2, 'transportation', 800000, '2022-01-01');
What is the total budget allocated to the 'transportation' department in 2024?
SELECT SUM(budget) FROM department WHERE name = 'transportation' AND created_at BETWEEN '2024-01-01' AND '2024-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_change_adaptation (country VARCHAR(50), year INT, projects INT); INSERT INTO climate_change_adaptation (country, year, projects) VALUES ('Guatemala', 2016, 50), ('Guatemala', 2017, 60), ('Guatemala', 2018, 70), ('Guatemala', 2019, 80), ('Guatemala', 2020, 90), ('Honduras', 2016, 40), ('Honduras', 2...
List the number of climate change adaptation projects in Central America by year.
SELECT year, SUM(projects) FROM climate_change_adaptation WHERE country IN ('Guatemala', 'Honduras') GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE student_accommodations (student_id INT, accommodation_type VARCHAR(255)); CREATE TABLE physical_impairments (student_id INT, impairment_type VARCHAR(255)); CREATE TABLE learning_disabilities (student_id INT, disability_type VARCHAR(255));
What is the total number of students who received accommodations for physical impairments and learning disabilities?
SELECT COUNT(*) FROM student_accommodations SA JOIN physical_impairments PI ON SA.student_id = PI.student_id JOIN learning_disabilities LD ON SA.student_id = LD.student_id WHERE SA.accommodation_type = 'Physical Impairment' AND LD.disability_type = 'Learning Disability';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), category VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO infrastructure_projects (id, project_name, location, category, budget) VALUES (1, 'Park Development', 'New York', 'Green Infrastructure', 2000000), (2, 'Urban Forestry',...
What is the average budget for green infrastructure projects in the United States?
SELECT AVG(budget) as avg_budget FROM infrastructure_projects WHERE category = 'Green Infrastructure' AND location = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE research_areas (area_id INT PRIMARY KEY, area_name VARCHAR(50), total_grant_amount DECIMAL(10,2));
Create a view to display the total grant amounts for each research area
CREATE VIEW vw_area_grant_totals AS SELECT area_name, SUM(total_grant_amount) AS total_grant_amount FROM research_areas GROUP BY area_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, quantity INT, sale_price DECIMAL); CREATE TABLE products (id INT, name TEXT, is_organic BOOLEAN, product_type TEXT, sale_price DECIMAL);
What's the total revenue of organic hair care products?
SELECT SUM(sales.quantity * sales.sale_price) FROM sales JOIN products ON sales.product_id = products.id WHERE products.is_organic = true AND products.product_type = 'hair care';
gretelai_synthetic_text_to_sql
CREATE TABLE subway_lines (id INT, name VARCHAR(255), length FLOAT, city VARCHAR(255)); INSERT INTO subway_lines (id, name, length, city) VALUES (1, 'Sample Subway Line', 20, 'London');
What is the total length of subway_lines in 'London'?
SELECT SUM(length) FROM subway_lines WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, exit_status TEXT); INSERT INTO companies (id, name, industry, exit_status) VALUES (1, 'TechBoost', 'Technology', 'None'); CREATE TABLE investments (id INT, company_id INT, round_size FLOAT); INSERT INTO investments (id, company_id, round_size) VALUES (1, 1, 75.0...
Update the exit status for 'TechBoost' to 'Acquired' where industry is 'Technology' and round size is greater than 50M.
UPDATE companies SET exit_status = 'Acquired' WHERE name = 'TechBoost' AND industry = 'Technology' AND id IN (SELECT company_id FROM investments WHERE round_size > 50.0);
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors_With_Disabilities (id INT, country VARCHAR(255), year INT, number_of_visitors INT);
How many visitors with disabilities visited our museums in Germany last year?
SELECT SUM(number_of_visitors) FROM Visitors_With_Disabilities WHERE country = 'Germany' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (id INT, name TEXT);CREATE TABLE policing_events (id INT, neighborhood_id INT, year INT, type TEXT);
How many community policing events were held in each neighborhood in 2021?
SELECT n.name, COUNT(pe.id) FROM neighborhoods n JOIN policing_events pe ON n.id = pe.neighborhood_id WHERE pe.year = 2021 GROUP BY n.id;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (country VARCHAR(50), capacity_mt FLOAT);
What is the maximum landfill capacity in megatons in Canada and Mexico?
SELECT MAX(capacity_mt) FROM LandfillCapacity WHERE country IN ('Canada', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE RecycledWater (id INT, state VARCHAR(20), volume FLOAT); INSERT INTO RecycledWater (id, state, volume) VALUES (1, 'Georgia', 600000.0), (2, 'Georgia', 650000.0), (3, 'Alabama', 500000.0);
What is the maximum recycled water volume for a plant in Georgia?
SELECT MAX(volume) FROM RecycledWater WHERE state = 'Georgia';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Gender TEXT); INSERT INTO Donors (DonorID, DonorName, Gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female');
What is the average donation amount by donor gender?
SELECT Gender, AVG(DonationAmount) AS AvgDonationAmount FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, city TEXT, rating FLOAT, facilities TEXT); INSERT INTO hotels (id, name, city, rating, facilities) VALUES (1, 'Hotel Ritz', 'Paris', 4.6, 'spa,pool');
What is the average rating of hotels in 'Paris' that have a 'spa' facility?
SELECT AVG(rating) FROM hotels WHERE city = 'Paris' AND 'spa' IN (facilities);
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTechnology (Country VARCHAR(50), Technology VARCHAR(50), Quantity INT); INSERT INTO MilitaryTechnology (Country, Technology, Quantity) VALUES ('USA', 'Artificial Intelligence', 500), ('China', 'Artificial Intelligence', 400), ('Russia', 'Artificial Intelligence', 300), ('USA', 'Cybersecurity', 600)...
What is the distribution of military technology by country?
SELECT Country, SUM(Quantity) as Total_Technology FROM MilitaryTechnology GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, order_date DATE, sustainable_fabric_cost DECIMAL(5,2));
What is the sum of sustainable fabric costs for each month, in descending order?
SELECT EXTRACT(MONTH FROM order_date) AS month, SUM(sustainable_fabric_cost) FROM orders WHERE sustainable = TRUE GROUP BY month ORDER BY month DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Feedback (Park VARCHAR(255), Region VARCHAR(255), Score INT); INSERT INTO Feedback (Park, Region, Score) VALUES ('Northwest Central Park', 'Northwest', 6), ('Northwest Riverfront Park', 'Northwest', 9), ('Southwest Central Park', 'Southwest', 8), ('Southeast Riverfront Park', 'Southeast', 7);
What is the minimum citizen feedback score for public parks in the Northwest region?
SELECT MIN(Score) FROM Feedback WHERE Region = 'Northwest' AND Park LIKE '%Public Park%';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, release_year INT, genre TEXT, streams INT); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (1, 'Song1', 2021, 'K-Pop', 180000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (2, 'Song2', 2021, 'K-Pop', 160000); INSERT INTO songs (id, title...
Find the difference in streams between the first and second most streamed K-Pop songs in 2021.
SELECT (MAX(streams) - MIN(streams)) AS stream_diff FROM songs WHERE release_year = 2021 AND genre = 'K-Pop';
gretelai_synthetic_text_to_sql
CREATE TABLE ReportedCrimes (ID INT, State VARCHAR(20), Year INT, Crimes INT); INSERT INTO ReportedCrimes (ID, State, Year, Crimes) VALUES (1, 'Texas', 2020, 1000);
What is the total number of reported crimes in the state of Texas in 2020?
SELECT SUM(Crimes) FROM ReportedCrimes WHERE State = 'Texas' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50)); CREATE TABLE crops_farmers (farmer_id INT, crop_id INT); CREATE TABLE crops (id INT, name VARCHAR(50)); INSERT INTO crops (id, name) VALUES (1, 'Corn'), (2, 'Soybean'); INSERT INTO farmers (id, name) VALUES (1, 'John'), (2, 'Jane'); INSERT INTO crops_farmers (farmer_id, ...
Find the names of all farmers who cultivate both corn and soybean?
SELECT f.name FROM farmers f JOIN crops_farmers cf ON f.id = cf.farmer_id JOIN crops c ON cf.crop_id = c.id WHERE c.name IN ('Corn', 'Soybean') GROUP BY f.name HAVING COUNT(DISTINCT c.name) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE City_Transport_Budget (City VARCHAR(255), Department VARCHAR(255), Budget INT); INSERT INTO City_Transport_Budget (City, Department, Budget) VALUES ('New York', 'Public Transportation', 200000000); INSERT INTO City_Transport_Budget (City, Department, Budget) VALUES ('Los Angeles', 'Public Transportation', ...
What is the total budget for public transportation in each city?
SELECT City, SUM(Budget) AS Total_Transport_Budget FROM City_Transport_Budget WHERE Department = 'Public Transportation' GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT);
Insert a new company: 'Eco Solutions' with founding year 2015
INSERT INTO company (name, founding_year) VALUES ('Eco Solutions', 2015);
gretelai_synthetic_text_to_sql
CREATE TABLE Heavy_Containers (container_id INTEGER, weight INTEGER, vessel_name TEXT, handling_date DATE); INSERT INTO Heavy_Containers (container_id, weight, vessel_name, handling_date) VALUES (1, 75, 'VesselA', '2021-03-01'), (2, 55, 'VesselB', '2021-03-02'), (3, 80, 'VesselC', '2021-01-01'), (4, 45, 'VesselD', '202...
What is the total number of containers with a weight greater than 50 metric tons that were transported by vessels in the Mediterranean in Q1 2021?
SELECT COUNT(*) FROM Heavy_Containers WHERE weight > 50 AND vessel_name IN (SELECT vessel_name FROM Heavy_Containers WHERE handling_date >= '2021-01-01' AND handling_date <= '2021-03-31' AND location = 'Mediterranean');
gretelai_synthetic_text_to_sql
CREATE SCHEMA MarineLife; CREATE TABLE SpeciesLocation (species_id INT, location VARCHAR(255)); INSERT INTO SpeciesLocation (species_id, location) VALUES (1, 'LocationA'), (2, 'LocationB'), (3, 'LocationC'), (4, 'LocationD'), (5, 'LocationB'), (6, 'LocationE');
Which locations in the 'MarineLife' schema have more than 3 marine life species?
SELECT location, COUNT(DISTINCT species_id) AS species_count FROM MarineLife.SpeciesLocation GROUP BY location HAVING species_count > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE policies(id INT, policy_name VARCHAR(50), policy_type VARCHAR(50), region_id INT);CREATE TABLE regions(id INT, region_name VARCHAR(50), country VARCHAR(50));
Identify the number of clean energy policies in the policies table for each region in the regions table.
SELECT r.region_name, COUNT(p.id) AS num_policies FROM policies p INNER JOIN regions r ON p.region_id = r.id GROUP BY p.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID INT, ClaimAmount INT, EffectiveDate DATE); INSERT INTO Claims (ClaimID, ClaimAmount, EffectiveDate) VALUES (1, 20000, '2021-01-01');
Delete claim records with claim amounts greater than $50000 and effective dates after 2022-01-01.
DELETE FROM Claims WHERE ClaimAmount > 50000 AND EffectiveDate > '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (name VARCHAR(255)); INSERT INTO neighborhoods (name) VALUES ('Chinatown'), ('Little Italy'), ('Soho'); CREATE TABLE community_engagements (id INT, neighborhood VARCHAR(255), engagement_type VARCHAR(255), engagement_time TIMESTAMP); INSERT INTO community_engagements (id, neighborhood, engagem...
How many community engagement activities have been conducted in each neighborhood?
SELECT neighborhood, COUNT(*) as total_engagements FROM community_engagements GROUP BY neighborhood;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (id INT, event_name VARCHAR(255), city VARCHAR(255), attendance INT); INSERT INTO CulturalEvents (id, event_name, city, attendance) VALUES (1, 'Event A', 'New York', 1000), (2, 'Event B', 'Toronto', 800), (3, 'Event C', 'Mexico City', 1200), (4, 'Event D', 'Los Angeles', 1500);
What is the average attendance for cultural events in each city?
SELECT city, AVG(attendance) FROM CulturalEvents GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(50), Location VARCHAR(50), WaterUsage INT); INSERT INTO MiningOperations (OperationID, MineName, Location, WaterUsage) VALUES (1, 'Crystal Mine', 'Canada', 5000), (2, 'Diamond Mine', 'Australia', 7000), (3, 'Gold Mine', 'South Africa', 6000);
What is the total water usage for mining operations in Canada?
SELECT SUM(WaterUsage) FROM MiningOperations WHERE Location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_urbanism (property_id INT, city VARCHAR(50), price INT, sustainable_project BOOLEAN); INSERT INTO sustainable_urbanism (property_id, city, price, sustainable_project) VALUES (1, 'San Francisco', 900000, TRUE), (2, 'Portland', 400000, FALSE), (3, 'San Francisco', 1000000, TRUE), (4, 'Seattle', 7...
What is the minimum price of a property in a sustainable urbanism project in San Francisco?
SELECT MIN(price) FROM sustainable_urbanism WHERE city = 'San Francisco' AND sustainable_project = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name TEXT, region TEXT); INSERT INTO Warehouse (id, name, region) VALUES (1, 'Cairo Warehouse', 'Africa'), (2, 'Johannesburg Warehouse', 'Africa'), (3, 'Nairobi Warehouse', 'Africa'); CREATE TABLE Shipment (id INT, warehouse_id INT, delivery_status TEXT); INSERT INTO Shipment (id, wareho...
How many shipments are pending delivery in each warehouse in the 'Africa' region?
SELECT Warehouse.name, COUNT(Shipment.id) as pending_shipments FROM Warehouse INNER JOIN Shipment ON Warehouse.id = Shipment.warehouse_id WHERE Warehouse.region = 'Africa' AND Shipment.delivery_status = 'Pending' GROUP BY Warehouse.name;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand TEXT); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT, ethical_line BOOLEAN); INSERT INTO brands (brand_id, brand) VALUES (1, 'Brand A'); INSERT INTO brands (brand_id, brand) VALUES (2, 'Brand B'); INSERT INTO brands (brand_id, brand) VALUES (3, 'Brand C'...
How many products does each brand offer in the ethical product line?
SELECT brand_id, COUNT(*) FROM products WHERE ethical_line = true GROUP BY brand_id;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(50), year INT, recycling_rate FLOAT);
Calculate the average recycling rate for 'Europe' in 2019 from the 'recycling_rates' table
SELECT AVG(recycling_rate) FROM recycling_rates WHERE year = 2019 AND country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_safety_protocols (protocol_id INT PRIMARY KEY, chemical_name VARCHAR(255), safety_measure TEXT);
List all chemicals with safety protocols
SELECT chemical_name FROM chemical_safety_protocols;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name STRING, location STRING, funding FLOAT);INSERT INTO biotech.startups(id, name, location, funding) VALUES (1, 'StartupA', 'France', 25000000.00), (2, 'StartupB', 'US', 20000000.00), (3, 'StartupC', 'UK', 10000000.00);
What is the maximum funding received by a biotech startup in France?
SELECT MAX(funding) FROM biotech.startups WHERE location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE Parks (ParkID INT, ParkName VARCHAR(255), Borough VARCHAR(255), CreationDate DATE); INSERT INTO Parks (ParkID, ParkName, Borough, CreationDate) VALUES (1, 'Central Park', 'Manhattan', '2015-07-01'), (2, 'Prospect Park', 'Brooklyn', '2016-04-01'), (3, 'Van Cortlandt Park', 'Bronx', '2017-08-01');
How many public parks have been created in each borough since 2015?
SELECT COUNT(*), Borough FROM Parks WHERE CreationDate >= '2015-01-01' GROUP BY Borough;
gretelai_synthetic_text_to_sql
CREATE TABLE yttrium_prices (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO yttrium_prices (country, price, year) VALUES ('India', 65.00, 2018), ('India', 62.00, 2019), ('India', 60.00, 2020);
What is the lowest price of yttrium in India?
SELECT MIN(price) FROM yttrium_prices WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), type VARCHAR(255), population INT, location VARCHAR(255)); INSERT INTO marine_species (id, name, type, population, location) VALUES (1, 'Bottlenose Dolphin', 'Mammal', 600000, 'Pacific Ocean'), (2, 'Humpback Whale', 'Mammal', 40000, 'Atlantic Ocean'), (3, 'Sea Ott...
How many marine mammals are there in the Pacific Ocean and the Atlantic Ocean?
SELECT location, SUM(population) FROM marine_species WHERE type = 'Mammal' AND location IN ('Pacific Ocean', 'Atlantic Ocean') GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, year INT, region VARCHAR(20), equipment_type VARCHAR(20), value FLOAT); INSERT INTO military_sales (id, year, region, equipment_type, value) VALUES (1, 2020, 'Africa', 'Missiles', 10000000); INSERT INTO military_sales (id, year, region, equipment_type, value) VALUES (2, 2020, 'Afric...
What was the maximum value of military equipment sales to the African governments in 2020?
SELECT MAX(value) FROM military_sales WHERE year = 2020 AND region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissionRecords (mission_name VARCHAR(30), astronaut_name VARCHAR(30), country VARCHAR(20), mission_duration INT); INSERT INTO SpaceMissionRecords (mission_name, astronaut_name, country, mission_duration) VALUES ('Moon Landing', 'Jacob Johnson', 'Canada', 120), ('Mars Exploration', 'Emily Brown', 'Cana...
What is the maximum duration of space missions led by Canadian astronauts?
SELECT MAX(mission_duration) FROM SpaceMissionRecords WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN);
Determine the number of games played by each team in the teams table
SELECT teams.name, COUNT(games.game_id) AS games_played FROM teams LEFT JOIN games ON teams.team_id = games.team_id GROUP BY teams.name;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech (id INT, name VARCHAR(255), type VARCHAR(255), country VARCHAR(255), date DATE); INSERT INTO military_tech (id, name, type, country, date) VALUES (1, 'F-35', 'Fighter Jet', 'USA', '2005-06-01'); INSERT INTO military_tech (id, name, type, country, date) VALUES (2, 'Type 45 Destroyer', 'Warship...
What is the ranking of military technologies for India based on the introduction date?
SELECT name, type, country, date, ROW_NUMBER() OVER (PARTITION BY country ORDER BY date DESC) as ranking FROM military_tech WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, country VARCHAR(50), is_recycled BOOLEAN, revenue DECIMAL(10, 2));
What is the total revenue of products made from recycled materials, grouped by country?
SELECT country, SUM(revenue) FROM products WHERE is_recycled = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicle (id INT, make VARCHAR(255), model VARCHAR(255), horsepower INT, transmission VARCHAR(255)); INSERT INTO Vehicle (id, make, model, horsepower, transmission) VALUES (1, 'Subaru', 'WRX', 310, 'Manual');
What is the maximum horsepower of vehicles with a manual transmission in the Vehicle table?
SELECT MAX(horsepower) FROM Vehicle WHERE transmission = 'Manual';
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (id INT, year INT, region VARCHAR(20), revenue INT); INSERT INTO esports_events (id, year, region, revenue) VALUES (1, 2018, 'North America', 1000000), (2, 2019, 'Europe', 2000000), (3, 2020, 'Asia', 1500000);
What is the total revenue generated by esports events in Europe?
SELECT SUM(revenue) FROM esports_events WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Continent (ContinentID int, ContinentName varchar(50)); INSERT INTO Continent (ContinentID, ContinentName) VALUES (1, 'Asia'), (2, 'Europe'), (3, 'Africa'), (4, 'South America'); CREATE TABLE SustainableTourism (STID int, ContinentID int, InitiativeCount int, Year int); INSERT INTO SustainableTourism (STID...
How many sustainable tourism initiatives were launched in South America in 2021?
SELECT SUM(InitiativeCount) as TotalInitiatives FROM SustainableTourism JOIN Continent ON SustainableTourism.ContinentID = Continent.ContinentID WHERE ContinentName = 'South America' AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation (id INT, initiative_name VARCHAR(50), location VARCHAR(50), start_year INT, end_year INT); INSERT INTO climate_mitigation (id, initiative_name, location, start_year, end_year) VALUES (1, 'Tree Planting', 'South America', 2010, 2022);
How many climate mitigation initiatives were carried out in South America in each year from 2010 to 2022?
SELECT start_year, COUNT(*) as initiative_count FROM climate_mitigation WHERE location = 'South America' GROUP BY start_year;
gretelai_synthetic_text_to_sql
CREATE TABLE nba_players_ec (id INT, name VARCHAR(100), team VARCHAR(100), conference VARCHAR(50), salary DECIMAL(10, 2)); INSERT INTO nba_players_ec (id, name, team, conference, salary) VALUES (1, 'Giannis Antetokounmpo', 'Bucks', 'Eastern', 40000000), (2, 'Kyrie Irving', 'Nets', 'Eastern', 36000000), (3, 'Joel Embiid...
Find the maximum salary for players in the NBA's Eastern Conference.
SELECT MAX(salary) FROM nba_players_ec WHERE conference = 'Eastern';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name TEXT, age INT);
What is the number of volunteers in each age group?
SELECT FLOOR(age / 10) * 10 as age_group, COUNT(*) as number_of_volunteers FROM Volunteers GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (id INT, city VARCHAR(50), country VARCHAR(50), system VARCHAR(50)); INSERT INTO public_transportation (id, city, country, system) VALUES (1, 'Toronto', 'Canada', 'Subway'), (2, 'Montreal', 'Canada', 'Bus'), (3, 'New York', 'USA', 'Subway'), (4, 'Los Angeles', 'USA', 'Bus');
Which public transportation systems are available in Canada and the United States?
SELECT DISTINCT system FROM public_transportation WHERE country IN ('Canada', 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovations (id INT, innovation VARCHAR(255), country VARCHAR(255), innovation_date DATE);
What is the most recent military innovation for each country?
SELECT country, MAX(innovation_date) as max_innovation_date FROM MilitaryInnovations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridge_Inspections (inspection_id INT, bridge_name VARCHAR(50), bridge_type VARCHAR(50), inspection_date DATE);
Calculate the average age of all bridges in the Bridge_Inspections table
SELECT AVG(DATEDIFF(CURRENT_DATE, inspection_date) / 365.25) FROM Bridge_Inspections WHERE bridge_type = 'Bridge';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists transportation (transport_id INT, transport VARCHAR(20), co2_emission INT); INSERT INTO transportation (transport_id, transport, co2_emission) VALUES (1, 'Airplane', 445), (2, 'Train', 14), (3, 'Car', 185), (4, 'Bus', 80), (5, 'Bicycle', 0);
What is the total CO2 emission of each transportation method?
SELECT transport, SUM(co2_emission) as total_emission FROM transportation GROUP BY transport;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (vid INT, name TEXT);CREATE TABLE Dishes (did INT, name TEXT, calorie_count INT);CREATE TABLE Ingredients (iid INT, dish_id INT, vendor_id INT);INSERT INTO Vendors VALUES (1, 'VendorA');INSERT INTO Dishes VALUES (1, 'DishA', 3000);INSERT INTO Ingredients VALUES (1, 1, 1);
List all vendors that supply ingredients for a dish with a calorie count higher than 2000.
SELECT DISTINCT Vendors.name FROM Vendors INNER JOIN Ingredients ON Vendors.vid = Ingredients.vendor_id INNER JOIN Dishes ON Ingredients.dish_id = Dishes.did WHERE Dishes.calorie_count > 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (model_name TEXT, satisfaction_score INTEGER, quarter TEXT); INSERT INTO explainable_ai (model_name, satisfaction_score, quarter) VALUES ('Model1', 80, 'Q1 2020'), ('Model2', 85, 'Q2 2021'), ('Model3', 90, 'Q3 2019'), ('Model4', 87, 'Q4 2021');
What is the average satisfaction score for AI models developed in Q2 of 2021?
SELECT AVG(satisfaction_score) FROM explainable_ai WHERE quarter = 'Q2 2021';
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (date DATE, borough VARCHAR(255)); INSERT INTO accidents (date, borough) VALUES ('2021-01-01', 'Manhattan'), ('2021-01-02', 'Brooklyn'), ('2021-01-03', 'Queens'), ('2021-01-04', 'Bronx'), ('2021-01-05', 'Staten Island');
How many traffic accidents occurred in each borough of New York City in the past year?
SELECT s1.borough, COUNT(s1.date) as num_accidents FROM accidents s1 WHERE s1.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY s1.borough;
gretelai_synthetic_text_to_sql
CREATE TABLE day_of_week (day_id int, day_name varchar(10));CREATE TABLE public_transportation (ride_id int, day_id int, num_passengers int);
Identify the busiest day of the week for public transportation in New York
SELECT day_name, AVG(num_passengers) as avg_passengers FROM day_of_week JOIN public_transportation ON day_of_week.day_id = public_transportation.day_id GROUP BY day_name ORDER BY avg_passengers DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents(id INT, incident_type VARCHAR(50), incidents INT, incident_date DATE);
What is the total number of security incidents by type in the last quarter?
SELECT incident_type, SUM(incidents) as total_incidents FROM SecurityIncidents WHERE incident_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 3 MONTH) GROUP BY incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE military_training (country VARCHAR(255), trainee_count INT, training_date DATE);
What is the total number of military personnel from African countries that have received training in the US since 2010?
SELECT SUM(trainee_count) FROM military_training WHERE country LIKE 'Africa%' AND training_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, site_name VARCHAR(255)); CREATE TABLE artifacts (id INT, excavation_site_id INT, artifact_type VARCHAR(255), weight FLOAT);
What are the average weights of pottery artifacts from each excavation site?
SELECT e.site_name, AVG(a.weight) AS avg_weight FROM artifacts a JOIN excavation_sites e ON a.excavation_site_id = e.id GROUP BY e.site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryEvents (EventID INT, Country VARCHAR(50), EventType VARCHAR(50)); INSERT INTO CountryEvents (EventID, Country, EventType) VALUES (1, 'USA', 'Esports'), (2, 'Canada', 'Esports'), (3, 'Mexico', 'Esports'), (4, 'Germany', 'Esports'), (5, 'France', 'Esports'), (6, 'USA', 'Local'), (7, 'Canada', 'Local')...
What is the total number of esports events in each country?
SELECT Country, COUNT(*) FROM CountryEvents WHERE EventType = 'Esports' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE harvests (harvest_id INT, weight DECIMAL(10, 2), grow_type VARCHAR(255)); INSERT INTO harvests (harvest_id, weight, grow_type) VALUES (1, 500.00, 'indoor'), (2, 350.00, 'outdoor'), (3, 700.50, 'greenhouse'); CREATE TABLE grow_operations (grow_operation_id INT, name VARCHAR(255), state VARCHAR(255)); INSERT...
What is the total weight of each harvest for indoor grow operations in Oregon?
SELECT go.name, SUM(h.weight) FROM harvests h INNER JOIN grow_operations go ON h.grow_type = 'indoor' AND h.grow_operation_id = go.grow_operation_id WHERE go.state = 'OR' GROUP BY go.name;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_incidents (report_year INT, location VARCHAR(255), incident_count INT); INSERT INTO pollution_incidents (report_year, location, incident_count) VALUES (2020, 'Mediterranean', 15), (2019, 'Mediterranean', 12);
How many pollution incidents were reported in the Mediterranean in 2020?
SELECT SUM(incident_count) FROM pollution_incidents WHERE report_year = 2020 AND location = 'Mediterranean';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), email VARCHAR(50), last_login DATE);
Delete records of users who have not logged in for the last three months from the users table
DELETE FROM users WHERE last_login < DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE public_defenders (defender_id INT, defender_state VARCHAR(2)); INSERT INTO public_defenders VALUES (1, 'NY'), (2, 'CA'), (3, 'IL');
How many defendants were represented by public defenders for each state?
SELECT pd.defender_state, COUNT(dd.defendant_id) FROM public_defenders pd INNER JOIN defendant_data dd ON pd.defender_id = dd.defender_id GROUP BY pd.defender_state;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (item_id INT, item_name VARCHAR(20), quantity INT); INSERT INTO inventory (item_id, item_name, quantity) VALUES (1, 'apples', 50), (2, 'bananas', 75), (3, 'oranges', 30);
List the top 3 item names with the highest quantity from the 'inventory' table.
SELECT item_name, quantity FROM inventory ORDER BY quantity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tour_companies (company_id INT, name VARCHAR(50), country VARCHAR(50));
Delete all records from the tour_companies table.
DELETE FROM tour_companies;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_ingredients(product_name TEXT, organic_weight DECIMAL(5,2), ingredient TEXT, country TEXT); INSERT INTO organic_ingredients VALUES ('Lotion', 1.0, 'Organic Aloe Vera', 'France'); INSERT INTO organic_ingredients VALUES ('Lotion', 0.5, 'Organic Coconut Oil', 'France'); INSERT INTO organic_ingredients...
What is the average weight of organic ingredients in lotion sold in France?
SELECT AVG(organic_weight) FROM (SELECT organic_weight FROM organic_ingredients WHERE country = 'France' AND ingredient LIKE 'Organic%' GROUP BY organic_weight) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (operation_id INT, operation_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE, cost DECIMAL(10,2)); INSERT INTO humanitarian_assistance (operation_id, operation_name, region, start_date, end_date, cost) VALUES (1, 'Operation A', 'Caribbean', '2019-01-01', '2019...
What was the total cost of all humanitarian assistance operations in the Caribbean in 2019?
SELECT SUM(cost) FROM humanitarian_assistance INNER JOIN operations ON humanitarian_assistance.operation_id = operations.operation_id WHERE region = 'Caribbean' AND YEAR(start_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (ID INT, Agency VARCHAR(50), Status VARCHAR(50), Quantity INT); INSERT INTO SatelliteDeployments (ID, Agency, Status, Quantity) VALUES (1, 'SpaceX', 'Success', 200), (2, 'ROSCOSMOS', 'Success', 100), (3, 'SpaceX', 'Failure', 5), (4, 'ROSCOSMOS', 'Failure', 15);
Identify the number of successful and failed satellite deployments by SpaceX and ROSCOSMOS.
SELECT Agency, Status, SUM(Quantity) FROM SatelliteDeployments GROUP BY Agency, Status;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, region VARCHAR(255), year INT); INSERT INTO projects (id, region, year) VALUES (1, 'North America', 2018), (2, 'Europe', 2021), (3, 'North America', 2019), (4, 'North America', 2020), (5, 'North America', 2021), (6, 'Europe', 2022);
What is the average number of defense projects per year in the North America region for the past 5 years?
SELECT AVG(year) as avg_year FROM projects WHERE region = 'North America' AND year BETWEEN (YEAR(CURRENT_DATE()) - 5) AND YEAR(CURRENT_DATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (id INT, name VARCHAR(255), launch_date DATE, manufacturing_cost FLOAT); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (1, 'Sputnik 1', '1957-10-04', 140000); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (2, 'Explorer 1', '1958-01-31', ...
Delete the record of the spacecraft that was launched before the first spacecraft.
DELETE FROM Spacecrafts WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN, price DECIMAL(5,2), attendance INT, year INT);INSERT INTO teams (team_id, team_name) VALUES (1, 'Rangers'), (2, 'Bulls');INSERT INTO games (game_id, team_id, home_team, price, attendance, year) VALUE...
List the total number of tickets sold for home games of each team, considering only games from the 2022 season.
SELECT t.team_name, SUM(g.price * g.attendance) AS total_revenue FROM teams t INNER JOIN games g ON t.team_id = g.team_id AND g.home_team = t.team_id WHERE g.year = 2022 GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE BioSolutions_ClinicalTrials(company VARCHAR(20), year INT, trials INT); INSERT INTO BioSolutions_ClinicalTrials VALUES('BioSolutions', 2019, 12); INSERT INTO BioSolutions_ClinicalTrials VALUES('BioSolutions', 2020, 18);
How many clinical trials did 'BioSolutions' conduct in 2019 and 2020?
SELECT SUM(trials) FROM BioSolutions_ClinicalTrials WHERE company = 'BioSolutions' AND year IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_veteran BOOLEAN); INSERT INTO company (id, name, founding_year, founder_veteran) VALUES (1, 'Acme Inc', 2010, true); INSERT INTO company (id, name, founding_year, founder_veteran) VALUES (2, 'Beta Corp', 2015, false);
What is the average number of employees for companies founded by veterans?
SELECT AVG(num_employees) FROM company_data INNER JOIN company ON company_data.company_id = company.id WHERE company.founder_veteran = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Hiring (HireID int, HireDate date); INSERT INTO Hiring (HireID, HireDate) VALUES (1, '2022-04-01'), (2, '2022-07-15'), (3, '2022-03-30');
How many employees were hired in Q2 of 2022?
SELECT COUNT(*) FROM Hiring WHERE HireDate BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE CriminalJustice (case_id INT, case_status VARCHAR(10)); INSERT INTO CriminalJustice (case_id, case_status) VALUES (1, 'pending'), (2, 'closed'), (3, 'pending'), (4, 'closed');
Find the total number of cases in the 'CriminalJustice' table and the number of cases with 'case_status' of 'pending'
SELECT COUNT(*) AS total_cases, SUM(CASE WHEN case_status = 'pending' THEN 1 ELSE 0 END) AS pending_cases FROM CriminalJustice;
gretelai_synthetic_text_to_sql
CREATE TABLE Training_Programs (Program_ID INT, Program_Name VARCHAR(50), Instructor_ID INT, Start_Date DATE, End_Date DATE); CREATE TABLE Instructors (Instructor_ID INT, First_Name VARCHAR(20), Last_Name VARCHAR(20)); CREATE TABLE Participation (Participant_ID INT, Program_ID INT, Participation_Date DATE);
What is the name of the instructor for the Python for Data Analysis training program?
SELECT i.First_Name, i.Last_Name FROM Instructors i JOIN Training_Programs tp ON i.Instructor_ID = tp.Instructor_ID WHERE tp.Program_Name = 'Python for Data Analysis';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (hash VARCHAR(64), value INT, timestamp TIMESTAMP);
Delete transactions with a value greater than 10000 from the 'transactions' table.
DELETE FROM transactions WHERE value > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO readers (id, name, country) VALUES (1, 'Alice Johnson', 'United States'); INSERT INTO readers (id, name, country) VALUES (2, 'Bob Williams', 'Canada');
Delete all records from the 'readers' table where 'country' is 'United States'
DELETE FROM readers WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, name VARCHAR(30)); INSERT INTO Programs (id, name) VALUES (1, 'Community Education Program 1'), (2, 'Habitat Restoration Program 2'); CREATE TABLE Animals_In_Programs (program_id INT, animal_id INT, species VARCHAR(20)); INSERT INTO Animals_In_Programs (program_id, animal_id, species) VAL...
How many animals are there in each program?
SELECT program_id, COUNT(animal_id) AS animal_count FROM Animals_In_Programs GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects_africa (id INT, country VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO climate_projects_africa (id, country, sector, funding) VALUES (1, 'Nigeria', 'Climate Communication', 150000); INSERT INTO climate_projects_africa (id, country, sector, funding) VALUES (2, 'Kenya', 'Climat...
What is the average funding for climate communication projects in Africa?
SELECT AVG(funding) FROM climate_projects_africa WHERE sector = 'Climate Communication' AND country IN ('Nigeria', 'Kenya', 'South Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE EmploymentStats (state VARCHAR(255), year INT, industry VARCHAR(255), veteran_employment_rate FLOAT); INSERT INTO EmploymentStats (state, year, industry, veteran_employment_rate) VALUES ('California', 2021, 'Defense', 0.15), ('New York', 2020, 'Defense', 0.13);
What is the employment rate for veterans in the defense industry in New York as of 2020?
SELECT veteran_employment_rate FROM EmploymentStats WHERE state = 'New York' AND year = 2020 AND industry = 'Defense';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtMovementSales (ArtMovement VARCHAR(255), ArtWork VARCHAR(255), Year INT, Revenue DECIMAL(10,2)); INSERT INTO ArtMovementSales (ArtMovement, ArtWork, Year, Revenue) VALUES ('Post-Impressionism', 'Artwork 1', 2021, 500.00), ('Post-Impressionism', 'Artwork 2', 2021, 400.00), ('Pop Art', 'Artwork 3', 2021, ...
What was the total revenue for each art movement's works sold in 2021?
SELECT ArtMovement, SUM(Revenue) as TotalRevenue FROM ArtMovementSales WHERE Year = 2021 GROUP BY ArtMovement;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name TEXT); INSERT INTO Artists (id, name) VALUES (1, 'Paul Cezanne'), (2, 'Georges Seurat'), (3, 'Vincent Van Gogh'); CREATE TABLE Artwork (id INT, title TEXT, artist_id INT); INSERT INTO Artwork (id, title, artist_id) VALUES (1, 'The Card Players', 1), (2, 'Bathers', 1), (3, 'A Sunday on...
Delete artists without any artwork in 'Artists' table.
DELETE FROM Artists WHERE id NOT IN (SELECT artist_id FROM Artwork);
gretelai_synthetic_text_to_sql