context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE policies (id INT, policyholder_id INT, policy_type TEXT, issue_date DATE, expiry_date DATE); INSERT INTO policies (id, policyholder_id, policy_type, issue_date, expiry_date) VALUES (1, 3, 'Life', '2020-01-01', '2022-01-01'), (2, 4, 'Health', '2021-02-01', '2023-02-01'), (3, 5, 'Auto', '2021-03-01', '2024-0...
Delete policies that have been expired for more than 2 years for policyholders in California.
DELETE FROM policies WHERE policies.id IN (SELECT policies.id FROM policies JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE policyholders.state = 'California' AND policies.expiry_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR));
gretelai_synthetic_text_to_sql
CREATE TABLE customer_location (subscriber_id INT, area_type VARCHAR(10));
How many mobile customers are there in urban areas compared to rural areas?
SELECT area_type, COUNT(*) FROM customer_location GROUP BY area_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ConsumerPreference (id INT, ConsumerID INT, ProductID INT, PreferenceScore INT); CREATE TABLE Products (id INT, ProductName VARCHAR(50), Category VARCHAR(50), Price DECIMAL(5,2), IsCrueltyFree BOOLEAN); CREATE TABLE CrueltyFreeCertification (id INT, ProductID INT, CertificationDate DATE);
Find the category with the minimum preference score for products that have at least 3 cruelty-free certifications.
SELECT P.Category, MIN(CP.PreferenceScore) as MinPreferenceScore FROM ConsumerPreference CP JOIN Products P ON CP.ProductID = P.id JOIN CrueltyFreeCertification CFC ON P.id = CFC.ProductID GROUP BY P.Category HAVING COUNT(DISTINCT CFC.CertificationDate) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_vehicles (id INT, type VARCHAR(255), city VARCHAR(255), country VARCHAR(255), num_vehicles INT); INSERT INTO shared_vehicles VALUES (1, 'Scooter', 'Berlin', 'Germany', 2000);
How many shared scooters are available in Berlin?
SELECT num_vehicles FROM shared_vehicles WHERE type = 'Scooter' AND city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE building_permit (permit_id INT, permit_date DATE, project_id INT, location VARCHAR(50)); CREATE TABLE construction_labor (laborer_id INT, laborer_name VARCHAR(50), project_id INT, material VARCHAR(50), cost DECIMAL(10,2));
List the laborers who have worked on the most projects in the 'building_permit' and 'construction_labor' tables.
SELECT laborer_name, COUNT(DISTINCT project_id) AS projects_worked FROM construction_labor JOIN building_permit ON construction_labor.project_id = building_permit.project_id GROUP BY laborer_name ORDER BY projects_worked DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE european_contractors (contractor_id INT, region VARCHAR(255)); INSERT INTO european_contractors (contractor_id, region) VALUES (6, 'Europe'), (7, 'Europe'), (8, 'Europe');
What is the total value of military equipment sales for defense contractors located in Europe?
SELECT SUM(s.sale_value) as total_sales FROM defense_contractors d INNER JOIN european_contractors ec ON d.contractor_id = ec.contractor_id INNER JOIN military_sales s ON d.contractor_id = s.contractor_id WHERE ec.region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE patients_by_gender (patient_id INT, age INT, gender VARCHAR(20), location VARCHAR(20)); INSERT INTO patients_by_gender (patient_id, age, gender, location) VALUES (1, 45, 'Male', 'Rural Alaska');
What is the ratio of male to female patients in rural areas of Alaska?
SELECT (COUNT(*) FILTER (WHERE gender = 'Male'))::float / COUNT(*) FROM patients_by_gender WHERE location = 'Rural Alaska';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, state VARCHAR(20)); CREATE TABLE broadband_customers (customer_id INT, state VARCHAR(20)); INSERT INTO mobile_customers (customer_id, state) VALUES (1, 'California'), (2, 'New York'); INSERT INTO broadband_customers (customer_id, state) VALUES (3, 'California'), (4, 'Texa...
How many mobile and broadband customers are there in total in the state of California?
SELECT COUNT(*) FROM (SELECT customer_id FROM mobile_customers WHERE state = 'California' UNION ALL SELECT customer_id FROM broadband_customers WHERE state = 'California') AS total_customers;
gretelai_synthetic_text_to_sql
CREATE TABLE delivery (delivery_id INT, delivery_date DATE, location VARCHAR(100)); INSERT INTO delivery (delivery_id, delivery_date, location) VALUES (1, '2022-01-01', 'Location A'), (2, '2022-01-05', 'Location A'), (3, '2022-01-10', 'Location B');
What is the minimum number of days between deliveries to the same location?
SELECT MIN(DATEDIFF(d2.delivery_date, d1.delivery_date)) FROM delivery d1 JOIN delivery d2 ON d1.location = d2.location AND d1.delivery_date < d2.delivery_date GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(50), category VARCHAR(20), funding DECIMAL(10,2)); CREATE VIEW investigative_projects AS SELECT * FROM projects WHERE category = 'investigative';
Which investigative journalism projects received the most funding?
SELECT name, SUM(funding) FROM investigative_projects GROUP BY name ORDER BY SUM(funding) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, price DECIMAL(5,2), quantity INT, sales_channel VARCHAR(50)); INSERT INTO ticket_sales (ticket_id, price, quantity, sales_channel) VALUES (1, 20.00, 50, 'Online'), (2, 50.00, 30, 'Box Office'), (3, 80.00, 20, 'Online');
What is the total revenue by ticket price range and sales channel?
SELECT CASE WHEN price <= 30 THEN 'Low' WHEN price <= 60 THEN 'Medium' ELSE 'High' END as price_range, sales_channel, SUM(price * quantity) as revenue FROM ticket_sales GROUP BY price_range, sales_channel;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (id INT, subscriber_id INT, type VARCHAR(10), region VARCHAR(10), amount DECIMAL(10,2)); INSERT INTO revenue (id, subscriber_id, type, region, amount) VALUES (1, 1, 'mobile', 'South West', 50.00), (2, 2, 'broadband', 'South West', 60.00), (3, 3, 'mobile', 'North East', 40.00);
What is the total revenue generated from mobile and broadband services in the 'South West' region?
SELECT SUM(revenue.amount) AS total_revenue FROM revenue WHERE revenue.region = 'South West';
gretelai_synthetic_text_to_sql
CREATE TABLE community(id INT, name VARCHAR(255), population INT, language VARCHAR(255), representative BOOLEAN);
Update the representative status of the Inuit to true
UPDATE community SET representative = true WHERE name = 'Inuit';
gretelai_synthetic_text_to_sql
CREATE TABLE agri_innovation (id INT, name TEXT, location TEXT, budget FLOAT); INSERT INTO agri_innovation (id, name, location, budget) VALUES (1, 'Precision Agriculture', 'Argentina', 200000.00), (2, 'Sustainable Farming', 'Argentina', 250000.00);
What is the maximum budget for agricultural innovation projects in Argentina?
SELECT MAX(budget) FROM agri_innovation WHERE location = 'Argentina';
gretelai_synthetic_text_to_sql
CREATE TABLE australia_water_usage (id INT, city VARCHAR(50), year INT, monthly_consumption FLOAT); INSERT INTO australia_water_usage (id, city, year, monthly_consumption) VALUES (1, 'Sydney', 2020, 140), (2, 'Sydney', 2021, 145);
Identify the change in monthly water consumption between 2020 and 2021 for Sydney, Australia.
SELECT city, (LAG(monthly_consumption) OVER (PARTITION BY city ORDER BY year)) - monthly_consumption AS consumption_change FROM australia_water_usage WHERE city = 'Sydney';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, launch_date DATE, decommission_date DATE); INSERT INTO satellites (satellite_id, launch_date, decommission_date) VALUES (1, '2010-01-01', '2020-01-01'), (2, '2015-01-01', '2022-01-01'), (3, '2020-01-01', NULL);
What is the average lifespan of satellites in space?
SELECT AVG(DATEDIFF(decommission_date, launch_date)) as avg_lifespan FROM satellites WHERE decommission_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_date DATE, category VARCHAR(20), provider_id INT); INSERT INTO incidents (incident_id, incident_date, category, provider_id) VALUES (1, '2021-01-01', 'Medical', 1), (2, '2021-02-15', 'Fire', 2), (3, '2021-03-01', 'Traffic', 3); CREATE TABLE providers (provider_id INT, n...
Which providers in 'providers' table have not been used in any incident in the 'incidents' table?
SELECT name FROM providers WHERE provider_id NOT IN (SELECT provider_id FROM incidents);
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT PRIMARY KEY, name VARCHAR(50), launch_date DATE);
Add a new satellite 'USA-210' launched on '2021-04-01' to the table
INSERT INTO satellites (id, name, launch_date) VALUES (6, 'USA-210', '2021-04-01');
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, mental_health_score INT, participated_in_open_pedagogy BOOLEAN); INSERT INTO students (student_id, mental_health_score, participated_in_open_pedagogy) VALUES (1, 80, FALSE), (2, 70, FALSE), (3, 90, TRUE);
What is the mental health score of the student with the highest ID who has not participated in open pedagogy?
SELECT mental_health_score FROM students WHERE student_id = (SELECT MAX(student_id) FROM students WHERE participated_in_open_pedagogy = FALSE);
gretelai_synthetic_text_to_sql
CREATE TABLE members (id INT, country VARCHAR(50)); INSERT INTO members (id, country) VALUES (1, 'Canada'); CREATE TABLE workouts (id INT, member_id INT, activity VARCHAR(50), duration INT); INSERT INTO workouts (id, member_id, activity, duration) VALUES (1, 1, 'Strength Training', 60);
What percentage of total workout time is spent on strength training by members from Canada?
SELECT 100.0 * SUM(CASE WHEN activity = 'Strength Training' THEN duration ELSE 0 END) / SUM(duration) AS percentage FROM members JOIN workouts ON members.id = workouts.member_id WHERE members.country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE spin_classes (user_id INT, age INT, heart_rate INT);
What is the average heart rate of users aged 25-30 during their spin classes?
SELECT AVG(heart_rate) FROM spin_classes WHERE age BETWEEN 25 AND 30;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerSignUps (SignUpID INT, VolunteerID INT, EventID INT, SignUpDate DATE);
List all events that have more than 50 volunteers signed up
SELECT Events.EventName FROM Events JOIN VolunteerSignUps ON Events.EventID = VolunteerSignUps.EventID GROUP BY Events.EventID HAVING COUNT(VolunteerSignUps.VolunteerID) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (did INT, name VARCHAR(255)); CREATE TABLE calls (cid INT, did INT, time DATETIME, response_time INT); INSERT INTO districts VALUES (1, 'Downtown'), (2, 'Uptown'); INSERT INTO calls VALUES (1, 1, '2022-01-01 12:00:00', 30), (2, 2, '2022-01-01 13:00:00', 45);
What is the average response time for emergency calls in each city district?
SELECT d.name, AVG(c.response_time) as avg_response_time FROM districts d JOIN calls c ON d.did = c.did GROUP BY d.did;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives(initiative_id INT, name TEXT, launch_date DATE);
Which circular economy initiatives have the lowest and highest launch dates?
SELECT MIN(launch_date) as min_launch_date, MAX(launch_date) as max_launch_date FROM initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, quantity INT); INSERT INTO production (element, year, quantity) VALUES ('Terbium', 2018, 1000), ('Terbium', 2018, 1100), ('Terbium', 2018, 1200), ('Terbium', 2019, 1300), ('Terbium', 2019, 1400), ('Terbium', 2019, 1500), ('Terbium', 2020, 1600), ('Terbium', 2020, ...
Calculate the total annual production of Terbium from the 'production' table for the years 2018 to 2020.
SELECT year, SUM(quantity) as total_production FROM production WHERE element = 'Terbium' AND year BETWEEN 2018 AND 2020 GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_sales (employee TEXT, department TEXT, revenue FLOAT); INSERT INTO employee_sales (employee, department, revenue) VALUES ('John', 'Sales', 5000.0), ('Jane', 'Sales', 6000.0), ('Mike', 'Marketing', 4000.0), ('Lucy', 'Marketing', 5000.0);
Who are the top 3 employees in terms of revenue generated for each department?
SELECT department, employee, revenue, ROW_NUMBER() OVER (PARTITION BY department ORDER BY revenue DESC) as rank FROM employee_sales WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyEfficiency (Sector VARCHAR(255), Investment DECIMAL(5,2), Year INT); INSERT INTO EnergyEfficiency (Sector, Investment, Year) VALUES ('Residential', 50000, 2021), ('Commercial', 75000, 2021), ('Industrial', 100000, 2021);
Find the total energy efficiency investment in each sector in the EnergyEfficiency schema?
SELECT Sector, SUM(Investment) as TotalInvestment FROM EnergyEfficiency WHERE Year = 2021 GROUP BY Sector;
gretelai_synthetic_text_to_sql
CREATE TABLE Seasons (SeasonID INT, TeamName VARCHAR(50), Points INT); INSERT INTO Seasons (SeasonID, TeamName, Points) VALUES (1, 'Golden State Warriors', 9785), (2, 'Los Angeles Lakers', 8874);
What are the total points scored in the last 5 NBA seasons by the team with the most points?
SELECT SUM(Points) FROM Seasons WHERE TeamName = (SELECT TeamName FROM Seasons WHERE SeasonID = (SELECT MAX(SeasonID) - 4 FROM Seasons)) AND SeasonID BETWEEN (SELECT MAX(SeasonID) - 4 FROM Seasons) AND (SELECT MAX(SeasonID) FROM Seasons)
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel (ID INT, Name TEXT, AverageSpeed DECIMAL); INSERT INTO Vessel (ID, Name, AverageSpeed) VALUES (1, 'VesselA', 20.5), (2, 'VesselB', 22.3), (3, 'VesselC', 18.9);
Find the vessels with an average speed above the median average speed in the Vessel table.
SELECT Name FROM (SELECT Name, AverageSpeed, PERCENT_RANK() OVER (ORDER BY AverageSpeed DESC) AS PercentRank FROM Vessel) AS RankedVessels WHERE PercentRank >= 0.5;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO species (id, name, population, region) VALUES (1, 'Polar Bear', 25000, 'Arctic'); INSERT INTO species (id, name, population, region) VALUES (2, 'Caribou', 6000, 'Tundra');
What is the average population of each species that has a population greater than 5000?
SELECT region, AVG(population) FROM species WHERE population > 5000 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name TEXT, country TEXT, points INT, olympics_year INT); INSERT INTO athletes (athlete_id, name, country, points, olympics_year) VALUES (1, 'John Smith', 'USA', 15, 2018), (2, 'Jessica Jones', 'GBR', 10, 2018), (3, 'Peter Parker', 'USA', 20, 2020), (4, 'Oliver Queen', 'CAN', 18, 2...
What are the total points scored by athletes from different countries in the 2018 and 2020 Olympics?
SELECT SUM(points) FROM athletes WHERE olympics_year IN (2018, 2020) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(100), region VARCHAR(50), score INT); INSERT INTO players (id, name, region, score) VALUES (1, 'John', 'NA', 500), (2, 'Jane', 'EU', 400), (3, 'Alice', 'NA', 600), (4, 'Bob', 'EU', 700), (5, 'Charlie', 'ASIA', 800), (6, 'David', 'EU', 900), (7, 'Eve', 'NA', 100), (8, 'Frank', ...
Create a new view named 'top_players' that displays the top 5 players with the highest scores
CREATE VIEW top_players AS SELECT * FROM (SELECT name, region, score, ROW_NUMBER() OVER (ORDER BY score DESC) as rank FROM players) as player_ranks WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (visitor_id INT, age INT, visited_surrealism BOOLEAN); INSERT INTO visitors (visitor_id, age, visited_surrealism) VALUES (123, 35, TRUE), (456, 28, FALSE), (789, 42, TRUE), (111, 60, TRUE), (222, 19, FALSE);
What is the age distribution of visitors who attended the "Surrealism" exhibition?
SELECT age_range, COUNT(*) AS visitor_count FROM (SELECT CASE WHEN age < 30 THEN '18-29' WHEN age < 50 THEN '30-49' ELSE '50+' END AS age_range, visited_surrealism FROM visitors) AS visitor_age_groups WHERE visited_surrealism = TRUE GROUP BY age_range;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (Id INT, Type VARCHAR(20), SafetyRating FLOAT); INSERT INTO Vehicles (Id, Type, SafetyRating) VALUES (1, 'Electric', 4.3), (2, 'Gasoline', 4.0), (3, 'Diesel', 4.1);
What are the average safety ratings for gasoline vehicles?
SELECT AVG(SafetyRating) FROM Vehicles WHERE Type = 'Gasoline';
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(100), revenue FLOAT, year INT); INSERT INTO drugs (drug_id, drug_name, revenue, year) VALUES (1, 'DrugA', 1500000, 2021), (2, 'DrugB', 2000000, 2021), (3, 'DrugC', 1200000, 2021);
What was the average revenue per drug in 2021?
SELECT AVG(revenue) FROM drugs WHERE year = 2021 AND drug_name IN (SELECT drug_name FROM drugs WHERE year = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE Visits (visit_id INT, visitor_id INT, event_id INT, visit_date DATE); CREATE TABLE Visitors (visitor_id INT, name VARCHAR(255), birthdate DATE); CREATE TABLE Events (event_id INT, name VARCHAR(255), date DATE, city VARCHAR(255));
What is the percentage change in attendance for dance events in 'CityX' compared to the previous year?
SELECT 100.0 * (CURRENT_YEAR_ATTENDANCE - PREVIOUS_YEAR_ATTENDANCE) / PREVIOUS_YEAR_ATTENDANCE AS percentage_change FROM (SELECT COUNT(DISTINCT V.visitor_id) AS CURRENT_YEAR_ATTENDANCE FROM Visits V JOIN Visitors VV ON V.visitor_id = VV.visitor_id JOIN Events E ON V.event_id = E.event_id WHERE E.name LIKE '%Dance%' AND...
gretelai_synthetic_text_to_sql
CREATE TABLE daily_oil_production (platform_id INT, production_date DATE, oil_production FLOAT); INSERT INTO daily_oil_production (platform_id, production_date, oil_production) VALUES (1, '2020-07-01', 50), (1, '2020-07-02', 60), (1, '2020-07-03', 70), (1, '2020-08-01', 80), (1, '2020-08-02', 90), (1, '2020-08-03', 100...
Determine the daily oil production for all platforms in Q3 2020
SELECT platform_id, production_date, oil_production FROM daily_oil_production WHERE YEAR(production_date) = 2020 AND MONTH(production_date) BETWEEN 7 AND 9;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50));CREATE TABLE SalesData (SaleID INT, ManufacturerID INT, GarmentID INT, SalesQuantity INT);
Display the top 3 best-selling garments for each manufacturer.
SELECT M.ManufacturerName, G.GarmentName, SUM(SD.SalesQuantity) AS TotalSales FROM SalesData SD JOIN Manufacturers M ON SD.ManufacturerID = M.ManufacturerID JOIN Garments G ON SD.GarmentID = G.GarmentID GROUP BY M.ManufacturerName, G.GarmentName ORDER BY TotalSales DESC, M.ManufacturerName, G.GarmentName LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableBuildingProjects (id INT, state VARCHAR(50), project_name VARCHAR(50), completed_date DATE, sustainability_rating INT); INSERT INTO SustainableBuildingProjects VALUES (1, 'Florida', 'WindTower', '2020-08-01', 90); INSERT INTO SustainableBuildingProjects VALUES (2, 'Florida', 'SolarFarm', '2021-1...
How many sustainable building projects were completed in Florida in 2020 and 2021?
SELECT COUNT(*) FROM SustainableBuildingProjects WHERE state = 'Florida' AND YEAR(completed_date) IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE tournaments (id INT, game VARCHAR(10), home_team VARCHAR(50), away_team VARCHAR(50), home_score INT, away_score INT, tournament_date DATE); INSERT INTO tournaments (id, game, home_team, away_team, home_score, away_score, tournament_date) VALUES (1, 'League of Legends', 'Team Liquid', 'TSM', 25, 20, '2022-0...
What is the average score difference between the home team and the away team in the past 5 games for the 'League of Legends' tournaments?
SELECT AVG(home_score - away_score) AS avg_score_difference FROM (SELECT home_team, away_team, home_score, away_score, home_score - away_score AS score_difference, ROW_NUMBER() OVER (PARTITION BY home_team, away_team ORDER BY tournament_date DESC) rn FROM tournaments WHERE game = 'League of Legends') sub WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE residents (id INT, name TEXT, age INT, gender TEXT, chronic_condition BOOLEAN);
Find the number of rural residents who have been diagnosed with a chronic condition, grouped by age and gender.
SELECT age, gender, COUNT(*) FROM residents WHERE chronic_condition = TRUE GROUP BY age, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_gender TEXT, exit_valuation INT); INSERT INTO startups VALUES (1, 'StartupA', 'Healthcare', 'Female', 100000000); INSERT INTO startups VALUES (2, 'StartupB', 'Healthcare', 'Female', 50000000); INSERT INTO startups VALUES (3, 'StartupC', 'Tech', 'Male', 200...
What is the average exit valuation for startups founded by women in the healthcare industry?
SELECT AVG(exit_valuation) FROM startups WHERE founder_gender = 'Female' AND industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE Africa_Shipments (id INT, destination_country VARCHAR(50), delivery_time INT); INSERT INTO Africa_Shipments (id, destination_country, delivery_time) VALUES (1, 'Nigeria', 14), (2, 'Nigeria', 16), (3, 'Egypt', 15);
What is the minimum delivery time for shipments to Nigeria?
SELECT MIN(delivery_time) FROM Africa_Shipments WHERE destination_country = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE params_data (model_id INT, model_name VARCHAR(50), application VARCHAR(50), num_params INT);
What is the maximum number of parameters for models used in Explainable AI applications?
SELECT MAX(num_params) FROM params_data WHERE application = 'Explainable AI';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, safety_rating FLOAT, organic BOOLEAN); CREATE TABLE ingredients (ingredient_id INT, product_id INT, organic BOOLEAN);
Calculate the average safety rating of cosmetic products that use at least one non-organic ingredient.
SELECT AVG(products.safety_rating) as avg_safety_rating FROM products JOIN ingredients ON products.product_id = ingredients.product_id WHERE ingredients.organic = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE news.articles (article_id INT, title VARCHAR(100), word_count INT); INSERT INTO news.articles (article_id, title, word_count) VALUES (1, 'Article 1', 500), (2, 'Article 2', 600), (3, 'Article 3', 700);
What is the maximum word count for articles published in the 'news' schema?
SELECT MAX(word_count) FROM news.articles;
gretelai_synthetic_text_to_sql
CREATE TABLE Waste (WasteID INT, WasteType VARCHAR(50), Amount INT, Date DATE);
Insert new records into the Waste table with the following data: WasteType 'Toxic Chemicals', Amount 120, Date '2022-01-01'.
INSERT INTO Waste (WasteID, WasteType, Amount, Date) VALUES (1, 'Toxic Chemicals', 120, '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), extraction_rate DECIMAL(5,2)); INSERT INTO mining_sites (id, name, location, extraction_rate) VALUES (1, 'Gold Mine', 'California', 12.5), (2, 'Silver Mine', 'Nevada', 15.2), (3, 'Copper Mine', 'Arizona', 18.9), (4, 'Iron Mine', 'Minnesota', 21....
list the mines in the mining_sites table that have the highest extraction rates, up to a maximum of 3 mines
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY extraction_rate DESC) rn FROM mining_sites) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE dish(category VARCHAR(255), ingredient VARCHAR(255), quantity INT); INSERT INTO dish(category, ingredient, quantity) VALUES ('Starter', 'Lettuce', 100), ('Starter', 'Tofu', 150), ('Main', 'Chickpeas', 200), ('Main', 'Tofu', 250), ('Side', 'Quinoa', 120), ('Side', 'Lettuce', 180);
What is the total quantity of vegan ingredients used in each dish category?
SELECT category, SUM(quantity) as total_vegan_quantity FROM dish WHERE ingredient IN ('Lettuce', 'Tofu', 'Chickpeas') GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, date DATE, funding_source VARCHAR(50), event_type VARCHAR(50)); INSERT INTO Events (id, date, funding_source, event_type) VALUES (1, '2021-01-01', 'Foundation', 'Exhibition'), (2, '2021-02-01', 'Corporate', 'Gallery'); CREATE TABLE Attendance (id INT, event_id INT, is_new_attendee BOOLEAN, ...
How many first-time attendees were there at each visual arts event, in the past year, broken down by funding source and age group?
SELECT e.funding_source, a.age_group, COUNT(a.id) AS count FROM Events e INNER JOIN Attendance a ON e.id = a.event_id AND a.is_new_attendee = TRUE WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND e.event_type = 'Visual Arts' GROUP BY e.funding_source, a.age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE prisons (id INT, state VARCHAR(2)); INSERT INTO prisons (id, state) VALUES (1, 'California'); CREATE TABLE inmates (id INT, age INT, prison_id INT); CREATE TABLE restorative_justice_programs (id INT, inmate_id INT);
What is the average age of inmates who have participated in restorative justice programs in California prisons?
SELECT AVG(inmates.age) FROM inmates INNER JOIN restorative_justice_programs ON inmates.id = restorative_justice_programs.inmate_id INNER JOIN prisons ON inmates.prison_id = prisons.id WHERE prisons.state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT, name VARCHAR(50), start_stop_id INT, end_stop_id INT); INSERT INTO routes (id, name, start_stop_id, end_stop_id) VALUES (6, 'Purple Line', 110, 125); CREATE TABLE trips (id INT, start_time TIMESTAMP, end_time TIMESTAMP, passenger_count INT, stop_id INT); INSERT INTO trips (id, start_time, e...
What is the total number of trips for route 'Purple Line' in January 2022?
SELECT COUNT(t.id) FROM trips t INNER JOIN routes r ON t.stop_id = r.start_stop_id WHERE r.name = 'Purple Line' AND t.start_time BETWEEN '2022-01-01 00:00:00' AND '2022-01-31 23:59:59';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, company_name TEXT, certification TEXT, region TEXT); INSERT INTO green_buildings (id, company_name, certification, region) VALUES (1, 'EcoBuild Pte Ltd', 'LEED', 'Asia-Pacific'), (2, 'GreenTech India', 'IGBC', 'Asia-Pacific'), (3, 'GreenBuild S.A.', 'LEED', 'South America');
What green building certifications are not held by companies based in South America?
SELECT certification FROM green_buildings WHERE region != 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, city VARCHAR(50)); INSERT INTO green_buildings (building_id, city) VALUES (1, 'New York'), (2, 'Toronto'), (3, 'Mexico City'), (4, 'New York'), (5, 'Los Angeles');
Find the number of green buildings in each city.
SELECT city, COUNT(*) FROM green_buildings GROUP BY city
gretelai_synthetic_text_to_sql
CREATE TABLE Certifications (ProductID INT, LeapingBunny BOOLEAN); INSERT INTO Certifications (ProductID, LeapingBunny) VALUES (1, TRUE), (2, FALSE), (3, TRUE);
What is the number of products certified by Leaping Bunny?
SELECT COUNT(*) FROM Certifications WHERE LeapingBunny = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policy_name VARCHAR(255), last_updated_date DATE); INSERT INTO policies (id, policy_name, last_updated_date) VALUES (1, 'Access Control', '2022-01-01'), (2, 'Incident Response', '2022-03-15'), (3, 'Data Privacy', '2022-04-10'), (4, 'Network Security', '2022-06-05');
Which policies have been updated in the last 90 days but not in the last 60 days? Provide the output in the format: policy_name, last_updated_date.
SELECT policy_name, last_updated_date FROM policies WHERE last_updated_date >= DATE(NOW()) - INTERVAL 90 DAY AND last_updated_date < DATE(NOW()) - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE hr.employee_hires (id INT, employee_id INT, hire_date DATE, job_id VARCHAR(20));
List the number of employees who have been hired in each month of the year in the 'hr' schema's 'employee_hires' table
SELECT MONTH(hire_date) AS month, COUNT(*) FROM hr.employee_hires GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Public_Services( service_id INT PRIMARY KEY, service_name VARCHAR(255), location VARCHAR(255), budget FLOAT, created_date DATE); INSERT INTO Public_Services (service_id, service_name, location, budget, created_date) VALUES (1, 'Road Maintenance', 'NYC', 5000000.00, '2022-01-01'), (2, 'Waste Management', '...
Delete the record with service_id 2 from the 'Public_Services' table
DELETE FROM Public_Services WHERE service_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE community_projects (id INT, project_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO community_projects (id, project_name, start_date, end_date) VALUES (1, 'Library', '2019-01-01', '2019-12-31'); INSERT INTO community_projects (id, project_name, start_date, end_date) VALUES (2, 'Park', '2020-...
What is the total number of community projects?
SELECT COUNT(*) FROM community_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (state VARCHAR(255), initiative_type VARCHAR(255), initiative_name VARCHAR(255)); INSERT INTO community_development (state, initiative_type, initiative_name) VALUES ('California', 'Youth Center', 'Oakland Youth Hub'), ('Texas', 'Library', 'Austin Public Library');
List the number of community development initiatives for each state in the 'community_development' table.
SELECT state, COUNT(*) FROM community_development GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_region (attorney TEXT, region TEXT); INSERT INTO attorney_region (attorney, region) VALUES ('Smith', 'boston'), ('Johnson', 'nyc'), ('Williams', 'boston'), ('Brown', 'nyc'); CREATE TABLE attorney_cases (attorney TEXT, cases INT, revenue DECIMAL(10,2)); INSERT INTO attorney_cases (attorney, cases, ...
What is the number of cases and total revenue for each attorney by region?
SELECT attorney_region.region, SUM(attorney_cases.revenue) as total_revenue, SUM(attorney_cases.cases) as case_count FROM attorney_region JOIN attorney_cases ON attorney_region.attorney = attorney_cases.attorney GROUP BY attorney_region.region;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), city VARCHAR(30), funding_source VARCHAR(30)); INSERT INTO events (event_id, event_name, city, funding_source) VALUES (1, 'Theater Play', 'New York', 'Arts Council'), (2, 'Art Exhibit', 'Los Angeles', 'Private Donors');
Find the number of events funded by "Arts Council" per city
SELECT city, COUNT(*) as num_events FROM events WHERE funding_source = 'Arts Council' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Art (ArtID INT, Type VARCHAR(255), Region VARCHAR(255), Quantity INT); INSERT INTO Art (ArtID, Type, Region, Quantity) VALUES (1, 'Painting', 'Asia', 25), (2, 'Sculpture', 'Africa', 18), (3, 'Textile', 'South America', 30), (4, 'Pottery', 'Europe', 20), (5, 'Jewelry', 'North America', 12);
What is the total quantity of traditional art pieces by type?
SELECT Type, SUM(Quantity) as Total_Quantity FROM Art GROUP BY Type;
gretelai_synthetic_text_to_sql
CREATE TABLE UNESCO_Heritage_Sites (id INT, country VARCHAR(50), site VARCHAR(100)); INSERT INTO UNESCO_Heritage_Sites (id, country, site) VALUES (1, 'Italy', 'Colosseum'), (2, 'China', 'Great Wall'), (3, 'Spain', 'Alhambra');
Show the number of heritage sites in each country, ordered from the most to the least, along with their respective percentage in relation to the total number of heritage sites.
SELECT country, COUNT(site) as num_sites, ROUND(COUNT(site) * 100.0 / (SELECT COUNT(*) FROM UNESCO_Heritage_Sites), 2) as percentage FROM UNESCO_Heritage_Sites GROUP BY country ORDER BY num_sites DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (region VARCHAR(20), source VARCHAR(20), energy_generated INT);
Show the number of renewable energy sources and the total energy generated by those sources for each region
SELECT region, COUNT(source) AS num_sources, SUM(energy_generated) AS total_energy FROM renewable_energy GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Sponsors (SponsorID INT, Name VARCHAR(50), SponsorshipAmount FLOAT, ProgramID INT); INSERT INTO Sponsors (SponsorID, Name, SponsorshipAmount, ProgramID) VALUES (1, 'ABC Corporation', 10000, 1), (2, 'XYZ Foundation', 15000, 2);
What is the name of the sponsor who has contributed the most to the conservation program with ID 2?
SELECT Sponsors.Name FROM Sponsors WHERE Sponsors.ProgramID = 2 ORDER BY Sponsors.SponsorshipAmount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE building_info (info_id INT, sq_footage INT, city TEXT, state TEXT, sustainable BOOLEAN); INSERT INTO building_info VALUES (1, 50000, 'Seattle', 'Washington', TRUE), (2, 60000, 'Houston', 'Texas', FALSE), (3, 70000, 'Seattle', 'Washington', TRUE), (4, 40000, 'New York', 'New York', FALSE), (5, 80000, 'Austi...
What is the average square footage of sustainable buildings in the state of Texas?
SELECT AVG(sq_footage) FROM building_info WHERE state = 'Texas' AND sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE resources (id INT, clinic_id INT, name VARCHAR(50), quantity INT, allocation_date DATE); INSERT INTO resources (id, clinic_id, name, quantity, allocation_date) VALUES (1, 1, 'Insulin', 100, '2020-01-01');
How many resources were allocated to clinics in rural Mississippi in 2020?
SELECT SUM(resources.quantity) FROM resources WHERE resources.allocation_date >= '2020-01-01' AND resources.allocation_date < '2021-01-01' AND resources.clinic_id IN (SELECT clinics.id FROM clinics WHERE clinics.region = 'Rural Mississippi');
gretelai_synthetic_text_to_sql
CREATE TABLE reserve_years (reserve_id INT, year_established INT);
Get the number of marine reserves established per year, including the year of establishment in the 'reserve_years' table.
SELECT year_established, COUNT(*) FROM reserve_years GROUP BY year_established;
gretelai_synthetic_text_to_sql
CREATE TABLE member_workouts (member_id INT, wearable_tech BOOLEAN);
Show the number of members who have used wearable technology to track their workouts
SELECT COUNT(*) FROM member_workouts WHERE wearable_tech = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_housing_units (id INT, city VARCHAR(255), property_type VARCHAR(255), area FLOAT); INSERT INTO affordable_housing_units (id, city, property_type, area) VALUES (1, 'Seattle', 'Apartment', 800.00), (2, 'Seattle', 'Condo', 900.00);
What is the total area of affordable housing units in the city of Seattle, Washington, broken down by property type?
SELECT property_type, SUM(area) FROM affordable_housing_units WHERE city = 'Seattle' GROUP BY property_type;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityArtCenter (memberID INT, joinDate DATE); INSERT INTO CommunityArtCenter (memberID, joinDate) VALUES (4, '2022-04-15'), (5, '2022-04-22'), (6, '2022-04-29');
How many new members joined the community art center in the past month?
SELECT COUNT(*) FROM CommunityArtCenter WHERE joinDate >= '2022-04-01' AND joinDate <= '2022-04-30';
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT PRIMARY KEY, seller VARCHAR(255), buyer VARCHAR(255), equipment_type VARCHAR(255), quantity INT);
List all military equipment sales records where the buyer is "Country B" and the quantity sold is greater than 50, ordered by the equipment type in ascending order.
SELECT * FROM military_sales WHERE buyer = 'Country B' AND quantity > 50 ORDER BY equipment_type ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), season INT, user_count INT); INSERT INTO tv_shows (id, title, season, user_count) VALUES (1, 'The Crown', 1, 1000000); INSERT INTO tv_shows (id, title, season, user_count) VALUES (2, 'The Crown', 2, 1200000); INSERT INTO tv_shows (id, title, season, user_count) VALUES ...
How many users watched TV show 'The Crown' per season?
SELECT season, user_count FROM tv_shows WHERE title = 'The Crown';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (ID INT PRIMARY KEY, Country VARCHAR(50), AccommodationType VARCHAR(50), Quantity INT); INSERT INTO Accommodations (ID, Country, AccommodationType, Quantity) VALUES (1, 'USA', 'Sign Language Interpretation', 300), (2, 'Canada', 'Wheelchair Ramp', 250), (3, 'Mexico', 'Assistive Listening Devi...
What is the minimum number of accommodations provided, per country?
SELECT Country, MIN(Quantity) as Minimum FROM Accommodations GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(255), Nationality VARCHAR(255), Genre VARCHAR(255)); INSERT INTO Artists VALUES (8, 'Agnez Mo', 'Indonesian', 'Pop',); INSERT INTO Artists VALUES (9, 'Wang Leehom', 'Taiwanese-American', 'Mandopop',);
How many artists are in our database from Asia?
SELECT COUNT(*) FROM Artists WHERE Nationality = 'Asian';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artwork_name VARCHAR(255), year_created INT, price FLOAT); INSERT INTO Artworks (id, artwork_name, year_created, price) VALUES (1, 'Composition with Red Blue and Yellow', 1930, 800000); INSERT INTO Artworks (id, artwork_name, year_created, price) VALUES (2, 'The Persistence of Memory', 19...
What is the maximum price of artworks created in the '1920s'?
SELECT MAX(price) FROM Artworks WHERE year_created BETWEEN 1920 AND 1929;
gretelai_synthetic_text_to_sql
CREATE TABLE Game (GameID INT, GameName VARCHAR(100), Genre VARCHAR(50), Price DECIMAL(5, 2)); INSERT INTO Game (GameID, GameName, Genre, Price) VALUES (1, 'GameA', 'Shooter', 50.00), (2, 'GameB', 'Strategy', 60.00), (3, 'GameC', 'RPG', 40.00); CREATE TABLE Sales (SaleID INT, GameID INT, Quantity INT); INSERT INTO Sale...
What is the total revenue for each game?
SELECT GameID, SUM(Price * Quantity) FROM Game G JOIN Sales S ON G.GameID = S.GameID GROUP BY GameID;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParityViolations (Id INT, State VARCHAR(2), Year INT, ViolationCount INT); INSERT INTO MentalHealthParityViolations (Id, State, Year, ViolationCount) VALUES (1, 'CA', 2020, 135), (2, 'MI', 2020, 125), (3, 'WA', 2020, 110), (4, 'NY', 2019, 140), (5, 'TX', 2019, 155);
How many mental health parity violations were reported in California, Michigan, and Washington in 2020?
SELECT State, SUM(ViolationCount) as TotalViolations FROM MentalHealthParityViolations WHERE State IN ('CA', 'MI', 'WA') AND Year = 2020 GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_size(customer_id INT, size VARCHAR(10), purchase_date DATE); INSERT INTO customer_size(customer_id, size, purchase_date) VALUES(1, 'large', '2022-01-05'), (2, 'medium', '2022-02-10'), (3, 'large', '2022-03-25');
How many customers in the 'large' size range have made purchases in the last six months?
SELECT COUNT(*) FROM customer_size WHERE size = 'large' AND purchase_date >= DATEADD(month, -6, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), star_rating INT);
Insert a new record into the "hotels" table with id 102, name "Heritage Hotel", city "Delhi", country "India", and star_rating 5
INSERT INTO hotels VALUES (102, 'Heritage Hotel', 'Delhi', 'India', 5);
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT, sector VARCHAR(50), improvement FLOAT); INSERT INTO energy_efficiency (id, sector, improvement) VALUES (1, 'Industry', 5.5), (2, 'Transportation', 3.2), (3, 'Residential', 7.1), (4, 'Commercial', 4.0);
What is the total energy efficiency improvement (in percentage) in each sector in Australia?
SELECT sector, SUM(improvement) FROM energy_efficiency GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT PRIMARY KEY, vessel_name VARCHAR(50)); CREATE TABLE vessel_movements (id INT PRIMARY KEY, vessel_id INT, port VARCHAR(50), arrival_date DATE, containers_unloaded INT, FOREIGN KEY (vessel_id) REFERENCES vessels(id));
Which vessels arrived at the Port of Los Angeles with more than 1000 containers in Q3 2019?
SELECT vessel_name FROM vessels INNER JOIN vessel_movements ON vessels.id = vessel_movements.vessel_id WHERE port = 'Port of Los Angeles' AND arrival_date BETWEEN '2019-07-01' AND '2019-09-30' GROUP BY vessel_name HAVING COUNT(*) > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, student_name VARCHAR(255));
What is the percentage of students who have received accommodations for visual impairments?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM students)) as percentage FROM student_accommodations SA JOIN visual_impairments VI ON SA.student_id = VI.student_id WHERE SA.accommodation_type = 'Visual Impairment';
gretelai_synthetic_text_to_sql
CREATE TABLE north_sea_oil (country VARCHAR(255), wellhead_price DECIMAL(10,2), year INT);
What are the average wellhead prices for oil in the North Sea, broken down by country, for the year 2020?
SELECT nso.country, AVG(nso.wellhead_price) FROM north_sea_oil nso WHERE nso.year = 2020 GROUP BY nso.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Tunnels (id INT, name VARCHAR(50), construction_date DATE); INSERT INTO Tunnels (id, name, construction_date) VALUES (1, 'Hudson Tunnel', '2010-01-01');
List the names and construction dates of all tunnels in New York
SELECT name, construction_date FROM Tunnels WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT PRIMARY KEY, title VARCHAR(100), principal_investigator VARCHAR(50), amount NUMERIC, start_date DATE, end_date DATE);
Update the title of a research grant in the "grants" table
WITH updated_grant AS (UPDATE grants SET title = 'Advanced Quantum Computing' WHERE id = 1 RETURNING *) SELECT * FROM updated_grant;
gretelai_synthetic_text_to_sql
CREATE TABLE public.property_owners (id SERIAL PRIMARY KEY, property_owner_name VARCHAR(255), property_owner_email VARCHAR(255)); INSERT INTO public.property_owners (property_owner_name, property_owner_email) VALUES ('John Smith', 'john.smith@example.com'), ('Jane Doe', 'jane.doe@example.com'), ('Mary Major', 'mary.maj...
Add a new property owner to the property_owners table
INSERT INTO public.property_owners (property_owner_name, property_owner_email) VALUES ('Mohammad Ahmad', 'mohammad.ahmad@example.com');
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, founding_date DATE, founder_gender TEXT);
What is the earliest founding date for a startup with a female founder?
SELECT MIN(founding_date) FROM startups WHERE founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Levees(id INT, name TEXT, location TEXT, built DATE); INSERT INTO Levees(id, name, location, built) VALUES (1, 'New Orleans East Levee', 'Louisiana', '2006-01-01');
Which levees in Louisiana were built after 2000?
SELECT name FROM Levees WHERE location = 'Louisiana' AND built > '2000-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), Budget decimal(10,2)); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 5000.00), (2, 'Health', 7000.00);
What is the total budget allocated to each program in 2021?
SELECT ProgramName, SUM(Budget) as TotalBudget FROM Programs WHERE YEAR(ProgramStartDate) = 2021 GROUP BY ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE patents (id INT, title VARCHAR(50), filed_by VARCHAR(50), filed_date DATE, type VARCHAR(50), industry VARCHAR(50));
Get the number of patents filed per month for a specific year.
SELECT EXTRACT(MONTH FROM filed_date) AS month, COUNT(*) FROM patents WHERE industry = 'biotech' AND EXTRACT(YEAR FROM filed_date) = 2020 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployments (id INT, country VARCHAR(255), manufacturer VARCHAR(255), deployment_date DATE);
What is the number of satellite deployments by country and manufacturer in the last 10 years?
SELECT country, manufacturer, COUNT(*) as num_deployments FROM satellite_deployments WHERE deployment_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 10 YEAR) GROUP BY country, manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO fish_farms (id, name, country) VALUES (1, 'Farm A', 'Norway'), (2, 'Farm B', 'Canada'), (3, 'Farm C', 'Norway'), (4, 'Farm D', 'Japan'), (5, 'Farm E', 'Norway'), (6, 'Farm F', 'Philippines');
Identify the number of fish farms in each country?
SELECT country, COUNT(*) FROM fish_farms GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, origin VARCHAR(50), destination VARCHAR(50), distance INT, eta DATE);
Add a new record to the "routes" table with the following data: route_id = 5, origin = "Seattle", destination = "New York", distance = 2500, and eta = '2022-07-01'
INSERT INTO routes (route_id, origin, destination, distance, eta) VALUES (5, 'Seattle', 'New York', 2500, '2022-07-01');
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO clients (client_id, name, region, account_balance) VALUES (1, 'John Smith', 'West', 30000.00), (2, 'Jane Doe', 'Northeast', 22000.00), (3, 'Mike Johnson', 'West', 35000.00), (4, 'Sara Jones', 'Southeas...
Find the top 3 clients with the highest account balance in the West region.
SELECT client_id, name, account_balance FROM clients WHERE region = 'West' ORDER BY account_balance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid (provider_id INT, provider VARCHAR(255), location VARCHAR(255)); CREATE TABLE legal_aid_practices (provider_id INT, practice_id INT); CREATE TABLE restorative_practices (practice_id INT, practice VARCHAR(255));
Identify legal aid providers offering restorative practice services in the 'legal_aid_practices' and 'restorative_practices' tables?
SELECT legal_aid.provider FROM legal_aid INNER JOIN legal_aid_practices ON legal_aid.provider_id = legal_aid_practices.provider_id INNER JOIN restorative_practices ON legal_aid_practices.practice_id = restorative_practices.practice_id;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (year INT, country VARCHAR(255), region VARCHAR(255), volume FLOAT);
Find total timber production in North America by country
SELECT country, SUM(volume) FROM timber_production WHERE region = 'North America' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE complaints (complaint_id INT, complaint_type VARCHAR(255), date DATE); INSERT INTO complaints (complaint_id, complaint_type, date) VALUES (1, 'Physical Barrier', '2021-03-15'); INSERT INTO complaints (complaint_id, complaint_type, date) VALUES (2, 'Lack of Communication', '2021-02-20');
Identify the top 3 most common disability-related complaints received in the last 6 months?
SELECT complaint_type, COUNT(*) as count FROM complaints WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 6 MONTH) AND NOW() GROUP BY complaint_type ORDER BY count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_production (crop_variety VARCHAR(255), year INT, production FLOAT); INSERT INTO crop_production (crop_variety, year, production) VALUES ('CropVarietyA', 2015, 1200.5), ('CropVarietyA', 2016, 1500.7), ('CropVarietyB', 2015, 1800.9), ('CropVarietyB', 2016, 2000.2), ('CropVarietyC', 2015, 800.0), ('CropV...
Identify the top 3 crops with the highest production increase between 2015 and 2016 in the 'crop_production' table.
SELECT cp1.crop_variety, (cp2.production - cp1.production) as production_increase FROM crop_production cp1 INNER JOIN crop_production cp2 ON cp1.crop_variety = cp2.crop_variety WHERE cp1.year = 2015 AND cp2.year = 2016 ORDER BY production_increase DESC LIMIT 3;
gretelai_synthetic_text_to_sql