context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE farmers (id INT, name VARCHAR(50), acres FLOAT, country VARCHAR(50)); INSERT INTO farmers (id, name, acres, country) VALUES (1, 'Ram', 5.0, 'Nepal'); CREATE TABLE innovative_practices (farmer_id INT, practice VARCHAR(50)); INSERT INTO innovative_practices (farmer_id, practice) VALUES (1, 'System of Rice Intensification');
|
List the names of all farmers in Nepal who have adopted innovative agricultural practices and the number of acres they cultivate?
|
SELECT f.name, f.acres FROM farmers f INNER JOIN innovative_practices ip ON f.id = ip.farmer_id WHERE f.country = 'Nepal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_preferences (product_id INT, product_name VARCHAR(255), preference_score FLOAT, organic BOOLEAN);
|
What are the average preference scores for organic cosmetic products?
|
SELECT AVG(preference_score) FROM consumer_preferences WHERE organic = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu (menu_id INT PRIMARY KEY, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
|
How many items are there in each category?
|
SELECT category, COUNT(*) FROM Menu GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Platform (PlatformID INT, Name VARCHAR(50), Revenue INT);
|
What is the total revenue for each platform?
|
SELECT Platform.Name, SUM(Platform.Revenue) as TotalRevenue FROM Platform GROUP BY Platform.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE institution (institution_id INT, institution_name VARCHAR(255)); CREATE TABLE open_pedagogy_courses (institution_id INT, course_id INT); INSERT INTO institution (institution_id, institution_name) VALUES (2001, 'Institution X'), (2002, 'Institution Y'), (2003, 'Institution Z'); INSERT INTO open_pedagogy_courses (institution_id, course_id) VALUES (2001, 3001), (2001, 3002), (2002, 3003);
|
What is the total number of open pedagogy courses offered by each institution?
|
SELECT institution_name, COUNT(course_id) as total_courses FROM institution JOIN open_pedagogy_courses ON institution.institution_id = open_pedagogy_courses.institution_id GROUP BY institution_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkersCanada (WorkerID INT, Age INT, Gender VARCHAR(10), Province VARCHAR(2)); INSERT INTO CommunityHealthWorkersCanada (WorkerID, Age, Gender, Province) VALUES (1, 35, 'F', 'ON'), (2, 40, 'M', 'QC'), (3, 45, 'F', 'BC');
|
Update the Gender of the community health worker with Age 45 in 'BC' province to 'Non-binary'.
|
UPDATE CommunityHealthWorkersCanada SET Gender = 'Non-binary' WHERE Age = 45 AND Province = 'BC';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Knights'), (2, 'Lions'), (3, 'Titans'); CREATE TABLE events (event_id INT, team_id INT, num_tickets_sold INT); INSERT INTO events (event_id, team_id, num_tickets_sold) VALUES (1, 1, 500), (2, 1, 700), (3, 2, 600), (4, 3, 800), (5, 3, 900);
|
Which teams have a higher average ticket sales than the average ticket sales for all teams?
|
SELECT e.team_id, AVG(e.num_tickets_sold) as avg_tickets_sold FROM events e GROUP BY e.team_id HAVING AVG(e.num_tickets_sold) > (SELECT AVG(e.num_tickets_sold) FROM events e);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtPieces (id INT, artist VARCHAR(255), type VARCHAR(255), price FLOAT); INSERT INTO ArtPieces (id, artist, type, price) VALUES (1, 'Picasso', 'Painting', 1000), (2, 'Michelangelo', 'Sculpture', 1500), (3, 'Van Gogh', 'Painting', 800);
|
What is the average price of traditional art pieces by artist and their total number?
|
SELECT artist, AVG(price), COUNT(*) FROM ArtPieces GROUP BY artist;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicles (Vehicle VARCHAR(50), Manufacturer VARCHAR(50), Year INT, Range INT, Country VARCHAR(50)); INSERT INTO ElectricVehicles (Vehicle, Manufacturer, Year, Range, Country) VALUES ('Chevy Bolt EV', 'Chevrolet', 2022, 259, 'USA'); CREATE VIEW VehicleCountries AS SELECT Vehicle, Country FROM ElectricVehicles;
|
Find the most popular electric vehicle model in each country
|
SELECT Vehicle, Country, COUNT(*) as num_of_vehicles FROM VehicleCountries GROUP BY Vehicle, Country HAVING COUNT(*) = (SELECT MAX(num_of_vehicles) FROM (SELECT Vehicle, Country, COUNT(*) as num_of_vehicles FROM VehicleCountries GROUP BY Vehicle, Country) as VCGroup) GROUP BY Vehicle, Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE visual_arts_programs (id INT, visitor_age INT, underrepresented_community BOOLEAN, visit_date DATE); CREATE TABLE workshops (id INT, visitor_age INT, underrepresented_community BOOLEAN, visit_date DATE);
|
What is the total number of visitors from underrepresented communities for visual arts programs and workshops, separated by age group?
|
SELECT 'Visual Arts Programs' AS event, visitor_age, COUNT(*) AS total FROM visual_arts_programs WHERE underrepresented_community = TRUE GROUP BY visitor_age UNION ALL SELECT 'Workshops' AS event, visitor_age, COUNT(*) AS total FROM workshops WHERE underrepresented_community = TRUE GROUP BY visitor_age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crime_rates (id INT, state VARCHAR(20), rate_per_1000_residents INT); INSERT INTO crime_rates (id, state, rate_per_1000_residents) VALUES (1, 'California', 18), (2, 'California', 15), (3, 'New York', 22), (4, 'New York', 20);
|
What is the minimum crime rate per 1000 residents in the state of California and in New York?
|
SELECT MIN(rate_per_1000_residents) FROM crime_rates WHERE state IN ('California', 'New York');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Permit_Data_LA (PermitID INT, City VARCHAR(50), Quarter INT, Year INT, Cost FLOAT);
|
What is the total cost of construction permits issued in Los Angeles in Q2 of 2019?
|
SELECT SUM(Cost) FROM Permit_Data_LA WHERE City = 'Los Angeles' AND Quarter = 2 AND Year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_sales(menu_category VARCHAR(50), sales INT); INSERT INTO menu_sales VALUES ('Appetizers', 300), ('Entrees', 800), ('Desserts', 500);
|
What is the total sales for each menu category, ordered by total sales in descending order?
|
SELECT menu_category, SUM(sales) AS total_sales FROM menu_sales GROUP BY menu_category ORDER BY total_sales DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment (equipment_id INT, name VARCHAR(255), type VARCHAR(255), maintenance_cost DECIMAL(10,2), state VARCHAR(2)); CREATE TABLE maintenance_requests (request_id INT, equipment_id INT, request_date DATE, branch VARCHAR(255));
|
Count the number of military equipment maintenance requests for each type of equipment in the state of New York
|
SELECT equipment_type, COUNT(*) as num_requests FROM military_equipment JOIN maintenance_requests ON military_equipment.equipment_id = maintenance_requests.equipment_id WHERE state = 'New York' GROUP BY equipment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stories (id INT, city VARCHAR(20), date DATE); CREATE TABLE categories (id INT, category VARCHAR(20)); INSERT INTO stories VALUES (2, 'Los Angeles', '2022-01-05'); INSERT INTO categories VALUES (2, 'international news');
|
Who are the top 3 cities with the most international news stories in the past month?
|
SELECT city, COUNT(*) as story_count FROM stories INNER JOIN categories ON stories.id = categories.id WHERE stories.date >= '2022-02-01' GROUP BY city ORDER BY story_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organic_farming (id INT, crop_type VARCHAR(255), yield INT);
|
What is the average yield of crops for each crop type in the organic farming dataset?
|
SELECT crop_type, AVG(yield) FROM organic_farming GROUP BY crop_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing_station (id INT, name TEXT, location TEXT); INSERT INTO community_policing_station (id, name, location) VALUES (1, 'Station A', 'City Center'), (2, 'Station B', 'North District'); CREATE TABLE emergency_incidents (id INT, station_id INT, type TEXT, date DATE); INSERT INTO emergency_incidents (id, station_id, type, date) VALUES (1, 1, 'Fire', '2021-01-01'), (2, 1, 'Theft', '2021-01-02'), (3, 2, 'Assault', '2021-01-03');
|
What is the total number of emergency incidents recorded per community policing station?
|
SELECT s.name, COUNT(e.id) as total_incidents FROM community_policing_station s JOIN emergency_incidents e ON s.id = e.station_id GROUP BY s.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE top_donors (donor_id INT, donor_name TEXT, total_donations DECIMAL(10,2)); INSERT INTO top_donors VALUES (1, 'John Doe', 1500.00), (2, 'Jane Smith', 700.00), (3, 'Alice Johnson', 800.00), (4, 'Bob Jones', 500.00);
|
List the top 3 donors by total donation amount and their respective rank.
|
SELECT donor_id, donor_name, total_donations, RANK() OVER (ORDER BY total_donations DESC) as donor_rank FROM top_donors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farming_system_data (farmer_id INT, farming_system TEXT, production INT); INSERT INTO farming_system_data (farmer_id, farming_system, production) VALUES (1, 'Agroforestry', 200), (2, 'Agroforestry', 250), (3, 'Permaculture', 150), (4, 'Permaculture', 180), (5, 'Organic', 220), (6, 'Organic', 250), (7, 'Conventional', 170), (8, 'Conventional', 200);
|
What is the number of farmers in each farming system and the total production for each farming system?
|
SELECT farming_system, COUNT(*) as num_farmers, SUM(production) as total_production FROM farming_system_data GROUP BY farming_system;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (sale_id INT, dish_id INT, sale_date DATE); INSERT INTO sales_data (sale_id, dish_id, sale_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-05'), (3, 1, '2022-01-10'); CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255)); INSERT INTO menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'), (2, 'Chicken Sandwich', 'Non-Vegetarian');
|
Determine the dishes that have not been sold in the last 30 days
|
SELECT m.dish_id, m.dish_name FROM menu m LEFT JOIN sales_data s ON m.dish_id = s.dish_id WHERE s.sale_date < DATE_SUB(CURDATE(), INTERVAL 30 DAY) IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE field_sensors (field_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); INSERT INTO field_sensors (field_id, sensor_type, value, timestamp) VALUES (1, 'temperature', 22.5, '2021-03-01 10:00:00'), (1, 'humidity', 60.0, '2021-03-01 10:00:00');
|
Find the average temperature and humidity for the crops in field 1 during March 2021.
|
SELECT AVG(value) FROM field_sensors WHERE field_id = 1 AND sensor_type IN ('temperature', 'humidity') AND MONTH(timestamp) = 3 AND YEAR(timestamp) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExcavationSites (site_id INT, site_name TEXT, period TEXT); INSERT INTO ExcavationSites (site_id, site_name, period) VALUES (1, 'SiteA', 'Stone Age'), (2, 'SiteB', 'Iron Age'); CREATE TABLE Artifacts (artifact_id INT, site_id INT, artifact_name TEXT); INSERT INTO Artifacts (artifact_id, site_id, artifact_name) VALUES (1, 1, 'Artifact1'), (2, 1, 'Artifact2'), (3, 2, 'Artifact3');
|
Add a new excavation site 'SiteG' from the 'Stone Age' period and related artifacts.
|
INSERT INTO ExcavationSites (site_id, site_name, period) VALUES (3, 'SiteG', 'Stone Age'); INSERT INTO Artifacts (artifact_id, site_id, artifact_name) VALUES (4, 3, 'Artifact4'), (5, 3, 'Artifact5');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA forestry; CREATE TABLE trees (id INT, species VARCHAR(50), age INT); INSERT INTO trees (id, species, age) VALUES (1, 'oak', 50), (2, 'pine', 30), (3, 'eucalyptus', 15);
|
find the average age of trees in the forestry schema, excluding eucalyptus trees
|
SELECT AVG(age) FROM forestry.trees WHERE species NOT IN ('eucalyptus');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE listeners (id INT, artist_id INT, platform VARCHAR(255), date DATE, listeners INT); INSERT INTO listeners (id, artist_id, platform, date, listeners) VALUES (1, 1, 'Spotify', '2021-01-01', 100000);
|
What is the average number of monthly listeners for country music artists on Spotify in 2021?
|
SELECT AVG(listeners) FROM listeners WHERE platform = 'Spotify' AND genre = 'Country' AND YEAR(date) = 2021 GROUP BY artist_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT, name VARCHAR(50), organic_produce_percentage DECIMAL(5,2)); INSERT INTO suppliers (id, name, organic_produce_percentage) VALUES (1, 'ABC Farms', 0.6), (2, 'XYZ Orchards', 0.45), (3, 'Green Grocers', 0.9); CREATE TABLE stores (id INT, country VARCHAR(50), supplier_id INT); INSERT INTO stores (id, country, supplier_id) VALUES (1, 'France', 1), (2, 'Germany', 2), (3, 'Italy', 3);
|
Which suppliers provide more than 50% of the organic produce for our stores in the EU?
|
SELECT suppliers.name FROM suppliers JOIN stores ON suppliers.id = stores.supplier_id WHERE stores.country LIKE 'EU%' AND suppliers.organic_produce_percentage > 0.5 GROUP BY suppliers.name HAVING COUNT(DISTINCT stores.id) > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Tilapia_Farms (Farm_ID INT, Farm_Name TEXT, Water_Temperature FLOAT); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Water_Temperature) VALUES (1, 'Farm A', 28.5); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Water_Temperature) VALUES (2, 'Farm B', 29.0); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Water_Temperature) VALUES (3, 'Farm C', 29.5);
|
What is the minimum and maximum water temperature in Tilapia Farms?
|
SELECT MIN(Water_Temperature), MAX(Water_Temperature) FROM Tilapia_Farms;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecrafts (Id INT, Agency VARCHAR(50), Mission VARCHAR(50), LaunchYear INT, Status VARCHAR(10)); INSERT INTO Spacecrafts (Id, Agency, Mission, LaunchYear, Status) VALUES (1, 'NASA', 'Voyager 1', 1977, 'Active'), (2, 'NASA', 'Voyager 2', 1977, 'Active'), (3, 'NASA', 'New Horizons', 2006, 'Active'), (4, 'ESA', 'Cassini-Huygens', 1997, 'Inactive'), (5, 'JAXA', 'Hayabusa', 2003, 'Inactive'), (6, 'JAXA', 'Hayabusa2', 2014, 'Active');
|
Identify the space agencies with the most spacecraft in deep space.
|
SELECT Agency, COUNT(*) as DeepSpaceMissions FROM Spacecrafts WHERE Status = 'Active' GROUP BY Agency ORDER BY DeepSpaceMissions DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exploration_activities (activity_id INT, platform_id INT, activity_start_date DATE, activity_end_date DATE); INSERT INTO exploration_activities (activity_id, platform_id, activity_start_date, activity_end_date) VALUES (1, 1, '2020-01-01', '2020-02-01'), (2, 2, '2021-01-01', '2021-03-01');
|
Identify the exploration activities for each platform, indicating the start and end date of each activity
|
SELECT platform_id, activity_start_date, activity_end_date FROM exploration_activities;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT, company_name VARCHAR(100), region VARCHAR(50), employees_of_color INT, women_in_tech INT); INSERT INTO diversity_metrics (id, company_name, region, employees_of_color, women_in_tech) VALUES (1, 'Acme Inc.', 'Europe', 15, 22), (2, 'Bravo Corp.', 'North America', 35, 18);
|
Update all records in the "diversity_metrics" table, setting the 'women_in_tech' to 0
|
UPDATE diversity_metrics SET women_in_tech = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_revenue (id INT, game VARCHAR(20), release_date DATE, revenue INT); INSERT INTO game_revenue (id, game, release_date, revenue) VALUES (1, 'Game1', '2020-01-01', 100), (2, 'Game2', '2021-01-01', 200), (3, 'Game3', '2019-01-01', 300);
|
What is the total revenue generated by games released in the last 2 years?
|
SELECT SUM(revenue) FROM game_revenue WHERE release_date >= DATEADD(year, -2, CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DefenseProjects (project_name VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO DefenseProjects (project_name, start_date, end_date, budget) VALUES ('Project A', '2018-01-01', '2019-12-31', 1200000000);
|
List all defense projects that have a budget greater than 1,000,000,000 and have been completed before 2020.
|
SELECT * FROM DefenseProjects WHERE budget > 1000000000 AND end_date < '2020-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE construction_projects (project_id INT, city VARCHAR(20), state VARCHAR(20), value DECIMAL(10,2)); INSERT INTO construction_projects (project_id, city, state, value) VALUES (1, 'San Francisco', 'CA', 1000000.00), (2, 'Los Angeles', 'CA', 2000000.00);
|
Get the total value of construction projects in California, grouped by city
|
SELECT city, SUM(value) FROM construction_projects WHERE state = 'CA' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_costs (project_id INT, sector VARCHAR(50), labor_cost FLOAT, year INT); INSERT INTO labor_costs (project_id, sector, labor_cost, year) VALUES (1, 'Sustainable', 30000, 2022), (2, 'Conventional', 25000, 2022), (3, 'Sustainable', 35000, 2022);
|
List the total labor costs for each sector in 2022.
|
SELECT sector, SUM(labor_cost) FROM labor_costs WHERE year = 2022 GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soil_moisture_sensors (sensor_id VARCHAR(10), moisture_level INT);
|
Add a new soil moisture reading of 42 for sensor S102
|
INSERT INTO soil_moisture_sensors (sensor_id, moisture_level) VALUES ('S102', 42);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE career_medals (id INT, athlete_name VARCHAR(50), sport VARCHAR(20), medals INT);
|
What is the total number of medals won by a specific athlete in their career?
|
SELECT SUM(medals) FROM career_medals WHERE athlete_name = 'Usain Bolt' AND sport = 'Athletics';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (project_id INT, project_category VARCHAR(255), project_name VARCHAR(255), num_volunteers INT); INSERT INTO projects (project_id, project_category, project_name, num_volunteers) VALUES (1, 'Education', 'Coding for Kids', 20), (2, 'Education', 'Web Development', 30), (3, 'Environment', 'Tree Planting', 40), (4, 'Environment', 'Clean Up Drives', 50), (5, 'Technology', 'Digital Literacy', 15), (6, 'Technology', 'Cybersecurity Awareness', 25);
|
How many volunteers were there in each project category in the 'projects' table?
|
SELECT project_category, SUM(num_volunteers) AS total_volunteers FROM projects GROUP BY project_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (id INT, name STRING, length FLOAT, type STRING); INSERT INTO routes (id, name, length, type) VALUES (302, 'Blue Line', 24.5, 'Train');
|
What is the total distance traveled for each route type?
|
SELECT type, SUM(length) as total_distance FROM routes GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stores (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(10,2), supplier_id INT); CREATE TABLE supplier_location (supplier_id INT, country VARCHAR(255));
|
List all stores located in California that carry products from suppliers located in the European Union.
|
SELECT s.name FROM stores s JOIN (SELECT DISTINCT store_id FROM products p JOIN supplier_location sl ON p.supplier_id = sl.supplier_id WHERE sl.country IN ('Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden')) ss ON s.id = ss.store_id WHERE s.state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO customers (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Jim Brown', 'UK'), (4, 'Hiroshi Nakamura', 'Japan'); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10, 2)); INSERT INTO transactions (id, customer_id, amount) VALUES (1, 1, 1200.00), (2, 1, 800.00), (3, 2, 500.00), (4, 4, 200.00), (5, 4, 150.00);
|
What is the total number of transactions for customers from Japan?
|
SELECT COUNT(t.id) FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE c.country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GreenBuildings ( id INT, name VARCHAR(50), squareFootage INT, certification VARCHAR(10), budget DECIMAL(10,2) ); INSERT INTO GreenBuildings (id, name, squareFootage, certification, budget) VALUES (1, 'EcoTower', 50000, 'Green-Star', 15000000.00), (2, 'GreenHaven', 35000, 'Green-Star', 9000000.00), (3, 'GreenParadise', 60000, 'Green-Star', 12000000.00);
|
What is the maximum budget (in USD) for Green-Star certified buildings in the 'GreenBuildings' table?
|
SELECT MAX(budget) FROM GreenBuildings WHERE certification = 'Green-Star';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerAge INT, Game VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerAge, Game) VALUES (1, 23, 'MapleStory'), (2, 27, 'Fortnite');
|
What is the average age of players who played MapleStory in Canada?
|
SELECT AVG(PlayerAge) FROM Players WHERE Game = 'MapleStory' AND Country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, Name TEXT, Address TEXT); INSERT INTO Donors (DonorID, Name, Address) VALUES (1, 'John Doe', '123 Main St'); INSERT INTO Donors (DonorID, Name, Address) VALUES (2, 'Jane Smith', '456 Elm St'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL, DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 50.00, '2021-01-01'); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (2, 1, 75.00, '2021-03-15'); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (3, 2, 100.00, '2021-12-31');
|
Find the total amount donated by each donor in 2021, ordered by the total donation amount in descending order.
|
SELECT DonorID, SUM(Amount) as TotalDonated FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID ORDER BY TotalDonated DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityDevelopment (id INT, location VARCHAR(20), initiative_count INT, year INT); INSERT INTO CommunityDevelopment (id, location, initiative_count, year) VALUES (1, 'Pacific Islands', 20, 2017), (2, 'Caribbean Islands', 30, 2018), (3, 'Atlantic Islands', 15, 2019);
|
How many community development initiatives were implemented in the Pacific Islands in 2017?
|
SELECT SUM(initiative_count) FROM CommunityDevelopment WHERE location = 'Pacific Islands' AND year = 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species (Name VARCHAR(50) PRIMARY KEY, Population INT); INSERT INTO Species (Name, Population) VALUES ('Coral', 2000), ('Whale Shark', 1500);
|
Count the number of species records
|
SELECT COUNT(*) FROM Species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FashionTrends (TrendID INT, TrendName VARCHAR(255), Quarter VARCHAR(255), FabricSource VARCHAR(255)); INSERT INTO FashionTrends (TrendID, TrendName, Quarter, FabricSource) VALUES (1, 'Trend1', 'Q1', 'Local');
|
Calculate the percentage of sales by quarter, for each fashion trend, where the fabric is locally sourced.
|
SELECT TrendName, Quarter, SUM(CASE WHEN FabricSource = 'Local' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as LocalSalesPercentage FROM FashionTrends GROUP BY TrendName, Quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, city TEXT, revenue DECIMAL(6,2)); INSERT INTO eco_hotels (hotel_id, name, city, revenue) VALUES (1, 'Green Hotel', 'Paris', 80000.00), (2, 'Eco Lodge', 'Rome', 65000.00);
|
Insert a new eco-friendly hotel, 'Eco Paradise', in Tokyo with a revenue of 75000.00.
|
INSERT INTO eco_hotels (name, city, revenue) VALUES ('Eco Paradise', 'Tokyo', 75000.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, condition TEXT); INSERT INTO patients (id, name, age, condition) VALUES (1, 'John Doe', 30, 'Anxiety Disorder'); INSERT INTO patients (id, name, age, condition) VALUES (2, 'Jane Smith', 45, 'Depression');
|
Update the condition of patient Jane Smith to 'Generalized Anxiety Disorder'
|
UPDATE patients SET condition = 'Generalized Anxiety Disorder' WHERE name = 'Jane Smith';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AnimalHabitats (id INT PRIMARY KEY, species VARCHAR(50), habitat VARCHAR(50));
|
Determine the number of unique habitats where each species is present, and display the results in a table format with species and their respective number of habitats.
|
SELECT AnimalHabitats.species, COUNT(DISTINCT AnimalHabitats.habitat) FROM AnimalHabitats GROUP BY AnimalHabitats.species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wastewater_treatment (plant_id INT PRIMARY KEY, location VARCHAR(50), capacity INT);
|
Insert a new record in the 'wastewater_treatment' table with the following data: plant_id = 3, location = 'North Bay', capacity = 1000000
|
INSERT INTO wastewater_treatment (plant_id, location, capacity) VALUES (3, 'North Bay', 1000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_mass (satellite_name TEXT, orbit_type TEXT, satellite_weight REAL); INSERT INTO satellite_mass (satellite_name, orbit_type, satellite_weight) VALUES ('ISS', 'Low Earth Orbit', 419500), ('Hubble', 'Low Earth Orbit', 11000);
|
What is the average mass of a satellite in low Earth orbit?
|
SELECT AVG(satellite_weight) FROM satellite_mass WHERE orbit_type = 'Low Earth Orbit';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT); INSERT INTO patients (id, name, age, treatment) VALUES (1, 'John Doe', 35, 'CBT'), (2, 'Jane Smith', 40, 'DBT');
|
What is the average age of patients who received CBT?
|
SELECT AVG(age) FROM patients WHERE treatment = 'CBT';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project_timeline (project_id INT, city VARCHAR(20), project_type VARCHAR(20), timeline_in_months INT); INSERT INTO project_timeline (project_id, city, project_type, timeline_in_months) VALUES (1, 'Chicago', 'Sustainable', 18), (2, 'Chicago', 'Conventional', 20), (3, 'New York', 'Sustainable', 22), (4, 'Los Angeles', 'Sustainable', 24), (5, 'Chicago', 'Sustainable', 26), (6, 'Chicago', 'Conventional', 19);
|
What is the average project timeline in months for sustainable building projects in the city of Chicago?
|
SELECT city, AVG(timeline_in_months) FROM project_timeline WHERE city = 'Chicago' AND project_type = 'Sustainable' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (location VARCHAR(255), revenue FLOAT, month VARCHAR(9)); INSERT INTO restaurant_revenue (location, revenue, month) VALUES ('Quebec', 12000, 'June-2022'), ('Montreal', 15000, 'June-2022');
|
What was the total revenue for Quebec in June 2022?
|
SELECT SUM(revenue) FROM restaurant_revenue WHERE location = 'Quebec' AND month = 'June-2022';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Forests (id INT, name VARCHAR(50), country VARCHAR(50), hectares INT, year_established INT); CREATE TABLE Climate (id INT, temperature FLOAT, year INT, forest_id INT); INSERT INTO Forests (id, name, country, hectares, year_established) VALUES (1, 'Bialowieza', 'Poland', 141000, 1921), (2, 'Amazon', 'Brazil', 340000, 1968), (3, 'Daintree', 'Australia', 12000, 1770); INSERT INTO Climate (id, temperature, year, forest_id) VALUES (1, 15.5, 1921, 1), (2, 28.7, 2005, 2), (3, 34.1, 1998, 3), (4, 26.3, 1982, 2);
|
What is the name of the forest where the highest temperature was recorded and it was established after the average year of establishment?
|
SELECT Forests.name FROM Forests, Climate WHERE Forests.id = Climate.forest_id AND temperature = (SELECT MAX(temperature) FROM Climate) AND year_established > (SELECT AVG(year_established) FROM Forests);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GreenBuildings (id INT, building_id INT, address VARCHAR(100), green_certification VARCHAR(50));
|
Update the address for properties with the green_certification 'LEED' to 'Green Certified'.
|
UPDATE GreenBuildings SET address = 'Green Certified' WHERE green_certification = 'LEED';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists sales (sale_id serial PRIMARY KEY, sale_date date, title varchar(255), revenue decimal(10,2));
|
Insert a new record for the album 'Thriller' with 30,000,000 sales in 1982-12-15
|
insert into sales (sale_date, title, revenue) values ('1982-12-15', 'Thriller', 30000000 * 0.01);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (initiative VARCHAR(255), country VARCHAR(255)); CREATE TABLE country_populations (country VARCHAR(255), population INT);
|
Which countries have the most carbon offset initiatives, and how many initiatives are there in each country?
|
SELECT country, COUNT(initiative) as num_initiatives FROM carbon_offsets GROUP BY country ORDER BY num_initiatives DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE disability_support_programs (id INT, state VARCHAR(255), program_name VARCHAR(255)); INSERT INTO disability_support_programs (id, state, program_name) VALUES (1, 'California', 'Accessible Technology Initiative'); INSERT INTO disability_support_programs (id, state, program_name) VALUES (2, 'Texas', 'Promoting the Readiness of Minors in Supplemental Security Income');
|
Find the total number of disability support programs in California and Texas.
|
SELECT SUM(total) FROM (SELECT COUNT(*) AS total FROM disability_support_programs WHERE state = 'California' UNION ALL SELECT COUNT(*) AS total FROM disability_support_programs WHERE state = 'Texas') AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Agricultural_Projects (Project_ID INT, Project_Name TEXT, Location TEXT, Status TEXT, Led_By TEXT, Year INT); INSERT INTO Agricultural_Projects (Project_ID, Project_Name, Location, Status, Led_By, Year) VALUES (1, 'Crop Diversification', 'Nigeria', 'Completed', 'Women', 2019), (2, 'Livestock Improvement', 'Kenya', 'Completed', 'Women', 2019);
|
What is the number of agricultural projects in Nigeria and Kenya led by women that were completed in 2019?
|
SELECT COUNT(*) FROM Agricultural_Projects WHERE Status = 'Completed' AND Led_By = 'Women' AND Year = 2019 AND Location IN ('Nigeria', 'Kenya');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donor_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO Donations (donor_id, donation_amount, donation_date) VALUES (1, 500, '2020-01-01'), (2, 300, '2020-02-03'), (1, 700, '2020-12-31');
|
How many donations were made by each donor in the year 2020?
|
SELECT donor_id, SUM(donation_amount) as total_donations FROM Donations WHERE YEAR(donation_date) = 2020 GROUP BY donor_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emission_reduction (reduction_id INT, country_id INT, co2_reduction FLOAT); INSERT INTO co2_emission_reduction VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000), (4, 3, 8000);
|
What is the total CO2 emission reduction per country?
|
SELECT country_id, SUM(co2_reduction) as total_reduction FROM co2_emission_reduction GROUP BY country_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy_initiatives (city VARCHAR(50), initiative_date DATE, initiative_type VARCHAR(50)); INSERT INTO circular_economy_initiatives (city, initiative_date, initiative_type) VALUES ('Tokyo', '2021-03-15', 'Recycling Program'), ('Tokyo', '2020-08-01', 'Composting Program'), ('Tokyo', '2019-12-01', 'Waste Reduction Campaign');
|
How many circular economy initiatives were implemented in Tokyo by 2022?
|
SELECT COUNT(*) FROM circular_economy_initiatives WHERE city = 'Tokyo' AND initiative_date <= '2022-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtAccommodations (AccommodationID INT, Department VARCHAR(20)); INSERT INTO ArtAccommodations (AccommodationID, Department) VALUES (1, 'Art'), (2, 'Art'), (3, 'Art'); CREATE TABLE PhysicalEducationAccommodations (AccommodationID INT, Department VARCHAR(20)); INSERT INTO PhysicalEducationAccommodations (AccommodationID, Department) VALUES (4, 'Physical Education'), (5, 'Physical Education'), (6, 'Physical Education');
|
What is the total number of accommodations provided in the Art department, and the total number of accommodations provided in the Physical Education department?
|
SELECT COUNT(*) FROM ArtAccommodations WHERE Department = 'Art' UNION SELECT COUNT(*) FROM PhysicalEducationAccommodations WHERE Department = 'Physical Education';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_transit (id INT PRIMARY KEY, agency VARCHAR(255), line VARCHAR(255), route_id VARCHAR(255), stop_id VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), passengers INT); INSERT INTO public_transit (id, agency, line, route_id, stop_id, city, state, country, passengers) VALUES (1, 'SF Muni', 'N Judah', '123', '456', 'San Francisco', 'California', 'USA', 50);
|
Show all records from the public transportation usage table
|
SELECT * FROM public_transit;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subway_systems (id INT, country VARCHAR(255), total_length INT); INSERT INTO subway_systems (id, country, total_length) VALUES (1, 'South Korea', 960), (2, 'China', 5600), (3, 'Japan', 1270), (4, 'India', 290);
|
What is the total length of subway systems in South Korea and China?
|
SELECT SUM(total_length) FROM subway_systems WHERE country IN ('South Korea', 'China');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE parisian_transportation (route_id INT, trips_taken INT, fare_collected DECIMAL(5,2)); INSERT INTO parisian_transportation (route_id, trips_taken, fare_collected) VALUES (4, 700, 1625.00), (5, 800, 2350.00), (6, 650, 1425.00);
|
Calculate the average fare and number of trips per route in the Parisian public transportation
|
SELECT route_id, AVG(trips_taken) as average_trips, AVG(fare_collected) as average_fare FROM parisian_transportation GROUP BY route_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT, name TEXT, city TEXT); INSERT INTO teams (id, name, city) VALUES (1, 'Boston Celtics', 'Boston'), (2, 'NY Knicks', 'NY'), (3, 'LA Lakers', 'LA'), (4, 'Atlanta Hawks', 'Atlanta'), (5, 'Chicago Bulls', 'Chicago');
|
Delete all records of the 'Atlanta Hawks' in the 'teams' table.
|
DELETE FROM teams WHERE name = 'Atlanta Hawks';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (id INT, company_id INT, region TEXT); INSERT INTO regions (id, company_id, region) VALUES (1, 2, 'USA'), (2, 9, 'Canada');
|
Show companies in the education sector with ESG scores below 60 in North America.
|
SELECT * FROM companies WHERE sector = 'Education' AND ESG_score < 60 AND companies.country IN ('USA', 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodation (student_id INT, accommodation_type TEXT, accommodation_date DATE); INSERT INTO accommodation (student_id, accommodation_type, accommodation_date) VALUES (1, 'Tutoring', '2022-01-01'), (2, 'Quiet Space', '2022-02-01'), (3, 'Extended Testing Time', '2022-03-01'), (4, 'Tutoring', '2022-04-01');
|
Find the percentage of students with mental health disabilities who received tutoring or extended testing time.
|
SELECT COUNT(DISTINCT student_id) * 100.0 / (SELECT COUNT(DISTINCT student_id) FROM accommodation WHERE student_id IN (SELECT student_id FROM student WHERE disability = 'Mental Health')) as percentage FROM accommodation WHERE student_id IN (SELECT student_id FROM student WHERE disability = 'Mental Health') AND accommodation_type IN ('Tutoring', 'Extended Testing Time');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (project_id INT, project_name VARCHAR(50), region VARCHAR(30), mitigation BOOLEAN, completion_year INT); INSERT INTO project VALUES (1, 'Solar Farm', 'Latin America', true, 2012), (2, 'Wind Turbines', 'Caribbean', true, 2013), (3, 'Energy Efficiency', 'Latin America', false, 2011), (4, 'Carbon Capture', 'Caribbean', true, 2014);
|
How many climate mitigation projects were completed in Latin America and the Caribbean between 2010 and 2015?
|
SELECT COUNT(*) FROM project WHERE region IN ('Latin America', 'Caribbean') AND mitigation = true AND completion_year BETWEEN 2010 AND 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE boroughs (bid INT, name VARCHAR(255)); CREATE TABLE police_officers (oid INT, bid INT, rank VARCHAR(255)); CREATE TABLE firefighters (fid INT, bid INT, rank VARCHAR(255)); INSERT INTO boroughs VALUES (1, 'Manhattan'), (2, 'Brooklyn'); INSERT INTO police_officers VALUES (1, 1, 'Captain'), (2, 2, 'Lieutenant'); INSERT INTO firefighters VALUES (1, 1, 'Captain'), (2, 2, 'Lieutenant');
|
What is the total number of police officers and firefighters in each borough?
|
SELECT b.name, COUNT(po.oid) + COUNT(f.fid) as total_employees FROM boroughs b LEFT JOIN police_officers po ON b.bid = po.bid LEFT JOIN firefighters f ON b.bid = f.bid GROUP BY b.bid;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Horsepower INT);
|
Update the horsepower of the 'Chevrolet Bolt' to 266 in the 'GreenAutos' database.
|
UPDATE ElectricVehicles SET Horsepower = 266 WHERE Make = 'Chevrolet' AND Model = 'Bolt';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_mammals (mammal_id INT, name VARCHAR(50), population INT, habitat VARCHAR(50)); INSERT INTO marine_mammals (mammal_id, name, population, habitat) VALUES (1, 'Krill', 5000000000, 'Antarctic Region'), (2, 'Crabeater Seal', 2500000, 'Antarctic Region'), (3, 'Antarctic Fur Seal', 500000, 'Antarctic Region');
|
What is the minimum population size of all marine mammals in the Antarctic region?
|
SELECT MIN(population) FROM marine_mammals WHERE habitat = 'Antarctic Region';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID int, Community varchar(20), HourlyRate decimal(5,2)); INSERT INTO Attorneys (AttorneyID, Community, HourlyRate) VALUES (1, 'Indigenous', 300.00), (2, 'Middle Eastern', 250.00), (3, 'Pacific Islander', 350.00), (4, 'Caucasian', 200.00), (5, 'African', 400.00); CREATE TABLE Cases (CaseID int, AttorneyID int); INSERT INTO Cases (CaseID, AttorneyID) VALUES (1, 1), (2, 2), (3, 3), (4, 5), (5, 1), (6, 4);
|
What is the average billing amount for cases handled by attorneys from Indigenous communities?
|
SELECT AVG(HourlyRate * 8 * 22) AS AverageBillingAmount FROM Attorneys WHERE Community = 'Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE life_expectancy (id INT, country TEXT, years_of_life_expectancy INT); INSERT INTO life_expectancy (id, country, years_of_life_expectancy) VALUES (1, 'United States', 78), (2, 'Mexico', 75), (3, 'Canada', 82), (4, 'Brazil', 74), (5, 'Australia', 83), (6, 'Russia', 70), (7, 'China', 76), (8, 'India', 70), (9, 'Germany', 81), (10, 'France', 82);
|
What is the average life expectancy in each country in the world?
|
SELECT country, AVG(years_of_life_expectancy) FROM life_expectancy GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (post_id INT, post_country VARCHAR(255), post_topic VARCHAR(255), post_date DATE); CREATE TABLE user_interactions (interaction_id INT, user_id INT, post_id INT, interaction_type VARCHAR(10)); INSERT INTO posts (post_id, post_country, post_topic, post_date) VALUES (1, 'Brazil', 'social justice', '2023-01-01'), (2, 'Colombia', 'social justice', '2023-01-05'); INSERT INTO user_interactions (interaction_id, user_id, post_id, interaction_type) VALUES (1, 1, 1, 'like'), (2, 2, 1, 'share'), (3, 3, 2, 'comment');
|
How many users from Brazil and Colombia interacted with posts about social justice in the last month?
|
SELECT SUM(interaction_type = 'like') + SUM(interaction_type = 'share') + SUM(interaction_type = 'comment') AS total_interactions FROM user_interactions WHERE post_id IN (SELECT post_id FROM posts WHERE post_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND post_country IN ('Brazil', 'Colombia') AND post_topic = 'social justice');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing (spacecraft_model VARCHAR(255), spacecraft_country VARCHAR(255), cost INT); INSERT INTO SpacecraftManufacturing (spacecraft_model, spacecraft_country, cost) VALUES ('Apollo', 'USA', 25400000), ('Space Shuttle', 'USA', 192000000), ('Orion', 'USA', 15100000);
|
What is the total cost of SpacecraftManufacturing for US based spacecraft?
|
SELECT SUM(cost) FROM SpacecraftManufacturing WHERE spacecraft_country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountrySatellites (Country VARCHAR(50), Satellites INT); INSERT INTO CountrySatellites (Country, Satellites) VALUES ('USA', 1417), ('Russia', 1250), ('China', 413), ('India', 127), ('Japan', 125), ('Germany', 77), ('France', 66), ('Italy', 60), ('UK', 59), ('Canada', 54);
|
Find the number of satellites in orbit for each country and order them by the total number of satellites.
|
SELECT Country, Satellites, RANK() OVER (ORDER BY Satellites DESC) as Rank FROM CountrySatellites;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WinsStats (CharacterID int, CharacterName varchar(50), Wins int, Playtime decimal(10,2)); INSERT INTO WinsStats (CharacterID, CharacterName, Wins, Playtime) VALUES (1, 'Knight', 250, 100.25), (2, 'Mage', 225, 115.00), (3, 'Archer', 200, 120.50), (4, 'Healer', 175, 95.00), (5, 'Warrior', 150, 85.75), (6, 'Assassin', 125, 70.00);
|
What are the top 5 characters with the most wins, and their total playtime in hours?
|
SELECT ws.CharacterName, SUM(ws.Wins) as TotalWins, SUM(ws.Playtime / 60) as TotalPlaytimeInHours FROM WinsStats ws GROUP BY ws.CharacterName ORDER BY TotalWins DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm_iot_sensors (farm_id INTEGER, sensor_id INTEGER); INSERT INTO farm_iot_sensors VALUES (1, 101), (1, 102), (2, 201); CREATE TABLE farms (farm_id INTEGER, farm_name TEXT); INSERT INTO farms VALUES (1, 'Farm A'), (2, 'Farm B');
|
What is the total number of IoT sensors in each farm?
|
SELECT farm_name, COUNT(sensor_id) as total_sensors FROM farm_iot_sensors JOIN farms ON farm_iot_sensors.farm_id = farms.farm_id GROUP BY farm_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (id INT, name TEXT, year INT, art_style TEXT, num_artists INT); INSERT INTO Exhibitions (id, name, year, art_style, num_artists) VALUES (1, 'Exhibition1', 2000, 'Abstract Expressionism', 12), (2, 'Exhibition2', 2005, 'Cubism', 8), (3, 'Exhibition3', 2010, 'Abstract Expressionism', 20);
|
How many exhibitions featured more than 10 abstract expressionist artists?
|
SELECT COUNT(*) FROM Exhibitions WHERE art_style = 'Abstract Expressionism' GROUP BY art_style HAVING COUNT(*) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name VARCHAR(50), group VARCHAR(50), followers INT, posts INT, last_post_date DATE); INSERT INTO users (id, name, group, followers, posts, last_post_date) VALUES (1, 'Alice', 'influencer', 15000, 75, '2022-01-01'); INSERT INTO users (id, name, group, followers, posts, last_post_date) VALUES (2, 'Bob', 'influencer', 22000, 120, '2022-01-02'); INSERT INTO users (id, name, group, followers, posts, last_post_date) VALUES (3, 'Charlie', 'fan', 500, 20, '2022-01-03');
|
What is the average number of posts per day for users in the 'influencer' group, who have more than 10,000 followers and have posted more than 50 times in the last 30 days?
|
SELECT AVG(posts) FROM users WHERE group = 'influencer' AND followers > 10000 AND posts > 50 AND last_post_date >= DATEADD(day, -30, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TextileMills (id INT, mill VARCHAR(50), dye_type VARCHAR(50), quantity INT); INSERT INTO TextileMills (id, mill, dye_type, quantity) VALUES (1, 'Mill A', 'Natural Dye', 2000), (2, 'Mill B', 'Low-Impact Dye', 3000), (3, 'Mill C', 'Natural Dye', 1500);
|
What is the total quantity of eco-friendly dyes used by each textile mill, ordered from most to least?
|
SELECT mill, SUM(quantity) AS total_quantity FROM TextileMills WHERE dye_type IN ('Natural Dye', 'Low-Impact Dye') GROUP BY mill ORDER BY total_quantity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE matches (team VARCHAR(50), opponent VARCHAR(50), points_team INTEGER, points_opponent INTEGER, season VARCHAR(10)); INSERT INTO matches (team, opponent, points_team, points_opponent, season) VALUES ('Chicago Bulls', 'Charlotte Hornets', 103, 84, '1995-1996'), ('Chicago Bulls', 'Miami Heat', 112, 89, '1995-1996');
|
How many matches were played by the Chicago Bulls in the 1995-1996 NBA season and what was their average points difference?
|
SELECT COUNT(*), AVG(points_team - points_opponent) FROM matches WHERE team = 'Chicago Bulls' AND season = '1995-1996';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE food_safety_records (country VARCHAR(50), violations INT); INSERT INTO food_safety_records (country, violations) VALUES ('United States', 500), ('Canada', 300), ('Mexico', 700), ('Brazil', 400);
|
Which countries have the highest and lowest food safety violation rates?
|
SELECT country, violations FROM food_safety_records ORDER BY violations DESC LIMIT 1; SELECT country, violations FROM food_safety_records ORDER BY violations ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), call_date DATE); INSERT INTO emergency_calls (id, city, call_date) VALUES (1, 'Phoenix', '2021-01-01'), (2, 'Phoenix', '2021-01-03'), (3, 'Phoenix', '2021-01-05');
|
What is the total number of emergency calls in the city of Phoenix for each day of the week?
|
SELECT EXTRACT(DOW FROM call_date) as day_of_week, COUNT(*) FROM emergency_calls WHERE city = 'Phoenix' GROUP BY day_of_week;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ReaderDemographics (ReaderID INT, Age INT, PreferredNewsTopic VARCHAR(255)); INSERT INTO ReaderDemographics (ReaderID, Age, PreferredNewsTopic) VALUES (1, 45, 'politics');
|
What is the average age of readers who prefer news about politics in the "NewsReporting" database?
|
SELECT AVG(Age) FROM ReaderDemographics WHERE PreferredNewsTopic = 'politics'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_temperature (id INT, location VARCHAR(255), temperature FLOAT, date DATE); INSERT INTO ocean_temperature (id, location, temperature, date) VALUES (2, 'Arctic Ocean', 5.0, '2022-05-01');
|
What is the average ocean temperature in the Arctic Ocean?
|
SELECT location, AVG(temperature) FROM ocean_temperature WHERE location = 'Arctic Ocean'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (name TEXT, habitat TEXT); INSERT INTO marine_species (name, habitat) VALUES ('Polar Bear', 'Arctic'), ('Narwhal', 'Arctic'), ('Walrus', 'Arctic'), ('Beluga Whale', 'Arctic');
|
Which marine species are found in the Arctic Ocean?
|
SELECT name FROM marine_species WHERE habitat = 'Arctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_grid (id INT PRIMARY KEY, city VARCHAR(50), power_sources VARCHAR(50));
|
Insert records into 'smart_grid' for three cities
|
INSERT INTO smart_grid (id, city, power_sources) VALUES (1, 'San Francisco', 'Solar, Wind'); INSERT INTO smart_grid (id, city, power_sources) VALUES (2, 'New York', 'Solar, Hydro'); INSERT INTO smart_grid (id, city, power_sources) VALUES (3, 'Tokyo', 'Wind, Geothermal');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Users (user_id INT, update_count INT); INSERT INTO Users (user_id, update_count) VALUES (1, 3), (2, 1), (3, 2);
|
How many users have updated their account information more than once?
|
SELECT COUNT(*) as num_users FROM Users WHERE update_count > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Location VARCHAR(50), Salary DECIMAL(10,2), HireDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Location, Salary, HireDate) VALUES (1, 'John', 'Doe', 'IT', 'New York', 80000.00, '2022-01-01'), (2, 'Jane', 'Doe', 'HR', 'Los Angeles', 65000.00, '2022-02-15'), (3, 'Jim', 'Smith', 'IT', 'Chicago', 85000.00, '2022-03-20');
|
Calculate the average salary for employees in each department, excluding employees who were hired after '2022-02-01'
|
SELECT Department, AVG(Salary) FROM Employees WHERE HireDate <= '2022-02-01' GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fabrics (id INT, fabric_type VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO fabrics (id, fabric_type, country, quantity) VALUES (1, 'Tencel', 'Spain', 2500);
|
What is the total quantity of sustainable fabrics sourced from Spain?
|
SELECT SUM(quantity) FROM fabrics WHERE fabric_type = 'Tencel' AND country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(100), category VARCHAR(20)); CREATE TABLE readership (reader_id INT, article_id INT, gender VARCHAR(10), country VARCHAR(50)); INSERT INTO articles (id, title, category) VALUES (1, 'Arctic wildlife on the decline', 'Environment'); INSERT INTO readership (reader_id, article_id, gender, country) VALUES (1, 1, 'Female', 'Canada');
|
Find the top 3 news articles read by females in Canada.
|
SELECT a.title, r.gender, r.country FROM articles a JOIN ( SELECT article_id, gender, country FROM readership WHERE gender = 'Female' AND country = 'Canada' LIMIT 3) r ON a.id = r.article_id
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibitions (id INT, city VARCHAR(50), visitor_age INT); INSERT INTO exhibitions (id, city, visitor_age) VALUES (1, 'New York', 35), (2, 'New York', 42), (3, 'New York', 30);
|
What is the most common age range of visitors who attended exhibitions in New York?
|
SELECT city, COUNT(*) AS visitor_count, NTILE(4) OVER (ORDER BY visitor_age) AS age_range FROM exhibitions GROUP BY city, NTILE(4) OVER (ORDER BY visitor_age) HAVING city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (city VARCHAR(20), material VARCHAR(20), year INT, quantity INT); INSERT INTO waste_generation (city, material, year, quantity) VALUES ('San Francisco', 'Plastic', 2022, 1500), ('San Francisco', 'Glass', 2022, 2000), ('San Francisco', 'Paper', 2022, 2500), ('San Francisco', 'Metal', 2022, 1000);
|
What is the total waste generation by material type in 2022 for the city of San Francisco?
|
SELECT SUM(quantity) AS total_waste_generation, material FROM waste_generation WHERE city = 'San Francisco' AND year = 2022 GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_volume (chemical_category VARCHAR(255), production_volume INT); INSERT INTO production_volume (chemical_category, production_volume) VALUES ('Polymers', 1200), ('Dyes', 800), ('Acids', 1500);
|
What is the total production volume for each chemical category?
|
SELECT chemical_category, SUM(production_volume) OVER (PARTITION BY chemical_category) AS total_volume FROM production_volume;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incident (incident_id INT, incident_date DATE, incident_description TEXT, source_ip VARCHAR(255));CREATE VIEW country_risk AS SELECT ip_address, risk_level FROM ip_address_risk WHERE agency = 'CISA';
|
List all security incidents where the source IP address is from a country with a high risk of cyber attacks according to the Cybersecurity and Infrastructure Security Agency (CISA)?
|
SELECT incident_description, source_ip FROM incident i JOIN country_risk cr ON i.source_ip = cr.ip_address WHERE cr.risk_level = 'high';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE streams (id INT, track_id INT, date DATE, views INT); INSERT INTO streams (id, track_id, date, views) VALUES (1, 1, '2022-01-01', 10000);
|
What is the maximum number of streams for a classical music track in a single day?
|
SELECT MAX(views) FROM streams WHERE genre = 'Classical' GROUP BY track_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget_france (region VARCHAR(20), category VARCHAR(20), allocation DECIMAL(10, 2)); INSERT INTO budget_france VALUES ('France', 'Education', 12000.00);
|
What is the average budget allocation per service category in France?
|
SELECT AVG(allocation) FROM budget_france WHERE region = 'France' GROUP BY category;
|
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.