context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE social_media_users_roles (user_id INT, role VARCHAR(20)); INSERT INTO social_media_users_roles (user_id, role) VALUES (1, 'regular_user'), (2, 'content_creator'), (3, 'partner'), (4, 'content_creator'), (5, 'regular_user'); CREATE TABLE social_media_posts (post_id INT, user_id INT, likes_count INT); INSERT...
What is the total number of posts made by users with the role "content_creator" in the "social_media_users_roles" table?
SELECT SUM(likes_count) FROM social_media_posts WHERE user_id IN (SELECT user_id FROM social_media_users_roles WHERE role = 'content_creator');
gretelai_synthetic_text_to_sql
CREATE TABLE food_recalls (id INT PRIMARY KEY, product VARCHAR(100), recall_date DATE);
Delete all records from the 'food_recalls' table that have a 'recall_date' before '2019-01-01'
DELETE FROM food_recalls WHERE recall_date < '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), accommodation_needs VARCHAR(50)); CREATE TABLE assistive_tech_services (id INT, student_id INT, service_date DATE, service_type VARCHAR(50));
What is the total number of students who have utilized assistive technology services in the past year, grouped by their accommodation needs?
SELECT accommodation_needs, COUNT(*) as total FROM students s JOIN assistive_tech_services ats ON s.id = ats.student_id WHERE service_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY accommodation_needs;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, ethnicity VARCHAR(20), region VARCHAR(25)); CREATE TABLE certifications (id INT PRIMARY KEY, farmer_id INT, name VARCHAR(50), authority VARCHAR(50)); INSERT INTO farmers (id, name, age, ethnicity, region) VALUES (1, 'Emma Johnson', 35, 'Caucasian', 'N...
Which farmers in the Northeast have no certifications and what are their names?
SELECT f.name FROM farmers f LEFT JOIN certifications c ON f.id = c.farmer_id WHERE f.region = 'Northeast' AND c.name IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (area_id INT, area_name VARCHAR(50), member_id INT, member_name VARCHAR(50), age INT);
Get the names and ages of all community members living in 'rural_area_1' from the 'community_development' table
SELECT member_name, age FROM community_development WHERE area_name = 'rural_area_1';
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperature(field_id INT, temperature DECIMAL(5,2), date DATE); INSERT INTO field_temperature(field_id, temperature, date) VALUES (1, 23.5, '2022-05-01'), (1, 24.3, '2022-05-02'), (1, 25.1, '2022-05-03'), (1, 26.2, '2022-05-04'), (1, 24.8, '2022-05-05'), (1, 22.9, '2022-05-06'), (1, 21.8, '2022-05-07...
What is the average temperature in field 1 over the last 7 days?
SELECT AVG(temperature) FROM field_temperature WHERE field_id = 1 AND date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE market_approval (approval_id INT, drug_id INT, approval_date DATE); INSERT INTO market_approval (approval_id, drug_id, approval_date) VALUES (1, 1, '2020-03-01'), (2, 2, '2019-06-15'), (3, 3, '2017-09-30');
What is the average time to market approval (in months) for drugs in the market_approval table, grouped by drug name?
SELECT drug_id, AVG(DATEDIFF('month', MIN(approval_date), MAX(approval_date))) AS avg_time_to_market_approval FROM market_approval GROUP BY drug_id;
gretelai_synthetic_text_to_sql
CREATE TABLE public.vehicles (id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO public.vehicles (id, type, city) VALUES (1, 'electric_car', 'San Francisco'), (2, 'conventional_car', 'San Francisco'), (3, 'electric_bus', 'Los Angeles'), (4, 'conventional_bus', 'Los Angeles'), (5, 'electric_car', 'New York'), (6, ...
Show the total number of vehicles in 'New York' and 'Los Angeles'
SELECT SUM(cnt) FROM (SELECT city, COUNT(*) AS cnt FROM public.vehicles GROUP BY city HAVING city IN ('New York', 'Los Angeles')) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (Fid INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Area FLOAT); CREATE TABLE Harvest (Hid INT PRIMARY KEY, Fid INT, Year INT, Volume INT, FOREIGN KEY (Fid) REFERENCES Forests(Fid));
What are the names of forests in the United States and their respective annual harvest volumes, if any?
SELECT Forests.Name, Harvest.Year, Harvest.Volume FROM Forests LEFT JOIN Harvest ON Forests.Fid = Harvest.Fid WHERE Forests.Country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerName VARCHAR(255), TournamentLosses INT); INSERT INTO Players (PlayerName, TournamentLosses) VALUES ('PlayerA', 4), ('PlayerB', 7), ('PlayerC', 2), ('PlayerD', 6), ('PlayerE', 5);
Who are the eSports players with the most losses in "Rainbow Six Siege" tournaments?
SELECT PlayerName FROM Players WHERE TournamentLosses = (SELECT MAX(TournamentLosses) FROM Players);
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (SaleID INT, VehicleID INT, Country TEXT, SaleDate DATE);
How many electric vehicles have been sold in the United States in Q1 and Q2 of 2023?
SELECT COUNT(*) FROM SalesData WHERE Country = 'United States' AND SaleDate >= '2023-01-01' AND SaleDate < '2023-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, patient_id INT, country VARCHAR(255), date DATE); INSERT INTO campaigns (id, patient_id, country, date) VALUES (1, 1, 'South Korea', '2022-01-01'), (2, 2, 'Canada', '2022-02-01'), (3, 3, 'South Korea', '2022-03-01');
How many public awareness campaigns have been conducted in South Korea in the past year?
SELECT COUNT(*) FROM campaigns WHERE country = 'South Korea' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_contributors (id INT, contributor TEXT, contributions INT); INSERT INTO ethical_ai_contributors (id, contributor, contributions) VALUES (1, 'Alice', 100), (2, 'Bob', 150), (3, 'Charlie', 80), (4, 'David', 120);
Who are the top contributors to open-source ethical AI projects?
SELECT contributor FROM ethical_ai_contributors ORDER BY contributions DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatIntelligence (id INT, region VARCHAR(20), severity VARCHAR(10), incident_date DATE); INSERT INTO ThreatIntelligence (id, region, severity, incident_date) VALUES (1, 'Middle East', 'High', '2020-02-11'); INSERT INTO ThreatIntelligence (id, region, severity, incident_date) VALUES (2, 'Middle East', 'Lo...
What is the total number of cybersecurity incidents reported in the Middle East, grouped by severity level, for the year 2020?
SELECT severity, COUNT(*) as total_incidents FROM ThreatIntelligence WHERE region = 'Middle East' AND incident_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY severity;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount int); INSERT INTO Donors (Donor_ID, Name, Donation_Amount) VALUES (1, 'John Doe', 7000), (2, 'Jane Smith', 3000), (3, 'Mike Johnson', 4000);
delete from Donors where Donation_Amount < 5000
DELETE FROM Donors WHERE Donation_Amount < 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE user (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), created_at TIMESTAMP); INSERT INTO user (id, name, age, gender, created_at) VALUES (1, 'John Doe', 25, 'Male', '2021-01-01 10:00:00'); CREATE TABLE post (id INT, user_id INT, content TEXT, posted_at TIMESTAMP); INSERT INTO post (id, user_id, cont...
What is the average age of users who have made a post in the 'social_media' schema?
SELECT AVG(user.age) FROM user JOIN post ON user.id = post.user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE agri_innovation (id INT, name TEXT, location TEXT, implementation_year INT, budget INT); INSERT INTO agri_innovation (id, name, location, implementation_year, budget) VALUES (1, 'Precision Agriculture', 'Southeast Asia', 2018, 500000), (2, 'Smart Farming', 'Southeast Asia', 2019, 700000);
What is the total budget for agricultural innovation projects in Southeast Asia implemented after 2017?
SELECT SUM(agri_innovation.budget) FROM agri_innovation WHERE agri_innovation.location = 'Southeast Asia' AND agri_innovation.implementation_year > 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE City_Hotels (city VARCHAR(50), hotel_count INT, avg_rating DECIMAL(2,1)); INSERT INTO City_Hotels (city, hotel_count, avg_rating) VALUES ('New York', 250, 4.2), ('Los Angeles', 300, 4.3), ('Chicago', 180, 4.5);
Which city has the highest average rating in the 'City_Hotels' table?
SELECT city, AVG(avg_rating) FROM City_Hotels GROUP BY city ORDER BY AVG(avg_rating) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate) VALUES (1, 'Organization', 'Nigeria', 10000, '2020-01-01'), (2, 'Individual', 'Egypt', 5000, '2020-02-01'), (3, 'Or...
What is the total amount donated by organizations in Africa in each year?
SELECT YEAR(DonationDate) as Year, SUM(AmountDonated) as TotalDonated FROM Donors WHERE DonorType = 'Organization' AND Country LIKE 'Africa%' GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE Disease_Prevalence (Disease VARCHAR(50), Continent VARCHAR(50), Prevalence FLOAT); INSERT INTO Disease_Prevalence (Disease, Continent, Prevalence) VALUES ('Diabetes', 'Asia', 9.0), ('Hypertension', 'Asia', 22.0);
What is the prevalence of diabetes in Asia?
SELECT Prevalence FROM Disease_Prevalence WHERE Disease = 'Diabetes';
gretelai_synthetic_text_to_sql
CREATE TABLE Song (Platform VARCHAR(20), Genre VARCHAR(10), Duration FLOAT); INSERT INTO Song (Platform, Genre, Duration) VALUES ('Youtube', 'HipHop', 3.15), ('Youtube', 'Pop', 4.23), ('AppleMusic', 'HipHop', 2.87), ('AppleMusic', 'Pop', 3.12);
What is the average duration of songs in the hip-hop genre on Youtube and AppleMusic?
SELECT Platform, AVG(Duration) FROM Song WHERE Genre = 'HipHop' AND (Platform = 'Youtube' OR Platform = 'AppleMusic') GROUP BY Platform;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, SignUpDate date); INSERT INTO Volunteers (VolunteerID, SignUpDate) VALUES (1, '2022-01-03'), (2, '2022-02-14');
How many new volunteers signed up in each month of 2022?
SELECT DATE_FORMAT(SignUpDate, '%Y-%m') as Month, COUNT(VolunteerID) as NewVolunteers FROM Volunteers WHERE YEAR(SignUpDate) = 2022 GROUP BY Month ORDER BY Month ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO restaurants (id, name, category) VALUES (1, 'Restaurant G', 'Fast Food'); INSERT INTO restaurants (id, name, category) VALUES (2, 'Restaurant H', 'Casual Dining');CREATE TABLE orders (id INT, restaurant_id INT, supplier_id INT, quant...
Who are the suppliers for restaurants in the 'Fast Food' category, and what is the total quantity of food supplied by them?
SELECT s.name AS supplier_name, SUM(o.quantity) AS total_quantity FROM suppliers s INNER JOIN orders o ON s.id = o.supplier_id INNER JOIN restaurants r ON o.restaurant_id = r.id WHERE r.category = 'Fast Food' GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (appliance TEXT, rating FLOAT); INSERT INTO energy_efficiency (appliance, rating) VALUES ('Refrigerator A', 5.0), ('Washing Machine B', 3.5), ('Television C', 2.5), ('Dishwasher D', 4.0);
What is the energy efficiency rating of appliances in the United States?
SELECT appliance, rating FROM energy_efficiency WHERE appliance IN ('Refrigerator A', 'Washing Machine B', 'Television C', 'Dishwasher D');
gretelai_synthetic_text_to_sql
CREATE TABLE waste_processing_facilities (id INT, facility_name TEXT, province TEXT, landfill_capacity INT); INSERT INTO waste_processing_facilities (id, facility_name, province, landfill_capacity) VALUES (1, 'Facility A', 'Alberta', 120000), (2, 'Facility B', 'Alberta', 80000);
How many waste processing facilities are there in the province of Alberta, Canada, that have a landfill capacity over 100000 tons?
SELECT COUNT(*) FROM waste_processing_facilities WHERE province = 'Alberta' AND landfill_capacity > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft_maintenance (id INT, incident_number VARCHAR(255), region VARCHAR(255), date DATE);
How many aircraft maintenance incidents were reported in the Middle East region in the last 12 months?
SELECT COUNT(*) FROM aircraft_maintenance WHERE region = 'Middle East' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name TEXT, start_date DATE, end_date DATE);
Insert a new row into carbon_offset_programs table for a program with id 5, name 'Bike to Work', start_date 2023-01-01 and end_date 2024-12-31
INSERT INTO carbon_offset_programs (id, name, start_date, end_date) VALUES (5, 'Bike to Work', '2023-01-01', '2024-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_cases(attorney_id INT, case_id INT, district VARCHAR(20), opened_date DATE); INSERT INTO attorney_cases(attorney_id, case_id, district, opened_date) VALUES (1, 101, 'Southeast', '2021-03-01'), (2, 102, 'Northeast', '2021-08-15'), (3, 103, 'Southeast', '2021-11-29'), (1, 104, 'Southeast', '2021-05-...
How many cases were opened for each attorney in the 'Southeast' district in 2021?
SELECT attorney_id, COUNT(*) FROM attorney_cases WHERE district = 'Southeast' AND YEAR(opened_date) = 2021 GROUP BY attorney_id;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_trend (date DATE, school_id INT, mental_health_score INT); INSERT INTO mental_health_trend (date, school_id, mental_health_score) VALUES ('2022-01-01', 101, 80), ('2022-01-02', 101, 75), ('2022-01-03', 102, 85), ('2022-01-04', 102, 90), ('2022-02-01', 101, 82), ('2022-02-02', 101, 78), ('2022...
What is the trend of student mental health scores in the last 6 months?
SELECT date, mental_health_score, ROW_NUMBER() OVER (ORDER BY date) as rank FROM mental_health_trend WHERE date >= DATEADD(month, -6, CURRENT_TIMESTAMP) ORDER BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArts (ID INT, ArtForm TEXT, PracticedIn TEXT); INSERT INTO TraditionalArts (ID, ArtForm, PracticedIn) VALUES (1, 'Batik', 'Indonesia'), (2, 'Kabuki', 'Japan');
How many traditional art forms are practiced in 'Asia-Pacific'?
SELECT COUNT(*) FROM TraditionalArts WHERE PracticedIn = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE VeganLeatherManufacturing (id INT, water_consumption DECIMAL); INSERT INTO VeganLeatherManufacturing (id, water_consumption) VALUES (1, 1200), (2, 1300), (3, 1250), (4, 1100), (5, 1350);
What is the average water consumption of manufacturing processes using vegan leather?
SELECT AVG(water_consumption) FROM VeganLeatherManufacturing;
gretelai_synthetic_text_to_sql
CREATE TABLE species_discoveries (species_id INT, discovery_year INT);
How many species have been discovered since 2015?
SELECT COUNT(*) FROM species_discoveries WHERE discovery_year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Students (id INT PRIMARY KEY, age INT, gender VARCHAR(10), art_school_id INT, FOREIGN KEY (art_school_id) REFERENCES ArtSchools(id)); INSERT INTO Students (id, age, gender, art_school_id) VALUES (1, 22, 'Female', 1); INSERT INTO Students (id, age, gender, art_school_id) VALUES (2, 25, 'Male', 2);
What is the average age of students attending art schools in New York?
SELECT AVG(Students.age) as avg_age FROM Students JOIN ArtSchools ON Students.art_school_id = ArtSchools.id WHERE ArtSchools.city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE residential_waste (city VARCHAR(50), generation_rate FLOAT); INSERT INTO residential_waste (city, generation_rate) VALUES ('CityA', 1.2), ('CityB', 1.5), ('CityC', 0.9);
What is the average waste generation rate per capita in the residential sector across all cities in the country?
SELECT AVG(generation_rate) FROM residential_waste;
gretelai_synthetic_text_to_sql
CREATE TABLE factory (id INT, name VARCHAR(255), location VARCHAR(255), capacity INT, renewable_energy BOOLEAN); INSERT INTO factory (id, name, location, capacity, renewable_energy) VALUES (1, 'Factory A', 'Los Angeles', 1000, TRUE); INSERT INTO factory (id, name, location, capacity, renewable_energy) VALUES (2, 'Facto...
List all factories that use renewable energy sources.
SELECT * FROM factory WHERE renewable_energy = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE RocketLaunches (id INT, company VARCHAR(50), launch_date DATE, launch_status VARCHAR(50), number_of_satellites INT);
List the number of successful and failed rocket launches by 'United Launch Alliance' in the last 2 years?
SELECT company, launch_status, COUNT(*) FROM RocketLaunches WHERE company = 'United Launch Alliance' AND launch_date >= DATEADD(year, -2, GETDATE()) GROUP BY company, launch_status;
gretelai_synthetic_text_to_sql
CREATE TABLE AffordableHousing (id INT, state VARCHAR(20), size FLOAT);
List all affordable housing units in the state of California that have a size greater than 1500 square feet.
SELECT * FROM AffordableHousing WHERE state = 'California' AND size > 1500;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (initiative VARCHAR(50), funding DECIMAL(10,2)); INSERT INTO climate_adaptation (initiative, funding) VALUES ('Coastal Flood Protection', 3000000), ('Drought Resistant Agriculture', 2500000), ('Heat Resilient Infrastructure', 4000000);
List the unique climate adaptation initiatives in Europe and their respective funding amounts.
SELECT DISTINCT initiative, funding FROM climate_adaptation WHERE initiative IN ('Coastal Flood Protection', 'Drought Resistant Agriculture', 'Heat Resilient Infrastructure', 'Urban Green Spaces', 'Climate Migration Support');
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, property_id INT, city TEXT, size INT); INSERT INTO properties (id, property_id, city, size) VALUES (1, 101, 'Austin', 1200), (2, 102, 'Seattle', 900), (3, 103, 'Austin', 1500), (4, 106, 'Portland', 1400), (5, 107, 'Portland', 1600), (6, 108, 'Seattle', 1800), (7, 109, 'Seattle', 1900);
What is the total number of properties in the city of Seattle?
SELECT COUNT(*) FROM properties WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, continent TEXT, project_type TEXT, finance_amount FLOAT);
What is the maximum and minimum finance amount spent on climate adaptation projects in each continent?
SELECT continent, MAX(finance_amount) as max_finance, MIN(finance_amount) as min_finance FROM climate_finance WHERE project_type = 'adaptation' GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (Astronaut_ID INT, Name VARCHAR(50), Gender VARCHAR(10), Age INT, Agency VARCHAR(50)); INSERT INTO Astronauts (Astronaut_ID, Name, Gender, Age, Agency) VALUES (1, 'Jeremy Hansen', 'Male', 43, 'CSA'); CREATE TABLE Missions (Mission_ID INT, Mission_Name VARCHAR(50), Satellite_Name VARCHAR(50), Age...
What space missions have astronauts from the Canadian Space Agency (CSA) participated in?
SELECT m.Mission_Name, a.Name, a.Agency FROM Astronauts a RIGHT JOIN Missions m ON a.Agency = m.Agency WHERE a.Agency = 'CSA';
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policy_id INT, policyholder_age INT, policy_type VARCHAR(20)); CREATE TABLE policies (policy_id INT, policy_state VARCHAR(2));
List all policyholders with home insurance policies in Texas who are over 60 years old
SELECT DISTINCT policyholder_age, policy_type FROM policyholders JOIN policies ON policyholders.policy_id = policies.policy_id WHERE policies.policy_state = 'TX' AND policyholder_age > 60;
gretelai_synthetic_text_to_sql
CREATE TABLE police_reports (id INT, report_type VARCHAR(255), report_date TIMESTAMP); INSERT INTO police_reports (id, report_type, report_date) VALUES (1, 'Theft', '2022-01-01 12:00:00'); CREATE TABLE ninety_one_calls (id INT, call_type VARCHAR(255), call_date TIMESTAMP); INSERT INTO ninety_one_calls (id, call_type, c...
What is the total number of police reports and 911 calls in the city of Chicago?
SELECT COUNT(*) FROM police_reports UNION ALL SELECT COUNT(*) FROM ninety_one_calls;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (person_id INT, state VARCHAR(50), year INT, water_consumption FLOAT); INSERT INTO water_usage (person_id, state, year, water_consumption) VALUES (1, 'New York', 2019, 123.4), (2, 'New York', 2019, 234.5), (3, 'New York', 2019, 345.6);
What is the average water consumption per person in the state of New York in 2019?
SELECT AVG(water_consumption) as avg_water_consumption FROM water_usage WHERE state = 'New York' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (inspection_id INT, rating INT, region VARCHAR(50)); INSERT INTO Inspections (inspection_id, rating, region) VALUES (1, 5, 'Northeast'); INSERT INTO Inspections (inspection_id, rating, region) VALUES (2, 4, 'Southeast');
Determine the number of five-star food safety inspection ratings in each region
SELECT region, COUNT(*) AS five_star_ratings FROM Inspections WHERE rating = 5 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (ID INT, Name VARCHAR(50), LaunchDate DATE); INSERT INTO Satellites (ID, Name, LaunchDate) VALUES (1, 'Sat1', '2018-01-01'), (2, 'Sat2', '2020-05-15'), (3, 'Sat3', '2019-09-01'), (4, 'Sat4', '2016-03-01'), (5, 'Sat5', '2017-12-25');
Delete satellites that were launched before 2018
DELETE FROM Satellites WHERE ID NOT IN (SELECT ROW_NUMBER() OVER (ORDER BY LaunchDate DESC) as Rank, ID FROM Satellites WHERE LaunchDate >= '2018-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE sourcing (id INT, region VARCHAR(50), ingredient VARCHAR(50), quantity INT, sustainable BOOLEAN); INSERT INTO sourcing (id, region, ingredient, quantity, sustainable) VALUES (1, 'North', 'Quinoa', 100, true), (2, 'South', 'Lentils', 150, true), (3, 'East', 'Rice', 80, false);
What is the total quantity of sustainable ingredients sourced by region in Q1 2022?
SELECT region, SUM(quantity) as total_quantity FROM sourcing WHERE sustainable = true AND datepart(yy, date) = 2022 AND datepart(qq, date) = 1 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (app_id INT, app_name TEXT, safety_rating REAL); INSERT INTO creative_ai VALUES (1, 'Dalle', 4.3, 'USA'), (2, 'GTP-3', 4.5, 'Canada'), (3, 'Midjourney', 4.7, 'Australia');
Update the safety rating of the 'GTP-3' application to 4.6 in the creative_ai table.
UPDATE creative_ai SET safety_rating = 4.6 WHERE app_name = 'GTP-3';
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (FarmID int, FarmName varchar(50), Location varchar(50)); INSERT INTO Farm (FarmID, FarmName, Location) VALUES (1, 'Farm A', 'Country A'); INSERT INTO Farm (FarmID, FarmName, Location) VALUES (2, 'Farm B', 'Country B'); CREATE TABLE FishStock (FishStockID int, FishSpecies varchar(50), FarmID int, Stoc...
What is the average stocking density of Tilapia per farm?
SELECT AVG(StockingDensity) FROM FishStock WHERE FishSpecies = 'Tilapia';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT PRIMARY KEY, home_team VARCHAR(50), away_team VARCHAR(50), score INT, date DATE);
Delete the 'game' record with ID '456' from the 'games' table
DELETE FROM games WHERE id = 456;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_processing_requirements (chemical_name VARCHAR(255), min_pressure FLOAT);
What is the minimum pressure required for processing each chemical in the chemical_processing_requirements table?
SELECT chemical_name, MIN(min_pressure) FROM chemical_processing_requirements GROUP BY chemical_name;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_production (site VARCHAR(20), state VARCHAR(20), co2_emission INT, production INT); INSERT INTO co2_production (site, state, co2_emission, production) VALUES ('SiteA', 'QLD', 2500, 1500), ('SiteB', 'NSW', 3000, 2000), ('SiteC', 'WA', 3500, 1800);
What is the average CO2 emission per coal production in WA?
SELECT state, AVG(co2_emission/production) FROM co2_production WHERE state = 'WA';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (id INT, project_name VARCHAR(50), start_year INT, end_year INT, project_type VARCHAR(50)); INSERT INTO climate_projects (id, project_name, start_year, end_year, project_type) VALUES (1, 'Mitigation Project 1', 2015, 2020, 'climate mitigation'); INSERT INTO climate_projects (id, project_na...
How many climate mitigation projects were initiated between 2015 and 2017?
SELECT COUNT(*) FROM climate_projects WHERE project_type = 'climate mitigation' AND start_year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE SCHEMA FoodService;CREATE TABLE Transactions (transaction_id INT, restaurant_id INT, transaction_date DATE, revenue FLOAT); INSERT INTO Transactions (transaction_id, restaurant_id, transaction_date, revenue) VALUES (1, 1, '2021-09-01', 1000.00), (2, 1, '2021-09-05', 1500.00), (3, 2, '2021-09-03', 800.00), (4, 2,...
What is the average revenue per transaction for each restaurant category in the past month?
SELECT category, AVG(revenue) as avg_revenue FROM Transactions JOIN Restaurants ON Transactions.restaurant_id = Restaurants.restaurant_id WHERE transaction_date >= '2021-08-01' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, strategy TEXT); INSERT INTO cybersecurity_strategies (id, strategy) VALUES (1, 'Strategy1'), (2, 'Strategy2'), (3, 'Strategy3'); CREATE TABLE military_technologies (id INT, name TEXT); INSERT INTO military_technologies (id, name) VALUES (1, 'Tech1'), (2, 'Tech2'), (3, 'Tec...
Get the total number of cybersecurity strategies and military technologies combined.
SELECT COUNT(*) FROM (SELECT * FROM cybersecurity_strategies UNION ALL SELECT * FROM military_technologies) AS all_data;
gretelai_synthetic_text_to_sql
CREATE TABLE Calories (id INT, user_id INT, calories INT, diet TEXT); INSERT INTO Calories (id, user_id, calories, diet) VALUES (1, 1, 2000, 'vegetarian'), (2, 2, 3000, 'vegan');
What is the average calorie intake for users with a specific dietary preference?
SELECT AVG(calories) FROM Calories WHERE diet = 'vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id VARCHAR(10), name VARCHAR(50), role VARCHAR(50), hourly_wage DECIMAL(5,2));
Insert a new record into the 'employees' table with ID '0001', name 'John Doe', role 'Engineer', and hourly_wage $35
INSERT INTO employees (id, name, role, hourly_wage) VALUES ('0001', 'John Doe', 'Engineer', 35.00);
gretelai_synthetic_text_to_sql
create table ChemicalProduction (Machine varchar(255), Quantity int, ProductionDate date); insert into ChemicalProduction values ('Machine1', 100, '2022-01-01'), ('Machine2', 150, '2022-01-01'), ('Machine1', 120, '2022-01-02');
Find the total quantity of chemical produced per machine per day?
select Machine, ProductionDate, SUM(Quantity) as TotalQuantity from ChemicalProduction group by Machine, ProductionDate;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_sites (site_id INT, name TEXT, city TEXT, virtual_tour BOOLEAN); INSERT INTO cultural_sites (site_id, name, city, virtual_tour) VALUES (1, 'Tokyo National Museum', 'Tokyo', true), (2, 'Meiji Shrine', 'Tokyo', false);
Which cultural heritage sites in Tokyo have virtual tour availability?
SELECT name FROM cultural_sites WHERE city = 'Tokyo' AND virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE nfl_fans (fan_id INT, name VARCHAR(50), community VARCHAR(50), games_attended INT); INSERT INTO nfl_fans (fan_id, name, community, games_attended) VALUES (1, 'John Smith', 'African American', 5), (2, 'Maria Garcia', 'Hispanic', 3), (3, 'James Kim', 'Asian American', 4);
What is the total number of fans who have attended NFL games from historically underrepresented communities?
SELECT SUM(games_attended) FROM nfl_fans WHERE community IN ('African American', 'Hispanic', 'Asian American');
gretelai_synthetic_text_to_sql
CREATE TABLE Garments(id INT, name VARCHAR(100), rating FLOAT, production_country VARCHAR(50)); INSERT INTO Garments(id, name, rating, production_country) VALUES (1, 'Dress', 4.5, 'France'); INSERT INTO Garments(id, name, rating, production_country) VALUES (2, 'Shirt', 4.2, 'Italy');
What is the average rating of garments produced in France?
SELECT AVG(rating) FROM Garments WHERE production_country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name TEXT, production INT, year INT, country TEXT); INSERT INTO crops (id, name, production, year, country) VALUES (1, 'Quinoa', 1200, 2020, 'Bolivia'); INSERT INTO crops (id, name, production, year, country) VALUES (2, 'Quinoa', 800, 2020, 'Peru');
What is the total production of 'Quinoa' in 2020, grouped by country?
SELECT country, SUM(production) as total_production FROM crops WHERE name = 'Quinoa' AND year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (country, year, recycling_rate) VALUES ('Germany', 2019, 65), ('France', 2019, 55), ('Spain', 2019, 45), ('Italy', 2019, 40), ('Poland', 2019, 35);
What is the average recycling rate by country in Europe in 2019?
SELECT AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates WHERE year = 2019 AND country IN ('Germany', 'France', 'Spain', 'Italy', 'Poland');
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (id INT, city VARCHAR(50), population INT, tech_adoption FLOAT);
What is the maximum smart city technology adoption rate for cities with a population over 1 million?
SELECT MAX(tech_adoption) FROM smart_cities WHERE population > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites_2 (id INT, name TEXT, location TEXT, is_unesco_site BOOLEAN); INSERT INTO heritage_sites_2 (id, name, location, is_unesco_site) VALUES (1, 'Mount Fuji', 'Asia', true), (2, 'Himeji Castle', 'Asia', true), (3, 'Statue of Liberty', 'North America', true);
How many heritage sites are located in each continent?
SELECT SUBSTRING(location, 1, INSTR(location, ' ')-1) AS continent, COUNT(*) FROM heritage_sites_2 GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE dish (dish_id INT, dish_name TEXT, category_id INT, waste_percentage DECIMAL(5,2)); INSERT INTO dish (dish_id, dish_name, category_id, waste_percentage) VALUES (1, 'Pizza Margherita', 1, 0.12), (2, 'Veggie Burger', 2, 0.18); CREATE TABLE category (category_id INT, category_name TEXT); INSERT INTO category ...
Which dishes have a waste percentage over 15% and their respective categories?
SELECT d.dish_name, c.category_name, d.waste_percentage FROM dish d JOIN category c ON d.category_id = c.category_id WHERE d.waste_percentage > 0.15;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control(id INT, project VARCHAR(50), region VARCHAR(20), pollution_level FLOAT); INSERT INTO pollution_control(id, project, region, pollution_level) VALUES (1, 'Project A', 'Atlantic', 2.3), (2, 'Project B', 'Pacific', 1.9), (3, 'Project C', 'Indian', 4.1);
What is the maximum pollution level in the ocean floor mapping projects located in the Indian region?
SELECT MAX(pollution_level) FROM pollution_control WHERE region = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE port_operations.ports (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE port_operations.cargo_handling (id INT, port_id INT, volume INT);
List the ports and their total cargo handling volume in the 'port_operations' schema.
SELECT p.name, SUM(ch.volume) FROM port_operations.ports p INNER JOIN port_operations.cargo_handling ch ON p.id = ch.port_id GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(50), region VARCHAR(50)); INSERT INTO Manufacturers (manufacturer_id, manufacturer_name, region) VALUES (1, 'ManufacturerA', 'North America'), (2, 'ManufacturerB', 'Europe'); CREATE TABLE WasteData (manufacturer_id INT, waste_quantity INT); INSE...
Calculate the total waste generated by each manufacturer in the North American region
SELECT m.manufacturer_name, SUM(wd.waste_quantity) AS total_waste FROM Manufacturers m INNER JOIN WasteData wd ON m.manufacturer_id = wd.manufacturer_id WHERE m.region = 'North America' GROUP BY m.manufacturer_name;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (state VARCHAR(20), year INT, volume_m3 INT); INSERT INTO water_usage (state, year, volume_m3) VALUES ('California', 2020, 30000000);
What is the total water usage in California in 2020?
SELECT SUM(volume_m3) FROM water_usage WHERE state = 'California' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE project_budget (project_id INT, budget DECIMAL); INSERT INTO project_budget (project_id, budget) VALUES (1, 2500000.00);
What is the minimum budget for any climate adaptation project in the Middle East?
SELECT MIN(budget) FROM project_budget JOIN climate_project ON project_budget.project_id = climate_project.project_id WHERE climate_project.project_type = 'Adaptation' AND climate_project.project_region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT, name TEXT, city TEXT, league TEXT, rank INT); INSERT INTO teams (id, name, city, league, rank) VALUES (6, 'Boston Celtics', 'Boston', 'NBA', 1), (7, 'Toronto Raptors', 'Toronto', 'NBA', 2), (8, 'Milwaukee Bucks', 'Milwaukee', 'NBA', 3), (9, 'Philadelphia 76ers', 'Philadelphia', 'NBA', 4), (1...
What is the average points scored by the top 5 NBA teams?
SELECT AVG(GREATEST(points_home, points_away)) FROM games JOIN teams ON games.home_team_id = teams.id OR games.away_team_id = teams.id WHERE teams.rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); CREATE TABLE DonationEvents (EventID INT PRIMARY KEY, EventName VARCHAR(100), DonationID INT, EventLocation VARCHAR(100), FOREIGN KEY (DonationID) REFERENCES Donors(DonorID));
What is the average donation amount for charity events held in 'California'?
SELECT AVG(DonationAmount) as AverageDonation FROM Donors d JOIN DonationEvents e ON d.DonorID = e.DonationID WHERE e.EventLocation = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE WaterUsage (Location VARCHAR(100), Usage FLOAT, Date DATE); INSERT INTO WaterUsage (Location, Usage, Date) VALUES ('Mumbai', 150, '2022-01-01'), ('Delhi', 200, '2022-01-01');
What is the average water usage in Mumbai and Delhi?
SELECT Location, AVG(Usage) FROM WaterUsage GROUP BY Location;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'Germany'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'France'); CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, E...
What is the average age of players who have adopted VR technology and play esports?
SELECT AVG(Players.Age) FROM Players INNER JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID INNER JOIN VRAdoption ON Players.PlayerID = VRAdoption.PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, area TEXT, revenue FLOAT); INSERT INTO restaurants (id, name, area, revenue) VALUES (1, 'Restaurant A', 'downtown', 50000.00), (2, 'Restaurant B', 'uptown', 45000.00), (3, 'Restaurant C', 'downtown', 60000.00), (4, 'Restaurant D', 'downtown', 75000.00), (5, 'Restaurant E', '...
What is the total revenue generated by restaurants in each area?
SELECT area, SUM(revenue) FROM restaurants GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), country VARCHAR(20), quantity INT, year INT); INSERT INTO production (element, country, quantity, year) VALUES ('Promethium', 'Brazil', 1500, 2016), ('Promethium', 'Brazil', 1700, 2017), ('Promethium', 'Brazil', 1900, 2018), ('Promethium', 'Brazil', 2100, 2019), ('Promethiu...
What is the average quantity of 'Promethium' produced annually by 'Brazil'?
SELECT AVG(quantity) FROM production WHERE element = 'Promethium' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature (id INT, location TEXT, temperature FLOAT); INSERT INTO ocean_temperature (id, location, temperature) VALUES (1, 'Baltic Sea', 10.5); INSERT INTO ocean_temperature (id, location, temperature) VALUES (2, 'Atlantic Ocean', 15.8); INSERT INTO ocean_temperature (id, location, temperature) VAL...
What is the average water temperature in the Baltic Sea region?
SELECT AVG(temperature) FROM ocean_temperature WHERE location = 'Baltic Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department_id INT, department_name VARCHAR(255)); INSERT INTO departments (department_id, department_name) VALUES (1, 'Engineering'), (2, 'Production'), (3, 'Quality Control'); CREATE TABLE employees (employee_id INT, employee_name VARCHAR(255), department_id INT); INSERT INTO employees (emplo...
Find the total number of employees for each department in the manufacturing plant
SELECT departments.department_name, COUNT(employees.employee_id) as total_employees FROM departments LEFT JOIN employees ON departments.department_id = employees.department_id GROUP BY departments.department_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (team_id INT, team_name VARCHAR(50), total_sales DECIMAL(10,2)); INSERT INTO ticket_sales (team_id, team_name, total_sales) VALUES (1, 'Team A', 45000.00), (2, 'Team B', 32000.00), (3, 'Team C', 50000.00), (4, 'Team D', 42000.00), (5, 'Team E', 38000.00), (6, 'Team F', 35000.00), (7, 'Team G',...
List the top 5 teams with the highest total ticket sales, along with their total sales, in descending order.
SELECT team_name, total_sales FROM (SELECT team_name, total_sales, ROW_NUMBER() OVER (ORDER BY total_sales DESC) AS rank FROM ticket_sales) AS team_ranks WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, industry VARCHAR(255), salary FLOAT, union_member BOOLEAN); INSERT INTO workers (id, industry, salary, union_member) VALUES (1, 'Manufacturing', 50000.0, true), (2, 'Arts', 75000.0, true), (3, 'Retail', 30000.0, false);
What is the total number of workers in the 'Arts' industry who are part of a union and earn more than $70,000?
SELECT COUNT(*) FROM workers WHERE industry = 'Arts' AND union_member = true AND salary > 70000;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, publish_date DATE); INSERT INTO articles (id, title, publish_date) VALUES (1, 'Article Title 1', '2022-05-01'), (2, 'Article Title 2', '2022-05-05');
Show the number of articles published per day in the last month in descending order.
SELECT DATE(publish_date) AS pub_date, COUNT(*) AS num_articles FROM articles WHERE publish_date >= NOW() - INTERVAL 1 MONTH GROUP BY pub_date ORDER BY num_articles DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ca_mine_productivity (year INT, productivity FLOAT); INSERT INTO ca_mine_productivity (year, productivity) VALUES (2019, 3.1), (2020, 3.3); CREATE TABLE ru_mine_productivity (year INT, productivity FLOAT); INSERT INTO ru_mine_productivity (year, productivity) VALUES (2019, 2.8), (2020, 3.0);
Compare the labor productivity in the Canadian and Russian mining sectors in 2019 and 2020.
SELECT ca_mine_productivity.year, ca_mine_productivity.productivity AS canada_productivity, ru_mine_productivity.productivity AS russia_productivity FROM ca_mine_productivity INNER JOIN ru_mine_productivity ON ca_mine_productivity.year = ru_mine_productivity.year WHERE ca_mine_productivity.year IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE technology_sector (sector VARCHAR(255), vulnerability VARCHAR(255), remediation_days INT); INSERT INTO technology_sector (sector, vulnerability, remediation_days) VALUES ('Technology', 'Vulnerability A', 30), ('Technology', 'Vulnerability B', 45), ('Technology', 'Vulnerability C', 60), ('Technology', 'Vuln...
What is the average number of days to remediate vulnerabilities in the technology sector?
SELECT AVG(remediation_days) FROM technology_sector WHERE sector = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'XY987', 700, 'Brazil'), (2, 'GH247', 600, 'India'), (3, 'XY987', 300, 'Australia'), (4, 'GH247', 500, 'India'), (5, 'GH247',...
Find the average production quantity of chemical 'GH247' in each country
SELECT country, AVG(quantity) FROM chemical_production WHERE chemical_id = 'GH247' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE public_consultations (consultation_date DATE, num_participants INT); INSERT INTO public_consultations (consultation_date, num_participants) VALUES ('2022-01-01', 50), ('2022-02-01', 75), ('2022-03-01', 60);
What is the average number of citizens participating in public consultations in the last 6 months?
SELECT AVG(num_participants) FROM public_consultations WHERE consultation_date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE online_course (id INT, student_id INT, course_name VARCHAR(50), score INT, completed BOOLEAN);
What is the average score of students who have completed the online_course for the intro_to_programming course?
SELECT AVG(score) FROM online_course WHERE course_name = 'intro_to_programming' AND completed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT PRIMARY KEY, EventName VARCHAR(50), GameID INT, PrizePool DECIMAL(10,2)); INSERT INTO EsportsEvents (EventID, EventName, GameID, PrizePool) VALUES (3, 'Call of Duty League', 2, 1500000.00); INSERT INTO EsportsEvents (EventID, EventName, GameID, PrizePool) VALUES (4, 'Fortnite Wor...
How many unique players have participated in esports events with a prize pool greater than 100,000?
SELECT COUNT(DISTINCT PlayerID) FROM Players p JOIN EsportsEvents e ON p.PlayerID = e.PlayerID WHERE e.PrizePool > 100000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(255), launch_country VARCHAR(50), launch_cost FLOAT); INSERT INTO space_missions (mission_id, mission_name, launch_country, launch_cost) VALUES (1, 'Mars Orbiter Mission', 'India', 75000000), (2, 'Kenya Space Mission', 'Kenya', 100000000);
What is the total cost of all space missions led by African countries?
SELECT SUM(launch_cost) FROM space_missions WHERE launch_country LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT); CREATE TABLE professional_development_courses (course_id INT, course_name TEXT, year INT, teacher_id INT); INSERT INTO teachers (teacher_id, teacher_name) VALUES (1, 'Jane Smith'), (2, 'Carlos Mendoza'); INSERT INTO professional_development_courses (course_id, ...
Which professional development courses did teacher Carlos Mendoza attend in 2020?
SELECT pdc.course_name FROM professional_development_courses pdc INNER JOIN teachers t ON pdc.teacher_id = t.teacher_id WHERE t.teacher_name = 'Carlos Mendoza' AND pdc.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (id, name) VALUES (12, 'Aavegotchi'); CREATE TABLE token_balances (smart_contract_id INT, token_balance INT); INSERT INTO token_balances (smart_contract_id, token_balance) VALUES (12, 5000000);
What is the total number of tokens held by the 'Aavegotchi' smart contract?
SELECT token_balance FROM token_balances WHERE smart_contract_id = (SELECT id FROM smart_contracts WHERE name = 'Aavegotchi');
gretelai_synthetic_text_to_sql
CREATE TABLE member_info (id INT, join_date DATE); INSERT INTO member_info (id, join_date) VALUES (1, '2022-03-01'), (2, '2022-02-15'), (3, '2021-12-31'), (4, '2022-03-20'), (5, '2022-01-05');
Which members joined in March 2022?
SELECT id FROM member_info WHERE EXTRACT(MONTH FROM join_date) = 3 AND EXTRACT(YEAR FROM join_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE harvested_trees (id INT, species VARCHAR(50), volume FLOAT);
What is the sum of timber production in the 'harvested_trees' table?
SELECT SUM(volume) FROM harvested_trees;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, ItemID INT, SaleDate DATE); INSERT INTO Sales (SaleID, ItemID, SaleDate) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-02-01'), (3, 3, '2022-03-01'), (4, 1, '2022-04-01'), (5, 4, '2022-05-01');
What are the top 3 most popular sustainable clothing items based on sales in the last 6 months?
SELECT Items.Item, COUNT(*) AS SalesCount FROM Sales INNER JOIN Items ON Sales.ItemID = Items.ItemID WHERE Items.IsSustainable = TRUE AND Sales.SaleDate BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY Items.Item ORDER BY SalesCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE wellbeing (id INT, athlete_id INT, program_name VARCHAR(50), sales INT); INSERT INTO wellbeing (id, athlete_id, program_name, sales) VALUES (1, 1, 'Yoga', 100); INSERT INTO wellbeing (id, athlete_id, program_name, sales) VALUES (2, 2, 'Meditation', 150);
What is the total number of tickets sold for each athlete wellbeing program?
SELECT program_name, SUM(sales) AS total_sales FROM wellbeing GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE passengers_by_station (line_name VARCHAR(50), station_name VARCHAR(50), passengers_served INT); INSERT INTO passengers_by_station (line_name, station_name, passengers_served) VALUES ('Purple', 'Downtown', 800), ('Purple', 'Uptown', 1000), ('Purple', 'Midtown', 900);
What is the maximum number of passengers served by any station on the 'Purple Line'?
SELECT MAX(passengers_served) FROM passengers_by_station WHERE line_name = 'Purple';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, country TEXT, position TEXT, team TEXT, home_runs INT); INSERT INTO players (id, name, country, position, team, home_runs) VALUES (1, 'Jane Doe', 'Canada', 'Outfielder', 'Team A', 45);
Who was the top performing player in terms of home runs for the 2018 season?
SELECT name, MAX(home_runs) FROM players WHERE year = 2018 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), attendance INT); INSERT INTO events (id, name, date, category, attendance) VALUES (1, 'Ballet', '2022-06-01', 'dance', 500), (2, 'Flamenco', '2022-06-02', 'dance', 400), (3, 'Hip-Hop', '2022-06-03', 'dance', 600), (4, 'Tango', '2022-06-04...
List the top 3 most attended dance events in each category.
SELECT name, category, attendance FROM (SELECT name, category, attendance, RANK() OVER (PARTITION BY category ORDER BY attendance DESC) as attendance_rank FROM events WHERE category = 'dance') ranked_events WHERE attendance_rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CosmeticsSales (product VARCHAR(255), country VARCHAR(255), revenue FLOAT);
What is the total revenue of lipsticks sold in the US?
SELECT SUM(revenue) FROM CosmeticsSales WHERE product = 'Lipstick' AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE VIEW europe_hotels AS SELECT * FROM hotels WHERE continent = 'Europe'; CREATE VIEW ai_adopters AS SELECT hotel_id FROM ai_tech WHERE adoption_date IS NOT NULL;
What is the percentage of hotels in the 'europe_hotels' view that have adopted AI technology?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM europe_hotels) as percentage FROM ai_adopters;
gretelai_synthetic_text_to_sql