context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Exhibitions (exhibition_id INT, museum_name VARCHAR(255), artist_id INT, artwork_id INT); INSERT INTO Exhibitions (exhibition_id, museum_name, artist_id, artwork_id) VALUES (1, 'Museum X', 101, 201), (2, 'Museum Y', 102, 202), (3, 'Museum Z', 103, 203); CREATE TABLE Artworks (artwork_id INT, artist_id INT, artwork_title VARCHAR(255)); INSERT INTO Artworks (artwork_id, artist_id, artwork_title) VALUES (201, 101, 'Painting 1'), (202, 102, 'Sculpture 1'), (203, 103, 'Drawing 1'), (204, 102, 'Sculpture 2'), (205, 102, 'Sculpture 3');
How many artworks were exhibited by artist '102'?
SELECT COUNT(artwork_id) FROM Exhibitions WHERE artist_id = 102;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id INT, trial_name VARCHAR(100), approval_date DATE); INSERT INTO clinical_trials (trial_id, trial_name, approval_date) VALUES (1, 'TrialA', '2021-06-15'), (2, 'TrialB', '2022-02-03'), (3, 'TrialC', '2020-12-18');
Which clinical trials were approved before 2022?
SELECT trial_name FROM clinical_trials WHERE approval_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, industry TEXT, members INT); INSERT INTO unions (id, name, industry, members) VALUES (1, 'Unite Here', 'Service', 300000), (2, 'SEIU', 'Public Service', 2000000), (3, 'United Auto Workers', 'Manufacturing', 400000);
What is the union with the fewest members in the service sector?
SELECT name FROM unions WHERE industry = 'Service' ORDER BY members LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyNumber VARCHAR(20), PolicyholderName VARCHAR(50), Community VARCHAR(50)); INSERT INTO Policyholders (PolicyNumber, PolicyholderName, Community) VALUES ('P001', 'John Doe', 'African American'); CREATE TABLE Policies (PolicyNumber VARCHAR(20), AnnualPremium INT); INSERT INTO Policies (PolicyNumber, AnnualPremium) VALUES ('P001', 1000);
What are the names, policy numbers, and annual premiums for policyholders who are members of historically underrepresented communities?
SELECT p.PolicyholderName, p.PolicyNumber, pol.AnnualPremium FROM Policyholders p INNER JOIN Policies pol ON p.PolicyNumber = pol.PolicyNumber WHERE p.Community IN ('African American', 'Hispanic', 'Native American', 'Asian Pacific Islander', 'LGBTQ+');
gretelai_synthetic_text_to_sql
CREATE TABLE loans (id INT, bank_id INT, amount DECIMAL(10, 2)); INSERT INTO loans (id, bank_id, amount) VALUES (1, 1, 5000.00), (2, 2, 3000.00), (3, 3, 8000.00), (4, 4, 6000.00);
What is the total amount of socially responsible loans issued?
SELECT SUM(amount) FROM loans WHERE bank_id IN (1, 3);
gretelai_synthetic_text_to_sql
CREATE TABLE AstrophysicsResearch (grant_name VARCHAR(30), year INT, grant_amount INT); INSERT INTO AstrophysicsResearch (grant_name, year, grant_amount) VALUES ('Grant1', 2021, 1000000); INSERT INTO AstrophysicsResearch (grant_name, year, grant_amount) VALUES ('Grant2', 2021, 500000);
What is the sum of all astrophysics research grants awarded in 2021?
SELECT SUM(grant_amount) FROM AstrophysicsResearch WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE chicago_emergency_response (id INT, incident_type TEXT, response_time INT); INSERT INTO chicago_emergency_response (id, incident_type, response_time) VALUES (1, 'Fire', 120), (2, 'Medical', 150), (3, 'Fire', 180);
What is the most common type of incident in Chicago?
SELECT incident_type, COUNT(*) as count FROM chicago_emergency_response GROUP BY incident_type ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE maintenance (id INT, task TEXT, completed_date DATETIME); INSERT INTO maintenance (id, task, completed_date) VALUES (1, 'Oil Change', '2022-01-01 10:00:00'), (2, 'Tire Rotation', '2022-01-03 14:00:00'), (3, 'Inspection', '2022-01-07 09:00:00');
List all vehicle maintenance tasks for the past week.
SELECT * FROM maintenance WHERE completed_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, name VARCHAR(255)); INSERT INTO routes (route_id, name) VALUES (101, 'Route 101'); CREATE TABLE schedules (schedule_id INT, route_id INT, departure_time TIME); INSERT INTO schedules (schedule_id, route_id, departure_time) VALUES (1, 101, '06:15:00'), (2, 101, '07:15:00');
What is the earliest departure time for route 101?
SELECT MIN(departure_time) FROM schedules WHERE route_id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, seller VARCHAR(255), equipment VARCHAR(255), year INT, quantity INT); INSERT INTO military_sales (id, seller, equipment, year, quantity) VALUES (1, 'Lockheed Martin', 'tank', 2020, 50), (2, 'Lockheed Martin', 'aircraft', 2020, 75), (3, 'Lockheed Martin', 'ship', 2020, 30);
What is the total number of military vehicles sold by Lockheed Martin in the year 2020?
SELECT SUM(quantity) FROM military_sales WHERE seller = 'Lockheed Martin' AND year = 2020 AND equipment IN ('tank', 'aircraft', 'ship');
gretelai_synthetic_text_to_sql
CREATE TABLE Dates (date DATE); CREATE TABLE Sales (sale_id INT, date DATE, product_id INT, quantity INT);
What is the total quantity of meat products sold in the last 30 days?
SELECT SUM(s.quantity) as total_quantity FROM Sales s JOIN Dates d ON s.date = d.date WHERE d.date >= DATE(NOW()) - INTERVAL 30 DAY AND s.product_id IN (SELECT product_id FROM Products WHERE product_category = 'meat');
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_training_data (model_name TEXT, accuracy FLOAT);
What is the average accuracy of models trained on fairness_training_data?
SELECT AVG(accuracy) FROM fairness_training_data;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget(Year INT, Service VARCHAR(20), Amount INT); INSERT INTO Budget VALUES (2020, 'Education', 15000), (2020, 'Health', 12000), (2021, 'Education', 16000), (2021, 'Health', 14000), (2022, 'Education', 18000), (2022, 'Health', 15000);
What is the total budget allocated for education and health services in 2022?
SELECT SUM(Amount) FROM Budget WHERE Year = 2022 AND (Service = 'Education' OR Service = 'Health');
gretelai_synthetic_text_to_sql
CREATE TABLE waste_data (country VARCHAR(255), year INT, quantity INT); INSERT INTO waste_data (country, year, quantity) VALUES ('China', 2018, 5000), ('India', 2018, 3000), ('Bangladesh', 2018, 2000), ('China', 2019, 6000), ('India', 2019, 4000), ('Bangladesh', 2019, 3000);
What is the average waste production per factory in India and China?
SELECT country, AVG(quantity) as avg_waste FROM waste_data WHERE country IN ('China', 'India') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities ( id INT PRIMARY KEY, name VARCHAR(255), population INT, region VARCHAR(255), language VARCHAR(255)); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (1, 'Community A', 500, 'Arctic', 'Language A'); INSERT INTO indigenous_communities (id, name, population, region, language) VALUES (2, 'Community B', 700, 'Antarctic', 'Language B');
What is the average population for indigenous communities in the Arctic and the Antarctic?
SELECT AVG(population) FROM indigenous_communities WHERE region IN ('Arctic', 'Antarctic');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life_research_initiatives (id INT, initiative TEXT, region TEXT, funding FLOAT); INSERT INTO marine_life_research_initiatives (id, initiative, region, funding) VALUES (1, 'Initiative A', 'Indian', 250000), (2, 'Initiative B', 'Pacific', 350000), (3, 'Initiative C', 'Indian', 400000);
What is the total funding for marine life research initiatives in the Indian Ocean?
SELECT SUM(funding) FROM marine_life_research_initiatives WHERE region = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE public_services (id INT PRIMARY KEY, service VARCHAR(255), location VARCHAR(255), budget DECIMAL(10, 2), provider VARCHAR(255));
Add a new column 'rating' to the existing 'public_services' table.
ALTER TABLE public_services ADD COLUMN rating INT;
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarding (route_id INT, origin TEXT, destination TEXT, revenue FLOAT);
Find the top 3 freight forwarding routes with the highest total revenue.
SELECT route_id, origin, destination, SUM(revenue) as total_revenue FROM freight_forwarding GROUP BY route_id, origin, destination ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Articles (id INT, title TEXT, content TEXT, word_count INT, language TEXT); INSERT INTO Articles (id, title, content, word_count, language) VALUES (1, 'Article 1', 'Content for article 1...', 500, 'English');
What is the average word count for articles by language?
SELECT language, AVG(word_count) as avg_word_count FROM Articles GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy_Advocacy_Events (event_id INT, year INT, type VARCHAR(255), format VARCHAR(255)); INSERT INTO Policy_Advocacy_Events VALUES (1, 2021, 'Webinar', 'Virtual');
What is the total number of policy advocacy events held in-person?
SELECT COUNT(*) FROM Policy_Advocacy_Events WHERE format = 'In-person';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, country VARCHAR(50), year INT, type VARCHAR(20));
For the "defense_diplomacy" table, insert new records for each of the following: Indonesia, 2020, Bilateral; Philippines, 2021, Multilateral
INSERT INTO defense_diplomacy (id, country, year, type) VALUES (1, 'Indonesia', 2020, 'Bilateral'), (2, 'Philippines', 2021, 'Multilateral');
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, project_name TEXT, start_date DATE); INSERT INTO community_development (id, project_name, start_date) VALUES (1, 'Water Supply Project', '2020-02-01'), (2, 'School Construction', '2019-12-15'), (3, 'Healthcare Facility', '2021-03-20');
List all community development projects in Africa that were started after January 1, 2020.
SELECT * FROM community_development WHERE project_name LIKE '%Africa%' AND start_date > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (StudentID INT, Accommodation VARCHAR(20), Cost INT); INSERT INTO Accommodations (StudentID, Accommodation, Cost) VALUES (5, 'Sign Language Interpreter', 2500); INSERT INTO Accommodations (StudentID, Accommodation, Cost) VALUES (6, 'Speech-to-Text Software', 1500);
Which students require communication accommodations and what are their associated costs?
SELECT s.StudentName, a.Accommodation, a.Cost FROM Students s JOIN Accommodations a ON s.StudentID = a.StudentID WHERE a.Accommodation LIKE '%Communication%';
gretelai_synthetic_text_to_sql
CREATE TABLE music_streams (song VARCHAR(255), country VARCHAR(255), streams INT); INSERT INTO music_streams (song, country, streams) VALUES ('Song1', 'Country1', 100000), ('Song2', 'Country2', 150000), ('Song3', 'Country3', 120000), ('Song4', 'Country1', 110000), ('Song5', 'Country3', 130000);
List the names of the top 3 countries with the most music streams.
SELECT country, SUM(streams) as total_streams FROM music_streams GROUP BY country ORDER BY total_streams DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), type VARCHAR(255), launch_date DATE, planet VARCHAR(255)); INSERT INTO SpaceMissions (id, name, type, launch_date, planet) VALUES (1, 'Voyager 1', 'Space probe', '1977-09-05', 'Jupiter'), (2, 'Cassini-Huygens', 'Space probe', '1997-10-15', 'Saturn');
What is the earliest launch date for space missions to each planet in our solar system?
SELECT planet, MIN(launch_date) as earliest_launch_date FROM SpaceMissions GROUP BY planet;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GamePurchaseCount INT); INSERT INTO Players (PlayerID, Age, GamePurchaseCount) VALUES (1, 25, 120), (2, 35, 200), (3, 42, 150), (4, 22, 80), (5, 31, 175); CREATE TABLE VR_Games (PlayerID INT, VRGamePlayed BOOLEAN); INSERT INTO VR_Games (PlayerID, VRGamePlayed) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, FALSE), (5, TRUE);
What is the average age of players who play VR games and their total game purchase count?
SELECT AVG(Players.Age), SUM(Players.GamePurchaseCount) FROM Players INNER JOIN VR_Games ON Players.PlayerID = VR_Games.PlayerID WHERE VR_Games.VRGamePlayed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INTEGER, name TEXT);
Find the total number of marine species in the 'Mediterranean Sea'.
SELECT COUNT(DISTINCT id) FROM marine_species WHERE id IN (SELECT species_id FROM marine_species_in_habitat WHERE habitat = 'Mediterranean Sea');
gretelai_synthetic_text_to_sql
CREATE TABLE graduates (student_id INT, student_name TEXT, disability BOOLEAN, graduated INT); INSERT INTO graduates (student_id, student_name, disability, graduated) VALUES (1, 'Alice', true, 2020), (2, 'Bob', false, 2020), (3, 'Carol', true, 2020), (4, 'Dave', false, 2020), (5, 'Eva', true, 2020), (6, 'Frank', false, 2020);
What is the percentage of students with and without disabilities who graduated in 2020?
SELECT year, SUM(CASE WHEN disability THEN 1 ELSE 0 END) / COUNT(*) * 100 AS percentage_with_disabilities, SUM(CASE WHEN NOT disability THEN 1 ELSE 0 END) / COUNT(*) * 100 AS percentage_without_disabilities FROM graduates WHERE graduated = 2020 GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Innovation_Projects (id INT, name VARCHAR(50), location VARCHAR(50), funding DECIMAL(10,2), start_date DATE); INSERT INTO Innovation_Projects (id, name, location, funding, start_date) VALUES (1, 'Solar-Powered Irrigation', 'Rural Colombia', 35000.00, '2021-07-15');
Which agricultural innovation projects received funding in South America in 2021?
SELECT name, location, funding FROM Innovation_Projects WHERE location LIKE 'Rural%' AND YEAR(start_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE music_track (track_id INT, title VARCHAR(100), artist VARCHAR(100)); INSERT INTO music_track (track_id, title, artist) VALUES (1, 'Eternal Love', 'Sarah Brightman');
Delete the music track 'Eternal Love' by 'Sarah Brightman'.
DELETE FROM music_track WHERE title = 'Eternal Love' AND artist = 'Sarah Brightman';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(255), region VARCHAR(255)); CREATE VIEW bioregions AS SELECT DISTINCT region FROM marine_species;
Find the number of marine species in each biogeographical region.
SELECT bioregions.region, COUNT(marine_species.species) FROM bioregions LEFT JOIN marine_species ON bioregions.region = marine_species.region GROUP BY bioregions.region;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerData (PlayerID INT, Name VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO PlayerData (PlayerID, Name, Age, Country) VALUES ('1', 'John Doe', '25', 'USA'), ('2', 'Jane Smith', '30', 'Canada');
Show the average age of players from the 'PlayerData' table
SELECT AVG(Age) FROM PlayerData;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (region VARCHAR(255), year INT, total_consumption INT); INSERT INTO water_usage (region, year, total_consumption) VALUES ('North', 2018, 5000), ('North', 2019, 5500), ('North', 2020, 6000), ('South', 2018, 6000), ('South', 2019, 6500), ('South', 2020, 7000); CREATE TABLE drought_info (region VARCHAR(255), year INT, severity INT); INSERT INTO drought_info (region, year, severity) VALUES ('North', 2018, 3), ('North', 2019, 5), ('North', 2020, 4), ('South', 2018, 2), ('South', 2019, 4), ('South', 2020, 5);
What is the total water consumption in regions with severe droughts in 2020?
SELECT SUM(w.total_consumption) FROM water_usage w JOIN drought_info d ON w.region = d.region WHERE w.year = 2020 AND d.severity = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (region TEXT, acidity NUMERIC); INSERT INTO ocean_acidity (region, acidity) VALUES ('Southern Ocean', '8.1'); INSERT INTO ocean_acidity (region, acidity) VALUES ('Southern Ocean', '8.05');
What is the minimum ocean acidity level recorded in the Southern Ocean?
SELECT MIN(acidity) FROM ocean_acidity WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, ProjectName VARCHAR(50), StartDate DATE, EndDate DATE, EmployeeID INT, FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID));
Update the project name in the Projects table for a specific project ID.
UPDATE Projects SET ProjectName = 'Sustainable Housing Development' WHERE ProjectID = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (source_id INT, source_name VARCHAR(50), amount DECIMAL(10, 2)); CREATE TABLE donors (donor_id INT, donor_name VARCHAR(50), country VARCHAR(50), source_id INT);
What is the average donation amount by individuals from the "funding_sources" table joined with the "donors" table, grouped by donor's country?
SELECT d.country, AVG(fs.amount) as avg_donation FROM funding_sources fs INNER JOIN donors d ON fs.source_id = d.source_id GROUP BY d.country;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), region VARCHAR(255), production FLOAT);
Update the 'production' column in the 'wells' table for well 'A-01' to 1000
UPDATE wells SET production = 1000 WHERE well_name = 'A-01';
gretelai_synthetic_text_to_sql
CREATE TABLE CrueltyFreeCertification (id INT, product_id INT, certification_date DATE, certification_authority VARCHAR(255)); INSERT INTO CrueltyFreeCertification (id, product_id, certification_date, certification_authority) VALUES (1, 1, '2022-03-01', 'Leaping Bunny'), (2, 2, '2021-09-15', 'Leaping Bunny'), (3, 3, '2022-06-05', 'Choose Cruelty Free');
Calculate the average cruelty-free certification date for products certified by Leaping Bunny.
SELECT AVG(certification_date) as avg_certification_date FROM CrueltyFreeCertification WHERE certification_authority = 'Leaping Bunny';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, genre VARCHAR(20), price FLOAT, tickets_sold INT); INSERT INTO Concerts (id, genre, price, tickets_sold) VALUES (1, 'Rock', 100.0, 200), (2, 'Rock', 120.0, 150), (3, 'Pop', 150.0, 250);
What was the average ticket price for a concert in a specific genre?
SELECT AVG(price) FROM Concerts WHERE genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE rooms_data (room_id INT, room_type VARCHAR(20), rate FLOAT, hotel_id INT);
Update the room rates for all single rooms in the 'rooms_data' table by 5%.
UPDATE rooms_data SET rate = rate * 1.05 WHERE room_type = 'single';
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farms (id INT, name TEXT, country TEXT); INSERT INTO urban_farms (id, name, country) VALUES (1, 'Farm 1', 'Canada'), (2, 'Farm 2', 'Australia');
How many urban farms are there in Canada and Australia?
SELECT COUNT(*) as count FROM urban_farms WHERE country IN ('Canada', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id INT, org_name TEXT);CREATE TABLE policy_advocacy_events_org (event_id INT, event_name TEXT, event_date DATE, org_id INT);
List all organizations and their respective policy advocacy events, including event date, in ascending order by event date.
SELECT o.org_name, pa.event_name, pa.event_date FROM policy_advocacy_events_org pa INNER JOIN organizations o ON pa.org_id = o.org_id ORDER BY pa.event_date ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Trainings (TrainingID int, Department varchar(20), Cost int, Date datetime); INSERT INTO Trainings (TrainingID, Department, Cost, Date) VALUES (1, 'Marketing', 5000, '2022-01-01'); INSERT INTO Trainings (TrainingID, Department, Cost, Date) VALUES (2, 'Marketing', 6000, '2022-02-01'); INSERT INTO Trainings (TrainingID, Department, Cost, Date) VALUES (3, 'IT', 7000, '2022-03-01');
What is the total training cost for each department in the last quarter?
SELECT Department, SUM(Cost) FROM Trainings WHERE Date >= '2022-01-01' AND Date < '2022-04-01' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE injury (id INT, athlete_id INT, injury_date DATE);
Delete all the records in the injury table that occurred more than 2 years ago.
DELETE FROM injury WHERE injury_date < DATE_SUB(CURDATE(), INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, name TEXT, country TEXT, level INT); INSERT INTO charging_stations (id, name, country, level) VALUES (1, 'Berlin EV Charging Station', 'Germany', 3), (2, 'Hamburg EV Charging Station', 'Germany', 2);
How many electric vehicle charging stations are there in the country 'Germany' with a level of at least 3?
SELECT COUNT(*) FROM charging_stations WHERE country = 'Germany' AND level >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Contract (CID INT, State VARCHAR(20), Value DECIMAL(10, 2)); INSERT INTO Contract (CID, State, Value) VALUES (1, 'Texas', 100000), (2, 'California', 200000), (3, 'Virginia', 300000);
Find the number of contracts awarded per state in the US, and the total value of these contracts?
SELECT State, COUNT(CID) as NumContracts, SUM(Value) as TotalValue FROM Contract GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE Sites (SiteID INT PRIMARY KEY, SiteName TEXT, Location TEXT, StartDate DATE, EndDate DATE, Era TEXT);
Drop the 'Era' column from the Sites table.
ALTER TABLE Sites DROP COLUMN Era;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_usage(landfill VARCHAR(50), year INT, used FLOAT, capacity FLOAT); INSERT INTO landfill_usage(landfill, year, used, capacity) VALUES('Landfill1', 2021, 52000, 55000), ('Landfill1', 2020, 48000, 55000), ('Landfill2', 2021, 63000, 65000), ('Landfill2', 2020, 60000, 65000), ('Landfill3', 2021, 73000, 75000), ('Landfill3', 2020, 70000, 75000);
What is the total capacity of each landfill in GB that reached its limit in 2021?
SELECT landfill, SUM(capacity) FROM landfill_usage WHERE landfill IN (SELECT landfill FROM landfill_usage WHERE year = 2021 GROUP BY landfill HAVING SUM(used) >= SUM(capacity)) GROUP BY landfill;
gretelai_synthetic_text_to_sql
CREATE TABLE active_rigs (id INT, location VARCHAR(20), type VARCHAR(20), status VARCHAR(10)); INSERT INTO active_rigs (id, location, type, status) VALUES (1, 'Beaufort Sea', 'Drilling', 'Active'), (2, 'Beaufort Sea', 'Production', 'Active');
Show me the number of active rigs in the Beaufort Sea by rig type.
SELECT type, COUNT(*) FROM active_rigs WHERE location = 'Beaufort Sea' AND status = 'Active' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (id INT, genre VARCHAR(20), date DATE); INSERT INTO Streams (id, genre, date) VALUES (1, 'Country', '2022-02-01'), (2, 'Pop', '2022-01-15'), (3, 'Country', '2022-02-10');
How many Country music streams occurred in February?
SELECT COUNT(*) FROM Streams WHERE genre = 'Country' AND date BETWEEN '2022-02-01' AND '2022-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Heat'); CREATE TABLE games (game_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT, home_team_assists INT, away_team_assists INT); INSERT INTO games (game_id, home_team_id, away_team_id, home_team_score, away_team_score, home_team_assists, away_team_assists) VALUES (1, 1, 2, 100, 90, 25, 20), (2, 2, 1, 80, 85, 22, 27), (3, 1, 3, 110, 105, 28, 30), (4, 4, 1, 70, 75, 18, 25);
What is the average number of assists per game for the Heat?
SELECT AVG(home_team_assists + away_team_assists) as avg_assists FROM games WHERE home_team_id = (SELECT team_id FROM teams WHERE team_name = 'Heat') OR away_team_id = (SELECT team_id FROM teams WHERE team_name = 'Heat');
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, state VARCHAR(2), policy_type VARCHAR(20), age INT); INSERT INTO policyholders (id, state, policy_type, age) VALUES (1, 'NY', 'Life', 35), (2, 'NY', 'Health', 45), (3, 'NJ', 'Life', 50), (4, 'PA', 'Life', 55), (5, 'CA', 'Life', 60);
What is the count of policyholders in each state with life insurance policies?
SELECT state, COUNT(*) FROM policyholders WHERE policy_type = 'Life' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, shipped_date DATE, destination VARCHAR(20), weight INT, delivery_time INT); INSERT INTO shipments (id, shipped_date, destination, weight, delivery_time) VALUES (1, '2022-03-15', 'Oceania', 120, 4), (2, '2022-03-20', 'Oceania', 180, 6), (3, '2022-03-03', 'Oceania', 200, 5);
What is the total delivery time for shipments with a weight greater than 100 kg that were sent to 'Oceania' in the last week?
SELECT SUM(delivery_time) FROM shipments WHERE shipped_date >= DATEADD(day, -7, GETDATE()) AND destination = 'Oceania' AND weight > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, name VARCHAR(100)); CREATE TABLE deep_sea_mining_sites (site_id INT, name VARCHAR(100), country_id INT); INSERT INTO countries (country_id, name) VALUES (1, 'Papua New Guinea'); INSERT INTO deep_sea_mining_sites (site_id, name, country_id) VALUES (1, 'Solwara 1', 1);
Which countries have more than 5 deep-sea mining sites?
SELECT countries.name FROM countries INNER JOIN deep_sea_mining_sites ON countries.country_id = deep_sea_mining_sites.country_id GROUP BY countries.name HAVING COUNT(deep_sea_mining_sites.site_id) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE vaccine_records (patient_id INT, vaccine_name VARCHAR(20), age INT, state VARCHAR(20)); INSERT INTO vaccine_records VALUES (1, 'Pfizer', 35, 'Texas'), (2, 'Pfizer', 42, 'Texas'), (3, 'Moderna', 50, 'Florida'); INSERT INTO vaccine_records VALUES (4, 'Pfizer', 25, 'New York'), (5, 'Pfizer', 30, 'New York'), (6, 'Johnson', 40, 'New York');
How many patients received the Pfizer vaccine in each state?
SELECT state, COUNT(*) FROM vaccine_records WHERE vaccine_name = 'Pfizer' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (WarehouseID int, WarehouseName varchar(50), City varchar(50)); INSERT INTO Warehouse VALUES (1, 'Warehouse 1', 'New York'), (2, 'Warehouse 2', 'Los Angeles'), (3, 'Warehouse 3', 'Chicago');
Insert a new record into the Warehouse table for a new warehouse in Dallas.
INSERT INTO Warehouse (WarehouseID, WarehouseName, City) VALUES (4, 'Warehouse 4', 'Dallas')
gretelai_synthetic_text_to_sql
CREATE TABLE Users (id INT, user_name TEXT); CREATE TABLE Workouts (id INT, user_id INT, workout_name TEXT, calories INT); INSERT INTO Users (id, user_name) VALUES (1, 'John Doe'); INSERT INTO Users (id, user_name) VALUES (2, 'Jane Smith');
Insert a new row into the Workouts table with the user_id of 3, workout_name of 'Weight Lifting', and 500 calories.
INSERT INTO Workouts (id, user_id, workout_name, calories) VALUES (1, 3, 'Weight Lifting', 500);
gretelai_synthetic_text_to_sql
CREATE TABLE wnba_players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(20)); INSERT INTO wnba_players (player_id, name, age, position) VALUES (1, 'Sue Bird', 40, 'Guard'); INSERT INTO wnba_players (player_id, name, age, position) VALUES (2, 'Breanna Stewart', 26, 'Forward');
What is the average age of players in the WNBA?
SELECT AVG(age) FROM wnba_players;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), age INT, city VARCHAR(50)); INSERT INTO clients VALUES (1, 'John Doe', 55, 'New York'), (2, 'Jane Smith', 45, 'Los Angeles'), (3, 'Mike Johnson', 58, 'New York'), (4, 'Alice Davis', 35, 'Chicago'), (5, 'Bob Brown', 40, 'New York');
What is the number of clients living in each city?
SELECT city, COUNT(*) FROM clients GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Dates (date DATE); CREATE TABLE Sales (sale_id INT, date DATE, product_id INT, quantity INT); CREATE TABLE Products (product_id INT, product_name VARCHAR(255), is_gluten_free BOOLEAN);
How many units of gluten-free products were sold in the first quarter of 2022?
SELECT SUM(s.quantity) as total_quantity FROM Sales s JOIN Dates d ON s.date = d.date JOIN Products p ON s.product_id = p.product_id WHERE d.date BETWEEN '2022-01-01' AND '2022-03-31' AND p.is_gluten_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_emergencies (id INT, incident_type VARCHAR(50), incident_location VARCHAR(100), response_time INT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO medical_emergencies (id, incident_type, incident_location, response_time, city, state) VALUES (1, 'Medical Emergency', '321 Pine St', 12, 'Miami', 'FL');
What is the total number of medical emergencies in the state of Florida?
SELECT COUNT(*) FROM medical_emergencies WHERE state = 'FL';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicles(Id INT, Name VARCHAR(50), Horsepower INT, ReleaseYear INT, Country VARCHAR(50)); INSERT INTO ElectricVehicles(Id, Name, Horsepower, ReleaseYear, Country) VALUES (1, 'Tesla Model S', 417, 2015, 'USA'); INSERT INTO ElectricVehicles(Id, Name, Horsepower, ReleaseYear, Country) VALUES (2, 'Tesla Model 3', 283, 2017, 'USA');
What is the average horsepower of electric vehicles released in the US since 2015?
SELECT AVG(Horsepower) FROM ElectricVehicles WHERE ReleaseYear >= 2015 AND Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO education_programs (id, name, region) VALUES (1, 'Wildlife Rangers', 'North America'), (2, 'Conservation Kids', 'Europe'), (3, 'Eco Warriors', 'Africa'), (4, 'Nature Guardians', 'Asia'), (5, 'Ocean Explorers', 'Oceania');
Find all education programs in the 'North America' region
SELECT * FROM education_programs WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID INT, PolicyholderName VARCHAR(50), ClaimDate DATE); INSERT INTO Claims VALUES (1, 'John Doe', '2017-01-01'), (2, 'Jane Smith', '2019-05-05'), (3, 'John Doe', '2021-12-31'), (4, 'Jim Brown', '2016-09-09');
Delete all records from the Claims table that are older than 5 years.
DELETE FROM Claims WHERE ClaimDate < NOW() - INTERVAL '5 years';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, warehouse_name VARCHAR(50), country VARCHAR(50), total_space INT, occupied_space INT); INSERT INTO warehouses VALUES (1, 'Warehouse A', 'Canada', 20000, 15000), (2, 'Warehouse B', 'Canada', 30000, 25000), (3, 'Warehouse C', 'Canada', 15000, 10000);
What is the total occupied space and the percentage of total warehouse space occupied for each warehouse in Canada?
SELECT warehouse_name, total_space, occupied_space, (occupied_space * 100.0 / total_space) as occupation_percentage FROM warehouses WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255), assignment VARCHAR(255));
Insert a new record into the "journalists" table with "id" as 201, "name" as "Alex García", "email" as "alex.garcia@elpais.es", "assignment" as "Investigative Reporting"
INSERT INTO journalists (id, name, email, assignment) VALUES (201, 'Alex García', 'alex.garcia@elpais.es', 'Investigative Reporting');
gretelai_synthetic_text_to_sql
CREATE TABLE Cyber_Strategies (id INT, name VARCHAR(50), location VARCHAR(20), type VARCHAR(20), budget INT); INSERT INTO Cyber_Strategies (id, name, location, type, budget) VALUES (1, 'Cyber Shield', 'North America', 'Defense', 5000000);
What is the average budget of cybersecurity strategies in the 'Cyber_Strategies' table?
SELECT AVG(budget) FROM Cyber_Strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'NYC Warehouse', 'NYC'); CREATE TABLE Packages (id INT, warehouse_id INT, delivery_time INT, status VARCHAR(20)); INSERT INTO Packages (id, warehouse_id, delivery_time, status) VALUES (1, 1, 5, 'shipped'), (2, 1, 7, 'shipped'), (3, 1, 6, 'processing');
What is the minimum delivery time for packages shipped to 'NYC'?
SELECT MIN(delivery_time) FROM Packages WHERE warehouse_id = (SELECT id FROM Warehouse WHERE city = 'NYC') AND status = 'shipped';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (ID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), City VARCHAR(50), State VARCHAR(20), ZipCode VARCHAR(10), RiskCategory VARCHAR(10));
Update the risk category of policyholders living in New York to 'High Risk'.
UPDATE Policyholders SET RiskCategory = 'High Risk' WHERE State = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, type VARCHAR(255), last_maintenance_date DATE); INSERT INTO military_equipment (equipment_id, type, last_maintenance_date) VALUES (1, 'Tank', '2021-05-12'), (2, 'Helicopter', '2020-09-25'), (3, 'Drone', '2022-03-28');
Update the last_maintenance_date to '2021-12-11' for equipment_id 1 in the 'military_equipment' table
UPDATE military_equipment SET last_maintenance_date = '2021-12-11' WHERE equipment_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE language_preservation_programs (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO language_preservation_programs (id, name, location) VALUES (1, 'Quechua Language Program', 'Peru'), (2, 'Greenlandic Language Program', 'Greenland');
What are the names and locations of all language preservation programs in the 'language_preservation' schema?
SELECT name, location FROM language_preservation.language_preservation_programs;
gretelai_synthetic_text_to_sql
CREATE TABLE Port_Infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), cost INT);
Find the project with the lowest cost in 'Port_Infrastructure' table.
SELECT project_name, MIN(cost) FROM Port_Infrastructure;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, name VARCHAR(50)); CREATE TABLE Workouts (workout_id INT, user_id INT, workout_type VARCHAR(10), heart_rate INT); INSERT INTO Users (user_id, name) VALUES (1, 'Alice'), (2, 'Bob'); INSERT INTO Workouts (workout_id, user_id, workout_type, heart_rate) VALUES (1, 1, 'in-person', 120);
What is the average heart rate during in-person workouts for each user in the last month?
SELECT u.name, AVG(w.heart_rate) FROM Users u JOIN Workouts w ON u.user_id = w.user_id WHERE w.workout_type = 'in-person' AND w.workout_id IN (SELECT workout_id FROM Workouts WHERE last_modified >= DATEADD(month, -1, GETDATE())) GROUP BY u.name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name TEXT, location TEXT, biomass FLOAT);
What is the total biomass of marine life in all marine protected areas in the Atlantic Ocean?
SELECT SUM(marine_protected_areas.biomass) AS total_biomass FROM marine_protected_areas WHERE marine_protected_areas.location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (region VARCHAR(20), source VARCHAR(20));
Show the number of renewable energy sources for each region
SELECT region, COUNT(source) FROM renewable_energy GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), City VARCHAR(50)); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, City) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'Los Angeles'), (3, 'Alice Johnson', 'Chicago'); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2025-01-01', 100.00), (2, 1, '2025-01-02', 200.00), (3, 2, '2025-01-01', 150.00), (4, NULL, '2025-01-01', 50.00);
What is the total amount donated by each donor in 2025, ranked in descending order?
SELECT d.DonorName, SUM(DonationAmount) AS TotalDonated FROM Donors d JOIN Donations don ON d.DonorID = don.DonorID WHERE YEAR(DonationDate) = 2025 GROUP BY d.DonorName ORDER BY TotalDonated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, object_weight FLOAT);
What is the total weight of all space debris objects?
SELECT SUM(object_weight) FROM space_debris;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farms AS SELECT f.name AS farmer_name, c.crop_name FROM farmers f JOIN crops c ON f.id = c.farmer_id JOIN farm_regions fr ON f.id = fr.farm_id WHERE fr.region = 'urban'; INSERT INTO urban_farms (farmer_name, crop_name) VALUES ('Jane', 'maize'), ('Alice', 'carrot'), ('Bob', 'soybean');
List all the farmers and the crops they cultivate in 'urban' areas.
SELECT * FROM urban_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_gender TEXT);
Show the number of startups founded by women in each industry
SELECT c.industry, COUNT(*) FROM company c WHERE founder_gender = 'Female' GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE community_members (id INT, name TEXT, engagement INT, language TEXT); INSERT INTO community_members (id, name, engagement, language) VALUES (1, 'Member A', 5000, 'Language1'), (2, 'Member B', 3000, 'Language2'), (3, 'Member C', 7000, 'Language3');
What is the name of the community member who has engaged the most in language preservation?
SELECT name FROM community_members WHERE engagement = (SELECT MAX(engagement) FROM community_members)
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artist VARCHAR(20), title VARCHAR(50), year INT, type VARCHAR(20)); INSERT INTO Artworks (id, artist, title, year, type) VALUES (1, 'African Artist 1', 'Artwork 1', 2000, 'Painting'); INSERT INTO Artworks (id, artist, title, year, type) VALUES (2, 'African Artist 2', 'Artwork 2', 2005, 'Sculpture');
How many artworks were created each year by artists from Africa?
SELECT year, COUNT(*) AS artworks_per_year FROM Artworks WHERE artist LIKE 'African Artist%' GROUP BY year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE insurance (id INT, age_group INT, insured BOOLEAN);
Calculate the percentage of the population without health insurance, by age group.
SELECT i.age_group, AVG(i.insured) AS avg_insurance_rate FROM insurance i GROUP BY i.age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, region VARCHAR(255), year INT, sector VARCHAR(255), amount FLOAT); INSERT INTO climate_finance (id, region, year, sector, amount) VALUES (1, 'India', 2005, 'renewable energy', 2500000);
What is the total amount of climate finance invested in renewable energy sources in India before 2010?
SELECT SUM(amount) FROM climate_finance WHERE region = 'India' AND sector = 'renewable energy' AND year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_conferences (id INT, name VARCHAR(100), year INT, submissions INT, location VARCHAR(100), prev_location VARCHAR(100));
What AI safety conferences in Asia or Africa had more than 2 submissions in 2022, excluding those that have been held in the same location twice in a row?
SELECT name FROM ai_conferences WHERE year = 2022 AND (location = 'Asia' OR location = 'Africa') AND submissions > 2 AND id NOT IN (SELECT id FROM ai_conferences WHERE prev_location = location AND year = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShows (Id INT, Vehicle VARCHAR(50), Year INT, Displayed VARCHAR(5)); CREATE TABLE ElectricVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Horsepower INT);
Delete records of vehicles from the 'AutoShows' database that are not in the 'ElectricVehicles' table.
DELETE FROM AutoShows WHERE Vehicle NOT IN (SELECT Model FROM ElectricVehicles);
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policyholder_id INT, state TEXT); INSERT INTO policies (id, policyholder_id, state) VALUES (1, 1, 'CA'); INSERT INTO policies (id, policyholder_id, state) VALUES (2, 2, 'CA'); INSERT INTO policies (id, policyholder_id, state) VALUES (3, 3, 'NY'); INSERT INTO policies (id, policyholder_id, state) VALUES (4, 4, 'TX'); INSERT INTO policies (id, policyholder_id, state) VALUES (5, 5, 'FL'); INSERT INTO policies (id, policyholder_id, state) VALUES (6, 6, 'CA');
What is the total number of policies in 'CA' and 'FL'?
SELECT SUM(state = 'CA') + SUM(state = 'FL') FROM policies;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, rating DECIMAL(3,2));
What is the average rating of movies released between 2015 and 2020?
SELECT AVG(rating) FROM movies WHERE release_year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10)); CREATE TABLE posts (id INT PRIMARY KEY, user_id INT, title VARCHAR(100), post_date DATE); CREATE TABLE likes (id INT PRIMARY KEY, post_id INT, user_id INT); INSERT INTO users (id, name, age, gender) VALUES (1, 'Olivia', 25, 'Female'); INSERT INTO users (id, name, age, gender) VALUES (2, 'Sam', 30, 'Male'); INSERT INTO posts (id, user_id, title, post_date) VALUES (1, 1, 'First post', '2022-01-01'); INSERT INTO likes (id, post_id, user_id) VALUES (1, 1, 2);
Who has liked posts from users aged 25 or older?
SELECT users.name FROM users INNER JOIN posts ON users.id = posts.user_id INNER JOIN likes ON posts.id = likes.post_id WHERE users.age >= 25;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, name VARCHAR(50), service_type VARCHAR(50), data_usage FLOAT);
Insert a new record with 'subscriber_id' 25, 'name' 'Jane Smith', 'service_type' 'Mobile', and 'data_usage' 45 in the 'subscribers' table, ordered by 'data_usage' in descending order.
INSERT INTO subscribers (subscriber_id, name, service_type, data_usage) VALUES (25, 'Jane Smith', 'Mobile', 45);
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, location TEXT, mental_health_score INT); INSERT INTO community_health_workers (id, name, location, mental_health_score) VALUES (1, 'Alice', 'New York', 80), (2, 'Bob', 'Los Angeles', 85), (3, 'Charlie', 'New York', 82);
What is the average mental health score for community health workers in New York?
SELECT AVG(mental_health_score) FROM community_health_workers WHERE location = 'New York' AND occupation = 'community health worker';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, rating FLOAT); INSERT INTO movies (id, title, release_year, rating) VALUES (1, 'Movie1', 2017, 7.8); INSERT INTO movies (id, title, release_year, rating) VALUES (2, 'Movie2', 2018, 8.2); INSERT INTO movies (id, title, release_year, rating) VALUES (3, 'Movie3', 2019, 7.5); INSERT INTO movies (id, title, release_year, rating) VALUES (4, 'Movie4', 2020, 8.0); INSERT INTO movies (id, title, release_year, rating) VALUES (5, 'Movie5', 2021, 7.9);
What's the minimum rating for movies released between 2017 and 2019?
SELECT MIN(rating) FROM movies WHERE release_year BETWEEN 2017 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Athletes (AthleteID INT, AthleteName VARCHAR(100), TeamID INT, LastGameDate DATE); CREATE TABLE TeamRoster (TeamID INT, AthleteID INT);
Delete athletes who haven't participated in any games in the last 12 months.
DELETE FROM Athletes WHERE AthleteID IN (SELECT a.AthleteID FROM Athletes a JOIN TeamRoster tr ON a.TeamID = tr.TeamID WHERE a.LastGameDate < DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH));
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (id INT, incident VARCHAR(20), risk_level VARCHAR(20), mitigation_strategy TEXT, country VARCHAR(20));
Insert new records into the 'ai_safety' table for 'Label Noise' in 'Italy' with 'Medium' risk level and 'Implemented' mitigation strategy
INSERT INTO ai_safety (id, incident, risk_level, mitigation_strategy, country) VALUES (3, 'Label Noise', 'Medium', 'Implemented', 'Italy');
gretelai_synthetic_text_to_sql
CREATE TABLE Country (CountryID int, CountryName varchar(50)); INSERT INTO Country (CountryID, CountryName) VALUES (1, 'France'), (2, 'Germany'), (3, 'Italy'); CREATE TABLE Region (RegionID int, RegionName varchar(50)); INSERT INTO Region (RegionID, RegionName) VALUES (1, 'Europe'), (2, 'Asia'), (3, 'Africa'); CREATE TABLE VirtualTourism (VTID int, CountryID int, RegionID int, Revenue int, Quarter varchar(10), Year int); INSERT INTO VirtualTourism (VTID, CountryID, RegionID, Revenue, Quarter, Year) VALUES (1, 1, 1, 70000, 'Q3', 2022);
What was the revenue from virtual tourism in Q3 2022 in Europe?
SELECT SUM(VirtualTourism.Revenue) as TotalRevenue FROM VirtualTourism JOIN Country ON VirtualTourism.CountryID = Country.CountryID JOIN Region ON VirtualTourism.RegionID = Region.RegionID WHERE VirtualTourism.Quarter = 'Q3' AND VirtualTourism.Year = 2022 AND Region.RegionName = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), category VARCHAR(50), supplier_id INT, price DECIMAL(5,2), is_ethical_labor_practices BOOLEAN); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50)); INSERT INTO products (product_id, product_name, category, supplier_id, price, is_ethical_labor_practices) VALUES (1, 'T-Shirt', 'Clothing', 1, 20.00, true), (2, 'Jeans', 'Clothing', 2, 50.00, false), (3, 'Shoes', 'Footwear', 3, 75.00, true), (4, 'Dress', 'Clothing', 1, 30.00, true), (5, 'Bag', 'Accessories', 2, 40.00, false); INSERT INTO suppliers (supplier_id, supplier_name) VALUES (1, 'GreenEarth'), (2, 'EcoBlue'), (3, 'CircularWear');
What is the average price of ethical labor practice products per category?
SELECT category, AVG(price) FROM products INNER JOIN suppliers ON products.supplier_id = suppliers.supplier_id WHERE is_ethical_labor_practices = true GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE signups (signup_id INT, signup_date DATE, region VARCHAR(50), signup_count INT); INSERT INTO signups VALUES (401, '2022-07-01', 'North America', 50), (402, '2022-07-03', 'Europe', 30), (403, '2022-07-05', 'Asia', 40), (404, '2022-07-07', 'South America', 20);
What is the number of user signups for each region in the first week of July 2022?
SELECT region, SUM(signup_count) as total_signups FROM signups WHERE signup_date BETWEEN '2022-07-01' AND '2022-07-07' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists defense_projects;CREATE TABLE if not exists defense_project_timelines(project_name text, start_year integer, end_year integer, status text);INSERT INTO defense_project_timelines(project_name, start_year, end_year, status) VALUES('F-35', 2007, 2017, 'Completed'), ('Joint Light Tactical Vehicle', 2012, 2021, 'Delayed'), ('Global Hawk', 2001, 2011, 'Completed');
How many defense projects were delayed in 2021?
SELECT COUNT(*) FROM defense_project_timelines WHERE status = 'Delayed' AND end_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name VARCHAR(50), sector VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO community_development (id, initiative_name, sector, start_date, end_date, budget) VALUES (1, 'Youth Empowerment Program', 'Community Development', '2019-01-01', '2020-12-31', 250000);
Which community development initiatives were completed in '2021'?
SELECT initiative_name FROM community_development WHERE YEAR(end_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(20), Genre VARCHAR(20), Available_in INT); INSERT INTO Games (GameID, GameName, Genre, Available_in) VALUES (1, 'Space Explorer', 'Action', 1); INSERT INTO Games (GameID, GameName, Genre, Available_in) VALUES (2, 'Mystery Solver', 'Adventure', 1);
How many unique game genres are available in the US?
SELECT COUNT(DISTINCT Genre) FROM Games WHERE Available_in = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill (id INT, city VARCHAR(50), country VARCHAR(50), capacity INT, year INT); INSERT INTO landfill (id, city, country, capacity, year) VALUES (1, 'Toronto', 'Canada', 1200000, 2022), (2, 'Vancouver', 'Canada', 800000, 2022), (3, 'Montreal', 'Canada', 700000, 2022);
Display the top 2 cities with the highest landfill capacity in Canada in 2022, along with their capacities.
SELECT city, capacity FROM (SELECT city, capacity, ROW_NUMBER() OVER (PARTITION BY country ORDER BY capacity DESC) as rank FROM landfill WHERE country = 'Canada' AND year = 2022) AS subquery WHERE rank <= 2;
gretelai_synthetic_text_to_sql