context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE farm_details (farm_name TEXT, acreage INTEGER); INSERT INTO farm_details (farm_name, acreage) VALUES ('Farm A', 500), ('Farm B', 700);
Find the total acreage of farm A and farm B
SELECT SUM(acreage) FROM farm_details WHERE farm_name IN ('Farm A', 'Farm B');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name VARCHAR, email VARCHAR, phone VARCHAR); CREATE TABLE volunteer_assignments (id INT, volunteer_id INT, program_id INT);
Determine the number of volunteers for each program and the total number of volunteers
SELECT volunteer_assignments.program_id, COUNT(DISTINCT volunteers.id) as total_volunteers, COUNT(DISTINCT volunteer_assignments.volunteer_id) as num_volunteers FROM volunteers JOIN volunteer_assignments ON volunteers.id = volunteer_assignments.volunteer_id GROUP BY volunteer_assignments.program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, size FLOAT, PRIMARY KEY (id)); INSERT INTO properties (id, size) VALUES (1, 1200.0), (2, 800.0), (3, 1500.0), (4, 1000.0);
What is the average size of properties in the 'properties' table?
SELECT AVG(size) FROM properties;
gretelai_synthetic_text_to_sql
CREATE TABLE provinces (province_id INT, province_name VARCHAR(255)); CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(255), province_id INT);
What is the total number of community development initiatives in each province, sorted by initiative count in descending order?
SELECT p.province_name, COUNT(i.initiative_id) as initiative_count FROM provinces p JOIN initiatives i ON p.province_id = i.province_id GROUP BY p.province_name ORDER BY initiative_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ISSMissions (SpacecraftName TEXT, MissionType TEXT);
List all spacecraft that have been used for missions to the International Space Station, and display them in alphabetical order.
SELECT SpacecraftName FROM ISSMissions ORDER BY SpacecraftName ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Scores (id INT, country VARCHAR(50), score INT); INSERT INTO Scores (id, country, score) VALUES (1, 'Egypt', 80), (2, 'South Africa', 85); CREATE TABLE Accommodations_Africa (id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO Accommodations_Africa (id, country, type) VALUES (1, 'Egypt', 'Eco-Frien...
What is the total number of eco-friendly accommodations in Africa and their average sustainability scores?
SELECT AVG(Scores.score) FROM Scores INNER JOIN Accommodations_Africa ON Scores.country = Accommodations_Africa.country WHERE Accommodations_Africa.type = 'Eco-Friendly' AND Scores.country IN ('Egypt', 'South Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, campaign VARCHAR(255), amount DECIMAL(10, 2));
What is the difference between the total donations for 'Habitats for Tigers' and 'Habitats for Lions'?
SELECT (SELECT SUM(amount) FROM Donations WHERE campaign = 'Habitats for Tigers') - (SELECT SUM(amount) FROM Donations WHERE campaign = 'Habitats for Lions');
gretelai_synthetic_text_to_sql
CREATE TABLE disasters (id INT PRIMARY KEY, name TEXT, start_date DATE);
Insert a new record for a disaster with ID 11, name 'Tornado', and start date 2022-03-01 into the "disasters" table
INSERT INTO disasters (id, name, start_date) VALUES (11, 'Tornado', '2022-03-01');
gretelai_synthetic_text_to_sql
CREATE TABLE social_justice_articles (id INT, title VARCHAR(100), date DATE, reader_id INT);CREATE TABLE readers (id INT, name VARCHAR(50), genre VARCHAR(50)); INSERT INTO social_justice_articles VALUES (1, 'Racial justice', '2022-03-01', 1); INSERT INTO readers VALUES (1, 'John Doe', 'Investigative');
What is the total number of readers and their preferred genres for articles about social justice issues in the past month?
SELECT readers.genre, COUNT(DISTINCT readers.id) FROM readers INNER JOIN social_justice_articles ON readers.id = social_justice_articles.reader_id WHERE social_justice_articles.date >= DATEADD(month, -1, GETDATE()) GROUP BY readers.genre;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartCityProjects (id INT, project_name VARCHAR(100), project_type VARCHAR(50), city VARCHAR(50), state VARCHAR(50), capacity INT);
Find the total number of smart city projects in 'NY' and 'FL'
SELECT COUNT(*) FROM SmartCityProjects WHERE state IN ('NY', 'FL');
gretelai_synthetic_text_to_sql
CREATE TABLE unfair_outcomes (id INT PRIMARY KEY, algorithm_name VARCHAR(50), outcome VARCHAR(20), bias_type VARCHAR(20), description TEXT); CREATE TABLE algorithm_details (id INT PRIMARY KEY, algorithm_name VARCHAR(50), developer VARCHAR(50), release_year INT);
List all algorithms that have contributed to 'unfavorable' outcomes for 'gender' and 'race' biases
SELECT algorithm_details.algorithm_name, algorithm_details.developer, algorithm_details.release_year FROM unfair_outcomes JOIN algorithm_details ON unfair_outcomes.algorithm_name = algorithm_details.algorithm_name WHERE unfair_outcomes.outcome = 'unfavorable' AND unfair_outcomes.bias_type IN ('gender', 'race');
gretelai_synthetic_text_to_sql
CREATE TABLE user_data (user_id INT, age INT, category VARCHAR(50), platform VARCHAR(20)); INSERT INTO user_data (user_id, age, category, platform) VALUES (1, 25, 'sports', 'Twitter'), (2, 35, 'music', 'Twitter'), (3, 22, 'sports', 'Twitter');
What is the minimum age of users who have posted in the 'sports' category on Twitter?
SELECT MIN(age) FROM user_data WHERE category = 'sports' AND platform = 'Twitter';
gretelai_synthetic_text_to_sql
CREATE TABLE interactions (id INT, user_id INT, ad_type VARCHAR(50), interaction_date DATE); INSERT INTO interactions (id, user_id, ad_type, interaction_date) VALUES (1, 1, 'political', '2022-01-01'), (2, 1, 'non-political', '2022-01-02'), (3, 2, 'political', '2022-01-03');
How many users have interacted with political ads in the last month?
SELECT COUNT(DISTINCT user_id) FROM interactions WHERE ad_type = 'political' AND interaction_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (initiative_id INT, initiative_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), offset_value INT);
Insert a new record of a carbon offset initiative in the city of New York with an offset value of 5000 tons.
INSERT INTO carbon_offsets (initiative_id, initiative_name, city, state, offset_value) VALUES (1, 'Carbon Offset Initiative 1', 'New York', 'New York', 5000);
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (MenuID INT, MenuItem VARCHAR(50), MenuType VARCHAR(50), Price DECIMAL(5, 2)); INSERT INTO Menu (MenuID, MenuItem, MenuType, Price) VALUES (1, 'Vegan Tofu Stir Fry', 'Meal', 9.99); CREATE TABLE Orders (OrderID INT, MenuID INT, OrderDate DATE, Quantity INT); INSERT INTO Orders (OrderID, MenuID, OrderDa...
How many vegan meals were sold in the month of January 2022?
SELECT SUM(Quantity) FROM Orders JOIN Menu ON Orders.MenuID = Menu.MenuID WHERE Menu.MenuType = 'Meal' AND Orders.OrderDate >= '2022-01-01' AND Orders.OrderDate < '2022-02-01' AND Menu.MenuItem LIKE '%vegan%';
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftSpecs (Company VARCHAR(50), Model VARCHAR(50), Wingspan INT); INSERT INTO AircraftSpecs (Company, Model, Wingspan) VALUES ('Boeing', '747', 211), ('Boeing', '787 Dreamliner', 197), ('Airbus', 'A320', 118), ('Airbus', 'A380', 262), ('Bombardier', 'CRJ700', 91);
Which companies have manufactured aircraft with a wingspan greater than 200 feet?
SELECT DISTINCT Company FROM AircraftSpecs WHERE Wingspan > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (id INT, name TEXT, type TEXT); INSERT INTO facilities (id, name, type) VALUES (1, 'Rural Clinic', 'Primary Care'), (2, 'Urgent Care', 'Urgent Care'), (3, 'General Hospital', 'Hospital');
What is the name and type of each facility?
SELECT name, type FROM facilities;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_plants (id INT, plant_name VARCHAR(100), country VARCHAR(50), production_capacity INT); INSERT INTO chemical_plants (id, plant_name, country, production_capacity) VALUES (1, 'Brazil Plant 1', 'Brazil', 3000), (2, 'Brazil Plant 2', 'Brazil', 4000);
What is the average production capacity of the chemical manufacturing plants in Brazil?
SELECT AVG(production_capacity) FROM chemical_plants WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), age INT, region VARCHAR(20)); INSERT INTO customers (customer_id, name, age, region) VALUES (1, 'John Doe', 35, 'Southeast'), (2, 'Jane Smith', 45, 'Northeast'), (3, 'Mike Johnson', 50, 'Southeast'), (4, 'Alice Davis', 25, 'Midwest'), (5, 'Bob Brown', 60, 'Nort...
What is the maximum and minimum age of customers in the Northwest region?
SELECT MAX(age), MIN(age) FROM customers WHERE region = 'Northwest';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, sale_date DATE, quantity_sold INT);
How many garments were sold in each quarter of the year 2022?
SELECT DATE_FORMAT(sale_date, '%Y-%m') AS quarter, SUM(quantity_sold) AS total_sold FROM sales WHERE YEAR(sale_date) = 2022 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(50)); INSERT INTO cities (id, name) VALUES (1, 'CityA'), (2, 'CityB'), (3, 'CityC'), (4, 'CityD'), (5, 'CityE'); CREATE TABLE budget (id INT, city_id INT, department VARCHAR(50), amount INT); INSERT INTO budget (id, city_id, department, amount) VALUES (1, 1, 'Education', 500000...
What is the number of schools in 'CityE' with a budget over 500000?
SELECT COUNT(*) FROM budget WHERE department = 'Education' AND city_id IN (SELECT id FROM cities WHERE name = 'CityE') AND amount > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(50), price FLOAT, cruelty_free BOOLEAN); CREATE TABLE ingredients (id INT PRIMARY KEY, product_id INT, ingredient_name VARCHAR(255), source_country VARCHAR(50), safety_rating FLOAT); CREATE TABLE ingredient_sources (id INT PRIMARY KEY, ingre...
What is the total revenue for products that have more than 5 unique ingredients sourced from African countries?
SELECT SUM(product_sales.revenue) FROM product_sales INNER JOIN products ON product_sales.product_id = products.id INNER JOIN ingredients ON products.id = ingredients.product_id INNER JOIN ingredient_sources ON ingredients.id = ingredient_sources.ingredient_id WHERE ingredient_sources.source_id IN (SELECT id FROM sourc...
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_address VARCHAR(64), user_address VARCHAR(64));
List all users associated with a specific smart contract '0xdef...'.
SELECT user_address FROM smart_contracts WHERE contract_address = '0xdef...';
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (manufacturer_id INT, manufacturer_name TEXT, country TEXT); CREATE TABLE Fabric_Manufacturers (fabric_id INT, manufacturer_id INT, is_sustainable BOOLEAN);
Identify the top 5 countries with the highest number of sustainable fabric manufacturers.
SELECT m.country, COUNT(DISTINCT fm.manufacturer_id) as manufacturer_count FROM Manufacturers m JOIN Fabric_Manufacturers fm ON m.manufacturer_id = fm.manufacturer_id WHERE fm.is_sustainable = TRUE GROUP BY m.country ORDER BY manufacturer_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (company VARCHAR(255), region VARCHAR(255), year INT, num_projects INT); INSERT INTO defense_projects (company, region, year, num_projects) VALUES ('CACI International', 'Asia-Pacific', 2020, 20), ('CACI International', 'Asia-Pacific', 2021, 25);
What is the total number of defense projects initiated by CACI International in the Asia-Pacific region in 2020 and 2021?
SELECT SUM(num_projects) FROM defense_projects WHERE company = 'CACI International' AND region = 'Asia-Pacific' AND year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE Savings (AccountID INT, AccountType VARCHAR(255), Balance DECIMAL(10,2), IsShariahCompliant BOOLEAN); INSERT INTO Savings (AccountID, AccountType, Balance, IsShariahCompliant) VALUES (1, 'Savings1', 5000.00, true), (2, 'Savings2', 7000.00, true), (3, 'Savings3', 3000.00, false);
What is the average monthly balance for all Shariah-compliant savings accounts, partitioned by account type and ranked by average balance in descending order?
SELECT AccountType, AVG(Balance) as AvgBalance, ROW_NUMBER() OVER (ORDER BY AvgBalance DESC) as Rank FROM Savings WHERE IsShariahCompliant = true GROUP BY AccountType;
gretelai_synthetic_text_to_sql
CREATE TABLE beds (bed_id INT, hospital_id INT, location VARCHAR(20));
What is the total number of hospital beds in rural areas of each state?
SELECT hospital_id, COUNT(*) FROM beds WHERE location = 'Rural' GROUP BY hospital_id;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_compounds (compound_id INT, compound_name TEXT, country TEXT, sds_expiration_date DATE); INSERT INTO chemical_compounds (compound_id, compound_name, country, sds_expiration_date) VALUES (1, 'Compound A', 'Mexico', '2024-06-01'), (2, 'Compound B', 'Brazil', '2025-02-15'), (3, 'Compound C', 'Argenti...
List all chemical compounds with their respective safety data sheet (SDS) expiration dates and countries of origin.
SELECT compound_name, sds_expiration_date, country FROM chemical_compounds;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT, make VARCHAR(20), model VARCHAR(20), total_distance INT);
List all autonomous vehicles in 'autonomous_vehicles' table that have a total distance greater than 1000 miles, along with the make, model, and the total distance.
SELECT make, model, total_distance FROM autonomous_vehicles WHERE total_distance > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, type TEXT, city TEXT, region TEXT); INSERT INTO subscribers (id, type, city, region) VALUES (1, 'mobile', 'Tokyo', 'Asia'); INSERT INTO subscribers (id, type, city, region) VALUES (2, 'mobile', 'Mumbai', 'Asia'); INSERT INTO subscribers (id, type, city, region) VALUES (3, 'mobile', 'Se...
List the top 3 cities with the highest mobile subscriber count in 'Asia'
SELECT city, COUNT(*) as subscriber_count FROM subscribers WHERE type = 'mobile' AND region = 'Asia' GROUP BY city ORDER BY subscriber_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CyberSecurityStrategies (StrategyID INT, Strategy TEXT, Region TEXT, Budget INT); INSERT INTO CyberSecurityStrategies (StrategyID, Strategy, Region, Budget) VALUES (1, 'Firewall Implementation', 'Asia-Pacific', 1500000); INSERT INTO CyberSecurityStrategies (StrategyID, Strategy, Region, Budget) VALUES (2, ...
List all cybersecurity strategies and their corresponding budgets for the Asia-Pacific region.
SELECT Strategy, Budget FROM CyberSecurityStrategies WHERE Region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE ad_impressions (id INT, country VARCHAR(255), ad_format VARCHAR(255), timestamp TIMESTAMP); INSERT INTO ad_impressions (id, country, ad_format, timestamp) VALUES (1, 'Italy', 'Carousel', '2022-07-01 12:00:00'), (2, 'Italy', 'Image', '2022-07-02 14:30:00');
Identify the number of ad impressions in Italy for the 'Carousel' ad format in the last month.
SELECT COUNT(*) FROM ad_impressions WHERE country = 'Italy' AND ad_format = 'Carousel' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Seasons (season VARCHAR(10)); INSERT INTO Seasons (season) VALUES ('Spring'), ('Summer'), ('Fall'), ('Winter'); CREATE TABLE Manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(50), region VARCHAR(25)); INSERT INTO Manufacturers (manufacturer_id, manufacturer_name, region) VALUES (1, 'ABC Manufac...
maximum retail sales for garments manufactured in the 'Europe' region in the 'Spring' season
SELECT MAX(price) FROM Garments INNER JOIN Manufacturers ON Garments.manufacturer_id = Manufacturers.manufacturer_id WHERE region = 'Europe' AND season = 'Spring';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai (id INT, organization_name TEXT, founder TEXT, region TEXT); INSERT INTO ethical_ai (id, organization_name, founder, region) VALUES (1, 'AI Ethics Inc', 'Alex Lee', 'North America'), (2, 'Ethical Tech Co', 'Jessica Chen', 'Canada'), (3, 'AI for Good Ltd', 'Michael Brown', 'UK');
Which ethical AI organizations have a founder with the last name 'Lee'?
SELECT organization_name, founder FROM ethical_ai WHERE founder LIKE '%Lee%';
gretelai_synthetic_text_to_sql
CREATE TABLE city_budget (city VARCHAR(20), category VARCHAR(20), budget INT); INSERT INTO city_budget (city, category, budget) VALUES ('Austin', 'Education', 5000000);
What is the average budget allocated for education in the city of Austin?
SELECT AVG(budget) FROM city_budget WHERE city = 'Austin' AND category = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE incident (incident_id INT, incident_date DATE, incident_type VARCHAR(255), resolution_date DATE);CREATE TABLE malware (malware_id INT, malware_name VARCHAR(255), incident_id INT);
What is the average time to resolution for security incidents that were caused by a specific type of malware?
SELECT AVG(DATEDIFF(resolution_date, incident_date)) AS avg_resolution_time FROM incident i JOIN malware m ON i.incident_id = m.incident_id WHERE incident_type = 'malware_type';
gretelai_synthetic_text_to_sql
CREATE TABLE contract (id INT, vendor_id INT, value FLOAT, length INT, contract_date DATE); INSERT INTO contract (id, vendor_id, value, length, contract_date) VALUES (1, 1, 50000, 3, '2021-01-01'); INSERT INTO contract (id, vendor_id, value, length, contract_date) VALUES (2, 2, 25000, 2, '2022-02-01'); CREATE TABLE ven...
What is the total contract value and average length for each contract, partitioned by vendor and ordered by total contract value in descending order?
SELECT v.name as vendor, SUM(c.value) as total_contract_value, AVG(c.length) as avg_contract_length, ROW_NUMBER() OVER (PARTITION BY v.name ORDER BY SUM(c.value) DESC) as rank FROM contract c JOIN vendor v ON c.vendor_id = v.id GROUP BY v.name ORDER BY total_contract_value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, user_name TEXT); INSERT INTO Users (user_id, user_name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); CREATE TABLE Streams (stream_id INT, user_id INT, song_id INT, stream_date DATE); INSERT INTO Streams (stream_id, user_id, song_id, stream_date) VALUES (1, 1, 1, '2021-01-01'), (2, 1...
What is the average number of streams per user for songs released in 2019 or earlier, and longer than 4 minutes?
SELECT AVG(s.streams_per_user) FROM (SELECT COUNT(*) / COUNT(DISTINCT user_id) AS streams_per_user FROM Streams s JOIN Songs st ON s.song_id = st.song_id WHERE st.release_year <= 2019 AND st.duration > 240) s;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment_model VARCHAR(255), sale_price DECIMAL(10,2), sale_date DATE, region VARCHAR(255));
What is the average sale price of 'Joint Light Tactical Vehicles' (JLTV) sold by 'Beta Corp' in the 'Asia-Pacific' region?
SELECT AVG(sale_price) FROM MilitaryEquipmentSales WHERE seller = 'Beta Corp' AND equipment_model = 'JLTV' AND region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE trees (id INT, age FLOAT, species TEXT, region TEXT); INSERT INTO trees (id, age, species, region) VALUES (1, 55.3, 'Pine', 'Boreal'), (2, 82.1, 'Spruce', 'Boreal');
What is the average age of trees in the 'Boreal' region?
SELECT AVG(age) FROM trees WHERE region = 'Boreal';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_sites (id INT, site_name VARCHAR(50), region VARCHAR(50), total_waste FLOAT); INSERT INTO chemical_sites (id, site_name, region, total_waste) VALUES (1, 'Site A', 'Asia', 150.5), (2, 'Site B', 'Europe', 125.7), (3, 'Site C', 'Asia', 200.3), (4, 'Site D', 'Africa', 75.9);
What is the average chemical waste produced per site, partitioned by region and ordered by the highest average?
SELECT region, AVG(total_waste) as avg_waste FROM chemical_sites GROUP BY region ORDER BY avg_waste DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (HotelID int, HotelName varchar(255), Country varchar(255), Rating float); INSERT INTO Hotels (HotelID, HotelName, Country, Rating) VALUES (1, 'Hotel X', 'France', 4.5), (2, 'Hotel Y', 'Spain', 4.2), (3, 'Hotel Z', 'Italy', 4.7);
What is the average hotel rating for each country, ordered by the highest rating first?
SELECT Country, AVG(Rating) as AvgRating FROM Hotels GROUP BY Country ORDER BY AvgRating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mlb_games (id INT, home_team VARCHAR(50), away_team VARCHAR(50), runs_scored INT, season VARCHAR(10)); INSERT INTO mlb_games (id, home_team, away_team, runs_scored, season) VALUES (1, 'New York Mets', 'Philadelphia Phillies', 4, '2023'), (2, 'Atlanta Braves', 'New York Mets', 3, '2023');
What is the average number of runs scored by the New York Mets in their home games in the 2023 MLB season?
SELECT AVG(runs_scored) FROM mlb_games WHERE home_team = 'New York Mets' AND season = '2023';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, region VARCHAR(20), severity VARCHAR(10));INSERT INTO vulnerabilities (id, region, severity) VALUES (1, 'Asia Pacific', 'High');INSERT INTO vulnerabilities (id, region, severity) VALUES (2, 'Europe', 'Medium');INSERT INTO vulnerabilities (id, region, severity) VALUES (3, 'North Ame...
Which high severity vulnerabilities were found in the Americas?
SELECT * FROM vulnerabilities WHERE region LIKE 'America%' AND severity = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(100), country VARCHAR(50), donation DECIMAL(10,2)); INSERT INTO donors (id, name, country, donation) VALUES (1, 'John Doe', 'Australia', 50.00), (2, 'Jane Smith', 'USA', 100.00), (3, 'Alice Johnson', 'New Zealand', 75.00), (4, 'Bob Brown', 'Africa', 25.00), (5, 'Charlie Green',...
What is the average amount of donations given per donor from Oceania?
SELECT AVG(donation) FROM donors WHERE country IN ('Australia', 'New Zealand');
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (title VARCHAR(255), duration MINUTE, production_country VARCHAR(64));
What is the average duration of TV shows produced in the UK?
SELECT AVG(duration) FROM tv_shows WHERE production_country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(255)); INSERT INTO marine_species (id, species) VALUES (1, 'Dolphin'), (2, 'Shark'); CREATE TABLE pollution_control (id INT, initiative VARCHAR(255)); INSERT INTO pollution_control (id, initiative) VALUES (1, 'Beach Cleanup'), (2, 'Ocean Floor Mapping'), (3, 'Coral R...
Identify pollution control initiatives that are not present in the pollution_control table.
SELECT pollution_control.initiative FROM pollution_control LEFT JOIN marine_species ON pollution_control.initiative = marine_species.species WHERE marine_species.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE crop (id INT, type VARCHAR(255), temperature FLOAT); INSERT INTO crop (id, type, temperature) VALUES (1, 'corn', 22.5), (2, 'soybean', 20.0), (3, 'cotton', 24.3), (4, 'corn', 27.5), (5, 'soybean', 24.5);
Find the maximum temperature for all crops
SELECT MAX(temperature) FROM crop;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_projects (project_id INT, location VARCHAR(50), investment_amount FLOAT, investment_year INT); INSERT INTO climate_adaptation_projects (project_id, location, investment_amount, investment_year) VALUES (1, 'Egypt', 5000000, 2018), (2, 'Morocco', 4000000, 2018), (3, 'Jordan', 3000000, 2018...
What is the maximum investment in climate adaptation projects in the Middle East and North Africa in 2018?
SELECT MAX(investment_amount) FROM climate_adaptation_projects WHERE location LIKE 'Middle East%' AND investment_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, building_name VARCHAR(50), country VARCHAR(50), certification_level VARCHAR(50));
List the top 3 countries with the highest number of green buildings in the 'green_buildings' table
SELECT country, COUNT(*) as building_count FROM green_buildings GROUP BY country ORDER BY building_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, state TEXT, policy_type TEXT, issue_date DATE); INSERT INTO policyholders (id, name, state, policy_type, issue_date) VALUES (1, 'John Doe', 'FL', 'Auto', '2021-01-01'); INSERT INTO policyholders (id, name, state, policy_type, issue_date) VALUES (2, 'Jane Smith', 'FL', 'Hom...
What is the earliest issue date for policies in Florida?
SELECT MIN(issue_date) FROM policyholders WHERE state = 'FL';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, company_name VARCHAR(50), founder_disability VARCHAR(20)); INSERT INTO companies VALUES (1, 'Iota Inc', 'Yes'); INSERT INTO companies VALUES (2, 'Kappa Corp', NULL);
Identify the number of companies founded by individuals with disabilities
SELECT COUNT(*) FROM companies WHERE founder_disability IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, state VARCHAR(2), year INT, accessibility FLOAT, quality FLOAT);
Insert data into the table for mental health parity
INSERT INTO mental_health_parity (id, state, year, accessibility, quality) VALUES (1, 'NY', 2020, 7.5, 8.3), (2, 'CA', 2020, 8.1, 8.7);
gretelai_synthetic_text_to_sql
CREATE TABLE cruelty_free_certifications (id INT, product_id INT, country VARCHAR(50), rating INT); INSERT INTO cruelty_free_certifications (id, product_id, country, rating) VALUES (1, 101, 'USA', 9), (2, 102, 'Canada', 8), (3, 101, 'UK', 10), (4, 103, 'Australia', 9), (5, 102, 'Germany', 7), (6, 105, 'USA', 8);
Which cruelty-free certification ratings are associated with product 105?
SELECT rating FROM cruelty_free_certifications WHERE product_id = 105;
gretelai_synthetic_text_to_sql
CREATE TABLE fields (field_id INT, field_name TEXT, location TEXT); INSERT INTO fields (field_id, field_name, location) VALUES (1, 'Field A', 'Gulf of Mexico'), (2, 'Field B', 'North Sea'), (3, 'Field C', 'Brazil');
Delete all records from the 'fields' table where the location is not in the Gulf of Mexico.
DELETE FROM fields WHERE location NOT IN ('Gulf of Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (id INT, mission VARCHAR(50), location VARCHAR(50), depth DECIMAL(5,2), date DATE); INSERT INTO deep_sea_expeditions (id, mission, location, depth, date) VALUES (2, 'PACIFIC_PLATEAU', 'Pacific Ocean', 8500, '2021-10-01');
How many deep-sea expeditions reached a depth greater than 8000 meters in the Pacific Ocean?
SELECT COUNT(*) FROM deep_sea_expeditions WHERE location = 'Pacific Ocean' AND depth > 8000;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Material VARCHAR(50), Quantity INT);INSERT INTO Brands (BrandID, BrandName, Material, Quantity) VALUES (1, 'BrandA', 'Organic Cotton', 3000), (2, 'BrandB', 'Recycled Polyester', 2500), (1, 'BrandA', 'Organic Silk', 1000), (3, 'BrandC', 'Organic Cotton', 2000), (2...
What is the total quantity of sustainable materials used by each brand, excluding 'Organic Cotton'?
SELECT BrandName, SUM(Quantity) as TotalQuantity FROM Brands WHERE Material != 'Organic Cotton' GROUP BY BrandName;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_payment (payment_id INT PRIMARY KEY, client_id INT, payment_amount DECIMAL(10, 2), payment_date DATE);CREATE TABLE financial_wellbeing_client (client_id INT PRIMARY KEY, name VARCHAR(100), age INT, income DECIMAL(10, 2));INSERT INTO financial_wellbeing_payment (payment_id, client_id, pa...
Delete records of clients who have not made any loan payments in the Financial Wellbeing database
DELETE p FROM financial_wellbeing_payment p INNER JOIN financial_wellbeing_client c ON p.client_id = c.client_id WHERE NOT EXISTS (SELECT 1 FROM financial_wellbeing_payment p2 WHERE p2.client_id = c.client_id);
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (app_id INT, app_name TEXT, safety_rating REAL, country TEXT); INSERT INTO creative_ai VALUES (1, 'Dalle', 4.3, 'USA'), (2, 'GTP-3', 4.5, 'Canada'), (3, 'Midjourney', 4.7, 'Australia');
What is the average safety rating for all creative AI applications, grouped by country?
SELECT country, AVG(safety_rating) as avg_safety_rating FROM creative_ai GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(50), genre VARCHAR(20));CREATE TABLE characters (id INT, movie_id INT, name VARCHAR(50), gender VARCHAR(10), lines_spoken INT);
What is the total number of words spoken by male and female characters in the 'Sci-Fi' genre in the last 3 years?
SELECT genre, SUM(CASE WHEN gender = 'male' THEN lines_spoken ELSE 0 END) AS total_male_lines, SUM(CASE WHEN gender = 'female' THEN lines_spoken ELSE 0 END) AS total_female_lines FROM movies m JOIN characters c ON m.id = c.movie_id WHERE m.genre = 'Sci-Fi' AND publish_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR...
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name VARCHAR(50), conservation_status VARCHAR(20)); INSERT INTO marine_species (species_name, conservation_status) VALUES ('Vaquita Porpoise', 'critically endangered'), ('Black Abalone', 'endangered');
List all critically endangered marine species.
SELECT species_name FROM marine_species WHERE conservation_status = 'critically endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, min_depth INTEGER, max_depth INTEGER); INSERT INTO marine_protected_areas (name, location, min_depth, max_depth) VALUES ('Area A', 'Atlantic', 50, 200), ('Area B', 'Atlantic', 75, 175), ('Area C', 'Indian', 100, 250);
What is the maximum depth of any marine protected area in the Atlantic?
SELECT MAX(max_depth) FROM marine_protected_areas WHERE location = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_date DATE, incident_region VARCHAR(255)); INSERT INTO incidents (incident_id, incident_date, incident_region) VALUES (1, '2022-01-01', 'North America'); INSERT INTO incidents (incident_id, incident_date, incident_region) VALUES (2, '2022-01-15', 'APAC'); INSERT INTO inc...
How many security incidents were reported in the last month from the APAC region?
SELECT COUNT(*) FROM incidents WHERE incident_region = 'APAC' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Hiring (HireID INT, HireDate DATE); INSERT INTO Hiring (HireID, HireDate) VALUES (1, '2020-01-01'), (2, '2020-01-15'), (3, '2020-03-01'), (4, '2019-12-31');
How many employees were hired in Q1 of 2020?
SELECT COUNT(*) FROM Hiring WHERE HireDate BETWEEN '2020-01-01' AND '2020-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT PRIMARY KEY, loan_amount DECIMAL(10, 2), approval_date DATE);
Delete records of Shariah-compliant loans older than 2018.
DELETE FROM shariah_compliant_finance WHERE approval_date < '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investing (organization_name TEXT, donation_amount INTEGER); INSERT INTO impact_investing (organization_name, donation_amount) VALUES ('Effctive Altruism Funds', 50000), ('GiveWell', 40000), ('The Life You Can Save', 30000), ('EIN', 12000), ('Impact Matters', 9000);
Delete records of donations less than $10,000 in the 'impact_investing' table.
DELETE FROM impact_investing WHERE donation_amount < 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE property_crimes (id INT, city VARCHAR(20), clearance_rate FLOAT); INSERT INTO property_crimes (id, city, clearance_rate) VALUES (1, 'Chicago', 0.45);
What is the clearance rate for property crimes in the city of Chicago?
SELECT clearance_rate FROM property_crimes WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_sales (sale_id int, sale_date date, product_id int, revenue decimal, is_ethical boolean);
What is the sales trend of ethical products in the past year, broken down by month?
SELECT DATEPART(YEAR, sale_date) AS year, DATEPART(MONTH, sale_date) AS month, SUM(revenue) AS total_revenue FROM ethical_sales WHERE is_ethical = true GROUP BY DATEPART(YEAR, sale_date), DATEPART(MONTH, sale_date);
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policyholder_state VARCHAR(20)); INSERT INTO policies (policy_id, policyholder_state) VALUES (1, 'Washington'), (2, 'Oregon'), (3, 'Washington');
What is the count of policies issued to policyholders in 'Washington' and 'Oregon'?
SELECT COUNT(*) FROM policies WHERE policyholder_state IN ('Washington', 'Oregon');
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, plan_type VARCHAR(10), region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, plan_type, region) VALUES (1, '5G', 'Northeast'); INSERT INTO subscribers (subscriber_id, plan_type, region) VALUES (2, '4G', 'Southeast');
Calculate the percentage of mobile subscribers who have upgraded to 5G plans, in each region.
SELECT region, COUNT(*) FILTER (WHERE plan_type = '5G') * 100.0 / COUNT(*) OVER (PARTITION BY region) as pct_5g_subscribers FROM subscribers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mining_type VARCHAR(255), country VARCHAR(255), num_employees INT); INSERT INTO mining_operations (id, mining_type, country, num_employees) VALUES (1, 'open pit', 'Australia', 100), (2, 'underground', 'Australia', 150), (3, 'open pit', 'Australia', 120); CREATE TABLE employee_dem...
How many employees from underrepresented communities have been hired by mining operations in Australia in the last 3 months, partitioned by the mining type?
SELECT mining_type, COUNT(*) as num_underrepresented_employees FROM mining_operations JOIN employee_demographics ON mining_operations.id = employee_demographics.mining_operation_id WHERE country = 'Australia' AND operation_date >= DATEADD(month, -3, GETDATE()) AND employee_group = 'underrepresented' GROUP BY mining_typ...
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerDemographics (PlayerID INT, Game VARCHAR(20), Age INT); INSERT INTO PlayerDemographics (PlayerID, Game, Age) VALUES (1, 'Rocket League', 19), (2, 'Overwatch', 22), (3, 'Minecraft', 15), (4, 'Rocket League', 20), (5, 'Overwatch', 24);
Find the difference in the number of players between 'Rocket League' and 'Overwatch'
SELECT COUNT(CASE WHEN Game = 'Rocket League' THEN 1 END) - COUNT(CASE WHEN Game = 'Overwatch' THEN 1 END) FROM PlayerDemographics
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS rainfall_levels (id int, location varchar(50), rainfall float, timestamp datetime); INSERT INTO rainfall_levels (id, location, rainfall, timestamp) VALUES (1, 'India', 54.8, '2022-03-25 10:00:00');
Find the average rainfall level in India in the last 60 days?
SELECT AVG(rainfall) FROM rainfall_levels WHERE location = 'India' AND timestamp >= DATE_SUB(NOW(), INTERVAL 60 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE disease_prevalence (id INT, region VARCHAR(50), heart_disease INT, cancer INT, diabetes INT);
Update the "disease_prevalence" table to include the latest data for the "heart_disease" column.
UPDATE disease_prevalence SET heart_disease = (SELECT latest_heart_disease_data FROM latest_data) WHERE region = 'Rural Appalachia';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50), ethical BOOLEAN); CREATE TABLE Sales (sale_id INT, brand_id INT, revenue DECIMAL(10,2)); CREATE TABLE Regions (region_id INT, region VARCHAR(50)); CREATE TABLE BrandRegions (brand_id INT, region_id INT);
What is the total revenue of fair labor practice brands in each region?
SELECT R.region, SUM(S.revenue) FROM Brands B INNER JOIN Sales S ON B.brand_id = S.brand_id INNER JOIN BrandRegions BR ON B.brand_id = BR.brand_id INNER JOIN Regions R ON BR.region_id = R.region_id WHERE B.ethical = TRUE GROUP BY R.region;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers_3 (id INT, name TEXT, country TEXT, certification TEXT); INSERT INTO farmers_3 (id, name, country, certification) VALUES (1, 'Farmer A', 'India', 'organic'), (2, 'Farmer B', 'China', 'conventional'), (3, 'Farmer C', 'Japan', 'organic');
How many farmers are there in 'Asia' without any production records?
SELECT COUNT(*) FROM farmers_3 WHERE country = 'Asia' AND id NOT IN (SELECT farmer_id FROM crops);
gretelai_synthetic_text_to_sql
CREATE TABLE public.vehicles (id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO public.vehicles (id, type, city) VALUES (1, 'electric_car', 'San Francisco'), (2, 'conventional_car', 'San Francisco'), (3, 'electric_bus', 'Los Angeles'), (4, 'conventional_bus', 'Los Angeles'), (5, 'electric_car', 'New York');
List all cities with their respective counts of electric vehicles
SELECT city, COUNT(*) FROM public.vehicles WHERE type LIKE 'electric%' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_speed (id INT PRIMARY KEY, bus_id INT, speed INT, speed_time TIMESTAMP);
Display the average speed of buses with registration numbers starting with 'B' for the month of May 2022
SELECT bus_id, AVG(speed) AS avg_speed FROM bus_speed WHERE bus_id LIKE 'B%' AND speed_time >= '2022-05-01 00:00:00' AND speed_time < '2022-06-01 00:00:00' GROUP BY bus_id;
gretelai_synthetic_text_to_sql
CREATE TABLE military_technologies (id INT, name VARCHAR(100), branch VARCHAR(50), year_developed INT);
How many military technologies were developed in each year, according to the military_technologies table?
SELECT year_developed, COUNT(*) as technology_count FROM military_technologies GROUP BY year_developed;
gretelai_synthetic_text_to_sql
VESSEL(vessel_id, vessel_name); TRIP(voyage_id, trip_date, vessel_id, cargo_weight)
List vessels with the highest cargo weight transported in Q1 2022
SELECT v.vessel_id, v.vessel_name, SUM(t.cargo_weight) AS total_cargo_weight FROM VESSEL v JOIN TRIP t ON v.vessel_id = t.vessel_id WHERE t.trip_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY v.vessel_id, v.vessel_name ORDER BY total_cargo_weight DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE age_groups (age_group_id INT, age_group VARCHAR(10), start_age INT, end_age INT);
Calculate the average financial wellbeing score for each age group
CREATE TABLE financial_wellbeing_scores (score_id INT, score DECIMAL(18,2), age_group_id INT); SELECT age_group, AVG(score) FROM age_groups INNER JOIN financial_wellbeing_scores ON age_groups.age_group_id = financial_wellbeing_scores.age_group_id GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE, donor_country VARCHAR); INSERT INTO donations (id, donor_id, donation_amount, donation_date, donor_country) VALUES (1, 101, '500', '2021-01-01', 'USA'), (2, 102, '300', '2021-02-01', 'Canada'), (3, 103, '800', '2021-03-01', 'Mexi...
What is the average donation amount for donors from the USA and Canada?
SELECT AVG(donation_amount) as avg_donation_amount FROM donations WHERE donor_country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty (FacultyID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10), Salary INT); INSERT INTO Faculty (FacultyID, Name, Department, Gender, Salary) VALUES (1, 'Alice', 'Physics', 'Female', 80000); INSERT INTO Faculty (FacultyID, Name, Department, Gender, Salary) VALUES (2, 'Bob', 'Physics'...
What is the minimum research grant amount awarded to a faculty member in the Physics department?
SELECT MIN(Amount) FROM ResearchGrants rg INNER JOIN Faculty f ON rg.FacultyID = f.FacultyID WHERE f.Department = 'Physics';
gretelai_synthetic_text_to_sql
CREATE TABLE facility_location (facility_id INT, state VARCHAR(50), quarter INT, year INT, co2_emissions FLOAT); INSERT INTO facility_location (facility_id, state, quarter, year, co2_emissions) VALUES (1, 'California', 1, 2021, 1500), (1, 'California', 2, 2021, 1600), (1, 'California', 3, 2021, 1700), (1, 'California',...
Get the total CO2 emissions per quarter for the facilities located in California.
SELECT state, quarter, year, SUM(co2_emissions) as total_co2_emissions FROM facility_location WHERE state = 'California' GROUP BY state, quarter, year;
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSuppliers (id INT, supplier_name TEXT, eco_friendly_material BOOLEAN); INSERT INTO TextileSuppliers (id, supplier_name, eco_friendly_material) VALUES (1, 'GreenTextiles', true), (2, 'BlueFabrics', false), (3, 'EcoFiberCo', true);
Which textile suppliers have provided eco-friendly materials to the company?
SELECT supplier_name FROM TextileSuppliers WHERE eco_friendly_material = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Habitats (id INT, name VARCHAR(20)); INSERT INTO Habitats (id, name) VALUES (1, 'Habitat A'), (2, 'Habitat B'), (3, 'Habitat C'), (4, 'Habitat D'), (5, 'Habitat E'), (6, 'Habitat F'); CREATE TABLE Animals (id INT, name VARCHAR(20), habitat_id INT); INSERT INTO Animals (id, name, habitat_id) VALUES (1, 'Tig...
Find the total number of animals in each habitat that were educated in a given year, excluding 'Habitat F'?
SELECT subquery.habitat_id, SUM(num_animals) FROM (SELECT habitat_id, COUNT(*) as num_animals FROM Animals INNER JOIN Education ON Animals.id = Education.animal_id WHERE habitat_id != 6 GROUP BY habitat_id, YEAR(Education.date)) AS subquery GROUP BY subquery.habitat_id
gretelai_synthetic_text_to_sql
CREATE TABLE Tokyo_Neighborhoods (Neighborhood_Name TEXT, Sustainability BOOLEAN); INSERT INTO Tokyo_Neighborhoods (Neighborhood_Name, Sustainability) VALUES ('Shinjuku', true), ('Shibuya', false), ('Ginza', true), ('Tsukiji', false), ('Asakusa', true); CREATE TABLE Tokyo_Properties (Neighborhood_Name TEXT, Property_Si...
What is the average property size in sustainable neighborhoods in Tokyo?
SELECT AVG(Tokyo_Properties.Property_Size) FROM Tokyo_Properties INNER JOIN Tokyo_Neighborhoods ON Tokyo_Properties.Neighborhood_Name = Tokyo_Neighborhoods.Neighborhood_Name WHERE Tokyo_Neighborhoods.Sustainability = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255), type VARCHAR(255), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, type, launch_date) VALUES (1, 'Chandrayaan-1', 'ISRO', 'Robotic', '2008-10-22'); INSERT INTO Spacecraft (id, name, manufacturer, type, launch_date) VALUES ...
Which spacecraft have been launched by ISRO?
SELECT name FROM Spacecraft WHERE manufacturer = 'ISRO';
gretelai_synthetic_text_to_sql
CREATE TABLE OnlineEngagement (EventID INT, EventName VARCHAR(50), TotalParticipants INT, AvgDuration FLOAT);
Insert new records for the OnlineEngagement table for the 'Virtual Tour' event.
INSERT INTO OnlineEngagement (EventID, EventName, TotalParticipants, AvgDuration) VALUES (201, 'Virtual Tour', 120, 45.5);
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(100), OperationType VARCHAR(50), Country VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO MiningOperations (OperationID, MineName, OperationType, Country, StartDate, EndDate) VALUES (1, 'Golden Mine', 'Exploration', 'South Africa', '2015-01-01', '2...
Identify the mining operations with the highest water usage in South Africa.
SELECT mo.OperationID, mo.MineName, ei.WaterUsage FROM MiningOperations mo JOIN EnvironmentalImpact ei ON mo.OperationID = ei.OperationID WHERE mo.Country = 'South Africa' ORDER BY ei.WaterUsage DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (project_id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), budget FLOAT); INSERT INTO climate_projects (project_id, name, country, budget) VALUES (1, 'Solar Power India', 'India', 5000000); INSERT INTO climate_projects (project_id, name, country, budget) VALUES (2, 'Wind Farms I...
Find the average budget of climate change projects
SELECT AVG(budget) FROM climate_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, is_volunteer BOOLEAN); INSERT INTO donations (id, donor_name, donation_amount, donation_date, is_volunteer) VALUES (1, 'Ravi Sharma', 200.00, '2021-04-15', true), (2, 'Priya Gupta', 300.00, '2021-07-30', true), (3...
What is the total donation amount from volunteers in India, grouped by fiscal quarter?
SELECT DATE_FORMAT(donation_date, '%Y-%V') AS fiscal_quarter, SUM(donation_amount) FROM donations WHERE is_volunteer = true AND donor_country = 'India' GROUP BY fiscal_quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT PRIMARY KEY, name VARCHAR(50), ethical_certifications INT); INSERT INTO Brands (brand_id, name, ethical_certifications) VALUES (1, 'Sustainable Fashion', 3), (2, 'Eco Friendly Wear', 2);
What is the total number of ethical certifications for all brands?
SELECT SUM(ethical_certifications) FROM Brands;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), HireDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, HireDate) VALUES (1, 'John', 'Doe', 'IT', '2021-06-01'), (2, 'Jane', 'Doe', 'HR', '2022-02-15');
How many employees have been hired in the past year, broken down by department?
SELECT Department, COUNT(*) FROM Employees WHERE HireDate >= DATEADD(year, -1, GETDATE()) GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE state_conservation_efforts (state TEXT, month INT, water_conserved FLOAT); INSERT INTO state_conservation_efforts (state, month, water_conserved) VALUES ('CA', 1, 100000), ('CA', 2, 120000), ('NY', 1, 150000), ('NY', 2, 180000);
What is the maximum water conservation effort by any state in a month?
SELECT state, MAX(water_conserved) FROM state_conservation_efforts GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, faculty_id INT, year INT, amount DECIMAL(10,2)); INSERT INTO grants (id, faculty_id, year, amount) VALUES (1, 1, 2020, 85000); INSERT INTO grants (id, faculty_id, year, amount) VALUES (2, 2, 2019, 35000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO f...
Determine the maximum grant amount awarded to a faculty member in the Mathematics department.
SELECT MAX(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Mathematics';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, program TEXT, country TEXT, donation_amount DECIMAL(10, 2)); INSERT INTO donations VALUES (1, 'Education', 'Canada', 200.00), (2, 'Healthcare', 'Canada', 300.00), (3, 'Environment', 'Canada', 400.00);
What is the average donation amount per program in Canada?
SELECT program, AVG(donation_amount) FROM donations WHERE country = 'Canada' GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'USA'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'Canada'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES ...
What is the average age of players from each country?
SELECT Country, AVG(Age) FROM Players GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(100), region VARCHAR(50), assets_value FLOAT); INSERT INTO customers (id, name, region, assets_value) VALUES (1, 'Li Xiang', 'Greater China', 350000.00);
Delete the record of the customer with the lowest assets value from 'Greater China' region.
DELETE FROM customers WHERE id = (SELECT id FROM customers WHERE region = 'Greater China' ORDER BY assets_value ASC LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE RuralHospitals (Country VARCHAR(20), HospitalName VARCHAR(50), NumberOfBeds INT); INSERT INTO RuralHospitals (Country, HospitalName, NumberOfBeds) VALUES ('Canada', 'Hospital A', 75), ('Canada', 'Hospital B', 100), ('USA', 'Hospital C', 50), ('USA', 'Hospital D', 75);
What is the average number of hospital beds per rural hospital in Canada and the United States?
SELECT AVG(NumberOfBeds) FROM RuralHospitals WHERE Country IN ('Canada', 'USA') AND HospitalName IN ('Hospital A', 'Hospital B', 'Hospital C', 'Hospital D') GROUP BY Country;
gretelai_synthetic_text_to_sql