context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE vulnerabilities (id INT, vuln_severity INT, vuln_date DATE, asset_type VARCHAR(50)); INSERT INTO vulnerabilities (id, vuln_severity, vuln_date, asset_type) VALUES (1, 7, '2022-01-01', 'server'), (2, 8, '2022-02-05', 'server'), (3, 9, '2022-03-10', 'server');
|
What is the average severity of vulnerabilities found in the last quarter for the 'server' asset type?
|
SELECT AVG(vuln_severity) as avg_severity FROM vulnerabilities WHERE vuln_date >= DATEADD(quarter, -1, GETDATE()) AND asset_type = 'server';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Port (port_id INT PRIMARY KEY, port_name VARCHAR(255)); INSERT INTO Port (port_id, port_name) VALUES (1, 'New York'), (2, 'Los Angeles'); CREATE TABLE Vessel (vessel_id INT PRIMARY KEY, vessel_name VARCHAR(255)); CREATE TABLE Cargo (cargo_id INT, vessel_id INT, cargo_weight INT, PRIMARY KEY (cargo_id, vessel_id)); CREATE TABLE Vessel_Movement (vessel_id INT, movement_date DATE, port_id INT, PRIMARY KEY (vessel_id, movement_date));
|
What is the total cargo weight for each vessel that visited New York and Los Angeles in the first quarter of 2022?
|
SELECT V.vessel_name, SUM(C.cargo_weight) FROM Vessel V JOIN Cargo C ON V.vessel_id = C.vessel_id JOIN Vessel_Movement VM ON V.vessel_id = VM.vessel_id WHERE VM.movement_date >= '2022-01-01' AND VM.movement_date < '2022-04-01' AND VM.port_id IN (1, 2) GROUP BY V.vessel_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Aircrafts (id INT, name VARCHAR(50), type VARCHAR(50), maintenance_cost FLOAT);
|
What is the average maintenance cost for military aircrafts?
|
SELECT AVG(maintenance_cost) FROM Aircrafts WHERE type = 'Military';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), Region varchar(50), VolunteerDate date); INSERT INTO Volunteers (VolunteerID, VolunteerName, Region, VolunteerDate) VALUES (1, 'Bob Johnson', 'Northeast', '2019-01-01'), (2, 'Sally Davis', 'Southeast', '2019-05-15');
|
How many volunteers signed up in each region in 2019?
|
SELECT Region, COUNT(*) as NumVolunteers FROM Volunteers WHERE VolunteerDate BETWEEN '2019-01-01' AND '2019-12-31' GROUP BY Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donor_continent(donor_id INT, donor_name TEXT, continent TEXT); INSERT INTO donor_continent(donor_id, donor_name, continent) VALUES (1, 'John Doe', 'North America'), (2, 'Jane Smith', 'North America'), (3, 'Alice Johnson', 'Africa');
|
How many donors have there been in total from each continent?
|
SELECT continent, COUNT(*) FROM donor_continent GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE language_preservation_budget (id INT, language VARCHAR(50), region VARCHAR(20), budget INT); INSERT INTO language_preservation_budget (id, language, region, budget) VALUES (1, 'Mandarin', 'Asia', 500000), (2, 'English', 'Europe', 700000), (3, 'Tibetan', 'Asia', 300000);
|
What is the total budget allocated for endangered language preservation in Asia?
|
SELECT SUM(budget) FROM language_preservation_budget WHERE region = 'Asia' AND language IN (SELECT name FROM endangered_languages WHERE status = 'Endangered' OR status = 'Critically Endangered');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name VARCHAR(255), location VARCHAR(255), annual_coal_production INT); INSERT INTO mines (id, name, location, annual_coal_production) VALUES (1, 'Mine A', 'USA', 150000), (2, 'Mine B', 'Canada', 80000), (3, 'Mine C', 'USA', 120000), (4, 'Mine D', 'USA', 90000), (5, 'Mine E', 'Australia', 110000);
|
List the mines that have more than 100000 tons of annual coal production.
|
SELECT m.name FROM mines m WHERE m.annual_coal_production > 100000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE African_Plate (trench_name TEXT, location TEXT, max_depth FLOAT); INSERT INTO African_Plate (trench_name, location, max_depth) VALUES ('Southwest Indian Ridge', 'Indian Ocean', 7455), ('Mid-Atlantic Ridge', 'Atlantic Ocean', 7000);
|
What is the maximum depth of oceanic trenches in the African plate?
|
SELECT MAX(max_depth) FROM African_Plate;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE personal_injury (case_id INT, client_name VARCHAR(50), case_status VARCHAR(20), closed_date DATE);
|
Delete all cases from the 'personal_injury' table that were closed before 2015-01-01
|
WITH deleted_cases AS (DELETE FROM personal_injury WHERE case_status = 'closed' AND closed_date < '2015-01-01' RETURNING *) SELECT * FROM deleted_cases;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, department VARCHAR(20));CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2), department VARCHAR(20)); INSERT INTO factories (factory_id, department) VALUES (1, 'textile'), (2, 'metal'), (3, 'electronics'); INSERT INTO workers (worker_id, factory_id, salary, department) VALUES (1, 1, 35000, 'textile'), (2, 1, 36000, 'textile'), (3, 2, 45000, 'metal'), (4, 2, 46000, 'metal'), (5, 3, 55000, 'electronics');
|
What is the maximum salary for workers in the 'metal' department at factory 2?
|
SELECT MAX(w.salary) FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'metal' AND w.factory_id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), country VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft (id, name, country, launch_date) VALUES (1, 'Falcon 9', 'USA', '2010-06-04'); INSERT INTO Spacecraft (id, name, country, launch_date) VALUES (2, 'Soyuz-FG', 'Russia', '2001-11-02'); CREATE TABLE Astronauts (id INT, name VARCHAR(50), gender VARCHAR(50), spacecraft_id INT); INSERT INTO Astronauts (id, name, gender, spacecraft_id) VALUES (1, 'Douglas Hurley', 'Male', 1); INSERT INTO Astronauts (id, name, gender, spacecraft_id) VALUES (2, 'Anousheh Ansari', 'Female', 2); CREATE TABLE Flights (id INT, astronaut_id INT, spacecraft_id INT); INSERT INTO Flights (id, astronaut_id, spacecraft_id) VALUES (1, 1, 1); INSERT INTO Flights (id, astronaut_id, spacecraft_id) VALUES (2, 2, 2);
|
What is the name and gender of all astronauts who have flown on spacecraft launched by the USA?
|
SELECT a.name AS astronaut_name, a.gender FROM Astronauts a JOIN Flights f ON a.id = f.astronaut_id JOIN Spacecraft sp ON f.spacecraft_id = sp.id WHERE sp.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Feedback(Quarter INT, Region VARCHAR(20), Service VARCHAR(20), Score INT); INSERT INTO Feedback(Quarter, Region, Service, Score) VALUES (1, 'Urban', 'Public Transportation', 8), (1, 'Urban', 'Public Transportation', 9), (1, 'Urban', 'Public Transportation', 7), (1, 'Rural', 'Public Transportation', 6), (2, 'Urban', 'Public Transportation', 8);
|
What was the average citizen feedback score for public transportation in urban areas in Q1 2022?
|
SELECT AVG(Score) FROM Feedback WHERE Quarter = 1 AND Region = 'Urban' AND Service = 'Public Transportation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (id INT, name VARCHAR(255), category VARCHAR(255), sustainability_rating INT, monthly_revenue DECIMAL(10,2)); INSERT INTO restaurants (id, name, category, sustainability_rating, monthly_revenue) VALUES (1, 'Green Garden', 'Organic', 5, 25000), (2, 'Quick Bites', 'Fast Food', 2, 18000), (3, 'Healthy Bites', 'Organic', 4, 22000), (4, 'Farm Fresh', 'Farm to Table', 3, 19000), (5, 'Local Harvest', 'Organic', 5, 26000);
|
Calculate the total revenue for each restaurant category.
|
SELECT category, SUM(monthly_revenue) FROM restaurants GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, name VARCHAR(50), position VARCHAR(50), age INT);
|
List the top 5 most common positions in the "mining_operations" table, along with their count.
|
SELECT position, COUNT(*) AS count FROM mining_operations GROUP BY position ORDER BY count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE packages (id INT, package_status VARCHAR(20), delivery_date DATE); INSERT INTO packages (id, package_status, delivery_date) VALUES (1, 'delayed', '2022-06-15'); INSERT INTO packages (id, package_status, delivery_date) VALUES (2, 'delivered', '2022-06-20'); INSERT INTO packages (id, package_status, delivery_date) VALUES (3, 'delayed', '2022-06-18');
|
Delete records in the "packages" table where the package status is "delayed" and the delivery date is older than 3 days
|
DELETE FROM packages WHERE package_status = 'delayed' AND DATEDIFF(day, delivery_date, CURDATE()) > 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE extraction_stats (year INT, mine_name TEXT, material TEXT, quantity INT); INSERT INTO extraction_stats (year, mine_name, material, quantity) VALUES (2015, 'Aggromine A', 'Gold', 1200), (2015, 'Aggromine A', 'Silver', 2500), (2016, 'Borax Bravo', 'Boron', 18000), (2016, 'Borax Bravo', 'Copper', 3000), (2017, 'Carbon Cat', 'Coal', 12300), (2017, 'Carbon Cat', 'Diamonds', 250), (2018, 'Diamond Delta', 'Graphite', 1500), (2018, 'Diamond Delta', 'Graphite', 1800), (2019, 'Emerald Echo', 'Emerald', 2000), (2019, 'Emerald Echo', 'Emerald', 2200), (2020, 'Manganese Monarch', 'Gold', 5000), (2020, 'Manganese Monarch', 'Gold', 5500);
|
What is the total quantity of gold extracted by the Manganese Monarch mine for each year?
|
SELECT year, mine_name, SUM(quantity) as total_gold_quantity FROM extraction_stats WHERE mine_name = 'Manganese Monarch' AND material = 'Gold' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonorGender varchar(10), DonationCount int, TotalDonations numeric(18,2));
|
What is the total number of donations and total amount donated by each gender in the 'Donors' table?
|
SELECT DonorGender, SUM(DonationCount) as TotalDonationsCount, SUM(TotalDonations) as TotalDonationsAmount FROM Donors GROUP BY DonorGender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtWorks (ArtworkID int, Title varchar(100), YearCreated int, ArtistID int);
|
How many artworks were created by each artist in the 1800s?
|
SELECT Artists.Name, COUNT(ArtWorks.ArtworkID) FROM Artists
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArt (ArtID int, ArtName varchar(50), ArtType varchar(50)); INSERT INTO TraditionalArt (ArtID, ArtName, ArtType) VALUES (1, 'Pottery', 'Ceramics'), (2, 'Woven Rug', 'Textiles'), (3, 'Calligraphy', 'Writing'), (4, 'Dance Performance', 'Performance'), (5, 'Painting', 'Ceramics'), (6, 'Sculpture', 'Sculpture');
|
What are the unique art types and their counts in the TraditionalArt table?
|
SELECT ArtType, COUNT(*) FROM TraditionalArt GROUP BY ArtType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameSessions (GameID int, SessionID int); INSERT INTO GameSessions (GameID, SessionID) VALUES (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (3, 6);
|
What is the total number of sessions for each game?
|
SELECT G.GameName, COUNT(GS.SessionID) as SessionCount FROM Games G JOIN GameSessions GS ON G.GameID = GS.GameID GROUP BY G.GameName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stations (station_id INT, station_name TEXT, vehicle_id INT, is_wheelchair_accessible BOOLEAN); CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT);
|
What is the average number of wheelchair-accessible vehicles available per station?
|
SELECT AVG(CASE WHEN s.is_wheelchair_accessible = TRUE THEN 1 ELSE 0 END) as avg_wheelchair_accessible_vehicles_per_station FROM stations s INNER JOIN vehicles v ON s.vehicle_id = v.vehicle_id GROUP BY s.station_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title TEXT, publication_date DATE, publisher TEXT);
|
Insert a new record for an article with the title 'AI and Journalism' published by 'CNN' on '2022-12-01'.
|
INSERT INTO articles (title, publication_date, publisher) VALUES ('AI and Journalism', '2022-12-01', 'CNN');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50), position VARCHAR(50)); INSERT INTO faculty VALUES (1, 'John Doe', 'Male', 'Computer Science', 'Professor'), (2, 'Jane Smith', 'Female', 'Physics', 'Assistant Professor'), (3, 'Alice Johnson', 'Female', 'Mathematics', 'Associate Professor'); CREATE TABLE grants (grant_id INT, faculty_id INT, title VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO grants VALUES (1, 1, 'Grant A', 80000), (2, 1, 'Grant B', 95000), (3, 3, 'Grant C', 60000), (4, 2, 'Grant D', 40000);
|
What is the average grant amount received by male faculty members in the Computer Science department?
|
SELECT AVG(g.amount) FROM grants g INNER JOIN faculty f ON g.faculty_id = f.faculty_id WHERE f.gender = 'Male' AND f.department = 'Computer Science';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EV_Price (id INT, vehicle_model VARCHAR(255), price FLOAT); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (1, 'Lucid Air', 169000.0); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (2, 'Tesla Model S Plaid', 139000.0); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (3, 'Rimac Nevera', 247000.0);
|
What is the minimum range of electric vehicles with a price above $100,000?
|
SELECT MIN(range) FROM EV_Specs WHERE vehicle_model IN (SELECT vehicle_model FROM EV_Price WHERE price > 100000.0);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie (id INT, title VARCHAR(255), studio VARCHAR(255), country VARCHAR(255)); INSERT INTO movie (id, title, studio, country) VALUES (1, 'Movie1', 'StudioA', 'USA'), (2, 'Movie2', 'StudioB', 'USA'), (3, 'Movie3', 'StudioC', 'Canada');
|
What is the total number of movies produced by studios located in the United States?
|
SELECT COUNT(*) FROM movie WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteGeneration (Country VARCHAR(50), WasteQuantity INT, Population INT); INSERT INTO WasteGeneration (Country, WasteQuantity, Population) VALUES ('Japan', 55000000, 126000000), ('South Korea', 40000000, 51000000);
|
Compare the waste generation rates per capita in Japan and South Korea.
|
SELECT Country, WasteQuantity * 1.0 / Population AS WasteGenerationPerCapita FROM WasteGeneration WHERE Country IN ('Japan', 'South Korea') ORDER BY WasteGenerationPerCapita DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hospitals (ID INT, Name VARCHAR(100), State VARCHAR(50)); INSERT INTO Hospitals (ID, Name, State) VALUES (1, 'New York Presbyterian', 'New York'), (2, 'Mount Sinai Hospital', 'New York');
|
How many hospitals are there in the state of New York?
|
SELECT COUNT(*) FROM Hospitals WHERE State = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name TEXT, manager TEXT); INSERT INTO departments (id, name, manager) VALUES (1, 'manufacturing', 'John Doe'), (2, 'research', 'Jane Smith'); CREATE TABLE initiatives (id INT, name TEXT, department TEXT); INSERT INTO initiatives (id, name, department) VALUES (1, 'recycling program', 'manufacturing');
|
Insert a new record for a circular economy initiative in the 'research' department.
|
INSERT INTO initiatives (id, name, department) VALUES (2, 'circular economy', 'research');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Buildings (BuildingID int, Name varchar(100), Location varchar(100), Age int); INSERT INTO Buildings VALUES (1, 'Building A', 'Africa', 10); INSERT INTO Buildings VALUES (2, 'Building B', 'Africa', 15);
|
What is the minimum age (years) of buildings in 'Africa'?
|
SELECT MIN(Age) FROM Buildings WHERE Location = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles_6 (article_id INT, pub_date DATE, category VARCHAR(255)); INSERT INTO news_articles_6 (article_id, pub_date, category) VALUES (1, '2023-07-01', 'Politics'), (2, '2023-07-10', 'Sports'), (3, '2023-07-15', 'Entertainment'), (4, '2023-07-20', 'Politics'), (5, '2023-07-25', 'Sports');
|
What is the total number of articles published per day in July 2023, grouped by their respective categories?
|
SELECT DATE(pub_date) AS pub_date, category, COUNT(*) AS total FROM news_articles_6 WHERE MONTH(pub_date) = 7 AND YEAR(pub_date) = 2023 GROUP BY pub_date, category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soil_moisture_sensors ( id INT, sensor_id INT, moisture DECIMAL(5,2), timestamp TIMESTAMP); INSERT INTO soil_moisture_sensors (id, sensor_id, moisture, timestamp) VALUES (1, 1001, 45, '2022-01-01 12:00:00'), (2, 1002, 48, '2022-01-01 13:00:00'), (3, 1001, 46, '2022-01-01 14:00:00'), (4, 1004, 35, '2022-01-02 15:00:00'), (5, 1003, 50, '2022-01-02 16:00:00');
|
List all unique sensor_ids from the soil_moisture_sensors table with their corresponding moisture readings, ordered by moisture.
|
SELECT DISTINCT sensor_id, moisture FROM soil_moisture_sensors ORDER BY moisture;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CrimeStatistics (Id INT, CrimeType VARCHAR(20), NumberOfIncidences INT, Location VARCHAR(20)); INSERT INTO CrimeStatistics (Id, CrimeType, NumberOfIncidences, Location) VALUES (1, 'Theft', 20, 'CityA'), (2, 'Burglary', 10, 'CityB'), (3, 'Assault', 5, 'CityC'), (4, 'Theft', 15, 'CityA');
|
What is the total number of burglaries and thefts in CityA?
|
SELECT Location, SUM(NumberOfIncidences) FROM CrimeStatistics WHERE CrimeType IN ('Burglary', 'Theft') GROUP BY Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artwork (ArtworkID INT, ArtistID INT, SellingPrice DECIMAL); INSERT INTO Artwork (ArtworkID, ArtistID, SellingPrice) VALUES (1, 2, 200000), (2, 2, 300000);
|
Who are the top 3 artists with the highest selling artwork in the Americas?
|
SELECT ArtistID, MAX(SellingPrice) as HighestSellingPrice FROM Artwork WHERE Continent = 'Americas' GROUP BY ArtistID ORDER BY HighestSellingPrice DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Budget (Year INT, Category VARCHAR(255), Region VARCHAR(255), Amount DECIMAL(10,2)); INSERT INTO Budget (Year, Category, Region, Amount) VALUES (2020, 'Education', 'North', 1500000.00), (2020, 'Education', 'South', 1750000.00), (2020, 'Education', 'East', 1800000.00), (2020, 'Education', 'West', 1600000.00);
|
What was the total budget allocated to education in 2020, for all regions?
|
SELECT SUM(Amount) FROM Budget WHERE Year = 2020 AND Category = 'Education';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_exploration ( id INT, mission_name VARCHAR(255), country VARCHAR(255), success BOOLEAN );
|
How many space missions have been attempted by China?
|
SELECT COUNT(*) FROM space_exploration WHERE country = 'China';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, date DATE); INSERT INTO virtual_tours (tour_id, hotel_id, date) VALUES (6, 7, '2022-03-02'), (7, 7, '2022-03-05'), (8, 8, '2022-03-03'); CREATE TABLE hotels (hotel_id INT, region VARCHAR(50)); INSERT INTO hotels (hotel_id, region) VALUES (7, 'Asia'), (8, 'Europe'); CREATE TABLE dates (date DATE); INSERT INTO dates (date) VALUES ('2022-03-01'), ('2022-03-02'), ('2022-03-03'), ('2022-03-04'), ('2022-03-05'), ('2022-03-06'), ('2022-03-07');
|
How many virtual tours were conducted in 'Asian' hotels in the past week?
|
SELECT COUNT(*) FROM virtual_tours JOIN hotels ON virtual_tours.hotel_id = hotels.hotel_id JOIN dates ON virtual_tours.date = dates.date WHERE hotels.region = 'Asia' AND dates.date >= DATEADD(day, -7, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (ProjectID int, Name varchar(50), StartDate date, EndDate date, Budget int); INSERT INTO Projects (ProjectID, Name, StartDate, EndDate, Budget) VALUES (1, 'Renovation of Park', '2021-01-15', '2021-04-30', 25000); INSERT INTO Projects (ProjectID, Name, StartDate, EndDate, Budget) VALUES (2, 'New Library Building', '2021-07-01', '2022-03-31', 50000); INSERT INTO Projects (ProjectID, Name, StartDate, EndDate, Budget) VALUES (3, 'School Expansion', '2022-05-01', '2023-01-31', 40000);
|
List the names and start dates of all construction projects that have a budget greater than the average budget for all construction projects.
|
SELECT Name, StartDate FROM Projects WHERE Budget > (SELECT AVG(Budget) FROM Projects);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, country VARCHAR(50), waste_amount FLOAT, year INT); INSERT INTO waste_generation (id, country, waste_amount, year) VALUES (1, 'USA', 1500.5, 2020), (2, 'Canada', 850.2, 2020), (3, 'Mexico', 700.3, 2020);
|
What is the total waste generation per capita by country in 2020, ordered by the highest amount?
|
SELECT country, SUM(waste_amount) / (SELECT SUM(population) FROM populations WHERE populations.year = 2020) as per_capita FROM waste_generation WHERE year = 2020 GROUP BY country ORDER BY per_capita DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE population_stats (id INT, country VARCHAR(50), total_population INT, year INT); INSERT INTO population_stats (id, country, total_population, year) VALUES (1, 'Nigeria', 206000000, 2021); INSERT INTO population_stats (id, country, total_population, year) VALUES (2, 'Pakistan', 220892340, 2021); INSERT INTO population_stats (id, country, total_population, year) VALUES (3, 'Indonesia', 273523615, 2021);
|
What is the name of the country with the lowest total population in the year 2021?
|
SELECT country FROM population_stats WHERE year = 2021 ORDER BY total_population LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PeacekeepingOperations (year INT, location VARCHAR(255), led_by VARCHAR(255)); INSERT INTO PeacekeepingOperations (year, location, led_by) VALUES (2015, 'Middle East', 'United Nations'); INSERT INTO PeacekeepingOperations (year, location, led_by) VALUES (2016, 'Middle East', 'European Union'); INSERT INTO PeacekeepingOperations (year, location, led_by) VALUES (2017, 'Middle East', 'United States');
|
How many peacekeeping operations were conducted in the Middle East in each year since 2015, excluding those led by the United Nations?
|
SELECT year, COUNT(*) FROM PeacekeepingOperations WHERE location = 'Middle East' AND led_by != 'United Nations' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biosensor_patents (id INT, country VARCHAR(50), num_patents INT); INSERT INTO biosensor_patents (id, country, num_patents) VALUES (1, 'USA', 500); INSERT INTO biosensor_patents (id, country, num_patents) VALUES (2, 'Germany', 350); INSERT INTO biosensor_patents (id, country, num_patents) VALUES (3, 'Japan', 400); INSERT INTO biosensor_patents (id, country, num_patents) VALUES (4, 'China', 200);
|
List the top 3 countries with the most biosensor technology patents.
|
SELECT country, SUM(num_patents) FROM biosensor_patents GROUP BY country ORDER BY SUM(num_patents) DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_compliant_finance (account_id INT, account_holder VARCHAR(30), transaction_value DECIMAL(10,2), transaction_date DATE); INSERT INTO shariah_compliant_finance (account_id, account_holder, transaction_value, transaction_date) VALUES (1, 'Ahmed', 2000, '2022-01-01'), (2, 'Fatima', 1500, '2022-01-05'), (3, 'Hassan', 2500, '2022-01-10'), (4, 'Aisha', 1000, '2022-01-15'), (5, 'Zayn', 3000, '2022-01-20');
|
Find the top 3 contributors to Shariah-compliant finance by total transaction value in descending order.
|
SELECT account_id, account_holder, SUM(transaction_value) OVER (PARTITION BY account_id ORDER BY SUM(transaction_value) DESC) as total FROM shariah_compliant_finance LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE UserGameStats (UserID int, GameID int, Region varchar(50)); INSERT INTO UserGameStats (UserID, GameID, Region) VALUES (1, 101, 'North America'), (2, 101, 'Europe'), (3, 102, 'Asia'), (4, 102, 'North America'), (5, 103, 'South America');
|
How many games have been played by users from the "North America" region?
|
SELECT COUNT(*) FROM UserGameStats WHERE Region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu_Items_Without_Sales (MenuItemID INT, MenuItemName VARCHAR(255)); INSERT INTO Menu_Items_Without_Sales VALUES (1,'Burger'),(2,'Pizza'),(3,'Pasta'),(4,'Salad'),(5,'Tacos');
|
List the menu items that have not been sold in any restaurant.
|
SELECT Menu_Items_Without_Sales.MenuItemName FROM Menu_Items_Without_Sales WHERE Menu_Items_Without_Sales.MenuItemID NOT IN (SELECT Sales.MenuItemID FROM Sales);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_grants (student_id INT, grant_date DATE, grant_amount FLOAT); INSERT INTO research_grants (student_id, grant_date, grant_amount) VALUES (1, '2020-01-01', 15000), (2, '2019-08-15', 20000), (3, '2020-12-31', 12000);
|
Find the number of graduate students who received research grants in the last 2 years from the 'research_grants' table
|
SELECT COUNT(*) FROM research_grants WHERE grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE website_visitors (id INT, visit_date DATE, country VARCHAR(50)); INSERT INTO website_visitors (id, visit_date, country) VALUES (1, '2022-01-01', 'USA'), (2, '2022-01-02', 'Canada'), (3, '2022-01-03', 'France'), (4, '2022-01-04', 'USA'), (5, '2022-02-01', 'Germany');
|
What is the count of unique visitors to the website from Europe in the last month?
|
SELECT COUNT(DISTINCT id) FROM website_visitors WHERE country IN ('France', 'Germany', 'Italy', 'Spain', 'UK') AND visit_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (title VARCHAR(255), author_name VARCHAR(255), author_underrepresented BOOLEAN);
|
What is the percentage of articles published by underrepresented authors in the 'articles' table?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM articles)) AS percentage FROM articles WHERE author_underrepresented = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sensors (id INT, location VARCHAR(255), precipitation INT, reading_date DATE); INSERT INTO sensors (id, location, precipitation, reading_date) VALUES (1, 'Field1', 12, '2021-06-01'); INSERT INTO sensors (id, location, precipitation, reading_date) VALUES (2, 'Field2', 0, '2021-06-15');
|
How many times were precipitation readings taken in 'Summer'?
|
SELECT COUNT(*) FROM sensors WHERE reading_date BETWEEN (SELECT MIN(reading_date) FROM sensors WHERE EXTRACT(MONTH FROM reading_date) IN (6,7,8)) AND (SELECT MAX(reading_date) FROM sensors WHERE EXTRACT(MONTH FROM reading_date) IN (6,7,8))
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50)); INSERT INTO animal_population (animal_id, animal_name, program) VALUES (1, 'Grizzly Bear', 'habitat_preservation'), (2, 'Gray Wolf', 'community_education'), (3, 'Bald Eagle', 'habitat_preservation'), (4, 'Red Fox', 'community_education');
|
List all animals and their programs
|
SELECT animal_name, program FROM animal_population;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sectors (sector_id INT, sector_name VARCHAR(20)); CREATE TABLE companies (company_id INT, company_name VARCHAR(30), sector_id INT, esg_rating FLOAT);
|
How many companies have an ESG rating greater than 7 in the 'finance' sector?
|
SELECT COUNT(*) FROM companies c INNER JOIN sectors s ON c.sector_id = s.sector_id WHERE s.sector_name = 'finance' AND c.esg_rating > 7;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Studios (id INT, studio_name VARCHAR(100), location VARCHAR(50)); CREATE TABLE Movies (id INT, title VARCHAR(100), studio_id INT, release_year INT); INSERT INTO Studios (id, studio_name, location) VALUES (1, 'Studio1', 'Japan'), (2, 'Studio2', 'USA'); INSERT INTO Movies (id, title, studio_id, release_year) VALUES (1, 'Movie1', 1, 2015), (2, 'Movie2', 1, 2014), (3, 'Movie3', 2, 2017);
|
How many movies were released by each studio in Japan in 2015?
|
SELECT studio_id, COUNT(*) as num_movies FROM Movies WHERE release_year = 2015 GROUP BY studio_id HAVING studio_id IN (SELECT id FROM Studios WHERE location = 'Japan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (project_id INT, city TEXT, schema_name TEXT); INSERT INTO projects (project_id, city, schema_name) VALUES (1, 'New York', 'smart_cities'), (2, 'Los Angeles', 'smart_cities'), (3, 'Chicago', 'smart_cities'), (4, 'Houston', 'smart_cities'); CREATE TABLE green_projects (project_id INT, project_type TEXT); INSERT INTO green_projects (project_id, project_type) VALUES (1, 'green building'), (2, 'renewable energy'), (3, 'smart city'), (4, 'carbon offset');
|
How many green building projects are there in each city in the 'smart_cities' schema?
|
SELECT city, COUNT(DISTINCT project_id) FROM projects JOIN green_projects ON projects.project_id = green_projects.project_id WHERE schema_name = 'smart_cities' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (id INT, program VARCHAR(50), country VARCHAR(50), contributor VARCHAR(50), amount INT); INSERT INTO funding (id, program, country, contributor, amount) VALUES (1, 'African Art Program', 'USA', 'Foundation A', 25000), (2, 'African Art Program', 'USA', 'Foundation B', 30000), (3, 'African Art Program', 'USA', 'Foundation C', 35000);
|
Who are the top 3 contributors to African art programs in the US?
|
SELECT contributor, SUM(amount) AS total_amount FROM funding WHERE program = 'African Art Program' AND country = 'USA' GROUP BY contributor ORDER BY total_amount DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policy_info (policy_id INT, premium FLOAT, sum_insured INT); INSERT INTO policy_info (policy_id, premium, sum_insured) VALUES (1, 1200.50, 60000), (2, 2500.00, 70000), (3, 1800.00, 90000), (4, 1500.00, 40000), (5, 1700.00, 50000);
|
Display policy_id and sum_insured for policies with premium less than 2000 and sum insured less than 80000
|
SELECT policy_id, sum_insured FROM policy_info WHERE premium < 2000 AND sum_insured < 80000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE explainable_ai_algorithms (algorithm_id INT, algorithm_name TEXT, publication_date DATE); INSERT INTO explainable_ai_algorithms (algorithm_id, algorithm_name, publication_date) VALUES (1, 'AI Transparency', '2020-03-15'), (2, 'Explainable Deep Learning', '2019-12-21'), (3, 'Interpretable AI', '2020-08-01'); CREATE TABLE publications (publication_id INT, publication_date DATE, publication_country TEXT); INSERT INTO publications (publication_id, publication_date, publication_country) VALUES (101, '2020-01-01', 'USA'), (102, '2019-12-21', 'Canada'), (103, '2020-08-01', 'UK');
|
How many explainable AI algorithms were published by each country in 2020?
|
SELECT eaa.publication_country, COUNT(*) as num_algorithms FROM explainable_ai_algorithms eaa JOIN publications p ON eaa.publication_date = p.publication_date GROUP BY eaa.publication_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, RecurringDonor BOOLEAN); INSERT INTO Donors (DonorID, DonorName, Country, RecurringDonor) VALUES (1, 'John Doe', 'Australia', TRUE), (2, 'Jane Smith', 'Canada', FALSE);
|
What is the average donation amount for recurring donors from Australia?
|
SELECT AVG(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'Australia' AND Donors.RecurringDonor = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wildlife (id INT, name VARCHAR(255), carbon_sequestration FLOAT); INSERT INTO wildlife (id, name, carbon_sequestration) VALUES (1, 'Wildlife1', 123.45); INSERT INTO wildlife (id, name, carbon_sequestration) VALUES (2, 'Wildlife2', 234.56); CREATE TABLE species (id INT, name VARCHAR(255), wildlife_id INT); INSERT INTO species (id, name, wildlife_id) VALUES (1, 'Species1', 1); INSERT INTO species (id, name, wildlife_id) VALUES (2, 'Species2', 2);
|
What is the minimum carbon sequestration value for each wildlife species?
|
SELECT s.name, MIN(w.carbon_sequestration) FROM wildlife w JOIN species s ON w.id = s.wildlife_id GROUP BY s.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityDevelopment (id INT, initiative_name TEXT, location TEXT, start_date DATE, end_date DATE); INSERT INTO CommunityDevelopment (id, initiative_name, location, start_date, end_date) VALUES (1, 'Road Construction South Asia', 'South Asia', '2015-01-01', '2017-12-31'); INSERT INTO CommunityDevelopment (id, initiative_name, location, start_date, end_date) VALUES (2, 'Bridge Building South Asia', 'South Asia', '2016-04-01', '2018-06-30');
|
How many community development initiatives have been completed in South Asia since 2015?
|
SELECT COUNT(*) FROM CommunityDevelopment WHERE location LIKE '%South Asia%' AND end_date >= '2015-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CompanyLeadership (id INT, company_id INT, gender TEXT, is_leadership BOOLEAN); INSERT INTO CompanyLeadership (id, company_id, gender, is_leadership) VALUES (1, 1, 'female', true), (2, 1, 'male', false), (3, 2, 'female', true), (4, 2, 'male', true), (5, 3, 'non-binary', false), (6, 3, 'female', true); CREATE TABLE Companies (id INT, name TEXT, has_tech_social_good BOOLEAN); INSERT INTO Companies (id, name, has_tech_social_good) VALUES (1, 'TechCo', true), (2, 'GreenTech', true), (3, 'EthicalLabs', false);
|
What is the percentage of women in leadership roles in companies that have implemented technology for social good?
|
SELECT AVG(CASE WHEN is_leadership THEN 1.0 ELSE 0.0 END) * 100.0 FROM CompanyLeadership cl INNER JOIN Companies c ON cl.company_id = c.id WHERE c.has_tech_social_good = true AND gender = 'female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, rating FLOAT); INSERT INTO products (product_id, rating) VALUES (1, 4.5), (2, 3.2), (3, 4.8);
|
Increase the rating of product 3 by 0.5.
|
UPDATE products SET rating = rating + 0.5 WHERE product_id = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LipstickSales (sale_id INT, product_name VARCHAR(100), category VARCHAR(50), price DECIMAL(10,2), quantity INT, sale_date DATE, country VARCHAR(50), vegan BOOLEAN);
|
Insert a new record of a sale of a vegan lipstick in the USA.
|
INSERT INTO LipstickSales (sale_id, product_name, category, price, quantity, sale_date, country, vegan) VALUES (1, 'Vegan Lipstick', 'Lipstick', 12.99, 10, '2021-12-25', 'USA', TRUE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_schools (id INT, name TEXT, location TEXT, num_students INT, avg_teacher_age FLOAT); INSERT INTO public_schools (id, name, location, num_students, avg_teacher_age) VALUES (1, 'School 1', 'Chicago', 500, 44.3);
|
Update the average teacher age for a school in Chicago to 46.5.
|
UPDATE public_schools SET avg_teacher_age = 46.5 WHERE name = 'School 1' AND location = 'Chicago';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_access (id INT, name TEXT, insurance TEXT, state TEXT); INSERT INTO healthcare_access (id, name, insurance, state) VALUES (1, 'John Doe', 'Medicaid', 'Texas'); INSERT INTO healthcare_access (id, name, insurance, state) VALUES (2, 'Jane Smith', 'Uninsured', 'Texas');
|
What is the percentage of uninsured individuals in Texas?
|
SELECT (COUNT(*) FILTER (WHERE insurance IS NULL)) * 100.0 / COUNT(*) FROM healthcare_access WHERE state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Orders (id INT, order_channel VARCHAR(50), price DECIMAL(10,2)); CREATE VIEW Online_Orders AS SELECT price FROM Orders WHERE order_channel = 'online';
|
What is the total revenue generated from online orders?
|
SELECT SUM(price) FROM Online_Orders;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brand_sustainability (id INT PRIMARY KEY, brand VARCHAR(255), sustainability_rating INT); INSERT INTO brand_sustainability (id, brand, sustainability_rating) VALUES (1, 'Brand X', 91), (2, 'Brand Y', 89), (3, 'Brand Z', 95); CREATE TABLE cosmetics (id INT PRIMARY KEY, brand VARCHAR(255), rating INT); INSERT INTO cosmetics (id, brand, rating) VALUES (1, 'Brand X', 4), (2, 'Brand X', 5), (3, 'Brand Y', 3), (4, 'Brand Z', 5), (5, 'Brand Z', 5);
|
What is the average rating of cosmetics produced by brands with a sustainability rating above 90?
|
SELECT AVG(c.rating) FROM cosmetics c INNER JOIN brand_sustainability bs ON c.brand = bs.brand WHERE bs.sustainability_rating > 90;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lifelong_learning_events (id INT, name VARCHAR(255), date DATE); INSERT INTO lifelong_learning_events (id, name, date) VALUES (1, 'Python Programming Workshop', '2023-06-01');
|
List the names and dates of all lifelong learning events taking place in 2023.
|
SELECT name, date FROM lifelong_learning_events WHERE date >= '2023-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_preferences (product_id INT, consumer_age INT, preference_score FLOAT); CREATE TABLE product_catalog (product_id INT, product_name VARCHAR(255));
|
What are the top 3 preferred cosmetic products among consumers in a specific age group?
|
SELECT pc.product_name, preference_score FROM consumer_preferences cp JOIN product_catalog pc ON cp.product_id = pc.product_id WHERE consumer_age BETWEEN 25 AND 34 ORDER BY preference_score DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE basketball_sales(game_name TEXT, tickets_sold INT); INSERT INTO basketball_sales(game_name, tickets_sold) VALUES ('Game A', 500), ('Game B', 600), ('Game C', 700); CREATE TABLE football_sales(game_name TEXT, tickets_sold INT); INSERT INTO football_sales(game_name, tickets_sold) VALUES ('Game D', 800), ('Game E', 900), ('Game F', 1000);
|
List the names and ticket sales for the top 3 games with the highest ticket sales across all sports.
|
(SELECT game_name, tickets_sold FROM basketball_sales) UNION ALL (SELECT game_name, tickets_sold FROM football_sales) ORDER BY tickets_sold DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_awareness (date DATE, awareness INT); INSERT INTO consumer_awareness (date, awareness) VALUES ('2022-01-01', 75), ('2022-02-01', 78), ('2022-03-01', 82), ('2022-04-01', 80), ('2022-05-01', 85), ('2022-06-01', 88);
|
Identify the consumer awareness trend for ethical fashion in the last 6 months.
|
SELECT date, awareness, LAG(awareness, 2) OVER (ORDER BY date) as lagged_awareness FROM consumer_awareness;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, make VARCHAR(255), model VARCHAR(255), year INT, city VARCHAR(255));
|
Find the number of autonomous shuttles in each city
|
CREATE VIEW autonmous_shuttles AS SELECT city, COUNT(*) as num_shuttles FROM autonomous_vehicles WHERE make = 'Wayve' AND model = 'Kamino' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bridges_aus (country VARCHAR(50), name VARCHAR(50), length INT); INSERT INTO bridges_aus (country, name, length) VALUES ('Australia', 'Sydney Harbour Bridge', 1341), ('Australia', 'Great Barrier Reef Marine Park (GBRMP) Bridge', 2300);
|
Identify the bridges in Australia longer than 2000 meters not including the Sydney Harbour Bridge.
|
SELECT name FROM bridges_aus WHERE country = 'Australia' AND length > 2000 AND name != 'Sydney Harbour Bridge';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_divide_2 (project_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO digital_divide_2 (project_id, region, budget) VALUES (1, 'Asia', 40000.00), (2, 'Europe', 50000.00), (3, 'Asia', 35000.00), (4, 'Africa', 60000.00), (5, 'North America', 55000.00);
|
What is the maximum budget allocated for digital divide projects in all continents?
|
SELECT MAX(budget) FROM digital_divide_2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equity_metrics_by_state (state VARCHAR(2), score INT); INSERT INTO equity_metrics_by_state (state, score) VALUES ('CA', 70), ('NY', 65), ('TX', 80);
|
What is the maximum and minimum health equity metric score by state?
|
SELECT state, MAX(score), MIN(score) FROM equity_metrics_by_state GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fair_trade_manufacturers (id INT, country VARCHAR(255), manufacturer VARCHAR(255)); INSERT INTO fair_trade_manufacturers VALUES (1, 'Kenya', 'Manufacturer A'), (2, 'Ghana', 'Manufacturer B'), (3, 'Kenya', 'Manufacturer C'), (4, 'Ethiopia', 'Manufacturer D');
|
What is the average number of fair trade certified manufacturers in Africa per country?
|
SELECT country, AVG(number_of_manufacturers) FROM (SELECT country, COUNT(DISTINCT manufacturer) as number_of_manufacturers FROM fair_trade_manufacturers GROUP BY country) as subquery GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT, name TEXT, location TEXT, project_type TEXT, energy_consumption FLOAT); INSERT INTO project (id, name, location, project_type, energy_consumption) VALUES (1, 'Wind Farm', 'North America', 'Wind', 2.5);
|
Which renewable energy projects in North America have the lowest energy consumption?
|
SELECT name, energy_consumption FROM project WHERE location = 'North America' ORDER BY energy_consumption ASC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_violations (employee_id INT, department VARCHAR(255), violation_count INT); INSERT INTO safety_violations (employee_id, department, violation_count) VALUES (1, 'Production', 2), (2, 'Production', 0), (3, 'Engineering', 1), (4, 'Engineering', 3);
|
What is the maximum safety violation count for each employee?
|
SELECT employee_id, department, MAX(violation_count) OVER (PARTITION BY employee_id) AS max_violations_per_employee FROM safety_violations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete_wellbeing (athlete_id INT, team_id INT, athlete_name VARCHAR(255), nationality VARCHAR(255), score INT); INSERT INTO athlete_wellbeing (athlete_id, team_id, athlete_name, nationality, score) VALUES (1, 1, 'AthleteA', 'USA', 8), (2, 1, 'AthleteB', 'Canada', 9), (3, 2, 'AthleteC', 'Brazil', 7), (4, 2, 'AthleteD', 'India', 6);
|
What is the average wellbeing score for each athlete's nationality?
|
SELECT nationality, AVG(score) as avg_score FROM athlete_wellbeing GROUP BY nationality;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellites (id INT, name VARCHAR(50), launch_date DATE, agency VARCHAR(50)); INSERT INTO Satellites (id, name, launch_date, agency) VALUES (1, 'Sat1', '2000-01-01', 'SpaceAgency'), (2, 'Sat2', '1999-12-31', 'OtherAgency'), (3, 'Sat3', '2001-01-01', 'SpaceAgency');
|
What are the names and launch dates of satellites that were launched before any satellite launched by 'SpaceAgency'?
|
SELECT name, launch_date FROM Satellites WHERE launch_date < (SELECT MIN(launch_date) FROM Satellites WHERE agency = 'SpaceAgency');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HistoricalContext (ArtifactID INT, HistoricalContext TEXT); INSERT INTO HistoricalContext (ArtifactID, HistoricalContext) VALUES (6, 'Mesoamerican Civilization'), (7, 'Mesoamerican Civilization'), (8, 'Mesoamerican Civilization'), (9, 'Ancient Mexico');
|
What is the historical context of the artifacts from the 'Teotihuacan' excavation site?
|
SELECT hc.HistoricalContext FROM Artifacts a JOIN HistoricalContext hc ON a.ArtifactID = hc.ArtifactID WHERE a.SiteName = 'Teotihuacan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE desserts (id INT, item_name TEXT, sugar_content INT, country_origin TEXT); INSERT INTO desserts (id, item_name, sugar_content, country_origin) VALUES (1, 'Tiramisu', 25, 'Italy');
|
Find the maximum sugar content in desserts, grouped by country of origin.
|
SELECT country_origin, MAX(sugar_content) FROM desserts GROUP BY country_origin;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restorative_completions (completion_id INT, program_id INT, state VARCHAR(20), completions INT); INSERT INTO restorative_completions (completion_id, program_id, state, completions) VALUES (1, 1, 'New York', 35), (2, 2, 'California', 20), (3, 3, 'Texas', 21);
|
Identify the program with the lowest number of successful completions in California.
|
SELECT program_id, MIN(completions) FROM restorative_completions WHERE state = 'California' GROUP BY program_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Intel_Ops (ops_id INT, ops_name VARCHAR(50), ops_location VARCHAR(50), ops_year INT, ops_success BOOLEAN); INSERT INTO Intel_Ops (ops_id, ops_name, ops_location, ops_year, ops_success) VALUES (1, 'Operation Red Sparrow', 'Russia', 2020, true); INSERT INTO Intel_Ops (ops_id, ops_name, ops_location, ops_year, ops_success) VALUES (2, 'Operation Black Swan', 'Iran', 2019, false);
|
How many intelligence operations were conducted in '2018' according to the 'Intel_Ops' table?
|
SELECT COUNT(*) FROM Intel_Ops WHERE ops_year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rescue_center (id INT, animal_name VARCHAR(50), date_admitted DATE, region VARCHAR(20)); INSERT INTO rescue_center (id, animal_name, date_admitted, region) VALUES (1, 'Fox', '2021-01-05', 'Mountain'); INSERT INTO rescue_center (id, animal_name, date_admitted, region) VALUES (2, 'Eagle', '2021-06-10', 'Forest'); INSERT INTO rescue_center (id, animal_name, date_admitted, region) VALUES (3, 'Bear', '2021-07-15', 'Mountain');
|
Delete the record of the animal 'Bear' from the 'Rescue Center' table;
|
DELETE FROM rescue_center WHERE animal_name = 'Bear';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE finance (country VARCHAR(255), amount DECIMAL(10,2), year INT);
|
What is the total 'climate finance' committed by 'USA' in '2021' in the 'finance' table?
|
SELECT SUM(amount) FROM finance WHERE country = 'USA' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), population INT); INSERT INTO animals (id, name, population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 3000), (3, 'Giraffe', 1000), (4, 'Koala', 500);
|
Update the population of the animal Koala to 600 in the 'animals' table.
|
UPDATE animals SET population = 600 WHERE name = 'Koala';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_condition (condition_id INT, name VARCHAR(255)); INSERT INTO mental_health_condition (condition_id, name) VALUES (1, 'Anxiety Disorder'), (2, 'Depression'), (3, 'Bipolar Disorder'), (4, 'Post-Traumatic Stress Disorder'); CREATE TABLE therapy_session (session_id INT, patient_id INT, therapist_id INT, condition_id INT);
|
Who are the therapists who have conducted therapy sessions in the most number of unique mental health conditions?
|
SELECT therapist_id, COUNT(DISTINCT condition_id) AS unique_conditions FROM therapy_session GROUP BY therapist_id ORDER BY unique_conditions DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_depth (species_name VARCHAR(255), phylum VARCHAR(255), avg_depth FLOAT, ocean VARCHAR(255)); INSERT INTO marine_species_depth (species_name, phylum, avg_depth, ocean) VALUES ('Giant Squid', 'Cephalopoda', 2000, 'Pacific'), ('Blue Whale', 'Mammalia', 500, 'Pacific'), ('Anglerfish', 'Vertebrata', 1500, 'Pacific');
|
What is the average depth distribution of marine species in the Pacific Ocean, grouped by phylum?"
|
SELECT phylum, AVG(avg_depth) as avg_depth FROM marine_species_depth WHERE ocean = 'Pacific' GROUP BY phylum;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_revenue (product_id int, is_ethical boolean, revenue decimal, country varchar);
|
What is the difference in revenue between ethical and non-ethical products in each country?
|
SELECT country, (SUM(CASE WHEN is_ethical THEN revenue ELSE 0 END) - SUM(CASE WHEN NOT is_ethical THEN revenue ELSE 0 END)) AS revenue_difference FROM product_revenue GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, program_name VARCHAR(255), start_date DATE, end_date DATE);
|
Insert data into the new table for athlete wellbeing programs
|
INSERT INTO wellbeing_programs (program_id, athlete_id, program_name, start_date, end_date) VALUES (1, 1, 'Yoga', '2022-01-01', '2022-12-31'), (2, 2, 'Meditation', '2022-06-01', '2022-12-31'), (3, 3, 'Nutrition counseling', '2022-04-01', '2022-09-30');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sensors (id INT, sensor_id INT, crop VARCHAR(10)); INSERT INTO sensors (id, sensor_id, crop) VALUES (1, 101, 'corn'), (2, 102, 'soybean'), (3, 103, 'corn'), (4, 104, 'wheat'), (5, 105, 'sorghum');
|
List all unique crop types for the IoT sensors in the 'sensors' table?
|
SELECT DISTINCT crop FROM sensors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, sector VARCHAR(255), incident_date DATE); INSERT INTO security_incidents (id, sector, incident_date) VALUES (1, 'healthcare', '2021-01-01');
|
How many security incidents were there in the healthcare sector in the first half of this year?
|
SELECT COUNT(*) FROM security_incidents WHERE sector = 'healthcare' AND incident_date >= '2021-01-01' AND incident_date < '2021-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (menu_category VARCHAR(50), daily_revenue DECIMAL(10,2)); INSERT INTO restaurant_revenue (menu_category, daily_revenue) VALUES ('Appetizers', 500.00), ('Entrees', 2000.00), ('Desserts', 1000.00), ('Beverages', 1500.00);
|
What is the total revenue for each menu category, ordered by total revenue in descending order?
|
SELECT menu_category, SUM(daily_revenue) AS total_revenue FROM restaurant_revenue GROUP BY menu_category ORDER BY total_revenue DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (id INT, country VARCHAR(50), equipment_type VARCHAR(50), year INT, sales INT, price INT); INSERT INTO military_equipment (id, country, equipment_type, year, sales, price) VALUES (1, 'USA', 'Tanks', 2016, 1000000, 5000000), (2, 'USA', 'Aircraft', 2016, 2000000, 20000000), (3, 'China', 'Tanks', 2016, 800000, 3000000), (4, 'China', 'Aircraft', 2016, 1500000, 15000000), (5, 'USA', 'Tanks', 2017, 1200000, 5500000), (6, 'USA', 'Aircraft', 2017, 2200000, 22000000), (7, 'China', 'Tanks', 2017, 900000, 3500000), (8, 'China', 'Aircraft', 2017, 1600000, 16000000);
|
What is the average sales price for military equipment by country over the past 5 years?
|
SELECT country, equipment_type, AVG(price) as avg_price FROM military_equipment WHERE year >= 2016 GROUP BY country, equipment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessel (VesselID INT, VesselName VARCHAR(100), FuelType VARCHAR(100), FuelConsumption DECIMAL(5,2), OperationalDays INT); INSERT INTO Vessel (VesselID, VesselName, FuelType, FuelConsumption, OperationalDays) VALUES (1, 'Sealand Express', 'Diesel', 120.50, 25); INSERT INTO Vessel (VesselID, VesselName, FuelType, FuelConsumption, OperationalDays) VALUES (2, 'Cosco Hope', 'Fuel Oil', 150.25, 30);
|
What is the average fuel consumption rate per day for each vessel, ordered from highest to lowest?
|
SELECT VesselName, AVG(FuelConsumption/OperationalDays) OVER(PARTITION BY VesselName ORDER BY VesselName) AS AvgDailyFuelConsumption, ROW_NUMBER() OVER(ORDER BY AvgDailyFuelConsumption DESC) as Rank FROM Vessel
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Location TEXT, Expenses DECIMAL(10,2), Impact INT, Continent TEXT); INSERT INTO Programs (ProgramID, ProgramName, Location, Expenses, Impact, Continent) VALUES (1, 'Empowerment', 'Kenya', 12000.00, 35, 'Africa'), (2, 'Education', 'Brazil', 18000.00, 40, 'South America');
|
Calculate the average program impact and expenses per continent.
|
SELECT Continent, AVG(Expenses), AVG(Impact) FROM Programs GROUP BY Continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biomes (biome_id INT PRIMARY KEY, name VARCHAR(50), area_km2 FLOAT); INSERT INTO biomes (biome_id, name, area_km2) VALUES (1, 'Tropical Rainforest', 15000000.0), (2, 'Temperate Rainforest', 250000.0), (3, 'Boreal Forest', 12000000.0); CREATE TABLE trees (tree_id INT PRIMARY KEY, species VARCHAR(50), biome_id INT, family VARCHAR(50), volume FLOAT, FOREIGN KEY (biome_id) REFERENCES biomes(biome_id)); INSERT INTO trees (tree_id, species, biome_id, family, volume) VALUES (1, 'Quercus robur', 1, 'Fagaceae', 300.0), (2, 'Fagus sylvatica', 1, 'Fagaceae', 400.0), (3, 'Castanea sativa', 1, 'Fagaceae', 200.0);
|
What is the total volume of trees in the tropical rainforest that belong to the Fagaceae family?
|
SELECT SUM(trees.volume) FROM trees JOIN biomes ON trees.biome_id = biomes.biome_id WHERE trees.family = 'Fagaceae' AND biomes.name = 'Tropical Rainforest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_training (employee_name VARCHAR(255), training_topic VARCHAR(255), training_hours INT, training_completion_date DATE);
|
Create a table named 'diversity_training' with columns for employee_name, training_topic, training_hours, and training_completion_date
|
CREATE TABLE diversity_training (employee_name VARCHAR(255), training_topic VARCHAR(255), training_hours INT, training_completion_date DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversion (case_id INT, outcome VARCHAR(10), state VARCHAR(20)); INSERT INTO diversion (case_id, outcome, state) VALUES (1, 'Success', 'Washington'), (2, 'Failure', 'Washington');
|
What is the success rate of diversion programs for juveniles in Washington state?
|
SELECT (SUM(outcome = 'Success') / COUNT(*)) * 100 AS success_rate FROM diversion WHERE state = 'Washington';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biomes (biome_id INT PRIMARY KEY, name VARCHAR(50), area_km2 FLOAT); INSERT INTO biomes (biome_id, name, area_km2) VALUES (1, 'Tropical Rainforest', 15000000.0), (2, 'Temperate Rainforest', 250000.0), (3, 'Boreal Forest', 12000000.0); CREATE TABLE trees (tree_id INT PRIMARY KEY, species VARCHAR(50), biome_id INT, family VARCHAR(50), dbh FLOAT, FOREIGN KEY (biome_id) REFERENCES biomes(biome_id)); INSERT INTO trees (tree_id, species, biome_id, family, dbh) VALUES (1, 'Artocarpus heterophyllus', 1, 'Moraceae', 70.0), (2, 'Ficus benghalensis', 1, 'Moraceae', 90.0), (3, 'Broussonetia papyrifera', 1, 'Moraceae', 80.0);
|
What is the maximum DBH for trees in the tropical rainforest that belong to the Moraceae family?
|
SELECT MAX(dbh) FROM trees WHERE trees.family = 'Moraceae' AND biomes.name = 'Tropical Rainforest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE steps (id INT, user_id INT, date DATE, steps INT); INSERT INTO steps (id, user_id, date, steps) VALUES (1, 1, '2021-01-01', 5000); INSERT INTO steps (id, user_id, date, steps) VALUES (2, 2, '2021-01-01', 6000); INSERT INTO steps (id, user_id, date, steps) VALUES (3, 3, '2021-01-02', 4000); INSERT INTO steps (id, user_id, date, steps) VALUES (4, 1, '2021-01-02', 7000); INSERT INTO steps (id, user_id, date, steps) VALUES (5, 4, '2021-01-01', 8000);
|
What is the average number of steps taken per day by users from the USA?
|
SELECT AVG(steps / 1) as avg_steps_per_day FROM steps JOIN users ON steps.user_id = users.id WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.