context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Donors (DonorID INT, DonorType VARCHAR(10), Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorType, Amount) VALUES (1, 'Individual', 150.00), (2, 'Organization', 5000.00), (3, 'Individual', 250.00);
What is the total amount donated by individual donors and organizations?
SELECT SUM(Amount) FROM Donors WHERE DonorType IN ('Individual', 'Organization');
gretelai_synthetic_text_to_sql
CREATE TABLE flu_shots (id INT, shot_id INT, patient_id INT, shot_date DATE, province VARCHAR(50)); INSERT INTO flu_shots (id, shot_id, patient_id, shot_date, province) VALUES (1, 1001, 801, '2021-01-15', 'Ontario'); INSERT INTO flu_shots (id, shot_id, patient_id, shot_date, province) VALUES (2, 1002, 802, '2021-02-03', 'Quebec');
What is the total number of flu shots administered per month in Canada, partitioned by province?
SELECT province, DATE_TRUNC('month', shot_date) AS month, COUNT(*) FROM flu_shots WHERE country = 'Canada' GROUP BY province, month;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, region TEXT); CREATE TABLE projects (id INT, organization_id INT, project_name TEXT, start_date DATE); INSERT INTO organizations (id, name, region) VALUES (1, 'Aid Africa', 'Africa'), (2, 'Asian Aid', 'Asia'), (3, 'Healthcare Hope', 'Asia'); INSERT INTO projects (id, organization_id, project_name, start_date) VALUES (1, 2, 'Healthcare Initiative', '2018-04-01'), (2, 2, 'Education Program', '2017-08-15'), (3, 3, 'Disaster Relief', '2019-12-25');
What is the total number of volunteers in organizations that have implemented healthcare projects in Asia since 2018?
SELECT COUNT(DISTINCT o.id) FROM organizations o INNER JOIN projects p ON o.id = p.organization_id WHERE o.region = 'Asia' AND p.project_name LIKE '%healthcare%' AND p.start_date >= '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_projects (year INT, country VARCHAR(255), funding FLOAT); INSERT INTO climate_finance_projects (year, country, funding) VALUES (2020, 'USA', 12000000), (2020, 'France', 18000000), (2020, 'Brazil', 15000000), (2021, 'India', 10000000), (2021, 'China', 17000000);
What is the average climate finance project funding per country in 2021?
SELECT country, AVG(funding) AS avg_funding FROM climate_finance_projects WHERE year = 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_daily_incidents (id INT, incident_date DATE, num_incidents INT); INSERT INTO cybersecurity_daily_incidents (id, incident_date, num_incidents) VALUES (1, '2022-01-01', 20), (2, '2022-01-02', 30), (3, '2022-01-03', 25); CREATE VIEW recent_cybersecurity_daily_incidents AS SELECT * FROM cybersecurity_daily_incidents WHERE incident_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
What is the average number of cybersecurity incidents per day in the last month?
SELECT AVG(num_incidents) FROM recent_cybersecurity_daily_incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget FLOAT); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 15000.00), (2, 'Healthcare', 20000.00); CREATE TABLE ProgramOutcomes (ProgramID INT, Outcome TEXT); INSERT INTO ProgramOutcomes (ProgramID, Outcome) VALUES (1, 'Increased literacy rates'), (2, 'Improved healthcare access');
List all programs with their associated budgets and outcomes?
SELECT Programs.ProgramName, Programs.Budget, ProgramOutcomes.Outcome FROM Programs INNER JOIN ProgramOutcomes ON Programs.ProgramID = ProgramOutcomes.ProgramID;
gretelai_synthetic_text_to_sql
CREATE TABLE Performances (id INT, artist VARCHAR(50), city VARCHAR(50)); INSERT INTO Performances (id, artist, city) VALUES (1, 'Artist A', 'New York'), (2, 'Artist B', 'Chicago'), (3, 'Artist A', 'Chicago'), (4, 'Artist C', 'Los Angeles');
Find the names of artists who have performed in both New York and Chicago.
SELECT artist FROM Performances WHERE city IN ('New York', 'Chicago') GROUP BY artist HAVING COUNT(DISTINCT city) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Project (id INT, name VARCHAR(50), budget FLOAT, state VARCHAR(50)); INSERT INTO Project (id, name, budget, state) VALUES (1, 'Water Treatment Plant', 50000000, 'Texas');
What is the total budget for water infrastructure projects in Texas?
SELECT SUM(budget) FROM Project WHERE state = 'Texas' AND type = 'Water Infrastructure';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), num_employees INT); INSERT INTO mining_sites (id, name, location, num_employees) VALUES (1, 'Site Alpha', 'USA', 100), (2, 'Site Bravo', 'Canada', 150), (3, 'Site Charlie', 'Australia', 200);
What is the location of the mining site with the least employees in the 'mining_sites' table?
SELECT location FROM mining_sites WHERE num_employees = (SELECT MIN(num_employees) FROM mining_sites);
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT PRIMARY KEY, freight_forwarder VARCHAR(50), warehouse VARCHAR(50), status VARCHAR(20), delivery_date DATE); CREATE TABLE warehouses (id INT PRIMARY KEY, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50));
List all records from the "shipments" table for freight forwarder "Reliable Freight" and the "warehouses" table for warehouses in "USA" or "Canada" in a single result set
SELECT s.id, s.freight_forwarder, s.warehouse, s.status, s.delivery_date, w.name, w.city, w.country FROM shipments s INNER JOIN warehouses w ON s.warehouse = w.name WHERE s.freight_forwarder = 'Reliable Freight' AND w.country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
diversity_metrics
Delete records with gender 'M' from the 'diversity_metrics' table
DELETE FROM diversity_metrics WHERE gender = 'M';
gretelai_synthetic_text_to_sql
CREATE TABLE projects_investments (id INT, name TEXT, focus TEXT, region TEXT, investment FLOAT); INSERT INTO projects_investments (id, name, focus, region, investment) VALUES (1, 'Clean Energy Project', 'Climate Action', 'Asia-Pacific', 100000.0), (2, 'Sustainable Agriculture Program', 'Biodiversity', 'Asia-Pacific', 150000.0);
Find the sum of investments for projects with a climate action focus in the Asia-Pacific region.
SELECT SUM(investment) FROM projects_investments WHERE focus = 'Climate Action' AND region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_transactions (id INT PRIMARY KEY, source VARCHAR(50), destination VARCHAR(50), energy_type VARCHAR(50), quantity INT, transaction_date DATE);
What is the total cost of wind energy transactions for each destination?
SELECT energy_transactions.destination, SUM(energy_transactions.quantity * carbon_pricing.price) FROM energy_transactions INNER JOIN carbon_pricing ON energy_transactions.energy_type = carbon_pricing.location WHERE energy_type = 'Wind' GROUP BY energy_transactions.destination;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (id INT, project_budget INT, project_status TEXT, country TEXT); INSERT INTO agricultural_innovation (id, project_budget, project_status, country) VALUES (1, 60000, 'completed', 'Thailand'), (2, 45000, 'in_progress', 'Vietnam'), (3, 70000, 'completed', 'Malaysia');
What is the total budget for agricultural innovation projects in Southeast Asia that have a budget greater than $50,000?
SELECT SUM(project_budget) FROM agricultural_innovation WHERE project_budget > 50000 AND country IN ('Southeast Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, country TEXT, points_per_game FLOAT);
What is the average points per game scored by players from the United States in the NBA?
SELECT AVG(points_per_game) FROM players WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents (incident_id INT, incident_date DATE, incident_country TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_date, incident_country) VALUES (1, '2021-03-15', 'USA'), (2, '2020-12-21', 'Canada'), (3, '2021-08-01', 'UK'); CREATE TABLE countries (country_id INT, country_name TEXT); INSERT INTO countries (country_id, country_name) VALUES (101, 'USA'), (102, 'Canada'), (103, 'UK'), (104, 'Australia');
What is the average number of AI safety incidents per country in the last year?
SELECT c.country_name, AVG(EXTRACT(YEAR FROM ai.incident_date)) as avg_year FROM ai_safety_incidents ai JOIN countries c ON ai.incident_country = c.country_name GROUP BY c.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (country VARCHAR(20), amount FLOAT); INSERT INTO climate_finance (country, amount) VALUES ('usa', 100000), ('canada', 75000), ('brazil', 55000), ('argentina', 40000), ('mexico', 35000);
What is the total climate finance spent by each country in the 'americas' region?
SELECT country, SUM(amount) FROM climate_finance WHERE country IN ('usa', 'canada', 'brazil', 'argentina', 'mexico') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (item_id INT, name TEXT, category TEXT, unit_price FLOAT, unit_quantity INT, unit_weight FLOAT, waste_factor FLOAT); INSERT INTO inventory (item_id, name, category, unit_price, unit_quantity, unit_weight, waste_factor) VALUES (1, 'Plastic Spoon', 'Disposable', 0.05, 100, 0.01, 0.02), (2, 'Paper Plate', 'Disposable', 0.10, 50, 0.05, 0.10); CREATE TABLE sales (sale_id INT, item_id INT, sale_quantity INT, sale_date DATE); INSERT INTO sales (sale_id, item_id, sale_quantity, sale_date) VALUES (1, 1, 200, '2022-03-05'), (2, 1, 300, '2022-04-12'), (3, 2, 100, '2022-03-15'), (4, 1, 150, '2022-06-01');
What is the total waste generated from disposable cutlery in the last quarter?
SELECT SUM(i.unit_quantity * i.unit_weight * s.sale_quantity * i.waste_factor) as total_waste FROM inventory i JOIN sales s ON i.item_id = s.item_id WHERE i.category = 'Disposable' AND s.sale_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainability_metrics (id INT PRIMARY KEY, fabric VARCHAR(50), water_reduction DECIMAL(3,2));
Insert a new record for 'Bamboo Viscose' with a water consumption reduction of '50%' into the 'sustainability_metrics' table
INSERT INTO sustainability_metrics (id, fabric, water_reduction) VALUES (2, 'Bamboo Viscose', 0.50);
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (MovieID INT, Title VARCHAR(255), Genre VARCHAR(50), ReleaseYear INT, ProductionBudget DECIMAL(10,2), IMDBRating DECIMAL(3,2));
What's the average production budget for action movies released between 2010 and 2015, and their respective IMDb ratings?
SELECT AVG(ProductionBudget) AS Avg_Budget, AVG(IMDBRating) AS Avg_Rating FROM Movies WHERE Genre = 'Action' AND ReleaseYear BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, user_id INT, city VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, user_id, city, amount, donation_date) VALUES (1, 1001, 'New York', 50.00, '2023-01-05'); INSERT INTO Donations (id, user_id, city, amount, donation_date) VALUES (2, 1002, 'Toronto', 75.00, '2023-01-10'); INSERT INTO Donations (id, user_id, city, amount, donation_date) VALUES (3, 1003, 'Mexico City', 100.00, '2023-03-15');
Find the top 2 cities with the highest average donation amount in 2023?
SELECT city, AVG(amount) as avg_donation FROM Donations WHERE donation_date >= '2023-01-01' AND donation_date < '2024-01-01' GROUP BY city ORDER BY avg_donation DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (song_id INT, stream_date DATE, genre VARCHAR(20), country VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO streams (song_id, stream_date, genre, country, revenue) VALUES (17, '2020-12-31', 'Classical', 'Brazil', 2.50);
Delete all records of Classical music streams in Brazil before January 1, 2021.
DELETE FROM streams WHERE genre = 'Classical' AND country = 'Brazil' AND stream_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE);
Show the names and locations of all restorative justice programs starting in 2023 from the 'programs' table
SELECT name, location FROM programs WHERE type = 'Restorative Justice' AND start_date >= '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255)); CREATE TABLE production_rates (factory_id INT, compound_name VARCHAR(255), production_rate INT); INSERT INTO factories (id, name) VALUES (1, 'Factory A'), (2, 'Factory B'); INSERT INTO production_rates (factory_id, compound_name, production_rate) VALUES (1, 'Compound X', 200), (1, 'Compound Y', 180), (2, 'Compound X', 250), (2, 'Compound Y', 220);
What are the total production rates for each compound in Factory A?
SELECT compound_name, SUM(production_rate) FROM production_rates INNER JOIN factories ON production_rates.factory_id = factories.id WHERE factories.name = 'Factory A' GROUP BY compound_name;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), agency VARCHAR(50), year INT); INSERT INTO space_missions (id, name, agency, year) VALUES (1, 'Apollo 11', 'NASA', 1969); INSERT INTO space_missions (id, name, agency, year) VALUES (2, 'Voyager 1', 'NASA', 1977); INSERT INTO space_missions (id, name, agency, year) VALUES (3, 'Mars Curiosity Rover', 'NASA', 2012); INSERT INTO space_missions (id, name, agency, year) VALUES (4, 'Sputnik 1', 'Roscosmos', 1957);
How many space missions have been conducted by NASA?
SELECT COUNT(*) FROM space_missions WHERE agency = 'NASA';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy (country VARCHAR(20), production FLOAT); INSERT INTO wind_energy (country, production) VALUES ('Canada', 15.2), ('Canada', 15.5), ('Mexico', 12.6), ('Mexico', 12.9);
What is the total wind energy production in Canada and Mexico?
SELECT SUM(production) as total_production, country FROM wind_energy GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (id INT, sensor_id VARCHAR(255), temperature DECIMAL(4,2), humidity DECIMAL(4,2), PRIMARY KEY (id)); INSERT INTO sensor_data (id, sensor_id, temperature, humidity) VALUES (1, 's1', 24.3, 55.1), (2, 's2', 26.8, 48.6), (3, 's3', 22.9, 72.5);
What's the sensor data for humidity above 70%?
SELECT * FROM sensor_data WHERE humidity > 70.0;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Stations (ID INT, Name VARCHAR(50), Type VARCHAR(50), Average_Distance FLOAT); INSERT INTO Space_Stations (ID, Name, Type, Average_Distance) VALUES (1, 'International Space Station', 'Space Station', 410.4);
What is the average distance of the International Space Station from Earth?
SELECT AVG(Average_Distance) FROM Space_Stations WHERE Name = 'International Space Station';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, treatment VARCHAR(20)); INSERT INTO patients (patient_id, age, treatment) VALUES (1, 35, 'CBT'), (2, 28, 'CBT'), (3, 42, 'CBT');
What is the average age of patients who received cognitive behavioral therapy (CBT)?
SELECT AVG(age) FROM patients WHERE treatment = 'CBT';
gretelai_synthetic_text_to_sql
CREATE TABLE species_data (measurement_id INT, measurement_date DATE, observed_species VARCHAR(50), location VARCHAR(50));
List the total number of species observed and the number of unique species observed for each year in the Arctic region.
SELECT YEAR(measurement_date) AS year, COUNT(observed_species) AS total_species_observed, COUNT(DISTINCT observed_species) AS unique_species_observed FROM species_data WHERE location LIKE '%Arctic%' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE SCHEMA pharma;CREATE TABLE pharma.company (id INT, name VARCHAR(50));CREATE TABLE pharma.expenditure (company_id INT, year INT, amount DECIMAL(10, 2)); INSERT INTO pharma.company (id, name) VALUES (1, 'AstraZeneca'), (2, 'Pfizer'); INSERT INTO pharma.expenditure (company_id, year, amount) VALUES (1, 2020, 12000000), (1, 2019, 11000000), (2, 2020, 15000000), (2, 2019, 13000000);
What was the total R&D expenditure for the year 2020 by company?
SELECT c.name, SUM(e.amount) FROM pharma.expenditure e JOIN pharma.company c ON e.company_id = c.id WHERE e.year = 2020 GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE products_cruelty (id INT, product_name TEXT, cruelty_free BOOLEAN); INSERT INTO products_cruelty (id, product_name, cruelty_free) VALUES (1, 'Lotion', true), (2, 'Shampoo', false), (3, 'Soap', true);
What is the total number of cruelty-free and non-cruelty-free products?
SELECT cruelty_free, COUNT(*) FROM products_cruelty GROUP BY cruelty_free;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID varchar(10), CargoWeight int, Region varchar(10)); INSERT INTO Vessels (VesselID, CargoWeight, Region) VALUES ('VesselO', 1200, 'Indian Ocean'), ('VesselP', 1800, 'Indian Ocean'), ('VesselQ', 1500, 'Atlantic');
What is the minimum cargo weight for vessels in the Indian Ocean?
SELECT MIN(CargoWeight) FROM Vessels WHERE Region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralHealthFacilities (FacilityID INT, Name VARCHAR(50), Address VARCHAR(100), TotalBeds INT); INSERT INTO RuralHealthFacilities (FacilityID, Name, Address, TotalBeds) VALUES (1, 'Rural Community Hospital', '1234 Rural Rd', 50), (2, 'Small Rural Clinic', '8899 Smalltown Ln', 25);
Delete records from 'RuralHealthFacilities' table where total beds are below 30.
DELETE FROM RuralHealthFacilities WHERE TotalBeds < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Grant (id INT, department_id INT, year INT, amount INT); INSERT INTO Grant (id, department_id, year, amount) VALUES (1, 1, 2018, 50000), (2, 1, 2019, 75000), (3, 2, 2018, 60000), (4, 3, 2017, 40000);
Show the number of research grants awarded each year for the Physics department
SELECT YEAR(g.year) as year, SUM(g.amount) as total_grants FROM Grant g WHERE g.department_id = (SELECT id FROM Department WHERE name = 'Physics') GROUP BY YEAR(g.year);
gretelai_synthetic_text_to_sql
CREATE TABLE Wind (field VARCHAR(50), date DATE, wind_speed FLOAT); INSERT INTO Wind (field, date, wind_speed) VALUES ('Field H', '2022-06-01', 12.1), ('Field H', '2022-06-02', 15.6), ('Field H', '2022-06-03', 10.3);
What is the maximum wind speed in field H in the past week?
SELECT MAX(wind_speed) FROM Wind WHERE field = 'Field H' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE homeruns (player VARCHAR(50), team VARCHAR(50), location VARCHAR(50), homeruns INTEGER); INSERT INTO homeruns (player, team, location, homeruns) VALUES ('Hank Aaron', 'Atlanta Braves', 'Home', 225), ('Hank Aaron', 'Milwaukee Brewers', 'Home', 83);
How many home runs did Hank Aaron hit at home during his career and what is the average number of home runs he hit per game at home?
SELECT COUNT(*) AS home_runs, AVG(homeruns) AS avg_home_runs_per_game FROM homeruns WHERE player = 'Hank Aaron' AND location = 'Home';
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationBudget (Service VARCHAR(25), Budget INT); INSERT INTO TransportationBudget (Service, Budget) VALUES ('Bus', 3000000), ('Train', 5000000), ('Subway', 4000000);
What is the minimum and maximum budget allocated for transportation services?
SELECT MIN(Budget), MAX(Budget) FROM TransportationBudget;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, length FLOAT, genre TEXT); INSERT INTO songs (id, title, length, genre) VALUES (1, 'Song1', 3.1, 'electronic'), (2, 'Song2', 4.3, 'dubstep'), (3, 'Song3', 4.1, 'house'), (4, 'Song4', 2.9, 'techno'), (5, 'Song5', 5.5, 'drum and bass'), (6, 'Song6', 6.4, 'trance');
What is the total duration of all electronic songs?
SELECT SUM(length) FROM songs WHERE genre IN ('electronic', 'dubstep', 'house', 'techno', 'drum and bass', 'trance');
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents_na (id INT, incident_name VARCHAR(255), incident_date DATE, region VARCHAR(255));
What is the number of AI safety incidents per quarter in North America?
SELECT region, DATEPART(YEAR, incident_date) as year, DATEPART(QUARTER, incident_date) as quarter, COUNT(*) FROM ai_safety_incidents_na WHERE region = 'North America' GROUP BY region, DATEPART(YEAR, incident_date), DATEPART(QUARTER, incident_date);
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, team_id INT, num_fans INT);
What is the minimum number of fans for each team in the 'events' table?
SELECT team_id, MIN(num_fans) FROM events GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Weather (location VARCHAR(50), temperature INT, timestamp TIMESTAMP);
What is the average temperature in Arizona in the past week?
SELECT AVG(temperature) FROM Weather WHERE location = 'Arizona' AND timestamp > NOW() - INTERVAL '1 week';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, Name VARCHAR(255), Type VARCHAR(255), Flag VARCHAR(255)); CREATE TABLE PortVisits (VisitID INT, VesselID INT, Port VARCHAR(255), VisitDate DATE, Country VARCHAR(255)); INSERT INTO Vessels (VesselID, Name, Type, Flag) VALUES (1, 'Island Explorer', 'Cruise', 'Bahamas'); INSERT INTO PortVisits (VisitID, VesselID, Port, VisitDate, Country) VALUES (1, 1, 'Auckland', '2022-03-14', 'New Zealand'), (2, 1, 'Sydney', '2022-04-01', 'Australia');
What are the names of all vessels that have visited ports in Oceania but not in Australia?
SELECT Vessels.Name FROM Vessels LEFT JOIN PortVisits ON Vessels.VesselID = PortVisits.VesselID WHERE PortVisits.Country NOT LIKE 'Australia%' AND Vessels.Flag LIKE 'Oceania%' GROUP BY Vessels.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerAge INT, GameName VARCHAR(20), Country VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (1, 25, 'Galactic Gold', 'United States'); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (2, 32, 'Starship Showdown', 'Egypt'); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (3, 28, 'Cosmic Conquerors', 'Japan');
What is the percentage of players from Africa who have played the game "Starship Showdown"?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Players WHERE Country LIKE 'Africa%')) as Percentage FROM Players WHERE GameName = 'Starship Showdown' AND Country LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE sports (sport_id INT, sport_name VARCHAR(50)); CREATE TABLE tickets (ticket_id INT, purchase_date DATE, revenue DECIMAL(10,2), quantity INT, sport_id INT);
What is the total revenue for each sport?
SELECT s.sport_name, SUM(t.revenue) as total_revenue FROM sports s JOIN tickets t ON s.sport_id = t.sport_id GROUP BY s.sport_name;
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_center (case_id INT, center_name VARCHAR(50), case_duration INT); INSERT INTO restorative_justice_center VALUES (1, 'Center A', 30), (2, 'Center B', 45), (3, 'Center C', 60), (4, 'Center A', 45);
What is the total number of cases handled by each restorative justice center and the average duration of cases?
SELECT center_name, COUNT(*) AS cases_handled, AVG(case_duration) AS avg_duration FROM restorative_justice_center GROUP BY center_name;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (country VARCHAR(255), year INT, population INT, emissions FLOAT); INSERT INTO co2_emissions (country, year, population, emissions) VALUES ('China', 2015, 1367000000, 10000), ('China', 2015, 1367000000, 10500), ('China', 2020, 1439000000, 12000), ('China', 2020, 1439000000, 12500);
What was the average CO2 emissions per capita in China in 2015 and 2020?
SELECT AVG(emissions/population) as avg_emissions_per_capita, year FROM co2_emissions WHERE country = 'China' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (inventory_id INT, inventory_category VARCHAR(50), quantity INT); INSERT INTO inventory (inventory_id, inventory_category, quantity) VALUES (1, 'Produce', 500), (2, 'Meat', 1000), (3, 'Dairy', 750);
What is the total quantity of each inventory category?
SELECT inventory_category, SUM(quantity) FROM inventory GROUP BY inventory_category;
gretelai_synthetic_text_to_sql
CREATE TABLE un_agencies (agency_name VARCHAR(255), country VARCHAR(255), funds_spent DECIMAL(10,2), funds_date DATE); INSERT INTO un_agencies (agency_name, country, funds_spent, funds_date) VALUES ('UNA', 'Somalia', 60000, '2016-02-25'), ('UNB', 'Somalia', 70000, '2016-08-17'), ('UNC', 'Somalia', 80000, '2016-11-29');
What was the total amount of funds spent by UN agencies in Somalia in 2016?
SELECT SUM(funds_spent) FROM un_agencies WHERE country = 'Somalia' AND YEAR(funds_date) = 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE brand (id INT PRIMARY KEY, name VARCHAR(50), market_value INT, sustainability_rating VARCHAR(10)); INSERT INTO brand (id, name, market_value, sustainability_rating) VALUES (1, 'Brand A', 1200000000, 'medium'), (2, 'Brand B', 800000000, 'low'), (3, 'Brand C', 1500000000, 'medium');
Update 'brand' table, setting 'sustainability_rating' as 'high' if 'market_value' is above 1000000000
UPDATE brand SET sustainability_rating = 'high' WHERE market_value > 1000000000;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicWorksProjects (id INT, city VARCHAR(50), country VARCHAR(50), completion_year INT);
How many public works projects were completed in the city of Toronto, Canada between 2015 and 2020?
SELECT COUNT(*) FROM PublicWorksProjects WHERE city = 'Toronto' AND country = 'Canada' AND completion_year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (1, 'TechFem', 'Technology', 2015, 'Female'), (2, 'GreenInno', 'GreenTech', 2018, 'Male'), (3, 'TechForAll', 'Technology', 2017, 'Female');
Update the founder_gender to 'Non-binary' for the startup with name 'TechForAll'.
UPDATE companies SET founder_gender = 'Non-binary' WHERE name = 'TechForAll';
gretelai_synthetic_text_to_sql
CREATE TABLE school_districts (district_id INT, district_name TEXT, state TEXT, budget FLOAT); INSERT INTO school_districts (district_id, district_name, state, budget) VALUES (1, 'Albany', 'New York', 2000000), (2, 'Buffalo', 'New York', 2500000), (3, 'New York City', 'New York', 12000000);
What is the average budget allocated per school district in the state of New York?
SELECT AVG(budget) FROM school_districts WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonationDate DATE); INSERT INTO Donors (DonorID, DonationDate) VALUES (1, '2020-01-01'), (2, '2020-04-15'), (3, '2020-07-01');
How many unique donors made donations in each quarter of 2020?
SELECT DATE_FORMAT(DonationDate, '%Y-%V') as 'Year-Quarter', COUNT(DISTINCT DonorID) as 'Unique Donors' FROM Donors WHERE YEAR(DonationDate) = 2020 GROUP BY 'Year-Quarter';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_health_centers (center_id INT, center_name VARCHAR(100), country VARCHAR(50), num_patients INT); INSERT INTO rural_health_centers (center_id, center_name, country, num_patients) VALUES (1, 'Center A', 'Brazil', 15000), (2, 'Center B', 'Brazil', 12000), (3, 'Center C', 'Argentina', 8000), (4, 'Center D', 'Argentina', 11000);
What is the total number of patients served by rural health centers in South America and how many of these centers serve more than 10000 patients?
SELECT COUNT(*) AS total_patients_served, COUNT(*) FILTER (WHERE num_patients > 10000) AS centers_with_more_than_10000_patients FROM rural_health_centers WHERE country IN (SELECT name FROM countries WHERE continent = 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE public.disaster_types (id SERIAL PRIMARY KEY, state VARCHAR(255), disaster_type VARCHAR(255), count INTEGER); INSERT INTO public.disaster_types (state, disaster_type, count) VALUES ('Florida', 'Hurricane', 2000), ('Florida', 'Tornado', 1500), ('Florida', 'Hurricane', 2500);
What is the most common type of disaster in the state of Florida?
SELECT disaster_type FROM public.disaster_types WHERE state = 'Florida' GROUP BY disaster_type ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE CitizenFeedback (Year INT, Service TEXT, Score INT); INSERT INTO CitizenFeedback (Year, Service, Score) VALUES (2021, 'Healthcare', 8), (2021, 'Healthcare', 9), (2021, 'Healthcare', 7), (2021, 'Healthcare', 8);
What was the average citizen feedback score for healthcare services in 2021?
SELECT AVG(Score) FROM CitizenFeedback WHERE Service = 'Healthcare' AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO Employees (id, name, department, salary) VALUES (1, 'John Doe', 'Finance', 50000.00); INSERT INTO Employees (id, name, department, salary) VALUES (2, 'Jane Smith', 'IT', 60000.00); INSERT INTO Employees (id, name, department, salary) VALUES (3, 'Alice Johnson', 'Finance', 55000.00);
What is the average salary of employees in the finance department?
SELECT AVG(salary) AS avg_salary FROM Employees WHERE department = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows_extended (id INT, title VARCHAR(255), genre VARCHAR(255), runtime INT); INSERT INTO tv_shows_extended (id, title, genre, runtime) VALUES (1, 'Show1', 'Action', 60), (2, 'Show2', 'Comedy', 30), (3, 'Show3', 'Drama', 45);
What is the average runtime for TV shows by genre?
SELECT genre, AVG(runtime) as avg_runtime FROM tv_shows_extended GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, first_name VARCHAR(50), last_name VARCHAR(50), city VARCHAR(50), state VARCHAR(2));
Update the record in the 'patients' table for a patient from Chicago, IL to show they now live in Atlanta, GA
UPDATE patients SET city = 'Atlanta', state = 'GA' WHERE patient_id = 5678 AND city = 'Chicago' AND state = 'IL';
gretelai_synthetic_text_to_sql
CREATE TABLE social_media_engagement (id INT PRIMARY KEY, platform VARCHAR(15), likes INT, shares INT, comments INT);
Delete the record for Twitter engagement metrics from the social_media_engagement table
DELETE FROM social_media_engagement WHERE platform = 'Twitter';
gretelai_synthetic_text_to_sql
CREATE TABLE health_facilities (facility_id INT, name VARCHAR(50), type VARCHAR(50), population INT, city VARCHAR(50), state VARCHAR(50));
What is the average population of 'clinics' in the 'health_facilities' table?
SELECT AVG(population) FROM health_facilities WHERE type = 'clinic';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(255), publication_date DATE, author_id INT);
Insert a new record with id 50, title "Machine Learning for Journalists", publication date 2022-10-01, and author id 10 into the "articles" table
INSERT INTO articles (article_id, title, publication_date, author_id) VALUES (50, 'Machine Learning for Journalists', '2022-10-01', 10);
gretelai_synthetic_text_to_sql
CREATE TABLE residential_users (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO residential_users (id, state, water_usage) VALUES (1, 'New Mexico', 7.5), (2, 'New Mexico', 9.6), (3, 'California', 12.2);
What is the minimum water usage by residential users in the state of New Mexico?
SELECT MIN(water_usage) FROM residential_users WHERE state = 'New Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE trends (id INT, trend_name VARCHAR(50), region VARCHAR(50), forecast VARCHAR(50), popularity INT);
Select all records from trends table where forecast='Winter' and trend_name like '%Jacket%'
SELECT * FROM trends WHERE forecast = 'Winter' AND trend_name LIKE '%Jacket%';
gretelai_synthetic_text_to_sql
CREATE SCHEMA gov_data;CREATE TABLE gov_data.citizen_complaints (city VARCHAR(20), service VARCHAR(20), complaint INT); INSERT INTO gov_data.citizen_complaints (city, service, complaint) VALUES ('Chicago', 'Public Transportation', 100), ('Chicago', 'Street Cleaning', 50), ('Chicago', 'Parks', 75);
Identify the number of citizen complaints received for each public service in the city of Chicago.
SELECT service, SUM(complaint) as total_complaints FROM gov_data.citizen_complaints WHERE city = 'Chicago' GROUP BY service;
gretelai_synthetic_text_to_sql
CREATE TABLE continent_visitors (id INT, continent VARCHAR(50), visit_month DATE, visitors INT); INSERT INTO continent_visitors (id, continent, visit_month, visitors) VALUES (1, 'Africa', '2022-01-01', 5000000); INSERT INTO continent_visitors (id, continent, visit_month, visitors) VALUES (2, 'Africa', '2022-02-01', 4500000);
Show the number of visitors per month for Africa.
SELECT visit_month, visitors, COUNT(visitors) OVER (PARTITION BY continent ORDER BY visit_month) as monthly_visitors FROM continent_visitors WHERE continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (id INT, contract_name VARCHAR(50), contract_value DECIMAL(10,2), contract_date DATE, contract_party VARCHAR(50)); INSERT INTO defense_contracts (id, contract_name, contract_value, contract_date, contract_party) VALUES (1, 'Contract A', 1000000, '2022-01-01', 'US Government'), (2, 'Contract B', 2000000, '2021-06-01', 'Foreign Government');
Calculate the total value of defense contracts with the US Government in the last quarter?
SELECT SUM(contract_value) FROM defense_contracts WHERE contract_party = 'US Government' AND contract_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE project (project_id INT, project_name TEXT, region TEXT); INSERT INTO project (project_id, project_name, region) VALUES (1, 'ProjectAA', 'Asia-Pacific'), (2, 'ProjectAB', 'Europe'), (3, 'ProjectAC', 'Asia-Pacific');
Which technology for social good projects were implemented in the Asia-Pacific region?
SELECT project_name FROM project WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_shipments AS SELECT order_id, 'USA' as country FROM orders WHERE shipping_address LIKE '123%' UNION ALL SELECT order_id, 'Canada' as country FROM orders WHERE shipping_address LIKE '456%' UNION ALL SELECT order_id, 'Mexico' as country FROM orders WHERE shipping_address LIKE '789%';
How many orders were shipped to each country in the 'warehouse_shipments' table, ordered by the most shipped orders?
SELECT country, COUNT(order_id) as orders_shipped FROM warehouse_shipments GROUP BY country ORDER BY orders_shipped DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_agents (id INT, name VARCHAR(50), position VARCHAR(50), agency VARCHAR(50), budget INT);
What are the names and positions of intelligence agents who work for the internal_intelligence agency and have a budget greater than 50000, listed in the intelligence_agents table?
SELECT name, position FROM intelligence_agents WHERE agency = 'internal_intelligence' AND budget > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (name VARCHAR(255), location VARCHAR(255), endangered_languages INTEGER); INSERT INTO programs (name, location, endangered_languages) VALUES ('Program A', 'Country A', 10); INSERT INTO programs (name, location, endangered_languages) VALUES ('Program B', 'Country B', 5);
Identify the community engagement programs in countries with the highest number of endangered languages.
SELECT programs.name, programs.location FROM programs JOIN (SELECT location, MAX(endangered_languages) AS max_endangered_languages FROM programs GROUP BY location) AS max_endangered_locations ON programs.location = max_endangered_locations.location AND programs.endangered_languages = max_endangered_locations.max_endangered_languages;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO funding_sources (id, name, type) VALUES (1, 'Government', 'government'), (2, 'Private', 'private'), (3, 'Corporate', 'corporate'); CREATE TABLE exhibitions (id INT, name VARCHAR(255), funding_source_id INT); INSERT INTO exhibitions (id, name, funding_source_id) VALUES (1, 'ExhibitionA', 1), (2, 'ExhibitionB', 2), (3, 'ExhibitionC', 3); CREATE TABLE performances (id INT, name VARCHAR(255), funding_source_id INT); INSERT INTO performances (id, name, funding_source_id) VALUES (1, 'PerformanceA', 1), (2, 'PerformanceB', 2), (3, 'PerformanceC', 3);
What is the percentage of funding for exhibitions and performances from government sources?
SELECT (COUNT(CASE WHEN f.name = 'Government' AND t.type IN ('exhibitions', 'performances') THEN 1 END) * 100.0 / COUNT(*)) AS government_funding_percentage FROM funding_sources f JOIN exhibitions e ON f.id = e.funding_source_id JOIN performances p ON f.id = p.funding_source_id JOIN (VALUES ('exhibitions'), ('performances')) AS t(type) ON TRUE
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, store_id INT, sale_date DATE, revenue DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, store_id, sale_date, revenue) VALUES (1, 1, 1, '2022-01-01', 200.00), (2, 2, 1, '2022-01-02', 50.00), (3, 1, 2, '2022-01-03', 300.00); CREATE TABLE stores (store_id INT, store_name VARCHAR(255)); INSERT INTO stores (store_id, store_name) VALUES (1, 'Store A'), (2, 'Store B');
What is the total revenue for each store?
SELECT s.store_name, SUM(sales.revenue) as total_revenue FROM sales JOIN stores s ON sales.store_id = s.store_id GROUP BY s.store_id;
gretelai_synthetic_text_to_sql
CREATE TABLE areas (name text, type text, community text); INSERT INTO areas VALUES ('Urban', 'CityA', ''), ('Suburban', 'CityB', ''), ('Rural', 'CityC', 'Indigenous'), ('Rural', 'CityD', 'Indigenous'); CREATE TABLE hospitals (name text, area_type text); INSERT INTO hospitals VALUES ('Hospital1', 'Urban'), ('Hospital2', 'Rural'), ('Hospital3', 'Suburban'); CREATE TABLE clinics (name text, area_type text); INSERT INTO clinics VALUES ('Clinic1', 'Urban'), ('Clinic2', 'Rural'), ('Clinic3', 'Suburban');
Identify the number of hospitals and clinics in indigenous communities, and calculate the ratio.
SELECT (SELECT COUNT(*) FROM hospitals WHERE area_type = 'Rural' AND communities = 'Indigenous') / COUNT(DISTINCT areas.type) AS indigenous_hospital_ratio, (SELECT COUNT(*) FROM clinics WHERE area_type = 'Rural' AND communities = 'Indigenous') / COUNT(DISTINCT areas.type) AS indigenous_clinic_ratio
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, habitat TEXT); INSERT INTO marine_species (name, habitat) VALUES ('Coral', 'Coral Reef'), ('Clownfish', 'Coral Reef'), ('Sea Star', 'Coral Reef'), ('Tuna', 'Open Ocean'), ('Blue Whale', 'Open Ocean'), ('Dolphin', 'Open Ocean'), ('Sea Turtle', 'Beaches'), ('Swordfish', 'Open Ocean');
How many marine species are there in each habitat?
SELECT habitat, COUNT(*) FROM marine_species GROUP BY habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE avg_transaction_value (industry_sector VARCHAR(10), asset_name VARCHAR(10), quarter INT, avg_transaction_value INT); INSERT INTO avg_transaction_value (industry_sector, asset_name, quarter, avg_transaction_value) VALUES ('Currency Exchange', 'BTC', 1, 1000), ('Currency Exchange', 'BTC', 2, 1500), ('Currency Exchange', 'BTC', 3, 2000), ('Currency Exchange', 'ETH', 1, 2500), ('Currency Exchange', 'ETH', 2, 3000), ('Currency Exchange', 'ETH', 3, 3500), ('Currency Exchange', 'XRP', 1, 4000), ('Currency Exchange', 'XRP', 2, 4500), ('Currency Exchange', 'XRP', 3, 5000);
What is the average transaction value for the 'Currency Exchange' industry sector in the 'XRP' digital asset in Q3 2021?
SELECT avg_transaction_value FROM avg_transaction_value WHERE industry_sector = 'Currency Exchange' AND asset_name = 'XRP' AND quarter = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS region (id INT PRIMARY KEY, name VARCHAR(50));CREATE TABLE IF NOT EXISTS animal (id INT PRIMARY KEY, name VARCHAR(50));CREATE TABLE IF NOT EXISTS animal_population (id INT PRIMARY KEY, animal_id INT, region_id INT, population INT);
Create a new table named 'animal_population'
CREATE TABLE IF NOT EXISTS animal_population (id INT PRIMARY KEY, animal_id INT, region_id INT, population INT);
gretelai_synthetic_text_to_sql
CREATE TABLE hiring (id INT, employee_id INT, hire_date DATE, department VARCHAR(255)); INSERT INTO hiring (id, employee_id, hire_date, department) VALUES (1, 101, '2020-01-02', 'HR'); INSERT INTO hiring (id, employee_id, hire_date, department) VALUES (2, 102, '2019-12-20', 'IT');
Find the number of unique departments that have employees hired in 2021
SELECT COUNT(DISTINCT department) FROM hiring WHERE YEAR(hire_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID INT, Name VARCHAR(50)); CREATE TABLE Menu (MenuID INT, RestaurantID INT, Item VARCHAR(50), Price DECIMAL(10,2));
Update the prices of specific menu items for a given restaurant.
UPDATE Menu SET Price = 11.99 WHERE Item = 'Vegan Burger' AND RestaurantID = 1; UPDATE Menu SET Price = 8.99 WHERE Item = 'Impossible Taco' AND RestaurantID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation_person (city VARCHAR(20), year INT, person INT, quantity INT); INSERT INTO waste_generation_person (city, year, person, quantity) VALUES ('Boston', 2017, 1, 100), ('Boston', 2017, 2, 200), ('Boston', 2017, 3, 300);
What was the average waste generation per person in the city of Boston in 2017?
SELECT AVG(quantity) AS avg_waste_generation FROM waste_generation_person WHERE city = 'Boston' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Department (DeptID INT, DeptName VARCHAR(50), City VARCHAR(50)); INSERT INTO Department (DeptID, DeptName, City) VALUES (1, 'Disability Services', 'New York'); INSERT INTO Department (DeptID, DeptName, City) VALUES (2, 'Student Support', 'Los Angeles'); CREATE TABLE Accommodation (AccID INT, AccName VARCHAR(50), StudentID INT, DeptID INT); INSERT INTO Accommodation (AccID, AccName, StudentID, DeptID) VALUES (1, 'Sign Language Interpreter', 1, 1); INSERT INTO Accommodation (AccID, AccName, StudentID, DeptID) VALUES (2, 'Note Taker', 2, 1); INSERT INTO Accommodation (AccID, AccName, StudentID, DeptID) VALUES (3, 'Adaptive Equipment', 3, 2); CREATE TABLE Student (StudentID INT, StudentName VARCHAR(50)); INSERT INTO Student (StudentID, StudentName) VALUES (1, 'John Doe'); INSERT INTO Student (StudentID, StudentName) VALUES (2, 'Jane Smith'); INSERT INTO Student (StudentID, StudentName) VALUES (3, 'Michael Lee');
What is the percentage of students who received accommodations out of the total number of students, for each department?
SELECT DeptName, (COUNT(DISTINCT A.StudentID) * 100.0 / COUNT(DISTINCT S.StudentID)) AS Percentage FROM Accommodation A JOIN Department D ON A.DeptID = D.DeptID JOIN Student S ON A.StudentID = S.StudentID GROUP BY DeptName;
gretelai_synthetic_text_to_sql
CREATE TABLE community_centers (name TEXT, city TEXT, budget_allocation INT); INSERT INTO community_centers (name, city, budget_allocation) VALUES ('Community Center A', 'Houston', 400000), ('Community Center B', 'Houston', 300000);
Which community centers in the city of Houston have a budget allocation over $350,000?
SELECT name, budget_allocation FROM community_centers WHERE city = 'Houston' AND budget_allocation > 350000;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT, Neodymium_production FLOAT); INSERT INTO mine (id, name, location, Neodymium_production) VALUES (1, 'German Mine', 'Germany', 1100.0), (2, 'Finnish Mine', 'Finland', 900.0);
Delete the entry for the German mine in the 'mine' table.
DELETE FROM mine WHERE name = 'German Mine';
gretelai_synthetic_text_to_sql
CREATE TABLE fisheries (fishery_name VARCHAR(50), fish_species VARCHAR(50), population INT); INSERT INTO fisheries (fishery_name, fish_species, population) VALUES ('South China Sea Sustainable 1', 'Pomfret', 120000), ('South China Sea Sustainable 1', 'Grouper', 180000), ('South China Sea Sustainable 2', 'Squid', 60000), ('South China Sea Sustainable 2', 'Shrimp', 70000);
List all fish species and their populations in sustainable fisheries in the South China Sea.
SELECT fish_species, population FROM fisheries WHERE fishery_name LIKE 'South China Sea Sustainable%';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_workforce (id INT, state VARCHAR(50), years_of_experience INT, position VARCHAR(50)); INSERT INTO mining_workforce (id, state, years_of_experience, position) VALUES (4, 'New York', 1, 'Miner'); INSERT INTO mining_workforce (id, state, years_of_experience, position) VALUES (5, 'New York', 3, 'Miner'); INSERT INTO mining_workforce (id, state, years_of_experience, position) VALUES (6, 'New York', 0, 'Miner'); INSERT INTO mining_workforce (id, state, years_of_experience, position) VALUES (7, 'New York', 2, 'Miner');
What is the total number of workers in mining operations in the state of New York that have less than 2 years of experience?
SELECT COUNT(*) FROM mining_workforce WHERE state = 'New York' AND years_of_experience < 2;
gretelai_synthetic_text_to_sql
CREATE SCHEMA fitness; CREATE TABLE users (id INT, user_name VARCHAR(255), state VARCHAR(255)); CREATE TABLE workouts (id INT, user_id INT, workout_date DATE, avg_heart_rate INT);
How many users in each state have a heart rate above 120 bpm on average during their workouts?
SELECT state, AVG(avg_heart_rate) FROM fitness.workouts INNER JOIN fitness.users ON workouts.user_id = users.id GROUP BY state HAVING AVG(avg_heart_rate) > 120;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, region TEXT); INSERT INTO marine_species (name, region) VALUES ('Species1', 'Arctic'); INSERT INTO marine_species (name, region) VALUES ('Species2', 'Atlantic');
Find all marine species that have been observed in the Arctic region but not in the Atlantic region
SELECT m1.name FROM marine_species m1 LEFT JOIN marine_species m2 ON m1.name = m2.name WHERE m1.region = 'Arctic' AND m2.region IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE news_categories (id INT, category VARCHAR(255), popularity INT); INSERT INTO news_categories (id, category, popularity) VALUES
What are the top 5 most popular news categories among users aged 25-34?
SELECT category, SUM(popularity) as total_popularity FROM news_categories JOIN user_demographics ON news_categories.id = user_demographics.news_id
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureResilience (State TEXT, Year INTEGER, ProjectType TEXT, ResilienceRating INTEGER); INSERT INTO InfrastructureResilience (State, Year, ProjectType, ResilienceRating) VALUES ('Texas', 2017, 'Bridge', 80), ('Texas', 2017, 'Highway', 75), ('Texas', 2017, 'Tunnel', 85), ('Texas', 2018, 'Bridge', 82), ('Texas', 2018, 'Highway', 78), ('Texas', 2018, 'Tunnel', 87), ('Texas', 2019, 'Bridge', 84), ('Texas', 2019, 'Highway', 79), ('Texas', 2019, 'Tunnel', 88), ('Texas', 2020, 'Bridge', 86), ('Texas', 2020, 'Highway', 77), ('Texas', 2020, 'Tunnel', 89), ('Texas', 2021, 'Bridge', 88), ('Texas', 2021, 'Highway', 80), ('Texas', 2021, 'Tunnel', 90);
What was the average resilience rating for infrastructure projects in Texas over the past 5 years?
SELECT ProjectType, AVG(ResilienceRating) as AvgResilience FROM InfrastructureResilience WHERE State = 'Texas' GROUP BY ProjectType;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_info (restaurant_id INT, location VARCHAR(50)); INSERT INTO restaurant_info (restaurant_id, location) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'New York'); CREATE TABLE restaurant_revenue (restaurant_id INT, revenue INT); INSERT INTO restaurant_revenue (restaurant_id, revenue) VALUES (1, 5000), (2, 6000), (3, 7000), (4, 8000);
What is the total revenue for the restaurants located in 'New York'?
SELECT SUM(revenue) FROM restaurant_revenue INNER JOIN restaurant_info ON restaurant_revenue.restaurant_id = restaurant_info.restaurant_id WHERE location = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE mine_env (id INT, name VARCHAR(50), location VARCHAR(50), environmental_score FLOAT); INSERT INTO mine_env VALUES (1, 'Mine K', 'California', 35), (2, 'Mine L', 'California', 65), (3, 'Mine M', 'California', 25);
Find mines in California with low environmental impact scores.
SELECT name, environmental_score FROM mine_env WHERE location = 'California' AND environmental_score < 40;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, region TEXT, budget FLOAT, focus TEXT, start_date DATE); INSERT INTO projects (id, name, region, budget, focus, start_date) VALUES (1, 'Project 1', 'South America', 500000, 'youth-focused economic diversification', '2016-01-01'), (2, 'Project 2', 'North America', 750000, 'infrastructure development', '2017-01-01'), (3, 'Project 3', 'South America', 1000000, 'rural development', '2015-01-01');
What is the total budget for 'youth-focused economic diversification projects' in 'South America' since 2016?
SELECT SUM(projects.budget) FROM projects WHERE projects.region = 'South America' AND projects.focus = 'youth-focused economic diversification' AND projects.start_date >= '2016-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (name TEXT, id INTEGER); INSERT INTO factories (name, id) VALUES ('Factory A', 1), ('Factory B', 2), ('Factory C', 3); CREATE TABLE recycling_rates (factory_id INTEGER, rate FLOAT); INSERT INTO recycling_rates (factory_id, rate) VALUES (1, 0.3), (2, 0.5), (3, 0.7);
What are the names of the factories that have never reported recycling rates?
SELECT f.name FROM factories f LEFT JOIN recycling_rates r ON f.id = r.factory_id WHERE r.rate IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(255), manufacturer VARCHAR(255), approval_status VARCHAR(255), market_availability VARCHAR(255)); INSERT INTO drugs (drug_id, drug_name, manufacturer, approval_status, market_availability) VALUES (1, 'DrugI', 'ManufacturerG', 'Approved', 'Available in UK'), (2, 'DrugJ', 'ManufacturerH', 'Not Approved', 'Not available in US'); CREATE TABLE sales (sale_id INT, drug_id INT, sale_amount DECIMAL(10,2), sale_tax DECIMAL(10,2), country VARCHAR(255)); INSERT INTO sales (sale_id, drug_id, sale_amount, sale_tax, country) VALUES (1, 1, 0.00, 0.00, 'US');
Identify drugs approved in the UK, but not yet approved in the US market.
SELECT d.drug_name FROM drugs d LEFT JOIN sales s ON d.drug_id = s.drug_id WHERE d.approval_status = 'Approved' AND d.market_availability = 'Available in UK' AND s.country = 'US' GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_devices (device_id INT, device_name VARCHAR(50), mobile_services INT, state VARCHAR(20)); CREATE TABLE mobile_customers (customer_id INT, device_id INT, plan_type VARCHAR(10));
What are the top 5 most used mobile devices among prepaid customers in the state of California, and how many subscribers use each device?
SELECT device_name, COUNT(*) as num_subscribers FROM mobile_devices JOIN mobile_customers ON mobile_devices.device_id = mobile_customers.device_id WHERE plan_type = 'prepaid' AND state = 'California' GROUP BY device_name ORDER BY num_subscribers DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_sales (customer_id INT, sales_revenue FLOAT, country VARCHAR(50)); INSERT INTO customer_sales (customer_id, sales_revenue, country) VALUES (1, 5000, 'CA'), (2, 7000, 'US'), (3, 3000, 'FR'), (4, 8000, 'CA'), (5, 4000, 'FR'), (6, 6000, 'US'), (7, 9000, 'FR');
Show the total revenue for the top 3 customers in France, in descending order.
SELECT customer_id, SUM(sales_revenue) as total_revenue FROM customer_sales WHERE country = 'FR' GROUP BY customer_id ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INTEGER, name TEXT, size INTEGER, price FLOAT); INSERT INTO products (product_id, name, size, price) VALUES (1001, 'Organic Cotton Dress', 12, 80.0), (1002, 'Silk Blouse', 8, 60.0), (1003, 'Recycled Polyester Jacket', 14, 120.0), (1004, 'Bamboo T-Shirt', 6, 30.0);
What is the maximum price of a size 12 dress?
SELECT MAX(price) FROM products WHERE size = 12;
gretelai_synthetic_text_to_sql
CREATE TABLE company_location (id INT, company_name VARCHAR(50), city VARCHAR(50), funding_amount DECIMAL(10, 2));
List the top 10 cities with the most funding, based on the total funding received by companies located in those cities
SELECT city, SUM(funding_amount) AS total_funding FROM company_location GROUP BY city ORDER BY total_funding DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionVolume (id INT, chemical VARCHAR(255), volume INT, date DATE); INSERT INTO ProductionVolume (id, chemical, volume, date) VALUES (1, 'chemical Z', 500, '2022-01-01'), (2, 'chemical X', 600, '2022-02-15');
What was the total production volume of chemical Z in the first half of 2022?
SELECT SUM(volume) FROM ProductionVolume WHERE chemical = 'chemical Z' AND date >= '2022-01-01' AND date <= '2022-06-30';
gretelai_synthetic_text_to_sql