context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE field (id INT, name VARCHAR(20)); CREATE TABLE soil_moisture (id INT, field_id INT, value INT, timestamp TIMESTAMP);
Which fields have had a decrease in soil moisture in the past week?
SELECT f.name FROM field f INNER JOIN soil_moisture sm1 ON f.id = sm1.field_id INNER JOIN soil_moisture sm2 ON f.id = sm2.field_id AND sm2.timestamp = sm1.timestamp - INTERVAL '1 day' WHERE sm1.value > sm2.value;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (game_id INT, game_name VARCHAR(100), rating DECIMAL(3,2), reviews INT); INSERT INTO Games (game_id, game_name, rating, reviews) VALUES (1, 'GameA', 4.5, 1500), (2, 'GameB', 3.8, 850), (3, 'GameC', 4.2, 1200);
Find the average rating and total reviews for each game in the 'Games' table
SELECT game_name, AVG(rating) AS avg_rating, SUM(reviews) AS total_reviews FROM Games GROUP BY game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, garment_id INT, size INT, sale_date DATE, country VARCHAR(50)); INSERT INTO sales (id, garment_id, size, sale_date, country) VALUES (1, 1007, 14, '2021-04-15', 'Canada');
How many size 14 garments were sold in Canada in the last month?
SELECT COUNT(*) FROM sales WHERE size = 14 AND country = 'Canada' AND sale_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Skincare_Sales_USA(Product_Name VARCHAR(30), Product_Type VARCHAR(20), Sales DECIMAL(10,2)); INSERT INTO Skincare_Sales_USA(Product_Name, Product_Type, Sales) VALUES('Product A', 'Moisturizer', 2000), ('Product B', 'Cleanser', 1500), ('Product C', 'Toner', 1200), ('Product D', 'Exfoliant', 1800), ('Product E', 'Serum', 2500), ('Product F', 'Moisturizer', 3000), ('Product G', 'Cleanser', 2000), ('Product H', 'Toner', 1700), ('Product I', 'Exfoliant', 1600), ('Product J', 'Serum', 2200);
Identify the top 5 best-selling skincare products in the USA?
SELECT Product_Name, Sales FROM Skincare_Sales_USA WHERE Country = 'USA' ORDER BY Sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (id INT PRIMARY KEY, product_id INT, name TEXT, quantity REAL);
Delete all ingredients associated with the food product with id 1
DELETE FROM ingredients WHERE product_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, region TEXT); INSERT INTO marine_species (name, region) VALUES ('Species1', 'Arctic'); INSERT INTO marine_species (name, region) VALUES ('Species2', 'Atlantic');
Find all marine species that have been observed in either the Arctic or the Atlantic regions
SELECT DISTINCT name FROM marine_species WHERE region IN ('Arctic', 'Atlantic');
gretelai_synthetic_text_to_sql
CREATE TABLE DApps (dapp_id INT, dapp_name VARCHAR(255), transaction_volume DECIMAL(18,2)); INSERT INTO DApps (dapp_id, dapp_name, transaction_volume) VALUES (1, 'Uniswap', 123456.78), (2, 'SushiSwap', 23456.78), (3, 'Aave', 34567.89), (4, 'Compound', 45678.90), (5, 'Yearn Finance', 56789.01);
List all decentralized applications (dApps) and their respective total transaction volume for Q2 2021, ordered by the dApps with the highest transaction volume in Q2 2021.
SELECT dapp_name, transaction_volume FROM (SELECT dapp_name, transaction_volume, RANK() OVER (ORDER BY transaction_volume DESC) as rank FROM DApps WHERE DApps.transaction_date BETWEEN '2021-04-01' AND '2021-06-30') AS ranked_dapps ORDER BY rank;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, City TEXT); CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT);
What is the number of volunteers and total volunteer hours for each city, sorted by the number of volunteers in descending order?
SELECT V.City, COUNT(V.VolunteerID) as NumVolunteers, SUM(VH.Hours) as TotalHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID GROUP BY V.City ORDER BY NumVolunteers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name TEXT, country TEXT); INSERT INTO artists (artist_id, artist_name, country) VALUES (1, 'Artist 1', 'China'), (2, 'Artist 2', 'Japan'), (3, 'Artist 3', 'USA'); CREATE TABLE songs (song_id INT, title TEXT, release_date DATE, artist_id INT); INSERT INTO songs (song_id, title, release_date, artist_id) VALUES (1, 'Song 1', '2018-01-01', 1), (2, 'Song 2', '2019-06-15', 2), (3, 'Song 3', '2020-12-25', 3);
Find the number of songs released by artists from Asia in the last 5 years.
SELECT COUNT(songs.song_id) FROM songs JOIN artists ON songs.artist_id = artists.artist_id WHERE artists.country = 'China' OR artists.country = 'Japan' AND songs.release_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(255)); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10, 2), DonationDate DATE);
What is the average donation amount per month, per donor for the past year, and which donor has the highest average donation amount in this period?
SELECT DonorID, DonorName, AVG(DonationAmount) AS AvgDonation, RANK() OVER (ORDER BY AVG(DonationAmount) DESC) AS DonorRank FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE DonationDate >= DATEADD(YEAR, -1, CURRENT_DATE) GROUP BY DonorID, DonorName, YEAR(DonationDate), MONTH(DonationDate) ORDER BY DonorRank;
gretelai_synthetic_text_to_sql
CREATE TABLE water_treatment_plant (plant_id INT, state VARCHAR(50), year INT, month INT, day INT, water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id, state, year, month, day, water_consumption) VALUES (9, 'Colorado', 2023, 1, 1, 12345.6), (9, 'Colorado', 2023, 1, 2, 23456.7), (9, 'Colorado', 2023, 1, 3, 34567.8);
What is the minimum daily water consumption for the water treatment plant with ID 9 in the state of Colorado in 2023?
SELECT MIN(water_consumption) as min_water_consumption FROM water_treatment_plant WHERE plant_id = 9 AND state = 'Colorado' AND year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide (country_name VARCHAR(50), region VARCHAR(20), divide_index DECIMAL(5, 2));INSERT INTO digital_divide (country_name, region, divide_index) VALUES ('Costa Rica', 'Central America', 0.25), ('Cuba', 'Caribbean', 0.30), ('Estonia', 'Baltic states', 0.55), ('Latvia', 'Baltic states', 0.45);
Show the average digital divide index for countries in Central America, the Caribbean, and the Baltic states.
SELECT AVG(divide_index) FROM digital_divide WHERE region IN ('Central America', 'Caribbean', 'Baltic states');
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), year INT, price FLOAT, type VARCHAR(255));
Show all electric vehicles and their prices
SELECT * FROM electric_vehicles WHERE type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(255), rating DECIMAL(2,1), country VARCHAR(255)); INSERT INTO hotels (hotel_id, hotel_name, rating, country) VALUES (1, 'Hotel Cairo', 4.1, 'Egypt'), (2, 'Hotel Cape Town', 4.6, 'South Africa'), (3, 'Hotel Marrakech', 4.8, 'Morocco');
What is the average rating of hotels in 'Africa' that have been reviewed more than 30 times?
SELECT AVG(rating) FROM (SELECT rating FROM hotels WHERE country = 'Africa' GROUP BY rating HAVING COUNT(*) > 30) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE industry_emission_targets (industry_name VARCHAR(50), year INT, co2_emission_target DECIMAL(10,2));
What is the CO2 emission reduction target for the fashion industry in 2030?
SELECT co2_emission_target AS co2_emission_reduction_target_2030 FROM industry_emission_targets WHERE industry_name = 'Fashion' AND year = 2030;
gretelai_synthetic_text_to_sql
CREATE TABLE orgs (id INT, name TEXT); INSERT INTO orgs (id, name) VALUES (1, 'Seeds of Hope'); INSERT INTO orgs (id, name) VALUES (2, 'Green Urban'); INSERT INTO orgs (id, name) VALUES (3, 'Harvest Together'); CREATE TABLE projects (id INT, org_id INT, name TEXT, type TEXT); INSERT INTO projects (id, org_id, name, type) VALUES (1, 1, 'Community Garden', 'Urban Agriculture'); INSERT INTO projects (id, org_id, name, type) VALUES (2, 1, 'Cooking Classes', 'Food Justice'); INSERT INTO projects (id, org_id, name, type) VALUES (3, 3, 'Food Co-op', 'Urban Agriculture');
Display the number of urban agriculture projects and their respective types for each organization.
SELECT o.name, p.type, COUNT(p.id) FROM orgs o JOIN projects p ON o.id = p.org_id WHERE o.name IN ('Seeds of Hope', 'Green Urban', 'Harvest Together') GROUP BY o.name, p.type;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, name TEXT, country TEXT, safety_score FLOAT); INSERT INTO ai_models (model_id, name, country, safety_score) VALUES (1, 'ModelA', 'India', 0.85), (2, 'ModelB', 'China', 0.90), (3, 'ModelC', 'US', 0.75), (4, 'ModelD', 'Germany', 0.95), (5, 'ModelE', 'France', 0.92), (6, 'ModelF', 'Japan', 0.88);
What is the average safety score for models developed in Asia?
SELECT AVG(safety_score) FROM ai_models WHERE country IN ('India', 'China', 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE, Duration INT); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate, Duration) VALUES (1, 1, '2022-01-01', 60); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate, Duration) VALUES (2, 1, '2022-01-03', 90);
What is the total workout duration for a specific member last week?
SELECT SUM(Duration) FROM Workouts WHERE MemberID = 1 AND WorkoutDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approvals (id INT, drug VARCHAR(255), indication VARCHAR(255), approval_date DATE); INSERT INTO drug_approvals (id, drug, indication, approval_date) VALUES (1, 'DrugC', 'Orphan Disease', '2018-04-25'); INSERT INTO drug_approvals (id, drug, indication, approval_date) VALUES (2, 'DrugD', 'Cardiovascular', '2017-11-10');
List all drugs approved for orphan diseases in the year 2018.
SELECT drug FROM drug_approvals WHERE indication = 'Orphan Disease' AND approval_date BETWEEN '2018-01-01' AND '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, city VARCHAR(20)); INSERT INTO hotels (id, city) VALUES (1, 'Tokyo'), (2, 'Osaka'), (3, 'Kyoto'); CREATE TABLE attractions (id INT, name VARCHAR(50), city VARCHAR(20)); INSERT INTO attractions (id, name, city) VALUES (1, 'Palace', 'Tokyo'), (2, 'Castle', 'Osaka'), (3, 'Shrine', 'Kyoto');
What is the total number of hotels and attractions in Japan?
SELECT COUNT(*) FROM hotels UNION ALL SELECT COUNT(*) FROM attractions;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), location VARCHAR(50), environmental_impact_score INT); INSERT INTO mining_operations (id, name, location, environmental_impact_score) VALUES (1, 'Mining Operation 1', 'São Paulo, Brazil', 80), (2, 'Mining Operation 2', 'São Paulo, Brazil', 20);
List all mining operations that have a high environmental impact score in the state of São Paulo, Brazil?
SELECT * FROM mining_operations WHERE environmental_impact_score >= 50 AND location LIKE '%São Paulo, Brazil%';
gretelai_synthetic_text_to_sql
CREATE TABLE youth_programs (id INT, program VARCHAR(20), duration INT); INSERT INTO youth_programs (id, program, duration) VALUES (1, 'Youth Restorative Circles', 75); INSERT INTO youth_programs (id, program, duration) VALUES (2, 'Youth Community Conferencing', 90);
What is the average duration of restorative justice programs for youth offenders?
SELECT AVG(duration) FROM youth_programs WHERE program LIKE 'Youth%';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_maintenance (request_id INT, request_date DATE); INSERT INTO military_equipment_maintenance (request_id, request_date) VALUES (1, '2022-07-01'), (2, '2022-12-31');
Determine the number of military equipment maintenance requests in H2 2022
SELECT COUNT(*) FROM military_equipment_maintenance WHERE request_date >= '2022-07-01' AND request_date < '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (country VARCHAR(50), year INT, event_count INT); INSERT INTO defense_diplomacy (country, year, event_count) VALUES ('France', 2018, 5), ('France', 2018, 6), ('France', 2019, 7), ('France', 2019, 8);
What is the maximum number of defense diplomacy events conducted by France in 2018 and 2019?
SELECT MAX(event_count) FROM defense_diplomacy WHERE country = 'France' AND year IN (2018, 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (region VARCHAR(50), inspection_date DATE); INSERT INTO vessels VALUES ('Region 1', '2021-01-01'), ('Region 1', '2021-02-01'), ('Region 2', '2021-01-01');
How many vessels were inspected in each region for maritime law compliance, along with the inspection dates?
SELECT region, COUNT(*) as inspections, MIN(inspection_date) as first_inspection, MAX(inspection_date) as last_inspection FROM vessels GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, role VARCHAR(20), city VARCHAR(30));
Who are the top 3 cities with the most male investigative journalists in the 'reporters' table?
SELECT city, COUNT(*) as count FROM reporters WHERE gender = 'male' AND role = 'investigative_journalist' GROUP BY city ORDER BY count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_location (id INT, species_id INT, location TEXT, PRIMARY KEY (id, species_id), FOREIGN KEY (species_id) REFERENCES marine_species(id)); INSERT INTO marine_species_location (id, species_id, location) VALUES (1, 1, 'Atlantic Ocean'), (2, 2, 'Pacific Ocean'), (3, 3, 'Indian Ocean');
Which marine species are found in the Pacific Ocean?
SELECT marine_species.species_name FROM marine_species INNER JOIN marine_species_location ON marine_species.id = marine_species_location.species_id WHERE marine_species_location.location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), year INT, type VARCHAR(255));
Delete all the data from 'autonomous_vehicles' table
WITH deleted_data AS (DELETE FROM autonomous_vehicles RETURNING *) SELECT * FROM deleted_data;
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture (location VARCHAR(255), date DATE, moisture FLOAT); INSERT INTO soil_moisture (location, date, moisture) VALUES ('California Vineyard 1', '2021-05-01', 0.35), ('California Vineyard 1', '2021-05-02', 0.36), ('California Vineyard 2', '2021-05-01', 0.40);
What is the maximum soil moisture level in California vineyards, based on satellite imagery analysis?
SELECT MAX(moisture) FROM soil_moisture WHERE location LIKE '%California Vineyard%';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name TEXT, course_level TEXT); CREATE TABLE enrollments (enrollment_id INT, student_id INT, course_id INT, enrollment_date DATE, student_age INT); INSERT INTO courses VALUES (1, 'Introduction to Programming', 'beginner'), (2, 'Data Science Fundamentals', 'beginner'), (3, 'Advanced Machine Learning', 'intermediate'); INSERT INTO enrollments VALUES (1, 1, 1, '2022-01-01', 55), (2, 2, 1, '2022-01-02', 22), (3, 3, 2, '2022-01-03', 30), (4, 4, 2, '2022-01-04', 52), (5, 5, 3, '2022-01-05', 28);
Which lifelong learning courses have the most students aged 50 or older?
SELECT c.course_name, COUNT(e.student_id) FROM courses c INNER JOIN enrollments e ON c.course_id = e.course_id WHERE e.student_age >= 50 GROUP BY c.course_name ORDER BY COUNT(e.student_id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (Id INT, VehicleId INT, Quantity INT, SaleDate DATE); CREATE TABLE ElectricVehicles (Id INT, Name VARCHAR(100), Type VARCHAR(50)); INSERT INTO Sales (Id, VehicleId, Quantity, SaleDate) VALUES (1, 1, 500, '2021-01-01'); INSERT INTO Sales (Id, VehicleId, Quantity, SaleDate) VALUES (2, 2, 600, '2021-04-01'); INSERT INTO ElectricVehicles (Id, Name, Type) VALUES (1, 'Model S', 'Electric'); INSERT INTO ElectricVehicles (Id, Name, Type) VALUES (2, 'Leaf', 'Electric');
How many electric vehicles were sold in the United States by quarter in 2021?
SELECT DATE_TRUNC('quarter', SaleDate) AS Quarter, COUNT(*) FROM Sales INNER JOIN ElectricVehicles ON Sales.VehicleId = ElectricVehicles.Id WHERE Type = 'Electric' AND EXTRACT(YEAR FROM SaleDate) = 2021 GROUP BY Quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE mars_satellites (id INT, name VARCHAR(50), type VARCHAR(50), altitude INT, status VARCHAR(50)); INSERT INTO mars_satellites (id, name, type, altitude, status) VALUES (1, 'Sat1', 'Communication', 400, 'Stable'), (2, 'Sat2', 'Navigation', 350, 'Stable'), (3, 'Sat3', 'Observation', 520, 'Unstable');
What is the total number of satellites in a stable orbit around Mars, with altitude between 300km to 500km?
SELECT COUNT(*) FROM mars_satellites WHERE altitude BETWEEN 300 AND 500 AND status = 'Stable';
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR, location VARCHAR, years_of_experience INT); INSERT INTO Farmers (id, name, location, years_of_experience) VALUES (1, 'Nur Afiqah', 'Singapore', 2), (2, 'Max Schmidt', 'Berlin', 4), (3, 'Anastasia Kuznetsova', 'Moscow', 6), (4, 'Jacob Nielsen', 'Oslo', 8), (5, 'Carla Moraes', 'Sao Paulo', 10);
Which farmers have less than 5 years of experience in the agriculture database?
SELECT name FROM Farmers WHERE years_of_experience < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_monthly_stats (warehouse_id INT, month INT, packages_shipped INT); INSERT INTO warehouse_monthly_stats (warehouse_id, month, packages_shipped) VALUES (1, 1, 400), (2, 1, 300), (1, 2, 450), (2, 2, 350);
How many packages were shipped from 'east' region warehouses in January 2022?
SELECT SUM(packages_shipped) FROM warehouse_monthly_stats WHERE warehouse_id IN (SELECT id FROM warehouses WHERE region = 'east') AND month = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai_apps (app_id INT, app_name TEXT, region TEXT, safety_score FLOAT); INSERT INTO creative_ai_apps (app_id, app_name, region, safety_score) VALUES (1, 'AI Painter', 'Asia-Pacific', 0.85), (2, 'AI Music Composer', 'Europe', 0.92), (3, 'AI Writer', 'Asia-Pacific', 0.88);
What is the average safety score for all creative AI applications in the Asia-Pacific region?
SELECT AVG(safety_score) FROM creative_ai_apps WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(255), industry VARCHAR(255), assets DECIMAL(10, 2)); INSERT INTO customers (id, name, industry, assets) VALUES (1, 'John Doe', 'Financial Services', 150000.00), (2, 'Jane Smith', 'Financial Services', 200000.00), (3, 'Alice Johnson', 'Financial Services', 250000.00), (4, 'Bob Brown', 'Financial Services', 300000.00), (5, 'Charlie Davis', 'Retail', 50000.00), (6, 'Diana Green', 'Healthcare', 75000.00);
What is the total assets value for customers in the financial services industry who have assets greater than 250000?
SELECT SUM(assets) FROM customers WHERE industry = 'Financial Services' AND assets > 250000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE CityM_Satis (ID INT, Year INT, Satisfaction VARCHAR(10)); INSERT INTO CityM_Satis (ID, Year, Satisfaction) VALUES (1, 2021, 'Satisfied'), (2, 2021, 'Neutral'), (3, 2021, 'Dissatisfied'), (4, 2021, 'Dissatisfied'), (5, 2021, 'Satisfied');
Find the percentage of citizens in 'CityM' who are dissatisfied with the public transportation service in 2021.
SELECT 100.0 * COUNT(CASE WHEN Satisfaction = 'Dissatisfied' THEN 1 END) / COUNT(*) FROM CityM_Satis WHERE Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (AgeGroup VARCHAR(20), VolunteerID INT); INSERT INTO Volunteers (AgeGroup, VolunteerID) VALUES ('18-25', 100), ('26-35', 200), ('36-45', 300), ('46-55', 400), ('56-65', 500);
How many volunteers are there in each age group?
SELECT AgeGroup, COUNT(VolunteerID) as NumVolunteers FROM Volunteers GROUP BY AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE market_approvals (market_approval_id INT, region_id INT, approval_date DATE); CREATE TABLE drugs (drug_id INT, drug_name TEXT, market_approval_id INT); INSERT INTO market_approvals (market_approval_id, region_id, approval_date) VALUES (1, 1, '2020-01-01'), (2, 2, '2019-05-05');
List all market approvals, including those without any drugs approved, for a specific region in the 'market_approvals' and 'drugs' tables?
SELECT ma.approval_date, COALESCE(COUNT(d.drug_id), 0) AS drug_count FROM market_approvals ma LEFT JOIN drugs d ON ma.market_approval_id = d.market_approval_id WHERE ma.region_id = 1 GROUP BY ma.approval_date;
gretelai_synthetic_text_to_sql
CREATE TABLE member_demographics (member_id INT, age INT, heart_rate INT); INSERT INTO member_demographics (member_id, age, heart_rate) VALUES (1, 27, 80), (2, 32, 75), (3, 26, 85), (4, 28, 90), (5, 31, 70);
What is the average heart rate of members aged 25-30?
SELECT AVG(heart_rate) FROM member_demographics WHERE age BETWEEN 25 AND 30;
gretelai_synthetic_text_to_sql
CREATE TABLE polygon_assets (asset_id INT, asset_name VARCHAR(255), total_supply INT, current_price FLOAT);
What is the total number of unique digital assets on the Polygon network, and what is the average market capitalization (in USD) of these assets?
SELECT COUNT(DISTINCT asset_name) as unique_assets, AVG(total_supply * current_price) as avg_market_cap FROM polygon_assets;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_size (id INT PRIMARY KEY, size VARCHAR(10), customer_count INT); INSERT INTO customer_size (id, size, customer_count) VALUES (1, 'XS', 500), (2, 'S', 800), (3, 'M', 1200), (4, 'L', 1500); CREATE VIEW customer_size_view AS SELECT size, customer_count FROM customer_size;
Show data from customer_size view
SELECT * FROM customer_size_view;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_tourists (id INT, continent VARCHAR(50), country VARCHAR(50), eco_visitors INT, year INT); INSERT INTO eco_tourists (id, continent, country, eco_visitors, year) VALUES (1, 'Africa', 'Kenya', 1500, 2020), (2, 'Africa', 'Tanzania', 1800, 2020), (3, 'Africa', 'Kenya', 1700, 2021), (4, 'Africa', 'Tanzania', 2000, 2021);
What was the average number of eco-tourists in Africa in 2020 and 2021?
SELECT continent, AVG(eco_visitors) FROM eco_tourists WHERE continent = 'Africa' AND year IN (2020, 2021) GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Customs (id INT, importId INT, item VARCHAR(50), weight FLOAT, region VARCHAR(50), importDate DATE, expirationDate DATE);
Update the expiration dates of all dairy products imported from Europe in the past week.
UPDATE Customs SET expirationDate = DATE_ADD(importDate, INTERVAL 30 DAY) WHERE item LIKE '%dairy%' AND region = 'Europe' AND importDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE volunteers (id INT, name VARCHAR(50), program_id INT, location VARCHAR(50)); INSERT INTO programs (id, name, location) VALUES (1, 'Health', 'Urban'), (2, 'Education', 'Rural'); INSERT INTO volunteers (id, name, program_id, location) VALUES (1, 'Alice', 1, 'Urban'), (2, 'Bob', 1, 'Urban'), (3, 'Charlie', 2, 'Rural');
What is the total number of volunteers in rural areas?
SELECT COUNT(v.id) FROM volunteers v INNER JOIN programs p ON v.program_id = p.id WHERE p.location = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping_projects (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE marine_life_research_stations (id INT, name VARCHAR(255), region VARCHAR(255));
Which ocean floor mapping projects and marine life research stations are not located in the same regions?
SELECT o.name, m.name FROM ocean_floor_mapping_projects o LEFT JOIN marine_life_research_stations m ON o.region = m.region WHERE m.region IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, director VARCHAR(255), region VARCHAR(255)); INSERT INTO movies (id, title, release_year, director, region) VALUES (1, 'Roma', 2018, 'Alfonso Cuarón', 'Mexico'), (2, 'The Queen of Versailles', 2012, 'Lauren Greenfield', 'USA'), (3, 'Y Tu Mamá También', 2001, 'Alfonso Cuarón', 'Mexico'), (4, 'The Chambermaid', 2018, 'Lila Avilés', 'Mexico');
How many movies have been directed by women from Latin America in the last 10 years?
SELECT COUNT(*) FROM movies WHERE director IN ('Women from Latin America') AND release_year >= 2011;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'City 1'), (2, 'City 2'); CREATE TABLE community_centers (id INT, name VARCHAR(255), city_id INT);
Add a new community center in 'City 2' to the 'community_centers' table.
INSERT INTO community_centers (id, name, city_id) VALUES (1, 'Community Center 1', 2);
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArtForms (id INT, name VARCHAR(50)); CREATE TABLE ArtPieces (id INT, art_form_id INT, site_id INT); CREATE TABLE HeritageSites (id INT, name VARCHAR(50), site_id INT);
Which traditional art forms are not represented in any heritage sites?
SELECT TAF.name FROM TraditionalArtForms TAF LEFT JOIN ArtPieces AP ON TAF.id = AP.art_form_id LEFT JOIN HeritageSites HS ON AP.site_id = HS.id WHERE HS.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE org_funding_env (org_name TEXT, funding_amount INT, funding_year INT, sector TEXT); INSERT INTO org_funding_env (org_name, funding_amount, funding_year, sector) VALUES ('SocialTech6', 50000, 2020, 'environment'), ('SocialTech7', 70000, 2019, 'environment'), ('SocialTech8', 60000, 2018, 'environment'), ('SocialTech9', 80000, 2021, 'environment'), ('SocialTech10', 90000, 2017, 'environment');
Which social good technology organizations in the environmental sector have received the least funding in the past 3 years?
SELECT org_name, MIN(funding_amount) FROM org_funding_env WHERE sector = 'environment' AND funding_year BETWEEN 2018 AND 2020 GROUP BY org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE field13 (date DATE, temperature FLOAT); INSERT INTO field13 (date, temperature) VALUES ('2021-11-20', 12.2), ('2021-11-21', 13.1), ('2021-11-22', 14.3);
Calculate the average temperature for the last 3 days for 'field13'.
SELECT AVG(temperature) FROM field13 WHERE date >= (CURRENT_DATE - INTERVAL '3 days');
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, vulnerability_name VARCHAR(255), region VARCHAR(255), severity_score INT); INSERT INTO vulnerabilities (id, vulnerability_name, region, severity_score) VALUES (1, 'SQL Injection', 'Africa', 8), (2, 'Cross-Site Scripting', 'Europe', 6);
What is the minimum severity score of vulnerabilities in the 'Europe' region?
SELECT MIN(severity_score) FROM vulnerabilities WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE hospital_beds (hospital_id INT, name VARCHAR(50), location VARCHAR(20), num_of_beds INT); INSERT INTO hospital_beds (hospital_id, name, location, num_of_beds) VALUES (1, 'Rural Hospital A', 'New Mexico', 15); INSERT INTO hospital_beds (hospital_id, name, location, num_of_beds) VALUES (2, 'Rural Hospital B', 'New Mexico', 25); INSERT INTO hospital_beds (hospital_id, name, location, num_of_beds) VALUES (3, 'Urban Hospital A', 'California', 30);
What is the total number of hospital beds in rural areas of New Mexico, with less than 20 beds per hospital?
SELECT location, COUNT(*) FROM hospital_beds WHERE num_of_beds < 20 AND location = 'New Mexico' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE product_ingredients (product_id INT, ingredient_name TEXT, natural BOOLEAN); INSERT INTO product_ingredients (product_id, ingredient_name, natural) VALUES (1, 'Water', TRUE), (1, 'Mica', TRUE), (2, 'Water', TRUE), (2, 'Mica', TRUE), (2, 'Carmine', FALSE), (3, 'Water', TRUE), (3, 'Silica', TRUE), (3, 'Fragrance', FALSE), (4, 'Water', TRUE), (4, 'Shea Butter', TRUE), (5, 'Glycerin', TRUE), (5, 'Jojoba Oil', TRUE), (6, 'Water', TRUE), (6, 'Coconut Oil', TRUE), (6, 'Vitamin E', TRUE);
Which natural ingredients are used in more than one cosmetic product?
SELECT ingredient_name, natural, COUNT(*) as product_count FROM product_ingredients WHERE natural = TRUE GROUP BY ingredient_name HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Goals INT); INSERT INTO Players (PlayerID, PlayerName, Goals) VALUES (1, 'Gretzky', 894), (2, 'Lemieux', 690), (3, 'Howe', 786);
What are the top 5 players in the NHL based on career goals scored?
SELECT PlayerName, Goals FROM Players ORDER BY Goals DESC LIMIT 5
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_plant (plant_id INT, country_id INT, capacity FLOAT); INSERT INTO renewable_energy_plant VALUES (1, 1, 500), (2, 1, 700), (3, 2, 1200), (4, 3, 800);
What is the average renewable energy capacity per plant?
SELECT AVG(capacity) as avg_capacity FROM renewable_energy_plant;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (app_id INT, app_name TEXT, safety_rating REAL); INSERT INTO creative_ai VALUES (1, 'Dalle', 4.3, 'USA'), (2, 'GTP-3', 4.5, 'Canada'), (3, 'Midjourney', 4.7, 'Australia');
Find the second lowest safety rating in the creative_ai table.
SELECT safety_rating FROM (SELECT safety_rating, ROW_NUMBER() OVER (ORDER BY safety_rating) as row_num FROM creative_ai) subquery WHERE row_num = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE city_info (id INT, city VARCHAR(50), state VARCHAR(2), mayor_name VARCHAR(50));
Update the 'mayor_name' column in the 'city_info' table for the city 'Denver', CO to 'Janet Van Der Laan'
UPDATE city_info SET mayor_name = 'Janet Van Der Laan' WHERE city = 'Denver' AND state = 'CO';
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (Bridge_ID INT, Bridge_Name VARCHAR(255), Construction_Year INT, Location VARCHAR(255));
How many bridges were constructed each year in the Northeast region of the US since 2010?
SELECT Construction_Year, COUNT(*) FROM Bridges WHERE Location LIKE '%Northeast%' AND Construction_Year >= 2010 GROUP BY Construction_Year;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_name TEXT); INSERT INTO company (id, name, founding_year, founder_name) VALUES (1, 'Acme Inc', 2010, 'Jane Doe'); INSERT INTO company (id, name, founding_year, founder_name) VALUES (2, 'Brick Co', 2012, 'John Smith');
Show the sum of investment amounts for startups founded by 'Jane Doe'
SELECT SUM(investment_amount) FROM investment_rounds ir INNER JOIN company c ON ir.company_id = c.id WHERE c.founder_name = 'Jane Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), Country TEXT);
What is the minimum donation amount from India?
SELECT MIN(DonationAmount) FROM Donors WHERE Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_trenches (name TEXT, location TEXT, max_depth INTEGER);INSERT INTO marine_trenches (name, location, max_depth) VALUES ('Mariana Trench', 'Pacific Ocean', 10994);
What is the average depth of all marine trenches?
SELECT AVG(max_depth) FROM marine_trenches;
gretelai_synthetic_text_to_sql
CREATE TABLE disability_accommodations (student_id INT, disability_type VARCHAR(50), gender VARCHAR(50)); INSERT INTO disability_accommodations (student_id, disability_type, gender) VALUES (1, 'Physical', 'Female');
What is the number of students who received accommodations by disability type and gender?
SELECT disability_type, gender, COUNT(*) as total_students FROM disability_accommodations GROUP BY disability_type, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(50), Location VARCHAR(50), WasteGeneration INT); INSERT INTO MiningOperations (OperationID, MineName, Location, WasteGeneration) VALUES (1, 'Crystal Mine', 'Canada', 200), (2, 'Diamond Mine', 'Australia', 220), (3, 'Gold Mine', 'South Africa', 250);
What is the maximum waste generation for mining operations in South America?
SELECT MAX(WasteGeneration) FROM MiningOperations WHERE Location LIKE 'South%';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(100), mission_area VARCHAR(50), state VARCHAR(50)); CREATE TABLE volunteers (id INT, organization_id INT, hours DECIMAL(5, 2)); INSERT INTO organizations VALUES (1, 'Organization D', 'Social Services', NULL); INSERT INTO organizations VALUES (2, 'Organization E', 'Disaster Relief', NULL); INSERT INTO volunteers VALUES (1, 1, 20); INSERT INTO volunteers VALUES (2, 1, 15);
Display the average number of volunteers per organization, including those with no volunteers, for mission areas Social Services and Disaster Relief.
SELECT o.mission_area, AVG(v.id) as avg_volunteers FROM organizations o LEFT JOIN volunteers v ON o.id = v.organization_id WHERE o.mission_area IN ('Social Services', 'Disaster Relief') GROUP BY o.mission_area;
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Data (flight_date DATE, aircraft_model VARCHAR(255), flight_speed INTEGER); INSERT INTO Flight_Data (flight_date, aircraft_model, flight_speed) VALUES ('2020-01-01', 'Boeing 737', 450), ('2020-02-01', 'Boeing 737', 500), ('2020-03-01', 'Airbus A380', 550), ('2020-04-01', 'Boeing 747', 600), ('2020-05-01', 'Airbus A380', 400);
What is the minimum flight speed for Airbus A380 aircraft?
SELECT MIN(flight_speed) AS min_flight_speed FROM Flight_Data WHERE aircraft_model = 'Airbus A380';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id int, hours_served int, country varchar(50)); INSERT INTO volunteers (volunteer_id, hours_served, country) VALUES (1, 12, 'India'), (2, 5, 'India'), (3, 20, 'India');
What is the total number of volunteers in India who have completed more than 10 hours of service?
SELECT COUNT(volunteer_id) FROM volunteers WHERE country = 'India' GROUP BY volunteer_id HAVING hours_served > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance (visitor_id INT, exhibition_name VARCHAR(255), visit_date DATE); INSERT INTO attendance (visitor_id, exhibition_name, visit_date) VALUES (123, 'Expressionism', '2022-01-08'), (456, 'Expressionism', '2022-01-09'), (789, 'Cubism', '2022-01-08'), (111, 'Cubism', '2022-01-09'), (222, 'Futurism', '2022-01-08'), (333, 'Futurism', '2022-01-09');
Which exhibition had the lowest number of visitors on a weekend?
SELECT exhibition_name, MIN(visit_date) AS min_weekend_visit FROM attendance WHERE EXTRACT(DAY FROM visit_date) BETWEEN 6 AND 7 GROUP BY exhibition_name;
gretelai_synthetic_text_to_sql
CREATE TABLE podcasts (id INT, name VARCHAR(255), country VARCHAR(255), duration INT); INSERT INTO podcasts (id, name, country, duration) VALUES (1, 'Podcast1', 'USA', 100), (2, 'Podcast2', 'UK', 200);
List all countries with their respective number of podcasts and the total duration of those podcasts.
SELECT country, COUNT(*) as num_podcasts, SUM(duration) as total_duration FROM podcasts GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Applications (Id INT, ApplicationDate DATE); INSERT INTO Applications (Id, ApplicationDate) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-03-05'), (4, '2022-04-20');
What is the number of union membership applications submitted per month in 2022?
SELECT MONTH(ApplicationDate) as Month, COUNT(*) as TotalApplications FROM Applications WHERE YEAR(ApplicationDate) = 2022 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (year INT, region VARCHAR(255), volume FLOAT);INSERT INTO ocean_acidification (year, region, volume) VALUES (2011, 'Southern Ocean', 2500), (2012, 'Southern Ocean', 2600), (2013, 'Southern Ocean', 2800), (2014, 'Southern Ocean', 3000), (2015, 'Southern Ocean', 3200), (2016, 'Southern Ocean', 3500), (2017, 'Southern Ocean', 3700), (2018, 'Southern Ocean', 4000), (2019, 'Southern Ocean', 4200), (2020, 'Southern Ocean', 4500);
What is the maximum volume of ocean acidification in the Southern Ocean over the last 10 years?
SELECT MAX(volume) FROM ocean_acidification WHERE region = 'Southern Ocean' AND year BETWEEN 2011 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE billing (attorney_id INT, client_id INT, hours_billed INT, billing_rate DECIMAL(5,2));
Find the average billing rate for attorneys in 'billing' table, excluding attorneys with less than 10 hours billed
SELECT AVG(billing_rate) FROM billing WHERE hours_billed >= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, faculty_id INT, title VARCHAR(100), amount DECIMAL(10, 2)); INSERT INTO grants (id, faculty_id, title, amount) VALUES (1, 1, 'Research Grant 1', 100000), (2, 2, 'Research Grant 2', 120000), (3, 3, 'Research Grant 3', 150000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO faculty (id, name, department) VALUES (1, 'Fiona', 'Engineering'), (2, 'Gabriel', 'Computer Science'), (3, 'Heidi', 'Humanities');
What is the maximum research grant amount awarded to faculty members in the Engineering department?
SELECT MAX(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE sydney_usage (user_id INT, last_used DATE); CREATE TABLE cape_town_usage (user_id INT, last_used DATE); INSERT INTO sydney_usage (user_id, last_used) VALUES (1, '2022-01-15'), (2, '2022-02-10'), (3, '2022-03-01'), (4, '2022-01-20'); INSERT INTO cape_town_usage (user_id, last_used) VALUES (5, '2022-02-25'), (6, '2022-03-15'), (7, '2022-01-05'), (8, '2022-02-20');
Show the number of users in Sydney and Cape Town who used public transportation at least once in the last month.
SELECT COUNT(*) FROM sydney_usage WHERE last_used >= DATEADD(month, -1, GETDATE()) UNION ALL SELECT COUNT(*) FROM cape_town_usage WHERE last_used >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE runners (id INT, name TEXT, distance FLOAT, marathon INT); INSERT INTO runners (id, name, distance, marathon) VALUES (1, 'John Doe', 42.2, 2019), (2, 'Jane Smith', 40.5, 2019), (3, 'Alberto Rodriguez', 38.7, 2019);
What is the total distance covered by all runners in the 2019 marathon?
SELECT SUM(distance) FROM runners WHERE marathon = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_farms (id INT, name TEXT, country TEXT, stocking_density FLOAT); INSERT INTO salmon_farms (id, name, country, stocking_density) VALUES (1, 'Farm A', 'Norway', 25.3); INSERT INTO salmon_farms (id, name, country, stocking_density) VALUES (2, 'Farm B', 'Norway', 23.1);
What is the average stocking density of salmon farms in Norway?
SELECT AVG(stocking_density) FROM salmon_farms WHERE country = 'Norway';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (species VARCHAR(50), habitat_type VARCHAR(50), animal_count INT);
Calculate the total number of animals in each habitat type.
SELECT habitat_type, SUM(animal_count) FROM habitat GROUP BY habitat_type;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategies (company_id INT, exit_type TEXT, exit_year INT); INSERT INTO exit_strategies (company_id, exit_type, exit_year) VALUES (1, 'Acquisition', 2020); INSERT INTO exit_strategies (company_id, exit_type, exit_year) VALUES (2, NULL, NULL); CREATE TABLE industry (company_id INT, industry TEXT); INSERT INTO industry (company_id, industry) VALUES (1, 'Fintech'); INSERT INTO industry (company_id, industry) VALUES (2, 'Retail');
List all companies that have not yet had an exit event and are in the Fintech industry
SELECT name FROM company WHERE id NOT IN (SELECT company_id FROM exit_strategies WHERE exit_type IS NOT NULL) AND id IN (SELECT company_id FROM industry WHERE industry = 'Fintech');
gretelai_synthetic_text_to_sql
CREATE TABLE Project (id INT, name VARCHAR(20), start_date DATE, end_date DATE); CREATE TABLE Sustainability_Standard (project_id INT, standard VARCHAR(20));
List all sustainable projects with their start and end dates
SELECT Project.name, Project.start_date, Project.end_date FROM Project INNER JOIN Sustainability_Standard ON Project.id = Sustainability_Standard.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue (restaurant_id INT, cuisine_type VARCHAR(255), revenue DECIMAL(10,2), transaction_date DATE); INSERT INTO restaurant_revenue (restaurant_id, cuisine_type, revenue, transaction_date) VALUES (1, 'Indian', 6000, '2022-02-01'), (2, 'Japanese', 8000, '2022-02-02');
What was the total revenue for each cuisine type in February 2022?
SELECT cuisine_type, SUM(revenue) as total_revenue FROM restaurant_revenue WHERE transaction_date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY cuisine_type;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists violations (id INT PRIMARY KEY, sector VARCHAR(255), violation_date DATE, num_violations INT); INSERT INTO violations (id, sector, violation_date, num_violations) VALUES (1, 'construction', '2022-01-01', 5), (2, 'construction', '2022-04-01', 10), (3, 'mining', '2022-07-01', 7);
What is the maximum number of workplace safety violations for any sector in the last year?
SELECT MAX(num_violations) FROM violations WHERE violation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(50), industry VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, industry, funding) VALUES (1, 'StartupA', 'TX', 'Biotech', 2000000.0); INSERT INTO startups (id, name, location, industry, funding) VALUES (2, 'StartupB', 'TX', 'Biotech', 3000000.0); INSERT INTO startups (id, name, location, industry, funding) VALUES (3, 'StartupC', 'NY', 'Biotech', 4000000.0);
What is the maximum funding amount for biotech startups in Texas?
SELECT MAX(funding) FROM startups WHERE location = 'TX' AND industry = 'Biotech';
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchStudy (id INT, title VARCHAR(100), year INT, location VARCHAR(50), type VARCHAR(50));
How many autonomous driving research studies were conducted in Japan in the year 2020?
SELECT COUNT(*) FROM ResearchStudy WHERE year = 2020 AND location = 'Japan' AND type = 'Autonomous Driving';
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimeline (ProjectID INT, State TEXT, Timeline INT); INSERT INTO ProjectTimeline (ProjectID, State, Timeline) VALUES (101, 'WA', 60), (102, 'OR', 50), (103, 'WA', 70), (104, 'OR', 55);
What is the average project timeline for sustainable building projects in the state of Washington?
SELECT AVG(Timeline) FROM ProjectTimeline WHERE State = 'WA' AND ProjectID IN (SELECT ProjectID FROM SustainableProjects);
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT PRIMARY KEY, location VARCHAR(255), waste_type VARCHAR(255), quantity INT, date DATE);
Delete records in waste_generation table where waste type is 'Plastic Bags'
DELETE FROM waste_generation WHERE waste_type = 'Plastic Bags';
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', 18.5), (5, 'soybean', 19.5);
Find the minimum temperature for each crop type
SELECT type, MIN(temperature) FROM crop GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE SouthAfricanHealthcare (Province VARCHAR(20), Location VARCHAR(50), ProviderType VARCHAR(30), NumberOfProviders INT); INSERT INTO SouthAfricanHealthcare (Province, Location, ProviderType, NumberOfProviders) VALUES ('Province A', 'Rural Area A', 'Doctor', 15), ('Province A', 'Rural Area B', 'Nurse', 20), ('Province A', 'Rural Area C', 'Physiotherapist', 12), ('Province B', 'Rural Area D', 'Physiotherapist', 10);
What is the average number of physiotherapists in rural areas in South Africa?
SELECT AVG(NumberOfProviders) FROM SouthAfricanHealthcare WHERE Province IN ('Province A', 'Province B') AND Location LIKE '%Rural Area%' AND ProviderType = 'Physiotherapist';
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (ProjectID INT, ProjectName VARCHAR(100), StartDate DATE, EndDate DATE);
Identify the defense projects with timelines that overlap with at least one other project.
SELECT A.ProjectID, A.ProjectName FROM DefenseProjects A JOIN DefenseProjects B ON A.ProjectID <> B.ProjectID AND A.StartDate <= B.EndDate AND B.StartDate <= A.EndDate;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name VARCHAR(50), location VARCHAR(50), size FLOAT);
Add a new 'habitat' record into the 'habitats' table
INSERT INTO habitats (id, name, location, size) VALUES (1, 'Forest', 'Amazon', 50000.0);
gretelai_synthetic_text_to_sql
CREATE TABLE natural_disasters_2018 (id INT, disaster_date DATE, response_time INT); INSERT INTO natural_disasters_2018 (id, disaster_date, response_time) VALUES (1, '2018-01-01', 12), (2, '2018-04-01', 15), (3, '2018-07-01', 18), (4, '2018-10-01', 20);
Find the average response time for natural disasters in each quarter of 2018
SELECT EXTRACT(QUARTER FROM disaster_date) as quarter, AVG(response_time) as avg_response_time FROM natural_disasters_2018 GROUP BY EXTRACT(QUARTER FROM disaster_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT, dish_name VARCHAR(255), dish_type VARCHAR(255), popularity INT); INSERT INTO Menu (id, dish_name, dish_type, popularity) VALUES (1, 'Tofu Stir Fry', 'Vegan', 150), (2, 'Black Bean Burger', 'Vegan', 200), (3, 'Chickpea Curry', 'Vegan', 250);
How many times has the most popular vegan dish been ordered?
SELECT MAX(popularity) FROM Menu WHERE dish_type = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE artist_museums (artist_id INT, museum_name TEXT); INSERT INTO artist_museums (artist_id, museum_name) VALUES (1, 'MoMA'), (2, 'Met'), (3, 'Tate'), (4, 'MoMA'), (5, 'Tate'); CREATE TABLE artworks (id INT, artist_id INT, title TEXT, museum_id INT); INSERT INTO artworks (id, artist_id, title, museum_id) VALUES (1, 1, 'Dora Maar au Chat', 1), (2, 2, 'Red Painting', NULL), (3, 3, 'Untitled', 3), (4, 4, 'The Persistence of Memory', 1), (5, 5, 'Composition with Red Blue and Yellow', NULL); CREATE TABLE museums (id INT, name TEXT); INSERT INTO museums (id, name) VALUES (1, 'MoMA'), (2, 'Met'), (3, 'Tate'); CREATE TABLE museum_artworks (museum_id INT, artwork_id INT); INSERT INTO museum_artworks (museum_id, artwork_id) VALUES (1, 1), (1, 4), (3, 3);
What is the minimum number of artworks created by artists who have works in the 'MoMA' museum?
SELECT MIN(artworks.id) FROM artworks JOIN artist_museums ON artworks.artist_id = artist_museums.artist_id JOIN museum_artworks ON artworks.id = museum_artworks.artwork_id WHERE museums.name = 'MoMA';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (volunteer_id INT, project_id INT, hours INT, volunteer_date DATE);
Determine the number of volunteers who participated in 'Environment' projects in H1 2022, broken down by month.
SELECT DATE_FORMAT(vp.volunteer_date, '%Y-%m') as month, COUNT(DISTINCT v.volunteer_id) as total_volunteers FROM volunteer_projects vp JOIN volunteer_hours vh ON vp.project_id = vh.project_id WHERE vp.cause = 'Environment' AND vp.year = 2022 AND vh.volunteer_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (operation_id INT, operation_type VARCHAR(20), impact_score INT, year INT); INSERT INTO environmental_impact (operation_id, operation_type, impact_score, year) VALUES (1, 'mining', 50, 2020), (2, 'processing', 80, 2020), (3, 'mining', 60, 2019), (4, 'processing', 90, 2019);
What is the combined environmental impact of our mining and processing operations in 2020?
SELECT impact_score FROM environmental_impact WHERE operation_type IN ('mining', 'processing') AND year = 2020
gretelai_synthetic_text_to_sql
CREATE TABLE Schools (id INT, name TEXT, country TEXT, build_date DATE); INSERT INTO Schools (id, name, country, build_date) VALUES (1, 'Primary School A', 'France', '2016-01-01'); INSERT INTO Schools (id, name, country, build_date) VALUES (2, 'Secondary School B', 'Germany', '2018-01-01');
Identify the number of schools built in each country in Europe between 2010 and 2020, inclusive.
SELECT country, COUNT(*) FROM Schools WHERE build_date BETWEEN '2010-01-01' AND '2020-12-31' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, city VARCHAR(20), collections INT); INSERT INTO artists (id, city, collections) VALUES (1, 'London', 2), (2, 'London', 3), (3, 'New York', 1), (4, 'London', 4), (5, 'London', 1);
Which artists in 'London' have more than 2 collections?
SELECT city, collections FROM artists WHERE city = 'London' AND collections > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Flights (flight_id INT, airline VARCHAR(255), region VARCHAR(255), safety_score INT);
What is the average flight safety score for flights operated by SkyHigh Airlines in Europe?
SELECT AVG(safety_score) FROM Flights WHERE airline = 'SkyHigh Airlines' AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation DECIMAL(10, 2), donation_date DATE);
What is the average donation amount for donors who donated more than $1000 in 2021?
SELECT AVG(donation) FROM donations WHERE donation > 1000 AND YEAR(donation_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(50), type VARCHAR(50), average_speed DECIMAL(5,2)); CREATE TABLE Cargo (vessel_id INT, cargo_type VARCHAR(50), transport_date DATE); INSERT INTO Vessels (id, name, type, average_speed) VALUES (1, 'Vessel1', 'OilTanker', 15.5), (2, 'Vessel2', 'BulkCarrier', 12.3), (3, 'Vessel3', 'BulkCarrier', 11.2); INSERT INTO Cargo (vessel_id, cargo_type, transport_date) VALUES (1, 'Oil', '2022-01-01'), (1, 'Oil', '2022-04-01'), (2, 'Coal', '2022-01-15'), (3, 'Coal', '2022-02-01');
What is the minimum speed for vessels that have transported coal?
SELECT MIN(Vessels.average_speed) FROM Vessels INNER JOIN Cargo ON Vessels.id = Cargo.vessel_id WHERE Cargo.cargo_type = 'Coal';
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_training (teacher_id INT, subject_area VARCHAR(50), completed BOOLEAN, teaching_experience INT); INSERT INTO teacher_training (teacher_id, subject_area, completed, teaching_experience) VALUES (1, 'Mathematics', TRUE, 10), (2, 'Mathematics', FALSE, 2), (3, 'Science', TRUE, 8), (4, 'Science', TRUE, 6), (5, 'English', FALSE, 3);
What is the total number of teachers who have completed professional development courses in each subject area and have more than 5 years of teaching experience?
SELECT subject_area, SUM(completed) as num_teachers FROM teacher_training WHERE teaching_experience > 5 GROUP BY subject_area;
gretelai_synthetic_text_to_sql