context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE clothing_items (id INT PRIMARY KEY, name VARCHAR(50), category VARCHAR(20), available_sizes TEXT); CREATE TABLE inventory (id INT PRIMARY KEY, clothing_item_id INT, size VARCHAR(10), quantity INT);
Delete records of sizes that are not available in the inventory.
DELETE FROM clothing_items WHERE available_sizes NOT LIKE CONCAT('%', (SELECT GROUP_CONCAT(DISTINCT size) FROM inventory WHERE clothing_item_id = clothing_items.id), '%');
gretelai_synthetic_text_to_sql
CREATE TABLE farms (id INT, name TEXT, state TEXT); INSERT INTO farms (id, name, state) VALUES (1, 'Farm A', 'Colorado'), (2, 'Farm B', 'California'), (3, 'Farm C', 'Colorado'); CREATE TABLE strains (id INT, farm_id INT, name TEXT, thc_percentage DECIMAL(5,2), cbd_percentage DECIMAL(5,2)); INSERT INTO strains (id, farm_id, name, thc_percentage, cbd_percentage) VALUES (1, 1, 'Strain 1', 15.5, 0.5), (2, 1, 'Strain 2', 20.0, 0.8), (3, 2, 'Strain 3', 12.0, 1.2), (4, 3, 'Strain 4', 24.5, 0.0), (5, 3, 'Strain 5', 18.0, 0.5);
What are the average THC and CBD percentages for strains grown in Colorado, grouped by the farm they come from?
SELECT f.name AS farm_name, AVG(s.thc_percentage) AS avg_thc, AVG(s.cbd_percentage) AS avg_cbd FROM strains s JOIN farms f ON s.farm_id = f.id WHERE f.state = 'Colorado' GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_transactions (transaction_date DATE, customer_id INT, transaction_amt DECIMAL(10, 2)); INSERT INTO customer_transactions (transaction_date, customer_id, transaction_amt) VALUES ('2022-01-01', 1, 200.00), ('2022-01-02', 2, 300.50), ('2022-01-03', 3, 150.25);
Find the transaction date with the maximum transaction amount for each customer.
SELECT transaction_date, customer_id, transaction_amt, RANK() OVER (PARTITION BY customer_id ORDER BY transaction_amt DESC) AS rank FROM customer_transactions;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(100), department VARCHAR(50), publications INT); INSERT INTO graduate_students (id, name, department, publications) VALUES (1, 'Heidi', 'Sociology', 3), (2, 'Anthropology', 4); CREATE VIEW social_sciences_departments AS SELECT DISTINCT department FROM graduate_students WHERE department LIKE 'Social%';
How many graduate students in the College of Social Sciences have published more than 2 papers?
SELECT COUNT(*) FROM graduate_students WHERE department IN (SELECT department FROM social_sciences_departments) AND publications > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Chemicals (Id INT, Name VARCHAR(255), Toxicity INT, Manufacturing_Country VARCHAR(255)); CREATE TABLE Safety_Protocols (Id INT, Chemical_Id INT, Safety_Measure VARCHAR(255)); INSERT INTO Chemicals (Id, Name, Toxicity, Manufacturing_Country) VALUES (1, 'Sodium Cyanide', 10, 'Japan'); INSERT INTO Safety_Protocols (Id, Chemical_Id, Safety_Measure) VALUES (1, 1, 'Fume Hood');
Which safety measures are used in Japan for storing toxic chemicals?
SELECT Chemicals.Name, Safety_Protocols.Safety_Measure FROM Chemicals INNER JOIN Safety_Protocols ON Chemicals.Id = Safety_Protocols.Chemical_Id WHERE Chemicals.Manufacturing_Country = 'Japan' AND Chemicals.Toxicity > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE AgriculturalInnovations (id INT, country VARCHAR(50), project VARCHAR(50), start_date DATE); INSERT INTO AgriculturalInnovations (id, country, project, start_date) VALUES (1, 'Uganda', 'AgriTech App Development', '2019-03-01'), (2, 'Uganda', 'Modern Irrigation Systems', '2018-08-15'), (3, 'Kenya', 'Solar Powered Pumps', '2020-06-05');
List the agricultural innovation projects in Uganda that started in 2019 or later.
SELECT project FROM AgriculturalInnovations WHERE country = 'Uganda' AND start_date >= '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation_spending (spending_id INT, country VARCHAR(50), year INT, spending INT); INSERT INTO military_innovation_spending (spending_id, country, year, spending) VALUES (1, 'United States', 2018, 500000), (2, 'China', 2019, 300000), (3, 'Russia', 2020, 200000), (4, 'United States', 2017, 600000), (5, 'India', 2016, 400000);
What is the total spending on military innovation by country and year?
SELECT mi.country, YEAR(mi.year), SUM(mi.spending) as total_spending FROM military_innovation_spending mi GROUP BY mi.country, YEAR(mi.year);
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, product TEXT, quantity INT, country TEXT); INSERT INTO imports (id, product, quantity, country) VALUES (1, 'Tofu', 1000, 'China'), (2, 'Lentils', 2000, 'Canada');
What is the total weight of imported plant-based protein?
SELECT SUM(quantity) FROM imports WHERE product LIKE '%plant-based%' AND country NOT IN ('United States', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (product_id INT, product_name TEXT, product_type TEXT, contains_sulfates BOOLEAN); INSERT INTO inventory (product_id, product_name, product_type, contains_sulfates) VALUES (1, 'Product 1', 'Hair Care', true), (2, 'Product 2', 'Hair Care', false), (3, 'Product 3', 'Skin Care', false), (4, 'Product 4', 'Hair Care', true), (5, 'Product 5', 'Makeup', false);
Determine the percentage of hair care products that contain sulfates, based on the current inventory.
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM inventory WHERE product_type = 'Hair Care') AS pct_sulfates FROM inventory WHERE product_type = 'Hair Care' AND contains_sulfates = true;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name VARCHAR(255), sector VARCHAR(255), founding_date DATE, funding FLOAT, founder_gender VARCHAR(50)); INSERT INTO startup (id, name, sector, founding_date, funding, founder_gender) VALUES (1, 'Echo Inc', 'Technology', '2010-01-01', 3000000.0, 'Male'); INSERT INTO startup (id, name, sector, founding_date, funding, founder_gender) VALUES (2, 'Foxtrot LLC', 'Healthcare', '2012-05-15', 7000000.0, 'Female'); INSERT INTO startup (id, name, sector, founding_date, funding, founder_gender) VALUES (3, 'Golf Alpha Bravo', 'Technology', '2015-09-09', 10000000.0, 'Male'); INSERT INTO startup (id, name, sector, founding_date, funding, founder_gender) VALUES (4, 'Hotel India', 'Retail', '2018-01-01', 5000000.0, 'Male'); INSERT INTO startup (id, name, sector, founding_date, funding, founder_gender) VALUES (5, 'Kilo Lima', 'Renewable Energy', '2020-06-19', 12000000.0, 'Female');
What is the average funding received by startups founded by women in the renewable energy sector?
SELECT AVG(funding) FROM startup WHERE sector = 'Renewable Energy' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (year INT, sector TEXT, consumption FLOAT); INSERT INTO water_consumption (year, sector, consumption) VALUES (2015, 'residential', 123.5), (2015, 'commercial', 234.6), (2016, 'residential', 130.2), (2016, 'commercial', 240.1), (2020, 'residential', 150.8), (2020, 'commercial', 255.9), (2021, 'residential', 160.5), (2021, 'commercial', 265.1);
What is the total water consumption by residential sector in 2020 and 2021?
SELECT consumption FROM water_consumption WHERE sector = 'residential' AND (year = 2020 OR year = 2021)
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT, equitable BOOLEAN); INSERT INTO dispensaries (id, name, state, equitable) VALUES (1, 'Dispensary X', 'Washington', true), (2, 'Dispensary Y', 'Washington', false); CREATE TABLE strains (id INT, name TEXT, dispensary_id INT); INSERT INTO strains (id, name, dispensary_id) VALUES (1, 'Strain A', 1), (2, 'Strain B', 2), (3, 'Strain C', 1);
Which socially equitable dispensaries in WA have a specific strain?
SELECT d.name FROM dispensaries d JOIN strains s ON d.id = s.dispensary_id WHERE d.state = 'Washington' AND d.equitable = true AND s.name = 'Strain A';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Department) VALUES (1, 'Marketing'), (2, 'Marketing'), (3, 'IT'), (4, 'HR'); CREATE TABLE Departments (Department VARCHAR(20), Manager VARCHAR(20)); INSERT INTO Departments (Department, Manager) VALUES ('Marketing', 'John'), ('IT', 'Jane'), ('HR', 'Sara');
What is the number of employees in each department?
SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Gender VARCHAR(10), Age INT, Country VARCHAR(50), PreferredGenre VARCHAR(20)); INSERT INTO Players (PlayerID, Gender, Age, Country, PreferredGenre) VALUES (6, 'Male', 19, 'Nigeria', 'Racing'); INSERT INTO Players (PlayerID, Gender, Age, Country, PreferredGenre) VALUES (7, 'Female', 22, 'South Africa', 'Racing');
Update the Players table to set the country to 'Africa' for players who are 18 or older and prefer racing games.
UPDATE Players SET Country = 'Africa' WHERE Age >= 18 AND PreferredGenre = 'Racing';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO Exhibitions VALUES (1, 'Exhibition A', '2022-01-01', '2022-03-31'), (2, 'Exhibition B', '2022-02-01', '2022-04-30'), (3, 'Exhibition C', '2022-03-01', '2022-05-31'); CREATE TABLE Visitors (id INT, exhibition_id INT, visit_date DATE); INSERT INTO Visitors VALUES (1, 1, '2022-01-02'), (2, 1, '2022-01-03'), (3, 2, '2022-02-05'), (4, 3, '2022-03-07'), (5, 3, '2022-03-08');
What is the average number of visitors per day for each exhibition?
SELECT Exhibitions.name, AVG(DATEDIFF(Visitors.visit_date, Exhibitions.start_date) + 1) AS avg_visitors_per_day FROM Exhibitions INNER JOIN Visitors ON Exhibitions.id = Visitors.exhibition_id GROUP BY Exhibitions.name;
gretelai_synthetic_text_to_sql
CREATE TABLE South_Atlantic_Trenches (trench_name TEXT, location TEXT, max_depth FLOAT); INSERT INTO South_Atlantic_Trenches (trench_name, location, max_depth) VALUES ('South Sandwich Trench', 'South Atlantic Ocean', 8428.0);
What is the maximum depth of the South Sandwich Trench in the South Atlantic Ocean?
SELECT max_depth FROM South_Atlantic_Trenches WHERE trench_name = 'South Sandwich Trench';
gretelai_synthetic_text_to_sql
CREATE TABLE community_initiatives_2 (id INT, name VARCHAR(255), completion_date DATE); INSERT INTO community_initiatives_2 (id, name, completion_date) VALUES (1, 'Youth Skills Training', '2021-03-01'), (2, 'Women Empowerment Program', '2020-05-15'), (3, 'Elderly Care Center', '2019-12-20');
What are the names and completion dates of community development initiatives in 'RuralDev' database that have been completed in the last year?
SELECT name, completion_date FROM community_initiatives_2 WHERE completion_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE StudentMentalHealth (id INT, name TEXT, mental_health_score INT); INSERT INTO StudentMentalHealth (id, name, mental_health_score) VALUES (1, 'Jessica', 75), (2, 'Lucas', 85), (3, 'Oliver', 95);
How many students in 'StudentMentalHealth' table have a mental health score greater than 80?
SELECT COUNT(*) FROM StudentMentalHealth WHERE mental_health_score > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE Freights (id INT PRIMARY KEY, warehouse_id INT, status VARCHAR(255), quantity INT, pickup_date DATETIME); CREATE VIEW PendingFreights AS SELECT * FROM Freights WHERE status = 'pending';
What is the earliest pickup date for pending freights in 'CA' warehouses?
SELECT MIN(pickup_date) as earliest_pickup_date FROM PendingFreights p INNER JOIN Warehouses w ON p.warehouse_id = w.id WHERE w.location = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE public.yearly_trips_by_vehicle (id SERIAL PRIMARY KEY, vehicle_type TEXT, city TEXT, year_start DATE, year_trips INTEGER); INSERT INTO public.yearly_trips_by_vehicle (vehicle_type, city, year_start, year_trips) VALUES ('electric_bus', 'Bangkok', '2021-01-01', 1200000), ('electric_bus', 'Bangkok', '2021-07-01', 1500000);
What is the total number of trips made by electric buses in Bangkok over the past year?
SELECT SUM(year_trips) FROM public.yearly_trips_by_vehicle WHERE vehicle_type = 'electric_bus' AND city = 'Bangkok' AND year_start BETWEEN DATE_TRUNC('year', CURRENT_DATE - INTERVAL '1 year') AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(255)); INSERT INTO factories VALUES (1, 'Assembly'), (1, 'Quality Control'), (2, 'Design'), (2, 'Testing'); CREATE TABLE workers (worker_id INT, factory_id INT, department VARCHAR(255), role VARCHAR(255), salary INT); INSERT INTO workers VALUES (1, 1, 'Assembly', 'Engineer', 50000), (2, 1, 'Assembly', 'Technician', 40000), (3, 1, 'Quality Control', 'Inspector', 45000), (4, 2, 'Design', 'Architect', 60000), (5, 2, 'Testing', 'Tester', 55000);
What is the minimum salary of workers in the 'Design' department for each factory?
SELECT f.factory_id, MIN(w.salary) as min_salary FROM factories f JOIN workers w ON f.factory_id = w.factory_id WHERE f.department = 'Design' GROUP BY f.factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE game_sales (game_id INT, genre VARCHAR(255), sales FLOAT); INSERT INTO game_sales (game_id, genre, sales) VALUES (1, 'RPG', 5000000), (2, 'FPS', 7000000), (3, 'Simulation', 4000000);
What are the total sales and average sales per game for each genre?
SELECT genre, SUM(sales) as total_sales, AVG(sales) as avg_sales_per_game FROM game_sales GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, Gallery VARCHAR(100), ArtworkID INT, Country VARCHAR(50), Year INT);
What are the galleries with the most modern art exhibitions?
SELECT Exhibitions.Gallery, COUNT(DISTINCT Exhibitions.ExhibitionID) AS ExhibitionCount FROM Exhibitions INNER JOIN Artworks ON Exhibitions.ArtworkID = Artworks.ArtworkID WHERE Artworks.Year >= 1900 GROUP BY Exhibitions.Gallery;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, name TEXT, speed DECIMAL(5,2), arrived_date DATE, country TEXT, cargo_weight INT); INSERT INTO vessel_performance (id, name, speed, arrived_date, country, cargo_weight) VALUES (1, 'Vessel J', 15.5, '2022-04-04', 'Singapore', 8000), (2, 'Vessel K', 17.2, '2022-04-17', 'Singapore', 8500), (3, 'Vessel L', 13.6, '2022-04-28', 'Singapore', 9000);
What is the maximum cargo weight for vessels arriving in Singapore in April 2022?
SELECT MAX(cargo_weight) FROM vessel_performance WHERE YEAR(arrived_date) = 2022 AND MONTH(arrived_date) = 4 AND country = 'Singapore';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, region TEXT, project_type TEXT, start_date DATE, end_date DATE);
List the number of community development projects in 'rural_development' database, grouped by region and project type.
SELECT region, project_type, COUNT(*) FROM projects GROUP BY region, project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (id INT, policyholder_id INT, claim_amount DECIMAL(10,2)); INSERT INTO claims (id, policyholder_id, claim_amount) VALUES (1, 1, 1500.00), (2, 2, 3000.00), (3, 3, 500.00), (4, 4, 4500.00), (5, 1, 2000.00);
What is the total claim amount for each policyholder?
SELECT policyholder_id, SUM(claim_amount) as total_claim_amount FROM claims GROUP BY policyholder_id;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness (id INT, year INT, disasterType VARCHAR(30), score INT);
List all disaster types and their respective average preparedness scores, for the last 2 years, from 'DisasterPreparedness' table.
SELECT disasterType, AVG(score) FROM DisasterPreparedness WHERE year BETWEEN (YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE) GROUP BY disasterType;
gretelai_synthetic_text_to_sql
CREATE TABLE Continent (name VARCHAR(50), hospital_beds INT); INSERT INTO Continent (name, hospital_beds) VALUES ('China', 3000000), ('India', 1600000);
How many hospital beds are there in Asia?
SELECT SUM(hospital_beds) FROM Continent WHERE name IN ('China', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipment (Id INT, EquipmentName VARCHAR(50), MaintenanceCost DECIMAL(10,2), Region VARCHAR(50)); INSERT INTO MilitaryEquipment (Id, EquipmentName, MaintenanceCost, Region) VALUES (1, 'Tank', 5000, 'Pacific'), (2, 'Helicopter', 8000, 'Europe');
What is the average maintenance cost for military equipment in the Pacific region?
SELECT AVG(MaintenanceCost) FROM MilitaryEquipment WHERE Region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Citizens (citizen_id INT, name VARCHAR(50), age INT, city VARCHAR(50));
Delete records of citizens who are over 65 in the 'Citizens' table
DELETE FROM Citizens WHERE age > 65;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_services (service_id INT, subscribers INT, region VARCHAR(20)); CREATE TABLE mobile_services (service_id INT, subscribers INT, region VARCHAR(20));
Which broadband services have a higher number of subscribers compared to mobile services in the same region?
SELECT b.region, b.service_id, b.subscribers FROM broadband_services b LEFT JOIN mobile_services m ON b.region = m.region WHERE b.subscribers > COALESCE(m.subscribers, 0);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (id INT, name VARCHAR(50), beds INT, location VARCHAR(50));
Add a new record to the 'rural_hospitals' table
INSERT INTO rural_hospitals (id, name, beds, location) VALUES (1, 'Eureka Community Hospital', 50, 'Eureka');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (id INT, country VARCHAR(50), continent VARCHAR(50), visitors INT, sustainability_score INT); INSERT INTO tourism_stats (id, country, continent, visitors, sustainability_score) VALUES (1, 'Australia', 'Oceania', 20000000, 85); INSERT INTO tourism_stats (id, country, continent, visitors, sustainability_score) VALUES (2, 'New Zealand', 'Oceania', 4000000, 90);
Find the average sustainability score for Oceania.
SELECT AVG(sustainability_score) FROM tourism_stats WHERE continent = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), publication_date DATE, word_count INT);
What is the average length of news articles published in each quarter of 2021?
SELECT EXTRACT(QUARTER FROM publication_date) AS quarter, AVG(word_count) AS avg_word_count FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2021 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name VARCHAR(50), donation_date DATE, amount INT, country VARCHAR(50)); INSERT INTO Donors (id, name, donation_date, amount, country) VALUES (1, 'Alice', '2021-01-01', 500, 'USA'), (2, 'Bob', '2021-02-01', 1000, 'Nigeria');
What is the total donation amount for each donor in Nigeria?
SELECT name, SUM(amount) as total_donation FROM Donors WHERE country = 'Nigeria' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (MemberID INT, MembershipType VARCHAR(20), WorkoutType VARCHAR(20), CaloriesBurned INT); INSERT INTO Workouts (MemberID, MembershipType, WorkoutType, CaloriesBurned) VALUES (1, 'Premium', 'Cardio', 300), (2, 'Basic', 'Strength', 250), (3, 'Premium', 'Strength', 350);
What is the maximum calorie burn during 'Strength' workouts for members with 'Premium' membership types?
SELECT MAX(CaloriesBurned) FROM Workouts WHERE MembershipType = 'Premium' AND WorkoutType = 'Strength';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, StartTime DATETIME); INSERT INTO Events (EventID, StartTime) VALUES (1, '2022-06-02 15:00:00'), (2, '2022-05-31 18:00:00'); CREATE TABLE Users (UserID INT, EventID INT); INSERT INTO Users (UserID, EventID) VALUES (1, 1), (2, 2);
What is the total number of users registered for events with a start time after 2022-06-01?
SELECT COUNT(DISTINCT Users.UserID) AS TotalUsersRegistered FROM Users INNER JOIN Events ON Users.EventID = Events.EventID WHERE Events.StartTime > '2022-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE movie_revenue (id INT, title VARCHAR(50), country VARCHAR(50), revenue DECIMAL(10,2)); CREATE TABLE tv_revenue (id INT, show VARCHAR(50), country VARCHAR(50), revenue DECIMAL(10,2));
What's the total revenue of movies and TV shows in a specific country?
SELECT SUM(movie_revenue.revenue + tv_revenue.revenue) FROM movie_revenue INNER JOIN tv_revenue ON movie_revenue.country = tv_revenue.country WHERE movie_revenue.country = 'CountryName';
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_investments (country TEXT, year INT, innovation_investment NUMERIC); INSERT INTO agricultural_investments (country, year, innovation_investment) VALUES ('India', 2017, 1000000), ('India', 2018, 1200000), ('India', 2019, 1500000), ('India', 2020, 1800000), ('India', 2021, 2200000);
What is the three-year rolling average of agricultural innovation investments in India?
SELECT year, AVG(innovation_investment) OVER (ORDER BY year ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS rolling_average FROM agricultural_investments WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT, TotalDonation FLOAT); INSERT INTO Donors (DonorID, Name, TotalDonation) VALUES (1, 'John Doe', 5000.00), (2, 'Jane Smith', 3500.00);
What was the total amount donated by each donor in 2021, sorted by the highest amount?
SELECT Name, SUM(TotalDonation) as TotalDonated FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY Name ORDER BY TotalDonated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, employees INT, founding_date DATE);
List the number of unique industries for companies with more than 50 employees founded between 2015 and 2018.
SELECT COUNT(DISTINCT industry) FROM companies WHERE employees > 50 AND founding_date BETWEEN '2015-01-01' AND '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE max_vessels_by_country (country TEXT, max_vessels INT); INSERT INTO max_vessels_by_country (country, max_vessels) VALUES ('Canada', 50000), ('USA', 100000), ('Mexico', 30000);
What is the maximum number of vessels registered in any country?
SELECT MAX(max_vessels) FROM max_vessels_by_country;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, sector VARCHAR(20), region VARCHAR(20), risk_score INT);
What is the minimum risk score for the energy sector in each region?
SELECT region, MIN(risk_score) FROM threat_intelligence WHERE sector = 'energy' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_preferences (customer_id INT, product_id INT, preference_score INT); INSERT INTO customer_preferences (customer_id, product_id, preference_score) VALUES (1, 1, 90), (1, 2, 70), (2, 1, 80), (2, 2, 85), (3, 1, 50), (3, 2, 95), (4, 1, 90), (4, 2, 80), (5, 1, 60), (5, 2, 90);
What is the ranking of customer preferences for each cosmetic product?
SELECT customer_id, product_id, preference_score, RANK() OVER (PARTITION BY product_id ORDER BY preference_score DESC) as preference_rank FROM customer_preferences;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), country VARCHAR(10), quantity INT); INSERT INTO production (year, element, country, quantity) VALUES (2017, 'Terbium', 'India', 1200), (2018, 'Terbium', 'India', 1400), (2019, 'Terbium', 'India', 1600), (2020, 'Terbium', 'India', 1800), (2021, 'Terbium', 'India', 2000);
Reduce the Terbium production in India by 10% for 2021 and later.
UPDATE production SET quantity = quantity * 0.9 WHERE element = 'Terbium' AND country = 'India' AND year >= 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Viewers (id INT, movie_title VARCHAR(100), age_group INT, viewers INT);
Total number of viewers by age group, for a specific movie?
SELECT age_group, SUM(viewers) FROM Viewers WHERE movie_title = 'The Matrix Resurrections' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_law_compliance_initiatives (id INT, initiative TEXT, region TEXT, funding FLOAT); INSERT INTO maritime_law_compliance_initiatives (id, initiative, region, funding) VALUES (1, 'Initiative X', 'Arctic', 400000), (2, 'Initiative Y', 'Atlantic', 300000), (3, 'Initiative Z', 'Arctic', 500000);
What is the total funding for maritime law compliance initiatives in the Arctic region?
SELECT SUM(funding) FROM maritime_law_compliance_initiatives WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeData (EmployeeID INT, Gender VARCHAR(10), Salary DECIMAL(10,2)); INSERT INTO EmployeeData (EmployeeID, Gender, Salary) VALUES (1, 'Male', 75000.00), (2, 'Female', 65000.00), (3, 'Non-binary', 62000.00);
What is the average salary for male and female employees?
SELECT Gender, AVG(Salary) FROM EmployeeData WHERE Gender IN ('Male', 'Female') GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT); CREATE TABLE product_compounds (compound_id INT, product_id INT); CREATE TABLE chemical_compounds (compound_id INT, name TEXT);
How many unique chemical compounds were used in the production of each product in the past month?
SELECT products.name, COUNT(DISTINCT chemical_compounds.compound_id) FROM products INNER JOIN product_compounds ON products.product_id = product_compounds.product_id INNER JOIN chemical_compounds ON product_compounds.compound_id = chemical_compounds.compound_id WHERE products.production_date > DATEADD(month, -1, GETDATE()) GROUP BY products.name;
gretelai_synthetic_text_to_sql
CREATE TABLE company_drugs (id INT PRIMARY KEY, company VARCHAR(50), drug_name VARCHAR(50), launch_date DATE); CREATE TABLE rd_expenditures (id INT PRIMARY KEY, company VARCHAR(50), year INT, amount DECIMAL(10,2));
What is the total R&D expenditure for companies that have launched a drug after 2015?
SELECT SUM(re.amount) FROM rd_expenditures re JOIN company_drugs cd ON re.company = cd.company WHERE cd.launch_date > '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE awards (year INT, country TEXT, num_awards INT); INSERT INTO awards (year, country, num_awards) VALUES ('2019', 'Italy', 3), ('2020', 'Italy', 2), ('2021', 'Italy', 5), ('2019', 'Spain', 2), ('2020', 'Spain', 4), ('2021', 'Spain', 1), ('2019', 'Greece', 1), ('2020', 'Greece', 3), ('2021', 'Greece', 4), ('2019', 'Portugal', 5), ('2020', 'Portugal', 4), ('2021', 'Portugal', 3);
Rank the top 5 countries by the number of sustainable tourism awards received in the last 3 years.
SELECT country, RANK() OVER (ORDER BY SUM(num_awards) DESC) as rank FROM awards WHERE year >= (SELECT MAX(year) - 3) GROUP BY country HAVING COUNT(*) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), sport VARCHAR(10));INSERT INTO athletes (athlete_id, athlete_name, sport) VALUES (1, 'John Doe', 'Baseball'), (2, 'Jane Doe', 'Football'), (3, 'Janet Doe', 'Baseball'), (4, 'Jack Doe', 'Football');
List athletes who have participated in both baseball and football during their career?
SELECT a.athlete_name FROM athletes a WHERE a.sport = 'Baseball' INTERSECT SELECT a.athlete_name FROM athletes a WHERE a.sport = 'Football';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (city VARCHAR(255), genre VARCHAR(255), attendance INT); INSERT INTO Concerts (city, genre, attendance) VALUES ('New York', 'Jazz', 300), ('Los Angeles', 'Jazz', 200), ('Chicago', 'Jazz', 250);
Delete the record of the least attended jazz concert.
DELETE FROM Concerts WHERE city = 'Los Angeles' AND genre = 'Jazz' AND attendance = (SELECT MIN(attendance) FROM Concerts WHERE genre = 'Jazz');
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ConcertID INT, ConcertName VARCHAR(100), ConcertType VARCHAR(50), VenueID INT, TicketPrice DECIMAL(5,2), ArtistID INT, ArtistNationality VARCHAR(50)); CREATE TABLE Tickets (TicketID INT, ConcertID INT, TicketSold BOOLEAN, PurchaseDate TIMESTAMP); INSERT INTO Concerts VALUES (1, 'Salsa Night', 'Concert', 1, 75, 1, 'Puerto Rico'); INSERT INTO Tickets VALUES (1, 1, TRUE, '2023-01-01 10:00:00');
What is the total revenue from concert ticket sales for Latin artists in the United States?
SELECT SUM(Concerts.TicketPrice) AS TotalRevenue FROM Concerts JOIN Tickets ON Concerts.ConcertID = Tickets.ConcertID WHERE Concerts.ArtistNationality = 'Latin' AND Tickets.PurchaseDate BETWEEN (CURRENT_DATE - INTERVAL '1 year') AND CURRENT_DATE AND Concerts.ConcertType = 'Concert';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_materials (material_name text, manufacturing_emissions integer, recycling_potential real);
Create a new table named "sustainable_materials" with columns "material_name" (text), "manufacturing_emissions" (integer), and "recycling_potential" (real)
CREATE TABLE sustainable_materials (material_name text, manufacturing_emissions integer, recycling_potential real);
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (state VARCHAR(2), recycling_rate DECIMAL(4,2)); INSERT INTO recycling_rates (state, recycling_rate) VALUES ('US', 35.01), ('CA', 50.03), ('NY', 25.10);
What is the total recycling rate in the state of California?
SELECT SUM(recycling_rate) FROM recycling_rates WHERE state = 'CA';
gretelai_synthetic_text_to_sql
CREATE VIEW vessel_summary AS SELECT vessel_id, AVG(avg_speed) AS average_speed, SUM(fuel_efficiency) AS total_fuel_efficiency, COUNT(*) FILTER (WHERE result = 'PASS') AS successful_inspections FROM vessel_performance JOIN safety_records ON vessel_performance.vessel_id = safety_records.vessel_id GROUP BY vessel_id;
List all vessel IDs and their corresponding average speeds from the "vessel_summary" view.
SELECT vessel_id, average_speed FROM vessel_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50), gre_score INT); INSERT INTO students (id, name, department, gre_score) VALUES (1, 'John Doe', 'Electrical Engineering', 165), (2, 'Jane Smith', 'Electrical Engineering', 160), (3, 'Bob Johnson', 'Electrical Engineering', 170), (4, 'Alice Smith', 'Electrical Engineering', 175), (5, 'Charlie Brown', 'Electrical Engineering', 155);
Who are the top 5 students with the highest GRE scores in the Electrical Engineering department?
SELECT * FROM students WHERE department = 'Electrical Engineering' ORDER BY gre_score DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, state VARCHAR(50), quarter VARCHAR(10), strain VARCHAR(50), revenue INT);
Insert a new sale for the state of Michigan in Q1 2022 with a revenue of 15000 and a strain of "Blue Dream"
INSERT INTO sales (state, quarter, strain, revenue) VALUES ('Michigan', 'Q1', 'Blue Dream', 15000);
gretelai_synthetic_text_to_sql
CREATE SCHEMA GreenEnergy; CREATE TABLE Countries (country_id INT, country_name VARCHAR(100), energy_efficiency_rating INT); INSERT INTO Countries (country_id, country_name, energy_efficiency_rating) VALUES (1, 'Switzerland', 90), (2, 'Sweden', 85), (3, 'Norway', 80), (4, 'Finland', 75), (5, 'Denmark', 70), (6, 'Austria', 65);
Which are the top 3 countries with the highest energy efficiency ratings in the 'GreenEnergy' schema?
SELECT country_name, energy_efficiency_rating FROM GreenEnergy.Countries ORDER BY energy_efficiency_rating DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (stream_id INT, user_id INT, song_id INT, streams INT, date DATE, artist_id INT, artist_lgbtq BOOLEAN);
Find the number of unique users who have streamed songs from artists who identify as LGBTQ+ in the 'music_streaming' table.
SELECT COUNT(DISTINCT user_id) FROM music_streaming WHERE artist_lgbtq = true;
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_management.vessels (id INT, name VARCHAR(50), year_built INT, type VARCHAR(50)); CREATE TABLE fleet_management.cargo_handling (id INT, port_id INT, volume INT, handling_date DATE, vessel_id INT);
List the vessels and their last cargo handling operation by type in the 'fleet_management' schema.
SELECT v.name, v.type, ch.handling_date FROM fleet_management.vessels v INNER JOIN (SELECT vessel_id, MAX(handling_date) AS max_handling_date FROM fleet_management.cargo_handling GROUP BY vessel_id) sub ON v.id = sub.vessel_id INNER JOIN fleet_management.cargo_handling ch ON v.id = ch.vessel_id AND sub.max_handling_date = ch.handling_date;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (menu_item VARCHAR(255), category VARCHAR(255), sales_quantity INT); INSERT INTO sales (menu_item, category, sales_quantity) VALUES ('Burger', 'Main Dishes', 1200); INSERT INTO sales (menu_item, category, sales_quantity) VALUES ('Caesar Salad', 'Salads', 450);
What are the top 3 selling menu categories for the last month?
SELECT category, SUM(sales_quantity) as total_sold FROM sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY category ORDER BY total_sold DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CSADistribution (state VARCHAR(50), num_csa INT); INSERT INTO CSADistribution (state, num_csa) VALUES ('California', 100), ('Texas', 50), ('New York', 75), ('Wisconsin', 25), ('Massachusetts', 50);
What is the maximum and minimum number of community-supported agriculture (CSA) farms per state in the US?
SELECT state, MAX(num_csa), MIN(num_csa) FROM CSADistribution GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT PRIMARY KEY, name TEXT, region TEXT); INSERT INTO countries (id, name, region) VALUES (1, 'USA', 'North America'), (2, 'Canada', 'North America'), (3, 'Mexico', 'North America'), (4, 'Brazil', 'South America'), (5, 'Argentina', 'South America'); CREATE TABLE oil_production (country_id INT, year INT, production INT); INSERT INTO oil_production (country_id, year, production) VALUES (1, 2020, 500), (1, 2021, 600), (2, 2020, 400), (2, 2021, 450), (3, 2020, 350), (3, 2021, 400), (4, 2020, 250), (4, 2021, 300), (5, 2020, 150), (5, 2021, 200);
List the countries with the highest oil production in 2021
SELECT c.name, op.production as total_production FROM countries c JOIN oil_production op ON c.id = op.country_id WHERE op.year = 2021 GROUP BY c.name ORDER BY total_production DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (country TEXT, category TEXT, mass FLOAT); INSERT INTO space_debris (country, category, mass) VALUES ('USA', 'Aluminum', 120.5), ('USA', 'Titanium', 170.1), ('Russia', 'Aluminum', 150.2), ('Russia', 'Titanium', 180.1), ('China', 'Copper', 100.1), ('China', 'Steel', 250.7);
What is the total mass of space debris launched by each country?
SELECT country, SUM(mass) FROM space_debris GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Aircraft (ID INT, Type VARCHAR(50), Year INT, Quantity INT); INSERT INTO Military_Aircraft (ID, Type, Year, Quantity) VALUES (1, 'F-16', 2015, 50), (2, 'F-35', 2018, 80), (3, 'A-10', 2017, 30);
What is the total number of military aircraft by type, ordered by the most recent year?
SELECT Type, MAX(Year), SUM(Quantity) FROM Military_Aircraft GROUP BY Type ORDER BY MAX(Year) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (country VARCHAR(50), num_bases INT); INSERT INTO military_bases (country, num_bases) VALUES ('Iran', 22), ('Saudi Arabia', 25), ('Turkey', 20), ('Israel', 18), ('Egypt', 12), ('Iraq', 15);
What is the average number of military bases in Middle Eastern countries?
SELECT AVG(num_bases) FROM military_bases WHERE country IN ('Iran', 'Saudi Arabia', 'Turkey', 'Israel', 'Egypt', 'Iraq') AND country LIKE 'Middle%';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, year INT, faculty_name VARCHAR(50), faculty_department VARCHAR(50)); INSERT INTO research_grants (id, year, faculty_name, faculty_department) VALUES (1, 2019, 'John Smith', 'Mechanical Engineering'), (2, 2020, 'Jane Doe', 'Electrical Engineering'), (3, 2018, 'Bob Johnson', 'Civil Engineering');
How many research grants were awarded to faculty members in the School of Engineering in 2020?
SELECT COUNT(*) FROM research_grants WHERE faculty_department LIKE '%Engineering%' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_dev (region VARCHAR(20), crop VARCHAR(20), yield INT); INSERT INTO rural_dev (region, crop, yield) VALUES ('rural_dev', 'corn', 70);
What is the average yield per hectare of corn in the 'rural_dev' region?
SELECT AVG(yield) FROM rural_dev WHERE crop = 'corn';
gretelai_synthetic_text_to_sql
CREATE TABLE ucl_season (team_id INT, team_name VARCHAR(50), games_played INT, goals_home INT, goals_away INT); INSERT INTO ucl_season (team_id, team_name, games_played, goals_home, goals_away) VALUES (1, 'Bayern Munich', 11, 43, 10);
What is the difference in total goals scored between the home and away games for each team in the 2020-2021 UEFA Champions League?
SELECT team_name, (goals_home - goals_away) as diff FROM ucl_season;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_training (id INT, provider_id INT, program_name VARCHAR(100), program_date DATE); INSERT INTO cultural_competency_training (id, provider_id, program_name, program_date) VALUES (1, 456, 'Cultural Sensitivity 101', '2021-02-01'), (2, 456, 'Working with Diverse Communities', '2021-03-15'); CREATE TABLE healthcare_providers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO healthcare_providers (id, name, region) VALUES (456, 'Jane Smith', 'California');
List all unique cultural competency training programs offered by providers in California.
SELECT DISTINCT program_name FROM cultural_competency_training INNER JOIN healthcare_providers ON cultural_competency_training.provider_id = healthcare_providers.id WHERE healthcare_providers.region = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_investments (country VARCHAR(255), investment_amount DECIMAL(10,2), investment_type VARCHAR(255), year INT); INSERT INTO renewable_investments (country, investment_amount, investment_type, year) VALUES ('China', 85000.0, 'public', 2020), ('China', 60000.0, 'private', 2020), ('USA', 50000.0, 'private', 2020), ('Germany', 35000.0, 'public', 2020), ('India', 28000.0, 'public', 2020), ('Brazil', 12000.0, 'private', 2020);
Calculate the total renewable energy investments made by public and private sectors in each country in 2020 from the 'renewable_investments' table.
SELECT country, SUM(investment_amount) as total_investments FROM renewable_investments WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(255), community VARCHAR(255)); CREATE TABLE decentralized_applications (app_id INT, name VARCHAR(255), developer_id INT); INSERT INTO developers (developer_id, name, community) VALUES (1, 'Alice', 'Women in Tech'), (2, 'Bob', 'LGBTQ+'), (3, 'Charlie', 'Minority Ethnicity'), (4, 'Dave', 'Neurodiverse'); INSERT INTO decentralized_applications (app_id, name, developer_id) VALUES (1, 'BlockchainVoting', 1), (2, 'DecentralizedBank', 2), (3, 'SmartContractPlatform', 3), (4, 'DataMarketplace', 4), (5, 'DecentralizedIdentity', 1);
Which decentralized applications were created by developers from underrepresented communities?
SELECT da.name FROM decentralized_applications da JOIN developers d ON da.developer_id = d.developer_id WHERE d.community IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50)); INSERT INTO Species (id, name, type) VALUES (1, 'Tuna', 'Fish'); INSERT INTO Species (id, name, type) VALUES (2, 'Krill', 'Crustacean'); INSERT INTO Species (id, name, type) VALUES (3, 'Dolphin', 'Mammal'); CREATE TABLE Observations (id INT PRIMARY KEY, species_id INT, location VARCHAR(50), weight REAL); INSERT INTO Observations (id, species_id, location, weight) VALUES (1, 1, 'Pacific Ocean', 20.5); INSERT INTO Observations (id, species_id, location, weight) VALUES (2, 2, 'Atlantic Ocean', 0.003); INSERT INTO Observations (id, species_id, location, weight) VALUES (4, 3, 'Atlantic Ocean', 120);
Calculate the average weight of marine mammals in the Atlantic Ocean.
SELECT AVG(O.weight) FROM Observations O JOIN Species S ON O.species_id = S.id WHERE S.type = 'Mammal' AND O.location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, department VARCHAR(20), amount FLOAT); INSERT INTO grants (id, department, amount) VALUES (1, 'Arts and Humanities', 50000.0), (2, 'Sciences', 75000.0);
Calculate the average grant amount awarded to all departments
SELECT AVG(amount) FROM grants;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionZone1 (species VARCHAR(20), production_volume FLOAT); INSERT INTO ProductionZone1 (species, production_volume) VALUES ('Salmon', 120), ('Trout', 150), ('Tuna', 180);
What is the total production volume (in tons) for each species in ProductionZone1?
SELECT species, SUM(production_volume) FROM ProductionZone1 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityImpact (id INT, impact_level TEXT); INSERT INTO CybersecurityImpact (id, impact_level) VALUES (1, 'High'), (2, 'Medium'), (3, 'Low'); CREATE TABLE CybersecurityIncidentsByMonth (id INT, month INT, impact_id INT); INSERT INTO CybersecurityIncidentsByMonth (id, month, impact_id) VALUES (1, 12, 1), (2, 11, 2);
What is the total number of cybersecurity incidents reported worldwide each month for the past 12 months and their respective impact levels?
SELECT MONTH(CybersecurityIncidentsByMonth.month) as month, COUNT(CybersecurityIncidentsByMonth.id) as total_incidents, AVG(CybersecurityImpact.impact_level) as avg_impact FROM CybersecurityIncidentsByMonth INNER JOIN CybersecurityImpact ON CybersecurityIncidentsByMonth.impact_id = CybersecurityImpact.id GROUP BY MONTH(CybersecurityIncidentsByMonth.month) ORDER BY MONTH(CybersecurityIncidentsByMonth.month) DESC LIMIT 12;
gretelai_synthetic_text_to_sql
CREATE TABLE sports (sport_id INT, sport_name VARCHAR(20)); INSERT INTO sports (sport_id, sport_name) VALUES (1, 'Basketball'), (2, 'Soccer'), (3, 'Rugby'); CREATE TABLE sales (sale_id INT, sport_id INT, revenue DECIMAL(5,2)); INSERT INTO sales (sale_id, sport_id, revenue) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 800.00), (4, 2, 1000.00);
List the unique sports that have ticket sales data.
SELECT DISTINCT sports.sport_name FROM sports JOIN sales ON sports.sport_id = sales.sport_id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (vessel_id INT, speed FLOAT, timestamp TIMESTAMP);
What is the average speed of vessels in the 'vessel_performance' table, grouped by month?
SELECT DATE_FORMAT(timestamp, '%Y-%m') AS month, AVG(speed) FROM vessel_performance GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE shipment (id INT PRIMARY KEY, warehouse_id INT, carrier_id INT, pallet_count INT, shipped_date DATE);
Update the pallet count for shipment ID 150 to 750, if the current pallet count is less than 750.
UPDATE shipment SET pallet_count = 750 WHERE id = 150 AND pallet_count < 750;
gretelai_synthetic_text_to_sql
CREATE TABLE exits (id INT, company_id INT, exit_type TEXT, exit_valuation INT, date DATE); INSERT INTO exits (id, company_id, exit_type, exit_valuation, date) VALUES (1, 1, 'Acquisition', 50000000, '2021-01-01'), (2, 2, 'IPO', 100000000, '2022-01-01'), (3, 3, 'Acquisition', 25000000, '2019-01-01');
What is the minimum exit valuation for startups in the FinTech sector founded by underrepresented minority founders?
SELECT MIN(exits.exit_valuation) FROM exits JOIN companies ON exits.company_id = companies.id WHERE companies.industry = 'FinTech' AND companies.founder_ethnicity IN ('Hispanic', 'African American', 'Native American');
gretelai_synthetic_text_to_sql
CREATE TABLE Hours (TeacherID INT, State VARCHAR(10), Subject VARCHAR(10), Hours DECIMAL(5,2)); INSERT INTO Hours (TeacherID, State, Subject, Hours) VALUES (1, 'FL', 'English', 15.5);
Calculate the total teaching hours for all teachers who teach 'English' and work in 'Florida'
SELECT SUM(Hours) FROM Hours WHERE Subject = 'English' AND State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (id INT, country TEXT);CREATE TABLE courses (id INT, teacher_id INT);CREATE TABLE course_completions (course_id INT, completion_date DATE);
How many professional development courses were completed by teachers from each country?
SELECT teachers.country, COUNT(DISTINCT courses.id) as courses_completed FROM teachers INNER JOIN courses ON teachers.id = courses.teacher_id INNER JOIN course_completions ON courses.id = course_completions.course_id GROUP BY teachers.country;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (id INT, name VARCHAR(20), age INT, address VARCHAR(30)); INSERT INTO teachers (id, name, age, address) VALUES (1, 'Alice', 30, 'San Francisco'); INSERT INTO teachers (id, name, age, address) VALUES (2, 'Brian', 35, 'Oakland'); INSERT INTO teachers (id, name, age, address) VALUES (3, 'Carla', 40, 'Berkeley');
Delete the record of the teacher with ID 2 from the 'teachers' table
DELETE FROM teachers WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_test_data (id INT, make VARCHAR(20), model VARCHAR(20), range DECIMAL(5,2)); INSERT INTO vehicle_test_data (id, make, model, range) VALUES (1, 'Tesla', 'Model 3', 322.3), (2, 'Ford', 'Mustang Mach-E', 230.8), (3, 'Chevrolet', 'Bolt', 259.0);
What are the average and standard deviation of the ranges of electric vehicles in the vehicle_test_data table?
SELECT AVG(range), STDDEV(range) FROM vehicle_test_data WHERE is_electric = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Projects_OR (project_id INT, project_name VARCHAR(50), state VARCHAR(2), cost FLOAT, is_sustainable BOOLEAN); INSERT INTO Sustainable_Projects_OR VALUES (1, 'Portland Eco-House', 'OR', 500000, true);
What is the average cost of a sustainable building project in Oregon?
SELECT AVG(cost) FROM Sustainable_Projects_OR WHERE state = 'OR' AND is_sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, content TEXT, likes INT, timestamp DATETIME); INSERT INTO posts (id, user_id, content, likes, timestamp) VALUES (1, 1, 'Sustainable living tips', 250, '2022-01-01 10:00:00'), (2, 2, 'Eco-friendly product review', 120, '2022-01-05 15:30:00'); CREATE TABLE hashtags (id INT, post_id INT, hashtag TEXT); INSERT INTO hashtags (id, post_id, hashtag) VALUES (1, 1, '#sustainability'), (2, 2, '#sustainability');
What is the average number of likes on posts containing the hashtag "#sustainability" in the last month?
SELECT AVG(likes) FROM posts JOIN hashtags ON posts.id = hashtags.post_id WHERE hashtag = '#sustainability' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (country VARCHAR(50), capacity_mwh INT); INSERT INTO energy_storage (country, capacity_mwh) VALUES ('Australia', 1342), ('Canada', 2501);
What is the average energy storage capacity in megawatt-hours (MWh) for Australia and Canada?
SELECT AVG(capacity_mwh) FROM energy_storage WHERE country IN ('Australia', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_use (sector VARCHAR(50), year INT, amount INT); INSERT INTO industrial_water_use (sector, year, amount) VALUES ('Agriculture', 2020, 12000), ('Manufacturing', 2020, 8000), ('Mining', 2020, 5000);
What is the total water consumption by industrial sector in California for the year 2020?
SELECT i.sector, SUM(i.amount) as total_water_consumption FROM industrial_water_use i WHERE i.year = 2020 AND i.sector = 'Industrial' GROUP BY i.sector;
gretelai_synthetic_text_to_sql
CREATE TABLE farm (id INT, region VARCHAR(20), crop VARCHAR(20), yield INT);
How many farms are in 'region3'?
SELECT COUNT(*) FROM farm WHERE region = 'region3';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (id INT, name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO courses (id, name, start_date, end_date) VALUES (1, 'Introduction to Programming', '2022-01-01', '2022-04-30'); INSERT INTO courses (id, name, start_date, end_date) VALUES (2, 'Data Science', '2022-05-01', '2022-08-31'); INSERT INTO courses (id, name, start_date, end_date) VALUES (3, 'Web Development', '2022-09-01', '2022-12-31');
Delete the course with the highest ID.
DELETE FROM courses WHERE id = (SELECT MAX(id) FROM courses);
gretelai_synthetic_text_to_sql
CREATE TABLE developers (id INT, name TEXT, country TEXT); INSERT INTO developers (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'USA'); CREATE TABLE digital_assets (id INT, name TEXT, developer_id INT); INSERT INTO digital_assets (id, name, developer_id) VALUES (1, 'CoinA', 1), (2, 'CoinB', 2), (3, 'CoinC', 1), (4, 'CoinD', 3);
What is the total number of digital assets created by developers from the US and Canada?
SELECT COUNT(*) FROM digital_assets d JOIN developers dev ON d.developer_id = dev.id WHERE dev.country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE biomass (location VARCHAR(20), biomass_kg FLOAT); INSERT INTO biomass (location, biomass_kg) VALUES ('Mediterranean sea', 1200000), ('Black sea', 900000);
What is the total biomass of fish in the Mediterranean sea and the Black sea?
SELECT SUM(biomass_kg) FROM biomass WHERE location IN ('Mediterranean sea', 'Black sea');
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT PRIMARY KEY, name VARCHAR(100), birth_date DATE, death_date DATE, nationality VARCHAR(50));
Create a table for artists' biographical data
CREATE TABLE artists_biography AS SELECT artist_id, name, birth_date, death_date, nationality FROM artists;
gretelai_synthetic_text_to_sql
CREATE TABLE pms_stats (pms_id INT, pms_name TEXT, country TEXT, hotel_count INT); INSERT INTO pms_stats (pms_id, pms_name, country, hotel_count) VALUES (1, 'PMS 1', 'Japan', 100), (2, 'PMS 2', 'India', 150), (3, 'PMS 3', 'Brazil', 75), (4, 'PMS 4', 'Japan', 50), (5, 'PMS 5', 'Brazil', 125);
What is the number of hotels that have adopted cloud PMS (Property Management System) in Japan, India, and Brazil?
SELECT country, SUM(hotel_count) as total_hotels FROM pms_stats WHERE country IN ('Japan', 'India', 'Brazil') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Research_Expeditions ( id INT PRIMARY KEY, expedition_name VARCHAR(50), lead_scientist VARCHAR(50), vessel VARCHAR(50), start_date DATETIME); INSERT INTO Research_Expeditions (id, expedition_name, lead_scientist, vessel, start_date) VALUES (1, 'Mariana Trench Exploration', 'Dr. Sylvia Earle', 'Deepsea Challenger', '2022-04-01'), (2, 'Amazon Reef Survey', 'Dr. Luiz Rocha', 'Kiel Explorer', '2022-07-01'), (3, 'Arctic Ice Melt Study', 'Dr. Michelle Laidlaw', 'Polar Star', '2023-02-15');
What is the next marine research expedition for the vessel 'Kiel Explorer'?
SELECT expedition_name, lead_scientist, vessel, start_date, LEAD(start_date) OVER(PARTITION BY vessel ORDER BY start_date) as next_expedition FROM Research_Expeditions WHERE vessel = 'Kiel Explorer'
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture_data (province VARCHAR(255), soil_moisture INT, date DATE); INSERT INTO soil_moisture_data (province, soil_moisture, date) VALUES ('Shanxi', 10, '2022-06-01'), ('Shaanxi', 15, '2022-06-01'), ('Gansu', 20, '2022-06-01'), ('Henan', 25, '2022-06-01');
What is the average soil moisture in the top 3 driest provinces in China in the past month?
SELECT province, AVG(soil_moisture) as avg_soil_moisture FROM (SELECT province, soil_moisture, RANK() OVER (PARTITION BY NULL ORDER BY soil_moisture ASC) as dryness_rank FROM soil_moisture_data WHERE date BETWEEN '2022-05-01' AND '2022-06-01' GROUP BY province) subquery WHERE dryness_rank <= 3 GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtsPractitioners (Country VARCHAR(255), NumberOfPractitioners INT); INSERT INTO ArtsPractitioners (Country, NumberOfPractitioners) VALUES ('India', 25000), ('China', 20000), ('Indonesia', 18000), ('Japan', 15000), ('Vietnam', 12000);
What is the total number of practitioners of traditional arts in Asia, listed alphabetically by country?
SELECT Country, SUM(NumberOfPractitioners) FROM ArtsPractitioners WHERE Country = 'Asia' GROUP BY Country ORDER BY Country ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (id INT, name VARCHAR(50), price DECIMAL(5,2), eco_friendly BOOLEAN);
Find the average price of eco-friendly skincare products
SELECT AVG(price) FROM cosmetics WHERE eco_friendly = TRUE;
gretelai_synthetic_text_to_sql