context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE if not exists buildings (id INT, name VARCHAR(100), location VARCHAR(50), energy_efficiency_rating FLOAT); INSERT INTO buildings (id, name, location, energy_efficiency_rating) VALUES (1, 'Downtown Building', 'downtown', 90);
|
What is the name of the building with the highest energy efficiency rating in 'downtown'?
|
SELECT name FROM buildings WHERE location = 'downtown' AND energy_efficiency_rating = (SELECT MAX(energy_efficiency_rating) FROM buildings WHERE location = 'downtown');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerEsportsData (PlayerID INT, Age INT, EventID INT); INSERT INTO PlayerEsportsData (PlayerID, Age, EventID) VALUES (1, 22, 1), (2, 25, 2), (3, 28, 3);
|
What is the minimum age of players who have participated in esports events?
|
SELECT MIN(Age) FROM PlayerEsportsData;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE advertising_performance (user_id INT, ad_spend DECIMAL(10,2), ad_date DATE);
|
What is the total ad revenue spent by users in 'advertising_performance' table for the last week?
|
SELECT ad_date, SUM(ad_spend) FROM advertising_performance WHERE ad_date >= CURDATE() - INTERVAL 7 DAY GROUP BY ad_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_training (individual_id TEXT, training_date DATE, wellbeing_score NUMERIC, country TEXT); INSERT INTO financial_training (individual_id, training_date, wellbeing_score, country) VALUES ('567890', '2022-03-01', 75, 'India'); INSERT INTO financial_training (individual_id, training_date, wellbeing_score, country) VALUES ('098765', '2022-04-01', 80, 'India');
|
What is the average financial wellbeing score of individuals in India who have completed financial capability training in the past year?
|
SELECT AVG(wellbeing_score) FROM financial_training WHERE training_date >= DATEADD(year, -1, CURRENT_DATE) AND country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, district VARCHAR(255), severity_score FLOAT); INSERT INTO crimes VALUES (1, 'Manhattan', 8.5), (2, 'Brooklyn', 9.2);
|
What is the maximum crime severity score in each district?
|
SELECT district, MAX(severity_score) FROM crimes GROUP BY district;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_investment_risk(investment_id INT, risk_rating INT, investment_type VARCHAR(20));
|
Avg. risk rating of sustainable investments in the EU
|
SELECT AVG(risk_rating) FROM sustainable_investment_risk WHERE investment_type = 'sustainable';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name VARCHAR(255), grade INT, location VARCHAR(255)); CREATE TABLE resources (id INT, name VARCHAR(255), access_date DATE); CREATE TABLE student_resources (student_id INT, resource_id INT);
|
What is the total number of open educational resources accessed by students in a rural area?
|
SELECT COUNT(DISTINCT sr.student_id) as num_students, COUNT(DISTINCT sr.resource_id) as num_resources FROM student_resources sr JOIN students s ON sr.student_id = s.id WHERE s.location LIKE '%rural%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, material VARCHAR(20), price DECIMAL(5,2), market VARCHAR(20)); INSERT INTO products (product_id, material, price, market) VALUES (1, 'organic cotton', 40.00, 'Africa'), (2, 'sustainable wood', 70.00, 'Asia'), (3, 'recycled polyester', 55.00, 'Europe'), (4, 'organic linen', 60.00, 'Africa');
|
What is the average price of products made from sustainable materials in the African market?
|
SELECT AVG(price) FROM products WHERE market = 'Africa' AND material IN ('organic cotton', 'sustainable wood', 'recycled polyester', 'organic linen');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hospitals (Name VARCHAR(255), Location VARCHAR(10), Specialized BOOLEAN); INSERT INTO Hospitals (Name, Location, Specialized) VALUES ('Hospital A', 'Urban', TRUE), ('Hospital B', 'Rural', FALSE), ('Hospital C', 'Urban', FALSE), ('Hospital D', 'Rural', TRUE);
|
What is the total number of hospitals in urban and rural areas, and how many of them are specialized in infectious diseases?
|
SELECT Location, COUNT(*) FROM Hospitals WHERE Specialized = TRUE GROUP BY Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Orders (OrderID INT, OrderDate DATE, CustomerID INT); CREATE TABLE OrderItems (OrderItemID INT, OrderID INT, FoodItemID INT, Quantity INT);
|
How many times has each food item been ordered?
|
SELECT FoodItems.FoodItemName, SUM(OrderItems.Quantity) AS TotalOrdered FROM FoodItems JOIN OrderItems ON FoodItems.FoodItemID = OrderItems.FoodItemID GROUP BY FoodItems.FoodItemName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games (id INT PRIMARY KEY, player_id INT, game_name VARCHAR(100), last_played TIMESTAMP); INSERT INTO games VALUES (1, 1001, 'GameA', '2021-01-01 12:00:00'), (2, 1002, 'GameB', '2021-02-15 14:30:00'), (3, 1003, 'GameA', '2021-06-20 09:15:00'); CREATE TABLE new_games (id INT PRIMARY KEY, game_name VARCHAR(100));
|
Add new games to the games table with the given game names
|
INSERT INTO games SELECT new_games.id, NULL AS player_id, new_games.game_name, NULL AS last_played FROM new_games WHERE NOT EXISTS (SELECT 1 FROM games WHERE games.game_name = new_games.game_name);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (PolicyholderID INT, ClaimAmount DECIMAL(10, 2), ClaimDate DATE); INSERT INTO Claims VALUES (1, 5000, '2022-01-01'); INSERT INTO Claims VALUES (1, 3000, '2022-02-15'); INSERT INTO Claims VALUES (1, 8000, '2022-03-30'); INSERT INTO Claims VALUES (2, 2000, '2022-01-05');
|
Calculate the moving average of claim amounts for the most recent 3 months for each policyholder in Canada.
|
SELECT PolicyholderID, AVG(ClaimAmount) OVER (PARTITION BY PolicyholderID ORDER BY ClaimDate ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS MovingAverage FROM Claims WHERE Country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerDemographics (PlayerID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Location VARCHAR(50)); INSERT INTO PlayerDemographics (PlayerID, Age, Gender, Location) VALUES (1, 25, 'Female', 'New York'), (2, 35, 'Male', 'Los Angeles');
|
Update records in 'PlayerDemographics'
|
UPDATE PlayerDemographics SET Age = 36 WHERE PlayerID = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE extraction_volume_q3 (site_id INT, daily_volume INT, volume_date DATE); INSERT INTO extraction_volume_q3 (site_id, daily_volume, volume_date) VALUES (1, 20, '2022-07-01'), (1, 25, '2022-07-02'), (1, 30, '2022-07-03'); INSERT INTO extraction_volume_q3 (site_id, daily_volume, volume_date) VALUES (2, 25, '2022-07-01'), (2, 30, '2022-07-02'), (2, 35, '2022-07-03');
|
What is the average mineral extraction volume per day for a mine site in Q3 2022?
|
SELECT site_id, AVG(daily_volume) FROM extraction_volume_q3 WHERE volume_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY site_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE environmental_impact (id INT, mine_id INT, impact_type VARCHAR(50), value INT, PRIMARY KEY (id), FOREIGN KEY (mine_id) REFERENCES mines(id)); INSERT INTO environmental_impact (id, mine_id, impact_type, value) VALUES (1, 1, 'Water Usage', 3000); INSERT INTO environmental_impact (id, mine_id, impact_type, value) VALUES (2, 1, 'Water Usage', 3100); INSERT INTO environmental_impact (id, mine_id, impact_type, value) VALUES (3, 2, 'Water Usage', 5000); INSERT INTO environmental_impact (id, mine_id, impact_type, value) VALUES (4, 2, 'Water Usage', 5200); CREATE TABLE mines (id INT, name VARCHAR(50), location VARCHAR(50), annual_production INT, PRIMARY KEY (id)); INSERT INTO mines (id, name, location, annual_production) VALUES (1, 'Golden Mine', 'California', 15000); INSERT INTO mines (id, name, location, annual_production) VALUES (2, 'Silver Mine', 'Nevada', 22000);
|
What is the change in water usage for each mine over time?
|
SELECT mine_id, impact_type, value, LAG(value) OVER (PARTITION BY mine_id ORDER BY id) as previous_value FROM environmental_impact;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourist_expenditures (visitor_country VARCHAR(50), total_expenditure INT); INSERT INTO tourist_expenditures (visitor_country, total_expenditure) VALUES ('Argentina', 50000);
|
What is the total expenditure for tourists visiting Argentina, grouped by their countries of origin?
|
SELECT visitor_country, SUM(total_expenditure) FROM tourist_expenditures WHERE visitor_country = 'Argentina' GROUP BY visitor_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), conservation_year INT); INSERT INTO marine_species (species_id, species_name, conservation_year) VALUES (1, 'Spinner Dolphin', 2006), (2, 'Clownfish', 2010), (3, 'Shark', 2008); CREATE TABLE conservation_efforts (effort_id INT, species_name VARCHAR(50), year INT, description TEXT); INSERT INTO conservation_efforts (effort_id, species_name, year, description) VALUES (1, 'Turtle', 2005, 'Hawaiian green turtle recovery'), (2, 'Clownfish', 2010, 'Clownfish conservation program'), (3, 'Shark', 2008, 'Shark finning ban');
|
List the marine species that share a conservation year with the 'Shark' species.
|
SELECT ms1.species_name FROM marine_species ms1 INNER JOIN conservation_efforts ce ON ms1.conservation_year = ce.year WHERE ce.species_name = 'Shark' AND ms1.species_name != 'Shark';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (post_id INT, likes INT); INSERT INTO posts (post_id, likes) VALUES (1, 100), (2, 50);
|
Update the number of likes for post_id 1 to 150.
|
UPDATE posts SET likes = 150 WHERE post_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, rating FLOAT, production_country VARCHAR(50)); INSERT INTO movies (id, title, release_year, rating, production_country) VALUES (1, 'Movie1', 2005, 7.5, 'USA'), (2, 'Movie2', 2002, 8.2, 'USA'), (3, 'Movie3', 2012, 6.8, 'Canada');
|
What is the average rating of movies produced in the US between 2000 and 2010?
|
SELECT AVG(rating) FROM movies WHERE production_country = 'USA' AND release_year BETWEEN 2000 AND 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Museums (id INT, name VARCHAR(30)); CREATE TABLE Exhibitions (id INT, museum_id INT, city VARCHAR(20)); INSERT INTO Museums (id, name) VALUES (1, 'Tokyo Museum'), (2, 'Seoul Art Gallery'), (3, 'New York Met'); INSERT INTO Exhibitions (id, museum_id, city) VALUES (1, 1, 'Tokyo'), (2, 1, 'Seoul'), (3, 3, 'Paris');
|
List all museums that have hosted exhibitions in both Tokyo and Seoul.
|
SELECT Museums.name FROM Museums INNER JOIN Exhibitions ON Museums.id = Exhibitions.museum_id WHERE Exhibitions.city IN ('Tokyo', 'Seoul') GROUP BY Museums.name HAVING COUNT(DISTINCT Exhibitions.city) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites_2 (id INT, type VARCHAR(50), name VARCHAR(100)); INSERT INTO heritage_sites_2 (id, type, name) VALUES (1, 'Historic Site', 'Anasazi Ruins'), (2, 'Museum', 'Metropolitan Museum of Art'), (3, 'Historic Site', 'Alamo'); CREATE TABLE traditional_art_3 (id INT, artist VARCHAR(50), title VARCHAR(100)); INSERT INTO traditional_art_3 (id, artist, title) VALUES (1, 'Picasso', 'Guernica'), (2, 'Dali', 'Persistence of Memory'), (3, 'Picasso', 'Three Musicians');
|
What is the total number of heritage sites and traditional art pieces?
|
SELECT (SELECT COUNT(*) FROM heritage_sites_2) + (SELECT COUNT(*) FROM traditional_art_3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE streams (song_id INT, stream_date DATE, genre VARCHAR(20), country VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO streams (song_id, stream_date, genre, country, revenue) VALUES (13, '2021-03-03', 'Pop', 'Canada', 1.10), (14, '2021-03-04', 'Pop', 'Canada', 1.20);
|
What is the total revenue of Pop music streams in Canada in March 2021?
|
SELECT SUM(revenue) FROM streams WHERE genre = 'Pop' AND country = 'Canada' AND stream_date BETWEEN '2021-03-01' AND '2021-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_images (image_id INT, image_url TEXT, capture_time TIMESTAMP); INSERT INTO satellite_images (image_id, image_url, capture_time) VALUES (1, 'image1.jpg', '2022-01-01 10:00:00'), (2, 'image2.jpg', '2021-05-01 10:00:00');
|
What is the number of satellite images taken per day?
|
SELECT TRUNC(capture_time, 'DD') capture_day, COUNT(*) OVER (PARTITION BY TRUNC(capture_time, 'DD')) FROM satellite_images;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(100), region VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO biotech.startups (id, name, region, funding) VALUES (1, 'StartupA', 'Asia-Pacific', 3000000.00), (2, 'StartupB', 'USA', 2000000.00), (3, 'StartupC', 'Canada', 1200000.00);
|
What is the total funding received by biotech startups in the Asia-Pacific region?
|
SELECT SUM(funding) FROM biotech.startups WHERE region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(50), organization VARCHAR(50), amount INT); INSERT INTO donors (id, name, organization, amount) VALUES (1, 'John Doe', 'United Nations', 50000); INSERT INTO donors (id, name, organization, amount) VALUES (2, 'Jane Smith', 'World Food Programme', 40000); INSERT INTO donors (id, name, organization, amount) VALUES (3, 'Alice Johnson', 'Doctors Without Borders', 45000);
|
Identify the donors who have donated more than the average amount in the donors table.
|
SELECT * FROM donors WHERE amount > (SELECT AVG(total_donation) FROM (SELECT SUM(amount) AS total_donation FROM donors GROUP BY id) AS super_donors);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Bridges (BridgeID INT, Name VARCHAR(255), ConstructionDate DATE, Location VARCHAR(255)); INSERT INTO Bridges VALUES (1, 'Golden Gate Bridge', '1937-05-27', 'California'); INSERT INTO Bridges VALUES (2, 'Rio-Niterói Bridge', '1974-03-04', 'Rio de Janeiro, Brazil');
|
What are the construction dates and locations of all the bridges in South America?
|
SELECT ConstructionDate, Location FROM Bridges WHERE Location = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Budget (Program varchar(50), Allocation numeric(10,2)); INSERT INTO Budget (Program, Allocation) VALUES ('ProgramA', 5000.00), ('ProgramB', 3000.00);
|
What is the percentage of the total budget allocated to each program?
|
SELECT Program, Allocation, (Allocation / SUM(Allocation) OVER ()) * 100 AS BudgetPercentage FROM Budget;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_data (visitor_id INT, country VARCHAR(50), arrival_age INT); INSERT INTO tourism_data (visitor_id, country, arrival_age) VALUES (1, 'USA', 35), (2, 'USA', 42), (3, 'Japan', 28), (4, 'Australia', 31), (5, 'UK', 29), (6, 'UK', 34), (7, 'Canada', 22), (8, 'Canada', 25);
|
Update the arrival age of visitors from Japan to 30.
|
UPDATE tourism_data SET arrival_age = 30 WHERE country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (state VARCHAR(50), capacity INT); INSERT INTO landfill_capacity (state, capacity) VALUES ('Texas', 5000), ('California', 3000), ('New York', 4000);
|
What is the maximum landfill capacity in Texas?
|
SELECT MAX(capacity) FROM landfill_capacity WHERE state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_exploration ( id INT, mission_name VARCHAR(255), country VARCHAR(255), success BOOLEAN );
|
How many space missions have been successfully completed by the US?
|
SELECT COUNT(*) FROM space_exploration WHERE country = 'United States' AND success = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(50), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, JobTitle, Department) VALUES (1, 'Female', 'Software Engineer', 'IT'), (2, 'Male', 'Project Manager', 'Marketing'), (3, 'Non-binary', 'Data Analyst', 'HR'), (4, 'Female', 'Software Engineer', 'IT'), (5, 'Male', 'Software Engineer', 'IT'), (6, 'Non-binary', 'QA Engineer', 'HR');
|
List all job titles and the number of employees who identify as non-binary, for jobs in the HR department.
|
SELECT e.JobTitle, COUNT(*) as NumNonbinaryEmployees FROM Employees e WHERE e.Gender = 'Non-binary' AND e.Department = 'HR' GROUP BY e.JobTitle;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite (id INT, name VARCHAR(255), manufacturer VARCHAR(255), weight FLOAT); INSERT INTO Satellite (id, name, manufacturer, weight) VALUES (1, 'SES-1', 'Boeing', 6165);
|
What is the average weight of satellites manufactured by Boeing?
|
SELECT AVG(weight) FROM Satellite WHERE manufacturer = 'Boeing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(50), Community VARCHAR(50)); INSERT INTO Employees (EmployeeID, Name, Department, Gender, Community) VALUES (8, 'Emily Brown', 'Mining', 'Female', 'Indigenous'); INSERT INTO Employees (EmployeeID, Name, Department, Gender, Community) VALUES (9, 'Michael White', 'Mining', 'Male', 'Indigenous');
|
What is the percentage of Indigenous employees in the Mining department?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE Department = 'Mining')) AS Percentage FROM Employees WHERE Department = 'Mining' AND Community = 'Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Mediterranean_Fish_Stocks (id INT, stock VARCHAR(20), year INT, status VARCHAR(10)); INSERT INTO Mediterranean_Fish_Stocks (id, stock, year, status) VALUES (1, 'Sardine', 2017, 'Overfished'); INSERT INTO Mediterranean_Fish_Stocks (id, stock, year, status) VALUES (2, 'Anchovy', 2018, 'Sustainable');
|
Which Mediterranean fish stocks have been overfished in the last 5 years?
|
SELECT stock FROM Mediterranean_Fish_Stocks WHERE status = 'Overfished' AND year >= 2016;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Supplies (supply_id INT, supply_name VARCHAR(255), quantity INT, delivery_date DATE, service_area VARCHAR(255), agency VARCHAR(255)); INSERT INTO Supplies (supply_id, supply_name, quantity, delivery_date, service_area, agency) VALUES (3, 'Tools', 100, '2021-03-01', 'Rural Development', 'UNDP');
|
How many supplies were delivered to 'Rural Development' projects in '2021' by the 'UNDP'?
|
SELECT SUM(Supplies.quantity) FROM Supplies WHERE Supplies.service_area = 'Rural Development' AND Supplies.agency = 'UNDP' AND YEAR(Supplies.delivery_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Company (id INT, name TEXT, industry TEXT, founding_date DATE); INSERT INTO Company (id, name, industry, founding_date) VALUES (1, 'Acme Inc', 'Tech', '2016-01-02'); INSERT INTO Company (id, name, industry, founding_date) VALUES (2, 'Wright Startups', 'Transport', '2015-05-15'); INSERT INTO Company (id, name, industry, founding_date) VALUES (3, 'Bella Innovations', 'FashionTech', '2018-09-09'); CREATE TABLE Diversity (id INT, company_id INT, gender TEXT, employee_count INT); INSERT INTO Diversity (id, company_id, gender, employee_count) VALUES (1, 1, 'Female', 3000); INSERT INTO Diversity (id, company_id, gender, employee_count) VALUES (2, 2, 'Male', 5000); INSERT INTO Diversity (id, company_id, gender, employee_count) VALUES (3, 3, 'Non-binary', 1500);
|
What is the average number of employees per gender for companies founded after 2015?
|
SELECT Company.founding_date, Diversity.gender, AVG(Diversity.employee_count) FROM Company RIGHT JOIN Diversity ON Company.id = Diversity.company_id WHERE Company.founding_date > '2015-01-01' GROUP BY Company.founding_date, Diversity.gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecycledMaterialGarments (id INT, production_date DATE); INSERT INTO RecycledMaterialGarments (id, production_date) VALUES (1, '2021-01-01'), (2, '2021-02-15'), (3, '2020-12-20');
|
How many garments have been produced using recycled materials in the last year?
|
SELECT COUNT(*) FROM RecycledMaterialGarments WHERE production_date >= '2021-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shows (id INT, title TEXT, genre TEXT); INSERT INTO shows (id, title, genre) VALUES (1, 'News Show1', 'News'), (2, 'Entertainment Show2', 'Entertainment'), (3, 'Breaking News Show3', 'News');
|
How many TV shows have the word 'News' in their title?
|
SELECT COUNT(*) FROM shows WHERE title LIKE '%News%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MitigationProjects (ID INT, Country VARCHAR(255), Projects INT); INSERT INTO MitigationProjects (ID, Country, Projects) VALUES (1, 'Nigeria', 5), (2, 'Kenya', 7), (3, 'South Africa', 8), (4, 'Egypt', 6), (5, 'Morocco', 9);
|
What is the average number of climate change mitigation projects in African countries?
|
SELECT AVG(Projects) FROM MitigationProjects WHERE Country IN ('Nigeria', 'Kenya', 'South Africa', 'Egypt', 'Morocco');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if NOT EXISTS iot_sensors (id int, location varchar(50), temperature float, timestamp datetime); INSERT INTO iot_sensors (id, location, temperature, timestamp) VALUES (1, 'Texas', 25.6, '2022-01-01 10:00:00'), (2, 'Texas', 27.2, '2022-01-02 10:00:00');
|
What is the average temperature in Texas IoT sensors last week?
|
SELECT AVG(temperature) FROM iot_sensors WHERE location = 'Texas' AND timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(50), country VARCHAR(20)); INSERT INTO mining_sites (site_id, site_name, country) VALUES (1, 'Mining Site A', 'Ghana'), (2, 'Mining Site B', 'Ghana'), (3, 'Mining Site C', 'Ghana'); CREATE TABLE eia_schedule (site_id INT, eia_date DATE); INSERT INTO eia_schedule (site_id, eia_date) VALUES (1, '2022-05-01'), (2, '2022-06-15'), (3, '2022-07-20'); CREATE TABLE safety_inspection (site_id INT, inspection_date DATE); INSERT INTO safety_inspection (site_id, inspection_date) VALUES (1, '2021-05-01'), (2, '2021-06-15'), (3, '2021-07-20');
|
List mining sites in Ghana with overdue environmental impact assessments (EIAs) and safety inspections.
|
SELECT site_name FROM mining_sites INNER JOIN eia_schedule ON mining_sites.site_id = eia_schedule.site_id INNER JOIN safety_inspection ON mining_sites.site_id = safety_inspection.site_id WHERE eia_schedule.eia_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND safety_inspection.inspection_date < DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name TEXT, founded_year INT, founder_ethnicity TEXT, industry TEXT); INSERT INTO startups (id, name, founded_year, founder_ethnicity, industry) VALUES (1, 'Delta Enterprises', 2020, 'Latinx', 'Retail'); INSERT INTO startups (id, name, founded_year, founder_ethnicity, industry) VALUES (2, 'Epsilon Co', 2018, 'Asian', 'Education'); INSERT INTO startups (id, name, founded_year, founder_ethnicity, industry) VALUES (3, 'Theta Startup', 2018, 'Pacific Islander', 'Artificial Intelligence');
|
List all startups founded by Pacific Islander entrepreneurs in the 'Artificial Intelligence' industry
|
SELECT * FROM startups WHERE founder_ethnicity = 'Pacific Islander' AND industry = 'Artificial Intelligence';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(255), faculty_gender VARCHAR(255), faculty_race_ethnicity VARCHAR(255), faculty_department VARCHAR(255)); CREATE TABLE publications (publication_id INT, faculty_id INT, publication_title VARCHAR(255), publication_date DATE);
|
What is the total number of publications in the past year by faculty members from underrepresented racial and ethnic groups?
|
SELECT SUM(cnt) FROM (SELECT f.faculty_race_ethnicity, COUNT(*) AS cnt FROM faculty f INNER JOIN publications p ON f.faculty_id = p.faculty_id WHERE p.publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND f.faculty_race_ethnicity IN ('Underrepresented Racial Group 1', 'Underrepresented Ethnic Group 1') GROUP BY f.faculty_race_ethnicity) subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-02'), (3, 1, '2022-01-03'), (4, 2, '2022-01-04'), (5, 2, '2022-01-04'), (6, 3, '2022-01-05');
|
What is the average number of posts per day for each user?
|
SELECT user_id, AVG(COUNT(*)) AS avg_posts_per_day FROM posts GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO Brands (BrandID, BrandName) VALUES (1, 'Brand1'), (2, 'Brand2'), (3, 'Brand3'); CREATE TABLE BrandMaterials (BrandID INT, Material VARCHAR(50), Quantity INT, IsSustainable BOOLEAN); INSERT INTO BrandMaterials (BrandID, Material, Quantity, IsSustainable) VALUES (1, 'Material1', 10, TRUE), (1, 'Material2', 20, FALSE), (2, 'Material1', 30, TRUE);
|
What is the total quantity of sustainable materials used by all brands?
|
SELECT SUM(Quantity) FROM BrandMaterials WHERE IsSustainable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Consumers (id INT, name VARCHAR(100), country VARCHAR(50), sustainability_score INT);
|
Find the top 5 consumers of sustainable materials in 2020
|
SELECT name FROM (SELECT name, sustainability_score, ROW_NUMBER() OVER (ORDER BY sustainability_score DESC) as rn FROM Consumers WHERE year = 2020) t WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (Region TEXT); INSERT INTO Regions VALUES ('Northeast'), ('Midwest'), ('South'), ('West'); CREATE TABLE Cases (CaseID INT, Region TEXT, Hours DECIMAL, HourlyRate DECIMAL); INSERT INTO Cases VALUES (1, 'Northeast', 10, 200), (2, 'Midwest', 8, 180), (3, 'South', 15, 220), (4, 'Midwest', 12, 250);
|
What is the total billing amount for cases in the Midwest region?
|
SELECT SUM(Cases.Hours * Cases.HourlyRate) FROM Cases INNER JOIN Regions ON Cases.Region = Regions.Region WHERE Regions.Region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE price_trends (element VARCHAR(2), month INT, year INT, price DECIMAL(5,2)); INSERT INTO price_trends VALUES ('Pm', 1, 2021, 12.5), ('Pm', 2, 2021, 13.6), ('Pm', 3, 2021, 14.2), ('Pm', 1, 2021, 12.0);
|
What was the maximum market price for Promethium (Pm) in 2021?
|
SELECT MAX(price) AS max_price FROM price_trends WHERE element = 'Pm' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE training_times (id INT, dataset VARCHAR(255), algorithm VARCHAR(255), time FLOAT); INSERT INTO training_times (id, dataset, algorithm, time) VALUES (1, 'MNIST', 'adaboost', 2.4), (2, 'CIFAR-10', 'adaboost', 3.1), (3, 'ImageNet', 'svm', 4.5);
|
What is the maximum training time for models using the 'adaboost' algorithm across all datasets?
|
SELECT MAX(time) FROM training_times WHERE algorithm = 'adaboost';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 72.5), (2, 'finance', 68.3), (3, 'technology', 75.1);
|
What's the average ESG score for companies in the 'technology' sector?
|
SELECT AVG(ESG_score) FROM companies WHERE sector = 'technology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (id INT, name VARCHAR(50), sport VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO athletes (id, name, sport, age, gender) VALUES (1, 'Alice', 'Football', 25, 'Female'); INSERT INTO athletes (id, name, sport, age, gender) VALUES (2, 'Bob', 'Basketball', 30, 'Male');
|
What is the average age of female athletes in the Football division?
|
SELECT AVG(age) FROM athletes WHERE sport = 'Football' AND gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W010', '2021-03-01', 150.5), ('W010', '2021-03-04', 175.0);
|
Update the production quantity for well 'W010' on '2021-03-04' to 185.0 in the Oil_Production table?
|
UPDATE Oil_Production SET quantity = 185.0 WHERE well = 'W010' AND production_date = '2021-03-04';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_preferences (consumer_id INT, product_id INT, preference_rating INT, timestamp DATETIME); INSERT INTO consumer_preferences (consumer_id, product_id, preference_rating, timestamp) VALUES (1, 101, 5, '2020-01-01 10:00:00'), (2, 102, 4, '2020-01-02 15:30:00');
|
What are the top 5 most preferred cosmetic products by consumers in the USA, considering consumer preference data from the past 2 years?
|
SELECT product_id, AVG(preference_rating) as avg_rating FROM consumer_preferences WHERE timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 2 YEAR) AND NOW() GROUP BY product_id ORDER BY avg_rating DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT, region_name TEXT);CREATE TABLE wildlife_habitat (habitat_id INT, region_id INT, area_ha INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); INSERT INTO wildlife_habitat (habitat_id, region_id, area_ha) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 8000), (4, 3, 9000);
|
What is the total area of wildlife habitat for each region?
|
SELECT region_id, region_name, SUM(area_ha) FROM wildlife_habitat JOIN regions ON wildlife_habitat.region_id = regions.region_id GROUP BY region_id, region_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicleHorsepower (VehicleID INT, Year INT, Horsepower FLOAT);
|
What is the minimum horsepower of electric vehicles released in 2023?
|
SELECT MIN(Horsepower) FROM ElectricVehicleHorsepower WHERE Year = 2023 AND VehicleID IN (SELECT DISTINCT VehicleID FROM ElectricVehicles);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, department_name VARCHAR(255)); CREATE TABLE research_grants (id INT, grant_name VARCHAR(255), grant_amount INT, department_id INT, grant_year INT, PRIMARY KEY (id), FOREIGN KEY (department_id) REFERENCES departments(id)); INSERT INTO departments (id, department_name) VALUES (1, 'Computer Science'), (2, 'Mathematics'), (3, 'Physics'); INSERT INTO research_grants (id, grant_name, grant_amount, department_id, grant_year) VALUES (1, 'Grant1', 50000, 1, 2021), (2, 'Grant2', 75000, 2, 2022), (3, 'Grant3', 100000, 3, 2021);
|
How many research grants were awarded to the Computer Science department in 2021?
|
SELECT COUNT(*) as grant_count FROM research_grants WHERE department_id = (SELECT id FROM departments WHERE department_name = 'Computer Science') AND grant_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics_sales (product VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255));
|
Delete all mascara records from the cosmetics_sales table for the year 2021.
|
DELETE FROM cosmetics_sales WHERE product IN (SELECT product FROM cosmetics WHERE product_category = 'Mascaras') AND YEAR(sale_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE professors (id INT, name TEXT, gender TEXT, research_interest TEXT); INSERT INTO professors (id, name, gender, research_interest) VALUES (1, 'Alice', 'Female', 'Machine Learning'); INSERT INTO professors (id, name, gender, research_interest) VALUES (2, 'Bob', 'Male', 'Data Science');
|
What are the names and research interests of female professors in the Computer Science department?
|
SELECT name, research_interest FROM professors WHERE gender = 'Female' AND department = 'Computer Science';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destination_marketing (destination VARCHAR(255), attraction VARCHAR(255), start_date DATE, end_date DATE);
|
Update the destination_marketing table to set the end_date to '30-JUN-2023' for the record with the attraction 'Eiffel Tower'
|
UPDATE destination_marketing SET end_date = '2023-06-30' WHERE attraction = 'Eiffel Tower';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE prison (id INT, name TEXT, security_level TEXT, age INT); INSERT INTO prison (id, name, security_level, age) VALUES (1, 'Federal Correctional Institution Ashland', 'low_security', 45); INSERT INTO prison (id, name, security_level, age) VALUES (2, 'Federal Correctional Institution Bastrop', 'medium_security', 35);
|
What is the total number of inmates in the low_security and medium_security prisons?
|
SELECT COUNT(*) FROM prison WHERE security_level IN ('low_security', 'medium_security');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE courses (id INT, name VARCHAR(50), open_pedagogy BOOLEAN, enrollment INT); INSERT INTO courses (id, name, open_pedagogy, enrollment) VALUES (1, 'Introduction to Programming', true, 500);
|
Open pedagogy courses with enrollment greater than or equal to 400
|
SELECT name FROM courses WHERE open_pedagogy = true AND enrollment >= 400;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (facility_id INT, facility_name VARCHAR(255), emission_date DATE, co2_emission DECIMAL(10,2)); INSERT INTO co2_emissions (facility_id, facility_name, emission_date, co2_emission) VALUES (1, 'Facility A', '2021-01-01', 500.00), (2, 'Facility B', '2021-02-01', 700.00), (3, 'Facility C', '2021-03-01', 800.00);
|
What was the average monthly CO2 emission for each manufacturing facility in 2021?
|
SELECT facility_name, AVG(co2_emission) as avg_monthly_emission FROM co2_emissions WHERE emission_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY facility_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name TEXT, location TEXT, carbon_emissions FLOAT); INSERT INTO mines (id, name, location, carbon_emissions) VALUES (1, 'Golden Mine', 'Colorado, USA', 5000), (2, 'Silver Ridge', 'Nevada, USA', 6000), (3, 'Bronze Basin', 'Utah, USA', 4000);
|
Which mines have the highest levels of carbon emissions?
|
SELECT name FROM mines WHERE carbon_emissions IN (SELECT MAX(carbon_emissions) FROM mines)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W002', '2021-01-01', 150.5), ('W002', '2021-01-02', 160.3), ('W002', '2021-01-03', 170.0);
|
What was the production quantity for well 'W002' on '2021-01-03' in the Oil_Production table?
|
SELECT quantity FROM Oil_Production WHERE well = 'W002' AND production_date = '2021-01-03';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA FoodService;CREATE TABLE Sales (sales_id INT, menu_item_id INT, restaurant_id INT, quantity INT); INSERT INTO Sales (sales_id, menu_item_id, restaurant_id, quantity) VALUES (1, 1, 1, 50), (2, 2, 1, 30), (3, 3, 2, 40), (4, 4, 2, 60);CREATE SCHEMA FoodService;CREATE TABLE MenuItems (menu_item_id INT, name VARCHAR(50), category VARCHAR(50), quantity INT); INSERT INTO MenuItems (menu_item_id, name, category, quantity) VALUES (1, 'Chicken Caesar Salad', 'dining', 100), (2, 'Vegetarian Pizza', 'dining', 100), (3, 'Chicken Burger', 'takeout', 100), (4, 'Fish and Chips', 'takeout', 100);
|
What is the total quantity of the most popular menu item sold for each restaurant category?
|
SELECT category, MAX(quantity) as max_quantity FROM Sales JOIN MenuItems ON Sales.menu_item_id = MenuItems.menu_item_id GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE date (date DATE); CREATE TABLE investment (transaction_id INT, date DATE, value DECIMAL(10,2), type VARCHAR(10));
|
What is the total transaction value for each day in the "investment" table, for transactions that occurred in the month of February 2022 and are of type "buy"?
|
SELECT d.date, SUM(i.value) as total_value FROM date d JOIN investment i ON d.date = i.date WHERE i.type = 'buy' AND MONTH(d.date) = 2 AND YEAR(d.date) = 2022 GROUP BY d.date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat_preservation (id INT, animal_species VARCHAR(50), population INT, continent VARCHAR(50)); INSERT INTO habitat_preservation (id, animal_species, population, continent) VALUES (1, 'Tiger', 2000, 'Asia'), (2, 'Elephant', 5000, 'Africa'), (3, 'Giraffe', 8000, 'Africa'), (4, 'Kangaroo', 9000, 'Australia'), (5, 'Panda', 1000, 'Asia');
|
List all continents and the number of animal species they have in the 'habitat_preservation' table
|
SELECT continent, COUNT(DISTINCT animal_species) FROM habitat_preservation GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, category VARCHAR(255), revenue INT); INSERT INTO products (product_id, category, revenue) VALUES (1, 'Electronics', 5000), (2, 'Fashion', 3000), (3, 'Electronics', 7000);
|
What is the total revenue for each category of products?
|
SELECT category, SUM(revenue) FROM products GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (id INT, name TEXT, amount_donated INT); INSERT INTO initiatives (id, name, amount_donated) VALUES (1, 'Climate Change Mitigation', 50000);
|
What's the total amount donated to climate change mitigation initiatives?
|
SELECT SUM(amount_donated) FROM initiatives WHERE name = 'Climate Change Mitigation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_from_id INT, warehouse_to_id INT, weight FLOAT, is_return BOOLEAN); INSERT INTO warehouse VALUES (1, 'LA'), (2, 'NY'), (3, 'CA'); INSERT INTO shipment VALUES (1, 1, 3, 50.3, FALSE), (2, 2, 3, 60.2, TRUE), (3, 3, 1, 45.1, TRUE), (4, 1, 3, 70.4, TRUE);
|
What is the total weight of all shipments that were sent to the 'CA' warehouse and then returned?
|
SELECT SUM(shipment.weight) FROM shipment WHERE shipment.warehouse_to_id = (SELECT id FROM warehouse WHERE name = 'CA') AND shipment.is_return = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vendors (id INT, name TEXT, country TEXT, industry TEXT); INSERT INTO vendors (id, name, country, industry) VALUES (1, 'EcoPower', 'China', 'Renewable Energy'), (2, 'SunIndia', 'India', 'Solar');
|
What are the names of vendors from India working in the Solar industry?
|
SELECT name FROM vendors WHERE country = 'India' AND industry = 'Solar';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Funding (Year INT, Region VARCHAR(20), Initiative VARCHAR(30), Funding DECIMAL(10,2)); INSERT INTO Funding (Year, Region, Initiative, Funding) VALUES (2022, 'Asia', 'Climate Mitigation', 500000.00);
|
Update the funding for climate mitigation initiatives in Asia for 2022 to 750000.00?
|
UPDATE Funding SET Funding = 750000.00 WHERE Year = 2022 AND Region = 'Asia' AND Initiative = 'Climate Mitigation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatment_outcomes (outcome_id INT, patient_id INT, therapy_type VARCHAR(50), improvement_score INT); INSERT INTO treatment_outcomes (outcome_id, patient_id, therapy_type, improvement_score) VALUES (1, 1, 'CBT', 12);
|
What is the success rate of patients by treatment type?
|
SELECT therapy_type, AVG(improvement_score) FROM treatment_outcomes GROUP BY therapy_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_name VARCHAR(255), season_start_year INT, season_end_year INT); INSERT INTO teams (team_name, season_start_year, season_end_year) VALUES ('Spurs', 2016, 2017); CREATE TABLE games (team_name VARCHAR(255), location VARCHAR(255), won BOOLEAN);
|
How many games did the Spurs win at away games in the 2016-2017 season?
|
SELECT COUNT(*) FROM games WHERE team_name = 'Spurs' AND location = 'away' AND won = TRUE AND season_start_year = 2016 AND season_end_year = 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (id INT, department VARCHAR, billing_amount DECIMAL); INSERT INTO attorneys (id, department, billing_amount) VALUES (1, 'Civil', 75000.00), (2, 'Criminal', 100000.00), (3, 'Family', 85000.00), (4, 'Immigration', 120000.00), (5, 'Immigration', 110000.00);
|
What is the average billing amount for cases in the immigration department?
|
SELECT AVG(billing_amount) FROM attorneys WHERE department = 'Immigration';
|
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); INSERT INTO city_data (city, shared_ebikes) VALUES ('New York', true), ('Los Angeles', false), ('Chicago', true);
|
Find the total number of trips made by shared electric bikes in New York
|
SELECT SUM(trip_count) FROM shared_vehicles WHERE vehicle_type = 'ebike' AND id IN (SELECT id FROM city_data WHERE city = 'New York' AND shared_ebikes = true);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie_studios (studio_id INT, studio_name TEXT, country TEXT); INSERT INTO movie_studios (studio_id, studio_name, country) VALUES (1, 'Studio A', 'USA'), (2, 'Studio B', 'Canada'), (3, 'Studio G', 'France'); CREATE TABLE movies (movie_id INT, title TEXT, release_date DATE, studio_id INT, revenue INT); INSERT INTO movies (movie_id, title, release_date, studio_id, revenue) VALUES (1, 'Movie 7', '2018-01-01', 3, 1000000), (2, 'Movie 8', '2017-06-15', 2, 800000), (3, 'Movie 9', '2019-12-25', 3, 1200000);
|
What is the total revenue of movies produced by Studio G in 2018 and 2019?
|
SELECT SUM(movies.revenue) FROM movies JOIN movie_studios ON movies.studio_id = movie_studios.studio_id WHERE movie_studios.studio_name = 'Studio G' AND YEAR(movies.release_date) BETWEEN 2018 AND 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_protocols (id INT PRIMARY KEY, chemical_name VARCHAR(100), protocol VARCHAR(500));
|
Add the new safety protocol for chemical ABC to the safety_protocols table.
|
INSERT INTO safety_protocols (id, chemical_name, protocol) VALUES (4, 'ABC', 'Store in a cool, dry place. Use protective gloves and eyewear.');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (id INT, name TEXT, years_with_firm INT); INSERT INTO attorneys (id, name, years_with_firm) VALUES (1, 'Jane Smith', 10), (2, 'John Doe', 2), (3, 'Sarah Lee', 7); CREATE TABLE cases (id INT, attorney_id INT, billing_amount INT); INSERT INTO cases (id, attorney_id, billing_amount) VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 3000), (4, 3, 4000), (5, 3, 5000);
|
What is the total billing amount for cases handled by attorneys who have been with the firm for more than 5 years?
|
SELECT SUM(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.years_with_firm > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (id INT, item_name VARCHAR(255), item_type VARCHAR(255), quantity INT, sustainable BOOLEAN, purchase_date DATE); INSERT INTO Inventory (id, item_name, item_type, quantity, sustainable, purchase_date) VALUES (1, 'Salmon Fillet', 'Seafood', 10, true, '2022-02-01'), (2, 'Shrimp', 'Seafood', 20, false, '2022-02-03'), (3, 'Tilapia', 'Seafood', 15, true, '2022-02-05');
|
What is the total weight of sustainable seafood used in the last month?
|
SELECT SUM(quantity) FROM Inventory WHERE item_type = 'Seafood' AND sustainable = true AND purchase_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_scores (player_id INT, game_id INT, score INT); INSERT INTO player_scores (player_id, game_id, score) VALUES (1, 1, 1000), (2, 1, 1200), (3, 2, 1500), (4, 2, 1300), (5, 3, 1100), (6, 1, 1400), (6, 2, 1600), (6, 3, 1700);
|
Which players have achieved the highest scores in the 'player_scores' table of the 'gaming' database?
|
SELECT player_id, MAX(score) as highest_score FROM player_scores GROUP BY player_id ORDER BY highest_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (id INT, name VARCHAR(255), country VARCHAR(255), uses_sustainable_materials BOOLEAN);
|
Find the number of factories in each country that use sustainable materials.
|
SELECT country, COUNT(*) FROM factories WHERE uses_sustainable_materials = TRUE GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (id INT, name VARCHAR(50), age INT, platform VARCHAR(50)); INSERT INTO Players (id, name, age, platform) VALUES (1, 'Player1', 25, 'PC'), (2, 'Player2', 30, 'Console'), (3, 'Player3', 35, 'Mobile');
|
What is the average age of players who play games on each platform, and what is the maximum age of players on a single platform?
|
SELECT platform, AVG(age) AS avg_age, MAX(age) AS max_age_per_platform FROM Players GROUP BY platform;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT, community_service_hours INT); INSERT INTO athletes (athlete_id, athlete_name, team_id, community_service_hours) VALUES (1, 'John Doe', 1, 50); INSERT INTO athletes (athlete_id, athlete_name, team_id, community_service_hours) VALUES (2, 'Jane Smith', 2, 75);
|
Which athletes have the highest number of community service hours in the Southeast division?
|
SELECT athletes.athlete_name, SUM(community_service_hours) as total_hours FROM athletes JOIN teams ON athletes.team_id = teams.team_id WHERE teams.division = 'Southeast' GROUP BY athletes.athlete_name ORDER BY total_hours DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id SERIAL PRIMARY KEY, name TEXT, yield INT, region TEXT); INSERT INTO crops (name, yield, region) VALUES ('corn', 120, 'North America'), ('rice', 220, 'Asia'), ('wheat', 90, 'Europe');
|
Show all entries in the "crops" table
|
SELECT * FROM crops;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT, Name TEXT, Nationality TEXT, Award INT); CREATE TABLE Artworks (ArtworkID INT, ArtistID INT, CreationYear INT); INSERT INTO Artists (ArtistID, Name, Nationality, Award) VALUES (1, 'Yayoi Kusama', 'Japanese', 1); INSERT INTO Artworks (ArtworkID, ArtistID, CreationYear) VALUES (1, 1, 1990);
|
How many artworks were created by artists from Japan who have won awards?
|
SELECT COUNT(*) FROM Artworks A JOIN Artists B ON A.ArtistID = B.ArtistID WHERE B.Nationality = 'Japanese' AND B.Award = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fare_collection (id INT, vehicle_type VARCHAR(20), fare_date DATE, fare FLOAT); INSERT INTO fare_collection (id, vehicle_type, fare_date, fare) VALUES (1, 'Bus', '2021-03-16', 2.5), (2, 'Tram', '2021-03-18', 3.0), (3, 'Train', '2021-03-20', 3.5);
|
What was the average fare for each vehicle type in the second half of March 2021?
|
SELECT vehicle_type, AVG(fare) as avg_fare FROM fare_collection WHERE fare_date BETWEEN '2021-03-16' AND '2021-03-31' GROUP BY vehicle_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, sale_date DATE, sale_channel VARCHAR(10), revenue DECIMAL(10,2));
|
What is the total revenue generated from online sales in the year 2022?
|
SELECT SUM(revenue) FROM sales WHERE sale_channel = 'online' AND YEAR(sale_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT, Name TEXT, Age INT, Genre TEXT); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (1, 'Taylor Swift', 32, 'Country'); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (2, 'Carrie Underwood', 39, 'Country');
|
What is the average age of all country music artists?
|
SELECT AVG(Age) FROM Artists WHERE Genre = 'Country';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_farms (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO wind_farms (id, name, region, capacity_mw) VALUES (1, 'Windfarm A', 'west', 150.5); INSERT INTO wind_farms (id, name, region, capacity_mw) VALUES (2, 'Windfarm B', 'east', 120.2); CREATE TABLE solar_power_plants (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (1, 'Solar Plant A', 'north', 125.8); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (2, 'Solar Plant B', 'south', 180.3);
|
What is the total installed capacity (in MW) of all renewable energy projects in the 'south' region?
|
SELECT SUM(capacity_mw) FROM wind_farms WHERE region = 'south' UNION ALL SELECT SUM(capacity_mw) FROM solar_power_plants WHERE region = 'south';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vehicle_Specs (id INT, make VARCHAR(50), model VARCHAR(50), segment VARCHAR(50), fuel_efficiency FLOAT, country VARCHAR(50)); INSERT INTO Vehicle_Specs (id, make, model, segment, fuel_efficiency, country) VALUES (1, 'Mercedes-Benz', 'C-Class', 'Luxury', 25.5, 'India'); INSERT INTO Vehicle_Specs (id, make, model, segment, fuel_efficiency, country) VALUES (2, 'BMW', '3 Series', 'Luxury', 23.4, 'India');
|
What is the average fuel efficiency of vehicles in the luxury segment in India?
|
SELECT AVG(fuel_efficiency) FROM Vehicle_Specs WHERE segment = 'Luxury' AND country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (id INT, country VARCHAR(255), name VARCHAR(255), launch_date DATE);
|
What is the earliest launch date for a satellite by any country?
|
SELECT MIN(launch_date) FROM satellites;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_sales (id INT, region VARCHAR(255), sale_value FLOAT); INSERT INTO equipment_sales (id, region, sale_value) VALUES (1, 'Asia-Pacific', 5000000); INSERT INTO equipment_sales (id, region, sale_value) VALUES (2, 'Europe', 7000000);
|
What is the total value of military equipment sales in the Asia-Pacific region?
|
SELECT SUM(sale_value) FROM equipment_sales WHERE region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (id INT, name VARCHAR, location VARCHAR, patients_served INT); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (1, 'John Doe', 'Rural', 50); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (2, 'Jane Smith', 'Rural', 75);
|
What is the average number of patients served by community health workers in rural areas?
|
SELECT location, AVG(patients_served) as avg_patients FROM community_health_workers WHERE location = 'Rural' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE us_water_usage (sector VARCHAR(50), usage INT); INSERT INTO us_water_usage (sector, usage) VALUES ('Agriculture', 130000000000), ('Industry', 45000000000), ('Residential', 35000000000);
|
What is the total water consumption in the United States and the percentage of water that is used for agriculture?
|
SELECT SUM(usage) FROM us_water_usage; SELECT (usage/SUM(usage)*100) FROM us_water_usage WHERE sector = 'Agriculture';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists water_quality (id INT PRIMARY KEY, location VARCHAR(50), water_quality_index FLOAT); CREATE TABLE if not exists water_treatment_plants (id INT PRIMARY KEY, location VARCHAR(50), treatment_capacity FLOAT); CREATE VIEW if not exists water_quality_report AS SELECT wq.location, (wq.water_quality_index - wtp.treatment_capacity) as treatment_efficiency FROM water_quality wq JOIN water_treatment_plants wtp ON wq.location = wtp.location;
|
Which water treatment plants have the highest treatment capacity but low water quality index?
|
SELECT location, treatment_efficiency, treatment_capacity FROM water_quality_report JOIN water_treatment_plants ON location = water_treatment_plants.location WHERE treatment_efficiency < 0 ORDER BY treatment_capacity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_sites (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO cultural_sites (id, name, country, visitors) VALUES (1, 'Eiffel Tower', 'France', 15000);
|
Update the number of visitors of the 'Eiffel Tower' in 'France' to 20000
|
UPDATE cultural_sites SET visitors = 20000 WHERE name = 'Eiffel Tower' AND country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (id INT, name VARCHAR(255), has_nutrition_label BOOLEAN); INSERT INTO dishes (id, name, has_nutrition_label) VALUES (1, 'Pad Thai', true), (2, 'Fried Rice', false), (3, 'Pizza', true), (4, 'Tacos', false), (5, 'Curry', true), (6, 'Coq au Vin', false);
|
How many dishes in the database have a nutritional information label?
|
SELECT COUNT(*) FROM dishes WHERE has_nutrition_label = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft_temperatures (spacecraft_name TEXT, temperature FLOAT, mission_date DATE);
|
What is the average temperature (in Kelvin) recorded by spacecrafts during their missions?
|
SELECT AVG(temperature) FROM spacecraft_temperatures;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (region VARCHAR(20), sector VARCHAR(20), usage INT); INSERT INTO water_usage (region, sector, usage) VALUES ('North', 'Agriculture', 300), ('North', 'Domestic', 200), ('North', 'Industrial', 500), ('South', 'Agriculture', 400), ('South', 'Domestic', 250), ('South', 'Industrial', 600);
|
What is the minimum water usage by a sector in the South region?
|
SELECT sector, MIN(usage) FROM water_usage WHERE region = 'South'
|
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.