context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Satellite_Manufacturers (Satellite_Manufacturer_ID INT, Manufacturer_ID INT, Country VARCHAR(50), FOREIGN KEY (Manufacturer_ID) REFERENCES Manufacturers(Manufacturer_ID)); INSERT INTO Satellite_Manufacturers (Satellite_Manufacturer_ID, Manufacturer_ID, Country) VALUES (1, 1, 'USA'); INSERT INTO Satellite_Manufacturers (Satellite_Manufacturer_ID, Manufacturer_ID, Country) VALUES (2, 2, 'Europe');
|
Which countries have manufactured aircraft, and how many satellites have been launched by each of those countries?
|
SELECT M.Country, COUNT(S.Satellite_ID) AS Total_Satellites_Launched FROM Satellite_Manufacturers M INNER JOIN Satellites S ON M.Manufacturer_ID = S.Manufacturer_ID GROUP BY M.Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE food_justice_scores (country VARCHAR(50), score FLOAT); INSERT INTO food_justice_scores (country, score) VALUES ('India', 63.5), ('China', 71.2), ('Indonesia', 58.7);
|
What is the minimum and maximum food justice score in Asia?
|
SELECT MIN(score), MAX(score) FROM food_justice_scores WHERE country IN ('India', 'China', 'Indonesia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE Tickets (id INT, visitor_id INT, exhibition_id INT);
|
Get the top 3 most visited exhibitions
|
SELECT Exhibitions.name, COUNT(Tickets.id) AS visits FROM Exhibitions JOIN Tickets ON Exhibitions.id = Tickets.exhibition_id GROUP BY Exhibitions.name ORDER BY visits DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transactions (UserID INT, TransactionID INT, TransactionTime DATETIME, Amount DECIMAL(10, 2));
|
Find the most recent transaction for each user in the 'Transactions' table.
|
SELECT UserID, MAX(TransactionTime) OVER (PARTITION BY UserID) as MaxTime FROM Transactions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy_projects (project_id INT, state VARCHAR(20), start_year INT, end_year INT, project_type VARCHAR(20));
|
How many renewable energy projects were initiated in New York between 2015 and 2020?
|
SELECT COUNT(project_id) FROM renewable_energy_projects WHERE state = 'New York' AND start_year BETWEEN 2015 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_personnel (id INT PRIMARY KEY, name VARCHAR(100), rank VARCHAR(50), age INT, status VARCHAR(50)); INSERT INTO military_personnel (id, name, rank, age, status) VALUES (1, 'John Doe', 'Colonel', 66, 'active');
|
Update military_personnel table, set status to 'retired' where age is greater than 65
|
UPDATE military_personnel SET status = 'retired' WHERE age > 65;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Song (SongID INT, Title VARCHAR(50), GenreID INT, Revenue INT);
|
What is the maximum revenue for a song in the Pop genre?
|
SELECT MAX(Song.Revenue) as MaxRevenue FROM Song WHERE Song.GenreID = (SELECT GenreID FROM Genre WHERE Name='Pop');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hiv_reports (id INT, disease VARCHAR(50), location VARCHAR(50), year INT, reported INT); INSERT INTO hiv_reports (id, disease, location, year, reported) VALUES (1, 'HIV', 'Florida', 2016, 4985), (2, 'HIV', 'Florida', 2015, 5151);
|
How many cases of HIV were reported in Florida in 2016?
|
SELECT reported FROM hiv_reports WHERE disease = 'HIV' AND location = 'Florida' AND year = 2016;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE disasters (id INT, country TEXT, type TEXT); INSERT INTO disasters (id, country, type) VALUES (1, 'Mexico', 'Earthquake'), (2, 'Brazil', 'Flood'), (3, 'Colombia', 'Volcano'); CREATE TABLE displaced_families (id INT, disaster INT, count INT); INSERT INTO displaced_families (id, disaster, count) VALUES (1, 1, 50), (2, 2, 75), (3, 1, 25);
|
What is the number of families displaced by natural disasters in each Latin American country?
|
SELECT d.country, SUM(df.count) as total_families FROM disasters d JOIN displaced_families df ON d.id = df.disaster GROUP BY d.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grants (id INT, title VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO grants (id, title, amount) VALUES (25, 'Sample Grant', 50000.00);
|
Delete the research grant with ID 25 from the grants table
|
DELETE FROM grants WHERE id = 25;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeritageSites (ID INT, SiteName VARCHAR(100), Region VARCHAR(50), YearAdded INT); INSERT INTO HeritageSites (ID, SiteName, Region, YearAdded) VALUES (1, 'Machu Picchu', 'South America', 2021); INSERT INTO HeritageSites (ID, SiteName, Region, YearAdded) VALUES (2, 'Taj Mahal', 'Asia', 2021);
|
How many heritage sites have been added in each region in the past year?
|
SELECT Region, YearAdded, COUNT(*) OVER (PARTITION BY YearAdded) AS SitesAddedInYear FROM HeritageSites;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (id INT, city VARCHAR(20), revenue FLOAT); INSERT INTO Exhibitions (id, city, revenue) VALUES (1, 'Paris', 50000), (2, 'London', 70000), (3, 'New York', 60000), (4, 'Berlin', 80000), (5, 'Rome', 90000);
|
Find the top 2 cities with the highest total revenue for exhibitions, and show the city name and the total revenue.
|
SELECT city, SUM(revenue) as total_revenue FROM Exhibitions GROUP BY city ORDER BY total_revenue DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Articles (id INT, title VARCHAR(255), publisher VARCHAR(100), publication_year INT, topic VARCHAR(50), comments INT); INSERT INTO Articles (id, title, publisher, publication_year, topic, comments) VALUES (1, 'Article1', 'The New York Times', 2021, 'Indigenous Rights', 50), (2, 'Article2', 'The Washington Post', 2020, 'Climate Change', 75), (3, 'Article3', 'National Geographic', 2021, 'Indigenous Rights', 35);
|
What is the average number of comments on articles about "Indigenous Rights" published in 2021?
|
SELECT AVG(comments) FROM Articles WHERE topic = 'Indigenous Rights' AND publication_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drivers (id INT PRIMARY KEY, name VARCHAR(50), license_type VARCHAR(20), car_make VARCHAR(20));
|
Add new record to 'drivers' with 'Provisional' license
|
INSERT INTO drivers (name, license_type, car_make) VALUES ('Jane Doe', 'Provisional', 'Nissan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Financial_Year (year INT, start_date DATE, end_date DATE); INSERT INTO Financial_Year (year, start_date, end_date) VALUES (2021, '2021-01-01', '2021-12-31'), (2022, '2022-01-01', '2022-12-31'); CREATE TABLE Orders (id INT, order_date DATE, order_value DECIMAL(5,2)); INSERT INTO Orders (id, order_date, order_value) VALUES (1, '2021-09-12', 50.00), (2, '2021-10-01', 75.00), (3, '2021-11-15', 100.00), (4, '2021-12-30', 120.00), (5, '2022-01-15', 150.00);
|
What is the total revenue generated from sales in the last financial year?
|
SELECT SUM(Orders.order_value) FROM Orders INNER JOIN Financial_Year ON Orders.order_date BETWEEN Financial_Year.start_date AND Financial_Year.end_date WHERE Financial_Year.year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_sources (id INT, state VARCHAR(50), year INT, renewable_energy FLOAT); INSERT INTO energy_sources (id, state, year, renewable_energy) VALUES (1, 'California', 2020, 33.0), (2, 'Texas', 2020, 20.0), (3, 'United States', 2020, 12.0);
|
What is the percentage of energy from renewable sources, per state, compared to the national average in 2020?
|
SELECT state, (renewable_energy / (SELECT AVG(renewable_energy) FROM energy_sources WHERE year = 2020) - 1) * 100.0 AS percentage FROM energy_sources WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE beaufort_forecasts (forecast_id INT, well_id INT, start_date DATE, end_date DATE, production_forecast FLOAT); INSERT INTO beaufort_forecasts (forecast_id, well_id, start_date, end_date, production_forecast) VALUES (9, 9, '2022-01-01', '2022-12-31', 700.0), (10, 9, '2023-01-01', '2023-12-31', 750.0), (11, 10, '2022-07-01', '2022-12-31', 800.0), (12, 10, '2023-01-01', '2023-12-31', 850.0);
|
Get the well ID, start month, and average production forecast for wells in the Beaufort Sea, ordered by the forecast start date.
|
SELECT well_id, EXTRACT(MONTH FROM start_date) as start_month, AVG(production_forecast) OVER (PARTITION BY well_id ORDER BY start_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as avg_forecast FROM beaufort_forecasts WHERE wells.location = 'Beaufort Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtSales (art_category VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO ArtSales (art_category, sale_date, revenue) VALUES ('Painting', '2022-01-02', 5000.00), ('Sculpture', '2022-01-03', 7000.00), ('Painting', '2022-03-05', 6000.00), ('Sculpture', '2022-02-10', 8000.00);
|
What is the total revenue generated by each art category in Q1 2022?
|
SELECT art_category, SUM(revenue) as Q1_Revenue FROM Artsales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY art_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, location VARCHAR(255));CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO Exhibitions (exhibition_id, location) VALUES (1, 'New York'), (2, 'Paris'), (3, 'New York'); INSERT INTO Visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 30), (2, 1, 45), (3, 2, 25), (4, 3, 18), (5, 3, 19);
|
What is the average number of visitors per exhibition in New York?
|
SELECT AVG(visitor_id) FROM Visitors JOIN Exhibitions ON Visitors.exhibition_id = Exhibitions.exhibition_id WHERE Exhibitions.location = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50)); CREATE TABLE Menu (MenuID int, ItemName varchar(50)); CREATE TABLE MenuSales (MenuID int, RestaurantID int, QuantitySold int, SaleDate date);
|
Which menu items were not sold at any restaurant in New York during the last week of March 2021?'
|
SELECT M.ItemName FROM Menu M LEFT JOIN MenuSales MS ON M.MenuID = MS.MenuID AND MS.RestaurantID IN (SELECT RestaurantID FROM Restaurants WHERE Name LIKE '%New York%') WHERE MS.QuantitySold IS NULL AND MS.SaleDate >= '2021-03-23' AND MS.SaleDate <= '2021-03-29';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE district_info (district_id INT, district_name VARCHAR(255), student_count INT); INSERT INTO district_info (district_id, district_name, student_count) VALUES (101, 'District A', 5000), (102, 'District B', 4000), (103, 'District C', 3000); CREATE TABLE student_mental_health (student_id INT, district_id INT, mental_health_score INT); INSERT INTO student_mental_health (student_id, district_id, mental_health_score) VALUES (1, 101, 75), (2, 101, 80), (3, 102, 60), (4, 102, 65), (5, 103, 85), (6, 103, 90);
|
What are the mental health scores of students in the district with the highest enrollment in lifelong learning programs?
|
SELECT s.student_id, s.district_id, s.mental_health_score FROM student_mental_health s JOIN (SELECT district_id FROM district_info ORDER BY student_count DESC LIMIT 1) d ON s.district_id = d.district_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name VARCHAR(255), category VARCHAR(255), budget FLOAT, year INT, status VARCHAR(255)); INSERT INTO projects (id, name, category, budget, year, status) VALUES (5, 'Highway Expansion', 'Transportation', 2500000.00, 2020, 'Completed');
|
What are the names and budgets of all projects in the 'Transportation' category that were completed in 2020 or earlier?
|
SELECT name, budget FROM projects WHERE category = 'Transportation' AND (year <= 2020 OR year IS NULL) AND status = 'Completed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE maintenance_requests (region TEXT, quarter NUMERIC, num_requests NUMERIC); INSERT INTO maintenance_requests (region, quarter, num_requests) VALUES ('Europe', 3, 80), ('Asia', 3, 90), ('Europe', 4, 85), ('Asia', 4, 95);
|
Compare military equipment maintenance requests in the European and Asian regions for Q3 2022
|
SELECT region, num_requests FROM maintenance_requests WHERE region IN ('Europe', 'Asia') AND quarter = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE judges (id INT, first_name VARCHAR(20), last_name VARCHAR(20), court_id INT); INSERT INTO judges (id, first_name, last_name, court_id) VALUES (1, 'Maria', 'Garcia', 1); INSERT INTO judges (id, first_name, last_name, court_id) VALUES (2, 'Juan', 'Rodriguez', 2); INSERT INTO judges (id, first_name, last_name, court_id) VALUES (3, 'Pedro', 'Martinez', 3);
|
Update the "judges" table to change the court id from 2 to 3 for the judge with id 2
|
UPDATE judges SET court_id = 3 WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE packages (id INT, type TEXT); INSERT INTO packages (id, type) VALUES (1, 'Box'), (2, 'Pallet'), (3, 'Envelope'); CREATE TABLE shipments (id INT, package_id INT, warehouse_id INT); INSERT INTO shipments (id, package_id, warehouse_id) VALUES (1, 1, 2), (2, 2, 2), (3, 3, 2), (4, 1, 1), (5, 3, 4); CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Warehouse A', 'EMEA'), (2, 'Warehouse B', 'Africa'), (3, 'Warehouse C', 'APAC'), (4, 'Warehouse D', 'AMER');
|
List all the unique package types shipped from 'Africa'
|
SELECT DISTINCT packages.type FROM packages JOIN shipments ON packages.id = shipments.package_id JOIN warehouses ON shipments.warehouse_id = warehouses.id WHERE warehouses.region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tugboats (id INT, name VARCHAR(50), year_built INT, status VARCHAR(10), PRIMARY KEY(id));
|
Update the 'status' column to 'inactive' for all tugboats in the 'tugboats' table that were built before 1990.
|
UPDATE tugboats SET status = 'inactive' WHERE year_built < 1990;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(255), initiative_type VARCHAR(255), start_date DATE);CREATE VIEW open_pedagogy_initiatives AS SELECT * FROM initiatives WHERE initiative_type = 'Open Pedagogy';
|
Show all open pedagogy initiatives for the past year
|
SELECT * FROM open_pedagogy_initiatives WHERE start_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africahotels (id INT, name VARCHAR(255), region VARCHAR(255), is_eco_friendly BOOLEAN, has_gym BOOLEAN, revenue FLOAT); INSERT INTO africahotels (id, name, region, is_eco_friendly, has_gym, revenue) VALUES (1, 'Eco Gym Hotel', 'Africa', 1, 1, 50000); INSERT INTO africahotels (id, name, region, is_eco_friendly, has_gym, revenue) VALUES (2, 'Non-Eco Gym Hotel', 'Africa', 0, 1, 40000);
|
Calculate the total revenue for the 'eco-friendly' and 'gym' hotels in the 'Africa' region.
|
SELECT SUM(revenue) FROM africahotels WHERE region = 'Africa' AND is_eco_friendly = 1 AND has_gym = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (artwork_id INT, artist_id INT, artwork_name TEXT, rating INT, num_reviews INT); INSERT INTO Artworks (artwork_id, artist_id, artwork_name, rating, num_reviews) VALUES (1, 101, 'Painting 1', 8, 30), (2, 101, 'Painting 2', 9, 50), (3, 102, 'Sculpture 1', 7, 25);
|
Show the average rating and total number of reviews for all artworks, and the number of artworks with a rating above 8.
|
SELECT AVG(a.rating) AS avg_rating, AVG(a.num_reviews) AS avg_reviews, COUNT(CASE WHEN a.rating > 8 THEN 1 ELSE NULL END) AS num_high_rating_artworks FROM Artworks a
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InclusivePolicies (id INT, city VARCHAR(20), year INT);
|
What is the average year of implementation of inclusive housing policies in the city of London?
|
SELECT AVG(year) FROM InclusivePolicies WHERE city = 'London';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment_types (id INT PRIMARY KEY, garment_type VARCHAR(50), production_count INT);
|
List all unique garment types with their corresponding production counts.
|
SELECT garment_type, COUNT(*) as production_count FROM garment_types GROUP BY garment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(255), sustainability_rating INT); INSERT INTO suppliers (supplier_id, supplier_name, sustainability_rating) VALUES (1, 'Supplier A', 5), (2, 'Supplier B', 3), (3, 'Supplier C', 5), (4, 'Supplier D', 2); CREATE TABLE manufacturing_process (process_id INT, process_name VARCHAR(255), supplier_id INT); INSERT INTO manufacturing_process (process_id, process_name, supplier_id) VALUES (1, 'Plastic Molding', 1), (2, 'Metal Stamping', 2), (3, 'Woodworking', 3), (4, 'Assembly', 4);
|
List the suppliers that have a sustainability rating of 5 for the company's manufacturing process.
|
SELECT supplier_name FROM suppliers s JOIN manufacturing_process mp ON s.supplier_id = mp.supplier_id WHERE s.sustainability_rating = 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, state VARCHAR(255)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, state) VALUES (1, 50.5, 'Texas'), (2, 60.3, 'Texas'), (3, 40.2, 'Texas'), (4, 25, 'Florida'), (5, 32, 'Florida'); CREATE TABLE states (state_id INT, state VARCHAR(255)); INSERT INTO states (state_id, state) VALUES (1, 'Texas'), (2, 'Florida'), (3, 'New Jersey');
|
What is the minimum data usage for mobile subscribers in each state?
|
SELECT MIN(ms.data_usage), s.state FROM mobile_subscribers ms JOIN states s ON ms.state = s.state GROUP BY s.state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_farms (id INT, name VARCHAR(50), location VARCHAR(50), installed_capacity FLOAT); INSERT INTO wind_farms (id, name, location, installed_capacity) VALUES (1, 'Wind Farm 1', 'Location A', 100.5), (2, 'Wind Farm 2', 'Location B', 150.2);
|
What is the total installed capacity of wind farms in the 'renewable_energy' schema?
|
SELECT SUM(installed_capacity) FROM wind_farms;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Budget (Year INT, Service TEXT, City TEXT, Budget FLOAT); INSERT INTO Budget (Year, Service, City, Budget) VALUES (2018, 'Waste Management', 'New York City', 20000000), (2019, 'Waste Management', 'New York City', 21000000), (2020, 'Waste Management', 'New York City', 22000000), (2021, 'Waste Management', 'New York City', 23000000), (2022, 'Waste Management', 'New York City', 24000000);
|
What was the total budget allocated for waste management services in New York City in the last 5 years?
|
SELECT SUM(Budget) as TotalBudget, City FROM Budget WHERE Service = 'Waste Management' AND City = 'New York City' AND Year >= (SELECT MAX(Year) - 5 FROM Budget) GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name VARCHAR(255), province VARCHAR(255), population INT); INSERT INTO cities (id, name, province, population) VALUES (1, 'City 1', 'Province A', 1200000); INSERT INTO cities (id, name, province, population) VALUES (2, 'City 2', 'Province B', 800000);
|
What is the total population of cities with a population greater than 1 million in Canada?
|
SELECT SUM(population) FROM cities WHERE province IN (SELECT province FROM cities WHERE population > 1000000 GROUP BY province HAVING COUNT(*) > 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (program_id INT, program_city VARCHAR(50), program_type VARCHAR(50), program_year INT, program_budget DECIMAL(10,2)); INSERT INTO Programs (program_id, program_city, program_type, program_year, program_budget) VALUES (1, 'Paris', 'Visual Art', 2018, 15000), (2, 'Berlin', 'Theater', 2019, 12000), (3, 'Paris', 'Visual Art', 2020, 18000), (4, 'Berlin', 'Visual Art', 2021, 14000), (5, 'Paris', 'Visual Art', 2019, 16000), (6, 'Berlin', 'Visual Art', 2020, 13000), (7, 'Paris', 'Visual Art', 2021, 15000);
|
What is the total number of visual art programs in Paris and Berlin from 2018 to 2021, excluding repeating programs?
|
SELECT program_city, COUNT(DISTINCT program_id) FROM Programs WHERE program_city IN ('Paris', 'Berlin') AND program_type = 'Visual Art' AND program_year BETWEEN 2018 AND 2021 GROUP BY program_city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary INT); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'HR', 50000), (2, 'Female', 'HR', 55000), (3, 'Male', 'IT', 60000), (4, 'Female', 'IT', 65000), (5, 'Male', 'Finance', 70000), (6, 'Female', 'Finance', 75000);
|
What is the average salary of male employees per department, sorted by the highest average salary?
|
SELECT Department, AVG(Salary) as Avg_Salary FROM Employees WHERE Gender = 'Male' GROUP BY Department ORDER BY Avg_Salary DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_sites (site_id INT, name TEXT, city TEXT, description TEXT); INSERT INTO cultural_sites (site_id, name, city, description) VALUES (1, 'Statue of Liberty', 'New York', 'Description available'), (2, 'Central Park', 'New York', NULL);
|
Delete the entry for the cultural heritage site in New York that has no description.
|
DELETE FROM cultural_sites WHERE site_id = 2 AND city = 'New York' AND description IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Country VARCHAR(50), Certification VARCHAR(50), Material VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Country, Certification, Material) VALUES (1, 'Supplier A', 'Vietnam', 'Fair Trade', 'Organic Cotton'), (2, 'Supplier B', 'Bangladesh', 'Fair Trade', 'Organic Cotton'), (3, 'Supplier C', 'Vietnam', 'Certified Organic', 'Organic Cotton'), (4, 'Supplier D', 'India', 'Fair Trade', 'Recycled Polyester'), (5, 'Supplier E', 'China', 'Certified Organic', 'Recycled Polyester'), (6, 'Supplier F', 'Indonesia', 'Fair Trade', 'Hemp'), (7, 'Supplier G', 'India', 'Certified Organic', 'Hemp');
|
Delete all suppliers from India who do not have a fair trade certification?
|
DELETE FROM Suppliers WHERE Country = 'India' AND Certification <> 'Fair Trade';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brazil_diplomacy (country VARCHAR(50), year INT, partner VARCHAR(50)); INSERT INTO brazil_diplomacy (country, year, partner) VALUES ('Brazil', 2020, 'Argentina'), ('Brazil', 2020, 'Chile'), ('Brazil', 2020, 'Colombia'), ('Brazil', 2020, 'Peru'), ('Brazil', 2020, 'Uruguay'), ('Brazil', 2020, 'Paraguay');
|
Who were the defense diplomacy partners of Brazil in 2020?
|
SELECT DISTINCT partner FROM brazil_diplomacy WHERE country = 'Brazil' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (product_id INT, category VARCHAR(50), is_cruelty_free BOOLEAN);
|
How many products in the skincare category are not cruelty-free?
|
SELECT COUNT(*) FROM Products WHERE category = 'Skincare' AND is_cruelty_free = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE strains (type VARCHAR(10), quantity INT); INSERT INTO strains (type, quantity) VALUES ('sativa', 10, 15), ('sativa', 12, 18), ('indica', 8, 12); CREATE TABLE dispensaries (state VARCHAR(20), sales INT); INSERT INTO dispensaries (state, sales) VALUES ('Nevada', 3200), ('Nevada', 3600); CREATE TABLE time_periods (quarter INT); INSERT INTO time_periods (quarter) VALUES (1);
|
Find the average quantity per transaction of sativa strains sold in Nevada dispensaries in Q1 2022.
|
SELECT AVG(strains.quantity) FROM strains JOIN dispensaries ON TRUE WHERE strains.type = 'sativa' AND dispensaries.state = 'Nevada' AND time_periods.quarter = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workplaces (id INT, country VARCHAR(50), num_employees INT, is_unionized BOOLEAN); INSERT INTO workplaces (id, country, num_employees, is_unionized) VALUES (1, 'Japan', 100, true), (2, 'Japan', 150, false), (3, 'Japan', 200, true);
|
What is the minimum number of employees in a unionized workplace in Japan?
|
SELECT MIN(num_employees) FROM workplaces WHERE country = 'Japan' AND is_unionized = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students (StudentID INT, Name VARCHAR(50), MentalHealthScore INT, GradeLevel INT); INSERT INTO Students (StudentID, Name, MentalHealthScore, GradeLevel) VALUES (6, 'Lucy Green', 86, 10); INSERT INTO Students (StudentID, Name, MentalHealthScore, GradeLevel) VALUES (7, 'Mason Blue', 90, 12);
|
What is the number of students in each grade level who have a mental health score greater than 85?
|
SELECT GradeLevel, COUNT(*) FROM Students WHERE MentalHealthScore > 85 GROUP BY GradeLevel;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (id INT, subscriber_type VARCHAR(10), country VARCHAR(20), data_usage INT); INSERT INTO subscribers (id, subscriber_type, country, data_usage) VALUES (1, 'Mobile', 'Canada', 2000), (2, 'Broadband', 'Canada', 3000), (3, 'Mobile', 'Mexico', 4000), (4, 'Mobile', 'Brazil', NULL), (5, 'Broadband', 'Brazil', 5000);
|
Find the total number of mobile and broadband subscribers in each country, excluding subscribers with no data usage.
|
SELECT country, SUM(CASE WHEN subscriber_type = 'Mobile' THEN 1 ELSE 0 END) as num_mobile_subscribers, SUM(CASE WHEN subscriber_type = 'Broadband' THEN 1 ELSE 0 END) as num_broadband_subscribers FROM subscribers WHERE data_usage IS NOT NULL GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Production (ProductionID INT, WellID INT, ProductionDate DATE, ProductionRate FLOAT, Country VARCHAR(50)); INSERT INTO Production (ProductionID, WellID, ProductionDate, ProductionRate, Country) VALUES (1, 1, '2022-01-01', 500, 'USA'), (2, 2, '2022-01-15', 600, 'Canada'), (3, 3, '2022-02-01', 700, 'Mexico');
|
What is the production rate trend for each well over time?
|
SELECT WellID, ProductionDate, ProductionRate, ROW_NUMBER() OVER (PARTITION BY WellID ORDER BY ProductionDate) AS RowNumber FROM Production;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diagnoses (id INT, patient_id INT, diagnosis VARCHAR(30), diagnosis_date DATE); INSERT INTO diagnoses (id, patient_id, diagnosis, diagnosis_date) VALUES (1, 1, 'anxiety', '2020-05-05'), (2, 2, 'depression', '2019-08-12'), (3, 3, 'anxiety', '2020-11-15');
|
How many patients were diagnosed with anxiety in 2020?
|
SELECT COUNT(*) FROM diagnoses WHERE diagnosis = 'anxiety' AND YEAR(diagnosis_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indigenous_communities (community VARCHAR(255), country VARCHAR(255), population INT);
|
Which indigenous community in Greenland has the largest population?
|
SELECT community, MAX(population) FROM indigenous_communities WHERE country = 'Greenland' GROUP BY community;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, donor_type VARCHAR(255), gender VARCHAR(10), recurring BOOLEAN); INSERT INTO donors (id, donor_type, gender, recurring) VALUES (1, 'Individual', 'Female', true), (2, 'Corporation', 'N/A', false); CREATE TABLE donations (id INT, donation_amount DECIMAL(10, 2), donation_date DATE, donor_id INT, nonprofit_focus VARCHAR(255), nonprofit_region VARCHAR(255)); INSERT INTO donations (id, donation_amount, donation_date, donor_id, nonprofit_focus, nonprofit_region) VALUES (1, 100, '2020-01-01', 1, 'Human Rights', 'Latin America'), (2, 200, '2020-02-01', 1, 'Human Rights', 'Latin America');
|
What was the average donation amount for recurring donors to human rights nonprofits in Latin America in 2020?
|
SELECT AVG(donation_amount) FROM donations d JOIN donors don ON d.donor_id = don.id WHERE don.recurring = true AND don.donor_type = 'Individual' AND d.nonprofit_focus = 'Human Rights' AND d.nonprofit_region = 'Latin America' AND EXTRACT(YEAR FROM donation_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_specialties_south_africa (name TEXT, location TEXT, specialty TEXT); INSERT INTO healthcare_specialties_south_africa (name, location, specialty) VALUES ('Provider A', 'Rural South Africa', 'Pediatric Care'), ('Provider B', 'Rural Kenya', 'Neurology');
|
Find the number of rural healthcare providers who are specialized in pediatric care in South Africa and Kenya.
|
SELECT location, COUNT(*) as provider_count FROM healthcare_specialties_south_africa WHERE location LIKE 'Rural%' AND specialty LIKE '%Pediatric%' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier_products (product_id INT, supplier_id INT); INSERT INTO supplier_products (product_id, supplier_id) VALUES (1, 100), (2, 101), (3, 100), (4, 102);
|
Find the total number of products for each supplier in the supplier_products table.
|
SELECT supplier_id, COUNT(*) FROM supplier_products GROUP BY supplier_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50), goals INT);
|
What is the average number of goals scored by players in each position?
|
SELECT position, AVG(goals) FROM players GROUP BY position;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plant_safety (plant_id INT, incident_date DATE, plant_location TEXT, incident_type TEXT, incident_rate FLOAT); INSERT INTO plant_safety (plant_id, incident_date, plant_location, incident_type, incident_rate) VALUES (1, '2021-01-15', 'Plant A', 'Chemical Spill', 0.01), (2, '2021-02-20', 'Plant B', 'Fire', 0.02), (3, '2021-03-05', 'Plant C', 'Equipment Failure', 0.03);
|
What is the maximum safety incident rate for each chemical plant in the past year, and the corresponding incident type?
|
SELECT plant_location, incident_type, MAX(incident_rate) AS max_rate FROM plant_safety WHERE incident_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY plant_location, incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE art_collection (museum VARCHAR(255), artist VARCHAR(255), art_type VARCHAR(255), year INT); INSERT INTO art_collection (museum, artist, art_type, year) VALUES ('Tate Modern', 'Pablo Picasso', 'Painting', 1937), ('Tate Modern', 'Vincent Van Gogh', 'Painting', 1888), ('Tate Modern', 'Andy Warhol', 'Print', 1962);
|
What is the number of visual artists in the art collection of the Tate Modern by art type?
|
SELECT art_type, COUNT(DISTINCT artist) FROM art_collection WHERE museum = 'Tate Modern' GROUP BY art_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forests (id INT, name VARCHAR(50), hectares DECIMAL(5,2), year_planted INT, PRIMARY KEY (id)); INSERT INTO forests (id, name, hectares, year_planted) VALUES (1, 'Forest A', 123.45, 1990), (2, 'Forest B', 654.32, 1985); CREATE TABLE wildlife (id INT, forest_id INT, species VARCHAR(50), population INT, PRIMARY KEY (id)); INSERT INTO wildlife (id, forest_id, species, population) VALUES (1, 1, 'Deer', 25), (2, 1, 'Bear', 10), (3, 2, 'Deer', 50), (4, 2, 'Moose', 30);
|
Identify the wildlife species present in a specific forest
|
SELECT DISTINCT w.species FROM wildlife w INNER JOIN forests f ON w.forest_id = f.id WHERE f.name = 'Forest A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO Warehouse (id, name, location) VALUES (1, 'Los Angeles', 'USA'); CREATE TABLE Shipment (id INT, warehouse_id INT, region VARCHAR(50), volume INT); INSERT INTO Shipment (id, warehouse_id, region, volume) VALUES (1, 1, 'Asia-Pacific', 100), (2, 1, 'Asia-Pacific', 150), (3, 1, 'Europe', 120);
|
What is the total volume of packages shipped to the Asia-Pacific region from our Los Angeles warehouse in the last quarter?
|
SELECT SUM(volume) FROM Shipment WHERE warehouse_id = (SELECT id FROM Warehouse WHERE location = 'Los Angeles') AND region = 'Asia-Pacific' AND shipment_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geographic_area (geographic_area VARCHAR(20)); INSERT INTO geographic_area (geographic_area) VALUES ('urban'), ('rural'); CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(50), geographic_area VARCHAR(20), has_compliance_issue INT); CREATE TABLE compliance_issues (issue_id INT, description VARCHAR(100)); INSERT INTO broadband_subscribers (subscriber_id, name, geographic_area, has_compliance_issue) VALUES (1, 'Jane Doe', 'urban', 1); INSERT INTO compliance_issues (issue_id, description) VALUES (1, 'Non-payment of annual fee');
|
List the broadband subscribers with compliance issues and the corresponding compliance issue description, along with the subscribers' geographic areas.
|
SELECT broadband_subscribers.name, geographic_area.geographic_area, compliance_issues.description FROM broadband_subscribers JOIN geographic_area ON broadband_subscribers.geographic_area = geographic_area.geographic_area JOIN compliance_issues ON broadband_subscribers.has_compliance_issue = compliance_issues.issue_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer (consumer_id INT, name TEXT); CREATE TABLE purchase (purchase_id INT, consumer_id INT, purchase_date DATE); INSERT INTO consumer VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); INSERT INTO purchase VALUES (1, 1, '2022-01-10'), (2, 2, '2022-01-15'), (3, 3, '2022-02-05');
|
How many consumers have made a purchase in the last month?
|
SELECT COUNT(DISTINCT consumer_id) FROM purchase WHERE purchase_date >= '2022-02-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE traffic_violations (id INT, city VARCHAR(20), ticket_issued INT); INSERT INTO traffic_violations (id, city, ticket_issued) VALUES (1, 'Tokyo', 120), (2, 'Tokyo', 150), (3, 'Osaka', 80);
|
What is the total number of traffic violation tickets issued in Tokyo?
|
SELECT COUNT(*) FROM traffic_violations WHERE city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50), Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Department, Position, Salary) VALUES (1, 'John Doe', 'IT', 'Developer', 75000.00), (2, 'Jane Smith', 'IT', 'Tester', 60000.00), (3, 'Alice Johnson', 'Marketing', 'Marketing Specialist', 60000.00), (4, 'Bob Brown', 'HR', 'HR Specialist', 65000.00);
|
What is the total salary cost for each position in the IT department?
|
SELECT Position, SUM(Salary) FROM Employees WHERE Department = 'IT' GROUP BY Position;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workplaces (id INT, city VARCHAR(10), safety_issues INT); INSERT INTO workplaces (id, city, safety_issues) VALUES (1, 'New York', 10), (2, 'Los Angeles', 5), (3, 'Houston', 15), (4, 'Miami', 8); CREATE TABLE cities (id INT, city VARCHAR(10)); INSERT INTO cities (id, city) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Houston'), (4, 'Miami');
|
What is the maximum number of safety issues in a workplace for each city?
|
SELECT w.city, MAX(w.safety_issues) OVER (PARTITION BY w.city) AS max_safety_issues FROM workplaces w INNER JOIN cities c ON w.city = c.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (product_id INT, product_name VARCHAR(20), launch_date DATE, environmental_impact_score DECIMAL(3,2));
|
What is the average environmental impact score of all products that were launched in the last year?
|
SELECT AVG(environmental_impact_score) FROM Products WHERE launch_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Producers (ProducerID INT PRIMARY KEY, Name TEXT, ProductionYear INT, RareEarth TEXT, Quantity INT);
|
Update the production quantity for all records of Erbium in 2020 to 125 units.
|
UPDATE Producers SET Quantity = 125 WHERE RareEarth = 'Erbium' AND ProductionYear = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_energy_efficiency (building_id INT, city VARCHAR(255), rating FLOAT); INSERT INTO building_energy_efficiency (building_id, city, rating) VALUES (1, 'City X', 80), (2, 'City X', 85), (3, 'City Y', 70), (4, 'City Y', 75);
|
What is the average energy efficiency rating for buildings in 'City X'?
|
SELECT AVG(rating) as avg_rating FROM building_energy_efficiency WHERE city = 'City X';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT); INSERT INTO factories (factory_id, name, location) VALUES (1, 'Factory A', 'Ohio'), (2, 'Factory B', 'Michigan'), (3, 'Factory C', 'California'); CREATE TABLE safety_protocols (protocol_id INT, factory_id INT, protocol TEXT); INSERT INTO safety_protocols (protocol_id, factory_id, protocol) VALUES (1, 1, 'Fire Safety'), (2, 1, 'Emergency Exits'), (3, 2, 'Fire Safety'), (4, 2, 'Chemical Spills'), (5, 3, 'Fire Safety'), (6, 3, 'Hurricane Preparedness');
|
List all the safety protocols for factories located in Ohio or Michigan?
|
SELECT s.protocol FROM factories f JOIN safety_protocols s ON f.factory_id = s.factory_id WHERE f.location IN ('Ohio', 'Michigan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DispensarySales (dispensary_id INT, strain VARCHAR(20), quantity INT); INSERT INTO DispensarySales (dispensary_id, strain, quantity) VALUES (1, 'Sour Diesel', 50), (1, 'Blue Dream', 75), (2, 'Green Crack', 60), (2, 'Jack Herer', 80); CREATE TABLE SanFranciscoDispensaries (dispensary_id INT, location VARCHAR(20)); INSERT INTO SanFranciscoDispensaries (dispensary_id, location) VALUES (1, 'San Francisco'); CREATE TABLE LosAngelesDispensaries (dispensary_id INT, location VARCHAR(20)); INSERT INTO LosAngelesDispensaries (dispensary_id, location) VALUES (2, 'Los Angeles');
|
What is the total quantity of hybrid strains sold by dispensaries in San Francisco and Los Angeles?
|
SELECT SUM(quantity) FROM DispensarySales ds JOIN SanFranciscoDispensaries sfd ON ds.dispensary_id = sfd.dispensary_id WHERE strain LIKE '%Hybrid%' UNION SELECT SUM(quantity) FROM DispensarySales ds JOIN LosAngelesDispensaries lad ON ds.dispensary_id = lad.dispensary_id WHERE strain LIKE '%Hybrid%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_demographics (id INT, category VARCHAR(50), sub_category VARCHAR(50)); INSERT INTO customer_demographics (id, category, sub_category) VALUES (1, 'Age', '18-24'), (2, 'Age', '25-34'); CREATE TABLE transactions (customer_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (customer_id, transaction_amount) VALUES (1, 200.00), (1, 300.00), (2, 100.00), (2, 400.00);
|
What is the total transaction amount by customer demographic category?
|
SELECT c.category, c.sub_category, SUM(t.transaction_amount) as total_transaction_amount FROM customer_demographics c JOIN transactions t ON 1=1 GROUP BY c.category, c.sub_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (property_id INT, price DECIMAL(10,2), size INT, city VARCHAR(50), num_owners INT); INSERT INTO properties (property_id, price, size, city, num_owners) VALUES (1, 500000, 2000, 'Oakland', 1), (2, 600000, 2500, 'San Francisco', 2), (3, 450000, 1000, 'Oakland', 1);
|
What's the average price of properties in each city, grouped by the number of owners?
|
SELECT city, num_owners, AVG(price) FROM properties GROUP BY city, num_owners;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_trend (menu_item VARCHAR(255), sales DECIMAL(10,2), date DATE); INSERT INTO sales_trend (menu_item, sales, date) VALUES ('Bruschetta', 200.00, '2022-01-01'), ('Bruschetta', 300.00, '2022-01-02'), ('Bruschetta', 400.00, '2022-01-03'), ('Bruschetta', 500.00, '2022-01-04'), ('Bruschetta', 600.00, '2022-01-05');
|
What is the daily sales trend for a specific menu item?
|
SELECT menu_item, date, sales, AVG(sales) OVER (PARTITION BY menu_item ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) as moving_average FROM sales_trend WHERE menu_item = 'Bruschetta' ORDER BY date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE svalbard_weather(year INT, temperature FLOAT);INSERT INTO svalbard_weather(year, temperature) VALUES (2000, 2.5), (2001, 3.2), (2002, 1.8);
|
What is the average temperature per year in Svalbard?
|
SELECT AVG(temperature) avg_temp, year FROM svalbard_weather GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VirtualTourCompanies (name VARCHAR(50), location VARCHAR(20), year INT, reviews INT, rating INT);
|
What is the total number of positive reviews received by virtual tour companies in Australia for the year 2022?
|
SELECT SUM(rating) FROM VirtualTourCompanies WHERE location = 'Australia' AND year = 2022 AND rating > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incident_categories (id INT, category VARCHAR(255), incident_count INT, incident_date DATE);
|
What is the percentage of security incidents in the 'Web Applications' category in the last month?
|
SELECT (SUM(CASE WHEN category = 'Web Applications' THEN incident_count ELSE 0 END) / SUM(incident_count)) * 100 as percentage FROM incident_categories WHERE incident_date >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, asset_type VARCHAR(255), discovered_time TIMESTAMP);
|
How many vulnerabilities were found in the 'network' asset type in the last quarter?
|
SELECT COUNT(*) as vulnerability_count FROM vulnerabilities WHERE asset_type = 'network' AND discovered_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, therapy TEXT, therapy_year INT); INSERT INTO patients (id, name, age, therapy, therapy_year) VALUES (1, 'Alice', 30, 'CBT', 2019), (2, 'Bob', 45, 'DBT', 2021), (3, 'Charlie', 60, 'CBT', 2018), (4, 'David', 50, 'CBT', 2017), (5, 'Eve', 55, 'DBT', 2021);
|
Delete the records of patients who received therapy in 2021
|
DELETE FROM patients WHERE therapy_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu (item VARCHAR(20), type VARCHAR(20), price DECIMAL(5,2), quantity INT);
|
Insert a new 'Sustainable Seafood' option in the 'Seafood' section with 'Grilled Sustainable Tuna' priced at $21.99 and quantity 15.
|
INSERT INTO Menu (item, type, price, quantity) VALUES ('Grilled Sustainable Tuna', 'Sustainable Seafood', 21.99, 15);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (id INT, name VARCHAR(50), age INT, participated_in_esports_event BOOLEAN); INSERT INTO Players (id, name, age, participated_in_esports_event) VALUES (1, 'Player1', 25, TRUE), (2, 'Player2', 30, FALSE), (3, 'Player3', 35, TRUE);
|
How many players have participated in esports events, and what is the average age of these players?
|
SELECT COUNT(*) AS num_players, AVG(age) AS avg_age FROM Players WHERE participated_in_esports_event = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Food (FoodID varchar(10), FoodName varchar(20), Price decimal(5,2)); INSERT INTO Food VALUES ('Y', 'Product Y', 5.00);
|
Update the price of product Y to $5.50.
|
UPDATE Food SET Price = 5.50 WHERE FoodID = 'Y';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accessible_tech (organization_name TEXT, country TEXT); INSERT INTO accessible_tech (organization_name, country) VALUES ('AccessibleTech', 'Canada'), ('EqualTech', 'United States'), ('InclusiveTech', 'United Kingdom'), ('AccessTech', 'Canada'), ('EqualAI', 'United States');
|
Which countries have the most organizations working on accessible technology?
|
SELECT country, COUNT(*) as organization_count FROM accessible_tech GROUP BY country ORDER BY organization_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name TEXT, industry TEXT, foundation_date DATE, founder_race TEXT, funding FLOAT); INSERT INTO startups(id, name, industry, foundation_date, founder_race, funding) VALUES (1, 'BioDiverse', 'Biotech', '2019-01-01', 'African American', 1000000);
|
What is the average funding amount for startups founded by people from underrepresented racial or ethnic backgrounds in the biotech sector?
|
SELECT AVG(funding) FROM startups WHERE industry = 'Biotech' AND founder_race IN ('African American', 'Hispanic', 'Native American', 'Pacific Islander');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, Country VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Age, Country) VALUES (1, 25, 'USA'), (2, 30, 'USA'), (3, 45, 'Canada'), (4, 50, 'Canada'), (5, 60, 'Mexico');
|
What is the policy count for policyholders in each age group, in 10-year intervals, for policyholders in each country?
|
SELECT Country, FLOOR(Age / 10) * 10 AS AgeGroup, COUNT(*) AS PolicyCount FROM Policyholders GROUP BY Country, AgeGroup;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (id INT, region VARCHAR(255), year INT, capacity INT); INSERT INTO landfill_capacity (id, region, year, capacity) VALUES (1, 'North America', 2019, 20000), (2, 'North America', 2020, 22000), (3, 'Europe', 2019, 18000), (4, 'Europe', 2020, 20000);
|
What is the change in landfill capacity for the North American region between 2019 and 2020?
|
SELECT region, (capacity - LAG(capacity) OVER (PARTITION BY region ORDER BY year)) AS change FROM landfill_capacity WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), launch_date DATE);CREATE TABLE Astronauts (id INT, name VARCHAR(255), gender VARCHAR(10), mission_id INT);
|
Find the number of space missions that were launched before 2010 and had at least one female astronaut.
|
SELECT COUNT(*) FROM SpaceMissions sm JOIN Astronauts a ON sm.id = a.mission_id WHERE launch_date < '2010-01-01' AND gender = 'female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE machines (machine_id INT, machine_name VARCHAR(50), manufacturer VARCHAR(50), production_year INT); INSERT INTO machines (machine_id, machine_name, manufacturer, production_year) VALUES (1, 'MachineA', 'ABC', 2020), (2, 'MachineB', 'XYZ', 2019), (3, 'MachineC', 'ABC', 2018), (4, 'MachineD', 'DEF', 2021);
|
What is the total number of machines produced by company 'ABC'?
|
SELECT COUNT(DISTINCT machine_id) FROM machines WHERE manufacturer = 'ABC';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Country varchar(50), Hours decimal(5,2)); INSERT INTO Volunteers (VolunteerID, Name, Country, Hours) VALUES (1, 'Aisha', 'Pakistan', 25.50), (2, 'Hiroshi', 'Japan', 35.25), (3, 'Marie', 'France', 50.00);
|
List the top 3 countries with the most volunteer hours in Q2 2022.
|
SELECT Country, SUM(Hours) as TotalHours FROM Volunteers WHERE QUARTER(VolunteerDate) = 2 GROUP BY Country ORDER BY TotalHours DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(255), age INT, team_id INT, FOREIGN KEY (team_id) REFERENCES teams(id)); INSERT INTO teams (id, name) VALUES (1, 'Lakers'); INSERT INTO teams (id, name) VALUES (2, 'Knicks'); INSERT INTO athletes (id, name, age, team_id) VALUES (1, 'John Doe', 25, 1); INSERT INTO athletes (id, name, age, team_id) VALUES (2, 'Jane Smith', 28, 1); INSERT INTO athletes (id, name, age, team_id) VALUES (3, 'Bob Johnson', 30, 2);
|
Create a view to show the total number of athletes per team
|
CREATE VIEW team_athlete_count AS SELECT teams.name, COUNT(athletes.id) FROM teams INNER JOIN athletes ON teams.id = athletes.team_id GROUP BY teams.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE publications (id INT, title TEXT, author VARCHAR(50), department VARCHAR(50)); INSERT INTO publications (id, title, author, department) VALUES (1, 'Theory of Algebraic Structures', 'Clara Mathematician', 'Mathematics'); INSERT INTO publications (id, title, author, department) VALUES (2, 'Calculus: A Complete Course', 'John Doe', 'Mathematics');
|
List the titles and authors of all publications in the Mathematics department that have at least one female author.
|
SELECT title, author FROM publications WHERE department = 'Mathematics' AND author IN (SELECT name FROM faculty WHERE gender = 'Female');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), Nationality VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Pablo Picasso', 'Spanish'); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (2, 'Salvador Dali', 'Spanish');
|
Which artists are from Spain?
|
SELECT Name FROM Artists WHERE Nationality = 'Spanish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AquaticWarriors.NavalSales (id INT, manufacturer VARCHAR(255), model VARCHAR(255), quantity INT, price DECIMAL(10,2), buyer_country VARCHAR(255), sale_date DATE);
|
What is the total number of naval vessels sold by AquaticWarriors to the Australian government?
|
SELECT SUM(quantity) FROM AquaticWarriors.NavalSales WHERE buyer_country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id int, product_name varchar(255), is_organic bool, revenue float); INSERT INTO products (product_id, product_name, is_organic, revenue) VALUES (1, 'Apples', true, 1000), (2, 'Bananas', false, 1500), (3, 'Carrots', true, 700);
|
What is the total revenue of organic products?
|
SELECT SUM(revenue) FROM products WHERE is_organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Salary INT); INSERT INTO Employees (EmployeeID, Gender, Salary) VALUES (1, 'Female', 65000); INSERT INTO Employees (EmployeeID, Gender, Salary) VALUES (2, 'Male', 70000);
|
What is the minimum salary for employees who identify as female?
|
SELECT MIN(Salary) FROM Employees WHERE Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Field1 (date DATE, temperature FLOAT, humidity FLOAT); INSERT INTO Field1 VALUES ('2021-06-01', 25, 60), ('2021-06-02', 22, 65); CREATE TABLE Field2 (date DATE, temperature FLOAT, humidity FLOAT); INSERT INTO Field2 VALUES ('2021-06-01', 27, 55), ('2021-06-02', 23, 60);
|
What is the average temperature and humidity in Field1 and Field2 for the month of June?
|
SELECT AVG(f1.temperature) as avg_temperature, AVG(f1.humidity) as avg_humidity FROM Field1 f1 INNER JOIN Field2 f2 ON f1.date = f2.date WHERE EXTRACT(MONTH FROM f1.date) = 6;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_data_india (customer_id INT, data_usage FLOAT, city VARCHAR(50)); INSERT INTO customer_data_india (customer_id, data_usage, city) VALUES (1, 3.5, 'Mumbai'); INSERT INTO customer_data_india (customer_id, data_usage, city) VALUES (2, 4.2, 'Mumbai'); INSERT INTO customer_data_india (customer_id, data_usage, city) VALUES (3, 5.0, 'Mumbai'); INSERT INTO customer_data_india (customer_id, data_usage, city) VALUES (4, 4.8, 'Delhi');
|
What is the maximum data usage for customers in 'Mumbai'?
|
SELECT MAX(data_usage) FROM customer_data_india WHERE city = 'Mumbai';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArtsEvents (id INT, city VARCHAR(50), country VARCHAR(50), event_name VARCHAR(100), event_date DATE); INSERT INTO TraditionalArtsEvents (id, city, country, event_name, event_date) VALUES (1, 'Puebla', 'Mexico', 'Música de Mariachi', '2021-03-17'), (2, 'Puebla', 'Mexico', 'Danza de los Voladores', '2021-04-22');
|
Update the event name for ID 2 in traditional arts events to "Cerámica Talavera".
|
UPDATE TraditionalArtsEvents SET event_name = 'Cerámica Talavera' WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (equipment_id INT, equipment_type VARCHAR(50), last_maintenance_date DATE);
|
Add a new military equipment record for an equipment_id of 333, equipment_type of 'Armored Vehicle', and last_maintenance_date of '2022-02-01'
|
INSERT INTO military_equipment (equipment_id, equipment_type, last_maintenance_date) VALUES (333, 'Armored Vehicle', '2022-02-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Equipment (EquipmentID INT, EquipmentName VARCHAR(100)); INSERT INTO Equipment (EquipmentID, EquipmentName) VALUES (1, 'Tank'); INSERT INTO Equipment (EquipmentID, EquipmentName) VALUES (2, 'Missile'); INSERT INTO Equipment (EquipmentID, EquipmentName) VALUES (3, 'Drone'); CREATE TABLE Contracts (ContractID INT, EquipmentID INT, ContractValue DECIMAL(10,2)); INSERT INTO Contracts (ContractID, EquipmentID, ContractValue) VALUES (1, 1, 500000), (2, 2, 750000), (3, 3, 900000);
|
What is the total contract value for drones?
|
SELECT SUM(Contracts.ContractValue) FROM Contracts INNER JOIN Equipment ON Contracts.EquipmentID = Equipment.EquipmentID WHERE Equipment.EquipmentName = 'Drone';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_personnel (country VARCHAR(255), num_personnel INT); INSERT INTO military_personnel (country, num_personnel) VALUES ('United States', 478351), ('South Korea', 557000), ('Japan', 247000), ('India', 1362500), ('Australia', 81000);
|
What is the average number of military personnel in the Asia Pacific region, excluding China?
|
SELECT AVG(num_personnel) FROM military_personnel WHERE country NOT IN ('China', 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founders, funding) VALUES (1, 'SAMEdTech', 'Edtech', 'South America', 9000000);
|
What is the maximum funding received by startups founded by individuals from South America in the edtech sector?
|
SELECT MAX(funding) FROM startups WHERE industry = 'Edtech' AND founders = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GenreTime (GenreID INT, TimeID INT, Revenue INT);
|
What is the total revenue for each genre in 2019?
|
SELECT Genre.Name, SUM(GenreTime.Revenue) as TotalRevenue FROM GenreTime INNER JOIN Genre ON GenreTime.GenreID = Genre.GenreID WHERE GenreTime.TimeID = (SELECT TimeID FROM Time WHERE Year=2019) GROUP BY Genre.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW crop_temperature AS SELECT crops.crop_name, field_sensors.temperature, field_sensors.measurement_date FROM crops JOIN field_sensors ON crops.field_id = field_sensors.field_id;
|
Which crops have the highest average temperature in the 'crop_temperature' view?
|
SELECT crop_name, AVG(temperature) as avg_temp FROM crop_temperature GROUP BY crop_name ORDER BY avg_temp DESC LIMIT 1;
|
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.