context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Dishes (DishID INT, Name VARCHAR(50), Category VARCHAR(50), WastePercentage DECIMAL(3,2)); INSERT INTO Dishes (DishID, Name, Category, WastePercentage) VALUES (1, 'Lamb Chops', 'Meat', 0.35), (2, 'Eggplant Parmesan', 'Vegetarian', 0.20), (3, 'Beef Stew', 'Meat', 0.40);
Identify dishes with a waste percentage above 30% and their respective categories.
SELECT d.Name, d.Category FROM Dishes d WHERE d.WastePercentage > 0.3;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ratings (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); INSERT INTO hotel_ratings (hotel_id, hotel_name, country, rating) VALUES (1, 'Eco-Friendly Hotel 1', 'France', 4.2), (2, 'Eco-Friendly Hotel 2', 'France', 4.5), (3, 'Eco-Friendly Hotel 3', 'Italy', 3.8), (4, 'Eco-Friendly Hotel 4', 'Italy', 4.1);
Find the difference in ratings between the first and last eco-friendly hotels in each country?
SELECT country, (MAX(rating) OVER (PARTITION BY country) - MIN(rating) OVER (PARTITION BY country)) AS rating_difference FROM hotel_ratings;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteer_Hours (volunteer_id INT, hours FLOAT, volunteer_date DATE, cause VARCHAR(255)); INSERT INTO Volunteer_Hours (volunteer_id, hours, volunteer_date, cause) VALUES (1, 5.00, '2021-01-01', 'Environment'), (2, 3.00, '2021-02-03', 'Health'), (3, 8.00, '2021-05-05', 'Environment');
How many volunteer hours were recorded for 'Environment' cause in '2021'?
SELECT SUM(hours) FROM Volunteer_Hours WHERE volunteer_date >= '2021-01-01' AND volunteer_date < '2022-01-01' AND cause = 'Environment';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name TEXT, region TEXT); INSERT INTO Warehouse (id, name, region) VALUES (1, 'London Warehouse', 'Europe'), (2, 'Berlin Warehouse', 'Europe'), (3, 'Madrid Warehouse', 'Europe'); CREATE TABLE Shipment (id INT, warehouse_id INT, delivery_fee DECIMAL); INSERT INTO Shipment (id, warehouse_id, delivery_fee) VALUES (1, 1, 50.5), (2, 1, 45.3), (3, 2, 60.2), (4, 3, 40.1);
What is the total revenue generated from deliveries in the 'Europe' region?
SELECT Warehouse.region, SUM(Shipment.delivery_fee) as total_revenue FROM Warehouse INNER JOIN Shipment ON Warehouse.id = Shipment.warehouse_id WHERE Warehouse.region = 'Europe' GROUP BY Warehouse.region;
gretelai_synthetic_text_to_sql
CREATE TABLE student_lifelong_learning (student_id INT, city VARCHAR(20), learning_score INT); INSERT INTO student_lifelong_learning (student_id, city, learning_score) VALUES (1, 'Toronto', 85), (2, 'Vancouver', 90), (3, 'New York', 80), (4, 'Montreal', 95), (5, 'Los Angeles', 75);
What is the average lifelong learning score for students in each city?
SELECT city, AVG(learning_score) as avg_score FROM student_lifelong_learning GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_projects (project VARCHAR(50), investment FLOAT); INSERT INTO rural_projects (project, investment) VALUES ('Irrigation System', 500000.00), ('Rural Roads', 700000.00), ('Electricity', 600000.00);
What is the total investment (in USD) for each rural infrastructure project?
SELECT project, investment FROM rural_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE, Orbit VARCHAR(50), Status VARCHAR(50)); INSERT INTO Satellites (SatelliteID, Name, Manufacturer, LaunchDate, Orbit, Status) VALUES (1, 'GPS I', 'Lockheed Martin', '2010-01-14', 'GEO', 'Active'), (2, 'GPS II', 'Raytheon', '2015-06-15', 'GEO', 'Active'), (5, 'GPS III', 'Lockheed Martin', '2008-09-28', 'GEO', 'Active'), (6, 'GPS IV', 'Raytheon', '2016-11-27', 'GEO', 'Inactive');
What is the average lifespan of satellites in GEO orbit?
SELECT AVG(DATEDIFF(day, LaunchDate, GETDATE())) AS AvgLifespan FROM Satellites WHERE Orbit = 'GEO' AND Status = 'Inactive';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (building_id INT, name VARCHAR(50), building_type VARCHAR(50));CREATE TABLE Units (unit_id INT, building_id INT, square_footage INT);
What is the total number of units and the average square footage of units in each building, partitioned by building type?
SELECT b.building_type, b.name, COUNT(u.unit_id) as num_units, AVG(u.square_footage) as avg_square_footage FROM Units u JOIN Buildings b ON u.building_id = b.building_id GROUP BY b.building_type, b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ABC_block (block_hash VARCHAR(255), block_number INT, timestamp TIMESTAMP, miner VARCHAR(255), transactions INT, transaction_value DECIMAL(18,2));
What was the average transaction value for each block in the ABC blockchain that contained more than 10 transactions?
SELECT block_number, AVG(transaction_value) AS avg_transaction_value FROM ABC_block WHERE transactions > 10 GROUP BY block_number;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtDonations (artist_name VARCHAR(50), piece_count INT, donation_date DATE); INSERT INTO ArtDonations (artist_name, piece_count, donation_date) VALUES ('Monet', 3, '2017-03-12'), ('Renoir', 2, '2019-05-28'), ('Cezanne', 1, '2020-11-05');
How many art pieces were donated by each artist in the last 5 years?
SELECT artist_name, SUM(piece_count) FROM ArtDonations WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY artist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT);CREATE TABLE shipments (shipment_id INT, shipment_weight INT, ship_date DATE, port_id INT); INSERT INTO ports VALUES (1, 'Port of Kolkata', 'India'), (2, 'Port of Chennai', 'India'); INSERT INTO shipments VALUES (1, 2000, '2019-01-01', 1), (2, 1500, '2019-02-15', 2);
What is the average weight of containers shipped from the Port of Kolkata to India in 2019?
SELECT AVG(shipment_weight) FROM shipments JOIN ports ON shipments.port_id = ports.port_id WHERE ports.country = 'India' AND ports.port_name IN ('Port of Kolkata', 'Port of Chennai') AND ship_date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR, budget DECIMAL); CREATE TABLE volunteers (id INT, name VARCHAR, email VARCHAR, phone VARCHAR); CREATE TABLE volunteer_assignments (id INT, volunteer_id INT, program_id INT);
List the programs with the highest and lowest number of volunteers
SELECT programs.name, COUNT(DISTINCT volunteer_assignments.volunteer_id) as num_volunteers FROM programs JOIN volunteer_assignments ON programs.id = volunteer_assignments.program_id GROUP BY programs.id ORDER BY num_volunteers DESC, programs.name LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE sea_surface_temperature_2 (region TEXT, temperature NUMERIC); INSERT INTO sea_surface_temperature_2 (region, temperature) VALUES ('Arctic', '-1.8'); INSERT INTO sea_surface_temperature_2 (region, temperature) VALUES ('Antarctic', '-1.9');
What is the average sea surface temperature for the Arctic and Antarctic Oceans?
SELECT AVG(temperature) FROM sea_surface_temperature_2 WHERE region IN ('Arctic', 'Antarctic');
gretelai_synthetic_text_to_sql
CREATE TABLE BrandUpdates (BrandID INT, UpdateDate DATE);
Which fashion brands have not updated their sustainable fabric usage data in the last 6 months?
SELECT FB.BrandName FROM FashionBrands FB LEFT JOIN BrandUpdates BU ON FB.BrandID = BU.BrandID WHERE BU.UpdateDate IS NULL OR BU.UpdateDate < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerProgress (PlayerID INT, GameName VARCHAR(20), Level INT, Completion BOOLEAN, PlayerContinent VARCHAR(30)); INSERT INTO PlayerProgress (PlayerID, GameName, Level, Completion, PlayerContinent) VALUES (1, 'Galactic Conquest', 1, true, 'North America'), (2, 'Galactic Conquest', 1, true, 'Europe'), (3, 'Galactic Conquest', 1, false, 'North America'), (4, 'Galactic Conquest', 1, true, 'South America'), (5, 'Galactic Conquest', 1, false, 'Europe'), (6, 'Galactic Conquest', 1, true, 'Asia'), (7, 'Galactic Conquest', 1, false, 'Asia'), (8, 'Galactic Conquest', 1, true, 'Africa');
What is the percentage of users who have completed the first level in "Galactic Conquest" for each continent?
SELECT PlayerContinent, COUNT(*) FILTER (WHERE Completion) * 100.0 / COUNT(*) AS pct_completion FROM PlayerProgress WHERE GameName = 'Galactic Conquest' GROUP BY PlayerContinent;
gretelai_synthetic_text_to_sql
CREATE TABLE Art_Exhibitions (id INT, country VARCHAR(255), year INT, number_of_pieces INT);
What is the average number of art pieces per exhibition in France in 2019?
SELECT AVG(number_of_pieces) FROM Art_Exhibitions WHERE country = 'France' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), Gender varchar(10)); INSERT INTO Donors (DonorID, DonorName, Country, Gender) VALUES (1, 'John Smith', 'USA', 'Male'); INSERT INTO Donors (DonorID, DonorName, Country, Gender) VALUES (2, 'Sara Ahmed', 'Canada', 'Female');
What is the percentage of donations from male and female donors in the United Kingdom?
SELECT Gender, ROUND(100 * SUM(DonationAmount) / (SELECT SUM(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Country = 'United Kingdom') , 2) AS Percentage FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Country = 'United Kingdom' GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_sales (id INT, equipment_name VARCHAR(255), sale_date DATE, revenue INT); INSERT INTO equipment_sales (id, equipment_name, sale_date, revenue) VALUES (1, 'Tank A', '2022-01-05', 500000), (2, 'Helicopter B', '2022-02-10', 600000), (3, 'Drone C', '2022-03-20', 400000), (4, 'Jeep D', '2022-04-01', 700000), (5, 'Ship E', '2022-05-15', 800000), (6, 'Tank A', '2022-06-30', 600000);
Which military equipment has the highest sales revenue in the first half of 2022?
SELECT equipment_name, SUM(revenue) AS total_revenue FROM equipment_sales WHERE QUARTER(sale_date) = 1 AND YEAR(sale_date) = 2022 GROUP BY equipment_name ORDER BY total_revenue DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy.wind_power (country VARCHAR(20), capacity INT);
What is the maximum renewable energy capacity (in MW) for wind power projects in the 'renewable_energy' schema, for each country?
SELECT country, MAX(capacity) FROM renewable_energy.wind_power GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturing_Parts (id INT PRIMARY KEY, part_name VARCHAR(100), quantity INT, manufacturer VARCHAR(100)); INSERT INTO Manufacturing_Parts (id, part_name, quantity, manufacturer) VALUES (1, 'Wing', 3, 'Boeing'); INSERT INTO Manufacturing_Parts (id, part_name, quantity, manufacturer) VALUES (2, 'Engine', 2, 'GE'); INSERT INTO Manufacturing_Parts (id, part_name, quantity, manufacturer) VALUES (3, 'Ailerons', 1, 'Airbus'); INSERT INTO Manufacturing_Parts (id, part_name, quantity, manufacturer) VALUES (4, 'Engine', 4, 'Pratt & Whitney');
What is the total quantity of engines manufactured by GE and Pratt & Whitney?
SELECT SUM(quantity) FROM Manufacturing_Parts WHERE manufacturer IN ('GE', 'Pratt & Whitney') AND part_name = 'Engine';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), risk_level VARCHAR(50), impact_score INT);
What is the average impact score of projects in South Asia that have a risk level of 'Medium'?
SELECT AVG(impact_score) FROM projects WHERE location = 'South Asia' AND risk_level = 'Medium';
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Rights (region VARCHAR(20), violation_reported BOOLEAN); INSERT INTO Labor_Rights (region, violation_reported) VALUES ('Northeast', true), ('Northeast', false), ('Midwest', true);
What is the total number of labor rights violations by region?
SELECT region, SUM(violation_reported) as total_violations FROM Labor_Rights GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (landfill VARCHAR(50), year INT, capacity INT); INSERT INTO landfill_capacity (landfill, year, capacity) VALUES ('Central', 2018, 5000000), ('Central', 2019, 5500000), ('Northern', 2018, 6000000), ('Northern', 2019, 6500000);
Landfill capacity of the 'Central' landfill in 2018 and 2019.
SELECT landfill, (SUM(capacity) FILTER (WHERE year = 2018)) AS capacity_2018, (SUM(capacity) FILTER (WHERE year = 2019)) AS capacity_2019 FROM landfill_capacity WHERE landfill = 'Central' GROUP BY landfill;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (id INT, name VARCHAR(50), genre VARCHAR(50), revenue INT); INSERT INTO Games (id, name, genre, revenue) VALUES (1, 'GameA', 'Racing', 500000), (2, 'GameB', 'RPG', 700000), (3, 'GameC', 'Racing', 800000);
What is the total revenue generated by each game genre, and what is the maximum revenue generated by a single game?
SELECT genre, SUM(revenue) AS total_revenue, MAX(revenue) AS max_revenue FROM Games GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(20), year INT, recycling_rate FLOAT);INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('San Francisco', 2019, 0.65), ('San Francisco', 2020, 0.7), ('San Francisco', 2021, 0.75), ('New York', 2019, 0.45), ('New York', 2020, 0.5), ('New York', 2021, 0.55);
Find the recycling rate for the city of New York in 2019
SELECT recycling_rate FROM recycling_rates WHERE city = 'New York' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name TEXT, nationality TEXT, points INT); INSERT INTO players (player_id, name, nationality, points) VALUES (1, 'John Doe', 'USA', 500), (2, 'Jane Smith', 'USA', 600);
What are the total points scored by players from the United States in the 2020 season?
SELECT SUM(points) FROM players WHERE nationality = 'USA' AND season = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artist_name VARCHAR(100), period VARCHAR(50), artwork_name VARCHAR(100), price FLOAT); INSERT INTO Artworks (id, artist_name, period, artwork_name, price) VALUES (1, 'Francis Bacon', 'Abstract Expressionism', 'Three Studies of Lucian Freud', 140000000.0); INSERT INTO Artworks (id, artist_name, period, artwork_name, price) VALUES (2, 'Francis Bacon', 'Abstract Expressionism', 'Figure with Meat', 20000000.0);
Find the total price of artworks by 'Francis Bacon' in the 'Abstract Expressionism' period.
SELECT SUM(price) as total_price FROM Artworks WHERE artist_name = 'Francis Bacon' AND period = 'Abstract Expressionism';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_innovation (id INT, name VARCHAR(50)); CREATE TABLE budget (innovation_id INT, rural_innovation_id INT, amount FLOAT);
What are the names of all agricultural innovation projects in the 'rural_innovation' table, along with their respective budgets from the 'budget' table? (Assuming 'rural_innovation.id' and 'budget.innovation_id' are related by foreign key)
SELECT r.name, b.amount FROM rural_innovation r JOIN budget b ON r.id = b.rural_innovation_id;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, industry TEXT, funding_source TEXT, funding_amount INT); INSERT INTO startups (id, name, industry, funding_source, funding_amount) VALUES (1, 'BioLabs', 'Biotech', 'VC', 12000000);
What is the maximum funding received by biotech startups in the UK?
SELECT MAX(funding_amount) FROM startups WHERE industry = 'Biotech' AND country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO organizations (id, name, category) VALUES (1, 'Freedom Alliance', 'human rights'), (2, 'Equal Rights Foundation', 'human rights'), (3, 'Shine Education', 'education'); CREATE TABLE donations (id INT, organization_id INT, amount DECIMAL(10, 2)); INSERT INTO donations (id, organization_id, amount) VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 500), (4, 2, 1500), (5, 3, 3000);
List all organizations in the 'human rights' category along with the number of donations they received.
SELECT organizations.name, COUNT(donations.id) AS num_donations FROM organizations INNER JOIN donations ON organizations.id = donations.organization_id WHERE organizations.category = 'human rights' GROUP BY organizations.id;
gretelai_synthetic_text_to_sql
CREATE TABLE district (name VARCHAR(20), income FLOAT); INSERT INTO district (name, income) VALUES ('North', 45000.0), ('East', 50000.0), ('West', 40000.0), ('South', 55000.0), ('South', 52000.0);
What is the minimum income in the "South" district?
SELECT MIN(income) FROM district WHERE name = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, last_reviewed DATE); INSERT INTO policies (policy_id, last_reviewed) VALUES (1, '2021-01-01'), (2, '2021-02-15'), (3, '2021-03-05');
Which policies have been reviewed in the last 30 days?
SELECT policy_id FROM policies WHERE last_reviewed >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_hydrothermal_vents (id INT, location TEXT, temperature FLOAT, region TEXT);
What is the maximum temperature recorded at deep-sea hydrothermal vents in the Indian Ocean?
SELECT MAX(temperature) FROM deep_sea_hydrothermal_vents WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50), production_rate FLOAT); INSERT INTO wells (well_id, well_name, region, production_rate) VALUES (7, 'Well G', 'Caribbean Sea', 3000), (8, 'Well H', 'Caribbean Sea', 7000);
List the names of all wells in the 'Caribbean Sea' and their production rates, sorted by production rate in descending order.
SELECT well_name, production_rate FROM wells WHERE region = 'Caribbean Sea' ORDER BY production_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE HumanResources (EmployeeID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Position VARCHAR(20), Gender VARCHAR(10));
Find the number of female faculty members in the HumanResources table.
SELECT COUNT(*) FROM HumanResources WHERE Position LIKE '%faculty%' AND Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel_middle_east (country VARCHAR(255), num_personnel INT); INSERT INTO military_personnel_middle_east (country, num_personnel) VALUES ('Israel', 170000), ('Saudi Arabia', 225000), ('Iran', 525000);
What is the average number of military personnel in the Middle East?
SELECT AVG(num_personnel) FROM military_personnel_middle_east;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers_tx (customer_id INT, data_usage FLOAT, state VARCHAR(50)); INSERT INTO mobile_customers_tx (customer_id, data_usage, state) VALUES (1, 5.5, 'TX'), (2, 4.2, 'NJ'), (3, 6.1, 'TX'), (4, 3.8, 'TX'), (5, 7.2, 'TX');
Which mobile customers in Texas have a data usage greater than 5 GB?
SELECT customer_id FROM mobile_customers_tx WHERE data_usage > 5 AND state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Category TEXT, Budget DECIMAL(10,2), StartYear INT); INSERT INTO Programs (ProgramID, Category, Budget, StartYear) VALUES (1, 'Environment', 15000.00, 2019), (2, 'Education', 12000.00, 2018);
What was the total budget spent on programs in the Environment category in 2019?
SELECT SUM(Budget) as 'Total Budget Spent' FROM Programs WHERE Category = 'Environment' AND StartYear = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2), is_organic BOOLEAN); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers', 12.99, false); INSERT INTO menus VALUES (2, 'Veggie Burger', 'Entrees', 10.99, false); INSERT INTO menus VALUES (3, 'Organic Salad', 'Entrees', 14.99, true); CREATE TABLE sales (sale_id INT, menu_id INT, quantity INT, region VARCHAR(255));
What is the average price of organic menu items in the European Union?
SELECT AVG(price) FROM menus WHERE is_organic = true AND region = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE organization_donations (donation_id INT, donation_amount FLOAT, donation_date DATE, organization VARCHAR(50)); INSERT INTO organization_donations (donation_id, donation_amount, donation_date, organization) VALUES (1, 500, '2021-10-01', 'Africa'), (2, 600, '2021-11-01', 'Africa');
What is the total donation amount in 'organization_donations' table for 'Africa' in Q4 2021?
SELECT SUM(donation_amount) FROM organization_donations WHERE EXTRACT(QUARTER FROM donation_date) = 4 AND organization = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), ProgramID int); CREATE TABLE Programs (ProgramID int, ProgramName varchar(50)); INSERT INTO Volunteers (VolunteerID, Name, ProgramID) VALUES (1, 'Alice', 1); INSERT INTO Volunteers (VolunteerID, Name, ProgramID) VALUES (2, 'Bob', 2); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'); INSERT INTO Programs (ProgramID, ProgramName) VALUES (2, 'Environment');
How many volunteers engaged per program in Q1 2022?
SELECT ProgramName, COUNT(DISTINCT VolunteerID) as VolunteersEngaged FROM Volunteers JOIN Programs ON Volunteers.ProgramID = Programs.ProgramID WHERE QUARTER(VolunteerDate) = 1 AND YEAR(VolunteerDate) = 2022 GROUP BY ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_ticket_sales (ticket_sale_id INT, artist_id INT, ticket_price DECIMAL(5,2), sale_date DATE);
What is the total revenue generated from concert ticket sales for each artist, for artists who have more than 10 million streams?
SELECT a.artist_id, SUM(t.ticket_price) as total_revenue FROM concert_ticket_sales t JOIN (SELECT artist_id FROM artist_streams WHERE streams > 10000000) a ON t.artist_id = a.artist_id GROUP BY a.artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, depth FLOAT, ocean TEXT); INSERT INTO marine_protected_areas (name, depth, ocean) VALUES ('Galapagos Marine Reserve', 2600.0, 'Pacific'), ('Great Barrier Reef', 3444.0, 'Pacific'), ('Sargasso Sea', 7000.0, 'Atlantic'), ('Bermuda Triangle', 4000.0, 'Atlantic');
What is the average depth of marine protected areas in the Pacific and Atlantic oceans?
SELECT AVG(depth) FROM marine_protected_areas WHERE ocean IN ('Pacific', 'Atlantic');
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_name TEXT, last_inspection_date DATE); CREATE TABLE safety_violations (vessel_name TEXT, violation_date DATE); INSERT INTO vessels (vessel_name, last_inspection_date) VALUES ('Ever Given', '2019-06-15'), ('Titanic Memorial Cruise', '2019-04-15'); INSERT INTO safety_violations (vessel_name, violation_date) VALUES ('Ever Given', '2021-03-23'), ('Titanic Memorial Cruise', '2021-04-12');
List all vessels with maritime safety violations in the last 3 years.
SELECT vessels.vessel_name FROM vessels INNER JOIN safety_violations ON vessels.vessel_name = safety_violations.vessel_name WHERE safety_violations.violation_date >= vessels.last_inspection_date AND vessels.last_inspection_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Budget (quarter INT, year INT, amount INT); INSERT INTO Infrastructure_Budget (quarter, year, amount) VALUES (1, 2021, 500000), (2, 2021, 600000), (3, 2021, 700000), (4, 2021, 800000), (1, 2022, 550000), (2, 2022, 650000), (3, 2022, 750000), (4, 2022, 850000);
What was the total budget allocated for infrastructure development in Q1 2021?
SELECT SUM(amount) as Total_Budget FROM Infrastructure_Budget WHERE quarter = 1 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE TopDefense.EquipmentSales (id INT, manufacturer VARCHAR(255), equipment_type VARCHAR(255), quantity INT, price DECIMAL(10,2), buyer_country VARCHAR(255), sale_date DATE);
What is the total value of military equipment sales to the Australian government by TopDefense from 2015 to 2020?
SELECT SUM(quantity * price) FROM TopDefense.EquipmentSales WHERE buyer_country = 'Australia' AND manufacturer = 'TopDefense' AND sale_date BETWEEN '2015-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, name TEXT, hired_date DATE, language TEXT, cultural_competency_score INT);
What is the total number of community health workers who have been hired in the last year?
SELECT COUNT(*) FROM community_health_workers WHERE hired_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Harvest (ID INT PRIMARY KEY, AquacultureFacilityID INT, HarvestDate DATE, Quantity INT, FOREIGN KEY (AquacultureFacilityID) REFERENCES AquacultureFacilities(ID)); INSERT INTO Harvest (ID, AquacultureFacilityID, HarvestDate, Quantity) VALUES (3, 3, '2022-04-01', 1500);
How many facilities are there for each species, and what is the total harvest quantity for each species, grouped by species and month?
SELECT af.SpeciesID, f.Name AS SpeciesName, COUNT(af.ID) AS NumFacilities, SUM(h.Quantity) AS TotalHarvestQuantity, DATE_FORMAT(h.HarvestDate, '%%Y-%%m') AS Month FROM AquacultureFacilities af JOIN Species f ON af.SpeciesID = f.ID JOIN Harvest h ON af.ID = h.AquacultureFacilityID GROUP BY af.SpeciesID, f.Name, MONTH(h.HarvestDate);
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Sila Copper', 'Nairobi, Kenya'), (2, 'Tumazoz Silver', 'Tangier, Morocco'), (3, 'Kavango Coal', 'Windhoek, Namibia'); CREATE TABLE employees (employee_id INT, name TEXT, gender TEXT, community TEXT, job_title TEXT, mining_site_id INT); INSERT INTO employees (employee_id, name, gender, community, job_title, mining_site_id) VALUES (1, 'Aisha Mohamed', 'Female', 'Historically marginalized', 'Miner', 1), (2, 'Ali Omar', 'Male', 'Indigenous', 'Engineer', 1), (3, 'Fatima Ahmed', 'Female', 'Refugee', 'Manager', 2), (4, 'Ahmed Hassan', 'Male', 'LGBTQIA+', 'Miner', 2), (5, 'Zainab Nassir', 'Female', 'Person with disability', 'Engineer', 3);
How many employees of underrepresented communities work in each mining site?
SELECT site_name, community, COUNT(*) AS employee_count FROM employees JOIN mining_sites ON employees.mining_site_id = mining_sites.site_id GROUP BY site_name, community;
gretelai_synthetic_text_to_sql
CREATE TABLE ClientDemographics (ClientID INT, Age INT, Won BOOLEAN); INSERT INTO ClientDemographics (ClientID, Age, Won) VALUES (1, 35, FALSE), (2, 45, TRUE);
What is the maximum age of clients who lost their cases?
SELECT MAX(ClientDemographics.Age) FROM ClientDemographics WHERE ClientDemographics.Won = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTechnologies (id INT, tech_name TEXT, country TEXT, development_cost FLOAT); INSERT INTO MilitaryTechnologies (id, tech_name, country, development_cost) VALUES (1, 'T-14 Armata', 'Russia', 38000000);
List all military technologies used by Russia and their respective development costs.
SELECT MilitaryTechnologies.tech_name, MilitaryTechnologies.development_cost FROM MilitaryTechnologies WHERE MilitaryTechnologies.country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE user_behavior (user_id INT, post_date DATE, posts_per_day INT);
What is the average number of posts per day for users in 'user_behavior' table?
SELECT AVG(posts_per_day) FROM user_behavior;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'Florida'); CREATE TABLE water_conservation_initiatives (id INT, name VARCHAR(255)); INSERT INTO water_conservation_initiatives (id, name) VALUES (1, 'InitiativeA'), (2, 'InitiativeB'); CREATE TABLE water_consumption (initiative_id INT, state_id INT, consumption INT, date DATE); INSERT INTO water_consumption (initiative_id, state_id, consumption, date) VALUES (1, 1, 3000, '2020-01-01'), (1, 1, 3500, '2020-01-02'), (2, 1, 2000, '2020-01-01'), (2, 1, 2500, '2020-01-02');
What is the total water consumption (in gallons) for each water conservation initiative in the state of Florida in 2020?
SELECT initiative_id, state_id, SUM(consumption) as total_consumption FROM water_consumption WHERE state_id = 1 AND date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY initiative_id, state_id;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (grant_id INT, name VARCHAR(50), budget DECIMAL(10,2), project_type VARCHAR(50)); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (1, 'Ethical AI Research', 400000, 'ethical AI'); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (2, 'Accessibility Tech Development', 600000, 'accessibility tech'); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (3, 'Digital Divide Education', 500000, 'digital divide');
What is the total budget of ethical AI and accessibility tech projects, grouped by project type?
SELECT project_type, SUM(budget) FROM grants WHERE project_type IN ('ethical AI', 'accessibility tech') GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_projects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), offset_tons_co2 INT, start_date DATE, end_date DATE);
List all carbon offset projects in 'asia' with offset amount greater than 10000 tons CO2
SELECT * FROM carbon_offset_projects WHERE location = 'asia' AND offset_tons_co2 > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_countries (country VARCHAR(50), manufacturing_sector VARCHAR(50), total_emissions INT); INSERT INTO manufacturing_countries (country, manufacturing_sector, total_emissions) VALUES ('India', 'textile_recycling', 35000), ('China', 'textile_manufacturing', 120000), ('Vietnam', 'garment_production', 55000);
Show the number of records in the 'manufacturing_countries' table
SELECT COUNT(*) FROM manufacturing_countries;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INTEGER, fan_state TEXT);
How many fans are from CA in the fan_demographics table?
SELECT COUNT(*) FROM fan_demographics WHERE fan_state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_providers (provider TEXT, subscribers INT);
Create a view to list top 3 mobile network providers by number of subscribers
CREATE VIEW top_providers AS SELECT provider, subscribers, ROW_NUMBER() OVER (ORDER BY subscribers DESC) as rank FROM mobile_providers;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorName VARCHAR(100), DonationAmount DECIMAL(10,2), DonationDate DATE, ProgramName VARCHAR(100)); INSERT INTO Donations (DonorName, DonationAmount, DonationDate, ProgramName) VALUES (1, 'John Smith', 7500, '2021-05-10', 'Education Fund'), (2, 'Alice Lee', 8500, '2022-01-01', 'Disaster Relief');
Insert a new record of a donation from 'Leila Zhang' of $12000 to the 'Women Empowerment' program on '2022-06-15'.
INSERT INTO Donations (DonorName, DonationAmount, DonationDate, ProgramName) VALUES ('Leila Zhang', 12000, '2022-06-15', 'Women Empowerment');
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (date DATE, location VARCHAR(255), temperature FLOAT, renewable_energy_production FLOAT); INSERT INTO weather_data (date, location, temperature, renewable_energy_production) VALUES ('2022-01-01', 'New York', 32, 50000);
Find the total renewable energy production in 2022 for each location
SELECT location, SUM(renewable_energy_production) FROM weather_data WHERE EXTRACT(YEAR FROM date) = 2022 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (id INT, name TEXT); INSERT INTO manufacturers (id, name) VALUES (1, 'MNO'), (2, 'PQR'); CREATE TABLE local_suppliers (id INT, manufacturer_id INT, cost FLOAT); INSERT INTO local_suppliers (id, manufacturer_id, cost) VALUES (1, 1, 5000.00), (2, 1, 7000.00), (3, 2, 8000.00); CREATE TABLE materials (id INT, local_supplier_id INT, quantity INT); INSERT INTO materials (id, local_supplier_id, quantity) VALUES (1, 1, 100), (2, 2, 150), (3, 3, 200);
What is the total cost of materials sourced from local suppliers by each manufacturer?
SELECT m.name, SUM(l.cost * m.quantity) FROM manufacturers m JOIN local_suppliers l ON m.id = l.manufacturer_id JOIN materials m ON l.id = m.local_supplier_id GROUP BY m.name;
gretelai_synthetic_text_to_sql
CREATE TABLE investment (id INT, company_id INT, investor TEXT, year INT, amount FLOAT); INSERT INTO investment (id, company_id, investor, year, amount) VALUES (1, 1, 'Microsoft', 2022, 8000000.0); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder TEXT, PRIMARY KEY (id)); INSERT INTO company (id, name, industry, founder) VALUES (1, 'AccessTech', 'Assistive Technology', 'Person with Disability');
List the number of investments made in startups founded by persons with disabilities in the last 3 years.
SELECT COUNT(*) FROM investment i JOIN company c ON i.company_id = c.id WHERE c.founder = 'Person with Disability' AND i.year >= (SELECT YEAR(CURRENT_DATE()) - 3);
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_sequences (gene_id INT, sequence VARCHAR(100), PRIMARY KEY (gene_id));
Insert a new genetic sequence 'CCGTTCGG' for 'gene_id' = 18
INSERT INTO genetic_sequences (gene_id, sequence) VALUES (18, 'CCGTTCGG');
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (practice VARCHAR(255), hours INT); INSERT INTO labor_hours (practice, hours) VALUES ('Green Roofs', 1500), ('Solar Panels', 2000);
What are the total construction labor hours for green roof and solar panel installations?
SELECT SUM(hours) FROM labor_hours WHERE practice IN ('Green Roofs', 'Solar Panels');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_appointments (id INT, gender VARCHAR(50), age INT, appointment_date DATE); INSERT INTO mental_health_appointments (id, gender, age, appointment_date) VALUES (1, 'Female', 30, '2022-01-01'), (2, 'Male', 40, '2022-01-02'), (3, 'Female', 50, '2022-01-03');
What is the total number of mental health appointments by gender and age group?
SELECT gender, FLOOR(age/10)*10 AS age_group, COUNT(*) FROM mental_health_appointments GROUP BY gender, age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE VRTechnology (TechID INT PRIMARY KEY, TechName VARCHAR(50), ReleaseDate DATE); INSERT INTO VRTechnology (TechID, TechName, ReleaseDate) VALUES (1, 'VR1', '2016-01-01'), (2, 'VR2', '2020-01-01'), (3, 'VR3', '2022-01-01'); CREATE TABLE PlayerVR (PlayerID INT, TechID INT); INSERT INTO PlayerVR (PlayerID, TechID) VALUES (6, 1), (6, 2), (7, 3); CREATE TABLE Players (PlayerID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (6, 28, 'Female', 'France'), (7, 30, 'Male', 'Germany');
How many VR technologies have been adopted by players from France?
SELECT COUNT(*) FROM PlayerVR JOIN Players ON PlayerVR.PlayerID = Players.PlayerID WHERE Players.Country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE crisis_intervention (donation_id INT, donor VARCHAR(50), amount DECIMAL(10,2), donation_date DATE); INSERT INTO crisis_intervention (donation_id, donor, amount, donation_date) VALUES (1, 'Quick Response (advocacy)', 175.00, '2021-01-15'), (2, 'Mountain Movers (humanitarian aid)', 225.00, '2021-02-05');
Find the most recent donation date in the 'crisis_intervention' table.
SELECT MAX(donation_date) FROM crisis_intervention;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (sale_id INT, product_id INT, country VARCHAR(50), category VARCHAR(50), revenue DECIMAL(10,2), sale_date DATE);
What are the top 3 beauty product categories with the highest sales in the Asian region?
SELECT category, SUM(revenue) as total_revenue FROM sales_data WHERE sale_date >= '2022-01-01' AND country LIKE 'Asia%' GROUP BY category ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255));
Add a new marine species to the 'marine_species' table
INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1005, 'Manta Ray', 'Vulnerable');
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, division VARCHAR(20), total_cost FLOAT); INSERT INTO Projects (id, division, total_cost) VALUES (1, 'water', 500000), (2, 'transportation', 300000), (3, 'water', 750000), (4, 'transportation', 800000), (5, 'transportation', 150000);
What is the average total cost of projects in the transportation division that have an id greater than 2?
SELECT AVG(total_cost) FROM Projects WHERE division = 'transportation' AND id > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_complaints (complaint_id INT, complaint_type VARCHAR(50), continent VARCHAR(50), complaint_date DATE); INSERT INTO customer_complaints (complaint_id, complaint_type, continent, complaint_date) VALUES (1, 'Billing', 'Asia', '2023-03-01'), (2, 'Network', 'Asia', '2023-03-05'), (3, 'Billing', 'Africa', '2023-03-10'), (4, 'Billing', 'Europe', '2023-03-15');
What is the distribution of customer complaints by continent in the past month?
SELECT continent, complaint_type, COUNT(*) as complaints, PERCENT_RANK() OVER (PARTITION BY continent ORDER BY complaints DESC) as complaint_percentile FROM customer_complaints WHERE complaint_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY continent, complaint_type;
gretelai_synthetic_text_to_sql
CREATE TABLE boroughs (bid INT, borough_name VARCHAR(255)); CREATE TABLE events (eid INT, bid INT, event_date DATE);
What is the total number of community policing events in each borough, sorted by event count?
SELECT b.borough_name, COUNT(e.eid) AS total_event_count FROM boroughs b INNER JOIN events e ON b.bid = e.bid GROUP BY b.borough_name ORDER BY total_event_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, country VARCHAR(50), alert_date DATE, alert_level INT); INSERT INTO threat_intelligence (id, country, alert_date, alert_level) VALUES (1, 'X', '2022-01-05', 3), (2, 'Y', '2022-01-07', 4), (3, 'X', '2022-01-10', 2);
What is the average threat level of alerts in country 'Y'?
SELECT AVG(alert_level) FROM threat_intelligence WHERE country = 'Y';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name VARCHAR(50), total_quantity INT, date DATE); INSERT INTO Warehouse (id, name, total_quantity, date) VALUES (1, 'Warehouse A', 300, '2023-02-01'), (2, 'Warehouse B', 400, '2023-02-01');
Calculate the total quantity of items in all warehouses for February 2023
SELECT SUM(total_quantity) FROM Warehouse WHERE date = '2023-02-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Violations (id INT PRIMARY KEY, violation_type VARCHAR(255), offender_name VARCHAR(255), fine INT);
Display all the maritime law violations along with the offender names from the 'Violations' table
SELECT violation_type, offender_name FROM Violations;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_usage_ca (state VARCHAR(20), year INT, sector VARCHAR(30), usage FLOAT); INSERT INTO industrial_water_usage_ca (state, year, sector, usage) VALUES ('California', 2020, 'Agriculture', 12345.6), ('California', 2020, 'Manufacturing', 23456.7), ('California', 2020, 'Mining', 34567.8); CREATE TABLE industrial_water_usage_tx (state VARCHAR(20), year INT, sector VARCHAR(30), usage FLOAT); INSERT INTO industrial_water_usage_tx (state, year, sector, usage) VALUES ('Texas', 2020, 'Agriculture', 23456.7), ('Texas', 2020, 'Manufacturing', 34567.8), ('Texas', 2020, 'Oil and Gas', 45678.9);
Compare the average water usage by industrial sectors in California and Texas in 2020.
SELECT AVG(industrial_water_usage_ca.usage) FROM industrial_water_usage_ca WHERE state = 'California' AND year = 2020; SELECT AVG(industrial_water_usage_tx.usage) FROM industrial_water_usage_tx WHERE state = 'Texas' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE product_ingredients (product_id INT, product_category VARCHAR(50), ingredient VARCHAR(50)); INSERT INTO product_ingredients (product_id, product_category, ingredient) VALUES (1009, 'skincare', 'aloe vera'), (1010, 'skincare', 'lavender oil'), (1011, 'haircare', 'coconut oil'), (1012, 'skincare', 'jojoba oil'), (1013, 'makeup', 'talc');
Which natural ingredient is most commonly used in skincare products?
SELECT ingredient, COUNT(*) AS ingredient_count FROM product_ingredients WHERE product_category = 'skincare' GROUP BY ingredient ORDER BY ingredient_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_name VARCHAR(100), year INT, location VARCHAR(100)); INSERT INTO projects (project_id, project_name, year, location) VALUES (1, 'Wind Farm', 2018, 'Europe'), (2, 'Solar Farm', 2019, 'Asia'), (3, 'Hydroelectric Dam', 2017, 'South America'), (4, 'Geothermal Plant', 2016, 'Africa'), (5, 'Carbon Capture', 2015, 'North America'), (6, 'Biofuel Research', 2014, 'Europe'), (7, 'Energy Efficiency', 2018, 'Asia'), (8, 'Electric Vehicles', 2019, 'South America'), (9, 'Climate Education', 2017, 'Africa'), (10, 'Climate Adaptation', 2016, 'North America');
What is the number of climate-related projects financed by year and by continent?
SELECT EXTRACT(YEAR FROM projects.year) AS year, CONCAT(SUBSTRING(location, 1, 3), '...') AS continent, COUNT(*) AS projects_funded FROM projects GROUP BY year, continent;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (region VARCHAR(50), amount FLOAT, sector VARCHAR(50)); INSERT INTO climate_finance (region, amount, sector) VALUES ('Asia', 6000000, 'Mitigation'), ('Africa', 4000000, 'Mitigation'), ('Europe', 7000000, 'Adaptation');
Which climate adaptation projects in Europe have received the most climate finance?
SELECT sector, region, MAX(amount) FROM climate_finance WHERE sector = 'Adaptation' AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (id INT, name TEXT, location TEXT); INSERT INTO mental_health_facilities (id, name, location) VALUES (1, 'Facility A', 'City A'); INSERT INTO mental_health_facilities (id, name, location) VALUES (2, 'Facility B', 'City B'); CREATE TABLE populations (city TEXT, size INT); INSERT INTO populations (city, size) VALUES ('City A', 800000); INSERT INTO populations (city, size) VALUES ('City B', 700000);
List the number of mental health facilities in each city with a population over 750,000 in the US?
SELECT mental_health_facilities.location, COUNT(mental_health_facilities.id) FROM mental_health_facilities INNER JOIN populations ON mental_health_facilities.location = populations.city WHERE populations.size > 750000 GROUP BY mental_health_facilities.location;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'StartupA', 'California', 15000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'StartupB', 'Texas', 12000000); INSERT INTO startups (id, name, location, funding) VALUES (3, 'StartupC', 'China', 20000000);
What is the total funding amount for biotech startups located in Asia?
SELECT SUM(funding) FROM startups WHERE location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE property_types (property_type VARCHAR(255), PRIMARY KEY (property_type)); INSERT INTO property_types (property_type) VALUES ('Single Family'), ('Condo');
Find the difference in the median listing price between single-family homes and condos in Seattle, Washington.
SELECT a.median_price - b.median_price as price_difference FROM (SELECT name, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY listing_price) as median_price FROM real_estate_listings WHERE city = 'Seattle' AND property_type = 'Single Family' GROUP BY name) a JOIN (SELECT name, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY listing_price) as median_price FROM real_estate_listings WHERE city = 'Seattle' AND property_type = 'Condo' GROUP BY name) b ON a.name = b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_production (country VARCHAR(50), year INT, plastic_waste_kg_per_capita FLOAT);
Which countries have the highest plastic waste production in 2021? Update the waste_production table with the latest data.
UPDATE waste_production SET plastic_waste_kg_per_capita = 120.5 WHERE country = 'Brazil' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name VARCHAR(50));CREATE TABLE ev_sales (sale_id INT, ev_type VARCHAR(50), sale_city INT);INSERT INTO cities (city_id, city_name) VALUES (1, 'Tokyo'), (2, 'New York');INSERT INTO ev_sales (sale_id, ev_type, sale_city) VALUES (1, 'Tesla Bus', 1), (2, 'Proterra Bus', 2);
Count the number of electric buses in Tokyo and New York
SELECT c.city_name, COUNT(es.ev_type) as num_ebuses FROM cities c JOIN ev_sales es ON c.city_id = es.sale_city WHERE es.ev_type LIKE '%Bus' GROUP BY c.city_name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, name VARCHAR(50), movement VARCHAR(50), attendance INT); INSERT INTO events (event_id, name, movement, attendance) VALUES (1, 'Art Exhibit', 'Cubism', 1500); INSERT INTO events (event_id, name, movement, attendance) VALUES (2, 'Theater Performance', 'Surrealism', 850); INSERT INTO events (event_id, name, movement, attendance) VALUES (3, 'Art Exhibit', 'Impressionism', 1200);
How many events in the 'events' table are associated with each art movement?
SELECT movement, COUNT(*) as num_events FROM events GROUP BY movement;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name TEXT, platinum_albums INT, concert_ticket_revenue INT); INSERT INTO Artists (artist_id, artist_name, platinum_albums, concert_ticket_revenue) VALUES (1, 'Beyoncé', 6, 1000000), (2, 'Ed Sheeran', 3, 750000), (3, 'Justin Bieber', 4, 850000);
What is the total revenue from concert ticket sales for artists who have released at least one platinum album?
SELECT SUM(a.concert_ticket_revenue) FROM Artists a WHERE a.platinum_albums > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (forest_type VARCHAR(255), year INT, carbon_sequestration INT); INSERT INTO forests (forest_type, year, carbon_sequestration) VALUES ('Temperate', 2018, 500), ('Temperate', 2019, 550), ('Temperate', 2020, 600), ('Temperate', 2021, 650), ('Boreal', 2018, 700), ('Boreal', 2019, 750), ('Boreal', 2020, 800), ('Boreal', 2021, 850), ('Tropical', 2018, 900), ('Tropical', 2019, 950), ('Tropical', 2020, 1000), ('Tropical', 2021, 1050);
What is the carbon sequestration by forest type and year?
SELECT forest_type, year, carbon_sequestration FROM forests;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT PRIMARY KEY, name VARCHAR(255), vessel_type VARCHAR(255), year_built INT); INSERT INTO vessels (id, name, vessel_type, year_built) VALUES (1, 'ABC Tanker', 'Tanker', 2000), (2, 'DEF Bulker', 'Bulker', 2010), (3, 'GHI Container', 'Container', 2015), (4, 'JKL Trawler', 'Trawler', 2008), (5, 'MNO Ferry', 'Ferry', 2012), (6, 'OLD SAILOR', 'Sailboat', 2005);
Update the vessels table to change the name to 'MAIDEN VOYAGE' for the record with an id of 6
UPDATE vessels SET name = 'MAIDEN VOYAGE' WHERE id = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, grade_level INT); INSERT INTO students (student_id, grade_level) VALUES (1, 6), (2, 7), (3, 8), (4, 9); CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(255), grade_level INT); INSERT INTO initiatives (initiative_id, initiative_name, grade_level) VALUES (1, 'Project-Based Learning', 6), (2, 'Maker Spaces', 7), (3, 'Genius Hour', 8), (4, 'E-Portfolios', 9); CREATE TABLE engagements (student_id INT, initiative_id INT); INSERT INTO engagements (student_id, initiative_id) VALUES (1, 1), (2, 2), (3, 3), (4, 4);
What is the number of students who have engaged in open pedagogy initiatives in each grade level?
SELECT s.grade_level, COUNT(DISTINCT e.student_id) as num_students FROM engagements e JOIN students s ON e.student_id = s.student_id JOIN initiatives i ON e.initiative_id = i.initiative_id GROUP BY s.grade_level;
gretelai_synthetic_text_to_sql
CREATE TABLE LaborStatistics (workerID INT, laborDate DATE, trade VARCHAR(50), hourlyRate DECIMAL(10,2), gender VARCHAR(10));
What is the average hourly wage for female construction workers in the 'LaborStatistics' table?
SELECT AVG(hourlyRate) AS AverageHourlyWage FROM LaborStatistics WHERE gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE AttorneyBilling (AttorneyID INT, Amount DECIMAL(10, 2)); INSERT INTO AttorneyBilling (AttorneyID, Amount) VALUES (1, 5000.00), (2, 7000.00);
Which attorneys have worked on cases with a high billing amount?
SELECT DISTINCT Attorneys.AttorneyID FROM Attorneys INNER JOIN AttorneyBilling ON Attorneys.AttorneyID = AttorneyBilling.AttorneyID WHERE AttorneyBilling.Amount > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, org_name VARCHAR(50), org_type VARCHAR(20)); CREATE TABLE programs (id INT, program_name VARCHAR(50), org_id INT, start_date DATE, end_date DATE);
Which organizations participated in refugee support programs in 2020?
SELECT DISTINCT org_name FROM organizations o JOIN programs p ON o.id = p.org_id WHERE YEAR(p.start_date) = 2020 AND YEAR(p.end_date) = 2020 AND org_type = 'Refugee Support';
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(50), country VARCHAR(20), open_pedagogy BOOLEAN); INSERT INTO initiatives (initiative_id, initiative_name, country, open_pedagogy) VALUES (1, 'Open Education Resources', 'USA', TRUE), (2, 'Massive Open Online Courses', 'Canada', TRUE), (3, 'Flipped Classroom', 'Mexico', FALSE), (4, 'Project-Based Learning', 'Brazil', TRUE);
What is the distribution of open pedagogy initiatives by country, with a count of initiatives that use open pedagogy and those that do not?
SELECT country, SUM(CASE WHEN open_pedagogy THEN 1 ELSE 0 END) as num_open, SUM(CASE WHEN NOT open_pedagogy THEN 1 ELSE 0 END) as num_not_open FROM initiatives GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE diversification_projects (id INT, initiative_name VARCHAR(50), budget INT, location VARCHAR(50)); INSERT INTO diversification_projects VALUES (1, 'Handicraft Production', 30000, 'Asia'), (2, 'Eco-Tourism', 50000, 'Africa'), (3, 'Livestock Farming', 75000, 'Europe');
List the unique economic diversification initiatives from the 'diversification_projects' table, excluding those that have a budget less than 25000 or are located in 'Asia'.
SELECT DISTINCT initiative_name FROM diversification_projects WHERE budget > 25000 AND location != 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets (id INT, name TEXT, discovery_mission TEXT, mass FLOAT); INSERT INTO exoplanets (id, name, discovery_mission, mass) VALUES (1, 'Kepler-186f', 'Kepler', 1.3), (2, 'HD 219134 b', 'TESS', 4.5), (3, 'Pi Mensae c', 'TESS', 12.6), (4, 'Kepler-22b', 'Kepler', 3.9);
What is the maximum mass of any exoplanet discovered by the Kepler space telescope?
SELECT MAX(mass) FROM exoplanets WHERE discovery_mission = 'Kepler';
gretelai_synthetic_text_to_sql
CREATE TABLE student_accommodations (student_id INT, accommodation_year INT, accommodation_type VARCHAR(255));
Delete all records with accommodation_type 'extended_time'
DELETE FROM student_accommodations WHERE accommodation_type = 'extended_time';
gretelai_synthetic_text_to_sql
CREATE TABLE midwest_water_usage(sector VARCHAR(20), usage INT, state VARCHAR(20)); INSERT INTO midwest_water_usage(sector, usage, state) VALUES ('Agricultural', 20000000, 'Iowa'), ('Agricultural', 15000000, 'Illinois'), ('Agricultural', 10000000, 'Indiana');
What is the water usage in the agricultural sector in the Midwest region?
SELECT usage FROM midwest_water_usage WHERE sector = 'Agricultural' AND state IN ('Iowa', 'Illinois', 'Indiana');
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, ota_name TEXT, region TEXT); CREATE TABLE virtual_tours (vt_id INT, ota_id INT, engagements INT); INSERT INTO otas (ota_id, ota_name, region) VALUES (1, 'OTA 1', 'Asia'), (2, 'OTA 2', 'Europe'), (3, 'OTA 3', 'Asia'); INSERT INTO virtual_tours (vt_id, ota_id, engagements) VALUES (1, 1, 500), (2, 2, 300), (3, 3, 700), (4, 1, 800);
Which online travel agencies have the highest number of virtual tour engagements in Asia?
SELECT ota_name, SUM(engagements) as total_engagements FROM otas JOIN virtual_tours ON otas.ota_id = virtual_tours.ota_id WHERE region = 'Asia' GROUP BY ota_name ORDER BY total_engagements DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.technologies(id INT, name TEXT, sensitivity FLOAT);INSERT INTO biosensors.technologies(id, name, sensitivity) VALUES (1, 'TechnologyA', 95.2), (2, 'TechnologyB', 98.7), (3, 'TechnologyC', 99.4);
List the top 3 biosensor technologies with the highest sensitivity
SELECT name FROM biosensors.technologies ORDER BY sensitivity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE books (title VARCHAR(255), author VARCHAR(100), rating DECIMAL(3,2), category VARCHAR(50)); CREATE VIEW children_books AS SELECT DISTINCT title FROM books WHERE category = 'children'; CREATE VIEW authors_from_asia AS SELECT DISTINCT author FROM authors WHERE country IN ('India', 'China', 'Japan', 'South Korea', 'Indonesia');
Find the average rating of children's books written by authors from Asia.
SELECT AVG(rating) FROM books JOIN children_books ON books.title = children_books.title JOIN authors_from_asia ON books.author = authors_from_asia.author WHERE category = 'children';
gretelai_synthetic_text_to_sql