context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE carbon_offset_programs (program_id INT, program_name TEXT, start_year INT);
What is the total number of carbon offset programs in the carbon_offset_programs table?
SELECT COUNT(*) FROM carbon_offset_programs;
gretelai_synthetic_text_to_sql
CREATE TABLE sourcing (id INT, region TEXT, quantity INT); INSERT INTO sourcing (id, region, quantity) VALUES (1, 'Asia', 1200), (2, 'Europe', 800), (3, 'Africa', 700), (4, 'South America', 900), (5, 'North America', 1100);
What is the average quantity of eco-friendly materials sourced from South America?
SELECT AVG(quantity) FROM sourcing WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE PublicServices (Quarter INT, Year INT, ServiceCount INT); INSERT INTO PublicServices VALUES (1, 2021, 1200), (2, 2021, 1500), (3, 2021, 1300);
What was the total number of public services delivered in Q1, Q2, and Q3 of 2021?
SELECT SUM(ServiceCount) FROM PublicServices WHERE Year = 2021 AND Quarter IN (1, 2, 3);
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_region TEXT); INSERT INTO companies (id, name, industry, founder_region) VALUES (1, 'TransportOceania', 'Transportation', 'Oceania'); INSERT INTO companies (id, name, industry, founder_region) VALUES (2, 'GreenTechMale', 'GreenTech', 'Europe');
How many startups in the transportation sector were founded by a person from Oceania?
SELECT COUNT(*) FROM companies WHERE industry = 'Transportation' AND founder_region = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE yoga_classes (class_id INT, user_id INT, duration INT, first_name VARCHAR(10));
What is the total duration (in minutes) of all yoga classes taken by users with the first name 'Amy'?
SELECT SUM(duration) FROM yoga_classes WHERE first_name = 'Amy';
gretelai_synthetic_text_to_sql
CREATE TABLE MenuCategory (MenuItemID INT, MenuCategory VARCHAR(50)); INSERT INTO MenuCategory (MenuItemID, MenuCategory) VALUES (1, 'Salads'), (2, 'Sandwiches'), (3, 'Desserts'); CREATE TABLE SalesData (SaleID INT, MenuItemID INT, SaleAmount DECIMAL(5,2), SaleDate DATE); INSERT INTO SalesData (SaleID, MenuItemID, SaleAmount, SaleDate) VALUES (1, 1, 12.99, '2022-12-01'), (2, 2, 10.50, '2022-12-03'), (3, 1, 13.50, '2022-12-05');
What is the revenue generated by each category of menu items last month?
SELECT MenuCategory, SUM(SaleAmount) FROM SalesData INNER JOIN MenuCategory ON SalesData.MenuItemID = MenuCategory.MenuItemID WHERE SaleDate BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE() GROUP BY MenuCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_sensors (sensor_id INT, sensor_type VARCHAR(255), reading DECIMAL(5,2)); INSERT INTO smart_city_sensors (sensor_id, sensor_type, reading) VALUES (1, 'temperature', 35.50), (2, 'humidity', 60.00), (3, 'temperature', 45.25), (4, 'pressure', 1013.25);
Delete all smart_city_sensors records with a 'sensor_type' of 'temperature' and a 'reading' value greater than 40.
DELETE FROM smart_city_sensors WHERE sensor_type = 'temperature' AND reading > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_location TEXT); INSERT INTO companies (id, name, industry, founding_date, founder_location) VALUES (1, 'AgriFuture', 'Agriculture', '2016-01-01', 'Rural');
What is the total funding received by companies founded by individuals from rural areas in the agriculture industry?
SELECT SUM(funding_amount) FROM funding_records JOIN companies ON funding_records.company_id = companies.id WHERE companies.industry = 'Agriculture' AND companies.founder_location = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE social_media_posts (id INT, platform VARCHAR(50), content TEXT, post_date DATE); INSERT INTO social_media_posts (id, platform, content, post_date) VALUES (1, 'Twitter', 'Disinformation tweet', '2021-01-01'), (2, 'Facebook', 'Disinformation post', '2021-01-02'), (3, 'Twitter', 'Another disinformation tweet', '2021-01-03');
Show the number of social media posts related to disinformation, grouped by platform, for the month of January 2021.
SELECT platform, COUNT(*) as post_count FROM social_media_posts WHERE post_date >= '2021-01-01' AND post_date < '2021-02-01' AND content LIKE '%disinformation%' GROUP BY platform;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (id INT, name VARCHAR(255)); INSERT INTO ingredients (id, name) VALUES (1, 'Tomatoes'), (2, 'Onions'), (3, 'Garlic'), (4, 'Cheese'), (5, 'Tofu'), (6, 'Chicken'), (7, 'Beef'), (8, 'Tomato Sauce'), (9, 'Onion Rings'); CREATE TABLE dish_ingredients (dish_id INT, ingredient_id INT); INSERT INTO dish_ingredients (dish_id, ingredient_id) VALUES (1, 1), (1, 2), (1, 3), (1, 8), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 6), (4, 2), (4, 9), (5, 3), (5, 4), (5, 7);
Find dishes that contain both tomatoes and onions as ingredients.
SELECT dish_ingredients.dish_id FROM dish_ingredients INNER JOIN ingredients ON dish_ingredients.ingredient_id = ingredients.id WHERE ingredients.name IN ('Tomatoes', 'Onions') GROUP BY dish_ingredients.dish_id HAVING COUNT(DISTINCT ingredients.name) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name TEXT, visitor_count INT); INSERT INTO Exhibitions (id, name, visitor_count) VALUES (1, 'Dinosaurs', 1000), (2, 'Egypt', 800);
What is the average visitor count for exhibitions?
SELECT AVG(visitor_count) FROM Exhibitions;
gretelai_synthetic_text_to_sql
CREATE TABLE circles (circle_id INT PRIMARY KEY, circle_date DATE, circle_time TIME, location VARCHAR(255), facilitator_id INT, case_number INT);
Delete a restorative justice circle from the 'circles' table
DELETE FROM circles WHERE circle_id = 9002 AND case_number = 2022003;
gretelai_synthetic_text_to_sql
CREATE TABLE shelters (id INT, country VARCHAR(20), name VARCHAR(50), capacity INT); INSERT INTO shelters (id, country, name, capacity) VALUES (1, 'Australia', 'Shelter1', 100), (2, 'Australia', 'Shelter2', 150), (3, 'Canada', 'Shelter3', 200), (4, 'Canada', 'Shelter4', 250);
What is the total number of shelters and their capacities in Australia and Canada?
SELECT SUM(capacity) as total_capacity, country FROM shelters GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10)); INSERT INTO faculty VALUES (1, 'Jane Smith', 'English', 'Female');
How many female and male faculty members are there in the English department?
SELECT department, gender, COUNT(*) as count FROM faculty GROUP BY department, gender HAVING department = 'English';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, program_name VARCHAR(50), quarter INT, year INT, expenses DECIMAL(10,2)); INSERT INTO programs (id, program_name, quarter, year, expenses) VALUES (1, 'Education', 1, 2021, 15000.00), (2, 'Health', 2, 2021, 20000.00), (3, 'Education', 1, 2022, 17000.00), (4, 'Health', 2, 2022, 25000.00);
Which programs had the highest increase in total expenses compared to the same quarter last year?
SELECT program_name, (expenses - (SELECT expenses FROM programs p2 WHERE p2.program_name = programs.program_name AND p2.quarter = programs.quarter AND p2.year = programs.year - 1)) AS difference INTO tmp_table FROM programs ORDER BY difference DESC LIMIT 1; SELECT program_name, difference FROM tmp_table; DROP TABLE tmp_table;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, founding_year INT, founder_immigrant TEXT); INSERT INTO startup (id, name, founding_year, founder_immigrant) VALUES (1, 'Acme Inc', 2010, 'Yes'); INSERT INTO startup (id, name, founding_year, founder_immigrant) VALUES (2, 'Beta Corp', 2015, 'No');
Count the number of startups founded by immigrants
SELECT COUNT(*) FROM startup WHERE founder_immigrant = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, country VARCHAR(255)); INSERT INTO satellites (id, country) VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'), (4, 'India'), (5, 'Japan'), (6, 'Germany'), (7, 'Italy');
How many countries have launched satellites into space?
SELECT COUNT(DISTINCT country) FROM satellites;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, project_status TEXT, start_date DATE, end_date DATE, country TEXT); INSERT INTO community_development (id, project_status, start_date, end_date, country) VALUES (1, 'successful', '2016-01-01', '2017-01-01', 'China'), (2, 'unsuccessful', '2015-01-01', '2015-12-31', 'India'), (3, 'successful', '2018-01-01', '2019-01-01', 'Japan');
What is the average duration of successful community development programs in Asia, rounded to the nearest week?
SELECT ROUND(AVG(DATEDIFF(end_date, start_date))/7) FROM community_development WHERE project_status = 'successful' AND country IN ('Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections(restaurant VARCHAR(255), region VARCHAR(255), score DECIMAL(3,1)); INSERT INTO food_safety_inspections VALUES ('Restaurant A', 'San Francisco', 92.5), ('Restaurant B', 'San Francisco', 87.6), ('Restaurant C', 'San Francisco', 95.3);
What is the average food safety score for each restaurant in the 'San Francisco' region?
SELECT region, AVG(score) FROM food_safety_inspections WHERE region = 'San Francisco' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (id INT, user_id INT, artist VARCHAR(50), song VARCHAR(50), genre VARCHAR(20), streamed_on DATE, streams INT); CREATE VIEW song_streams AS SELECT song, streamed_on, SUM(streams) AS total_streams FROM music_streaming GROUP BY song, streamed_on;
Who are the top 5 most streamed K-pop songs in the United States?
SELECT song, total_streams FROM song_streams WHERE genre = 'K-pop' AND user_id IN (SELECT id FROM users WHERE country = 'United States') ORDER BY total_streams DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT); CREATE TABLE faculty (id INT, department_id INT, publications INT);
What is the average number of publications per faculty member by department?
SELECT d.name, AVG(f.publications) FROM department d JOIN faculty f ON d.id = f.department_id GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, currency VARCHAR(10)); INSERT INTO clients (client_id, currency) VALUES (1, 'USD'), (2, 'EUR'); CREATE TABLE assets (asset_id INT, client_id INT, value INT); INSERT INTO assets (asset_id, client_id, value) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 30000);
How many high-value assets (value > 10000) does each client own?
SELECT assets.client_id, COUNT(*) FROM assets WHERE assets.value > 10000 GROUP BY assets.client_id;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investors (id INT, name TEXT, region TEXT, investment FLOAT); INSERT INTO impact_investors (id, name, region, investment) VALUES (1, 'Sustainable Impact Fund', 'European Union', 5000000.0), (2, 'Green Investment Group', 'European Union', 3500000.0);
List the names of the top 5 impact investors in the European Union by total investment.
SELECT name FROM impact_investors WHERE region = 'European Union' ORDER BY investment DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (AccidentID INT, VesselFlag VARCHAR(50), IncidentLocation VARCHAR(50), IncidentYear INT); INSERT INTO Accidents VALUES (1, 'Norway', 'Arctic Ocean', 2021), (2, 'Marshall Islands', 'Atlantic Ocean', 2020), (3, 'Canada', 'Arctic Ocean', 2019);
What is the total number of accidents reported for vessels flying the flag of Norway in the Arctic Ocean?
SELECT COUNT(*) FROM Accidents WHERE VesselFlag = 'Norway' AND IncidentLocation = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE faculties (faculty_id INT, name VARCHAR(255), dept_id INT, num_publications INT);
List the faculty members who have not published any papers, in alphabetical order.
SELECT name FROM faculties WHERE num_publications = 0 ORDER BY name ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_camps (id INT, build_year INT, org_type VARCHAR(20)); INSERT INTO refugee_camps (id, build_year, org_type) VALUES (1, 2015, 'Non-governmental'), (2, 2017, 'Governmental'), (3, 2019, 'Non-governmental'), (4, 2020, 'Non-governmental');
What was the average number of refugee camps built per year by org_type "Non-governmental" between 2015 and 2020?
SELECT AVG(build_year) FROM (SELECT build_year, YEAR(CURRENT_DATE) - build_year AS year_diff FROM refugee_camps WHERE org_type = 'Non-governmental') AS subquery HAVING year_diff BETWEEN 1 AND 6;
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (id INT, title VARCHAR(255), department VARCHAR(100), funding DECIMAL(10,2), start_date DATE); INSERT INTO research_projects (id, title, department, funding, start_date) VALUES (1, 'Robotics Project', 'Engineering', 50000.00, '2019-01-01'), (2, 'Automation Project', 'Engineering', 75000.00, '2020-01-01'), (3, 'IoT Project', 'Engineering', 60000.00, '2021-01-01');
What is the total funding received by research projects in the Engineering department, broken down by year?
SELECT YEAR(start_date) as year, SUM(funding) as total_funding FROM research_projects WHERE department = 'Engineering' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE cricket_attendance (fan_id INT, game_date DATE, team VARCHAR(50), gender VARCHAR(50)); INSERT INTO cricket_attendance (fan_id, game_date, team, gender) VALUES (1, '2022-01-01', 'Mumbai Indians', 'Male'), (2, '2022-01-02', 'Chennai Super Kings', 'Female'), (3, '2022-01-03', 'Delhi Capitals', 'Male'), (4, '2022-01-04', 'Royal Challengers Bangalore', 'Female'), (5, '2022-01-05', 'Sunrisers Hyderabad', 'Male');
How many unique fans attended cricket games in the last year, broken down by team and gender?
SELECT team, gender, COUNT(DISTINCT fan_id) FROM cricket_attendance WHERE game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY team, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE threats (threat_id INT, type VARCHAR(255), description VARCHAR(255), severity VARCHAR(255));
List all threats and their severity
SELECT * FROM threats;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_status TEXT, completion_date DATE, country TEXT); INSERT INTO rural_infrastructure (id, project_status, completion_date, country) VALUES (1, 'completed', '2018-03-15', 'Poland'), (2, 'in_progress', '2019-12-31', 'Romania'), (3, 'completed', '2020-08-01', 'Hungary');
How many rural infrastructure projects were completed in the last 5 years in Eastern Europe, broken down by year?
SELECT YEAR(completion_date) AS "Completion Year", COUNT(*) FROM rural_infrastructure WHERE project_status = 'completed' AND country IN ('Eastern Europe') AND completion_date >= DATE_SUB(NOW(), INTERVAL 5 YEAR) GROUP BY YEAR(completion_date);
gretelai_synthetic_text_to_sql
CREATE TABLE user (id INT, name TEXT, reg_date DATE); CREATE TABLE tour_registration (user_id INT, tour_id INT, registration_date DATE); INSERT INTO user (id, name, reg_date) VALUES (1, 'John Doe', '2022-05-15'); INSERT INTO tour_registration (user_id, tour_id, registration_date) VALUES (1, 1, '2022-05-25');
How many users registered for virtual tours of cultural heritage sites in the last month?
SELECT COUNT(*) as num_users FROM user JOIN tour_registration ON user.id = tour_registration.user_id WHERE tour_registration.registration_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'Canada'); CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount decimal(10, 2)); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 5000); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (2, 1, 7500);
What is the total amount donated by all donors from the United States?
SELECT SUM(Donations.DonationAmount) FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy VARCHAR(50), risk_level INT, sector VARCHAR(20)); INSERT INTO investment_strategies (id, strategy, risk_level, sector) VALUES (1, 'Impact Bonds', 30, 'social impact'), (2, 'Green Equity Funds', 20, 'environment'), (3, 'Sustainable Real Estate', 40, 'real estate');
List all investment strategies with a risk level above 30 and their associated sectors.
SELECT strategy, risk_level, sector FROM investment_strategies WHERE risk_level > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE RacialImpact (race VARCHAR(50), year INT, mineral VARCHAR(50), score INT); INSERT INTO RacialImpact (race, year, mineral, score) VALUES ('African American', 2020, 'Gold', 90), ('Hispanic', 2020, 'Silver', 120), ('Asian', 2020, 'Iron', 150);
What is the total environmental impact score for each racial group, by mineral type, in 2020?
SELECT context.race, context.mineral, SUM(context.score) as total_score FROM context WHERE context.year = 2020 GROUP BY context.race, context.mineral;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_date DATE, region VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO security_incidents (id, incident_date, region, incident_type) VALUES (1, '2022-01-05', 'APAC', 'Phishing'), (2, '2022-02-10', 'EMEA', 'Malware'), (3, '2022-03-15', 'AMER', 'SQL Injection'), (4, '2022-04-20', 'APAC', 'Cross-site Scripting'), (5, '2022-05-25', 'EMEA', 'DoS/DDoS'), (6, '2022-06-01', 'AMER', 'Phishing'), (7, '2022-07-05', 'APAC', 'Malware'), (8, '2022-08-10', 'EMEA', 'SQL Injection'), (9, '2022-09-15', 'AMER', 'Cross-site Scripting'), (10, '2022-10-20', 'APAC', 'DoS/DDoS'), (11, '2022-11-25', 'EMEA', 'Phishing'), (12, '2022-12-01', 'AMER', 'Malware');
What is the distribution of incident types by region?
SELECT region, incident_type, COUNT(*) as incidents_per_region_incident_type FROM security_incidents GROUP BY region, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget INT);
Update the budget for the 'solar_power' project in the 'rural_infrastructure' table to 175000.
UPDATE rural_infrastructure SET budget = 175000 WHERE project_name = 'solar_power';
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name TEXT, location TEXT, focus TEXT); INSERT INTO initiatives (id, name, location, focus) VALUES (1, 'Microfinance Program', 'Southeast Asia', 'Women Empowerment'), (2, 'Education Program', 'Southeast Asia', 'Youth Development');
Calculate the total number of rural development initiatives in Southeast Asia that have a focus on women's empowerment.
SELECT COUNT(DISTINCT initiatives.id) FROM initiatives WHERE initiatives.location = 'Southeast Asia' AND initiatives.focus = 'Women Empowerment';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature_data (data_id INT, date DATE, temperature FLOAT);
Show the average ocean temperature for each month in the 'ocean_temperature_data' table.
SELECT EXTRACT(MONTH FROM date), AVG(temperature) FROM ocean_temperature_data GROUP BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE green_technology_projects (id INT, region VARCHAR(50), investment FLOAT); INSERT INTO green_technology_projects (id, region, investment) VALUES (1, 'Middle East', 200000); INSERT INTO green_technology_projects (id, region, investment) VALUES (2, 'Middle East', 225000);
What is the average investment in green technology projects in the Middle East?
SELECT AVG(investment) FROM green_technology_projects WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), industry VARCHAR(50), ethical_rating INT); INSERT INTO suppliers (id, name, country, industry, ethical_rating) VALUES (1, 'Supplier A', 'USA', 'Electronics', 90), (2, 'Supplier B', 'China', 'Textiles', 70), (3, 'Supplier C', 'India', 'Machinery', 85); CREATE VIEW ethical_suppliers AS SELECT * FROM suppliers WHERE ethical_rating > 80;
List all suppliers from 'ethical_suppliers' view
SELECT * FROM ethical_suppliers;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers(SupplierID INT, Name VARCHAR(50), Type VARCHAR(50));CREATE TABLE MeatProducts(ProductID INT, SupplierID INT, ProductName VARCHAR(50), Quantity INT);INSERT INTO Suppliers VALUES (1, 'Supplier A', 'Meat Supplier'), (2, 'Supplier B', 'Meat Supplier'), (3, 'Supplier C', 'Fruit Supplier');INSERT INTO MeatProducts VALUES (1, 1, 'Beef', 200), (2, 1, 'Chicken', 300), (3, 2, 'Pork', 500), (4, 2, 'Lamb', 400), (5, 3, 'Apples', 500);
Find the number of unique types of meat products supplied by each supplier?
SELECT s.Name, COUNT(DISTINCT m.ProductName) FROM Suppliers s JOIN MeatProducts m ON s.SupplierID = m.SupplierID GROUP BY s.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id INT, country VARCHAR(255), start_date DATE); INSERT INTO clinical_trials (trial_id, country, start_date) VALUES (1, 'Germany', '2016-01-01'), (2, 'France', '2015-06-15'), (3, 'Germany', '2017-09-25');
List all clinical trials that were conducted in Germany since 2015.
SELECT trial_id, country FROM clinical_trials WHERE country = 'Germany' AND start_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE resource_depletion (id INT, location VARCHAR(50), operation_type VARCHAR(50), monthly_resource_depletion INT); INSERT INTO resource_depletion (id, location, operation_type, monthly_resource_depletion) VALUES (1, 'Australia', 'Gold', 500), (2, 'South Africa', 'Gold', 700), (3, 'Canada', 'Diamond', 600);
What is the total quantity of resources depleted from gold mining in Australia and South Africa?
SELECT SUM(CASE WHEN operation_type = 'Gold' THEN monthly_resource_depletion ELSE 0 END) as total_gold_depletion FROM resource_depletion WHERE location IN ('Australia', 'South Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, country TEXT); INSERT INTO artists (id, name, country) VALUES (1, 'Artist A', 'China'), (2, 'Artist B', 'Japan'), (3, 'Artist C', 'France');
How many artists in the database are from Asia?
SELECT COUNT(*) FROM artists WHERE country IN ('China', 'Japan', 'India', 'Korea');
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_demographics (id INT, name VARCHAR(50), age INT, sport VARCHAR(50));
Which athletes are older than 30 years old in the athlete_demographics table?
SELECT name FROM athlete_demographics WHERE age > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, has_diabetes BOOLEAN); INSERT INTO patients (id, age, has_diabetes) VALUES (1, 50, true), (2, 60, false); CREATE TABLE locations (id INT, region VARCHAR, is_rural BOOLEAN); INSERT INTO locations (id, region, is_rural) VALUES (1, 'Northern', true), (2, 'Southern', false);
What is the average age of patients with diabetes in the Northern rural areas of Canada?
SELECT AVG(patients.age) FROM patients INNER JOIN locations ON patients.id = locations.id WHERE patients.has_diabetes = true AND locations.region = 'Northern';
gretelai_synthetic_text_to_sql
INSERT INTO policyholders (id, name, age, gender, policy_type, state) VALUES (4, 'Sara Connor', 28, 'Female', 'Auto', 'Florida');
What is the minimum age of policyholders in Florida with 'Auto' policy_type?
SELECT MIN(age) FROM policyholders WHERE state = 'Florida' AND policy_type = 'Auto';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name TEXT, ocean TEXT, population INTEGER); INSERT INTO marine_species (species_name, ocean, population) VALUES ('Pacific Salmon', 'North Pacific Ocean', 5000000), ('Sea Otter', 'North Pacific Ocean', 100000);
Show the total number of marine species in the North Pacific Ocean
SELECT SUM(population) FROM marine_species WHERE ocean = 'North Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Patents (PatentID INT, Year INT, TeamLead GENDER, Technology VARCHAR(20)); INSERT INTO Patents (PatentID, Year, TeamLead, Technology) VALUES (1, 2018, 'Female', 'Artificial Intelligence'), (2, 2019, 'Male', 'Blockchain'), (3, 2020, 'Female', 'Natural Language Processing');
How many legal technology patents were granted to women-led teams in the last 5 years?
SELECT COUNT(*) FROM Patents WHERE TeamLead = 'Female' AND Year BETWEEN 2017 AND 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO forests (id, name, hectares, country) VALUES (1, 'Boreal Forest', 1200000.0, 'Canada'), (2, 'Amazon Rainforest', 5500000.0, 'Brazil'), (3, 'Daintree Rainforest', 120000.0, 'Australia'); CREATE TABLE trees (id INT, species VARCHAR(255), height FLOAT, forest_id INT); INSERT INTO trees (id, species, height, forest_id) VALUES (1, 'White Spruce', 42.0, 1), (2, 'Rainforest Gum', 30.0, 2), (3, 'Southern Silky Oak', 70.0, 3); CREATE VIEW avg_tree_height AS SELECT forest_id, AVG(height) as avg_height FROM trees GROUP BY forest_id;
Which forests have an average tree height over 45 meters?
SELECT forests.name FROM forests INNER JOIN avg_tree_height ON forests.id = avg_tree_height.forest_id WHERE avg_tree_height.avg_height > 45;
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, '2019-12-31'); INSERT INTO posts (id, user_id, post_date) VALUES (2, 3, '2020-01-02'); INSERT INTO posts (id, user_id, post_date) VALUES (3, 3, '2020-01-03');
Delete all posts from user 'Charlie' before 2020-01-01.
DELETE FROM posts WHERE user_id = (SELECT id FROM users WHERE name = 'Charlie') AND post_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_sourcing (practice VARCHAR(255), location VARCHAR(255), quarter INT, year INT); INSERT INTO sustainable_sourcing (practice, location, quarter, year) VALUES ('Organic meat', 'Texas', 1, 2022), ('Seasonal ingredients', 'Texas', 1, 2022);
Which sustainable sourcing practices were implemented in Texas in Q1 2022?
SELECT DISTINCT practice FROM sustainable_sourcing WHERE location = 'Texas' AND quarter = 1 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE exploration_projects_caribbean (id INT, location VARCHAR(20), start_date DATE);
List all exploration projects in the Caribbean that started before 2015.
SELECT * FROM exploration_projects_caribbean WHERE location LIKE 'Caribbean%' AND start_date < '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255)); CREATE TABLE ocean_basin (id INT, name VARCHAR(255)); CREATE TABLE species_ocean_basin (species_id INT, ocean_basin_id INT);
List all marine species that are found in more than one ocean basin
SELECT species.name FROM species JOIN species_ocean_basin ON species.id = species_ocean_basin.species_id JOIN ocean_basin ON species_ocean_basin.ocean_basin_id = ocean_basin.id GROUP BY species.name HAVING COUNT(DISTINCT ocean_basin.name) > 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA policy_trends; CREATE TABLE clean_energy_trends (year INT, num_trends INT); INSERT INTO clean_energy_trends (year, num_trends) VALUES (2015, 12), (2016, 18), (2017, 22), (2018, 27), (2019, 31);
How many clean energy policy trends were recorded in '2016' and '2017'?
SELECT SUM(num_trends) FROM policy_trends.clean_energy_trends WHERE year IN (2016, 2017);
gretelai_synthetic_text_to_sql
CREATE TABLE budget_2022 (service TEXT, budget INTEGER); INSERT INTO budget_2022 (service, budget) VALUES ('Education', 1500000), ('Healthcare', 1200000), ('Police', 1000000), ('Transportation', 800000);
What are the total budgets for public services in 2022, excluding the education and healthcare services?
SELECT SUM(budget) FROM budget_2022 WHERE service NOT IN ('Education', 'Healthcare');
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours_4 (tour_id INT, tour_name TEXT, date DATE, engagement INT, ota_id INT); INSERT INTO virtual_tours_4 (tour_id, tour_name, date, engagement, ota_id) VALUES (1, 'Tour C', '2022-01-01', 100, 1), (2, 'Tour D', '2022-01-05', 150, 2); CREATE TABLE online_travel_agencies_4 (ota_id INT, ota_name TEXT); INSERT INTO online_travel_agencies_4 (ota_id, ota_name) VALUES (1, 'OTA C'), (2, 'OTA D');
Which online travel agencies offer virtual tours in the African region?
SELECT ota_name FROM online_travel_agencies_4 INNER JOIN virtual_tours_4 ON online_travel_agencies_4.ota_id = virtual_tours_4.ota_id WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50));
Add a new program named "Green Thumbs" to the Programs table.
INSERT INTO Programs (ProgramID, ProgramName) VALUES (3, 'Green Thumbs');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, price DECIMAL(5,2), product_type TEXT); INSERT INTO products (product_id, price, product_type) VALUES (1, 25.99, 'Foundation'), (2, 15.49, 'Eyeshadow'), (3, 34.99, 'Foundation');
What is the difference in price between the most and least expensive foundations?
SELECT MAX(price) - MIN(price) FROM products WHERE product_type = 'Foundation';
gretelai_synthetic_text_to_sql
CREATE TABLE stop_sequence (stop_id INT, stop_sequence INT, route_id INT); INSERT INTO stop_sequence (stop_id, stop_sequence, route_id) VALUES (1001, 1, 101), (1002, 2, 101), (1003, 3, 101), (1004, 4, 101), (1005, 5, 101), (1006, 6, 101), (1007, 7, 101), (1008, 8, 101), (1009, 9, 101), (1010, 10, 101);
Identify the top 2 most frequently accessed bus stops along route 101?
SELECT stop_sequence, stop_id, COUNT(*) as access_count FROM stop_sequence WHERE route_id = 101 GROUP BY stop_sequence ORDER BY access_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspection ( id INT PRIMARY KEY, mine_id INT, inspector_id INT, year INT, date DATE, FOREIGN KEY (mine_id) REFERENCES Mine(id) );
What is the average waste generation volume for mines with more than 3 inspections in the year 2020?
SELECT AVG(wg.waste_volume) as avg_waste_volume FROM Waste_Generation wg JOIN Mine m ON wg.mine_id = m.id JOIN Inspection i ON m.id = i.mine_id WHERE i.year = 2020 GROUP BY m.id HAVING COUNT(i.id) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, organization_id INT, source VARCHAR(50), amount INT); CREATE TABLE organizations (organization_id INT, region VARCHAR(50));
What is the total funding received by arts organizations in the South region?
SELECT SUM(f.amount) as total_funding FROM funding f JOIN organizations o ON f.organization_id = o.organization_id WHERE o.region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE tech_for_social_good_budget (initiative_id INT, initiative_name VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO tech_for_social_good_budget (initiative_id, initiative_name, region, budget) VALUES (1, 'Smart city project', 'Asia', 1000000), (2, 'Green technology initiative', 'Europe', 800000), (3, 'Accessible technology for rural areas', 'Asia', 500000), (4, 'Educational technology for refugees', 'Europe', 900000), (5, 'Women in tech program', 'Asia', 700000), (6, 'Community tech center', 'Africa', 400000);
Which technology for social good initiatives have a budget greater than $600000?
SELECT initiative_name FROM tech_for_social_good_budget WHERE budget > 600000;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_engineering(dish VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), restaurant VARCHAR(255));
Update the price of the 'Tofu Stir Fry' dish to $12.50 in the 'Asian Fusion' restaurant.
UPDATE menu_engineering SET price = 12.50 WHERE dish = 'Tofu Stir Fry' AND restaurant = 'Asian Fusion';
gretelai_synthetic_text_to_sql
CREATE TABLE astronaut_medical (id INT, astronaut VARCHAR, mission VARCHAR, medical_score INT);
What is the maximum medical score for each astronaut during their missions?
SELECT astronaut, MAX(medical_score) as max_medical_score FROM astronaut_medical GROUP BY astronaut;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_facilities (region VARCHAR(50), capacity NUMERIC, technology VARCHAR(50)); INSERT INTO renewable_facilities (region, capacity, technology) VALUES ('Asia-Pacific', 500, 'Solar'), ('Asia-Pacific', 600, 'Wind'), ('Europe', 400, 'Hydro'), ('Africa', 300, 'Geothermal');
How many renewable energy facilities are located in the Asia-Pacific region, and what is their total capacity in MW?
SELECT region, SUM(capacity) as total_capacity FROM renewable_facilities WHERE region = 'Asia-Pacific' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO customers (id, name, city, state) VALUES (1, 'John Doe', 'San Francisco', 'CA'), (2, 'Jane Smith', 'Los Angeles', 'CA'), (3, 'Alice Johnson', 'San Jose', 'CA'); CREATE TABLE purchases (id INT, customer_id INT, product_id INT, purchase_date DATE, quantity_sold INT, price DECIMAL(10, 2)); INSERT INTO purchases (id, customer_id, product_id, purchase_date, quantity_sold, price) VALUES (1, 1, 1, '2022-01-01', 50, 100), (2, 2, 2, '2022-01-02', 75, 150), (3, 3, 3, '2022-01-03', 100, 200); CREATE TABLE products (id INT, name VARCHAR(255), is_sustainable BOOLEAN); INSERT INTO products (id, name, is_sustainable) VALUES (1, 'Product X', TRUE), (2, 'Product Y', FALSE), (3, 'Product Z', TRUE);
Rank the top 5 customers by their total spending on sustainable products in descending order.
SELECT c.name, SUM(p.price * p.quantity_sold) as total_spent FROM purchases p JOIN customers c ON p.customer_id = c.id JOIN products pr ON p.product_id = pr.id WHERE pr.is_sustainable = TRUE GROUP BY c.name ORDER BY total_spent DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(255), gender VARCHAR(10), department VARCHAR(255)); INSERT INTO faculty (id, name, gender, department) VALUES (1, 'Alex', 'Non-binary', 'Physics'), (2, 'Bob', 'Male', 'Mathematics'), (3, 'Charlie', 'Male', 'Chemistry'), (4, 'Diana', 'Female', 'Biology');
What is the total amount of research grants awarded to non-binary faculty members in the 'faculty' and 'research_grants' tables?
SELECT SUM(rg.amount) FROM research_grants rg JOIN faculty f ON rg.department = f.department WHERE f.gender = 'Non-binary';
gretelai_synthetic_text_to_sql
CREATE TABLE GeneSequencing (client_id INT, sequencing_date DATE, sequencing_cost FLOAT); INSERT INTO GeneSequencing (client_id, sequencing_date, sequencing_cost) VALUES (1, '2022-01-10', 4500.50), (2, '2022-03-15', 6200.75), (3, '2022-02-28', 3000.20), (4, '2022-06-20', 5800.00), (5, '2022-12-27', 7000.00);
What is the minimum sequencing cost for a unique client in the last 3 months?
SELECT MIN(sequencing_cost) FROM GeneSequencing WHERE sequencing_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY client_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Artist (ArtistID INT, ArtistName VARCHAR(50), TotalSales DECIMAL(10,2)); INSERT INTO Artist (ArtistID, ArtistName, TotalSales) VALUES (1, 'ArtistA', 5000), (2, 'ArtistB', 7000), (3, 'ArtistC', 6000), (4, 'ArtistD', 8000), (5, 'ArtistE', 4000);
Who are the top 3 artists with the highest art sales?
SELECT ArtistName, TotalSales FROM (SELECT ArtistName, TotalSales, ROW_NUMBER() OVER (ORDER BY TotalSales DESC) as Rank FROM Artist) AS Subquery WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE SCHEMA SpaceMissions;CREATE TABLE IndianMissions (MissionID INT, Country VARCHAR(50), LaunchYear INT);INSERT INTO IndianMissions VALUES (1, 'India', 2000), (2, 'India', 2005), (3, 'India', 2010), (4, 'India', 2015), (5, 'India', 2020);
How many space missions were launched by India in total?
SELECT COUNT(*) FROM IndianMissions WHERE Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchStudies (Id INT, Name TEXT, Location TEXT, StartDate DATE, EndDate DATE); INSERT INTO ResearchStudies (Id, Name, Location, StartDate, EndDate) VALUES (1, 'Self-Driving Cars in California', 'California', '2015-01-01', '2016-01-01'), (2, 'Autonomous Vehicle Testing in Texas', 'Texas', '2016-06-15', '2018-06-15'), (3, 'Electric Autonomous Vehicles', 'California', '2018-03-11', '2020-03-11');
List the names of all autonomous driving research studies that have been completed.
SELECT Name FROM ResearchStudies WHERE EndDate IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, crime_date DATE, district VARCHAR(20), crime_count INT);
What is the maximum number of crimes committed per day in the "south" district, for the month of July?
SELECT MAX(crime_count) FROM crimes WHERE district = 'south' AND EXTRACT(MONTH FROM crime_date) = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE building_efficiency (id INT, country VARCHAR(255), efficiency FLOAT);
What is the average energy efficiency of buildings in the United Kingdom?
SELECT AVG(efficiency) FROM building_efficiency WHERE country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal VARCHAR(50), continent VARCHAR(50), population INT); INSERT INTO animal_population (animal, continent, population) VALUES ('Kakapo', 'Oceania', 200), ('Quokka', 'Oceania', 10000), ('Iberian Lynx', 'Europe', 400); CREATE VIEW community_education AS SELECT animal, CONCAT('South ', continent) AS continent FROM animal_population WHERE continent IN ('Africa', 'Asia', 'South America');
What is the total number of animals in the 'community_education' view that are native to Oceania or Europe?
SELECT animal FROM community_education WHERE continent = 'South Oceania' UNION ALL SELECT animal FROM community_education WHERE continent = 'South Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE boroughs (id INT, name TEXT); INSERT INTO boroughs (id, name) VALUES (1, 'Bronx'), (2, 'Manhattan'), (3, 'Queens'); CREATE TABLE fire_incidents (id INT, borough_id INT, incidents INT, incident_date DATE); INSERT INTO fire_incidents (id, borough_id, incidents, incident_date) VALUES (1, 1, 3, '2023-01-01'), (2, 1, 4, '2023-02-15'), (3, 1, 5, '2023-03-10');
What is the total number of fire incidents in the Bronx borough in the last 6 months?
SELECT SUM(incidents) FROM fire_incidents WHERE borough_id = 1 AND incident_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, service VARCHAR(10), region VARCHAR(20)); INSERT INTO subscribers (id, service, region) VALUES (1, 'mobile', 'Caribbean'), (2, 'broadband', 'Caribbean'); CREATE TABLE usage (subscriber_id INT, data_usage FLOAT, year INT); INSERT INTO usage (subscriber_id, data_usage, year) VALUES (1, 12500, 2021), (1, 13000, 2022), (1, 11500, 2020), (2, 550000, 2022), (2, 555000, 2021), (2, 550000, 2020);
What is the total number of mobile subscribers and the total mobile data usage in TB for the Caribbean region in 2021?
SELECT subscribers.region, COUNT(subscribers.id) AS total_customers, SUM(usage.data_usage/1024/1024/1024) AS total_usage FROM subscribers JOIN usage ON subscribers.id = usage.subscriber_id WHERE subscribers.service = 'mobile' AND subscribers.region = 'Caribbean' AND usage.year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShows (City VARCHAR(50), State VARCHAR(50), Country VARCHAR(50), Year INT, Attendees INT); INSERT INTO AutoShows (City, State, Country, Year, Attendees) VALUES ('Las Vegas', 'NV', 'USA', 2022, 400000);
Identify top 5 cities with the most auto shows
SELECT City, COUNT(*) as num_of_auto_shows FROM AutoShows GROUP BY City ORDER BY num_of_auto_shows DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (id INT, country VARCHAR(50), occupation VARCHAR(50), hours DECIMAL(10,2)); INSERT INTO labor_hours (id, country, occupation, hours) VALUES (1, 'USA', 'Carpenter', 40.00), (2, 'Canada', 'Carpenter', 38.00), (3, 'USA', 'Electrician', 42.00), (4, 'Canada', 'Electrician', 40.00);
What is the average number of construction labor hours per week in the United States and Canada, broken down by occupation?
SELECT lh.country, lh.occupation, AVG(lh.hours) as avg_hours FROM labor_hours lh WHERE lh.country IN ('USA', 'Canada') GROUP BY lh.country, lh.occupation;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, year INT, event_type VARCHAR(10)); INSERT INTO events (id, year, event_type) VALUES (1, 2022, 'Art Exhibition'), (2, 2022, 'Theater Performance'), (3, 2021, 'Music Concert'), (4, 2022, 'Dance Recital');
How many cultural events were held in 2022?
SELECT COUNT(*) FROM events WHERE year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE OilRig (RigID int, RigName varchar(50), DrillingType varchar(50), WaterDepth int, Country varchar(50));
Find the number of offshore drilling platforms for each country in the OilRig table
SELECT Country, COUNT(*) as Num_Offshore_Rigs FROM OilRig WHERE DrillingType = 'Offshore' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE buses (id INT PRIMARY KEY, registration_number VARCHAR(10), next_maintenance_date DATE);
Show the daily maintenance records for buses with registration numbers starting with 'A' in the first quarter of 2021
SELECT DATE(next_maintenance_date) AS maintenance_date, registration_number FROM buses WHERE registration_number LIKE 'A%' AND next_maintenance_date >= '2021-01-01' AND next_maintenance_date < '2021-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Relief_Aid (id INT, disaster_id INT, organization VARCHAR(50), amount FLOAT, date DATE); INSERT INTO Relief_Aid (id, disaster_id, organization, amount, date) VALUES (7, 8, 'Red Cross', 12000, '2021-07-01'); CREATE TABLE Disaster (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO Disaster (id, name, location, type, start_date, end_date) VALUES (8, 'Storm', 'Europe', 'Wind', '2021-07-05', '2021-07-10');
What is the total amount of relief aid provided by 'Red Cross' for disasters not related to 'Floods'?
SELECT SUM(Relief_Aid.amount) FROM Relief_Aid WHERE Relief_Aid.organization = 'Red Cross' AND Relief_Aid.disaster_id NOT IN (SELECT Disaster.id FROM Disaster WHERE Disaster.type = 'Flood')
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(255), founding_year INT, founder_gender VARCHAR(10), industry VARCHAR(255)); INSERT INTO startups (id, name, founding_year, founder_gender, industry) VALUES (1, 'Kilo Lima', 2015, 'Female', 'Tech'), (2, 'Mike November', 2017, 'Male', 'Retail'), (3, 'November Oscar', 2018, 'Female', 'Tech'); CREATE TABLE funding (startup_id INT, amount INT); INSERT INTO funding (startup_id, amount) VALUES (1, 500000), (1, 1000000), (3, 750000);
List the unique industries of startups that have at least one female founder and have received funding.
SELECT DISTINCT startups.industry FROM startups INNER JOIN funding ON startups.id = funding.startup_id WHERE startups.founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE RaceEthnicityData (RaceEthnicity VARCHAR(255), Uninsured DECIMAL(3,1)); INSERT INTO RaceEthnicityData (RaceEthnicity, Uninsured) VALUES ('Asian', 5.0), ('Black', 12.0), ('Hispanic', 18.0), ('White', 8.0); CREATE TABLE OverallData (OverallUninsured DECIMAL(3,1)); INSERT INTO OverallData (OverallUninsured) VALUES (10.0);
What is the percentage of uninsured individuals by race and ethnicity, and how does it compare to the overall percentage?
SELECT RaceEthnicity, Uninsured, Uninsured * 100.0 / (SELECT OverallUninsured FROM OverallData) AS Percentage FROM RaceEthnicityData;
gretelai_synthetic_text_to_sql
CREATE TABLE orgs (org_id INT, name VARCHAR(50), employees INT, sector VARCHAR(50)); CREATE TABLE funding_source (funding_source_id INT, name VARCHAR(50)); CREATE TABLE funding (funding_id INT, org_id INT, funding_source_id INT, funded_country VARCHAR(50)); INSERT INTO orgs (org_id, name, employees, sector) VALUES (1, 'OrgX', 100, 'ethical AI'), (2, 'OrgY', 200, 'healthcare'), (3, 'OrgZ', 150, 'ethical AI'); INSERT INTO funding_source (funding_source_id, name) VALUES (1, 'European Commission'), (2, 'Gates Foundation'); INSERT INTO funding (funding_id, org_id, funding_source_id, funded_country) VALUES (1, 1, 1, 'Europe'), (2, 3, 1, 'Europe');
What are the names and number of employees of organizations in the ethical AI sector that have been granted funding from the European Commission in Europe?
SELECT o.name, COUNT(f.org_id) FROM orgs o JOIN funding f ON o.org_id = f.org_id JOIN funding_source fs ON f.funding_source_id = fs.funding_source_id WHERE o.sector = 'ethical AI' AND fs.name = 'European Commission' AND f.funded_country = 'Europe' GROUP BY o.name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, subscriber_type VARCHAR(10), region VARCHAR(10), usage FLOAT);
Identify the number of mobile subscribers in each region and their average monthly usage
SELECT region, COUNT(*), AVG(usage) FROM mobile_subscribers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE VisualArtsPrograms (ProgramID INT, ProgramName VARCHAR(50), Date DATE); CREATE TABLE Attendees (AttendeeID INT, AttendeeName VARCHAR(50), Age INT, ProgramID INT, FirstAttendance DATE, LastAttendance DATE, FOREIGN KEY (ProgramID) REFERENCES VisualArtsPrograms(ProgramID));
What is the total number of repeat attendees for visual arts programs, and how does this number vary by age group?
SELECT AVG(Attendees.Age), COUNT(DISTINCT Attendees.AttendeeID) FROM Attendees WHERE DATEDIFF(Attendees.LastAttendance, Attendees.FirstAttendance) > 365 GROUP BY (Attendees.Age / 10) * 10;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR, military_spending FLOAT, population INT);
What is the maximum, minimum, and average military spending per capita for countries involved in peacekeeping operations?
SELECT country, MAX(military_spending / population) AS max_military_spending_per_capita, MIN(military_spending / population) AS min_military_spending_per_capita, AVG(military_spending / population) AS avg_military_spending_per_capita FROM peacekeeping_operations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, location VARCHAR(20), volume INT, date DATE); INSERT INTO wells (id, location, volume, date) VALUES (1, 'Caspian Sea', 1200, '2021-01-01'); INSERT INTO wells (id, location, volume, date) VALUES (2, 'Caspian Sea', 2300, '2021-02-01'); INSERT INTO wells (id, location, volume, date) VALUES (3, 'Caspian Sea', 3400, '2021-03-01');
Find the maximum production volume for wells in the Caspian Sea in 2021.
SELECT MAX(volume) FROM wells WHERE location = 'Caspian Sea' AND YEAR(date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, area FLOAT, city VARCHAR(20), sustainable_urbanism_rating INT); INSERT INTO properties (id, area, city, sustainable_urbanism_rating) VALUES (1, 1500, 'Boston', 8), (2, 1200, 'Boston', 7), (3, 1800, 'Boston', 9), (4, 1100, 'Chicago', 6), (5, 1400, 'Boston', 7.5);
What is the total area of properties in the city of Boston with a sustainable urbanism rating above 7?
SELECT SUM(area) FROM properties WHERE city = 'Boston' AND sustainable_urbanism_rating > 7;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS public.projects2 (id SERIAL PRIMARY KEY, name TEXT, start_date DATE); INSERT INTO public.projects2 (name, start_date) SELECT 'ExampleProject3', CURRENT_DATE - INTERVAL '10 days' FROM generate_series(1, 10); INSERT INTO public.projects2 (name, start_date) SELECT 'ExampleProject4', CURRENT_DATE - INTERVAL '60 days' FROM generate_series(1, 10);
List all projects in the "public" schema that have a name that contains the substring "ex" and have a start date within the last 30 days?
SELECT name, start_date FROM public.projects2 WHERE name ILIKE '%ex%' AND start_date >= CURRENT_DATE - INTERVAL '30 days';
gretelai_synthetic_text_to_sql
CREATE TABLE Recurring_Donors (donor_id INT, donation_amount DECIMAL(10,2), donation_frequency INT, first_donation_date DATE);
What was the average donation amount for recurring donors in 2022?
SELECT AVG(donation_amount) FROM Recurring_Donors WHERE donor_id IN (SELECT donor_id FROM Recurring_Donors GROUP BY donor_id HAVING COUNT(*) > 1) AND first_donation_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE EconomicImpact (region VARCHAR(50), impact FLOAT, direct BOOLEAN); INSERT INTO EconomicImpact (region, impact, direct) VALUES ('New York City', 250000.00, true), ('New York City', 125000.00, false);
Show the total economic impact of tourism in New York City, including direct and indirect effects.
SELECT SUM(impact) FROM EconomicImpact WHERE region = 'New York City';
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50));
What is the number of unique countries represented in the 'readers' table?
SELECT COUNT(DISTINCT country) FROM readers;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_engineering (item VARCHAR(255), revenue FLOAT, month VARCHAR(9)); INSERT INTO menu_engineering (item, revenue, month) VALUES ('Burger', 3000, 'February-2022'), ('Pizza', 2500, 'February-2022'), ('Salad', 2000, 'February-2022');
Which menu item had the highest revenue in February 2022?
SELECT item, MAX(revenue) FROM menu_engineering WHERE month = 'February-2022';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, region TEXT, capacity INT); INSERT INTO hospitals (id, name, region, capacity) VALUES (1, 'Hospital A', 'Midwest', 200), (2, 'Hospital B', 'Midwest', 300), (3, 'Clinic C', 'Northeast', 50), (4, 'Hospital D', 'West', 250), (5, 'Clinic E', 'South', 40);
What is the total capacity of hospitals and clinics in the Midwest region?
SELECT SUM(capacity) FROM hospitals WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(50), description TEXT, price DECIMAL(5,2), category VARCHAR(20), is_vegan BOOLEAN);
Update the is_vegan column to true for all items in the menu_items table with 'vegetable stir-fry' as the name
UPDATE menu_items SET is_vegan = TRUE WHERE name = 'vegetable stir-fry';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO artists (id, name, country) VALUES (1, 'Frida Kahlo', 'Mexico'); INSERT INTO artists (id, name, country) VALUES (2, 'Pablo Picasso', 'Spain'); CREATE TABLE paintings (id INT, artist_id INT, year INT); INSERT INTO paintings (id, artist_id, year) VALUES (1, 1, 2000); INSERT INTO paintings (id, artist_id, year) VALUES (2, 2, 2000); INSERT INTO paintings (id, artist_id, year) VALUES (3, 1, 2001);
How many paintings were created per year by artists from different countries?
SELECT p.year, country, COUNT(p.id) as paintings_per_year FROM paintings p JOIN artists a ON p.artist_id = a.id GROUP BY p.year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_rooms (hotel_id INT, city VARCHAR(50), room_rate DECIMAL(5,2)); INSERT INTO hotel_rooms (hotel_id, city, room_rate) VALUES (1, 'Barcelona', 100), (2, 'Barcelona', 120), (3, 'Barcelona', 150), (4, 'Madrid', 80);
Update the room rates for hotels in Barcelona with an ID greater than 3.
UPDATE hotel_rooms SET room_rate = room_rate * 1.1 WHERE city = 'Barcelona' AND hotel_id > 3;
gretelai_synthetic_text_to_sql