context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE DigitalAssets (name VARCHAR(255), country VARCHAR(255)); INSERT INTO DigitalAssets (name, country) VALUES ('Asset1', 'USA'), ('Asset2', 'Canada');
Find the total number of digital assets issued in the US and their respective names
SELECT SUM(CASE WHEN country = 'USA' THEN 1 ELSE 0 END) as total_assets, name FROM DigitalAssets WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE production (site_id INT, production_date DATE, quantity INT);
Calculate the percentage change in production for each site, compared to the previous month.
SELECT site_id, production_date, (LAG(quantity) OVER (PARTITION BY site_id ORDER BY production_date) - quantity) * 100.0 / LAG(quantity) OVER (PARTITION BY site_id ORDER BY production_date) as pct_change FROM production;
gretelai_synthetic_text_to_sql
CREATE TABLE SubwayFares (FareID INT, TripID INT, Fare FLOAT);
What is the total fare revenue for the subway system in the last quarter?
SELECT SUM(Fare) FROM SubwayFares JOIN TrainTrips ON SubwayFares.TripID = TrainTrips.TripID WHERE TrainTrips.TripDate >= DATEADD(QUARTER, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE epl_players (player_id INT, player_name VARCHAR(50), team_id INT, team_name VARCHAR(50), age INT); INSERT INTO epl_players (player_id, player_name, team_id, team_name, age) VALUES (1, 'Harry Kane', 1, 'Tottenham Hotspur', 29), (2, 'Mohamed Salah', 2, 'Liverpool', 30), (3, 'Virgil van Dijk', 2, 'Liverpool', 31);
What is the average age of soccer players in the English Premier League?
SELECT AVG(age) FROM epl_players;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2), DonorType VARCHAR(50)); CREATE VIEW DonorTypes AS SELECT DISTINCT DonorType FROM Donations;
What is the total donation amount for each donor type in the last quarter?
SELECT dt.DonorType, SUM(d.DonationAmount) FROM Donations d JOIN DonorTypes dt ON d.DonorType = dt.DonorType WHERE d.DonationDate >= DATEADD(quarter, -1, GETDATE()) GROUP BY dt.DonorType;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), runtime_minutes INT, production_year INT, producer VARCHAR(255)); INSERT INTO tv_shows (id, title, runtime_minutes, production_year, producer) VALUES (1, 'Show1', 420, 2018, 'Diverse Producers'); INSERT INTO tv_shows (id, title, runtime_minutes, production_year, producer) VALUES (2, 'Show2', 300, 2019, 'Diverse Producers'); INSERT INTO tv_shows (id, title, runtime_minutes, production_year, producer) VALUES (3, 'Show3', 450, 2018, 'Other Producers');
What is the total runtime of TV shows produced by 'Diverse Producers' in 2018 and 2019?
SELECT SUM(runtime_minutes) FROM tv_shows WHERE production_year BETWEEN 2018 AND 2019 AND producer = 'Diverse Producers';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesDataCrueltyFree (sale_id INT, product_id INT, sale_date DATE, sale_revenue FLOAT, is_cruelty_free BOOLEAN); INSERT INTO SalesDataCrueltyFree (sale_id, product_id, sale_date, sale_revenue, is_cruelty_free) VALUES (1, 1, '2022-01-02', 75, true), (2, 2, '2022-01-15', 30, false), (3, 3, '2022-01-28', 60, false), (4, 4, '2022-01-10', 120, true), (5, 5, '2022-01-22', 45, false);
Determine the percentage of sales revenue for products that are labeled 'cruelty-free', considering only sales from the past month.
SELECT (SUM(sale_revenue) / (SELECT SUM(sale_revenue) FROM SalesDataCrueltyFree WHERE sale_date >= DATEADD(month, -1, GETDATE()))) * 100 as revenue_percentage FROM SalesDataCrueltyFree WHERE is_cruelty_free = true AND sale_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, city VARCHAR(50), date DATE); INSERT INTO Events (id, city, date) VALUES (1, 'New York City', '2021-05-01'), (2, 'Los Angeles', '2021-05-02'); CREATE TABLE Audience (id INT, event_id INT, age_group VARCHAR(20)); INSERT INTO Audience (id, event_id, age_group) VALUES (1, 1, '18-24'), (2, 1, '25-34'), (3, 2, '35-44');
What is the distribution of audience members by age group, for events held in New York City, in the past year?
SELECT e.city, a.age_group, COUNT(a.id) AS count FROM Events e INNER JOIN Audience a ON e.id = a.event_id WHERE e.city = 'New York City' AND e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY e.city, a.age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name VARCHAR(255), length FLOAT, fare FLOAT);
What is the total fare collected for each route in the 'routes' table?
SELECT route_name, SUM(fare) as total_fare FROM routes GROUP BY route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries(CountryID INT, CountryName TEXT); CREATE TABLE PeacekeepingMissions(MissionID INT, MissionName TEXT, CountryID INT, StartDate DATE, EndDate DATE);
What is the total number of peacekeeping missions led by each country, and the average duration of these missions, for countries that have led more than 5 missions, ordered by the average mission duration in descending order?
SELECT CountryName, COUNT(MissionID) as NumMissions, AVG(DATEDIFF(EndDate, StartDate)) as AvgMissionDuration FROM PeacekeepingMissions JOIN Countries ON PeacekeepingMissions.CountryID = Countries.CountryID GROUP BY CountryName HAVING NumMissions > 5 ORDER BY AvgMissionDuration DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, region VARCHAR(50), severity VARCHAR(10)); INSERT INTO incidents (incident_id, region, severity) VALUES (1, 'region_1', 'medium'), (2, 'region_2', 'high'), (3, 'region_3', 'high'), (4, 'region_1', 'low'), (5, 'region_3', 'medium');
What are the unique severity levels in the 'incidents' table?
SELECT DISTINCT severity FROM incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance (id INT, workshop_date DATE, num_attendees INT); INSERT INTO attendance (id, workshop_date, num_attendees) VALUES (1, '2021-01-01', 25), (2, '2021-02-15', 30), (3, '2021-03-10', 20), (4, '2022-04-01', 35);
What is the average attendance at workshops held in the last year?
SELECT AVG(num_attendees) as avg_attendance FROM attendance WHERE workshop_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT PRIMARY KEY, mine_name VARCHAR(255), location VARCHAR(255), resource VARCHAR(255), open_date DATE);
Update the open date of the 'Topaz Twilight' mine in Nunavut, Canada
UPDATE mining_operations SET open_date = '2022-03-15' WHERE mine_name = 'Topaz Twilight';
gretelai_synthetic_text_to_sql
CREATE TABLE Ports (PortID INT, PortName VARCHAR(100), City VARCHAR(100), Country VARCHAR(100)); INSERT INTO Ports (PortID, PortName, City, Country) VALUES (1, 'Port of Los Angeles', 'Los Angeles', 'USA'); INSERT INTO Ports (PortID, PortName, City, Country) VALUES (2, 'Port of Rotterdam', 'Rotterdam', 'Netherlands'); CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), VesselType VARCHAR(100), PortID INT); INSERT INTO Vessels (VesselID, VesselName, VesselType, PortID) VALUES (1, 'Ever Ace', 'Container Ship', 1);
List the names of ports where the Ever Ace has docked.
SELECT Ports.PortName FROM Ports INNER JOIN Vessels ON Ports.PortID = Vessels.PortID WHERE Vessels.VesselName = 'Ever Ace';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), monthly_cost DECIMAL(10,2)); INSERT INTO mobile_plans (plan_id, plan_name, monthly_cost) VALUES (1, 'Basic', 30.00), (2, 'Premium', 60.00);
Update the monthly cost of the "Premium" mobile plan to 70.00
UPDATE mobile_plans SET monthly_cost = 70.00 WHERE plan_name = 'Premium';
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (InspectionID INT, RestaurantID INT, InspectionDate DATETIME, ViolationCount INT);
Show the number of food safety inspections and the percentage of inspections with violations for restaurants in Texas, for the last 6 months.
SELECT RestaurantID, COUNT(*) OVER (PARTITION BY RestaurantID) as TotalInspections, (COUNT(*) FILTER (WHERE ViolationCount > 0) OVER (PARTITION BY RestaurantID) * 100.0 / COUNT(*) OVER (PARTITION BY RestaurantID)) as ViolationPercentage FROM Inspections WHERE RestaurantID IN (SELECT RestaurantID FROM Restaurants WHERE State = 'Texas') AND InspectionDate > CURRENT_DATE - INTERVAL '6 months';
gretelai_synthetic_text_to_sql
CREATE TABLE zinc_production (country VARCHAR(20), quantity INT); INSERT INTO zinc_production (country, quantity) VALUES ('China', 3000), ('India', 2500);
Which country has the lowest total zinc production, China or India?
SELECT country, MIN(quantity) FROM zinc_production WHERE country IN ('China', 'India') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255), college VARCHAR(255));CREATE TABLE grant (id INT, department_id INT, title VARCHAR(255), amount DECIMAL(10,2), year INT);
What is the total amount of research grants awarded to the Department of Physics in the last 5 years?
SELECT SUM(amount) FROM grant g JOIN department d ON g.department_id = d.id WHERE d.name = 'Department of Physics' AND g.year >= YEAR(CURDATE()) - 5;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), energy_savings FLOAT); INSERT INTO smart_city_projects (id, project_name, city, country, energy_savings) VALUES (1, 'Barcelona Smart Grid', 'Barcelona', 'Spain', 15.2);
What is the average energy savings of smart city projects in Barcelona, Spain?
SELECT AVG(energy_savings) FROM smart_city_projects WHERE city = 'Barcelona' AND country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE HempProduction (id INT, garment_type VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO HempProduction (id, garment_type, cost) VALUES (1, 'T-Shirt', 15.50), (2, 'Pants', 25.00), (3, 'Dress', 55.99);
What is the minimum production cost for a garment made from hemp?
SELECT MIN(cost) FROM HempProduction WHERE garment_type IN ('T-Shirt', 'Pants', 'Dress');
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects ( id INT PRIMARY KEY, project_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255), status VARCHAR(255) );
What is the total number of smart city technology projects in the city of Vancouver, Canada, that have a status of 'Active' or 'In Progress'?
SELECT COUNT(*) FROM smart_city_projects WHERE city = 'Vancouver' AND country = 'Canada' AND (status = 'Active' OR status = 'In Progress');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (destination VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (destination, year, visitors) VALUES ('Japan', 2018, 13000000), ('Japan', 2019, 15000000), ('Canada', 2018, 21000000), ('Canada', 2019, 23000000), ('France', 2018, 22000000), ('France', 2019, 24000000), ('City A', 2018, 500000), ('City A', 2019, 700000), ('City B', 2018, 800000), ('City B', 2019, 1000000);
Show the top 3 destinations with the highest increase in tourists from 2018 to 2019
SELECT destination, (visitors - (SELECT visitors FROM tourism_stats t2 WHERE t2.destination = t1.destination AND t2.year = 2018)) AS diff FROM tourism_stats t1 WHERE year = 2019 ORDER BY diff DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (FactoryID int, FactoryName varchar(50), Country varchar(50)); INSERT INTO Factories (FactoryID, FactoryName, Country) VALUES (1, 'EcoFactory', 'Bangladesh'); INSERT INTO Factories (FactoryID, FactoryName, Country) VALUES (2, 'GreenManufacturing', 'India'); CREATE TABLE Sourcing (FactoryID int, SustainableSourcePercentage decimal(5,2)); INSERT INTO Sourcing (FactoryID, SustainableSourcePercentage) VALUES (1, 0.85); INSERT INTO Sourcing (FactoryID, SustainableSourcePercentage) VALUES (2, 0.90);
List all factories in countries with a high percentage of sustainable textile sourcing, ordered alphabetically by factory name.
SELECT f.FactoryName FROM Factories f INNER JOIN Sourcing s ON f.FactoryID = s.FactoryID WHERE s.SustainableSourcePercentage >= 0.80 GROUP BY f.FactoryName ORDER BY f.FactoryName ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (mission_id INT, agency VARCHAR(255), year INT, mission_name VARCHAR(255));
List all space exploration missions conducted by the European Space Agency since 2010.
SELECT mission_name FROM SpaceMissions WHERE agency = 'European Space Agency' AND year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_type VARCHAR(255), location VARCHAR(255)); INSERT INTO wells VALUES (1, 'Well Z', 'Offshore', 'Gulf of Mexico');
What is the production rate trend for well 'Well Z' in the past 90 days?
SELECT production_rate, date FROM (SELECT production_rate, date, row_number() OVER (ORDER BY date DESC) as rn FROM well_production WHERE well_name = 'Well Z' AND date >= CURRENT_DATE - INTERVAL '90 days' ORDER BY date DESC) WHERE rn <= 90;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN, is_organic BOOLEAN); INSERT INTO Products (product_id, product_name, is_cruelty_free, is_organic) VALUES (1, 'Product A', true, false), (2, 'Product B', true, true), (3, 'Product C', false, true), (4, 'Product D', false, false);
Find the number of unique cruelty-free beauty products and the number of unique organic beauty products, and then identify the products that are both cruelty-free and organic.
SELECT COUNT(DISTINCT product_id) as cruelty_free_count FROM Products WHERE is_cruelty_free = true; SELECT COUNT(DISTINCT product_id) as organic_count FROM Products WHERE is_organic = true; SELECT product_id FROM Products WHERE is_cruelty_free = true AND is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Carrier (CarrierID INT, CarrierName TEXT, Country TEXT); INSERT INTO Carrier (CarrierID, CarrierName, Country) VALUES (1, 'Global Logistics', 'USA'), (2, 'Canada Shipping', 'Canada'), (3, 'Oceanic Freight', 'Australia'); CREATE TABLE Contract (ContractID INT, CarrierID INT, ContractType TEXT); INSERT INTO Contract (ContractID, CarrierID, ContractType) VALUES (1, 1, 'Freight'), (2, 2, 'Freight'), (3, 1, 'ReverseLogistics');
Find carriers sharing the same country with carriers having reverse logistics contracts?
SELECT DISTINCT c1.CarrierName, c1.Country FROM Carrier c1 JOIN Carrier c2 ON c1.Country = c2.Country WHERE c2.CarrierID IN (SELECT CarrierID FROM Contract WHERE ContractType = 'ReverseLogistics');
gretelai_synthetic_text_to_sql
CREATE TABLE Wastewater_Plant (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO Wastewater_Plant (id, state, water_usage) VALUES (1, 'California', 12000.0), (2, 'Texas', 9000.0), (3, 'Florida', 8000.0), (4, 'California', 15000.0), (5, 'New_York', 7000.0);
List the top 3 states with the highest water usage in wastewater treatment plants?
SELECT state, water_usage FROM Wastewater_Plant ORDER BY water_usage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (id INT, name VARCHAR(50), budget DECIMAL(10,2), region VARCHAR(50)); INSERT INTO biotech_startups (id, name, budget, region) VALUES (1, 'Genetix', 5000000.00, 'Africa'); INSERT INTO biotech_startups (id, name, budget, region) VALUES (2, 'BioEngineerz', 7000000.00, 'USA'); INSERT INTO biotech_startups (id, name, budget, region) VALUES (3, 'SensoraBio', 6000000.00, 'Germany');
What is the average budget of biotech startups in Africa?
SELECT AVG(budget) FROM biotech_startups WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2), actual_cost DECIMAL(10,2)); INSERT INTO projects (id, name, region, budget, actual_cost) VALUES (1, 'Project A', 'Middle East', 10000000.00, 11500000.00), (2, 'Project B', 'Middle East', 20000000.00, 18000000.00), (3, 'Project C', 'Middle East', 15000000.00, 16500000.00), (4, 'Project D', 'Middle East', 25000000.00, 27500000.00);
How many defense projects in the Middle East have exceeded their budget by more than 15%?
SELECT COUNT(*) as num_exceeded_budget FROM projects WHERE region = 'Middle East' AND actual_cost > (budget * 1.15);
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (id INT, project TEXT, location TEXT, year INT, capacity FLOAT, status TEXT); INSERT INTO energy_storage (id, project, location, year, capacity, status) VALUES (1, 'Los Angeles Energy Storage', 'California', 2021, 50.0, 'completed'), (2, 'San Diego Energy Storage', 'California', 2021, 75.0, 'in progress');
What is the maximum and minimum capacity of energy storage projects completed in California in 2021?
SELECT MAX(capacity) as max_capacity, MIN(capacity) as min_capacity FROM energy_storage WHERE location = 'California' AND year = 2021 AND status = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE rovers (name VARCHAR(50), mission_name VARCHAR(50), launch_date DATE); INSERT INTO rovers (name, mission_name, launch_date) VALUES ('Sojourner', 'Mars Pathfinder', '1996-12-04'), ('Spirit', 'Mars Exploration Rover', '2003-06-10'), ('Opportunity', 'Mars Exploration Rover', '2003-07-07'), ('Curiosity', 'Mars Science Laboratory', '2011-11-26'), ('Perseverance', 'Mars 2020', '2020-07-30');
List all Mars rovers and their launch dates.
SELECT name, launch_date FROM rovers;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, name VARCHAR(255), seating_capacity INT, revenue DECIMAL(10,2)); INSERT INTO Restaurants (restaurant_id, name, seating_capacity, revenue) VALUES (1, 'Restaurant A', 75, 5000.00), (2, 'Restaurant B', 50, 6000.00), (3, 'Restaurant C', 25, 4000.00);
What is the maximum revenue for restaurants with a seating capacity of 50 or less?
SELECT MAX(revenue) FROM Restaurants WHERE seating_capacity <= 50;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), category VARCHAR(20), rating DECIMAL(2,1)); INSERT INTO hotels (hotel_id, name, category, rating) VALUES (1, 'The Urban Chic', 'boutique', 4.5), (2, 'The Artistic Boutique', 'boutique', 4.7), (3, 'The Cozy Inn', 'budget', 4.2); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, title VARCHAR(50), duration INT); INSERT INTO virtual_tours (tour_id, hotel_id, title, duration) VALUES (1, 1, 'Virtual Tour: The Urban Chic Lobby', 15), (2, 1, 'Virtual Tour: The Urban Chic Rooms', 30), (3, 2, 'Virtual Tour: The Artistic Boutique Lobby', 10), (4, 3, 'Virtual Tour: The Cozy Inn Rooms', 20);
What is the total number of hotels and the total number of virtual tours in the database?
SELECT COUNT(*) FROM hotels; SELECT COUNT(*) FROM virtual_tours;
gretelai_synthetic_text_to_sql
CREATE TABLE sites (id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO sites (id, country, type) VALUES (1, 'Italy', 'Cultural'), (2, 'Spain', 'Cultural'), (3, 'France', 'Natural'), (4, 'Greece', 'Cultural');
List all cultural heritage sites in Italy, France, and Greece.
SELECT * FROM sites WHERE country IN ('Italy', 'France', 'Greece') AND type = 'Cultural';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), state VARCHAR(25), num_physicians INT, location VARCHAR(20), specialty VARCHAR(50)); INSERT INTO hospitals (id, name, state, num_physicians, location, specialty) VALUES (1, 'Hospital A', 'California', 50, 'rural', 'pediatrics'), (2, 'Hospital B', 'California', 30, 'urban', 'internal medicine'), (3, 'Hospital C', 'California', 75, 'rural', 'general surgery');
How many physicians specialize in pediatrics in hospitals in rural areas of California?
SELECT COUNT(*) FROM hospitals WHERE location = 'rural' AND state = 'California' AND specialty = 'pediatrics';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), position VARCHAR(50)); INSERT INTO faculty (id, name, department, position) VALUES (1, 'Gina Wilson', 'Humanities', 'Professor'); INSERT INTO faculty (id, name, department, position) VALUES (2, 'Harry Moore', 'Humanities', 'Assistant Professor'); CREATE TABLE publications (id INT, faculty_id INT, title VARCHAR(100)); INSERT INTO publications (id, faculty_id, title) VALUES (1, 1, 'Publication A'); INSERT INTO publications (id, faculty_id, title) VALUES (2, 1, 'Publication B'); INSERT INTO publications (id, faculty_id, title) VALUES (3, 2, 'Publication C');
What is the average number of publications per faculty member in the Humanities department?
SELECT AVG(num_publications) FROM (SELECT f.id, COUNT(p.id) as num_publications FROM faculty f LEFT JOIN publications p ON f.id = p.faculty_id WHERE f.department = 'Humanities' GROUP BY f.id) t;
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (chemical_id INT, name VARCHAR(255)); CREATE TABLE storage_temperatures (temperature_id INT, chemical_id INT, min_temp DECIMAL(5,2)); INSERT INTO chemicals (chemical_id, name) VALUES (1, 'Chemical A'), (2, 'Chemical B'); INSERT INTO storage_temperatures (temperature_id, chemical_id, min_temp) VALUES (1, 1, 15.0), (2, 1, 14.5), (3, 2, 10.0), (4, 2, 9.5);
What is the minimum temperature required for each chemical in storage?
SELECT c.name, MIN(st.min_temp) as min_temp FROM storage_temperatures st JOIN chemicals c ON st.chemical_id = c.chemical_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT, fuel_capacity FLOAT, gps_position TEXT); CREATE TABLE gps_positions (id INT, latitude FLOAT, longitude FLOAT, country TEXT, year INT, distance_traveled FLOAT);
What is the average fuel consumption rate for vessels in the Caribbean Sea, grouped by vessel type and year?
SELECT v.type, v.year, AVG(v.fuel_capacity / g.distance_traveled) FROM vessels v JOIN gps_positions g ON v.gps_position = g.id WHERE g.country = 'Caribbean Sea' GROUP BY v.type, v.year;
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID INT, PolicyholderID INT, ClaimType VARCHAR(20), PolicyType VARCHAR(20)); INSERT INTO Claims (ClaimID, PolicyholderID, ClaimType, PolicyType) VALUES (1, 4, 'Theft', 'Auto'), (2, 4, 'Fire', 'Home'), (3, 5, 'Accident', 'Auto');
List all claims and their corresponding claim types, along with the policy type, for policyholder ID 4?
SELECT Claims.ClaimID, Claims.ClaimType, Policyholders.PolicyType FROM Claims INNER JOIN Policyholders ON Claims.PolicyholderID = Policyholders.PolicyholderID WHERE Policyholders.PolicyholderID = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE public_schools(id INT, name VARCHAR(100), school_type VARCHAR(50), address VARCHAR(200), state VARCHAR(50));CREATE TABLE colleges(id INT, name VARCHAR(100), school_type VARCHAR(50), address VARCHAR(200), state VARCHAR(50));
Insert new records of public schools and colleges in the state of California into the corresponding tables.
INSERT INTO public_schools (name, school_type, address, state) VALUES ('Oakland Elementary School', 'Elementary', '123 Main St, Oakland, CA', 'California'), ('San Francisco Community College', 'Community College', '456 Market St, San Francisco, CA', 'California');INSERT INTO colleges (name, school_type, address, state) VALUES ('Berkeley College of Arts', 'College of Arts', '789 University Ave, Berkeley, CA', 'California'), ('Stanford University', 'University', '100 Serra Mall, Stanford, CA', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, country TEXT, amount DECIMAL(10,2)); INSERT INTO donations (id, country, amount) VALUES (1, 'USA', 100.00), (2, 'Canada', 50.50), (3, 'USA', 200.00), (4, 'Canada', 150.25);
What was the average gift size in Canada?
SELECT AVG(amount) FROM donations WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE evaluation_data2 (id INT, algorithm VARCHAR(20), precision DECIMAL(3,2), recall DECIMAL(3,2)); INSERT INTO evaluation_data2 (id, algorithm, precision, recall) VALUES (1, 'Random Forest', 0.92, 0.85), (2, 'XGBoost', 0.75, 0.87), (3, 'Naive Bayes', 0.88, 0.83);
Get the 'algorithm' and 'recall' values for records with 'precision' < 0.85 in the 'evaluation_data2' table
SELECT algorithm, recall FROM evaluation_data2 WHERE precision < 0.85;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, total_funding FLOAT, num_investments INT); INSERT INTO Companies (id, name, industry, total_funding, num_investments) VALUES (1, 'Acme Inc', 'Software', 2500000, 2), (2, 'Beta Corp', 'Software', 5000000, 1), (3, 'Gamma Startup', 'Hardware', 1000000, 1);
Find the top 3 industries with the highest total funding for companies that have had at least 2 investment rounds, ordered by the total funding in descending order.
SELECT industry, SUM(total_funding) AS industry_funding FROM Companies WHERE num_investments >= 2 GROUP BY industry ORDER BY industry_funding DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (id INT, model VARCHAR(50), maintenance_cost FLOAT); INSERT INTO aircraft (id, model, maintenance_cost) VALUES (1, 'F-16', 35000), (2, 'F-35', 42000), (3, 'A-10', 28000);
What is the average maintenance cost for military aircraft?
SELECT AVG(maintenance_cost) FROM aircraft;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (ID INT, Name VARCHAR(50), Age INT, State VARCHAR(50)); INSERT INTO CommunityHealthWorkers (ID, Name, Age, State) VALUES (1, 'John Doe', 35, 'California'); INSERT INTO CommunityHealthWorkers (ID, Name, Age, State) VALUES (2, 'Jane Smith', 40, 'Florida');
List all community health workers, their ages, and corresponding states.
SELECT Name, Age, State FROM CommunityHealthWorkers;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id int, network_type varchar(10), state varchar(20)); INSERT INTO mobile_subscribers (subscriber_id, network_type, state) VALUES (1, '4G', 'WA'), (2, '3G', 'NY'), (3, '5G', 'IL'); CREATE TABLE network_types (network_type varchar(10), description varchar(20)); INSERT INTO network_types (network_type, description) VALUES ('2G', '2G Network'), ('3G', '3G Network'), ('4G', '4G Network'), ('5G', '5G Network');
What is the percentage of mobile subscribers who are using 4G or higher networks in each state?
SELECT state, 100.0 * SUM(CASE WHEN network_type IN ('4G', '5G') THEN 1 ELSE 0 END) / COUNT(*) as percentage FROM mobile_subscribers GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transit (route_id INT, num_passengers INT, route_type VARCHAR(255), route_length FLOAT);
Update the 'num_passengers' column in the 'public_transit' table for the 'route_id' 42 to 50
UPDATE public_transit SET num_passengers = 50 WHERE route_id = 42;
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_sales (sale_date DATE, supplier_id INT, sale_revenue DECIMAL(10,2));
Find the top 3 suppliers with the highest revenue this year
SELECT supplier_id, SUM(sale_revenue) as annual_revenue FROM supplier_sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY supplier_id ORDER BY annual_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_name VARCHAR(255), sport VARCHAR(255)); INSERT INTO athletes (athlete_name, sport) VALUES ('Mutaz Essa Barshim', 'Athletics'); INSERT INTO athletes (athlete_name, sport) VALUES ('Bohdan Bondarenko', 'Athletics'); CREATE TABLE high_jumps (athlete_name VARCHAR(255), height FLOAT); INSERT INTO high_jumps (athlete_name, height) VALUES ('Mutaz Essa Barshim', 2.43); INSERT INTO high_jumps (athlete_name, height) VALUES ('Bohdan Bondarenko', 2.42);
Return the name of the athlete who has jumped the highest in the high jump
SELECT athlete_name FROM high_jumps WHERE height = (SELECT MAX(height) FROM high_jumps);
gretelai_synthetic_text_to_sql
CREATE TABLE k_pop_songs(song_id INT, release_year INT, rating DECIMAL(2,1)); INSERT INTO k_pop_songs(song_id, release_year, rating) VALUES (1, 2021, 4.5), (2, 2021, 4.7), (3, 2020, 4.8), (4, 2022, 5.0);
What's the release year and rating for the K-pop song with the highest rating?
SELECT release_year, MAX(rating) FROM k_pop_songs;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (id INT, location VARCHAR(255), sequestration FLOAT); INSERT INTO carbon_sequestration (id, location, sequestration) VALUES (1, 'Location1', 1200), (2, 'Location2', 800), (3, 'Location3', 1500);
Update the 'sequestration' value for the record with id 2 in the 'carbon_sequestration' table to 900 metric tons.
UPDATE carbon_sequestration SET sequestration = 900 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name TEXT, region TEXT, avg_depth REAL); CREATE TABLE pacific_region (region_name TEXT, region_description TEXT);
What is the average depth of all marine protected areas in the Pacific region?"
SELECT AVG(mpa.avg_depth) FROM marine_protected_areas mpa INNER JOIN pacific_region pr ON mpa.region = pr.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT PRIMARY KEY, name VARCHAR(50), certified_date DATE); INSERT INTO suppliers(id, name, certified_date) VALUES (1, 'Supplier One', '2021-01-01'), (2, 'Supplier Two', '2022-06-15'), (3, 'Supplier Three', '2020-08-08'), (4, 'Supplier Four', '2023-02-28'), (5, 'Supplier Five', '2021-05-15'); CREATE TABLE inventory(id INT PRIMARY KEY, product VARCHAR(50), supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); INSERT INTO inventory(id, product, supplier_id) VALUES (1, 'Product A', 1), (2, 'Product B', 2), (3, 'Product C', 3), (4, 'Product D', 3), (5, 'Product E', 4), (6, 'Product F', 5);
Identify suppliers who have not been certified in the last 2 years and provide their names and the number of products they supply.
SELECT s.name, COUNT(i.id) AS product_count FROM suppliers s LEFT JOIN inventory i ON s.id = i.supplier_id WHERE s.certified_date IS NULL OR s.certified_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS accommodations (id INT, name TEXT, country TEXT, carbon_footprint INT); INSERT INTO accommodations (id, name, country, carbon_footprint) VALUES (1, 'Eco Lodge', 'Africa', 50), (2, 'Green Resort', 'Africa', 75);
What is the total carbon footprint of all accommodations in Africa?
SELECT SUM(carbon_footprint) FROM accommodations WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE cricket_teams (id INT, team VARCHAR(50), season INT, runs INT); INSERT INTO cricket_teams (id, team, season, runs) VALUES (1, 'Mumbai Indians', 2022, 2301), (2, 'Chennai Super Kings', 2022, 2182);
What is the difference in total runs scored between the top and bottom scorers in each cricket season?
SELECT season, MAX(runs) - MIN(runs) FROM cricket_teams GROUP BY season;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(255), CargoQuantity INT, LastCargoArrival DATETIME); INSERT INTO Vessels (ID, Name, CargoQuantity, LastCargoArrival) VALUES (1, 'Endeavour', 0, '2022-01-01'), (2, 'Pioneer', 100, '2022-02-01');
Delete the record of the vessel 'Endeavour' if it didn't transport any cargo in the last month.
DELETE FROM Vessels WHERE Name = 'Endeavour' AND CargoQuantity = 0 AND LastCargoArrival < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE borough (id INT, name TEXT); INSERT INTO borough (id, name) VALUES (1, 'Manhattan'), (2, 'Brooklyn'), (3, 'Queens'), (4, 'Bronx'), (5, 'Staten Island'); CREATE TABLE emergency_calls (id INT, borough_id INT, call_time TIMESTAMP);
What is the total number of emergency calls in each borough?
SELECT b.name, COUNT(ec.id) FROM borough b LEFT JOIN emergency_calls ec ON b.id = ec.borough_id GROUP BY b.id;
gretelai_synthetic_text_to_sql
CREATE TABLE polygon_dapps (id INT, name VARCHAR(255), network VARCHAR(255), launch_date DATE); INSERT INTO polygon_dapps (id, name, network, launch_date) VALUES (1, 'Dapp3', 'polygon', '2022-03-01'), (2, 'Dapp4', 'polygon', '2021-12-31');
List all decentralized applications in the 'Polygon' network that were launched between 2022-01-01 and 2022-12-31.
SELECT * FROM polygon_dapps WHERE network = 'polygon' AND launch_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (id INT PRIMARY KEY, farm_id INT, date DATE, temperature FLOAT, rainfall FLOAT); INSERT INTO weather_data (id, farm_id, date, temperature, rainfall) VALUES (4, 3, '2019-05-01', 21.6, 16.2); INSERT INTO weather_data (id, farm_id, date, temperature, rainfall) VALUES (5, 3, '2019-05-02', 24.1, 13.5);
What is the average rainfall per farm?
SELECT farm_id, AVG(rainfall) FROM weather_data GROUP BY farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Products_By_Category (product_category VARCHAR(255), product_id INT); INSERT INTO Products_By_Category (product_category, product_id) VALUES ('Clothing', 100), ('Electronics', 101), ('Food', 102), ('Clothing', 103), ('Furniture', 104);
Show the total number of products in each product category that are not made from recycled materials.
SELECT product_category, COUNT(*) as non_recycled_count FROM Products_By_Category LEFT JOIN Supplier_Products ON Products_By_Category.product_id = Supplier_Products.product_id WHERE Supplier_Products.is_recycled IS NULL GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE timelines (state VARCHAR(255), practice VARCHAR(255), timeline INT);
What is the average project timeline for sustainable building practices in the northeast region?
SELECT AVG(timeline) FROM timelines WHERE state IN ('Connecticut', 'Maine', 'Massachusetts', 'New Hampshire', 'New Jersey', 'New York', 'Pennsylvania', 'Rhode Island', 'Vermont') AND practice IN ('Green Roofs', 'Solar Panels', 'Rainwater Harvesting');
gretelai_synthetic_text_to_sql
CREATE TABLE Investors (InvestorID INT, Gender VARCHAR(10), InvestorCountry VARCHAR(20)); INSERT INTO Investors VALUES (1, 'Male', 'India'), (2, 'Female', 'Brazil'); CREATE TABLE Investments (InvestmentID INT, InvestorID INT, Sector VARCHAR(20), FundsInvested DECIMAL(10,2), InvestmentDate DATE); INSERT INTO Investments VALUES (1, 1, 'Education', 500.00, '2021-01-01'), (2, 1, 'Education', 200.00, '2019-01-01'), (3, 2, 'Education', 350.00, '2021-02-01'), (4, 2, 'Education', 150.00, '2019-01-01');
Find the total number of social impact investments and total funds invested in the Education sector for each gender, excluding investments made before 2020 and only considering investments made by Indian investors.
SELECT i.Gender, COUNT(Investments.InvestmentID) AS TotalInvestments, SUM(Investments.FundsInvested) AS TotalFundsInvested FROM Investors i INNER JOIN Investments ON i.InvestorID = Investments.InvestorID WHERE Investments.Sector = 'Education' AND Investments.InvestmentDate >= '2020-01-01' AND i.InvestorCountry = 'India' GROUP BY i.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control_initiatives (id INT, name TEXT, location TEXT, year INT); INSERT INTO pollution_control_initiatives (id, name, location, year) VALUES (1, 'Coral Reef Protection Program', 'Caribbean Sea', 2017), (2, 'Ocean Plastic Reduction Project', 'Caribbean Sea', 2016), (3, 'Marine Life Restoration Effort', 'Atlantic Ocean', 2015);
Count the number of pollution control initiatives in the Caribbean Sea that have been implemented since 2015.
SELECT COUNT(*) FROM pollution_control_initiatives WHERE location = 'Caribbean Sea' AND year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255), population INT, ocean VARCHAR(255)); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (1, 'Blue Whale', 'Endangered', 1000, 'Atlantic'); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (2, 'Dolphin', 'Least Concern', 50000, 'Pacific'); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (3, 'Clownfish', 'Vulnerable', 30000, 'Indian'); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (4, 'Krill', 'Critically Endangered', 2000, 'Southern');
What is the total population of all marine species in the Southern Ocean with a conservation status of 'Critically Endangered'?
SELECT SUM(population) as total_population FROM species WHERE conservation_status = 'Critically Endangered' AND ocean = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (expenditure_id INT, drug_id INT, quarter INT, year INT, amount DECIMAL(10, 2));
What was the R&D expenditure for each drug in Q1 2022?
SELECT d.drug_name, SUM(r.amount) as total_expenditure FROM rd_expenditure r JOIN drugs d ON r.drug_id = d.drug_id WHERE r.quarter = 1 AND r.year = 2022 GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (id INT, crop_type VARCHAR(255), temperature INT, humidity INT, measurement_date DATE); INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (1, 'Corn', 22, 55, '2021-07-01'); INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (2, 'Cotton', 28, 65, '2021-07-03');
Calculate the average temperature for each crop type in the month of July for 2021.
SELECT crop_type, AVG(temperature) as avg_temperature FROM sensor_data WHERE measurement_date BETWEEN '2021-07-01' AND '2021-07-31' GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE operation_costs(year INT, operation VARCHAR(20), costs INT); INSERT INTO operation_costs VALUES (2018, 'mining', 5000000), (2019, 'mining', 5200000), (2020, 'mining', 5400000);
Calculate the percentage change in mining operation costs from 2018 to 2020
SELECT (SUM(costs) * 100.0 / (SELECT SUM(costs) FROM operation_costs WHERE year = 2018) - 100.0) as percentage_change FROM operation_costs WHERE year = 2020 AND operation = 'mining';
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT PRIMARY KEY, SiteName VARCHAR(255), Country VARCHAR(255), StartDate DATE, EndDate DATE); INSERT INTO ExcavationSites (SiteID, SiteName, Country, StartDate, EndDate) VALUES (1, 'Pompeii', 'Italy', '79-08-24', '79-10-01');
Insert data into the excavation sites table
INSERT INTO ExcavationSites (SiteID, SiteName, Country, StartDate, EndDate) VALUES (1, 'Pompeii', 'Italy', '79-08-24', '79-10-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Metal_Artifacts (id INT, artifact_name VARCHAR(50), artifact_type VARCHAR(50), weight INT); INSERT INTO Metal_Artifacts (id, artifact_name, artifact_type, weight) VALUES (1, 'Bronze Sword', 'Metal', 2000), (2, 'Iron Spear', 'Metal', 3000), (3, 'Gold Mask', 'Metal', 1000);
What is the total weight of all metal artifacts in the 'Metal_Artifacts' table?
SELECT SUM(weight) FROM Metal_Artifacts WHERE artifact_type = 'Metal';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_patients (id INT, state VARCHAR(2), age INT, diagnosis VARCHAR(10)); INSERT INTO rural_patients (id, state, age, diagnosis) VALUES (1, 'AL', 65, 'diabetes'); CREATE TABLE states (state_abbr VARCHAR(2), state_name VARCHAR(20)); INSERT INTO states (state_abbr, state_name) VALUES ('AL', 'Alabama');
What is the average age of patients diagnosed with diabetes in rural areas, grouped by state?
SELECT r.state, AVG(r.age) FROM rural_patients r JOIN states s ON r.state = s.state_abbr WHERE r.diagnosis = 'diabetes' GROUP BY r.state;
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (program_category VARCHAR(50), date DATE, revenue DECIMAL(10,2)); INSERT INTO Revenue (program_category, date, revenue) VALUES ('Dance', '2021-04-01', 15000.00), ('Theater', '2021-04-01', 20000.00), ('Music', '2021-04-01', 12000.00), ('Art', '2021-04-01', 18000.00), ('Dance', '2021-07-01', 17000.00), ('Theater', '2021-07-01', 22000.00), ('Music', '2021-07-01', 13000.00), ('Art', '2021-07-01', 19000.00);
What was the total revenue by program category in Q2 2021?
SELECT SUM(revenue) AS total_revenue, program_category FROM Revenue WHERE date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY program_category;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, annual_production INT); INSERT INTO mines (id, name, location, annual_production) VALUES (1, 'Mine A', 'Country X', 1500), (2, 'Mine B', 'Country Y', 2000), (3, 'Mine C', 'Country Z', 1750);
What is the total REE production by mine name for 2020?
SELECT name, SUM(annual_production) as total_production FROM mines WHERE YEAR(timestamp) = 2020 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE cargos(id INT, vessel_id INT, cargo_weight FLOAT); CREATE TABLE vessel_locations(id INT, vessel_id INT, location VARCHAR(50), timestamp TIMESTAMP);
What is the total cargo weight for vessels in the Mediterranean sea?
SELECT SUM(cargo_weight) FROM cargos JOIN vessel_locations ON cargos.vessel_id = vessel_locations.vessel_id WHERE location LIKE '%Mediterranean%'
gretelai_synthetic_text_to_sql
CREATE TABLE RouteRidership (RouteID int, AnnualPassengers int, Frequency int); INSERT INTO RouteRidership (RouteID, AnnualPassengers, Frequency) VALUES (1, 80000, 30), (2, 60000, 45), (3, 40000, 60), (4, 90000, 20);
What is the maximum ridership for routes that have a frequency of less than once per hour?
SELECT MAX(AnnualPassengers) FROM RouteRidership WHERE Frequency < 60;
gretelai_synthetic_text_to_sql
CREATE TABLE RegulatoryFrameworks (framework_id INT, framework_name TEXT, implementation_year INT); INSERT INTO RegulatoryFrameworks (framework_id, framework_name, implementation_year) VALUES (1, 'Framework1', 2020), (2, 'Framework2', 2021), (3, 'Framework3', 2022);
List all regulatory frameworks in the blockchain domain that have been implemented so far this decade.
SELECT framework_name FROM RegulatoryFrameworks WHERE RegulatoryFrameworks.implementation_year >= 2010 AND RegulatoryFrameworks.implementation_year < 2030;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, YearsOfExperience INT, Specialization VARCHAR(20), Gender VARCHAR(10), OfficeLocation VARCHAR(20)); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization, Gender, OfficeLocation) VALUES (3, 15, 'Immigration Law', 'Non-binary', 'Chicago'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization, Gender, OfficeLocation) VALUES (4, 9, 'Immigration Law', 'Female', 'Miami');
What is the average years of experience for attorneys specialized in Immigration Law?
SELECT Specialization, AVG(YearsOfExperience) as AverageExperience FROM Attorneys WHERE Specialization = 'Immigration Law';
gretelai_synthetic_text_to_sql
CREATE TABLE Property (id INT, property_type VARCHAR(20), price FLOAT, affordability_score INT, city VARCHAR(20)); INSERT INTO Property (id, property_type, price, affordability_score, city) VALUES (1, 'Apartment', 500000, 85, 'AffordableCity'), (2, 'House', 700000, 70, 'AffordableCity'), (3, 'Condo', 300000, 90, 'AffordableCity');
What is the average housing affordability score and total property price for properties in the "AffordableCity" schema, grouped by property type?
SELECT Property.property_type, AVG(Property.affordability_score) AS avg_affordability_score, SUM(Property.price) AS total_price FROM Property WHERE Property.city = 'AffordableCity' GROUP BY Property.property_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Game VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Game) VALUES (1, 25, 'Game1'), (2, 30, 'Game1'), (3, 35, 'Game2');
How many players play each game?
SELECT Game, COUNT(*) FROM Players GROUP BY Game;
gretelai_synthetic_text_to_sql
CREATE TABLE publication (id INT, author VARCHAR(50), department VARCHAR(30), year INT, title VARCHAR(100)); INSERT INTO publication (id, author, department, year, title) VALUES (1, 'Jasmine', 'Humanities', 2019, 'Critical Theory'), (2, 'Kai', 'Humanities', 2018, 'Literary Analysis');
Determine the average number of publications per author in the Humanities department.
SELECT department, AVG(num_publications) as avg_publications FROM (SELECT department, author, COUNT(*) as num_publications FROM publication GROUP BY department, author) AS subquery GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai_applications (application_id INTEGER, application_type TEXT, application_description TEXT);
How many creative_ai_applications are there for each application_type?
SELECT application_type, COUNT(*) as count FROM creative_ai_applications GROUP BY application_type;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (region VARCHAR(50), amount FLOAT, sector VARCHAR(50)); INSERT INTO climate_finance (region, amount, sector) VALUES ('Asia', 6000000, 'Mitigation'), ('Africa', 4000000, 'Mitigation'), ('Europe', 7000000, 'Adaptation');
How much climate finance has been allocated for mitigation projects in Africa?
SELECT SUM(amount) FROM climate_finance WHERE region = 'Africa' AND sector = 'Mitigation';
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (id INT, name VARCHAR(50), union_id INT, industry VARCHAR(20)); INSERT INTO union_members (id, name, union_id, industry) VALUES (1, 'John Doe', 123, 'construction'), (2, 'Jane Smith', 456, 'retail'), (3, 'Mike Johnson', 789, 'healthcare');
What is the total number of union members in the 'healthcare' industry?
SELECT COUNT(*) FROM union_members WHERE industry = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE offshore_oil_production (rig_name TEXT, location TEXT, oil_production INTEGER); INSERT INTO offshore_oil_production (rig_name, location, oil_production) VALUES ('Rig1', 'Gulf of Mexico', 150000), ('Rig2', 'Gulf of Mexico', 180000), ('Rig3', 'North Sea', 200000), ('Rig4', 'North Sea', 170000);
What are the total oil production figures for offshore rigs in the Gulf of Mexico and the North Sea?
SELECT oil_production FROM offshore_oil_production WHERE location IN ('Gulf of Mexico', 'North Sea')
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_production (id INT, year INT, location TEXT, quantity INT); INSERT INTO biosensor_production (id, year, location, quantity) VALUES (1, 2021, 'Japan', 800), (2, 2022, 'Japan', 950), (3, 2021, 'USA', 1200);
Find the change in biosensor production between 2021 and 2022 in Japan.
SELECT location, (SELECT quantity FROM biosensor_production WHERE location = 'Japan' AND year = 2022) - (SELECT quantity FROM biosensor_production WHERE location = 'Japan' AND year = 2021) as change FROM biosensor_production WHERE location = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (id INT, company_name VARCHAR(100), round_type VARCHAR(50), raised_amount FLOAT, round_date DATE);
Insert a new investment round into the "investment_rounds" table for 'Lima Inc.' with a Series C round, $12M raised, and round date 2020-11-25
INSERT INTO investment_rounds (id, company_name, round_type, raised_amount, round_date) VALUES (8, 'Lima Inc.', 'Series C', 12000000, '2020-11-25');
gretelai_synthetic_text_to_sql
CREATE TABLE drug_e_sales (quarter INTEGER, year INTEGER, revenue INTEGER); INSERT INTO drug_e_sales (quarter, year, revenue) VALUES (1, 2020, 550000), (2, 2020, 600000), (3, 2020, 700000), (4, 2020, 800000);
What was the average sales revenue for 'DrugE' in 2020?
SELECT AVG(revenue) FROM drug_e_sales WHERE year = 2020 AND drug_name = 'DrugE';
gretelai_synthetic_text_to_sql
CREATE TABLE journalist_salaries (name VARCHAR(50), gender VARCHAR(10), salary DECIMAL(10,2)); INSERT INTO journalist_salaries (name, gender, salary) VALUES ('Fiona Chen', 'Female', 80000.00), ('George Harris', 'Male', 90000.00), ('Heidi Martinez', 'Female', 70000.00), ('Ivan Thompson', 'Male', 100000.00), ('Jasmine Brown', 'Female', 60000.00);
Who are the journalists with the highest and lowest salaries?
SELECT name, salary FROM journalist_salaries ORDER BY salary DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (company_name VARCHAR(255), foundation_year INT); INSERT INTO company_founding (company_name, foundation_year) VALUES ('Acme Inc', 2018), ('Beta Corp', 2015), ('Charlie LLC', 2019), ('Delta Co', 2016); CREATE TABLE funding (company_name VARCHAR(255), funding_amount INT); INSERT INTO funding (company_name, funding_amount) VALUES ('Acme Inc', 500000), ('Beta Corp', 750000), ('Charlie LLC', 600000), ('Delta Co', 400000);
Calculate the average funding amount for companies founded in the last 5 years
SELECT AVG(funding_amount) FROM funding JOIN company_founding ON funding.company_name = company_founding.company_name WHERE foundation_year >= YEAR(CURDATE()) - 5;
gretelai_synthetic_text_to_sql
CREATE TABLE games(id INT, name VARCHAR(50), genre VARCHAR(50), revenue FLOAT); CREATE TABLE transactions(id INT, game_id INT, transaction_date DATE, amount FLOAT);
What is the total revenue for each game genre in the last quarter, sorted by total revenue.
SELECT genres.genre, SUM(transactions.amount) as total_revenue FROM games JOIN transactions ON games.name = transactions.game_name JOIN (SELECT DISTINCT game_name, genre FROM games) genres ON games.genre = genres.genre WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY genres.genre ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Maintenance ( id INT, equipment_id INT, maintenance_date DATE, cost FLOAT ); INSERT INTO Equipment_Maintenance (id, equipment_id, maintenance_date, cost) VALUES (1, 101, '2022-01-01', 5000), (2, 102, '2022-01-05', 7000), (3, 101, '2022-04-01', 6000);
What is the average maintenance cost for military equipment in the last 3 months?
SELECT AVG(cost) FROM Equipment_Maintenance WHERE maintenance_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, ProductType VARCHAR(50)); INSERT INTO Products (ProductID, ProductType) VALUES (1, 'ProductTypeA'), (2, 'ProductTypeA'), (3, 'ProductTypeB'), (4, 'ProductTypeB'), (5, 'ProductTypeC'), (6, 'ProductTypeC'); CREATE TABLE LaborHours (HourID INT, LaborHours DECIMAL(5,2), ProductID INT); INSERT INTO LaborHours (HourID, LaborHours, ProductID) VALUES (1, 5.50, 1), (2, 6.60, 1), (3, 7.70, 2), (4, 8.80, 2), (5, 9.90, 3), (6, 10.00, 3), (7, 11.11, 4), (8, 12.12, 4), (9, 13.13, 5), (10, 14.14, 5);
What is the range of labor hours for producing each product type?
SELECT ProductType, MAX(LaborHours) - MIN(LaborHours) as LaborHoursRange FROM Products p JOIN LaborHours lh ON p.ProductID = lh.ProductID GROUP BY ProductType;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id INT, trial_name VARCHAR(255), status VARCHAR(255), start_date DATE); INSERT INTO clinical_trials (trial_id, trial_name, status, start_date) VALUES (1, 'TrialE', 'Completed', '2022-01-01'), (2, 'TrialF', 'Suspended', '2022-02-01'), (3, 'TrialG', 'Recruiting', '2022-03-01'), (4, 'TrialH', 'Terminated', '2022-04-01'); CREATE TABLE trial_participants (participant_id INT, trial_id INT); INSERT INTO trial_participants (participant_id, trial_id) VALUES (1, 1), (2, 1), (3, 3), (4, 4);
List all clinical trials with the number of participants, sorted by trial start date in descending order, excluding trials with a status of 'Suspended' or 'Terminated'.
SELECT ct.trial_name, COUNT(tp.participant_id) as num_participants, ct.start_date FROM clinical_trials ct JOIN trial_participants tp ON ct.trial_id = tp.trial_id WHERE ct.status NOT IN ('Suspended', 'Terminated') GROUP BY ct.trial_name, ct.start_date ORDER BY ct.start_date DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists blockchain; CREATE TABLE if not exists blockchain.digital_assets ( asset_id INT AUTO_INCREMENT, asset_name VARCHAR(255), market_cap DECIMAL(18,2), PRIMARY KEY (asset_id)); INSERT INTO blockchain.digital_assets (asset_name, market_cap) VALUES ('Bitcoin', 80000000000.00), ('Ethereum', 32000000000.00);
Delete digital assets with a market cap below $100M from the database.
DELETE FROM blockchain.digital_assets WHERE market_cap < 100000000;
gretelai_synthetic_text_to_sql
CREATE TABLE operator_sustainability (id INT PRIMARY KEY, operator_id INT, sustainable BOOLEAN);
Delete a tour operator that violates sustainable tourism principles
DELETE FROM operator_sustainability WHERE operator_id = 1 AND sustainable = false;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category TEXT); INSERT INTO cases (case_id, category) VALUES (1, 'Civil'), (2, 'Civil'), (3, 'Criminal'), (4, 'Family'), (5, 'Family');
What is the number of cases in the 'Family' category?
SELECT COUNT(*) FROM cases WHERE category = 'Family';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (id INT, equipment_type VARCHAR(255), maintenance_date DATE);
Get the latest military equipment maintenance record for each type of equipment
SELECT equipment_type, MAX(maintenance_date) FROM equipment_maintenance GROUP BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE public_schools (school_name TEXT, state TEXT, budget INTEGER); INSERT INTO public_schools (school_name, state, budget) VALUES ('School A', 'CA', 8000000), ('School B', 'CA', 9000000), ('School C', 'NY', 7000000);
What is the maximum budget allocated to public schools in the state of California?
SELECT MAX(budget) FROM public_schools WHERE state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE recycled_materials (recycled_material_id INT, recycled_material_name VARCHAR(255), product_category VARCHAR(255)); INSERT INTO recycled_materials (recycled_material_id, recycled_material_name, product_category) VALUES (1, 'Material X', 'Category X'), (2, 'Material Y', 'Category X'), (3, 'Material Z', 'Category Y'), (4, 'Material W', 'Category Y'); CREATE TABLE production (production_id INT, product_id INT, recycled_material_id INT, production_quantity INT); INSERT INTO production (production_id, product_id, recycled_material_id, production_quantity) VALUES (1, 1, 1, 100), (2, 1, 2, 200), (3, 2, 1, 250), (4, 2, 2, 300), (5, 3, 3, 350), (6, 3, 4, 400), (7, 4, 3, 450), (8, 4, 4, 500);
Get the percentage of products manufactured using recycled materials for each product category
SELECT product_category, SUM(production_quantity) as total_production_quantity, SUM(CASE WHEN recycled_material_id IS NOT NULL THEN production_quantity ELSE 0 END) as recycled_production_quantity, (SUM(CASE WHEN recycled_material_id IS NOT NULL THEN production_quantity ELSE 0 END) / SUM(production_quantity)) * 100 as recycled_percentage FROM production JOIN recycled_materials ON production.recycled_material_id = recycled_materials.recycled_material_id GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionSources (ID INT, Source VARCHAR(255), Location VARCHAR(255)); INSERT INTO PollutionSources (ID, Source, Location) VALUES (2, 'Factory Waste', 'Mediterranean Sea'); CREATE TABLE SpeciesAffected (ID INT, Species VARCHAR(255), Location VARCHAR(255)); INSERT INTO SpeciesAffected (ID, Species, Location) VALUES (1, 'Turtle', 'Mediterranean Sea');
Which marine species are affected by pollution in the Mediterranean Sea?
SELECT s.Species FROM SpeciesAffected s INNER JOIN PollutionSources p ON s.Location = p.Location WHERE p.Source = 'Factory Waste';
gretelai_synthetic_text_to_sql