context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE MarineConservationLaws (id INT, law VARCHAR(50), description TEXT, country VARCHAR(50)); INSERT INTO MarineConservationLaws (id, law, description, country) VALUES (1, 'Coral Reef Protection Act', 'Protects coral reefs from destructive fishing practices', 'Fiji');
What are the details of marine conservation laws in Fiji?
SELECT * FROM MarineConservationLaws WHERE country = 'Fiji';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN); CREATE TABLE safety_records (record_id INT, product_id INT, violation_date DATE);
How many products have received a safety violation in the past year and are not cruelty-free certified?
SELECT COUNT(DISTINCT products.product_id) FROM products INNER JOIN safety_records ON products.product_id = safety_records.product_id WHERE safety_records.violation_date >= NOW() - INTERVAL '1 year' AND products.is_cruelty_free = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue_by_month (month VARCHAR(10), dish VARCHAR(50), sales DECIMAL(10,2)); INSERT INTO revenue_by_month (month, dish, sales) VALUES ('January', 'Vegan Pizza', 100.00), ('January', 'Vegan Pasta', 125.00); CREATE VIEW monthly_revenue AS SELECT month, SUM(sales) as total_sales FROM revenue_by_month GROUP BY...
What was the total revenue of vegan dishes in January?
SELECT total_sales FROM monthly_revenue WHERE month = 'January' AND dish IN ('Vegan Pizza', 'Vegan Pasta', 'Vegan Curry');
gretelai_synthetic_text_to_sql
CREATE TABLE offsets (id INT, region VARCHAR(20), project VARCHAR(20), offset INT); INSERT INTO offsets (id, region, project, offset) VALUES (1, 'Western', 'Wind Farm', 5000); INSERT INTO offsets (id, region, project, offset) VALUES (2, 'Eastern', 'Solar Farm', 6000);
What is the average carbon offset of renewable energy projects in the Western region?
SELECT AVG(offset) FROM offsets WHERE region = 'Western';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT PRIMARY KEY, researcher_id INT, name VARCHAR(255)); INSERT INTO genetics.research_projects (id, researcher_id, name) VALUES (1, 1, 'ProjectA'), (2, 2, 'ProjectB'), (3, 1, 'ProjectC'), (4, 3, 'ProjectD'), (5, 1, 'ProjectE'...
What is the total number of genetic research projects per researcher and their corresponding rank, ordered by total projects?
SELECT researcher_id, COUNT(*) AS total_projects, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rank FROM genetics.research_projects WINDOW W AS (PARTITION BY researcher_id ORDER BY researcher_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) GROUP BY researcher_id, W.researcher_id ORDER BY rank;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_vehicles (id INT, vehicle_type VARCHAR(20), trip_count INT); INSERT INTO shared_vehicles (id, vehicle_type, trip_count) VALUES (1, 'ebike', 1200), (2, 'escooter', 800), (3, 'car', 1500); CREATE TABLE city_data (city VARCHAR(20), shared_ebikes BOOLEAN, shared_escooters BOOLEAN); INSERT INTO city_data...
Identify cities with more than 1000 trips on shared scooters
SELECT city FROM city_data WHERE shared_escooters = true AND city IN (SELECT city FROM (SELECT city, SUM(trip_count) AS total_trips FROM shared_vehicles WHERE vehicle_type = 'escooter' GROUP BY city) AS shared_scooters WHERE total_trips > 1000);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_urbanism (size INT, city VARCHAR(20));
What is the total size of sustainable urbanism projects in Toronto?
SELECT SUM(size) FROM sustainable_urbanism WHERE city = 'Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2), inventory_count INT); CREATE TABLE menu_categories (category_id INT, category_name TEXT);
Change the category of 'Impossible Burger' to 'Plant-based' in the menu_items table
UPDATE menu_items mi JOIN menu_categories mc ON mi.category = mc.category_name SET mi.category = 'Plant-based' WHERE mi.item_name = 'Impossible Burger' AND mc.category_name = 'New';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (BuildingID INT, BuildingName VARCHAR(50)); INSERT INTO Buildings (BuildingID, BuildingName) VALUES (1, 'Adams Hall'); INSERT INTO Buildings (BuildingID, BuildingName) VALUES (2, 'Brown Hall'); CREATE TABLE Accommodations (StudentID INT, BuildingID INT); INSERT INTO Accommodations (StudentID, Bui...
What is the number of students who received accommodations in each building?
SELECT b.BuildingName, COUNT(a.StudentID) AS NumStudents FROM Accommodations a INNER JOIN Buildings b ON a.BuildingID = b.BuildingID GROUP BY b.BuildingName;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founder_gender TEXT); CREATE TABLE investment_rounds (id INT, company_id INT, round TEXT, funding_amount INT);
How many Series A investments have been made in companies with at least one female founder?
SELECT COUNT(*) FROM investment_rounds JOIN company ON investment_rounds.company_id = company.id WHERE round = 'Series A' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE profiles (id INT, user_id INT, gender VARCHAR(10), country VARCHAR(50), region VARCHAR(50));
What is the distribution of gender in the profiles table, grouped by region?
SELECT region, gender, COUNT(*) FROM profiles GROUP BY region, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE CarbonOffsetProjects (project TEXT, carbon_offset FLOAT); INSERT INTO CarbonOffsetProjects (project, carbon_offset) VALUES ('ProjectA', 1200), ('ProjectB', 1500), ('ProjectC', 1800);
What is the average carbon offset of projects in the 'CarbonOffsetProjects' table?
SELECT AVG(carbon_offset) FROM CarbonOffsetProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, gender TEXT, ethnicity TEXT, mental_health_score INT);
What is the average mental health score of students by gender and ethnicity?
SELECT students.gender, students.ethnicity, AVG(students.mental_health_score) as avg_score FROM students GROUP BY students.gender, students.ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE wineries (id INT, name TEXT, country TEXT, rating FLOAT, sustainable BOOLEAN); INSERT INTO wineries (id, name, country, rating, sustainable) VALUES (1, 'Château Margaux', 'France', 9.8, TRUE);
What is the maximum rating of a sustainable winery in France?
SELECT MAX(rating) FROM wineries WHERE country = 'France' AND sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Workplace_Safety (state VARCHAR(20), workplace_id INT, safety_issue BOOLEAN); INSERT INTO Workplace_Safety (state, workplace_id, safety_issue) VALUES ('California', 101, true), ('California', 102, false), ('New York', 201, true);
What is the percentage of workplaces with safety issues in each state?
SELECT state, (SUM(safety_issue) / COUNT(*)) * 100 as safety_issue_percentage FROM Workplace_Safety GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterConservationInitiatives (initiative_id INT, state VARCHAR(20), water_saved_liters INT); INSERT INTO WaterConservationInitiatives (initiative_id, state, water_saved_liters) VALUES (1, 'California', 1800000), (2, 'California', 2000000);
What is the total amount of water saved in liters through water conservation initiatives in the state of California?
SELECT SUM(water_saved_liters) FROM WaterConservationInitiatives WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Programs (program_id INT, program_name VARCHAR(20), total_carbon_offset INT); INSERT INTO Carbon_Offset_Programs (program_id, program_name, total_carbon_offset) VALUES (1, 'Trees for the Future', 50000), (2, 'Clean Energy Corps', 75000), (3, 'Solar for All', 100000);
What is the total carbon offset of each carbon offset program?
SELECT program_name, total_carbon_offset FROM Carbon_Offset_Programs;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_disputes_union (state VARCHAR(50), year INT, disputes INT); INSERT INTO labor_disputes_union (state, year, disputes) VALUES ('California', 2018, 150), ('Texas', 2019, 120), ('New York', 2020, 180);
Find the maximum number of labor disputes in the 'labor_disputes_union' table for each state.
SELECT state, MAX(disputes) AS max_disputes FROM labor_disputes_union GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE ItalyAccommodation (visitor INT, eco_friendly_accommodation BOOLEAN); INSERT INTO ItalyAccommodation (visitor, eco_friendly_accommodation) VALUES (12000000, true), (13000000, false);
What is the percentage of international visitors to Italy who prefer eco-friendly accommodation?
SELECT (SUM(eco_friendly_accommodation) * 100.0 / COUNT(*)) AS pct_eco_friendly FROM ItalyAccommodation;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE schools (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), city_id INT, FOREIGN KEY (city_id) REFERENCES cities(id));CREATE TABLE budgets (id INT PRIMARY KEY, school_id INT, amount INT, FOREIGN KEY (school_id) REFERENCES schools(id)); INSE...
Find the number of public schools in each city and the total budget allocated to those schools from the 'education_budget' database.
SELECT cities.name, COUNT(schools.id) as school_count, SUM(budgets.amount) as total_budget FROM cities INNER JOIN schools ON cities.id = schools.city_id INNER JOIN budgets ON schools.id = budgets.school_id WHERE schools.type = 'public' GROUP BY cities.name;
gretelai_synthetic_text_to_sql
CREATE TABLE public_buildings (id INT, name VARCHAR(50), year_built INT, occupancy FLOAT); INSERT INTO public_buildings (id, name, year_built, occupancy) VALUES (1, 'City Hall', 1975, 0.75), (2, 'Library', 1982, 0.9), (3, 'Police Station', 1968, 0.6);
What are the names of all public buildings that have been built before 1980 and their current occupancy levels?
SELECT name, year_built, occupancy FROM public_buildings WHERE year_built < 1980;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_categories (menu_category VARCHAR(255), ingredients VARCHAR(255)); INSERT INTO menu_categories (menu_category, ingredients) VALUES ('Appetizers', 'Chicken Wings, Lettuce, Tomatoes'), ('Entrees', 'Beef, Chicken, Rice'), ('Desserts', 'Fruit, Flour, Sugar');
What is the percentage of sustainable sourced ingredients for each menu category?
SELECT menu_category, AVG(sustainable_ingredients_percentage) FROM (SELECT menu_category, IF(FIND_IN_SET('Chicken', ingredients), 1, 0) + IF(FIND_IN_SET('Beef', ingredients), 1, 0) + IF(FIND_IN_SET('Rice', ingredients), 1, 0) + IF(FIND_IN_SET('Lettuce', ingredients), 1, 0) + IF(FIND_IN_SET('Tomatoes', ingredients), 1, ...
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai_projects (id INT PRIMARY KEY, project_name VARCHAR(50), budget FLOAT); INSERT INTO explainable_ai_projects (id, project_name, budget) VALUES (1, 'Interpretability', 60000.0), (2, 'Feature Importance', 55000.0), (3, 'Model Transparency', 58000.0), (4, 'Explainable Boosting', 62000.0), (5, 'Lo...
What is the average budget for Explainable AI projects?
SELECT AVG(budget) FROM explainable_ai_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerAge INT, GameName VARCHAR(20), Country VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (1, 25, 'Galactic Gold', 'United States'); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (2, 32, 'Starship Showdown', 'Canada');
What is the average age of players who have played the game "Galactic Gold" and are from the United States?
SELECT AVG(PlayerAge) FROM Players WHERE GameName = 'Galactic Gold' AND Country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE VesselEmissions (VesselID INT, ComplianceDate DATE, Compliance BOOLEAN); INSERT INTO VesselEmissions (VesselID, ComplianceDate, Compliance) VALUES (1, '2021-01-15', FALSE), (2, '2021-02-20', TRUE), (3, '2021-03-05', FALSE);
Which vessels have not complied with emission standards in the last 6 months?
SELECT VesselID FROM VesselEmissions WHERE Compliance = FALSE AND ComplianceDate >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE union_healthcare (union_id INT, union_name TEXT, industry TEXT, members INT, incidents INT); INSERT INTO union_healthcare (union_id, union_name, industry, members, incidents) VALUES (1, 'Union L', 'Healthcare', 7000, 20), (2, 'Union M', 'Healthcare', 3000, 15), (3, 'Union N', 'Healthcare', 8000, 10);
What is the average number of workplace safety incidents for each union in the healthcare industry, excluding unions with less than 5000 members?
SELECT industry, AVG(incidents) FROM union_healthcare WHERE industry = 'Healthcare' AND members >= 5000 GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE user_activity (id INT, user_id INT, activity VARCHAR(20), country VARCHAR(20)); INSERT INTO user_activity (id, user_id, activity, country) VALUES (1, 1, 'running', 'USA'), (2, 2, 'swimming', 'CAN'), (3, 3, 'hiking', 'USA'), (4, 4, 'cycling', 'MEX');
How many users have participated in outdoor activities in each country?
SELECT country, COUNT(*) as num_users FROM user_activity WHERE activity LIKE '%outdoor%' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE fire_incidents (id INT, city VARCHAR(20), month INT, year INT, incidents INT); INSERT INTO fire_incidents (id, city, month, year, incidents) VALUES (1, 'Houston', 6, 2022, 40); INSERT INTO fire_incidents (id, city, month, year, incidents) VALUES (2, 'Houston', 6, 2022, 45);
What is the total number of fire incidents in the city of Houston reported in the month of June 2022?
SELECT SUM(incidents) FROM fire_incidents WHERE city = 'Houston' AND month = 6 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_projects (id INT, region VARCHAR(20)); INSERT INTO mitigation_projects (id, region) VALUES (1, 'americas'), (2, 'europe'), (3, 'africa');
What is the total number of mitigation projects in 'americas' and 'europe' regions?
SELECT region, COUNT(*) FROM mitigation_projects WHERE region IN ('americas', 'europe') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE);
Create a table named 'satellite_deployment'
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE UnionInfo (UnionID INT, UnionName VARCHAR(50), Sector VARCHAR(20)); INSERT INTO UnionInfo (UnionID, UnionName, Sector) VALUES (1001, 'Retail Workers United', 'Service Industry'); INSERT INTO UnionInfo (UnionID, UnionName, Sector) VALUES (1002, 'Transport Workers Union', 'Transportation'); CREATE TABLE Coll...
Examine the number of collective bargaining agreements per union, grouped by union and year for the 'Service Industry' unions
SELECT UnionID, YEAR(AgreementDate) as AgreementYear, COUNT(*) as CBACount FROM CollectiveBargaining INNER JOIN UnionInfo ON CollectiveBargaining.UnionID = UnionInfo.UnionID WHERE Sector = 'Service Industry' GROUP BY UnionID, AgreementYear;
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_assistance (family_id INT, organization_id INT, emergency_need VARCHAR(20), budget DECIMAL(10,2), assistance_date DATE); INSERT INTO refugee_assistance (family_id, organization_id, emergency_need, budget, assistance_date) VALUES (1201, 2001, 'Food', 5000.00, '2020-01-12'), (1202, 2001, 'Shelter', 7...
List the number of refugee families assisted by each organization, categorized by their emergency needs in 2020, and the total budget spent on each category?
SELECT organization_id, emergency_need, COUNT(*) as families_assisted, SUM(budget) as total_budget_spent FROM refugee_assistance WHERE EXTRACT(YEAR FROM assistance_date) = 2020 GROUP BY organization_id, emergency_need;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicArtists (artist_id INT, artist_name VARCHAR(50), genre VARCHAR(20));
Add a new artist 'Bad Bunny' from the Reggaeton genre to the MusicArtists table.
INSERT INTO MusicArtists (artist_id, artist_name, genre) VALUES (102, 'Bad Bunny', 'Reggaeton');
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_sales (id INT, vehicle_type VARCHAR(50)); INSERT INTO vehicle_sales (id, vehicle_type) VALUES (1, 'Tesla Model 3'), (2, 'Nissan Leaf'), (3, 'Honda Civic'), (4, 'Toyota Prius'); CREATE TABLE autonomous_vehicles (id INT, vehicle_type VARCHAR(50)); INSERT INTO autonomous_vehicles (id, vehicle_type) VA...
Compare the number of hybrid and electric vehicles in the vehicle_sales table with the number of hybrid and electric vehicles in the autonomous_vehicles table.
SELECT (SELECT COUNT(*) FROM vehicle_sales WHERE vehicle_type IN ('hybrid', 'electric')) - (SELECT COUNT(*) FROM autonomous_vehicles WHERE vehicle_type IN ('hybrid', 'electric'));
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT, name VARCHAR(50), continent VARCHAR(50)); CREATE TABLE Species (id INT, name VARCHAR(50), scientific_name VARCHAR(50)); CREATE TABLE FarmSpecies (farm_id INT, species_id INT, biomass INT); CREATE TABLE Farm (id INT, name VARCHAR(50), country_id INT);
What is the total biomass of fish for each species in a specific country?
SELECT s.name, SUM(fs.biomass) FROM Species s JOIN FarmSpecies fs ON s.id = fs.species_id JOIN Farm f ON fs.farm_id = f.id JOIN Country c ON f.country_id = c.id WHERE c.name = [some_country_name] GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE system_vulnerabilities (ip_address VARCHAR(15), vulnerability_date DATE, vulnerability_id INT); INSERT INTO system_vulnerabilities (ip_address, vulnerability_date, vulnerability_id) VALUES ('192.168.1.1', '2021-11-01', 1), ('192.168.1.1', '2021-11-05', 2), ('192.168.1.2', '2021-11-02', 3), ('192.168.1.3', ...
What are the top 3 most vulnerable systems by IP address and the number of vulnerabilities in the last month?
SELECT ip_address, COUNT(vulnerability_id) as num_vulnerabilities FROM system_vulnerabilities WHERE vulnerability_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY ip_address ORDER BY num_vulnerabilities DESC FETCH FIRST 3 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE institution_data (project_id INT, project_name VARCHAR(50), institution VARCHAR(50), amount FLOAT);
What is the distribution of funding for AI research by institution?
SELECT institution, SUM(amount) as total_funding FROM institution_data GROUP BY institution;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, country VARCHAR(50), program_id INT, participation_date DATE); CREATE TABLE programs (id INT, focus_area VARCHAR(50)); INSERT INTO volunteers (id, country, program_id, participation_date) VALUES (1, 'Mexico', 1, '2021-04-01'); INSERT INTO programs (id, focus_area) VALUES (1, 'Healthy Li...
How many volunteers from Mexico have participated in health-related programs in the past year?
SELECT COUNT(DISTINCT volunteers.id) FROM volunteers JOIN programs ON volunteers.program_id = programs.id WHERE volunteers.country = 'Mexico' AND programs.focus_area = 'health-related programs' AND participation_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, donor_name VARCHAR, email VARCHAR, phone VARCHAR, last_update DATE); INSERT INTO donors (id, donor_name, email, phone, last_update) VALUES (1, 'Jane Doe', 'jane@example.com', '555-1234', '2022-01-01'), (2, 'John Smith', 'john@example.com', '555-5678', '2022-02-10');
How many donors have updated their contact information in the last month?
SELECT COUNT(*) FROM donors WHERE last_update >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND (email IS NOT NULL AND email != '' OR phone IS NOT NULL AND phone != '');
gretelai_synthetic_text_to_sql
CREATE TABLE AgeGroups (AgeGroupID INT, AgeGroup VARCHAR(50)); CREATE TABLE AudienceDemographics (AudienceID INT, AgeGroupID INT); INSERT INTO AgeGroups (AgeGroupID, AgeGroup) VALUES (1, 'Under 18'), (2, '18-24'), (3, '25-34'), (4, '35-44'), (5, '45-54'), (6, '55-64'), (7, '65+'); INSERT INTO AudienceDemographics (Audi...
What is the demographic breakdown of audience members who attended events in 2021?
SELECT ag.AgeGroup, COUNT(a.AudienceID) as NumAudienceMembers FROM Audience a INNER JOIN AudienceDemographics ad ON a.AudienceID = ad.AudienceID INNER JOIN AgeGroups ag ON ad.AgeGroupID = ag.AgeGroupID INNER JOIN AudienceAttendance aa ON a.AudienceID = aa.AudienceID INNER JOIN Events e ON aa.EventID = e.EventID WHERE e...
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 50.00), (2, 1, 100.00), (3, 2, 75.00);
What is the maximum donation amount given by a single donor?
SELECT MAX(amount) FROM donations;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (id INT, type VARCHAR(255), location VARCHAR(255)); INSERT INTO farms (id, type, location) VALUES (1, 'Urban', 'US');
How many urban farms are there in the US?
SELECT COUNT(*) FROM farms WHERE type = 'Urban' AND location = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE OceanHealth (Location VARCHAR(50), pH FLOAT, Temperature FLOAT); INSERT INTO OceanHealth (Location, pH, Temperature) VALUES ('Caribbean', 8.2, 25); INSERT INTO OceanHealth (Location, pH, Temperature) VALUES ('Baltic', 8.5, 15);
What is the maximum pH value for aquatic locations with a temperature between 10 and 20 degrees Celsius?
SELECT MAX(pH) FROM OceanHealth WHERE Temperature BETWEEN 10 AND 20;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (community_id INT, community_name VARCHAR(255), population INT, region VARCHAR(255));
List the regions and the number of communities in each region from the 'indigenous_communities' table.
SELECT region, COUNT(DISTINCT community_id) AS community_count FROM indigenous_communities GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, name VARCHAR(255), category VARCHAR(255), country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO garments (id, name, category, country, price) VALUES (1, 'Organic Cotton Hoodie', 'Tops', 'United States', 50.00); CREATE TABLE orders (id INT, garment_id INT, quantity INT, order_date DATE);
Find the total revenue generated by 'Organic Cotton Hoodies' sold in the United States for the year 2022.
SELECT SUM(quantity * price) FROM orders INNER JOIN garments ON orders.garment_id = garments.id WHERE garments.name = 'Organic Cotton Hoodie' AND garments.country = 'United States' AND YEAR(order_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region, account_balance) VALUES (1, 'John Doe', 'South', 5000.00), (2, 'Jane Smith', 'North', 7000.00);
What is the average account balance for socially responsible lending customers in the South region?
SELECT AVG(account_balance) FROM customers WHERE region = 'South' AND product_type = 'Socially Responsible Lending';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name TEXT, region TEXT); INSERT INTO customers (customer_id, name, region) VALUES (1, 'John Smith', 'Western'), (2, 'Jane Doe', 'Eastern'); CREATE TABLE assets (asset_id INT, customer_id INT, value INT); INSERT INTO assets (asset_id, customer_id, value) VALUES (1, 1, 5000), (2, ...
What is the total assets value for all customers from the Western region?
SELECT SUM(a.value) FROM assets a INNER JOIN customers c ON a.customer_id = c.customer_id WHERE c.region = 'Western';
gretelai_synthetic_text_to_sql
CREATE TABLE appetizer_orders (order_id INT, appetizer VARCHAR(255), appetizer_quantity INT); INSERT INTO appetizer_orders VALUES (1, 'Bruschetta', 15), (2, 'Calamari', 8), (3, 'Bruschetta', 12);
What is the total quantity of each appetizer sold?
SELECT appetizer, SUM(appetizer_quantity) FROM appetizer_orders GROUP BY appetizer;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (stream_id INT, user_id INT, song_id INT, streams INT, date DATE, artist_id INT, artist_race VARCHAR(50), artist_nationality VARCHAR(50)); CREATE TABLE songs (song_id INT, song_name VARCHAR(100), artist_id INT, artist_race VARCHAR(50), artist_nationality VARCHAR(100));
Find the top 5 artists with the highest number of streams in the 'music_streaming' table, who are from Africa or of African descent.
SELECT s.artist_name, SUM(ms.streams) AS total_streams FROM music_streaming ms JOIN songs s ON ms.song_id = s.song_id WHERE (s.artist_race LIKE '%African%' OR s.artist_nationality LIKE '%Africa%') GROUP BY s.artist_name ORDER BY total_streams DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Golden State Warriors'), (2, 'Los Angeles Lakers'); CREATE TABLE ticket_sales (game_id INT, team_id INT, ticket_price DECIMAL(5,2)); INSERT INTO ticket_sales (game_id, team_id, ticket_price) VALUES (1, 1, 150.00...
What is the average ticket price for each team's games?
SELECT t.team_name, AVG(ts.ticket_price) as avg_ticket_price FROM teams t INNER JOIN ticket_sales ts ON t.team_id = ts.team_id GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtWorkSales (artworkID INT, saleDate DATE, artistID INT, revenue DECIMAL(10,2)); CREATE TABLE Artists (artistID INT, artistName VARCHAR(50), country VARCHAR(50));
How many artworks were sold by Indigenous artists from Canada in each year?
SELECT YEAR(saleDate) as sale_year, COUNT(*) as artwork_count FROM ArtWorkSales aws JOIN Artists a ON aws.artistID = a.artistID WHERE a.country = 'Canada' AND a.artistName IN (SELECT artistName FROM Artists WHERE ethnicity = 'Indigenous') GROUP BY sale_year;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (id INT, name TEXT, location TEXT, type TEXT);INSERT INTO military_bases (id, name, location, type) VALUES (1, 'Andersen AFB', 'Guam', 'Air Force');INSERT INTO military_bases (id, name, location, type) VALUES (2, 'Camp H.M. Smith', 'Hawaii', 'Joint Base');
What is the total number of military bases in the Pacific region?
SELECT SUM(number_of_bases) FROM (SELECT COUNT(*) AS number_of_bases FROM military_bases WHERE location = 'Pacific') AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(50), mission VARCHAR(50), mass FLOAT); INSERT INTO space_debris VALUES (1, 'Debris-1', 'Kounotori-8', 2.6);
What is the total mass of space debris collected by the Japanese Kounotori-8 mission?
SELECT SUM(mass) as total_mass FROM space_debris WHERE mission = 'Kounotori-8';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (provider_id INT, first_name VARCHAR(50), last_name VARCHAR(50), specialty VARCHAR(50), city VARCHAR(50), state VARCHAR(2)); CREATE TABLE patients (patient_id INT, provider_id INT, first_name VARCHAR(50), last_name VARCHAR(50), city VARCHAR(50), state VARCHAR(2), mental_health_score INT); CREATE ...
List the first name, last name, and city for all providers who have 'therapist' in their specialty and are located in New York, NY, along with the number of patients assigned to each provider, and the average mental health score for each provider's patients
SELECT p.first_name, p.last_name, p.city, AVG(m.mental_health_score) AS avg_score, COUNT(pa.patient_id) AS patient_count FROM providers p JOIN patients pa ON p.provider_id = pa.provider_id JOIN mental_health_scores m ON pa.patient_id = m.patient_id WHERE p.specialty LIKE '%therapist%' AND p.city = 'New York' AND p.stat...
gretelai_synthetic_text_to_sql
CREATE TABLE rural_communities (id INT, community_name VARCHAR(255), location VARCHAR(255), country VARCHAR(255), initiative_type VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_communities (id, community_name, location, country, initiative_type, start_date, end_date) VALUES (1, 'Community A', 'Village...
What is the count of community development initiatives in Country A?
SELECT COUNT(*) FROM rural_communities WHERE country = 'Country A' AND initiative_type = 'Community Development';
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_tournaments (id INT, year INT, month INT, tournaments INT); INSERT INTO monthly_tournaments (id, year, month, tournaments) VALUES (1, 2022, 1, 3), (2, 2022, 2, 2), (3, 2022, 3, 4);
How many tournaments have taken place per month in the last year?
SELECT TO_CHAR(DATE '2022-01-01' + INTERVAL month MONTH, 'Month YYYY') AS month_year, SUM(tournaments) OVER (ORDER BY DATE '2022-01-01' + INTERVAL month MONTH RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS total_tournaments FROM monthly_tournaments;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, artist_id INT, city VARCHAR(50), revenue DECIMAL(10,2), year INT);
What is the total revenue from concert ticket sales for a given artist in a given year?
SELECT artist_id, SUM(revenue) AS total_revenue FROM Concerts WHERE year = 2021 GROUP BY artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, department VARCHAR(50), timestamp DATETIME);
What is the total number of security incidents for each department in the last month?
SELECT department, COUNT(*) as num_incidents FROM security_incidents WHERE timestamp > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE plays (title VARCHAR(255), location VARCHAR(255), price DECIMAL(5,2)); INSERT INTO plays (title, location, price) VALUES ('Hamilton', 'London', 250.00), ('Macbeth', 'London', 150.00), ('Romeo and Juliet', 'London', 120.00);
What is the highest ticket price for a play in London?
SELECT MAX(price) FROM plays WHERE location = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE processes (id INT, name TEXT); INSERT INTO processes (id, name) VALUES (1, 'Process A'), (2, 'Process B'), (3, 'Process C'); CREATE TABLE waste (process_id INT, waste_date DATE, amount FLOAT); INSERT INTO waste (process_id, waste_date, amount) VALUES (1, '2022-03-01', 150.0), (1, '2022-04-01', 160.0), (1, ...
What is the total amount of waste produced by each process in the last 3 months?
SELECT process_id, SUM(amount) as total_waste FROM waste WHERE waste_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW() GROUP BY process_id;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceExploration (id INT, agency VARCHAR(255), country VARCHAR(255), cost FLOAT); INSERT INTO SpaceExploration VALUES (1, 'NASA', 'USA', 22000000000), (2, 'ESA', 'Europe', 18000000000), (3, 'Roscosmos', 'Russia', 15000000000), (4, 'ISRO', 'India', 7000000000);
What is the total cost of space exploration missions led by NASA?
SELECT SUM(cost) FROM SpaceExploration WHERE agency = 'NASA';
gretelai_synthetic_text_to_sql
CREATE TABLE members_geo_ext(id INT, name VARCHAR(50), gender VARCHAR(10), age INT, membership_type VARCHAR(20), country VARCHAR(20), city VARCHAR(20), wearable_device VARCHAR(20)); INSERT INTO members_geo_ext(id, name, gender, age, membership_type, country, city, wearable_device) VALUES (1, 'John Doe', 'Male', 30, 'Gy...
Show the total number of members from each country who have a gym membership, excluding those who also use wearable technology.
SELECT country, COUNT(*) as count FROM members_geo_ext WHERE membership_type = 'Gym' AND wearable_device IS NULL GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionMonitoring (SpeciesID INT, Individuals INT); INSERT INTO PollutionMonitoring (SpeciesID, Individuals) VALUES (1, 100), (2, 200), (3, 300); CREATE TABLE ConservationEfforts (SpeciesID INT, Individuals INT); INSERT INTO ConservationEfforts (SpeciesID, Individuals) VALUES (2, 200), (3, 300), (4, 400)...
Which marine species have the same number of individuals in the 'PollutionMonitoring' and 'ConservationEfforts' tables?
SELECT P.SpeciesID FROM PollutionMonitoring P INNER JOIN ConservationEfforts C ON P.SpeciesID = C.SpeciesID WHERE P.Individuals = C.Individuals;
gretelai_synthetic_text_to_sql
CREATE TABLE UniquePlayerGames (player_id INT, game_id INT, region VARCHAR(255)); INSERT INTO UniquePlayerGames (player_id, game_id, region) VALUES (17, 9, 'Central America'), (18, 9, 'Central America'), (19, 10, 'Central America'), (20, 10, 'Central America'), (21, 11, 'Central America'), (22, 11, 'Central America');
What is the count of unique players for each game in Central America?
SELECT G.game_name, COUNT(DISTINCT UPG.player_id) as unique_player_count FROM UniquePlayerGames UPG JOIN Games G ON UPG.game_id = G.game_id GROUP BY G.game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovations (id INT, project_name TEXT, sector TEXT, country TEXT, grant_amount DECIMAL(10,2)); INSERT INTO agricultural_innovations (id, project_name, sector, country, grant_amount) VALUES (1, 'Precision Agriculture', 'Agricultural Innovation', 'India', 25000.00), (2, 'Sustainable Farming', '...
Delete all records of agricultural innovation projects in India that have a grant amount greater than 20000.
DELETE FROM agricultural_innovations WHERE country = 'India' AND grant_amount > 20000;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, region VARCHAR(255), well_type VARCHAR(255), gas_production DECIMAL(5,2)); INSERT INTO wells (id, region, well_type, gas_production) VALUES (1, 'Marcellus Shale', 'Gas', 10.0), (2, 'Marcellus Shale', 'Oil', 15.0), (3, 'Haynesville Shale', 'Gas', 12.0), (4, 'Haynesville Shale', 'Oil', 18.0);
What is the average gas production rate in the Marcellus Shale and Haynesville Shale?
SELECT AVG(gas_production) as avg_gas_production FROM wells WHERE region IN ('Marcellus Shale', 'Haynesville Shale') AND well_type = 'Gas';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), state VARCHAR(25), num_beds INT); INSERT INTO hospitals (id, name, state, num_beds) VALUES (1, 'Hospital A', 'Texas', 60), (2, 'Hospital B', 'Texas', 30), (3, 'Hospital C', 'California', 75);
How many hospitals are there in Texas that have less than 50 beds?
SELECT COUNT(*) FROM hospitals WHERE state = 'Texas' AND num_beds < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE program (id INT, name VARCHAR(255)); INSERT INTO program (id, name) VALUES (1, 'Accommodations'), (2, 'Support Programs'), (3, 'Policy Advocacy'), (4, 'Inclusion'); CREATE TABLE student_program (program_id INT, student_id INT);
What is the total number of students served by each program?
SELECT p.name, COUNT(sp.student_id) as total_students FROM program p JOIN student_program sp ON p.id = sp.program_id GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Construction_Workers (worker_id INT, name VARCHAR(30), hours_worked FLOAT, location VARCHAR(20)); INSERT INTO Construction_Workers VALUES (1, 'John Doe', 150.25, 'Solar Suburb'), (2, 'Jane Smith', 200.50, 'Rural County'), (3, 'Mike Johnson', 300.75, 'Solar Suburb'), (4, 'Sara Doe', 250.50, 'Solar Suburb');
What is the total number of construction workers in 'Solar Suburb'?
SELECT COUNT(DISTINCT worker_id) FROM Construction_Workers WHERE location = 'Solar Suburb';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety_test_results (id INT PRIMARY KEY, vehicle_type VARCHAR(255), safety_rating DECIMAL(3,2));
Add a new column 'manufacturer' to 'vehicle_safety_test_results' table
ALTER TABLE vehicle_safety_test_results ADD manufacturer VARCHAR(255);
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_maintenance (id INT, country VARCHAR(50), cost FLOAT); INSERT INTO military_equipment_maintenance (id, country, cost) VALUES (1, 'Australia', 800000), (2, 'Australia', 750000), (3, 'New Zealand', 700000);
What is the average cost of military equipment maintenance for Australia and New Zealand?
SELECT AVG(cost) FROM military_equipment_maintenance WHERE country IN ('Australia', 'New Zealand') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE crypto_transactions (transaction_id INT, digital_asset VARCHAR(20), transaction_amount DECIMAL(10,2), transaction_time DATETIME);
What is the minimum transaction amount for each digital asset in the 'crypto_transactions' table, ordered by the minimum transaction amount in ascending order?
SELECT digital_asset, MIN(transaction_amount) as min_transaction_amount FROM crypto_transactions GROUP BY digital_asset ORDER BY min_transaction_amount;
gretelai_synthetic_text_to_sql
CREATE TABLE hydro_power_plants (id INT, name VARCHAR(255), country VARCHAR(255), capacity FLOAT, completion_date DATE);
What is the total installed capacity of hydroelectric power plants in the country of Canada, and what are their names?
SELECT name, SUM(capacity) AS total_capacity FROM hydro_power_plants WHERE country = 'Canada' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE econ_diversification (id INT, project_name VARCHAR(255), investment_amount FLOAT); INSERT INTO econ_diversification (id, project_name, investment_amount) VALUES (1, 'Renewable Energy', 800000), (2, 'Tourism Development', 600000);
Find the maximum and minimum investment amounts for economic diversification projects.
SELECT MAX(investment_amount) AS max_investment, MIN(investment_amount) AS min_investment FROM econ_diversification;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_image (image_id INT, analysis_date DATE, crop_health INT); INSERT INTO satellite_image (image_id, analysis_date, crop_health) VALUES (1, '2021-04-01', 80), (2, '2021-04-10', 85), (3, '2021-04-20', 90), (4, '2021-05-01', 75), (5, '2021-05-15', 88);
What is the latest crop health analysis from satellite imagery?
SELECT * FROM satellite_image ORDER BY analysis_date DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE authors (author_id INT, name VARCHAR(50), affiliation VARCHAR(100)); INSERT INTO authors (author_id, name, affiliation) VALUES (1, 'Alice', 'University of Oxford'); INSERT INTO authors (author_id, name, affiliation) VALUES (2, 'Bob', 'Google Research');
Insert a new author 'Charlie' with ID 4, affiliation 'IBM Watson'.
INSERT INTO authors (author_id, name, affiliation) VALUES (4, 'Charlie', 'IBM Watson');
gretelai_synthetic_text_to_sql
CREATE TABLE garment_prices (id INT, garment_type VARCHAR(255), region VARCHAR(255), price INT); INSERT INTO garment_prices (id, garment_type, region, price) VALUES (1, 'Dress', 'North America', 200), (2, 'Jacket', 'North America', 300), (3, 'Skirt', 'North America', 400);
Delete the record of the most expensive garment sold in the North American market.
DELETE FROM garment_prices WHERE id = (SELECT id FROM (SELECT ROW_NUMBER() OVER (ORDER BY price DESC) as row_num, id FROM garment_prices WHERE region = 'North America') t WHERE t.row_num = 1);
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id serial, framework_name varchar(20)); INSERT INTO regulatory_frameworks (framework_id, framework_name) VALUES (1, 'GDPR'), (2, 'HIPAA'), (3, 'PCI-DSS');
List the names of all regulatory frameworks in the database.
SELECT framework_name FROM regulatory_frameworks;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (student_id INT, accommodation_type VARCHAR(255), cost FLOAT, month INT);
What is the total cost of accommodations for students with hearing impairments in April?
SELECT SUM(cost) FROM Accommodations WHERE accommodation_type = 'Hearing Impairment' AND month = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE multi_annual_chemicals (manufacturer_id INT, manufacturer_name VARCHAR(50), year INT, weight FLOAT); INSERT INTO multi_annual_chemicals (manufacturer_id, manufacturer_name, year, weight) VALUES (1, 'AusChem', 2023, 800.5), (2, 'British Biotech', 2023, 900.3), (3, 'ChemCorp', 2023, 700.7), (4, 'Global Green...
Find the total weight of chemicals produced by each manufacturer, partitioned by year and ordered from most to least weight in 2024
SELECT manufacturer_id, manufacturer_name, SUM(weight) OVER (PARTITION BY manufacturer_id ORDER BY year DESC) as total_weight FROM multi_annual_chemicals WHERE year IN (2023, 2024) ORDER BY total_weight DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_south_asia (country VARCHAR(50), project VARCHAR(50)); INSERT INTO climate_mitigation_south_asia (country, project) VALUES ('India', 'Solar Energy Project'), ('Bangladesh', 'Energy Efficiency Project'), ('Pakistan', 'Wind Energy Project'), ('Sri Lanka', 'Hydropower Project');
Identify the top 2 countries with the highest number of climate mitigation projects in South Asia.
SELECT country, COUNT(project) AS project_count FROM climate_mitigation_south_asia WHERE country IN ('India', 'Bangladesh', 'Pakistan', 'Sri Lanka', 'Nepal') GROUP BY country ORDER BY project_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title TEXT, country TEXT, year INT, rating FLOAT); INSERT INTO news_articles (id, title, country, year, rating) VALUES (1, 'ArticleA', 'France', 2016, 7.2), (2, 'ArticleB', 'France', 2017, 8.5), (3, 'ArticleC', 'USA', 2018, 9.1);
What is the minimum rating of French news articles published in 2016?
SELECT MIN(rating) FROM news_articles WHERE country = 'France' AND year = 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT PRIMARY KEY, age INT, gender VARCHAR(50), country VARCHAR(50));
What are the demographics of patients who received mental health treatment in Canada?
SELECT age, gender FROM patients WHERE country = 'Canada' AND id IN (SELECT patient_id FROM prescriptions);
gretelai_synthetic_text_to_sql
CREATE TABLE basketball_players (player_id INT, name VARCHAR(50), position VARCHAR(50), height FLOAT, weight INT, team_id INT);
Insert new basketball player records into the basketball_players table
INSERT INTO basketball_players (player_id, name, position, height, weight, team_id) VALUES (1, 'Alex Thompson', 'Guard', 1.85, 82, 101), (2, 'Jasmine Davis', 'Forward', 1.93, 78, 202), (3, 'Michael Chen', 'Center', 2.08, 105, 303);
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftModels (ModelID INT, Model VARCHAR(50), Manufacturer VARCHAR(50), FlightHours INT); INSERT INTO AircraftModels (ModelID, Model, Manufacturer, FlightHours) VALUES (1, '787', 'Boeing', 2500000); INSERT INTO AircraftModels (ModelID, Model, Manufacturer, FlightHours) VALUES (2, 'A350', 'Airbus', 300000...
List aircraft models along with the number of flight hours they have accumulated, ranked in descending order per manufacturer.
SELECT Model, Manufacturer, SUM(FlightHours) AS Total_Flight_Hours, RANK() OVER (PARTITION BY Manufacturer ORDER BY SUM(FlightHours) DESC) AS Flight_Hour_Rank FROM AircraftModels GROUP BY Model, Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), cultural_background VARCHAR(50)); INSERT INTO community_health_workers (id, name, cultural_background) VALUES (1, 'Ana Garcia', 'Hispanic'); INSERT INTO community_health_workers (id, name, cultural_background) VALUES (2, 'Hiroshi Tanaka', 'Japanese');
List the unique 'cultural_background' values from the 'community_health_workers' table.
SELECT DISTINCT cultural_background FROM community_health_workers;
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), instructor_id INT); INSERT INTO courses (course_id, course_name, instructor_id) VALUES (1, 'Introduction to Computer Science', 1), (2, 'Data Structures and Algorithms', 1), (3, 'Calculus I', 2), (4, 'Calculus II', 2); CREATE TABLE students_courses (stude...
What is the total number of students enrolled in each course, and what is the average age of students in each course?
SELECT c.course_name, COUNT(sc.student_id) as total_enrolled, AVG(sc.student_age) as avg_student_age FROM courses c JOIN students_courses sc ON c.course_id = sc.course_id GROUP BY c.course_name;
gretelai_synthetic_text_to_sql
CREATE TABLE drilled_wells (well_id INT, well_name VARCHAR(50), country VARCHAR(50), drill_year INT); INSERT INTO drilled_wells (well_id, well_name, country, drill_year) VALUES (1, 'Well1', 'Brazil', 2016), (2, 'Well2', 'Brazil', 2015), (3, 'Well3', 'USA', 2017);
How many wells were drilled in 'Brazil' before 2016
SELECT COUNT(*) FROM drilled_wells WHERE country = 'Brazil' AND drill_year < 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (donor_id, donation_amount, donation_date) VALUES (1, 500, '2021-01-01'), (2, 300, '2021-03-15'), (1, 700, '2021-04-01');
Update the donation amount for donor 1 on 2021-01-01 to 600.
UPDATE Donations SET donation_amount = 600 WHERE donor_id = 1 AND donation_date = '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, name VARCHAR(50), type VARCHAR(20), data_usage FLOAT, subscription_date DATE); INSERT INTO subscribers (id, name, type, data_usage, subscription_date) VALUES (5, 'Jackie Liu', 'Mobile', 3.2, '2021-02-20'); CREATE TABLE regions (id INT, name VARCHAR(50), continent VARCHAR(50)); INSERT I...
How many mobile customers signed up in Oceania each year?
SELECT YEAR(subscription_date) AS year, COUNT(*) AS count FROM subscribers s INNER JOIN subscriber_regions sr ON s.id = sr.subscriber_id INNER JOIN regions r ON sr.region_id = r.id WHERE s.type = 'Mobile' AND r.continent = 'Oceania' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE bridge_info (bridge_id INT, bridge_name VARCHAR(50)); CREATE TABLE construction_dates (bridge_id INT, construction_year INT); INSERT INTO bridge_info (bridge_id, bridge_name) VALUES (1, 'Brooklyn Bridge'), (2, 'Golden Gate Bridge'), (3, 'Tacoma Narrows Bridge'); INSERT INTO construction_dates (bridge_id, c...
List all the bridges along with their construction dates from the 'bridge_info' and 'construction_dates' tables.
SELECT bridge_info.bridge_name, construction_dates.construction_year FROM bridge_info INNER JOIN construction_dates ON bridge_info.bridge_id = construction_dates.bridge_id;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT, name VARCHAR(50), company VARCHAR(50), service_frequency INT, company_location VARCHAR(50)); INSERT INTO military_equipment (id, name, company, service_frequency, company_location) VALUES (1, 'M1 Abrams', 'XYZ', 12, 'Texas'); INSERT INTO military_equipment (id, name, company, se...
What is the total number of military equipment serviced by defense contractors based in Texas?
SELECT SUM(service_frequency) FROM military_equipment WHERE company_location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE brands (id INT, name VARCHAR(255)); CREATE TABLE products (id INT, brand_id INT, certification VARCHAR(255));
List all brands that have at least one product with a certain certification
SELECT b.name FROM brands b INNER JOIN products p ON b.id = p.brand_id WHERE p.certification = 'certification' GROUP BY b.name HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE fina_athletes (athlete_id INT, athlete_name VARCHAR(50), birthdate DATE, gender VARCHAR(50));
What is the average age of athletes in the FINA World Championships?
SELECT AVG(DATEDIFF('2022-07-15', birthdate)/365.25) AS avg_age FROM fina_athletes;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, country VARCHAR(50)); INSERT INTO wells VALUES (1, 'Well A', 1000, 'Brazil'); INSERT INTO wells VALUES (2, 'Well B', 1500, 'Norway'); INSERT INTO wells VALUES (3, 'Well C', 1200, 'Brazil'); INSERT INTO wells VALUES (4, 'Well D', 800, 'Nige...
List the wells with the highest production volume in each country
SELECT country, MAX(production_volume) FROM wells GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_transaction_volume (regulatory_status VARCHAR(255), transaction_volume INT, date DATE); INSERT INTO daily_transaction_volume (regulatory_status, transaction_volume, date) VALUES ('Regulated', 50000, '2022-01-01'), ('Partially Regulated', 40000, '2022-01-01'), ('Unregulated', 30000, '2022-01-01'), ('R...
What is the total transaction volume for each regulatory status per day?
SELECT regulatory_status, date, SUM(transaction_volume) OVER (PARTITION BY regulatory_status, date) FROM daily_transaction_volume;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(100), country VARCHAR(50), co2_emission INT);
What is the CO2 emission of each production country?
SELECT factories.country, SUM(factories.co2_emission) AS co2_emission FROM factories GROUP BY factories.country;
gretelai_synthetic_text_to_sql
CREATE TABLE sales(drug varchar(10), revenue int); INSERT INTO sales(drug, revenue) VALUES('DrugA', 5000), ('DrugB', 6000);
What are the total sales figures for 'DrugA' and 'DrugB'?
SELECT SUM(revenue) FROM sales WHERE drug IN ('DrugA', 'DrugB')
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'Texas'); CREATE TABLE households (id INT, state_id INT, income FLOAT, members INT); INSERT INTO households (id, state_id, income, members) VALUES (1, 1, 75000, 3), (2, 1, 100000, 2), (3, 1, 60000, 4), (4, 1, 90000, 3);
What is the average income in Texas for households with more than two members?
SELECT AVG(households.income) AS avg_income FROM households INNER JOIN states ON households.state_id = states.id WHERE states.name = 'Texas' AND households.members > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT, journalist VARCHAR(255), publish_date DATE);
List the unique journalist names and their respective total article counts from the "news_articles" table, excluding any articles published before 2015.
SELECT journalist, COUNT(*) AS article_count FROM news_articles WHERE publish_date >= '2015-01-01' GROUP BY journalist;
gretelai_synthetic_text_to_sql