context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE ingredients (ingredient_id INT, ingredient_name VARCHAR(50), product_id INT); INSERT INTO ingredients (ingredient_id, ingredient_name, product_id) VALUES (1, 'Water', 1), (2, 'Glycerin', 1), (3, 'Shea Butter', 2), (4, 'Coconut Oil', 3), (5, 'Jojoba Oil', 3), (6, 'Aloe Vera', 4), (7, 'Beeswax', 4), (8, 'Ros...
What are the top 5 most popular ingredients in cosmetics products?
SELECT i.ingredient_name, COUNT(*) as product_count FROM ingredients i JOIN products p ON i.product_id = p.product_id GROUP BY i.ingredient_name ORDER BY product_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty(FacultyID INT, Gender VARCHAR(255), Department VARCHAR(255), GrantAmount DECIMAL(10, 2)); INSERT INTO Faculty VALUES (1, 'Female', 'Mathematics', 50000.00);
Find the average grant amount awarded to female faculty members in the Mathematics department.
SELECT AVG(Faculty.GrantAmount) FROM Faculty WHERE Faculty.Gender = 'Female' AND Faculty.Department = 'Mathematics';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (state VARCHAR(2), violations INT); INSERT INTO mental_health_parity (state, violations) VALUES ('NY', 40), ('CA', 35), ('TX', 50);
What is the total number of mental health parity violations by state?
SELECT state, SUM(violations) OVER (PARTITION BY 1) as total_violations FROM mental_health_parity;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), revenue FLOAT, booking_date DATE); INSERT INTO accommodations (id, name, type, revenue, booking_date) VALUES (1, 'Eco Lodge', 'Eco-Friendly', 500, '2022-01-01'), (2, 'Sustainable Resort', 'Eco-Friendly', 800, '2022-01-05'), (3, 'Gree...
What is the total revenue generated from eco-friendly accommodations in the last month?
SELECT monthly_revenue FROM eco_friendly_revenue WHERE booking_month = DATE_FORMAT(NOW() - INTERVAL 1 MONTH, '%Y-%m');
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, title TEXT, release_year INT, genre TEXT, popularity INT);
What is the most popular genre for each year?
SELECT release_year, genre, MAX(popularity) FROM songs GROUP BY release_year ORDER BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Education_Dept (Dept_Name VARCHAR(255), Service_Category VARCHAR(255), Budget_Allocated INT); INSERT INTO Education_Dept (Dept_Name, Service_Category, Budget_Allocated) VALUES ('Education', 'Early Childhood Education', 1500000), ('Education', 'Primary Education', 4000000), ('Education', 'Secondary Educatio...
What is the average budget allocation per service category in the Education department?
SELECT AVG(Budget_Allocated) as Average_Budget, Service_Category FROM Education_Dept GROUP BY Service_Category;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_inventory (id INT, chemical_name VARCHAR(50), safety_stock INT);
List all chemical names and their safety stock from 'chemical_inventory' table
SELECT chemical_name, safety_stock FROM chemical_inventory;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_sightings (id INT, species VARCHAR(255), sighting_date DATE);
List the wildlife species with their sighting frequency in the forest?
SELECT species, COUNT(*) as sighting_frequency FROM wildlife_sightings GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE UnderwritingDepartments (DeptID INT, DeptName TEXT, EmployeeID INT); INSERT INTO UnderwritingDepartments (DeptID, DeptName, EmployeeID) VALUES (1, 'Life', 100); INSERT INTO UnderwritingDepartments (DeptID, DeptName, EmployeeID) VALUES (2, 'Health', NULL);
Which underwriting departments have no employees?
SELECT DeptName FROM UnderwritingDepartments WHERE EmployeeID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255)); CREATE TABLE grant (id INT, department_id INT, amount DECIMAL(10, 2));
What is the total grant amount awarded to each department?
SELECT department.name, SUM(grant.amount) FROM department INNER JOIN grant ON department.id = grant.department_id GROUP BY department.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ChemicalProduction (date DATE, chemical VARCHAR(10), mass FLOAT); INSERT INTO ChemicalProduction (date, chemical, mass) VALUES ('2021-01-01', 'A', 100), ('2021-01-01', 'B', 150), ('2021-01-02', 'A', 120), ('2021-01-02', 'B', 170);
Which chemical has the highest average mass produced daily?
SELECT chemical, AVG(mass) as AvgMass FROM ChemicalProduction GROUP BY chemical ORDER BY AvgMass DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, disability BOOLEAN, visit_date DATE); INSERT INTO visitors (id, disability, visit_date) VALUES (1, true, '2022-01-01'); INSERT INTO visitors (id, disability, visit_date) VALUES (2, false, '2022-02-15');
How many visitors with disabilities visited our museum in the last quarter?
SELECT COUNT(*) FROM visitors WHERE disability = true AND visit_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Events_Attendance (city VARCHAR(20), event VARCHAR(30), attendance INT); INSERT INTO Events_Attendance (city, event, attendance) VALUES ('Sydney', 'Opera', 5000), ('Sydney', 'Theater', 3000), ('Melbourne', 'Opera', 6000), ('Melbourne', 'Theater', 4000);
What is the average attendance for cultural events in Sydney and Melbourne?
SELECT city, AVG(attendance) FROM Events_Attendance GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Teams(id INT, name TEXT, region TEXT); CREATE TABLE FanDemographics(id INT, team_id INT, fan_age INT, fan_gender TEXT, fan_income INT);
What are the top 2 most popular teams by fan demographics in the Central region?
SELECT t.name, COUNT(DISTINCT f.id) AS fan_count FROM Teams t JOIN FanDemographics f ON t.id = f.team_id WHERE t.region = 'Central' GROUP BY t.name ORDER BY fan_count DESC LIMIT 2
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(20), element VARCHAR(10), year INT, quantity FLOAT); INSERT INTO production (country, element, year, quantity) VALUES ('China', 'Dysprosium', 2015, 300), ('China', 'Dysprosium', 2016, 350), ('China', 'Dysprosium', 2017, 400), ('China', 'Dysprosium', 2018, 450), ('United States',...
Which country produced the most Dysprosium in 2018?
SELECT country, MAX(quantity) FROM production WHERE element = 'Dysprosium' AND year = 2018 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE officers (officer_id INT, first_name VARCHAR(20), last_name VARCHAR(20)); INSERT INTO officers (officer_id, first_name, last_name) VALUES (49, 'John', 'Doe'), (50, 'Jane', 'Doe'), (51, 'Mike', 'Johnson'), (60, 'Sara', 'Williams'), (61, 'Tom', 'Brown');
Delete records from the 'officers' table where officer_id is between 50 and 60
DELETE FROM officers WHERE officer_id BETWEEN 50 AND 60;
gretelai_synthetic_text_to_sql
CREATE TABLE collective_bargaining (id INT, industry VARCHAR(50), num_agreements INT); INSERT INTO collective_bargaining (id, industry, num_agreements) VALUES (1, 'construction', 15); INSERT INTO collective_bargaining (id, industry, num_agreements) VALUES (2, 'manufacturing', 10); INSERT INTO collective_bargaining (id,...
What is the maximum number of collective bargaining agreements signed in the 'retail' industry?
SELECT MAX(num_agreements) FROM collective_bargaining WHERE industry = 'retail';
gretelai_synthetic_text_to_sql
CREATE TABLE ad_campaigns (id INT, name VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2));
Insert a new ad campaign into the "ad_campaigns" table
INSERT INTO ad_campaigns (id, name, start_date, end_date, budget) VALUES (1, 'Spring Sale', '2023-03-20', '2023-04-30', 5000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (site_id INT, score DECIMAL(5,2)); INSERT INTO environmental_impact (site_id, score) VALUES (1, 85.67), (2, 90.23), (3, 78.91), (4, 92.14), (5, 75.32), (6, 88.45);
List the top 5 mining sites with the highest environmental impact score and their corresponding scores.
SELECT site_id, score FROM (SELECT site_id, score, RANK() OVER (ORDER BY score DESC) as rank FROM environmental_impact) ranked WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, sector VARCHAR(255), response_level VARCHAR(255), date DATE); INSERT INTO incidents (id, sector, response_level, date) VALUES (1, 'retail', 'level 1', '2021-01-01'); INSERT INTO incidents (id, sector, response_level, date) VALUES (2, 'finance', 'level 3', '2021-01-02');
Count the number of security incidents in the retail sector that required level 3 response in 2021
SELECT COUNT(*) FROM incidents WHERE sector = 'retail' AND response_level = 'level 3' AND YEAR(date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE diagnoses (patient_id INT, condition TEXT); CREATE TABLE conditions (id INT, name TEXT); INSERT INTO conditions (id, name) VALUES (1, 'Anxiety Disorder');
How many patients have been treated for anxiety disorders?
SELECT COUNT(*) FROM diagnoses JOIN conditions ON diagnoses.condition = conditions.name WHERE conditions.id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, StartYear INT, Budget DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, StartYear, Budget) VALUES (1, 'Feeding America', 2018, 100000.00); INSERT INTO Programs (ProgramID, ProgramName, StartYear, Budget) VALUES (2, 'Red Cross', 2019, 200000.00); INSERT...
What is the total budget for programs that started in 2020 or later?
SELECT SUM(Budget) FROM Programs WHERE StartYear >= 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE paratransit (request_id INT, request_date TIMESTAMP, pickup_time TIMESTAMP); INSERT INTO paratransit (request_id, request_date, pickup_time) VALUES (12, '2022-04-01 10:00:00', '2022-04-01 10:15:00');
What is the average waiting time for paratransit services in the last week, by day?
SELECT DATE(request_date) AS request_day, AVG(TIMESTAMPDIFF(MINUTE, request_date, pickup_time)) AS avg_waiting_time FROM paratransit WHERE request_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY request_day;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(100), market_cap DECIMAL(20,2)); INSERT INTO digital_assets (asset_id, name, market_cap) VALUES (1, 'Asset1', 500000), (2, 'Asset2', 350000), (3, 'Asset3', 275000), (4, 'Asset4', 200000), (5, 'Asset5', 150000); CREATE TABLE countries (country_id INT, country VARCH...
What are the market capitalizations of digital assets in the top 10 countries by number of digital asset users?
SELECT d.name, d.market_cap FROM digital_assets d INNER JOIN (SELECT country, MAX(users) AS max_users FROM countries GROUP BY country) m ON 1=1 WHERE d.name IN (SELECT name FROM digital_assets WHERE market_cap IN (SELECT market_cap FROM digital_assets WHERE market_cap IN (SELECT market_cap FROM digital_assets ORDER BY ...
gretelai_synthetic_text_to_sql
CREATE TABLE mine_env_scores (id INT, name VARCHAR(50), location VARCHAR(50), environmental_score FLOAT); INSERT INTO mine_env_scores VALUES (1, 'Mine V', 'Colorado', 85), (2, 'Mine W', 'Colorado', 70), (3, 'Mine X', 'Colorado', 65);
Identify mines in Colorado with environmental impact scores above 75.
SELECT name, environmental_score FROM mine_env_scores WHERE location = 'Colorado' AND environmental_score > 75;
gretelai_synthetic_text_to_sql
CREATE TABLE IndonesianHealthcare (FacilityType VARCHAR(20), Location VARCHAR(50), Budget INT); INSERT INTO IndonesianHealthcare (FacilityType, Location, Budget) VALUES ('Clinic', 'Rural Area A', 1500000), ('Hospital', 'Rural Area B', 2000000), ('Community Health Center', 'Rural Area C', 1000000), ('Health Post', 'Rura...
Find the total number of rural healthcare facilities in Indonesia with a budget greater than 1 million.
SELECT SUM(Budget) FROM IndonesianHealthcare WHERE Location LIKE '%Rural Area%' AND Budget > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_category VARCHAR(255), transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_date, transaction_category, transaction_value) VALUES (1, '2022-02-02', 'Food', 75.00), (2, '2022-02-05', 'Electronics', 350.00...
What is the total transaction value for each transaction category for the month of February 2022?
SELECT transaction_category, SUM(transaction_value) as total_transaction_value FROM transactions WHERE transaction_date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY transaction_category;
gretelai_synthetic_text_to_sql
CREATE TABLE lanthanum_production (country VARCHAR(255), year INT, tons_produced INT); INSERT INTO lanthanum_production (country, year, tons_produced) VALUES ('China', 2018, 30000), ('China', 2019, 32000), ('China', 2020, 35000), ('Australia', 2018, 2000), ('Australia', 2019, 2500), ('Australia', 2020, 3000), ('Malaysi...
How many Tons of Lanthanum were produced in each country between 2018 and 2020?
SELECT country, year, SUM(tons_produced) FROM lanthanum_production WHERE year BETWEEN 2018 AND 2020 GROUP BY ROLLUP(country, year);
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (item_id INT, name VARCHAR(50), is_vegan BOOLEAN, is_vegetarian BOOLEAN, preference_score INT); INSERT INTO Menu (item_id, name, is_vegan, is_vegetarian, preference_score) VALUES (1, 'Cheese Pizza', false, false, 80), (2, 'Garden Salad', true, true, 70), (3, 'Beef Burger', false, false, 85);
What is the average preference score of dishes that are neither vegan nor vegetarian?
SELECT AVG(preference_score) FROM Menu WHERE is_vegan = false AND is_vegetarian = false;
gretelai_synthetic_text_to_sql
CREATE TABLE FoodRecalls (RecallID int, Date date, Country varchar(50), Reason varchar(50));
What is the total number of food recalls in the United States by month for the past year?
SELECT TO_CHAR(Date, 'Month'), COUNT(*) FROM FoodRecalls WHERE Country = 'United States' AND Date >= ADD_MONTHS(TRUNC(CURRENT_DATE, 'MM'), -12) GROUP BY TO_CHAR(Date, 'Month') ORDER BY TO_CHAR(Date, 'Month');
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_diversity (id INT, name VARCHAR(50), position VARCHAR(50), gender VARCHAR(50));
What is the total number of workers in the 'workforce_diversity' table by gender?
SELECT gender, COUNT(*) FROM workforce_diversity GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT, Nationality TEXT, CreationYear INT); CREATE TABLE Artworks (ArtworkID INT, ArtistID INT, SalePrice INT); INSERT INTO Artists (ArtistID, Name, Nationality, CreationYear) VALUES (1, 'Johannes Vermeer', 'Dutch', 1632); INSERT INTO Artworks (ArtworkID, ArtistID, SalePric...
What is the minimum sale price for artworks created by artists from the Netherlands in the 17th century?
SELECT MIN(SalePrice) FROM Artworks A JOIN Artists B ON A.ArtistID = B.ArtistID WHERE B.Nationality = 'Dutch' AND A.CreationYear BETWEEN 1601 AND 1700;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(30), genre VARCHAR(20)); INSERT INTO Concerts (id, city, genre) VALUES (1, 'Paris', 'Classical'), (2, 'Berlin', 'Classical'), (3, 'London', 'Jazz');
List all classical music concerts in Paris.
SELECT * FROM Concerts WHERE city = 'Paris' AND genre = 'Classical';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT PRIMARY KEY, name VARCHAR(255), budget INT, start_date DATE, end_date DATE, Infrastructure_id INT, FOREIGN KEY (Infrastructure_id) REFERENCES Infrastructure(id));
What is the total budget for all dam projects with more than 10 million budget?
SELECT SUM(budget) as total_budget FROM Projects WHERE Infrastructure_id IN (SELECT id FROM Infrastructure WHERE type = 'Dam') GROUP BY Infrastructure_id HAVING total_budget > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Performances (PerformanceID INT, PerformanceType VARCHAR(50), PerformanceDate DATE); INSERT INTO Performances (PerformanceID, PerformanceType, PerformanceDate) VALUES (1, 'Dance', '2021-10-01'), (2, 'Theater', '2021-11-01'), (3, 'Dance', '2021-12-01');
What is the total ticket revenue for dance performances in the last quarter of 2021?
SELECT SUM(TicketRevenue) FROM TicketSales WHERE PerformanceType = 'Dance' AND PerformanceDate >= '2021-10-01' AND PerformanceDate <= '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE research_grants (id INT, graduate_student_id INT, amount DECIMAL(10,2), grant_date DATE);
What is the maximum amount of funding received by a graduate student in the Computer Science department from research grants awarded in the last 2 years?
SELECT MAX(rg.amount) FROM research_grants rg JOIN graduate_students gs ON rg.graduate_student_id = gs.id WHERE gs.department = 'Computer Science' AND rg.grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO marine_life (id, name, location, depth) VALUES (1, 'Station A', 'Pacific', 4000.5); INSERT INTO marine_life (id, name, location, depth) VALUES (2, 'Station B', 'Atlantic', 3000.2);
What are the names and locations of all marine life research stations deeper than 3500 meters?
SELECT name, location FROM marine_life WHERE depth > 3500;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE orders (id INT, dispensary_id INT, product_category TEXT, price DECIMAL, order_date DATE);
What is the total revenue for each product category in Colorado dispensaries this year?
SELECT d.state, o.product_category, SUM(o.price) as total_revenue FROM dispensaries d INNER JOIN orders o ON d.id = o.dispensary_id WHERE d.state = 'Colorado' AND YEAR(o.order_date) = YEAR(CURRENT_DATE) GROUP BY d.state, o.product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255), follower_count INT); INSERT INTO users (id, name, country, follower_count) VALUES (1, 'Alice', 'USA', 1000), (2, 'Bob', 'Canada', 2000), (3, 'Charlie', 'USA', 1500);
List the top 3 users who gained the most followers in a specific country last month.
SELECT name, follower_count, (follower_count - (SELECT follower_count FROM users WHERE id = u.id AND country = 'USA' AND DATE(date_added) < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))) AS follower_gain FROM users u WHERE country = 'USA' ORDER BY follower_gain DESC, follower_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(100), CargoWeight FLOAT, EU_Registration BOOLEAN); INSERT INTO Vessels (Id, Name, CargoWeight, EU_Registration) VALUES (1, 'VesselA', 50000.5, TRUE), (2, 'VesselB', 60000, FALSE), (3, 'VesselC', 70000, TRUE);
What is the maximum cargo weight carried by vessels that are registered in the European Union?
SELECT MAX(CargoWeight) FROM Vessels WHERE EU_Registration = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name VARCHAR(255), gender VARCHAR(10), country VARCHAR(255)); INSERT INTO founders (id, name, gender, country) VALUES (1, 'John Doe', 'Male', 'USA'), (2, 'Jane Smith', 'Female', 'USA'), (3, 'Mike Johnson', 'Male', 'Canada'), (4, 'Alice Williams', 'Female', 'Canada'), (5, 'Bob Brown', 'Mal...
Summarize the number of female and male founders in each country
SELECT country, gender, COUNT(*) as head_count FROM founders GROUP BY country, gender;
gretelai_synthetic_text_to_sql
CREATE SCHEMA manufacturing;CREATE TABLE workforce_development (id INT PRIMARY KEY, name TEXT, field TEXT);INSERT INTO workforce_development (id, name, field) VALUES (1, 'Workforce Development A', 'AI'); INSERT INTO workforce_development (id, name, field) VALUES (2, 'Workforce Development B', 'ML'); INSERT INTO workfor...
Delete the workforce development record with ID 1
DELETE FROM workforce_development WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_projects (project_id INT, project_name TEXT, project_budget INT, project_location TEXT);
Update the 'construction_projects' table to set the 'project_budget' to '5000000' for all records where 'project_name' is 'Highway Expansion'
UPDATE construction_projects SET project_budget = 5000000 WHERE project_name = 'Highway Expansion';
gretelai_synthetic_text_to_sql
CREATE TABLE china_emissions (year INT, sector TEXT, co2_emissions FLOAT); INSERT INTO china_emissions (year, sector, co2_emissions) VALUES (2012, 'transportation', 1234.5);
What's the total CO2 emissions for the transportation sector in China in the last 10 years?
SELECT SUM(co2_emissions) FROM china_emissions WHERE sector = 'transportation' AND year BETWEEN 2012 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_adoption (hotel_id INT, ai_adoption_date DATE); INSERT INTO ai_adoption (hotel_id, ai_adoption_date) VALUES (1, '2021-01-01'), (2, '2021-02-01'), (3, '2021-03-01');
Update the AI adoption date for 'Hotel1' in the 'APAC' region to '2021-05-01'.
UPDATE ai_adoption SET ai_adoption_date = '2021-05-01' WHERE hotel_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_trenches (id INT, name VARCHAR(255), depth FLOAT);
Find the maximum depth among all marine trenches.
SELECT MAX(depth) FROM marine_trenches;
gretelai_synthetic_text_to_sql
CREATE TABLE CyberSecurityStrategies (ID INT, Country VARCHAR(20), Name VARCHAR(50), Year INT); INSERT INTO CyberSecurityStrategies (ID, Country, Name, Year) VALUES (1, 'Singapore', 'Intelligent Nation 2015', 2010);
List all cybersecurity strategies implemented by Singapore from 2010 to 2020, including the strategy name and year of implementation.
SELECT Name, Year FROM CyberSecurityStrategies WHERE Country = 'Singapore' AND Year BETWEEN 2010 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (id INT, department VARCHAR(255), gender VARCHAR(10), head_count INT); INSERT INTO diversity_metrics (id, department, gender, head_count) VALUES (1, 'Engineering', 'Male', 200), (2, 'Engineering', 'Female', 50), (3, 'Marketing', 'Male', 70), (4, 'Marketing', 'Female', 110), (5, 'Sales', '...
Show diversity metrics for each department
SELECT department, gender, COUNT(*) as head_count, ROUND(COUNT(*)*100.0/SUM(COUNT(*)) OVER (PARTITION BY department), 2) as diversity_percentage FROM diversity_metrics GROUP BY department, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, customer_id, transaction_date, transaction_amount) VALUES (1, 2, '2022-01-05', 350.00), (2, 1, '2022-01-10', 500.00), (3, 3, '2022-02-15', 700.00), (4, 4, '...
What is the average transaction amount for each customer in the Midwest region?
SELECT customers.name, AVG(transactions.transaction_amount) FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE customers.region = 'Midwest' GROUP BY customers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation (conservation_id INT, region TEXT, budget FLOAT); INSERT INTO conservation (conservation_id, region, budget) VALUES (1, 'Caribbean', 1200000), (2, 'Mediterranean', 1500000);
What is the average conservation budget for each region?
SELECT region, AVG(budget) FROM conservation GROUP BY region
gretelai_synthetic_text_to_sql
CREATE TABLE multimodal_transportation_hubs (hub_id INT, hub_name TEXT, type TEXT, city TEXT, country TEXT);
Remove the multimodal transportation hub in the city of Berlin
DELETE FROM multimodal_transportation_hubs WHERE hub_name = 'Berlin Central Station';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE cost (mine_id INT, year INT, cost INT);
What is the total resource depletion cost for each mine?
SELECT mine.name, SUM(cost.cost) FROM cost JOIN mine ON cost.mine_id = mine.id GROUP BY mine.name;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, Age INT, Gender VARCHAR(20), State VARCHAR(20)); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (1, 45, 'Female', 'Texas'); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (2, 35, 'Male', 'California');
How many community health workers are there in total?
SELECT COUNT(*) FROM CommunityHealthWorker;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerAgeGroups (PlayerID INT, AgeGroup VARCHAR(10), GameType VARCHAR(10)); INSERT INTO PlayerAgeGroups (PlayerID, AgeGroup, GameType) VALUES (1, '18-24', 'RPG'), (2, '25-34', 'FPS'), (3, '18-24', 'RPG'), (4, '35-44', 'Simulation');
What is the distribution of players by age group for each game genre?
SELECT AgeGroup, GameType, COUNT(*) FROM PlayerAgeGroups GROUP BY AgeGroup, GameType;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_data (subscriber_id INT, plan_id INT, age INT); INSERT INTO subscriber_data (subscriber_id, plan_id, age) VALUES (1, 1, 25), (2, 2, 35), (3, 3, 45), (4, 1, 30), (5, 2, 40), (6, 3, 50);
Which mobile plans have more than 500 subscribers?
SELECT plan_id, COUNT(*) AS subscriber_count FROM subscriber_data GROUP BY plan_id HAVING subscriber_count > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE vaccines (vaccine_id INT, patient_id INT, ethnicity TEXT, state TEXT, vaccinated INT); INSERT INTO vaccines (vaccine_id, patient_id, ethnicity, state, vaccinated) VALUES (1, 1, 'Hispanic or Latino', 'New York', 1);
What is the total number of vaccines administered in the state of New York to individuals who identify as Hispanic or Latino?
SELECT SUM(vaccinated) FROM vaccines WHERE state = 'New York' AND ethnicity = 'Hispanic or Latino';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name TEXT, followers INT); INSERT INTO users (id, name, followers) VALUES (1, 'Alice', 500), (2, 'Bob', 150); CREATE TABLE posts (id INT, user_id INT, content TEXT, timestamp DATETIME); INSERT INTO posts (id, user_id, content, timestamp) VALUES (1, 1, 'Climate change is real', '2021-01-01 10...
How many unique users have posted about "climate change" in the past year, excluding those with less than 100 followers?
SELECT COUNT(DISTINCT user_id) FROM posts JOIN users ON posts.user_id = users.id WHERE content LIKE '%climate change%' AND followers > 100 AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_efforts (county_name VARCHAR(30), state VARCHAR(20), conservation_score FLOAT);
What are the average water conservation efforts by county in Texas?
SELECT county_name, AVG(conservation_score) FROM conservation_efforts WHERE state = 'Texas' GROUP BY county_name;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (id INT, track_id INT, user_id INT, region VARCHAR(255), genre VARCHAR(255), revenue DECIMAL(10,2), timestamp TIMESTAMP);
Delete all records of streams in the genre of pop that were streamed before 2022-01-01.
DELETE FROM streams WHERE genre = 'pop' AND timestamp < '2022-01-01 00:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, name VARCHAR(255), approval_date DATE);CREATE TABLE clinical_trials (trial_id INT, drug_id INT, outcome VARCHAR(255));
What is the minimum number of clinical trials and their outcomes for each drug that has been approved by the FDA, including the drug name and approval date?
SELECT d.name, d.approval_date, COUNT(ct.trial_id) as num_trials, MIN(ct.trial_id) as min_trial, STRING_AGG(ct.outcome, ',') as outcomes FROM drugs d JOIN clinical_trials ct ON d.drug_id = ct.drug_id GROUP BY d.name, d.approval_date;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_temperature (country VARCHAR(50), year INT, temperature FLOAT); INSERT INTO arctic_temperature (country, year, temperature) VALUES ('Canada', 1990, -10.0), ('Canada', 1991, -8.5), ('Norway', 1990, -5.0), ('Norway', 1991, -6.0);
What is the average annual temperature in the Arctic by country since 1990?
SELECT t.country, AVG(t.temperature) as avg_temp FROM arctic_temperature t GROUP BY t.country;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), content TEXT, word_count INT);
List all news articles with a word count greater than 500.
SELECT title, content FROM news_articles WHERE word_count > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE Demographics (ID INT, Population VARCHAR(10), LifeExpectancy FLOAT, AreaType VARCHAR(10)); INSERT INTO Demographics (ID, Population, LifeExpectancy, AreaType) VALUES (1, 'Urban', 81.5, 'Urban'); INSERT INTO Demographics (ID, Population, LifeExpectancy, AreaType) VALUES (2, 'Rural', 79.3, 'Rural');
What is the average life expectancy in rural areas of Canada?
SELECT AVG(LifeExpectancy) FROM Demographics WHERE AreaType = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name TEXT, category TEXT);CREATE TABLE products_sustainability (id INT, name TEXT, sustainable_label TEXT);
Insert new sustainable product records from 'products_sustainability' into 'products' table
INSERT INTO products (id, name, category) SELECT id, name, 'sustainable' FROM products_sustainability WHERE sustainable_label IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE tour_packages (package_id INT, package_name TEXT, operator_id INT, description TEXT, compliant BOOLEAN); INSERT INTO tour_packages (package_id, package_name, operator_id, description, compliant) VALUES (1, 'Eco-Friendly Japan Tour', 1, 'Explore Japan sustainably', true), (2, 'Cultural Heritage of Europe', ...
Delete tour packages that do not align with cultural heritage preservation guidelines.
DELETE FROM tour_packages WHERE compliant = false;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterUsage (Id INT, Location VARCHAR(50), Usage DECIMAL(5,2), Date DATE); INSERT INTO WaterUsage (Id, Location, Usage, Date) VALUES (1, 'Phoenix', 40.6, '2021-12-01'); INSERT INTO WaterUsage (Id, Location, Usage, Date) VALUES (2, 'Las Vegas', 32.8, '2021-12-01');
Which locations had water usage over 35 m³ on December 1, 2021?
SELECT Location, SUM(Usage) FROM WaterUsage WHERE Date = '2021-12-01' GROUP BY Location HAVING SUM(Usage) > 35;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (hash VARCHAR(64), value INT, timestamp TIMESTAMP, user_address VARCHAR(64));
Delete all transactions for a specific user '0x789...'.
DELETE FROM transactions WHERE user_address = '0x789...';
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_usage (fabric_type VARCHAR(20), quarter VARCHAR(2), year INT, units_used INT); INSERT INTO fabric_usage (fabric_type, quarter, year, units_used) VALUES ('eco_friendly', 'Q4', 2021, 1200), ('eco_friendly', 'Q4', 2021, 1800), ('eco_friendly', 'Q4', 2021, 1500);
How many units of eco-friendly fabrics were used in Q4 2021?
SELECT SUM(units_used) FROM fabric_usage WHERE fabric_type = 'eco_friendly' AND quarter = 'Q4' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Events (id INT, country VARCHAR(20), event_date DATE);
Count the number of visitors from the USA who engaged in community events in the last 3 months
SELECT COUNT(id) FROM Community_Events WHERE country = 'USA' AND event_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_justice_data (case_id INT, case_type VARCHAR(20), case_outcome VARCHAR(20), data_source VARCHAR(20)); INSERT INTO criminal_justice_data (case_id, case_type, case_outcome, data_source) VALUES (1, 'Homicide', 'Conviction', 'Police Department'), (2, 'Drug Offense', 'Acquittal', 'Courts');
What is the distribution of criminal justice data case types by case outcome and data source?
SELECT case_type, case_outcome, data_source, COUNT(*) as total_cases FROM criminal_justice_data GROUP BY case_type, case_outcome, data_source;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10,2), hire_date DATE, race VARCHAR(50)); INSERT INTO Employees (id, name, department, salary, hire_date, race) VALUES (3, 'David Lee', 'Operations', 65000.00, '2021-03-01', 'Asian');
What is the percentage of employees who identify as Hispanic or Latino in each department?
SELECT department, COUNT(*) as employee_count, COUNT(*) FILTER (WHERE race LIKE '%Hispanic%') * 100.0 / COUNT(*) as hispanic_employee_percentage FROM Employees GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (filing_entity VARCHAR(255), patent VARCHAR(255), filing_date DATE);
How many military innovation patents were filed by the US, China, and Russia in the last 5 years?
SELECT COUNT(*) FROM military_innovation WHERE filing_entity IN ('US', 'China', 'Russia') AND filing_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (id INT, name VARCHAR(50), department VARCHAR(50), billing_amount DECIMAL(10,2));
What is the average billing amount for attorneys in the "litigation" department?
SELECT AVG(billing_amount) FROM Attorneys WHERE department = 'litigation';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); CREATE TABLE students (student_id INT, district_id INT, mental_health_score INT); INSERT INTO districts VALUES (1, 'District A'), (2, 'District B'); INSERT INTO students VALUES (1, 1, 60), (2, 1, 75), (3, 2, 45), (4, 2, 30);
What is the total number of students enrolled in each district, and what is the minimum mental health score for students in each district?
SELECT d.district_name, COUNT(s.student_id) as num_students, MIN(s.mental_health_score) as min_mental_health_score FROM students s JOIN districts d ON s.district_id = d.district_id GROUP BY s.district_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_transactions (asset_name VARCHAR(20), network VARCHAR(20), transactions_value FLOAT); INSERT INTO ethereum_transactions (asset_name, network, transactions_value) VALUES ('ETH', 'Ethereum', 120000), ('Uniswap', 'Ethereum', 150000), ('Compound', 'Ethereum', 180000);
What is the minimum total value of transactions for digital assets in the 'Ethereum' network?
SELECT network, MIN(transactions_value) FROM ethereum_transactions WHERE network = 'Ethereum' GROUP BY network;
gretelai_synthetic_text_to_sql
CREATE TABLE ResponseTimes (call_id INT, call_type VARCHAR(10), neighborhood VARCHAR(20), response_time INT); INSERT INTO ResponseTimes VALUES (1, 'Fire', 'Parkside', 5), (2, 'Medical', 'Parkside', 7), (3, 'Fire', 'Downtown', 6), (4, 'Medical', 'Downtown', 8);
Find the difference between the average response times for 'Fire' and 'Medical' calls in each neighborhood.
SELECT neighborhood, AVG(response_time) - (SELECT AVG(response_time) FROM ResponseTimes r2 WHERE r2.neighborhood = r1.neighborhood AND r2.call_type = 'Medical') AS difference FROM ResponseTimes r1 WHERE r1.call_type = 'Fire' GROUP BY neighborhood;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (id INT, price FLOAT, wheelchair_accessible BOOLEAN); INSERT INTO inclusive_housing (id, price, wheelchair_accessible) VALUES (1, 400000, true), (2, 500000, false), (3, 600000, true);
What is the maximum price of properties in the table 'inclusive_housing' that have wheelchair accessibility?
SELECT MAX(price) FROM inclusive_housing WHERE wheelchair_accessible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT); CREATE TABLE infectious_diseases (id INT, hospital_id INT, disease TEXT); INSERT INTO hospitals (id, name, city) VALUES (1, 'Hospital X', 'Atlanta'), (2, 'Hospital Y', 'Miami'); INSERT INTO infectious_diseases (id, hospital_id, disease) VALUES (1, 1, 'Measles'), (2...
List all infectious diseases recorded in hospitals in Atlanta and Miami
SELECT i.disease FROM hospitals h INNER JOIN infectious_diseases i ON h.id = i.hospital_id WHERE h.city IN ('Atlanta', 'Miami');
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, data_usage FLOAT, region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, data_usage, region) VALUES (1, 15.5, 'Rural'), (2, 20.0, 'Urban'), (3, 30.0, 'Metro'), (4, 10.0, 'Rural');
Find the minimum data usage for customers in the 'Urban' region.
SELECT MIN(data_usage) FROM subscribers WHERE region = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_investment_accounts (account_id INT, account_holder_name TEXT, account_holder_gender TEXT, account_balance DECIMAL(10, 2)); INSERT INTO shariah_investment_accounts VALUES (1, 'John Doe', 'Male', 25000), (2, 'Jane Smith', 'Female', 30000), (3, 'Ahmed Ali', 'Male', 15000), (4, 'Aisha Khan', 'Female',...
What is the percentage of Shariah-compliant investment accounts by gender?
SELECT account_holder_gender, COUNT(account_id) * 100.0 / SUM(COUNT(account_id)) OVER () as percentage FROM shariah_investment_accounts GROUP BY account_holder_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Recruitment (RecruiterID int, RecruiterName varchar(50), CandidateSource varchar(50), NewHire bit, HireDate date); INSERT INTO Recruitment (RecruiterID, RecruiterName, CandidateSource, NewHire, HireDate) VALUES (1, 'Alice', 'Job Board', 1, '2022-01-01'), (2, 'Bob', 'Referral', 1, '2022-02-01'), (3, 'Charli...
What is the count of new hires in the last 3 months, by recruiter and source?
SELECT Recruitment.RecruiterName, Recruitment.CandidateSource, COUNT(CASE WHEN Recruitment.NewHire = 1 AND Recruitment.HireDate >= DATEADD(month, -3, GETDATE()) THEN 1 ELSE NULL END) as Count_of_New_Hires FROM Recruitment GROUP BY Recruitment.RecruiterName, Recruitment.CandidateSource;
gretelai_synthetic_text_to_sql
CREATE TABLE donations( id INT PRIMARY KEY NOT NULL, donor_name VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE ); INSERT INTO donations (id, donor_name, amount, donation_date) VALUES (1, 'John Doe', 50.00, '2022-01-01'); INSERT INTO donations (id, donor_name, amount, donation_date) VALUES (2, 'Jane Doe', 100.00...
List all donors and their total donation amounts
SELECT donor_name, SUM(amount) FROM donations GROUP BY donor_name;
gretelai_synthetic_text_to_sql
CREATE TABLE hr.employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO hr.employees (id, name, department) VALUES (1, 'John Doe', 'HR'); INSERT INTO hr.employees (id, name, department) VALUES (2, 'Jane Smith', 'IT'); INSERT INTO hr.employees (id, name, department) VALUES (3, 'Bob Brown', 'IT'); INSER...
List the number of employees in the "IT" and "HR" departments in the "hr" schema
SELECT department, COUNT(*) FROM hr.employees WHERE department IN ('IT', 'HR') GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (algorithm_id INT, name TEXT); INSERT INTO algorithmic_fairness (algorithm_id, name) VALUES (1, 'AlgorithmQ'), (2, 'AlgorithmR'), (3, 'AlgorithmS'); CREATE TABLE algorithmic_bias (algorithm_id INT, name TEXT); INSERT INTO algorithmic_bias (algorithm_id, name) VALUES (4, 'AlgorithmT'), ...
What is the total number of AI algorithms in the 'algorithmic_fairness' and 'algorithmic_bias' tables?
SELECT COUNT(*) FROM algorithmic_fairness UNION ALL SELECT COUNT(*) FROM algorithmic_bias;
gretelai_synthetic_text_to_sql
CREATE SCHEMA disability_services; CREATE TABLE students (id INT, name VARCHAR(50), accommodation VARCHAR(50), program VARCHAR(50));
Find the names and accommodations of students who are enrolled in the "academic_coaching" support program and have accommodations in the "disability_services" schema.
SELECT name, accommodation FROM disability_services.students WHERE program = 'academic_coaching' AND accommodation IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, city VARCHAR(20), inclusive BOOLEAN, co_ownership BOOLEAN); INSERT INTO properties (property_id, city, inclusive, co_ownership) VALUES (1, 'Atlanta', true, true); INSERT INTO properties (property_id, city, inclusive, co_ownership) VALUES (2, 'Atlanta', false, false);
List all properties in Atlanta with inclusive housing policies and co-ownership.
SELECT * FROM properties WHERE city = 'Atlanta' AND inclusive = true AND co_ownership = true;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT); CREATE TABLE exit_strategies (id INT, company_id INT, exit_year INT, exit_amount INT);
Get the number of exits for startups in the 'technology' sector
SELECT COUNT(*) FROM exit_strategies es INNER JOIN company c ON es.company_id = c.id WHERE c.industry = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name VARCHAR(20)); CREATE TABLE accessibility_features (feature_id INT, route_id INT, feature_name VARCHAR(20));
List all accessibility features available on each route
SELECT routes.route_name, accessibility_features.feature_name FROM routes FULL OUTER JOIN accessibility_features ON routes.route_id = accessibility_features.route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ota_stats (id INT, ota_name TEXT, region TEXT, date DATE, clicks INT, bookings INT); INSERT INTO ota_stats (id, ota_name, region, date, clicks, bookings) VALUES (1, 'OTA1', 'NA', '2021-01-01', 100, 20), (2, 'OTA2', 'NA', '2021-02-01', 150, 30), (3, 'OTA3', 'EMEA', '2021-01-01', 50, 10);
What are the average clicks and bookings per OTA for the 'NA' region in the 'ota_stats' table?
SELECT AVG(clicks), AVG(bookings) FROM ota_stats WHERE region = 'NA';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(100), country VARCHAR(100)); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port of New York', 'USA'); CREATE TABLE cargo_ships (ship_id INT, ship_name VARCHAR(100), port_id INT, containers_transported INT); INSERT INTO cargo_ships (ship_id, ship_name, por...
What is the total number of containers that were transported by cargo ships from European countries to the Port of New York?
SELECT SUM(containers_transported) FROM cargo_ships WHERE country = 'Europe' AND port_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE fitness_classes (id INT, city VARCHAR(20), enrollment INT, duration INT); INSERT INTO fitness_classes (id, city, enrollment, duration) VALUES (1, 'NYC', 20, 60), (2, 'LA', 15, 45), (3, 'CHI', 25, 75);
List all the fitness classes with their total enrollment and average duration for each city.
SELECT city, AVG(duration) as avg_duration, SUM(enrollment) as total_enrollment FROM fitness_classes GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, country VARCHAR(50), data_usage DECIMAL(10,2));CREATE VIEW last_quarter_data AS SELECT subscriber_id, MAX(date_time) AS max_date_time FROM mobile_usages WHERE date_time >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY subscriber_id;
List the top 5 mobile subscribers by data usage in the last quarter, including their usage in GB and country.
SELECT ms.subscriber_id, ms.country, mu.data_usage FROM mobile_subscribers ms JOIN last_quarter_data lqd ON ms.subscriber_id = lqd.subscriber_id JOIN mobile_usages mu ON ms.subscriber_id = mu.subscriber_id AND lqd.max_date_time = mu.date_time ORDER BY mu.data_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (project_name VARCHAR(255), continent VARCHAR(255), investment_amount INT); INSERT INTO climate_finance (project_name, continent, investment_amount) VALUES ('Solar Power Plant', 'Asia', 2000000), ('Wind Farm', 'Europe', 3000000), ('Hydroelectric Power Plant', 'South America', 4000000); CREA...
How many climate finance projects have been implemented in each continent?
SELECT continent, project_count FROM continent_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE recycled_polyester (brand VARCHAR(50), country VARCHAR(50), year INT); INSERT INTO recycled_polyester (brand, country, year) VALUES ('BrandA', 'China', 2020), ('BrandB', 'Taiwan', 2020), ('BrandC', 'Japan', 2019);
Delete the record of a brand sourcing recycled polyester from a country in 2019.
DELETE FROM recycled_polyester WHERE brand = 'BrandC' AND country = 'Japan' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (manufacturer VARCHAR(255), mass FLOAT); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('SpaceCorp', 12000); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('AstroCorp', 18000); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('Galactic Inc', 15000);
What is the average mass of spacecrafts manufactured by SpaceCorp?
SELECT manufacturer, AVG(mass) FROM spacecrafts WHERE manufacturer = 'SpaceCorp';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists blockchain_domain.smart_contracts (contract_id INT PRIMARY KEY, name VARCHAR(255), gas_cost FLOAT); CREATE TABLE if not exists blockchain_domain.digital_assets (asset_id INT PRIMARY KEY, name VARCHAR(255), smart_contract_id INT, FOREIGN KEY (smart_contract_id) REFERENCES blockchain_domain.sma...
How many digital assets are associated with each smart contract?
SELECT sc.name, COUNT(da.asset_id) FROM blockchain_domain.smart_contracts sc JOIN blockchain_domain.digital_assets da ON sc.contract_id = da.smart_contract_id GROUP BY sc.name;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_type TEXT, date_reported DATE, severity TEXT); INSERT INTO security_incidents (id, incident_type, date_reported, severity) VALUES (1, 'Phishing', '2022-01-01', 'High');
How many security incidents were there in Q1 2022?
SELECT COUNT(*) as count FROM security_incidents WHERE date_reported >= '2022-01-01' AND date_reported < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE housing_data (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), square_footage INT, sustainable_features VARCHAR(255)); INSERT INTO housing_data (id, address, city, state, square_footage, sustainable_features) VALUES (1, '123 Maple St', 'San Francisco', 'CA', 1200, 'solar panels'), (2, '...
What is the total square footage of properties in the 'housing_data' table for each state?
SELECT state, SUM(square_footage) FROM housing_data GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE automation_tech (tech_id INT, tech_type VARCHAR(255), last_update_date DATE); INSERT INTO automation_tech (tech_id, tech_type, last_update_date) VALUES (1, 'autonomous tractors', '2022-01-01'), (2, 'drone spraying', '2021-12-15'), (3, 'precision seeding', '2022-03-03'), (4, 'autonomous tractors', '2022-04-...
Delete all records in the automation_tech table with a technology type of 'drone spraying'
DELETE FROM automation_tech WHERE automation_tech.tech_type = 'drone spraying';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(255), air_pollution INT); INSERT INTO mining_sites (id, name, air_pollution) VALUES (1, 'Site A', 100), (2, 'Site B', 120), (3, 'Site C', 80); CREATE TABLE air_pollution_history (site_id INT, date DATE, air_pollution_level INT); INSERT INTO air_pollution_history (site_id,...
Which mining sites have experienced a significant increase in air pollution levels over the past year?
SELECT ms.name, (ms.air_pollution - SUM(aph.air_pollution_level)) AS air_pollution_diff FROM mining_sites ms JOIN air_pollution_history aph ON ms.id = aph.site_id WHERE aph.date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY ms.name HAVING air_pollution_diff < 0;
gretelai_synthetic_text_to_sql