context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE community_development (id INT, initiative VARCHAR(50), budget FLOAT, status VARCHAR(20));
Show the total budget for community development initiatives in the 'community_development' table, including completed and ongoing projects.
SELECT SUM(budget) FROM community_development WHERE status IN ('completed', 'ongoing');
gretelai_synthetic_text_to_sql
CREATE TABLE BridgeYears ( BridgeID INT, Year INT, MaintenanceCost DECIMAL(10, 2));
Identify the bridge in the 'South' region with the largest increase in maintenance costs between any two consecutive years.
SELECT BridgeID, MAX(Diff) as LargestIncrease FROM ( SELECT BridgeID, Year, MaintenanceCost, MaintenanceCost - LAG(MaintenanceCost) OVER (PARTITION BY BridgeID ORDER BY Year) as Diff FROM BridgeYears WHERE Region = 'South') sub WHERE Diff IS NOT NULL GROUP BY BridgeID;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT, name TEXT, sport TEXT, league TEXT, conference TEXT); CREATE TABLE games (id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT, game_date DATE); CREATE TABLE players (id INT, name TEXT, team_id INT, points INT);
Who is the top scorer for each team in the current season, and how many points did they score?
SELECT p.name, p.points FROM players p INNER JOIN (SELECT team_id, MAX(points) AS max_points FROM players WHERE game_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY team_id) b ON p.team_id = b.team_id AND p.points = b.max_points;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeData (EmployeeID int, Name varchar(30), Ethnicity varchar(20), JobTitle varchar(20), Department varchar(20), TrainingComplete int); INSERT INTO EmployeeData (EmployeeID, Name, Ethnicity, JobTitle, Department, TrainingComplete) VALUES (1, 'Sophia Gonzales', 'Latinx', 'Data Analyst', 'Engineering', 0), (2, 'Mohammad Ali', 'Asian', 'Software Engineer', 'IT', 1), (3, 'Leila Johnson', 'African American', 'Project Manager', 'Marketing', 0);
List the names, ethnicities, and job titles for employees in the Engineering department who have not completed diversity and inclusion training.
SELECT Name, Ethnicity, JobTitle FROM EmployeeData WHERE Department = 'Engineering' AND TrainingComplete = 0;
gretelai_synthetic_text_to_sql
CREATE VIEW sustainable_urbanism AS SELECT properties.id, properties.city, properties.square_footage as total_square_footage FROM properties; INSERT INTO properties (id, city, square_footage) VALUES (1, 'Austin', 1800.0), (2, 'Seattle', 2200.0), (3, 'New York', 1500.0);
Update the square footage of properties in the 'sustainable_urbanism' view that are located in 'Seattle' to increase by 10%.
UPDATE sustainable_urbanism SET total_square_footage = total_square_footage * 1.10 WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, product_id INT, sale_date DATE); CREATE TABLE Products (id INT, category TEXT, is_halal_certified BOOLEAN); INSERT INTO Sales (id, product_id, sale_date) VALUES (1, 1, '2022-01-05'), (2, 2, '2022-04-17'); INSERT INTO Products (id, category, is_halal_certified) VALUES (1, 'Makeup', true), (2, 'Skincare', false);
How many halal-certified makeup products were sold in the last quarter?
SELECT COUNT(*) FROM Sales JOIN Products ON Sales.product_id = Products.id WHERE is_halal_certified = true AND category = 'Makeup' AND sale_date >= '2022-01-01' AND sale_date <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, founders TEXT, industry TEXT); INSERT INTO Companies (id, name, founders, industry) VALUES (1, 'GreenVets', 'Male, Veteran', 'Renewable Energy'); INSERT INTO Companies (id, name, founders, industry) VALUES (2, 'TechBoost', 'Asian, Male', 'Technology'); CREATE TABLE Investment_Rounds (company_id INT, funding_amount INT, round_number INT); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (1, 600000, 1); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (1, 900000, 2); INSERT INTO Investment_Rounds (company_id, funding_amount, round_number) VALUES (2, 3000000, 1);
What is the average funding amount received by a company founded by a veteran in the renewable energy industry?
SELECT AVG(r.funding_amount) FROM Companies c JOIN Investment_Rounds r ON c.id = r.company_id WHERE c.founders LIKE '%Veteran%' AND c.industry = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(50), region VARCHAR(50));
Update the hotels_table to include the region for each hotel
UPDATE hotels SET region = CASE WHEN hotel_name LIKE '%Royal%' THEN 'Europe' WHEN hotel_name LIKE '%View%' THEN 'Americas' ELSE 'Asia' END;
gretelai_synthetic_text_to_sql
CREATE TABLE student_disabilities (state VARCHAR(20), disability VARCHAR(30), count INT); INSERT INTO student_disabilities (state, disability, count) VALUES ('California', 'Mental Health', 500); INSERT INTO student_disabilities (state, disability, count) VALUES ('Texas', 'Mental Health', 700); INSERT INTO student_disabilities (state, disability, count) VALUES ('Florida', 'Mental Health', 800);
What is the total number of students with mental health disabilities enrolled in each state?
SELECT state, SUM(count) FROM student_disabilities WHERE disability = 'Mental Health' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE FalconHeavyMissions (id INT, launch_date DATE, num_satellites INT);
What is the maximum number of satellites launched by a single SpaceX Falcon Heavy mission?
SELECT MAX(num_satellites) FROM FalconHeavyMissions WHERE num_satellites IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE song_details (song_id INT, artist_id INT, genre VARCHAR(20)); INSERT INTO song_details (song_id, artist_id, genre) VALUES (1, 1, 'Pop'), (2, 2, 'Rock'), (3, 3, 'Jazz'), (4, 1, 'Pop'), (5, 2, 'Rock'), (6, 3, 'Jazz'), (7, 1, 'Pop'), (8, 2, 'Rock'); CREATE TABLE artists (artist_id INT, artist_name VARCHAR(50)); INSERT INTO artists (artist_id, artist_name) VALUES (1, 'Taylor Swift'), (2, 'BTS'), (3, 'Coldplay');
What are the names of the top 2 artists with the most songs in the 'song_details' table?
SELECT artists.artist_name, COUNT(song_details.song_id) as song_count FROM artists INNER JOIN song_details ON artists.artist_id = song_details.artist_id GROUP BY artists.artist_id ORDER BY song_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(30), product_type VARCHAR(20), sell_by_date DATE); INSERT INTO products (product_id, product_name, product_type, sell_by_date) VALUES (1, 'Milk', 'dairy', '2022-12-31'), (2, 'Bread', 'bakery', '2023-01-05');
What is the minimum sell-by date for dairy products?
SELECT MIN(sell_by_date) FROM products WHERE product_type = 'dairy';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), department VARCHAR(50), age INT);
What is the number of employees in the "mining_operations" table, who are older than 40 and working in the "management" department?
SELECT COUNT(*) FROM mining_operations WHERE department = 'management' AND age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (id INT, operation_name TEXT, year INT, region TEXT, success_rate FLOAT); INSERT INTO IntelligenceOperations (id, operation_name, year, region, success_rate) VALUES (1, 'Operation A', 2021, 'ME', 0.8);
What is the total number of intelligence operations conducted in the Middle East in the last 3 years and their respective success rates?
SELECT YEAR(IntelligenceOperations.year) as year, COUNT(IntelligenceOperations.operation_name) as total_operations, AVG(IntelligenceOperations.success_rate) as avg_success_rate FROM IntelligenceOperations WHERE IntelligenceOperations.region = 'ME' GROUP BY YEAR(IntelligenceOperations.year) ORDER BY YEAR(IntelligenceOperations.year) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (country VARCHAR(2), regulation_name VARCHAR(100)); INSERT INTO regulations (country, regulation_name) VALUES ('US', 'Payment Services Act');
Update the "country" field to "Singapore" for the record with "regulation_name" as "Payment Services Act" in the "regulations" table
UPDATE regulations SET country = 'SG' WHERE regulation_name = 'Payment Services Act';
gretelai_synthetic_text_to_sql
CREATE TABLE property (id INT, size INT, state VARCHAR(20), co_owned BOOLEAN);
How many co-owned properties are there in the state of Texas with a size greater than 2000 square feet?
SELECT COUNT(*) FROM property WHERE state = 'Texas' AND co_owned = TRUE AND size > 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_plants (id INT, name VARCHAR(50), location VARCHAR(50), capacity FLOAT);
Delete records in the "solar_plants" table where the capacity is less than 50 MW
DELETE FROM solar_plants WHERE capacity < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, name TEXT, speed DECIMAL(5,2), arrived_date DATE, country TEXT); INSERT INTO vessel_performance (id, name, speed, arrived_date, country) VALUES (1, 'Vessel A', 20.2, '2022-06-05', 'UK'), (2, 'Vessel B', 19.8, '2022-06-10', 'UK'), (3, 'Vessel C', 22.6, '2022-06-18', 'UK');
What is the maximum speed recorded for vessels that arrived in the UK in June 2022?
SELECT MAX(speed) FROM vessel_performance WHERE YEAR(arrived_date) = 2022 AND MONTH(arrived_date) = 6 AND country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE event_attendance (event_name VARCHAR(50), attendee_age INT); INSERT INTO event_attendance (event_name, attendee_age) VALUES ('Art in the Park', 35), ('Art in the Park', 42), ('Art in the Park', 31);
What is the average age of attendees who participated in 'Art in the Park' event?
SELECT AVG(attendee_age) FROM event_attendance WHERE event_name = 'Art in the Park';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_class TEXT, expenditure INTEGER);
What was the maximum R&D expenditure for diabetes drugs?
SELECT MAX(expenditure) FROM rd_expenditure WHERE drug_class = 'diabetes';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_averages (id INT, ocean VARCHAR(255), avg_depth FLOAT); INSERT INTO ocean_averages (id, ocean, avg_depth) VALUES (1, 'Pacific', 4000.0), (2, 'Atlantic', 3926.0), (3, 'Indian', 3741.0), (4, 'Arctic', 1208.0), (5, 'Southern', 3738.0);
What is the average depth of the Atlantic ocean?
SELECT avg_depth FROM ocean_averages WHERE ocean = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE public_participation (id INT, country TEXT, budget FLOAT); INSERT INTO public_participation (id, country, budget) VALUES (1, 'Canada', 200000), (2, 'USA', 300000), (3, 'Mexico', 150000);
What is the maximum budget allocated for public participation in Canada?
SELECT MAX(budget) FROM public_participation WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (provider_id INT, name TEXT, state TEXT, cultural_competency_score INT); INSERT INTO providers (provider_id, name, state, cultural_competency_score) VALUES (1, 'Grace', 'Texas', 90), (2, 'Hannah', 'California', 85), (3, 'Ivan', 'National Average', 80);
What is the cultural competency score for providers in Texas, and how does it compare to the national average?
SELECT cultural_competency_score FROM providers WHERE state = 'Texas'; SELECT AVG(cultural_competency_score) FROM providers WHERE role = 'National Average';
gretelai_synthetic_text_to_sql
CREATE TABLE participants (participant_id INT, participant_satisfaction INT, program_id INT); CREATE TABLE programs (program_id INT, facilitator_id INT, program_type VARCHAR(255));
Which restorative justice programs have the highest participant satisfaction rates by facilitator?
SELECT facilitator_name, MAX(AVG(participant_satisfaction)) as avg_satisfaction FROM participants JOIN programs ON programs.program_id = participants.program_id JOIN facilitators ON programs.facilitator_id = facilitators.facilitator_id GROUP BY facilitator_name HAVING program_type = 'Restorative Justice';
gretelai_synthetic_text_to_sql
CREATE TABLE Providers (ProviderID INT, Name VARCHAR(50)); CREATE TABLE CulturalCompetencyScores (ScoreID INT, ProviderID INT, Score INT); INSERT INTO Providers (ProviderID, Name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mary Johnson'); INSERT INTO CulturalCompetencyScores (ScoreID, ProviderID, Score) VALUES (1, 1, 90), (2, 1, 95), (3, 2, 85), (4, 3, 92);
What is the cultural competency score for each provider?
SELECT p.ProviderID, c.Score FROM Providers p INNER JOIN CulturalCompetencyScores c ON p.ProviderID = c.ProviderID;
gretelai_synthetic_text_to_sql
CREATE TABLE co_owned_properties (id INT, neighborhood VARCHAR(50), co_owned BOOLEAN); INSERT INTO co_owned_properties (id, neighborhood, co_owned) VALUES (1, 'Westwood', TRUE), (2, 'Beverly Hills', FALSE), (3, 'Venice', TRUE);
What is the total number of co-owned properties in each neighborhood?
SELECT neighborhood, SUM(co_owned) OVER (PARTITION BY neighborhood) AS total_co_owned FROM co_owned_properties;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramOutcomes (program VARCHAR(255), outcome VARCHAR(255), year INT);
Delete the 'ProgramOutcomes' table.
DROP TABLE ProgramOutcomes;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, country VARCHAR(20), organization_id INT, donation_amount DECIMAL(10, 2), donation_date DATE);
What is the total amount of donations received by organizations in India and Pakistan?
SELECT country, SUM(donation_amount) as total_donations FROM donations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (supplierID int, supplierName varchar(255), country varchar(255), sustainableMaterials varchar(5)); INSERT INTO Suppliers VALUES (1, 'SupplierA', 'France', 'Y'); CREATE TABLE Supply (supplyID int, supplierID int, productID int, date datetime); INSERT INTO Supply VALUES (1, 1, 1, '2022-01-01');
List all suppliers in France that supplied sustainable materials in the last 6 months.
SELECT S.supplierName FROM Suppliers S INNER JOIN Supply Supp ON S.supplierID = Supp.supplierID WHERE S.country = 'France' AND Supp.date >= DATE_SUB(NOW(), INTERVAL 6 MONTH) AND S.sustainableMaterials = 'Y';
gretelai_synthetic_text_to_sql
CREATE TABLE Registrations (RegistrationID INT, UserID INT, RegistrationDate DATETIME, Game VARCHAR(50)); INSERT INTO Registrations (RegistrationID, UserID, RegistrationDate, Game) VALUES (1, 1, '2021-12-10', 'RPG'), (2, 2, '2022-01-05', 'RPG'), (3, 3, '2022-02-25', 'FPS');
How many users registered per month in the 'RPG' genre for the last year?
SELECT MONTH(RegistrationDate), YEAR(RegistrationDate), COUNT(*) as UsersRegistered FROM Registrations WHERE Game = 'RPG' AND RegistrationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY YEAR(RegistrationDate), MONTH(RegistrationDate);
gretelai_synthetic_text_to_sql
CREATE TABLE cities(id INT, name TEXT, state TEXT); INSERT INTO cities VALUES (1, 'City A', 'California'); INSERT INTO cities VALUES (2, 'City B', 'California'); INSERT INTO cities VALUES (3, 'City C', 'California'); CREATE TABLE vehicles(id INT, city_id INT, type TEXT, capacity INT); INSERT INTO vehicles VALUES (1, 1, 'Bus', 50); INSERT INTO vehicles VALUES (2, 1, 'Train', 1000); INSERT INTO vehicles VALUES (3, 2, 'Bus', 40); INSERT INTO vehicles VALUES (4, 2, 'Tram', 300); INSERT INTO vehicles VALUES (5, 3, 'Bus', 60);
What is the number of public transportation vehicles in each city in the state of California, including their type and capacity?
SELECT c.name, v.type, COUNT(*) as vehicle_count, SUM(v.capacity) as total_capacity FROM cities c JOIN vehicles v ON c.id = v.city_id WHERE c.state = 'California' GROUP BY c.name, v.type;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists VisitorStatistics (VisitorID INT, Country VARCHAR(50), TripDuration INT); INSERT INTO VisitorStatistics (VisitorID, Country, TripDuration) VALUES (1, 'Japan', 10), (2, 'India', 15), (3, 'Japan', 11);
What is the average trip duration for visitors from Japan and India?
SELECT AVG(TripDuration) FROM VisitorStatistics WHERE Country IN ('Japan', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (project_year INT, project_status VARCHAR(255));
What is the average number of military innovation projects per year?
SELECT AVG(project_year) FROM military_innovation WHERE project_status = 'completed';
gretelai_synthetic_text_to_sql
CREATE SCHEMA labor_unions; CREATE TABLE unions (id INT PRIMARY KEY, name VARCHAR(255), city VARCHAR(255)); CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(255), union_id INT, FOREIGN KEY (union_id) REFERENCES unions(id)); INSERT INTO unions (id, name, city) VALUES (1, 'Union A', 'New York'), (2, 'Union B', 'Los Angeles'); INSERT INTO employees (id, name, union_id) VALUES (1, 'John Doe', 1), (2, 'Jane Smith', 1);
Calculate the total number of employees in each city
SELECT u.city, COUNT(e.id) AS employee_count FROM labor_unions.unions u INNER JOIN labor_unions.employees e ON u.id = e.union_id GROUP BY u.city;
gretelai_synthetic_text_to_sql
CREATE TABLE packaging (package_id INT, product_id INT, material VARCHAR(20), recyclable BOOLEAN); INSERT INTO packaging (package_id, product_id, material, recyclable) VALUES (1, 1, 'plastic', false), (2, 2, 'glass', true), (3, 3, 'paper', true);
Which product has the most sustainable packaging material?
SELECT product_id, material FROM packaging WHERE recyclable = true ORDER BY LENGTH(material) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE NewsArticles (id INT, title VARCHAR(255), publication_date DATE);
How many news articles were published per day in the last month?
SELECT DATE(publication_date) AS publication_date, COUNT(*) AS articles_per_day FROM NewsArticles WHERE publication_date >= CURDATE() - INTERVAL 1 MONTH GROUP BY publication_date;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturer_data (manufacturer VARCHAR(50), electric_vehicles INT, total_vehicles INT); INSERT INTO manufacturer_data (manufacturer, electric_vehicles, total_vehicles) VALUES ('Tesla', 25000, 50000), ('Nissan', 15000, 30000), ('Chevrolet', 20000, 40000), ('BMW', 25000, 60000), ('Mercedes', 15000, 45000);
Display the number of electric vehicles and total vehicles for each manufacturer
SELECT manufacturer, electric_vehicles, total_vehicles FROM manufacturer_data;
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (site_id INT, year INT, avg_temp DECIMAL(5,2)); INSERT INTO WeatherData (site_id, year, avg_temp) VALUES (7, 1995, 23.7), (7, 1996, 24.2), (7, 1997, 24.5), (7, 1998, 23.8), (7, 1999, 23.9), (7, 2000, 24.3);
What was the average temperature in Cairo during excavations between 1995 and 2000?
SELECT AVG(avg_temp) FROM WeatherData WHERE site_id = 7 AND year BETWEEN 1995 AND 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE Archaeological_Tools (id INT PRIMARY KEY, name VARCHAR(255), type TEXT, age INT);
Insert data about a metal trowel into the Archaeological_Tools table
INSERT INTO Archaeological_Tools (id, name, type, age) VALUES (1, 'Metal Trowel', 'Digging', 5);
gretelai_synthetic_text_to_sql
CREATE TABLE capability_scores (id INT PRIMARY KEY, client_id INT, date DATE, score INT);
What is the lowest financial capability score for each client?
SELECT clients.name, MIN(capability_scores.score) as lowest_score FROM clients JOIN capability_scores ON clients.id = capability_scores.client_id GROUP BY clients.name;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (country VARCHAR(50), operation VARCHAR(50)); INSERT INTO peacekeeping_operations (country, operation) VALUES ('France', 'Mali'), ('France', 'Central African Republic'), ('Germany', 'Afghanistan'), ('Germany', 'Mali'), ('Italy', 'Lebanon'), ('Poland', 'Afghanistan'), ('Spain', 'Western Sahara'), ('Sweden', 'Congo'); CREATE TABLE eu_countries (country VARCHAR(50)); INSERT INTO eu_countries (country) VALUES ('France'), ('Germany'), ('Italy'), ('Poland'), ('Spain'), ('Sweden');
What is the number of peacekeeping operations participated in by each country in the EU?
SELECT pe.country, COUNT(pe.operation) FROM peacekeeping_operations pe INNER JOIN eu_countries ec ON pe.country = ec.country GROUP BY pe.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (TransactionID INT, TransactionAmount DECIMAL(10,2), StrategyID INT); INSERT INTO Transactions (TransactionID, TransactionAmount, StrategyID) VALUES (1, 1000.00, 1); INSERT INTO Transactions (TransactionID, TransactionAmount, StrategyID) VALUES (2, 1500.00, 1); INSERT INTO Transactions (TransactionID, TransactionAmount, StrategyID) VALUES (3, 800.00, 2); INSERT INTO Transactions (TransactionID, TransactionAmount, StrategyID) VALUES (4, 1200.00, 3); CREATE TABLE InvestmentStrategies (StrategyID INT, StrategyName VARCHAR(100), Returns DECIMAL(10,2)); INSERT INTO InvestmentStrategies (StrategyID, StrategyName, Returns) VALUES (1, 'Equity Growth', 12.5); INSERT INTO InvestmentStrategies (StrategyID, StrategyName, Returns) VALUES (2, 'Value Growth', 10.2); INSERT INTO InvestmentStrategies (StrategyID, StrategyName, Returns) VALUES (3, 'Dividend Growth', 9.1);
Find the total transaction amounts and average returns for all strategies with the word "growth" in their name.
SELECT SUM(TransactionAmount) AS TotalTransactionAmount, AVG(Returns) AS AverageReturns FROM Transactions INNER JOIN InvestmentStrategies ON Transactions.StrategyID = InvestmentStrategies.StrategyID WHERE StrategyName LIKE '%growth%';
gretelai_synthetic_text_to_sql
CREATE TABLE nba_players (player_id INT, player_name VARCHAR(255)); INSERT INTO nba_players VALUES (1, 'Player1'), (2, 'Player2'), (3, 'Player3'), (4, 'Player4'); CREATE TABLE nba_finals_stats (game_id INT, player_id INT, minutes_played INT); INSERT INTO nba_finals_stats VALUES (1, 1, 35), (1, 2, 30), (2, 1, 38), (2, 3, 15), (3, 2, 40), (3, 4, 22);
What is the average time spent on the court by each player during the 2022 NBA finals?
SELECT p.player_name, AVG(fs.minutes_played) AS avg_minutes_played FROM nba_players p JOIN nba_finals_stats fs ON p.player_id = fs.player_id GROUP BY p.player_name;
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility (id INT, issue VARCHAR(50), report_date DATE, schema VARCHAR(50)); INSERT INTO accessibility (id, issue, report_date, schema) VALUES (1, 'Issue A', '2022-01-01', 'inclusive_design'), (2, 'Issue B', '2023-01-01', 'inclusive_design'), (3, 'Issue C', '2023-02-01', 'inclusive_design'), (4, 'Issue D', '2023-03-15', 'inclusive_design');
What is the total number of accessibility-related issues reported in 2022 and 2023 in the "accessibility" table of the "inclusive_design" schema?
SELECT COUNT(*) FROM accessibility WHERE schema = 'inclusive_design' AND YEAR(report_date) BETWEEN 2022 AND 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(20)); CREATE TABLE members (id INT, name VARCHAR(50), membership_status VARCHAR(20), state VARCHAR(20)); INSERT INTO workouts (id, user_id, workout_type) VALUES (1, 1, 'Running'), (2, 1, 'Cycling'), (3, 2, 'Running'), (4, 3, 'Cycling'), (5, 3, 'Swimming'), (6, 4, 'Running'), (7, 4, 'Swimming'), (8, 5, 'Yoga'); INSERT INTO members (id, name, membership_status, state) VALUES (1, 'John Doe', 'Basic', 'Texas'), (2, 'Jane Doe', 'Inactive', 'California'), (3, 'Bob Smith', 'Active', 'Texas'), (4, 'Alice Johnson', 'Basic', 'California'), (5, 'Charlie Brown', 'Premium', 'New York');
List the number of users who have completed a workout of a specific type (e.g. Running) and have a membership status of 'Basic'.
SELECT COUNT(*) FROM (SELECT user_id FROM workouts WHERE workout_type = 'Running' EXCEPT SELECT id FROM members WHERE membership_status != 'Basic') AS user_set;
gretelai_synthetic_text_to_sql
CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), Location VARCHAR(50), Date DATE, TicketSales INT); INSERT INTO Festivals (FestivalID, FestivalName, Location, Date, TicketSales) VALUES (1, 'Coachella', 'Indio', '2023-04-14', 150000); INSERT INTO Festivals (FestivalID, FestivalName, Location, Date, TicketSales) VALUES (2, 'Lollapalooza', 'Chicago', '2023-08-04', 120000);
What is the most popular music festival by ticket sales?
SELECT FestivalName, MAX(TicketSales) FROM Festivals;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, habitat_name VARCHAR(50), threat_level VARCHAR(10), area_protected INT);
Delete all records from the 'habitat_preservation' table where the habitat_name is 'Coral Reefs'
DELETE FROM habitat_preservation WHERE habitat_name = 'Coral Reefs';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'North'), (2, 'South'); CREATE TABLE forests (id INT, region_id INT, carbon_sequestration FLOAT); INSERT INTO forests (id, region_id, carbon_sequestration) VALUES (1, 1, 120.5), (2, 1, 150.2), (3, 2, 75.9);
What is the total carbon sequestration for each region?
SELECT r.name, SUM(f.carbon_sequestration) FROM regions r JOIN forests f ON r.id = f.region_id GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE farmer_yields (farmer_id INT, yield_date DATE, crop_yield INT); INSERT INTO farmer_yields (farmer_id, yield_date, crop_yield) VALUES (1, '2021-01-01', 500), (1, '2021-02-01', 600), (2, '2021-01-01', 700), (2, '2021-02-01', 750);
Identify the change in crop yield for each farmer over time, if available.
SELECT farmer_id, yield_date, crop_yield, LAG(crop_yield) OVER (PARTITION BY farmer_id ORDER BY yield_date) AS prev_yield FROM farmer_yields;
gretelai_synthetic_text_to_sql
CREATE TABLE donors_total (donor_id INT, donor_name VARCHAR(255), donation_amount INT); INSERT INTO donors_total (donor_id, donor_name, donation_amount) VALUES (1, 'Amy Pond', 7000), (2, 'Rory Williams', 5000), (3, 'Martha Jones', 6000), (4, 'Donna Noble', 8000), (5, 'Rose Tyler', 9000);
What is the total donation amount for each donor, sorted by the highest total donation?
SELECT donor_name, SUM(donation_amount) AS total_donation FROM donors_total GROUP BY donor_name ORDER BY total_donation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_changes (program TEXT, month INT, num_volunteers INT); INSERT INTO volunteer_changes VALUES ('Feeding Program', 1, 10), ('Education Program', 1, 15), ('Feeding Program', 2, 8), ('Education Program', 2, 12), ('Feeding Program', 3, 12), ('Education Program', 3, 16);
Identify the programs with the largest decrease in volunteers from the previous month.
SELECT program, num_volunteers, LAG(num_volunteers) OVER (PARTITION BY program ORDER BY month) as previous_month_volunteers, num_volunteers - LAG(num_volunteers) OVER (PARTITION BY program ORDER BY month) as volunteer_change FROM volunteer_changes;
gretelai_synthetic_text_to_sql
CREATE TABLE articles_3 (id INT, title TEXT, author TEXT, category TEXT); INSERT INTO articles_3 (id, title, author, category) VALUES (1, 'Article1', 'Alice', 'sports'), (2, 'Article2', 'Bob', 'sports');
Count the number of articles written by male authors in the 'sports' category.
SELECT COUNT(*) FROM articles_3 WHERE author = 'Bob' AND category = 'sports';
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_sectors ( sector_id INT, sector_name TEXT ); INSERT INTO industrial_sectors (sector_id, sector_name) VALUES (1, 'Manufacturing'), (2, 'Agriculture'), (3, 'Mining'), (4, 'Construction'); CREATE TABLE california_water_usage ( id INT, sector_id INT, year INT, water_consumption FLOAT ); INSERT INTO california_water_usage (id, sector_id, year, water_consumption) VALUES (1, 1, 2020, 5000), (2, 2, 2020, 8000), (3, 3, 2020, 3000), (4, 4, 2020, 4000);
What is the total water consumption by each industrial sector in California in 2020?
SELECT i.sector_name, SUM(c.water_consumption) FROM industrial_sectors i JOIN california_water_usage c ON i.sector_id = c.sector_id WHERE c.year = 2020 GROUP BY i.sector_name;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartContracts (ContractID int, CreationDate date); INSERT INTO SmartContracts (ContractID, CreationDate) VALUES (1, '2021-01-01'), (2, '2021-02-15'), (3, '2021-05-03'), (4, '2021-12-30');
How many smart contracts were created per month in 2021?
SELECT EXTRACT(MONTH FROM CreationDate) as Month, COUNT(*) as ContractsPerMonth FROM SmartContracts WHERE CreationDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE trolleybuses (id INT, region VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO trolleybuses (id, region, fare) VALUES (1, 'Delhi', 15.00), (2, 'Delhi', 20.00), (3, 'Mumbai', 12.00);
What is the minimum fare for a trolleybus in the 'Delhi' region?
SELECT MIN(fare) FROM trolleybuses WHERE region = 'Delhi';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists north_american_schema;CREATE TABLE north_american_schema.mining_company (id INT, name VARCHAR, region VARCHAR, role VARCHAR);INSERT INTO north_american_schema.mining_company (id, name, region, role) VALUES (1, 'Canada mining', 'Canada', 'Worker'), (2, 'US mining', 'United States', 'Worker');
What is the total number of workers in 'mining_company' from the 'Canada' region?
SELECT COUNT(*) FROM north_american_schema.mining_company WHERE region = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Bikeshare (id INT, station VARCHAR(30), bike_type VARCHAR(20), total_bikes INT, last_inspection DATE); INSERT INTO Bikeshare (id, station, bike_type, total_bikes, last_inspection) VALUES (5, 'Queens', 'Standard', 12, '2022-01-02'), (6, 'Bronx', 'Standard', 9, '2022-01-01');
What is the average last inspection date for standard bikes?
SELECT bike_type, AVG(DATEDIFF('2000-01-01', last_inspection)) as avg_last_inspection FROM Bikeshare WHERE bike_type = 'Standard' GROUP BY bike_type;
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_teams (id INT, team_name VARCHAR(50), games_played INT, games_won INT); INSERT INTO baseball_teams (id, team_name, games_played, games_won) VALUES (1, 'Yankees', 162, 90), (2, 'Red Sox', 162, 85), (3, 'Dodgers', 162, 95);
What is the total number of games won by each baseball team in the MLB?
SELECT team_name, SUM(games_won) FROM baseball_teams GROUP BY team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (org_id INT, org_name TEXT); CREATE TABLE Donors (donor_id INT, donor_name TEXT, org_id INT);
List all organizations and the total number of unique donors they have, sorted by the number of donors in descending order
SELECT O.org_name, COUNT(DISTINCT D.donor_id) as total_donors FROM Organizations O LEFT JOIN Donors D ON O.org_id = D.org_id GROUP BY O.org_name ORDER BY total_donors DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics; CREATE TABLE if not exists genetics.projects (id INT, name VARCHAR(100), start_date DATE, end_date DATE); INSERT INTO genetics.projects (id, name, start_date, end_date) VALUES (1, 'ProjectX', '2020-01-01', '2021-01-01'), (2, 'ProjectY', '2019-01-01', '2020-01-01'), (3, 'ProjectZ', '2022-01-01', NULL);
Insert a new genetic research project with the name 'ProjectE', a start date of '2023-01-01', and no end date.
INSERT INTO genetics.projects (name, start_date, end_date) VALUES ('ProjectE', '2023-01-01', NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(255), followers INT, continent VARCHAR(255));
Get the number of followers for each user, pivoted by continent in the "users" table
SELECT username, SUM(CASE WHEN continent = 'Africa' THEN followers ELSE 0 END) AS Africa, SUM(CASE WHEN continent = 'Asia' THEN followers ELSE 0 END) AS Asia, SUM(CASE WHEN continent = 'Europe' THEN followers ELSE 0 END) AS Europe, SUM(CASE WHEN continent = 'North America' THEN followers ELSE 0 END) AS North_America, SUM(CASE WHEN continent = 'South America' THEN followers ELSE 0 END) AS South_America, SUM(CASE WHEN continent = 'Oceania' THEN followers ELSE 0 END) AS Oceania FROM users GROUP BY username;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_manufacturing (id INT AUTO_INCREMENT, company_name VARCHAR(50), location VARCHAR(50), ethical_certification VARCHAR(50), PRIMARY KEY(id));
Create a view named 'top_ethical_companies' with the top 5 companies by ethical certification level
CREATE VIEW top_ethical_companies AS SELECT company_name, ethical_certification FROM ethical_manufacturing ORDER BY ethical_certification DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, timestamp TIMESTAMP, indicator_type VARCHAR(255), value VARCHAR(255));
List all threat intelligence data tables and their respective column names.
SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = 'cybersecurity' AND table_name IN ('threat_intelligence', 'malware_signatures', 'ip_reputation', 'url_reputation');
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); CREATE TABLE students (student_id INT, district_id INT, mental_health_score INT); INSERT INTO districts VALUES (1, 'District A'), (2, 'District B'); INSERT INTO students VALUES (1, 1, 60), (2, 1, 75), (3, 2, 45), (4, 2, 30);
What is the total number of students enrolled in each district, and what is the average mental health score for students in each district?
SELECT d.district_name, COUNT(s.student_id) as num_students, AVG(s.mental_health_score) as avg_mental_health_score FROM students s JOIN districts d ON s.district_id = d.district_id GROUP BY s.district_id;
gretelai_synthetic_text_to_sql
CREATE TABLE audits (audit_id INT, location_id INT, audit_date DATE); INSERT INTO audits (audit_id, location_id, audit_date) VALUES (1, 301, '2021-01-01'), (2, 301, '2021-02-01'), (3, 302, '2021-03-01');
How many sustainable sourcing audits have been conducted for location 301?
SELECT COUNT(*) FROM audits WHERE location_id = 301;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT PRIMARY KEY, chemical_name VARCHAR(100), year INT, carbon_emission_tons FLOAT); INSERT INTO environmental_impact (id, chemical_name, year, carbon_emission_tons) VALUES (1, 'XYZ', 2020, 150.5), (2, 'ABC', 2020, 125.3), (3, 'LMN', 2020, 175.8), (4, 'JKL', 2020, 110.0);
Update the environmental_impact table to reflect the current year's carbon emissions for chemical 'JKL'.
UPDATE environmental_impact SET carbon_emission_tons = 115.2 WHERE chemical_name = 'JKL' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE MuseumArtPieces (id INT, museumId INT, artType VARCHAR(50), quantity INT); INSERT INTO MuseumArtPieces (id, museumId, artType, quantity) VALUES (1, 1, 'Modern', 20), (2, 1, 'Ancient', 10), (3, 2, 'Modern', 15), (4, 2, 'Ancient', 25);
What is the total number of art pieces by type in a given museum?
SELECT Museums.name, artType, SUM(quantity) FROM Museums JOIN MuseumArtPieces ON Museums.id = MuseumArtPieces.museumId GROUP BY Museums.name, artType;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, student_name VARCHAR(255), department VARCHAR(255)); CREATE TABLE published_papers (id INT, paper_title VARCHAR(255), student_id INT, PRIMARY KEY (id, student_id), FOREIGN KEY (student_id) REFERENCES graduate_students(id)); INSERT INTO graduate_students (id, student_name, department) VALUES (1, 'Student1', 'Computer Science'), (2, 'Student2', 'Mathematics'), (3, 'Student3', 'Physics'); INSERT INTO published_papers (id, paper_title, student_id) VALUES (1, 'Paper1', 1), (2, 'Paper2', 2), (3, 'Paper3', 3), (4, 'Paper4', 1), (5, 'Paper5', 1);
What is the total number of published papers by each graduate student?
SELECT gs.student_name, COUNT(pp.id) as paper_count FROM graduate_students gs JOIN published_papers pp ON gs.id = pp.student_id GROUP BY gs.student_name;
gretelai_synthetic_text_to_sql
CREATE TABLE member_activities (member_id INT, activity_type VARCHAR(50)); INSERT INTO member_activities (member_id, activity_type) VALUES (1, 'cardio'), (2, 'cardio'), (3, 'strength'), (4, 'cardio'), (5, 'strength');
List all members who have attended 'cardio' and 'strength' classes.
SELECT member_id FROM member_activities WHERE activity_type IN ('cardio', 'strength') GROUP BY member_id HAVING COUNT(DISTINCT activity_type) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearcherExpeditions(researcher VARCHAR(50), expedition VARCHAR(50));INSERT INTO ResearcherExpeditions(researcher, expedition) VALUES('Alice Johnson', 'Expedition 1'), ('Bob Brown', 'Expedition 2'), ('Charlie Green', 'Expedition 3'), ('Alice Johnson', 'Expedition 4');
What is the number of research expeditions led by each researcher?
SELECT researcher, COUNT(DISTINCT expedition) FROM ResearcherExpeditions GROUP BY researcher;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists well (well_id INT, well_name TEXT, location TEXT, oil_production FLOAT); INSERT INTO well (well_id, well_name, location, oil_production) VALUES (1, 'Well A', 'Permian Basin', 12345.67), (2, 'Well B', 'Permian Basin', 23456.78), (3, 'Well C', 'Eagle Ford', 34567.89);
Find the top 3 wells with the highest oil production in the Permian Basin
SELECT well_name, oil_production FROM well WHERE location = 'Permian Basin' ORDER BY oil_production DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE freshwater_farms (id INT, name TEXT, location TEXT, species TEXT, biomass FLOAT); INSERT INTO freshwater_farms (id, name, location, species, biomass) VALUES (1, 'Farm A', 'USA', 'Tilapia', 5000.0), (2, 'Farm B', 'Canada', 'Salmon', 3000.0);
What is the total biomass of fish species in freshwater farms?
SELECT SUM(biomass) FROM freshwater_farms WHERE species IN ('Tilapia', 'Salmon');
gretelai_synthetic_text_to_sql
CREATE TABLE TotalDonations (DonorID INT, Amount DECIMAL(10,2), DonorContinent TEXT, DonationYear INT); INSERT INTO TotalDonations (DonorID, Amount, DonorContinent, DonationYear) VALUES (1, 500.00, 'Africa', 2021), (2, 300.00, 'Europe', 2021), (3, 250.00, 'Africa', 2020);
What is the percentage of total donations made by donors from Africa in the year 2021?
SELECT (COUNT(DonorID) * 100.00 / (SELECT COUNT(DonorID) FROM TotalDonations WHERE DonationYear = 2021)) FROM TotalDonations WHERE DonorContinent = 'Africa' AND DonationYear = 2021;
gretelai_synthetic_text_to_sql
CREATE SCHEMA user_location;CREATE TABLE user_location.user_locations (user_id INT, location VARCHAR(30));
What is the distribution of user locations in the 'user_location' schema?
SELECT location, COUNT(user_id) FROM user_location.user_locations GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, district VARCHAR(255), crime_date DATE, crime_type VARCHAR(255)); INSERT INTO crimes (id, district, crime_date, crime_type) VALUES (1, 'District X', '2023-02-15', 'Theft'), (2, 'District Y', '2023-02-16', 'Vandalism');
Insert new crime records for the last week
INSERT INTO crimes (id, district, crime_date, crime_type) VALUES (3, 'District Z', CURRENT_DATE - INTERVAL '3 days', 'Assault'), (4, 'District W', CURRENT_DATE - INTERVAL '1 day', 'Harassment');
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (flight_id INT, flight_date DATE, carrier VARCHAR(255), event VARCHAR(255), outcome VARCHAR(255));
Insert a new record into the flight_safety table with the following details: Flight ID 32, Flight Date '2023-03-03', Carrier 'SpaceX', Event 'Engine Failure', Outcome 'Success'
INSERT INTO flight_safety (flight_id, flight_date, carrier, event, outcome) VALUES (32, '2023-03-03', 'SpaceX', 'Engine Failure', 'Success');
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (state VARCHAR(2), metric FLOAT); INSERT INTO health_equity_metrics (state, metric) VALUES ('CA', 0.85), ('NY', 0.87), ('TX', 0.82);
What is the health equity metric for California and Texas?
SELECT state, metric FROM health_equity_metrics WHERE state IN ('CA', 'TX');
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (MuseumID INT, MuseumName VARCHAR(100), TotalArtworks INT); INSERT INTO Museums (MuseumID, MuseumName, TotalArtworks) VALUES (1, 'Metropolitan Museum of Art', 190000), (2, 'British Museum', 8000000), (3, 'Louvre Museum', 480000);
Find the top 3 museums with the highest number of total artworks, across all categories, including paintings, sculptures, and mixed media.
SELECT MuseumName FROM (SELECT MuseumName, ROW_NUMBER() OVER (ORDER BY TotalArtworks DESC) as rank FROM Museums) AS subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, country TEXT, date DATE, unique_views INT); INSERT INTO virtual_tours (tour_id, country, date, unique_views) VALUES (1, 'Spain', '2022-01-01', 50), (2, 'Spain', '2022-02-01', 60), (3, 'Spain', '2022-03-01', 70);
What is the total number of unique views of virtual tours in Spain in the last year?
SELECT SUM(unique_views) FROM virtual_tours WHERE country = 'Spain' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE CharityEvents (ID INT, EventName VARCHAR(255), EventDate DATE, Attendees INT); CREATE TABLE Donations (ID INT, EventID INT, Donor VARCHAR(255), Donation DECIMAL(10,2));
What is the correlation between the number of attendees and the average donation per attendee for charity events?
SELECT c.EventName, AVG(d.Donation) as AverageDonation, COUNT(c.Attendees) as AttendeesCount, AVG(d.Donation) * COUNT(c.Attendees) as Correlation FROM CharityEvents c JOIN Donations d ON c.ID = d.EventID GROUP BY c.EventName;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name TEXT, country TEXT); INSERT INTO regions VALUES (1, 'Amazonas', 'Colombia'); INSERT INTO regions VALUES (2, 'Boyaca', 'Colombia'); CREATE TABLE aid (id INT, region_id INT, sector TEXT, amount INT, aid_date YEAR); INSERT INTO aid VALUES (1, 1, 'health', 5000, 2019);
What are the top 3 regions in Colombia that received the most humanitarian aid in the 'health' sector in 2019, and the total amount donated to each?
SELECT regions.name, SUM(aid.amount) FROM aid INNER JOIN regions ON aid.region_id = regions.id WHERE regions.country = 'Colombia' AND aid.sector = 'health' AND aid.aid_date = 2019 GROUP BY regions.id ORDER BY SUM(aid.amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name TEXT, gender TEXT, mental_health_issues TEXT); INSERT INTO students (id, name, gender, mental_health_issues) VALUES (1, 'Alice', 'Female', 'Anxiety, Depression'); INSERT INTO students (id, name, gender, mental_health_issues) VALUES (2, 'Bob', 'Male', 'Anxiety'); INSERT INTO students (id, name, gender, mental_health_issues) VALUES (3, 'Charlie', 'Non-binary', 'Depression');
What is the most common mental health issue among students?
SELECT mental_health_issues, COUNT(*) AS count FROM students GROUP BY mental_health_issues ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, incident_date DATE, incident_type VARCHAR(50), description TEXT);
Which cybersecurity incidents were reported in the last 3 months?
SELECT * FROM cybersecurity_incidents WHERE incident_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(20), DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, Name, Age, Gender, DonationAmount) VALUES (1, 'Alex Doe', 30, 'Non-binary', 250.00); CREATE TABLE Organizations (OrganizationID INT, Name VARCHAR(50), Sector VARCHAR(20)); INSERT INTO Organizations (OrganizationID, Name, Sector) VALUES (2, 'LGBTQ+ Rights', 'LGBTQ+ Rights');
What is the average donation amount for donors in the 'LGBTQ+ Rights' sector?
SELECT AVG(DonationAmount) FROM Donors INNER JOIN Organizations ON Donors.DonorID = Organizations.OrganizationID WHERE Sector = 'LGBTQ+ Rights';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT, unloaded_weight FLOAT); INSERT INTO ports (port_id, port_name, country, unloaded_weight) VALUES (1, 'Algeciras', 'Spain', 123456.78), (2, 'Valencia', 'Spain', 987654.32);
What is the average weight of cargo handled by each port in Spain?
SELECT port_name, AVG(unloaded_weight) FROM ports WHERE country = 'Spain' GROUP BY port_name;
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policy_trends (id INT, policy_name VARCHAR(255), region VARCHAR(255)); INSERT INTO clean_energy_policy_trends (id, policy_name, region) VALUES (1, 'Solar Subsidies', 'Asia'), (2, 'Wind Power Expansion', 'Europe');
What is the number of clean energy policy trends in 'Asia' region?
SELECT COUNT(*) FROM clean_energy_policy_trends WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ID INT, Violation INT, Date DATE); INSERT INTO MentalHealthParity (ID, Violation, Date) VALUES (1, 5, '2021-02-01'), (2, 3, '2021-03-15'), (3, 7, '2022-01-01');
How many mental health parity violations were recorded in Canada in the last year?
SELECT COUNT(*) FROM MentalHealthParity WHERE Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND Country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_data (region VARCHAR(255), year INT, anomaly FLOAT); INSERT INTO climate_data (region, year, anomaly) VALUES ('North America', 2016, 1.2), ('North America', 2017, 1.5), ('South America', 2018, 1.4), ('Asia', 2019, 1.8), ('Asia', 2020, 1.6), ('Africa', 2021, 2.0), ('South America', 2020, 1.3), ('South America', 2021, 1.7);
What is the average temperature anomaly for 'South America'?
SELECT AVG(anomaly) FROM climate_data WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name VARCHAR(50), continent VARCHAR(50)); CREATE TABLE SmartCityProjects (id INT, name VARCHAR(50), country VARCHAR(50), projectType VARCHAR(50)); INSERT INTO SmartCityProjects (id, name, country, projectType) SELECT 1, 'Smart Grid', 'USA', 'Smart City'; INSERT INTO SmartCityProjects (id, name, country, projectType) SELECT 2, 'Smart Lighting', 'Canada', 'Smart City'; INSERT INTO SmartCityProjects (id, name, country, projectType) SELECT 3, 'Smart Waste Management', 'Mexico', 'Smart City'; INSERT INTO Countries (id, name, continent) SELECT 1 as id, 'USA' as name, 'North America' as continent UNION SELECT 2 as id, 'Canada' as name, 'North America' as continent UNION SELECT 3 as id, 'Mexico' as name, 'North America' as continent;
Identify the number of smart city projects in the 'SmartCityProjects' table for each country, grouped by continent in the 'Countries' table.
SELECT C.continent, COUNT(SCP.country) as num_projects FROM SmartCityProjects SCP JOIN Countries C ON SCP.country = C.name GROUP BY C.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Expeditions(ExpeditionID INT, AvgDepth DECIMAL(5,2), MaxDepth INT); INSERT INTO Expeditions(ExpeditionID, AvgDepth, MaxDepth) VALUES (1, 3500.50, 6500), (2, 4200.30, 4200), (3, 2100.75, 2100), (4, 5100.90, 5100), (5, 2900.40, 7000);
Delete all expeditions that have a maximum depth less than the average depth of all expeditions?
DELETE FROM Expeditions WHERE MaxDepth < (SELECT AVG(AvgDepth) FROM Expeditions);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE purchases (id INT, customer_id INT, product_id INT, quantity INT); CREATE TABLE products (id INT, name VARCHAR(50), cruelty_free BOOLEAN);
Get the name and country of the top 2 customers for cruelty-free cosmetics
SELECT customers.name, customers.country FROM customers JOIN purchases ON customers.id = purchases.customer_id JOIN products ON purchases.product_id = products.id WHERE products.cruelty_free = TRUE GROUP BY customers.id ORDER BY SUM(purchases.quantity) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT PRIMARY KEY, name VARCHAR(255), industry VARCHAR(255), funding FLOAT); CREATE TABLE gene (id INT PRIMARY KEY, name VARCHAR(255), function VARCHAR(255), company_id INT, biosensor_type VARCHAR(255)); INSERT INTO company (id, name, industry, funding) VALUES (1, 'BioGen', 'Biotechnology', 50000000), (2, 'BioSense', 'Biosensor Technology', 20000000); INSERT INTO gene (id, name, function, company_id, biosensor_type) VALUES (1, 'GeneA', 'Growth', 1, 'pH'), (2, 'GeneB', 'Metabolism', 2, 'Temperature'), (3, 'GeneC', 'Development', 1, NULL);
What is the average funding for genes related to biosensors of type 'pH'?
SELECT AVG(c.funding) FROM company c JOIN gene g ON c.id = g.company_id WHERE g.biosensor_type = 'pH';
gretelai_synthetic_text_to_sql
CREATE TABLE local_businesses (business_id INT, business_name TEXT, sustainable_tourism_benefit DECIMAL(5,2)); INSERT INTO local_businesses (business_id, business_name, sustainable_tourism_benefit) VALUES (1, 'Small Artisan Shop', 23456.78), (2, 'Family-owned Restaurant', 12345.67);
Which local businesses have benefited the most from sustainable tourism initiatives?
SELECT business_name, sustainable_tourism_benefit FROM local_businesses ORDER BY sustainable_tourism_benefit DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name TEXT, campaign TEXT, amount INT, donation_date DATE); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (1, 'John Doe', 'Climate Action', 50, '2020-01-01'); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (2, 'Jane Smith', 'Climate Action', 100, '2020-05-15'); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (3, 'Michael Lee', 'Climate Action', 25, '2020-12-31');
What is the total donation amount received for the 'Climate Action' campaign in 2020?
SELECT SUM(amount) FROM donations WHERE campaign = 'Climate Action' AND YEAR(donation_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID int, Name varchar(50), Type varchar(50), AverageSpeed float, ComplianceStatus varchar(50)); CREATE TABLE Cargo (CargoID int, VesselID int, MaterialType varchar(50), Tonnage int, TransportDate date); INSERT INTO Vessels VALUES (1, 'Vessel1', 'Transport', 15, 'Non-Compliant'); INSERT INTO Cargo VALUES (1, 1, 'Non-Hazardous', 100, '2022-01-01');
What is the total tonnage of cargo shipped by vessels that did not comply with safety regulations in the last year?
SELECT SUM(C.Tonnage) FROM Cargo C INNER JOIN Vessels V ON C.VesselID = V.VesselID WHERE V.ComplianceStatus = 'Non-Compliant' AND C.TransportDate >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, country VARCHAR(20), project_name VARCHAR(50), project_budget FLOAT); INSERT INTO agricultural_projects (id, country, project_name, project_budget) VALUES (1, 'Senegal', 'Precision Agriculture', 120000.00), (2, 'Senegal', 'Drip Irrigation', 90000.00);
Which agricultural innovation projects in Senegal have the highest budget?
SELECT project_name, project_budget, RANK() OVER (ORDER BY project_budget DESC) AS rank FROM agricultural_projects WHERE country = 'Senegal' HAVING rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE country (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE incident (id INT PRIMARY KEY, country_id INT, region_id INT, reported_date DATE, type VARCHAR(255)); INSERT INTO country (id, name) VALUES (1, 'Russia'), (2, 'China'), (3, 'Brazil'); INSERT INTO region (id, name) VALUES (1, 'Asia'), (2, 'South America'); INSERT INTO incident (id, country_id, region_id, reported_date, type) VALUES (1, 1, 1, '2008-12-31', 'Ransomware'), (2, 2, 2, '2009-12-31', 'Ransomware');
Delete all cybersecurity incidents related to 'Ransomware' attacks reported before January 1, 2010.
DELETE FROM incident WHERE type = 'Ransomware' AND reported_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE STORES(city VARCHAR(20), type VARCHAR(20)); INSERT INTO STORES(city, type) VALUES('Tokyo', 'Sustainable Fashion'), ('Tokyo', 'Fast Fashion'), ('Tokyo', 'Luxury'), ('Seoul', 'Sustainable Fashion'), ('Seoul', 'Fast Fashion'), ('Seoul', 'Luxury');
What is the difference in the number of sustainable fashion stores between Tokyo and Seoul?
SELECT (SELECT COUNT(*) FROM STORES WHERE city = 'Tokyo' AND type = 'Sustainable Fashion') - (SELECT COUNT(*) FROM STORES WHERE city = 'Seoul' AND type = 'Sustainable Fashion');
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists research; USE research; CREATE TABLE if not exists studies (id INT, name VARCHAR(100), country VARCHAR(100), continent VARCHAR(100)); INSERT INTO studies (id, name, country, continent) VALUES (1, 'StudyA', 'USA', 'North America'), (2, 'StudyB', 'Canada', 'North America'), (3, 'StudyC', 'Brazil', 'South America'), (4, 'StudyD', 'China', 'Asia'), (5, 'StudyE', 'Japan', 'Asia'), (6, 'StudyF', 'Australia', 'Australia'), (7, 'StudyG', 'India', 'Asia'), (8, 'StudyH', 'Germany', 'Europe'), (9, 'StudyI', 'France', 'Europe'), (10, 'StudyJ', 'UK', 'Europe');
Find the total number of genetic research studies conducted in each country, grouped by continent.
SELECT studies.continent, studies.country, COUNT(studies.id) FROM research.studies GROUP BY studies.continent, studies.country ORDER BY COUNT(studies.id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR(255), city VARCHAR(255), revenue FLOAT); CREATE TABLE Menu (id INT, rest_id INT, item VARCHAR(255), price FLOAT);
List the cities with restaurants that have an average menu item price above the overall average price.
SELECT R.city, AVG(M.price) as avg_price FROM Restaurants R JOIN Menu M ON R.id = M.rest_id GROUP BY R.city HAVING AVG(M.price) > (SELECT AVG(price) FROM Menu);
gretelai_synthetic_text_to_sql