context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Warehouses (WarehouseID INT, WarehouseLocation VARCHAR(100), Region VARCHAR(50), StorageCapacity DECIMAL(10,2)); INSERT INTO Warehouses VALUES (1, 'Warehouse B', 'Europe', 5000);
|
Present the warehouse locations and their respective total storage capacity (in cubic meters) for the region 'Europe' as of 2022-02-01.
|
SELECT Warehouses.WarehouseLocation, SUM(Warehouses.StorageCapacity) as TotalStorageCapacity FROM Warehouses WHERE Warehouses.Region = 'Europe' AND Warehouses.StorageCapacity IS NOT NULL GROUP BY Warehouses.WarehouseLocation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists worker_industry2 (worker_id INT, industry TEXT);INSERT INTO worker_industry2 (worker_id, industry) VALUES (1, 'construction'), (2, 'retail'), (3, 'manufacturing'), (4, 'manufacturing');
|
How many workers are there in the 'manufacturing' industry?
|
SELECT COUNT(*) FROM worker_industry2 WHERE industry = 'manufacturing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine_operators (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), gender VARCHAR(10), years_of_experience INT); INSERT INTO mine_operators (id, name, role, gender, years_of_experience) VALUES (1, 'John Doe', 'Mining Engineer', 'Male', 7), (2, 'Maria', 'Mining Engineer', 'Female', 5);
|
List the names, roles, and years of experience of mining engineers with at least 5 years of experience.
|
SELECT name, role, years_of_experience FROM mine_operators WHERE years_of_experience >= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, country VARCHAR(20), building_type VARCHAR(20), certification_level VARCHAR(10)); INSERT INTO green_buildings (id, country, building_type, certification_level) VALUES (1, 'Oceania', 'Residential', 'Gold'), (2, 'Oceania', 'Commercial', 'Platinum'), (3, 'Oceania', 'Residential', 'Silver'), (4, 'Oceania', 'Mixed-use', 'Gold'), (5, 'Oceania', 'Commercial', 'Silver');
|
What is the distribution of green building types in Oceania, and how many of each type are there?
|
SELECT building_type, COUNT(*) AS count FROM green_buildings WHERE country = 'Oceania' GROUP BY building_type ORDER BY count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE case_processing (id INT, case_number INT, judge VARCHAR(50), process_date DATE, district VARCHAR(50));
|
What is the difference in average time taken for case processing between judges in the same court district?
|
SELECT judge, AVG(DATEDIFF(day, process_date, LEAD(process_date) OVER (PARTITION BY district ORDER BY process_date))) AS avg_time_diff FROM case_processing GROUP BY judge, district;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (id INT PRIMARY KEY, country VARCHAR(50), completion_date DATE, project_name VARCHAR(100)); INSERT INTO military_innovation (id, country, completion_date, project_name) VALUES (1, 'Nigeria', '2018-02-28', 'Project 1'), (2, 'Egypt', '2019-05-15', 'Project 2'), (3, 'South Africa', '2021-01-01', 'Project 3');
|
What is the count of military innovation projects led by African countries in the last 5 years?
|
SELECT COUNT(*) FROM military_innovation WHERE country IN ('Nigeria', 'Egypt', 'South Africa') AND completion_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics_sales(product_name TEXT, quantity INTEGER, is_sustainable BOOLEAN, sale_date DATE); INSERT INTO cosmetics_sales(product_name, quantity, is_sustainable, sale_date) VALUES('Sustainable Skincare Product 1', 35, true, '2021-12-31');
|
What is the total quantity of sustainable cosmetics sold in the last financial year?
|
SELECT SUM(quantity) FROM cosmetics_sales WHERE is_sustainable = true AND sale_date >= DATEADD(year, -1, CURRENT_DATE) AND sale_date < DATEADD(year, -1, DATEADD(day, -DATEPART(dw, CURRENT_DATE), CURRENT_DATE));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fairtrade_makeup (product_fairtrade BOOLEAN, sale_date DATE, quantity INT, manufacturing_country VARCHAR(20)); INSERT INTO fairtrade_makeup (product_fairtrade, sale_date, quantity, manufacturing_country) VALUES (TRUE, '2022-01-01', 50, 'South Africa'), (FALSE, '2022-01-02', 75, 'Nigeria');
|
What was the number of sales of fair trade makeup products in South Africa in H1 2022?
|
SELECT SUM(quantity) FROM fairtrade_makeup WHERE product_fairtrade = TRUE AND manufacturing_country = 'South Africa' AND sale_date BETWEEN '2022-01-01' AND '2022-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(50), category_id INT); CREATE TABLE product_categories (category_id INT, category_name VARCHAR(50)); INSERT INTO sales (sale_id, product_id, price) VALUES (1, 1, 50.00), (2, 2, 75.00), (3, 3, 30.00); INSERT INTO products (product_id, product_name, category_id) VALUES (1, 'Eco T-Shirt', 1), (2, 'Sustainable Sneakers', 2), (3, 'Recycled Backpack', 1); INSERT INTO product_categories (category_id, category_name) VALUES (1, 'Clothing'), (2, 'Footwear');
|
Update the price column in the sales table to reflect a 10% increase for all products in the 'Clothing' category in the product_categories table.
|
UPDATE sales SET price = price * 1.10 WHERE product_id IN (SELECT p.product_id FROM products p INNER JOIN product_categories pc ON p.category_id = pc.category_id WHERE pc.category_name = 'Clothing');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SizeDemand (Size VARCHAR(10), Demand INT);
|
Which sizes are not offered by any fashion brand, and what is the potential demand for those sizes?
|
SELECT C.Size, SUM(SD.Demand) AS TotalDemand FROM Customers C LEFT JOIN SizeDemand SD ON C.Size = SD.Size WHERE SD.Size IS NULL GROUP BY C.Size HAVING COUNT(C.CustomerID) = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(20), green_certified BOOLEAN, co_owned BOOLEAN); INSERT INTO properties (id, city, green_certified, co_owned) VALUES (1, 'San Antonio', true, true), (2, 'San Antonio', false, false), (3, 'San Antonio', true, false);
|
What is the total number of properties in the city of San Antonio that are both green-certified and co-owned?
|
SELECT COUNT(*) FROM properties WHERE city = 'San Antonio' AND green_certified = true AND co_owned = true;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA vehicle_info; CREATE TABLE vehicle_info.vehicle_ages (id INT PRIMARY KEY, vehicle_id INT, age INT); INSERT INTO vehicle_info.vehicle_ages (id, vehicle_id, age) VALUES (1, 1, 5), (2, 2, 3), (3, 3, 1), (4, 4, 4), (5, 5, 2);
|
What is the oldest vehicle in the 'vehicle_info' schema?
|
SELECT vehicle_id, MAX(age) as oldest FROM vehicle_info.vehicle_ages GROUP BY vehicle_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_safety (id INT, region VARCHAR, incident_date DATE); CREATE VIEW ai_safety_year AS SELECT id, region, incident_date FROM ai_safety WHERE incident_date >= DATEADD(year, -1, GETDATE());
|
How many AI safety incidents have been reported in each region in the past year?
|
SELECT region, COUNT(*) OVER (PARTITION BY region) FROM ai_safety_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (name VARCHAR(50), hours INT, volunteer_date DATE);
|
Update the volunteers table and set the hours to 5 for any records where the name is 'John Doe'
|
UPDATE volunteers SET hours = 5 WHERE name = 'John Doe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_rights_advocacy (advocacy_id INT, advocacy_type VARCHAR(10), year INT); INSERT INTO labor_rights_advocacy (advocacy_id, advocacy_type, year) VALUES (1, 'lobbying', 2021); INSERT INTO labor_rights_advocacy (advocacy_id, advocacy_type, year) VALUES (2, 'protest', 2022);
|
Delete records from the "labor_rights_advocacy" table where the "advocacy_type" column is "lobbying" and the "year" column is 2021
|
DELETE FROM labor_rights_advocacy WHERE advocacy_type = 'lobbying' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE offenders (id INT, age INT, city VARCHAR(20)); INSERT INTO offenders (id, age, city) VALUES (1, 34, 'Seattle'), (2, 28, 'New York'), (3, 45, 'Seattle');
|
What is the average age of offenders who committed theft in the city of Seattle?
|
SELECT AVG(age) FROM offenders WHERE city = 'Seattle' AND offense = 'theft';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm_locations (location VARCHAR, fish_id INT); CREATE TABLE fish_stock (fish_id INT, species VARCHAR, biomass FLOAT); INSERT INTO farm_locations (location, fish_id) VALUES ('Location A', 1), ('Location B', 2), ('Location A', 3), ('Location C', 4), ('Location B', 5); INSERT INTO fish_stock (fish_id, species, biomass) VALUES (1, 'Tilapia', 500.0), (2, 'Salmon', 800.0), (3, 'Trout', 300.0), (4, 'Bass', 700.0), (5, 'Tilapia', 600.0);
|
What is the total biomass of fish for all species at Location B?
|
SELECT SUM(fs.biomass) FROM fish_stock fs JOIN farm_locations fl ON fs.fish_id = fl.fish_id WHERE fl.location = 'Location B';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (id INT, company VARCHAR(255), country VARCHAR(255), phase VARCHAR(255)); INSERT INTO clinical_trials (id, company, country, phase) VALUES (1, 'BigPharma Inc.', 'United States', 'Phase 3');
|
What is the total number of clinical trials conducted by BigPharma Inc. in the United States?
|
SELECT COUNT(*) FROM clinical_trials WHERE company = 'BigPharma Inc.' AND country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE autonomous_shuttle (id INT PRIMARY KEY, name VARCHAR(255), make VARCHAR(255), model_year INT, software_status VARCHAR(255)); INSERT INTO autonomous_shuttle (id, name, make, model_year, software_status) VALUES (1, 'May Mobility Shuttle', 'May Mobility', 2021, 'Yes'), (2, 'Optimus Ride Shuttle', 'Optimus Ride', 2022, 'No'), (3, 'Perrone Robotics Shuttle', 'Perrone Robotics', 2021, 'Yes');
|
Remove autonomous shuttle records with software issues.
|
DELETE FROM autonomous_shuttle WHERE software_status = 'Yes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AfricanSites (id INT, site VARCHAR(50), continent VARCHAR(50), last_update DATE); INSERT INTO AfricanSites (id, site, continent, last_update) VALUES (1, 'Pyramids of Giza', 'Africa', '2022-01-15'), (2, 'Victoria Falls', 'Africa', '2021-07-28'), (3, 'Mount Kilimanjaro', 'Africa', '2022-06-03');
|
How many heritage sites are located in Africa and have been updated in the last 6 months?
|
SELECT COUNT(*) FROM AfricanSites WHERE continent = 'Africa' AND last_update >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Buildings (BuildingID int, Certification varchar(20), City varchar(20)); CREATE TABLE Properties (PropertyID int, Price int, BuildingID int); INSERT INTO Buildings (BuildingID, Certification, City) VALUES (1, 'Green', 'Seattle'); INSERT INTO Properties (PropertyID, Price, BuildingID) VALUES (1, 500000, 1); INSERT INTO Properties (PropertyID, Price, BuildingID) VALUES (2, 700000, 2); INSERT INTO Buildings (BuildingID, Certification, City) VALUES (2, 'Green', 'Portland');
|
What is the average property price for buildings with green certification in each city?
|
SELECT Buildings.City, AVG(Properties.Price) FROM Buildings INNER JOIN Properties ON Buildings.BuildingID = Properties.BuildingID WHERE Buildings.Certification = 'Green' GROUP BY Buildings.City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerOrders (id INT, customer_id INT, product VARCHAR(20), order_date DATE); INSERT INTO CustomerOrders (id, customer_id, product, order_date) VALUES (1, 1, 'Sustainable T-Shirt', '2022-05-03'), (2, 2, 'Regular Denim', '2022-05-05'), (3, 1, 'Sustainable T-Shirt', '2022-04-30'), (4, 3, 'Sustainable T-Shirt', '2022-03-28'), (5, 1, 'Sustainable T-Shirt', '2021-02-15'), (6, 4, 'Sustainable T-Shirt', '2022-01-01'), (7, 5, 'Sustainable Jacket', '2022-05-10'), (8, 5, 'Sustainable Pants', '2022-04-25'), (9, 5, 'Sustainable Shoes', '2022-03-20');
|
What is the customer with the least sustainable clothing purchases in the last year?
|
SELECT customer_id, COUNT(*) as num_purchases FROM CustomerOrders WHERE product LIKE 'Sustainable%' AND order_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY customer_id ORDER BY num_purchases ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hotels (HotelID INT, Country VARCHAR(50), CO2_Emissions_Reduction FLOAT); INSERT INTO Hotels (HotelID, Country, CO2_Emissions_Reduction) VALUES (1, 'India', 1000), (2, 'India', 1200);
|
What is the total CO2 emissions reduction by hotels in India?
|
SELECT SUM(CO2_Emissions_Reduction) FROM Hotels WHERE Country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_ratings (user_id INT, tv_show_name VARCHAR(50), genre VARCHAR(20), rating INT, rating_date DATE);
|
Identify the top 3 TV show genres with the highest average ratings, considering only those with at least 100 ratings.
|
SELECT genre, AVG(rating) as avg_rating FROM user_ratings GROUP BY genre HAVING COUNT(*) >= 100 ORDER BY avg_rating DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE algorand_smart_contracts (contract_address VARCHAR(42), category VARCHAR(20));
|
How many smart contracts are associated with each category in the Algorand blockchain?
|
SELECT category, COUNT(*) FROM algorand_smart_contracts GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rounds (id INT, company_id INT, funding_round_size INT, round_type TEXT); CREATE TABLE company (id INT, name TEXT, location TEXT, founder_origin TEXT); INSERT INTO rounds (id, company_id, funding_round_size, round_type) VALUES (1, 1, 15000000, 'Series C'); INSERT INTO company (id, name, location, founder_origin) VALUES (1, 'Acme Inc', 'Brazil', 'Latin America');
|
What is the maximum funding round size for startups founded by individuals from Latin America?
|
SELECT MAX(funding_round_size) FROM rounds JOIN company ON rounds.company_id = company.id WHERE company.founder_origin = 'Latin America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE capability_programs (id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO capability_programs (id, region, budget) VALUES (1, 'South America', 12000.00), (2, 'Europe', 9000.00), (3, 'Asia-Pacific', 15000.00);
|
List all financial capability programs in South America with a budget greater than $10,000.
|
SELECT * FROM capability_programs WHERE region = 'South America' AND budget > 10000.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name VARCHAR(50), country VARCHAR(50), start_date DATE, end_date DATE, operation_description TEXT);
|
Update the country column in the peacekeeping_operations table to lowercase for all records
|
UPDATE peacekeeping_operations SET country = LOWER(country);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExcavationSites (id INT, site VARCHAR(20), location VARCHAR(30), start_date DATE, end_date DATE); INSERT INTO ExcavationSites (id, site, location, start_date, end_date) VALUES (1, 'BronzeAge', 'UK', '2000-01-01', '2005-12-31'), (2, 'AncientGaul', 'France', '2004-01-01', '2007-12-31'); CREATE TABLE Artifacts (id INT, excavation_site VARCHAR(20), artifact_name VARCHAR(30), pieces INT); INSERT INTO Artifacts (id, excavation_site, artifact_name, pieces) VALUES (1, 'AncientGaul', 'Sword', 300,), (2, 'AncientGaul', 'Shield', 500,);
|
What is the total number of artifacts excavated from each site in 'France'?
|
SELECT excavation_site, SUM(pieces) FROM Artifacts JOIN ExcavationSites ON Artifacts.excavation_site = ExcavationSites.site WHERE location = 'France' GROUP BY excavation_site;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue (year INT, location TEXT, revenue FLOAT); INSERT INTO revenue (year, location, revenue) VALUES (2021, 'New York', 150000), (2022, 'New York', 200000);
|
What is the total revenue of virtual tourism in New York in 2022?
|
SELECT SUM(revenue) FROM revenue WHERE location = 'New York' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE campaigns (campaign_id INT, campaign_name VARCHAR(50), region VARCHAR(20)); INSERT INTO campaigns (campaign_id, campaign_name, region) VALUES (1, 'End the Stigma', 'Asia'), (2, 'Mental Health Matters', 'Europe'), (3, 'Speak Up', 'America');
|
List of public awareness campaigns by region?
|
SELECT campaign_name, region FROM campaigns;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_sites (site_id INT, name TEXT, city TEXT, virtual_tour_rating FLOAT); INSERT INTO cultural_sites (site_id, name, city, virtual_tour_rating) VALUES (1, 'Louvre Museum', 'Paris', 4.8), (2, 'Eiffel Tower', 'Paris', 4.5);
|
Which cultural heritage sites in Paris have the best virtual tour experiences?
|
SELECT name FROM cultural_sites WHERE city = 'Paris' ORDER BY virtual_tour_rating DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE borough (borough_id INT, name VARCHAR(255)); INSERT INTO borough (borough_id, name) VALUES (1, 'Manhattan'), (2, 'Brooklyn'), (3, 'Queens'), (4, 'Bronx'), (5, 'Staten Island'); CREATE TABLE property (property_id INT, price INT, borough_id INT, sqft INT); INSERT INTO property (property_id, price, borough_id, sqft) VALUES (1, 1500000, 1, 1000), (2, 800000, 2, 1200), (3, 1200000, 3, 1500);
|
What is the average property price in each borough, ordered by average price?
|
SELECT b.name, AVG(p.price) as avg_price FROM property p INNER JOIN borough b ON p.borough_id = b.borough_id GROUP BY b.name ORDER BY avg_price DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), rating DECIMAL(2,1), review_count INT); INSERT INTO dishes VALUES (1, 'Chicken Tikka Masala', 4.5, 15); INSERT INTO dishes VALUES (2, 'Veggie Pad Thai', 4.2, 7);
|
What is the average rating and review count for each dish, excluding dishes with fewer than 10 reviews?
|
SELECT dish_name, AVG(rating) as avg_rating, SUM(review_count) as total_reviews FROM dishes WHERE review_count >= 10 GROUP BY dish_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (event_id INT PRIMARY KEY, region VARCHAR(50), num_volunteers INT); INSERT INTO events (event_id, region, num_volunteers) VALUES (1, 'Northeast', 75), (2, 'Southeast', 50), (3, 'Northeast', 60);
|
How many events were held in the Northeast region with more than 50 volunteers in 2018?
|
SELECT COUNT(*) FROM events WHERE region = 'Northeast' AND num_volunteers > 50 AND YEAR(event_date) = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255)); INSERT INTO organizations (id, name, country, type) VALUES (4, 'Sunrise Movement', 'USA', 'NGO'); CREATE TABLE mitigation_actions (id INT, project_id INT, organization_id INT, date DATE, type VARCHAR(255)); INSERT INTO mitigation_actions (id, project_id, organization_id, date, type) VALUES (4, 3, 4, '2022-04-01', 'Electric Vehicles');
|
What organizations are working on mitigation actions in the USA?
|
SELECT organizations.name FROM organizations INNER JOIN mitigation_actions ON organizations.id = mitigation_actions.organization_id WHERE organizations.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteGeneration (waste_id INT, region VARCHAR(255), waste_amount DECIMAL(10,2), generation_date DATE); INSERT INTO WasteGeneration (waste_id, region, waste_amount, generation_date) VALUES (1, 'North', 1200, '2021-01-01'), (2, 'South', 1500, '2021-01-01'), (3, 'East', 800, '2021-01-01'), (4, 'West', 1700, '2021-01-01');
|
What is the total waste generated in the last 6 months by region?
|
SELECT region, SUM(waste_amount) FROM WasteGeneration WHERE generation_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RenewableEnergyProjects (id INT, name VARCHAR(100), location VARCHAR(100), type VARCHAR(50), capacity FLOAT);
|
What is the average capacity of renewable energy projects in the 'RenewableEnergyProjects' table?
|
SELECT AVG(capacity) FROM RenewableEnergyProjects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE na_ai_safety_incidents (id INT, incident_name VARCHAR(255), country VARCHAR(255), incident_category VARCHAR(255)); INSERT INTO na_ai_safety_incidents (id, incident_name, country, incident_category) VALUES (1, 'IncidentD', 'USA', 'Data Privacy'), (2, 'IncidentE', 'Canada', 'System Failure');
|
Find the AI safety incidents that occurred in North America and were related to data privacy.
|
SELECT * FROM na_ai_safety_incidents WHERE country IN ('USA', 'Canada') AND incident_category = 'Data Privacy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cultural_Competency_Training (Training_ID INT, Training_Name VARCHAR(255), Start_Date DATE, Region VARCHAR(255)); INSERT INTO Cultural_Competency_Training (Training_ID, Training_Name, Start_Date, Region) VALUES (1, 'Cultural Sensitivity', '2022-02-01', 'Midwest'), (2, 'Language Access', '2022-03-15', 'Northeast');
|
What are the unique cultural competency training programs and their respective start dates for healthcare workers in the Midwest region?
|
SELECT DISTINCT Training_Name, Start_Date FROM Cultural_Competency_Training WHERE Region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RetailStores (StoreID INT, StoreName VARCHAR(50));CREATE TABLE SustainabilityRatings (GarmentID INT, StoreID INT, SustainabilityRating INT);
|
Which retail stores have a sustainable product rating greater than 4?
|
SELECT RS.StoreName FROM RetailStores RS JOIN SustainabilityRatings SR ON RS.StoreID = SR.StoreID WHERE SR.SustainabilityRating > 4;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (garment VARCHAR(50), sale_date DATE); INSERT INTO sales (garment, sale_date) VALUES ('Shirt', '2021-01-05'), ('Pants', '2021-01-05'), ('Dress', '2021-01-10'), ('Shirt', '2022-01-05'), ('Pants', '2022-01-05'), ('Dress', '2022-01-10');
|
Determine the number of days between each sale, partitioned by garment and ordered by date.
|
SELECT garment, sale_date, DATEDIFF(day, LAG(sale_date) OVER (PARTITION BY garment ORDER BY sale_date), sale_date) as days_between_sales FROM sales;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels_rating (hotel_id INT, country TEXT, rating FLOAT, month INT); INSERT INTO hotels_rating (hotel_id, country, rating, month) VALUES (1, 'USA', 4.5, 1), (1, 'USA', 4.6, 2), (1, 'USA', 4.7, 3), (2, 'Canada', 4.2, 1), (2, 'Canada', 4.3, 2), (2, 'Canada', 4.4, 3), (3, 'Mexico', 4.7, 1), (3, 'Mexico', 4.8, 2), (3, 'Mexico', 4.9, 3);
|
What is the hotel rating trend by country?
|
SELECT country, rating, month, LEAD(rating) OVER (PARTITION BY country ORDER BY month) as next_month_rating FROM hotels_rating;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genres (id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE streams (id INT, song_id INT, user_id INT, location VARCHAR(255), timestamp TIMESTAMP); INSERT INTO genres (id, name, type) VALUES (1, 'Jazz', 'Music'), (2, 'Rock', 'Music'); INSERT INTO streams (id, song_id, user_id, location, timestamp) VALUES (1, 1, 1, 'Canada', NOW()), (2, 2, 2, 'Mexico', NOW()); CREATE VIEW jazz_rock_songs AS SELECT song_id FROM genres WHERE type IN ('Jazz', 'Rock');
|
Find the total number of streams for jazz and rock songs, excluding any streams from Canada.
|
SELECT COUNT(*) FROM streams WHERE song_id IN (SELECT song_id FROM jazz_rock_songs) AND location != 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerStats (PlayerID INT, Game VARCHAR(50), Kills INT, Deaths INT, Assists INT); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (1, 'FPS Game', 50, 30, 15); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (2, 'RPG Game', 20, 10, 30); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (3, 'FPS Game', 60, 20, 20); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (4, 'RPG Game', 30, 5, 40); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (5, 'FPS Game', 70, 25, 25); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (6, 'RPG Game', 40, 10, 50);
|
Identify the players who have the highest number of effective kills in each game.
|
SELECT PlayerID, Game, Kills + Assists - Deaths AS EffectiveKills FROM (SELECT PlayerID, Game, Kills, Deaths, Assists, ROW_NUMBER() OVER (PARTITION BY Game ORDER BY Kills + Assists - Deaths DESC) AS Rank FROM PlayerStats) AS PlayerStatsRank WHERE Rank = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (id INT, name TEXT, model TEXT, manufacturer TEXT); CREATE TABLE SpaceMissions (id INT, spacecraft_id INT, mission TEXT, duration INT);
|
What is the average duration of space missions for each spacecraft model?
|
SELECT model, AVG(duration) FROM SpaceMissions JOIN Spacecraft ON SpaceMissions.spacecraft_id = Spacecraft.id GROUP BY model;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, mental_health_score INT, participated_in_open_pedagogy BOOLEAN); INSERT INTO students (student_id, mental_health_score, participated_in_open_pedagogy) VALUES (1, 80, TRUE), (2, 70, FALSE), (3, 90, TRUE);
|
What is the number of students who have a lower mental health score than the average mental health score of students who have participated in open pedagogy?
|
SELECT COUNT(*) FROM students s1 WHERE s1.mental_health_score < (SELECT AVG(s2.mental_health_score) FROM students s2 WHERE s2.participated_in_open_pedagogy = TRUE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant (restaurant_id INT, region VARCHAR(50), revenue INT); INSERT INTO restaurant (restaurant_id, region, revenue) VALUES (1, 'Northeast', 5000), (2, 'Southeast', 6000), (3, 'Northeast', 7000);
|
What is the average revenue for restaurants in the Northeast?
|
SELECT region, AVG(revenue) FROM restaurant WHERE region = 'Northeast' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, City VARCHAR(20), Platform VARCHAR(10)); INSERT INTO Players (PlayerID, City, Platform) VALUES (1, 'Tokyo', 'PC'), (2, 'Los Angeles', 'Console'), (3, 'New York', 'PC'), (4, 'Paris', 'VR'), (5, 'Tokyo', 'Console'), (6, 'Los Angeles', 'PC');
|
What is the total number of players who play games on each platform and in each city?
|
SELECT City, Platform, COUNT(*) AS Count FROM Players GROUP BY City, Platform ORDER BY Count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE socially_responsible_loans (customer_id INT, loan_amount DECIMAL(10, 2), disbursement_date DATE); INSERT INTO socially_responsible_loans VALUES (1, 5000, '2021-01-15'), (2, 7000, '2021-03-20'), (1, 3000, '2021-06-05'), (3, 8000, '2021-09-10');
|
What is the loan amount disbursed per day for socially responsible loans, partitioned by week?
|
SELECT date_trunc('week', disbursement_date) as week, SUM(loan_amount) OVER (PARTITION BY date_trunc('week', disbursement_date)) as total_loan_amount FROM socially_responsible_loans;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), level INT);
|
Add a new 'player' record with id 6, name 'Alex', country 'Colombia', and level 10
|
INSERT INTO players (id, name, country, level) VALUES (6, 'Alex', 'Colombia', 10);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(255)); INSERT INTO Customers (CustomerID, Name) VALUES (1, 'John Doe'); INSERT INTO Customers (CustomerID, Name) VALUES (2, 'Jane Doe'); CREATE TABLE Loans (LoanID INT, CustomerID INT, Type VARCHAR(255), Date DATE); INSERT INTO Loans (LoanID, CustomerID, Type, Date) VALUES (1, 1, 'Green Loan', '2022-01-01'); INSERT INTO Loans (LoanID, CustomerID, Type, Date) VALUES (2, 1, 'Auto Loan', '2021-01-01'); INSERT INTO Loans (LoanID, CustomerID, Type, Date) VALUES (3, 2, 'Green Loan', '2022-05-01');
|
List all the customers who have taken out a green loan in the last year
|
SELECT L.CustomerID, C.Name FROM Loans L INNER JOIN Customers C ON L.CustomerID = C.CustomerID WHERE L.Type = 'Green Loan' AND L.Date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT); INSERT INTO Members (MemberID, Name, Age) VALUES (1, 'John Doe', 30); INSERT INTO Members (MemberID, Name, Age) VALUES (2, 'Jane Doe', 27); CREATE TABLE Workouts (WorkoutID INT, WorkoutDate DATE, WorkoutType VARCHAR(50), MemberID INT, Duration INT); INSERT INTO Workouts (WorkoutID, WorkoutDate, WorkoutType, MemberID, Duration) VALUES (1, '2022-02-01', 'Strength Training', 1, 60); INSERT INTO Workouts (WorkoutID, WorkoutDate, WorkoutType, MemberID, Duration) VALUES (2, '2022-02-10', 'Yoga', 2, 90);
|
What is the total duration of strength training workouts for members aged 25-35?
|
SELECT SUM(Workouts.Duration) FROM Members INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE Members.Age BETWEEN 25 AND 35 AND Workouts.WorkoutType = 'Strength Training';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conditions (id INT, country VARCHAR(255), condition VARCHAR(255)); INSERT INTO conditions (id, country, condition) VALUES (1, 'Bangladesh', 'Depression'), (2, 'Bangladesh', 'Anxiety'), (3, 'Bangladesh', 'Depression');
|
What is the most common mental health condition in Bangladesh?
|
SELECT condition, COUNT(*) FROM conditions WHERE country = 'Bangladesh' GROUP BY condition ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TempData (id INT, region VARCHAR(255), crop_type VARCHAR(255), timestamp TIMESTAMP, temperature DECIMAL(5,2));
|
What is the average temperature difference between morning and evening for each crop type in the 'Central' region in 2022?
|
SELECT region, crop_type, AVG(temperature_diff) FROM (SELECT region, crop_type, TIMESTAMPDIFF(HOUR, MIN(timestamp), MAX(timestamp)) AS hours_diff, AVG(temperature) - (SELECT AVG(temperature) FROM TempData t2 WHERE t1.region = t2.region AND t1.crop_type = t2.crop_type AND DATE(t2.timestamp) = DATE(t1.timestamp) AND HOUR(t2.timestamp) < 6) AS temperature_diff FROM TempData t1 WHERE region = 'Central' AND YEAR(timestamp) = 2022 GROUP BY region, crop_type, DATE(timestamp)) t GROUP BY region, crop_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE flight_safety (id INT, airline VARCHAR(50), accident_year INT); INSERT INTO flight_safety (id, airline, accident_year) VALUES (1, 'AirlineX', 2000), (2, 'AirlineY', 2005), (3, 'AirlineX', 2010);
|
How many accidents were recorded for airline X?
|
SELECT COUNT(*) FROM flight_safety WHERE airline = 'AirlineX';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'Beijing Warehouse 1', 'Beijing'), (2, 'Beijing Warehouse 2', 'Beijing'); CREATE TABLE Shipment (id INT, weight INT, warehouse_id INT); INSERT INTO Shipment (id, weight, warehouse_id) VALUES (101, 10000, 1), (102, 15000, 1), (103, 8000, 2);
|
What is the total weight of all shipments in the 'Beijing' warehouse?
|
SELECT SUM(weight) FROM Shipment s JOIN Warehouse w ON s.warehouse_id = w.id WHERE w.city = 'Beijing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_efforts (date DATE, effort VARCHAR(50), location VARCHAR(50));
|
Insert a new record into the 'conservation_efforts' table with the following data: date '2022-05-01', effort 'Reducing plastic pollution', location 'Arctic Ocean'
|
INSERT INTO conservation_efforts (date, effort, location) VALUES ('2022-05-01', 'Reducing plastic pollution', 'Arctic Ocean');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation_metrics ( country VARCHAR(50), year INT, generation_metric INT);
|
Alter the 'waste_generation_metrics' table to add a new column 'region'
|
ALTER TABLE waste_generation_metrics ADD COLUMN region VARCHAR(50);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE objects (id INT, name VARCHAR(50), distance DECIMAL(10,2), category VARCHAR(50));
|
Find the average distance from the sun of objects in the Kuiper Belt
|
SELECT AVG(distance) FROM objects WHERE category = 'Kuiper Belt';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Music (title TEXT, genre TEXT, year INTEGER, rating FLOAT); INSERT INTO Music (title, genre, year, rating) VALUES ('Song1', 'K-pop', 2016, 8.5), ('Song2', 'Pop', 2017, 9.0), ('Song3', 'K-pop', 2018, 9.2), ('Song4', 'Rock', 2019, 8.8), ('Song5', 'K-pop', 2020, 9.1), ('Song6', 'Jazz', 2021, 8.6);
|
What is the maximum rating of K-pop songs released in 2018?
|
SELECT MAX(rating) FROM Music WHERE genre = 'K-pop' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE music_genres(genre_id INT, name VARCHAR(50));
|
Insert a new music genre 'K-pop' into the music_genres table.
|
INSERT INTO music_genres (genre_id, name) VALUES (1, 'K-pop');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(255), type VARCHAR(255), price DECIMAL(5,2), gluten_free BOOLEAN); INSERT INTO menus (menu_id, menu_name, type, price, gluten_free) VALUES (1, 'Quinoa Salad', 'Vegetarian', 12.99, true), (2, 'Margherita Pizza', 'Non-Vegetarian', 9.99, false), (3, 'Falafel Wrap', 'Vegetarian', 8.99, true), (5, 'Vegan Burger', 'Vegan', 10.99, false), (6, 'Vegan Tacos', 'Vegan', 7.99, true);
|
What is the total revenue generated from gluten-free menu items?
|
SELECT SUM(price) FROM menus WHERE gluten_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_adaptation_projects (project_id INT, location VARCHAR(50), investment_amount FLOAT, investment_year INT); INSERT INTO climate_adaptation_projects (project_id, location, investment_amount, investment_year) VALUES (1, 'Marshall Islands', 2000000, 2015), (2, 'Fiji', 3000000, 2016), (3, 'Barbados', 1500000, 2017), (4, 'Haiti', 4000000, 2018), (5, 'Cape Verde', 2500000, 2019), (6, 'Seychelles', 3500000, 2020);
|
What is the average investment in climate adaptation projects in Small Island Developing States (SIDS) between 2015 and 2020?
|
SELECT AVG(investment_amount) FROM climate_adaptation_projects WHERE location LIKE 'SIDS' AND investment_year BETWEEN 2015 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Productivity (ProductivityID INT, MineType VARCHAR(10), Productivity DECIMAL(5,2)); INSERT INTO Productivity (ProductivityID, MineType, Productivity) VALUES (1, 'Coal', 5.5), (2, 'Gold', 4.3), (3, 'Coal', 6.1);
|
What is the average labor productivity by mine type?
|
SELECT MineType, AVG(Productivity) FROM Productivity GROUP BY MineType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (ID INT, Name VARCHAR(50), Cost FLOAT); INSERT INTO Spacecraft VALUES (1, 'Ares', 5000000), (2, 'Orion', 7000000), (3, 'Artemis', 8000000);
|
What is the average cost of spacecraft?
|
SELECT AVG(Cost) FROM Spacecraft;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE collections (id INT, name VARCHAR(50), artworks INT); INSERT INTO collections (id, name, artworks) VALUES (1, 'African Collection 1', 10), (2, 'African Collection 2', 15), (3, 'European Collection', 20);
|
What is the minimum number of artworks in a collection from Africa?
|
SELECT MIN(artworks) FROM collections WHERE name LIKE '%African%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dishes (DishID INT, Name VARCHAR(50), Calories INT); CREATE TABLE Ingredients (IngredientID INT, DishID INT, Name VARCHAR(50)); INSERT INTO Dishes (DishID, Name, Calories) VALUES (1, 'Scrambled Eggs', 400), (2, 'French Toast', 600); INSERT INTO Ingredients (IngredientID, DishID, Name) VALUES (1, 1, 'Eggs'), (2, 2, 'Eggs');
|
Which menu items contain eggs as an ingredient and have high calorie count?
|
SELECT d.Name FROM Dishes d JOIN Ingredients i ON d.DishID = i.DishID WHERE i.Name = 'Eggs' AND d.Calories > 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brand_carbon_footprint (id INT, brand VARCHAR(50), co2_emissions INT, country VARCHAR(50), year INT); INSERT INTO brand_carbon_footprint (id, brand, co2_emissions, country, year) VALUES (1, 'Brand X', 100, 'Japan', 2021), (2, 'Brand Y', 80, 'Japan', 2021), (3, 'Brand Z', 60, 'Japan', 2021);
|
What are the top 3 sustainable beauty brands in terms of carbon footprint reduction in Japan?
|
SELECT brand FROM (SELECT brand, co2_emissions, ROW_NUMBER() OVER (ORDER BY co2_emissions ASC) AS rank FROM brand_carbon_footprint WHERE country = 'Japan' AND year = 2021) subquery WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy (id INT, garment VARCHAR(20), order_qty INT); INSERT INTO circular_economy (id, garment, order_qty) VALUES (1, 'recycled_sweater', 50), (2, 'upcycled_jeans', 120), (3, 'refurbished_shoes', 75);
|
List the garments and their quantities in the 'circular_economy' table for orders over 100.
|
SELECT garment, order_qty FROM circular_economy WHERE order_qty > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE risk_assessments (id INT, region VARCHAR(255), risk_score INT); INSERT INTO risk_assessments (id, region, risk_score) VALUES (1, 'Middle East', 75); INSERT INTO risk_assessments (id, region, risk_score) VALUES (2, 'Asia', 50); INSERT INTO risk_assessments (id, region, risk_score) VALUES (4, 'Africa', 65);
|
Get the geopolitical risk scores for the 'Africa' region from the 'risk_assessments' table
|
SELECT risk_score FROM risk_assessments WHERE region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityInitiatives (initiative_name TEXT, district TEXT); INSERT INTO CommunityInitiatives (initiative_name, district) VALUES ('Neighborhood Watch', 'Oakland'), ('Coffee with a Cop', 'Oakland'), ('Community Police Academy', 'Oakland'), ('Police Athletic League', 'Oakland');
|
List all the unique community policing initiatives in the Oakland district.
|
SELECT DISTINCT initiative_name FROM CommunityInitiatives WHERE district = 'Oakland';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (ingredient VARCHAR(255), quantity INT); INSERT INTO inventory (ingredient, quantity) VALUES ('Flour', 1000), ('Tomatoes', 2000), ('Cheese', 3000);
|
What is the inventory level for each ingredient used in the menu?
|
SELECT ingredient, quantity FROM inventory;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cyber_strategies_risk_owners (id INT, strategy VARCHAR, risk VARCHAR, owner VARCHAR); INSERT INTO cyber_strategies_risk_owners (id, strategy, risk, owner) VALUES (1, 'Operation Iron Curtain', 'Medium', 'Alice'), (2, 'Operation Glass Shield', 'High', 'Bob'), (3, 'Operation Cyber Guardian', 'Low', 'Charlie');
|
Showcase the cybersecurity strategies and their respective risk owners, and rank them based on their risk levels.
|
SELECT strategy, risk, owner, ROW_NUMBER() OVER (PARTITION BY risk ORDER BY owner) as rank FROM cyber_strategies_risk_owners;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_marine_species (species VARCHAR(255), count INT); INSERT INTO arctic_marine_species (species, count) VALUES ('Seal', 100), ('Walrus', 120), ('Fish', 150);
|
Find the total number of marine species and their observation counts in the Arctic Ocean, excluding fish.
|
SELECT COUNT(DISTINCT species) AS species_count, SUM(count) AS total_count FROM arctic_marine_species WHERE species != 'Fish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE injuries (athlete_id INT, injury VARCHAR(255)); INSERT INTO injuries (athlete_id, injury) VALUES (1, 'Ankle Sprain'), (1, 'Knee Pain'), (2, 'Shoulder Dislocation'), (3, 'Ankle Sprain'), (3, 'Concussion');
|
What are the top 5 most common injuries for athletes in the past year?
|
SELECT injury, COUNT(*) AS count FROM injuries GROUP BY injury ORDER BY count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE compliance_records (subscriber_id INT, name VARCHAR(255), region VARCHAR(255), mobile_number VARCHAR(20), broadband_speed DECIMAL(10, 2), last_bill_date DATE, total_bill DECIMAL(10, 2));
|
What is the total data used by each subscriber?
|
SELECT subscriber_id, SUM(data_used) AS total_data_used FROM customer_usage GROUP BY subscriber_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, artwork VARCHAR(50), artist VARCHAR(50), medium VARCHAR(50), value INT); INSERT INTO artworks (id, artwork, artist, medium, value) VALUES (1, 'Painting', 'John Smith', 'Painting', 10000), (2, 'Sculpture', 'Maria Rodriguez', 'Sculpture', 15000), (3, 'Print', 'Jacques Leclerc', 'Print', 5000);
|
What is the total value of artworks by artist and medium, pivoted to display the artist and medium in separate columns?
|
SELECT artist, medium, SUM(value) as total_value FROM artworks GROUP BY artist, medium;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donor (don_id INT, donor_name VARCHAR(255)); CREATE TABLE donation (don_id INT, donor_id INT, donation_date DATE);
|
Determine the number of days between the first and last donation for each donor, for donors who have made at least two donations.
|
SELECT donor_id, DATEDIFF(MAX(donation_date), MIN(donation_date)) AS days_between_first_and_last_donation FROM donation GROUP BY donor_id HAVING COUNT(*) > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameDates (GameDate DATE, PlayerID INT, GameName VARCHAR(255)); INSERT INTO GameDates (GameDate, PlayerID, GameName) VALUES ('2022-01-01', 1, 'Virtual Soccer'); INSERT INTO GameDates (GameDate, PlayerID, GameName) VALUES ('2022-01-02', 2, 'Virtual Soccer'); INSERT INTO Players (PlayerID, Country) VALUES (1, 'Japan'); INSERT INTO Players (PlayerID, Country) VALUES (2, 'Canada');
|
What is the most recent date a player from Japan has played 'Virtual Soccer'?
|
SELECT MAX(GameDate) FROM GameDates JOIN Players ON GameDates.PlayerID = Players.PlayerID WHERE Players.Country = 'Japan' AND GameName = 'Virtual Soccer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name VARCHAR(255), industry VARCHAR(255), union_status VARCHAR(255), num_employees INT); INSERT INTO employees (id, name, industry, union_status, num_employees) VALUES (1, 'John Doe', 'Manufacturing', 'Union', 50), (2, 'Jane Smith', 'Manufacturing', 'Non-Union', 75), (3, 'Bob Johnson', 'Retail', 'Union', 30), (4, 'Alice Williams', 'Retail', 'Union', 40), (5, 'Charlie Brown', 'Construction', 'Non-Union', 100);
|
Calculate the average number of employees per industry, categorized by union status
|
SELECT union_status, AVG(num_employees) as 'Average Employees' FROM employees GROUP BY union_status;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_med (id INT, location TEXT, date DATE, value FLOAT); INSERT INTO temperature_med (id, location, date, value) VALUES (1, 'Mediterranean Sea', '2022-08-01', 24); INSERT INTO temperature_med (id, location, date, value) VALUES (2, 'Mediterranean Sea', '2022-08-15', 26);
|
What is the average temperature of the Mediterranean Sea in the month of August?
|
SELECT AVG(value) FROM temperature_med WHERE location = 'Mediterranean Sea' AND EXTRACT(MONTH FROM date) = 8;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_financing(client_id INT, country VARCHAR(25), amount FLOAT);INSERT INTO shariah_financing(client_id, country, amount) VALUES (1, 'Malaysia', 5000), (2, 'UAE', 7000), (3, 'Indonesia', 6000), (4, 'Saudi Arabia', 8000), (5, 'Malaysia', 9000), (6, 'UAE', 10000), (7, 'Indonesia', 11000), (8, 'Saudi Arabia', 12000), (9, 'Malaysia', 13000), (10, 'UAE', 14000), (11, 'Bahrain', 1500), (12, 'Kuwait', 1600);
|
What is the total amount of Shariah-compliant financing for clients in the bottom 2 countries with the least Shariah-compliant financing?
|
SELECT country, SUM(amount) as total_financing FROM shariah_financing WHERE country IN (SELECT country FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY SUM(amount) ASC) as rank FROM shariah_financing GROUP BY country) WHERE rank <= 2) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_expeditions (expedition_name VARCHAR(255), depth FLOAT, ocean VARCHAR(255));
|
What is the maximum depth of all deep-sea expeditions in the Pacific Ocean?
|
SELECT MAX(depth) FROM deep_sea_expeditions WHERE ocean = 'Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2)); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'Southern'), (2, 'Jane Smith', 'Northern'); INSERT INTO transactions (transaction_id, client_id, amount) VALUES (1, 1, 1000.00), (2, 1, 2000.00), (3, 2, 500.00);
|
What is the total value of transactions for clients in the Southern region?
|
SELECT c.client_id, c.name, c.region, SUM(t.amount) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id GROUP BY c.client_id, c.name, c.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Equipment(id INT, name VARCHAR(255), manufacturer VARCHAR(255), model VARCHAR(255), cost DECIMAL(10,2));
|
What is the average cost of military equipment items manufactured by 'Orange Corp.'?
|
SELECT AVG(cost) FROM Equipment WHERE manufacturer = 'Orange Corp.';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_complaints (complaint_date DATE, complaint_type TEXT);
|
How many customer complaints were there per month in 2021?
|
SELECT EXTRACT(MONTH FROM complaint_date) AS month, COUNT(*) FROM customer_complaints WHERE complaint_date >= '2021-01-01' AND complaint_date < '2022-01-01' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtPiecesValue (id INT, title VARCHAR(50), medium VARCHAR(50), value INT); INSERT INTO ArtPiecesValue (id, title, medium, value) VALUES (1, 'Mona Lisa', 'Oil on canvas', 1000000), (2, 'Starry Night', 'Oil on canvas', 500000), (3, 'Dinosaur Fossil', 'Organic material', 800000);
|
What is the total value of art pieces by medium?
|
SELECT medium, SUM(value) FROM ArtPiecesValue GROUP BY medium;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name TEXT, location TEXT, labor_productivity INT, year INT); INSERT INTO mine (id, name, location, labor_productivity, year) VALUES (1, 'Emerald Edge', 'OR', 125, 2022), (2, 'Sapphire Slope', 'WA', 140, 2022), (3, 'Ruby Ridge', 'ID', 110, 2022), (4, 'Topaz Terrace', 'UT', 135, 2022), (5, 'Amethyst Acre', 'NV', 150, 2022);
|
Calculate the average labor productivity for each mine in 2022
|
SELECT name, AVG(labor_productivity) FROM mine WHERE year = 2022 GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_initiatives (initiative_id INT, site_id INT, initiative_date DATE, initiative_description TEXT);
|
Insert new pollution control initiative records for the given sites and dates.
|
INSERT INTO pollution_initiatives (initiative_id, site_id, initiative_date, initiative_description) VALUES (1, 1, '2022-08-01', 'Installed new filters'), (2, 3, '2022-07-15', 'Regular cleaning schedule established');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Meat (product_type VARCHAR(50), volume_sold INT, organic BOOLEAN, sale_date DATE); INSERT INTO Meat (product_type, volume_sold, organic, sale_date) VALUES ('Chicken', 150, 1, '2022-01-01'), ('Beef', 200, 0, '2022-01-01'), ('Pork', 100, 1, '2022-01-02');
|
What is the total volume of organic meat sold in France in the last month?
|
SELECT SUM(volume_sold) AS total_volume FROM Meat WHERE organic = 1 AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Users (UserID INT, Country VARCHAR(255), Devices INT); INSERT INTO Users (UserID, Country, Devices) VALUES (1, 'USA', 3), (2, 'Canada', 2), (3, 'USA', 1);
|
What is the maximum number of devices owned by users in each country?
|
SELECT Country, MAX(Devices) FROM Users GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations_causes (donation_id INT, cause_id INT, amount DECIMAL(10,2)); INSERT INTO donations_causes (donation_id, cause_id, amount) VALUES (1, 1, 500.00), (2, 2, 300.00), (3, 1, 250.00), (4, 3, 400.00);
|
What is the percentage of donations made to education causes?
|
SELECT 100.00 * SUM(CASE WHEN cause_id = 1 THEN amount ELSE 0 END) / SUM(amount) as education_percentage FROM donations_causes;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA IF NOT EXISTS cybersecurity_strategies; CREATE TABLE IF NOT EXISTS strategy_risk (id INT PRIMARY KEY, name TEXT, category TEXT, risk_rating INT); INSERT INTO strategy_risk (id, name, category, risk_rating) VALUES (1, 'Firewalls', 'Network Security', 2), (2, 'Penetration Testing', 'Vulnerability Management', 5), (3, 'Intrusion Detection Systems', 'Network Security', 3);
|
What is the name and category of the cybersecurity strategy with the lowest risk rating?
|
SELECT name, category FROM cybersecurity_strategies.strategy_risk WHERE risk_rating = (SELECT MIN(risk_rating) FROM cybersecurity_strategies.strategy_risk);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AstronautMedicalData (AstronautName VARCHAR(255), MedicalIssue VARCHAR(255), MedicalDate DATE); INSERT INTO AstronautMedicalData (AstronautName, MedicalIssue, MedicalDate) VALUES ('Neil Armstrong', 'Allergies', '1968-12-12'), ('Buzz Aldrin', 'Anxiety', '1968-11-11');
|
Update the medical data of astronaut 'Sally Ride' to include a new medical record with a medical issue of 'Asthma' and a medical date of '1983-06-18'.
|
INSERT INTO AstronautMedicalData (AstronautName, MedicalIssue, MedicalDate) SELECT 'Sally Ride', 'Asthma', '1983-06-18' FROM AstronautMedicalData WHERE AstronautName = 'Sally Ride' LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerSizes (id INT, size VARCHAR(255), country VARCHAR(255), percentage DECIMAL(4,2)); INSERT INTO CustomerSizes (id, size, country, percentage) VALUES (1, 'XS', 'UK', 5.00), (2, 'S', 'Canada', 10.00), (3, 'M', 'France', 20.00); CREATE TABLE CustomerInterests (id INT, interest VARCHAR(255), country VARCHAR(255), percentage DECIMAL(4,2)); INSERT INTO CustomerInterests (id, interest, country, percentage) VALUES (1, 'Sustainable Fashion', 'Canada', 25.00), (2, 'Fast Fashion', 'Canada', 60.00), (3, 'Ethical Fashion', 'Canada', 15.00);
|
What is the most popular size among customers interested in sustainable fashion in Canada?
|
SELECT c.size, MAX(c.percentage) AS popularity FROM CustomerSizes c INNER JOIN CustomerInterests ci ON c.country = ci.country WHERE ci.interest IN ('Sustainable Fashion', 'Ethical Fashion') AND c.country = 'Canada' GROUP BY c.size;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_calls (id INT, region VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, region, response_time) VALUES (1, 'Coastal', 90);
|
What is the minimum response time for emergency calls in the 'Coastal' region?
|
SELECT MIN(response_time) FROM emergency_calls WHERE region = 'Coastal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cities (City varchar(20), Population int); CREATE TABLE Affordability (City varchar(20), Index int); INSERT INTO Cities (City, Population) VALUES ('Los Angeles', 4000000); INSERT INTO Cities (City, Population) VALUES ('San Francisco', 800000); INSERT INTO Affordability (City, Index) VALUES ('Los Angeles', 150); INSERT INTO Affordability (City, Index) VALUES ('San Francisco', 180);
|
What is the average housing affordability index for each city with a population over 1 million?
|
SELECT Cities.City, AVG(Affordability.Index) FROM Cities INNER JOIN Affordability ON Cities.City = Affordability.City WHERE Cities.Population > 1000000 GROUP BY Cities.City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255), production_cost DECIMAL(5,2)); INSERT INTO products (product_id, product_name, category, production_cost) VALUES (1, 'Eco-Friendly Bowl', 'Home & Kitchen', 4.50); INSERT INTO products (product_id, product_name, category, production_cost) VALUES (2, 'Sustainable Cutlery Set', 'Home & Kitchen', 12.99);
|
What is the minimum production cost for products in the 'Home & Kitchen' category?
|
SELECT MIN(production_cost) FROM products WHERE category = 'Home & Kitchen';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE languages_oceania (id INT, language VARCHAR(255), native_speakers INT, country VARCHAR(255)); INSERT INTO languages_oceania (id, language, native_speakers, country) VALUES (1, 'Maori', 6000, 'New Zealand'), (2, 'Hawaiian', 4000, 'Hawaii');
|
What is the total number of languages spoken in Oceania with more than 5000 native speakers?
|
SELECT SUM(native_speakers) FROM languages_oceania WHERE country LIKE 'Oceania%' GROUP BY country HAVING SUM(native_speakers) > 5000;
|
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.