context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Artists (id INT, name VARCHAR(50), community VARCHAR(50)); CREATE TABLE Artworks (id INT, title VARCHAR(50), artist_id INT);
Which artists from underrepresented communities have the most works in our collection?
SELECT Artists.name, COUNT(Artworks.id) as artwork_count FROM Artists INNER JOIN Artworks ON Artists.id = Artworks.artist_id WHERE Artists.community IN ('Indigenous', 'African American', 'Latinx') GROUP BY Artists.name ORDER BY artwork_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE project (project_id INT, project_start_date DATE, project_end_date DATE, project_type VARCHAR(50), country_code CHAR(3), completed BOOLEAN); INSERT INTO project (project_id, project_start_date, project_end_date, project_type, country_code, completed) VALUES (1, '2020-01-01', '2021-12-31', 'Road Constructio...
What is the total number of rural infrastructure projects and their completion rate for each country, categorized by project type?
SELECT country_code, project_type, COUNT(*) AS num_projects, SUM(completed) AS num_completed FROM project GROUP BY country_code, project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE strategies (id INT, sector VARCHAR(20), investment FLOAT); INSERT INTO strategies (id, sector, investment) VALUES (1, 'Education', 50000.0), (2, 'Healthcare', 75000.0), (3, 'Education', 100000.0);
What is the investment in the first strategy?
SELECT investment FROM strategies WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (PropertyID INT, Price INT, SustainabilityScore INT, Neighborhood VARCHAR(20)); INSERT INTO Properties (PropertyID, Price, SustainabilityScore, Neighborhood) VALUES (1, 300000, 80, 'GreenTowers'), (2, 450000, 95, 'SustainableVillage'), (3, 250000, 60, 'GreenTowers');
List the top 3 most affordable properties based on their sustainability scores in 'GreenTowers' and 'SustainableVillage' neighborhoods, ordered by price.
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY Neighborhood ORDER BY Price) AS rn FROM Properties WHERE Neighborhood IN ('GreenTowers', 'SustainableVillage') ORDER BY Price) sub WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id TEXT, fda_approval BOOLEAN, ema_approval BOOLEAN); INSERT INTO clinical_trials (trial_id, fda_approval, ema_approval) VALUES ('CT001', TRUE, FALSE), ('CT002', FALSE, TRUE), ('CT003', TRUE, TRUE);
List all clinical trials that have been approved by the FDA, but not by the EMA.
SELECT * FROM clinical_trials WHERE fda_approval = TRUE AND ema_approval = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT); INSERT INTO mines (id, name, location, production_volume) VALUES (1, 'Indian Iron Mine 1', 'India', 7000); INSERT INTO mines (id, name, location, production_volume) VALUES (2, 'Indian Iron Mine 2', 'India', 8000);
What is the average production volume for all iron mines in India?
SELECT AVG(production_volume) FROM mines WHERE location = 'India' AND mineral = 'iron';
gretelai_synthetic_text_to_sql
CREATE TABLE DecentralizedApps (name VARCHAR(255), developer VARCHAR(255), contract_address VARCHAR(255)); INSERT INTO DecentralizedApps (name, developer, contract_address) VALUES ('App1', 'DevA', '0x1111'), ('App2', 'DevB', '0x2222'), ('App3', 'DevC', '0x3333');
Delete the decentralized application 'App3' and all related information
DELETE FROM DecentralizedApps WHERE name = 'App3'; DELETE FROM SmartContracts WHERE contract_address = '0x3333'; DELETE FROM DigitalAssets WHERE name = 'App3';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_habitat (habitat_id INT, habitat_name VARCHAR(50), animal_name VARCHAR(50), acres FLOAT); INSERT INTO animal_habitat (habitat_id, habitat_name, animal_name, acres) VALUES (1, 'African Savannah', 'Lion', 5000.0), (2, 'Asian Rainforest', 'Tiger', 2000.0), (3, 'African Rainforest', 'Elephant', 3000.0);
What is the average number of acres of habitat for each animal species in the 'animal_habitat' table?
SELECT animal_name, AVG(acres) FROM animal_habitat GROUP BY animal_name;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists program (id INT, name VARCHAR(50), category VARCHAR(50)); CREATE TABLE if not exists funding (id INT, program_id INT, year INT, amount DECIMAL(10, 2)); INSERT INTO program (id, name, category) VALUES (1, 'Dance Education', 'Education'), (2, 'Artistic Explorers', 'Youth'), (3, 'Art & Creation'...
What is the total funding received for 'Dance Education' programs in 2022?
SELECT SUM(f.amount) FROM funding f JOIN program p ON f.program_id = p.id WHERE p.name = 'Dance Education' AND f.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_activity (volunteer_id INT, activity_type VARCHAR(255), hours_spent INT, activity_date DATE); INSERT INTO volunteer_activity (volunteer_id, activity_type, hours_spent, activity_date) VALUES (1, 'capacity building', 5, '2021-01-01'), (2, 'fundraising', 10, '2021-01-15'), (3, 'capacity building', 1...
What is the minimum number of hours volunteers spent on capacity building activities in Q1 2021?
SELECT MIN(hours_spent) FROM volunteer_activity WHERE activity_type = 'capacity building' AND YEAR(activity_date) = 2021 AND QUARTER(activity_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_cotton_supply_chain (manufacturer_id INT, quantity FLOAT); INSERT INTO organic_cotton_supply_chain (manufacturer_id, quantity) VALUES (1, 400.0), (2, 350.0), (3, 550.0);
What is the total quantity of organic cotton used by manufacturers in the ethical fashion supply chain?
SELECT SUM(quantity) FROM organic_cotton_supply_chain;
gretelai_synthetic_text_to_sql
CREATE TABLE production_by_country (country VARCHAR(50), oil_production FLOAT); INSERT INTO production_by_country (country, oil_production) VALUES ('USA', 10000000), ('Canada', 7000000), ('Mexico', 6000000), ('Brazil', 8000000);
Discover the top 2 countries with the highest oil production
SELECT country, oil_production FROM production_by_country ORDER BY oil_production DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE SCHEMA fitness; CREATE TABLE membership (member_id INT, member_start_date DATE, member_end_date DATE); CREATE TABLE participation (member_id INT, activity VARCHAR(20), participation_date DATE); INSERT INTO membership (member_id, member_start_date, member_end_date) VALUES (1, '2021-01-01', '2021-12-31'), (2, '202...
Identify the number of members who participated in each of the following activities: Running, Cycling, Swimming, and Yoga in the month of October 2021.
SELECT activity, COUNT(*) AS participants FROM participation INNER JOIN membership ON participation.member_id = membership.member_id WHERE YEAR(participation_date) = 2021 AND MONTH(participation_date) = 10 AND membership.member_start_date <= participation_date AND (membership.member_end_date IS NULL OR membership.membe...
gretelai_synthetic_text_to_sql
CREATE TABLE solar_installations (id INT, name VARCHAR(50), state VARCHAR(50), capacity FLOAT, completion_year INT);
How many solar power installations have been completed in California since 2015, excluding installations with a capacity of less than 1 MW?
SELECT COUNT(*) FROM solar_installations WHERE state = 'California' AND completion_year >= 2015 AND capacity >= 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), network VARCHAR(255), creation_date DATE); INSERT INTO digital_assets (asset_id, name, network, creation_date) VALUES (1, 'Asset1', 'polygon', '2022-02-01'), (2, 'Asset2', 'binance', '2022-01-01'); CREATE TABLE smart_contracts (contract_id INT, network VARCH...
Which digital assets in the 'polygon' and 'binance' networks were created in the same month as the latest updated smart contract?
SELECT name FROM digital_assets WHERE network IN ('polygon', 'binance') AND EXTRACT(MONTH FROM creation_date) = EXTRACT(MONTH FROM (SELECT MAX(last_updated) FROM smart_contracts WHERE network IN ('polygon', 'binance')));
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, Age INT, Gender VARCHAR(10), Income FLOAT); CREATE TABLE Cases (CaseID INT, ClientID INT, CaseOpenDate DATETIME);
List all clients who have not had any cases in the past 6 months, along with their demographic information.
SELECT C.ClientID, C.Age, C.Gender, C.Income FROM Clients C LEFT JOIN Cases CS ON C.ClientID = CS.ClientID WHERE CS.CaseOpenDate > DATE_SUB(CURDATE(), INTERVAL 6 MONTH) IS NULL;
gretelai_synthetic_text_to_sql
CREATE SCHEMA rural; CREATE TABLE rural.clinics (id INT, building_type TEXT);
Delete all records from the 'clinics' table where the building_type is 'mobile'.
DELETE FROM rural.clinics WHERE building_type = 'mobile';
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (id INT, vessel_name VARCHAR(255), vessel_type VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6), accident_date DATE); INSERT INTO accidents (id, vessel_name, vessel_type, latitude, longitude, accident_date) VALUES (1, 'VesselA', 'Cargo', 36.883204, 14.773147, '2022-01-01');
How many accidents were reported for each vessel type in the Mediterranean Sea?
SELECT vessel_type, COUNT(*) as num_accidents FROM accidents WHERE latitude BETWEEN 30.0 AND 45.0 AND longitude BETWEEN -0.0 AND 30.0 GROUP BY vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, region TEXT); INSERT INTO mobile_subscribers (subscriber_id, region) VALUES (1, 'Asia-Pacific'); CREATE TABLE broadband_subscribers (subscriber_id INT, region TEXT); INSERT INTO broadband_subscribers (subscriber_id, region) VALUES (1, 'Asia-Pacific');
Display the total number of mobile subscribers and broadband subscribers in the Asia-Pacific region.
SELECT COUNT(*) FROM mobile_subscribers WHERE region = 'Asia-Pacific' UNION ALL SELECT COUNT(*) FROM broadband_subscribers WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), population INT, habitat VARCHAR(255));
Insert a new record into the species table for a marine mammal found in the Pacific Ocean
INSERT INTO species (id, name, type, population, habitat) VALUES (12, 'Bottlenose Dolphin', 'Mammal', 50000, 'Pacific Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT); INSERT INTO company (id, name, industry, founding_date, founder_gender) VALUES (1, 'HealCo', 'Healthcare', '2019-01-01', 'Female');
What is the average funding amount for female-founded startups in the healthcare sector?
SELECT AVG(funding_amount) FROM company WHERE industry = 'Healthcare' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (id INT, course_name VARCHAR(50), enrollment INT); INSERT INTO courses (id, course_name, enrollment) VALUES (1, 'Introduction to Open Pedagogy', 30), (2, 'Advanced Open Pedagogy', 25), (3, 'Open Pedagogy Research Methods', 20), (4, 'Open Pedagogy Capstone', 15);
What is the maximum number of students enrolled in a course in the open pedagogy program?
SELECT MAX(enrollment) as max_enrollment FROM courses WHERE course_name LIKE '%Open Pedagogy%';
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, organization VARCHAR(50), amount INT, region VARCHAR(20)); INSERT INTO funding (funding_id, organization, amount, region) VALUES (1, 'Organization A', 500000, 'Oceania'), (2, 'Organization B', 700000, 'Oceania');
What is the maximum funding amount provided by organizations in Oceania for legal technology initiatives?
SELECT MAX(amount) FROM funding WHERE region = 'Oceania' AND funding.organization LIKE '%legal technology%';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT, name VARCHAR(255), country VARCHAR(255), certification VARCHAR(255)); INSERT INTO suppliers(id, name, country, certification) VALUES (1, 'Conventional Textiles', 'China', 'None'), (2, 'Organic Textiles', 'India', 'GOTS'), (3, 'Recycled Textiles', 'Bangladesh', 'Global Recycling Standard')...
Delete all records from the 'suppliers' table where the 'certification' is 'None' and the 'country' is 'China'
DELETE FROM suppliers WHERE certification = 'None' AND country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(50), type VARCHAR(20), product_code VARCHAR(10), state VARCHAR(2)); INSERT INTO products (id, name, type, product_code, state) VALUES (1, 'Savings Account', 'Shariah', 'SA101', 'Texas'); CREATE TABLE financial_institutions (id INT, name VARCHAR(50), state VARCHAR(2)); INSERT ...
List the Shariah-compliant financial products offered by financial institutions in Texas, along with their product codes.
SELECT products.name, products.product_code FROM products INNER JOIN financial_institutions ON products.state = financial_institutions.state WHERE products.type = 'Shariah';
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_responses (id INT, incident_id INT, response_time INT, city VARCHAR(255), state VARCHAR(255), county VARCHAR(255)); INSERT INTO emergency_responses (id, incident_id, response_time, city, state, county) VALUES (1, 1, 15, 'Miami', 'Florida', 'Miami-Dade County'); INSERT INTO emergency_responses (id...
What is the maximum response time for any emergency in Miami-Dade County in 2021?
SELECT MAX(response_time) FROM emergency_responses WHERE county = 'Miami-Dade County' AND reported_date >= '2021-01-01' AND reported_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE latinx_founders (company_id INT, founder_id INT, founder_latinx BOOLEAN); INSERT INTO latinx_founders (company_id, founder_id, founder_latinx) VALUES (1, 1, FALSE), (1, 2, TRUE), (2, 1, FALSE), (3, 1, FALSE);
Present founders who identify as Latinx.
SELECT company_id, founder_id FROM latinx_founders WHERE founder_latinx = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), capacity INT); CREATE TABLE daily_orders (restaurant_id INT, order_date DATE, number_of_meals INT); INSERT INTO restaurants (id, name, capacity) VALUES (1, 'Big Burger', 500), (2, 'Sushi House', 300); INSERT INTO daily_orders (restaurant_id, order_date, number_of_mea...
What is the maximum number of meals served by a single restaurant in a day?
SELECT r.name, MAX(do.number_of_meals) FROM restaurants r INNER JOIN daily_orders do ON r.id = do.restaurant_id GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Planting (id INT, year INT, tree_species_id INT); INSERT INTO Planting (id, year, tree_species_id) VALUES (1, 2000, 1), (2, 2000, 2), (3, 2005, 1), (4, 2005, 3); CREATE TABLE TreeSpecies (id INT, name VARCHAR(255)); INSERT INTO TreeSpecies (id, name) VALUES (1, 'Pine'), (2, 'Oak'), (3, 'Maple');
Which tree species were planted in each year?
SELECT p.year, ts.name AS tree_species_name FROM Planting p JOIN TreeSpecies ts ON p.tree_species_id = ts.id;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_test_results (vehicle_id INT, make VARCHAR(50), model VARCHAR(50), safety_rating INT);
What is the average safety rating for vehicles in the 'safety_test_results' table grouped by make?
SELECT make, AVG(safety_rating) FROM safety_test_results GROUP BY make;
gretelai_synthetic_text_to_sql
CREATE TABLE nonprofits (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sector VARCHAR(255)); CREATE TABLE esg_scores (id INT PRIMARY KEY, nonprofit_id INT, environmental_score DECIMAL(3,2), social_score DECIMAL(3,2), governance_score DECIMAL(3,2)); INSERT INTO nonprofits (id, name, location, sector) VAL...
Which nonprofits have the highest ESG scores?
SELECT n.name, AVG(esg_scores.environmental_score) AS avg_environmental_score, AVG(esg_scores.social_score) AS avg_social_score, AVG(esg_scores.governance_score) AS avg_governance_score FROM nonprofits n JOIN esg_scores ON n.id = nonprofit_id GROUP BY n.id ORDER BY AVG(esg_scores.environmental_score + esg_scores.social...
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255), country VARCHAR(255), follows_fair_practices BOOLEAN); INSERT INTO factories (id, name, country, follows_fair_practices) VALUES (1, 'Factory A', 'France', true), (2, 'Factory B', 'Germany', false);
How many factories in France follow fair labor practices?
SELECT COUNT(*) FROM factories WHERE country = 'France' AND follows_fair_practices = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, location VARCHAR(50), quantity INT); INSERT INTO Warehouse (id, location, quantity) VALUES (1, 'USA', 300), (2, 'Canada', 250);
What is the total quantity of items shipped from the USA to Canada?
SELECT SUM(quantity) FROM Warehouse WHERE location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Asian_Forests (species VARCHAR(50)); INSERT INTO Asian_Forests (species) VALUES ('Tiger'), ('Leopard'), ('Elephant'), ('Rhinoceros'), ('Pangolin'), ('Monkey');
How many species of wildlife inhabit 'Asian Forests'?
SELECT COUNT(DISTINCT species) FROM Asian_Forests;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, Ethnicity varchar(50), AmountDonated numeric(10,2)); INSERT INTO Donors (DonorID, Ethnicity, AmountDonated) VALUES (1, 'Asian', 500.00), (2, 'Hispanic', 750.00);
What was the total amount donated by each ethnicity in H1 2021?
SELECT Ethnicity, SUM(AmountDonated) as TotalDonated FROM Donors WHERE AmountDonated >= 0 AND AmountDonated < 9999.99 GROUP BY Ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, Material VARCHAR(50), Sales DECIMAL(5,2)); INSERT INTO Sales (SaleID, Material, Sales) VALUES (1, 'Organic Cotton', 1200.50), (2, 'Hemp', 752.20), (3, 'Recycled Polyester', 986.60), (4, 'Tencel', 310.10);
What is the distribution of sales by ethical material type?
SELECT Material, SUM(Sales) AS TotalSales FROM Sales GROUP BY Material ORDER BY TotalSales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_attendance (visitor_id INT, region VARCHAR(30), event_name VARCHAR(50)); INSERT INTO visitor_attendance (visitor_id, region, event_name) VALUES (1, 'New York', 'Art Festival'), (2, 'Texas', 'Art Exhibition'), (3, 'New York', 'History Day');
What is the average number of community events attended by visitors from a particular region?
SELECT region, AVG(count_events) FROM (SELECT region, event_name, COUNT(event_name) OVER (PARTITION BY visitor_id) as count_events FROM visitor_attendance) as subquery GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Ytterbium_Market_Prices (id INT, year INT, country VARCHAR(255), market_price FLOAT);
What is the maximum market price of Ytterbium in Japan in 2020?
SELECT MAX(market_price) FROM Ytterbium_Market_Prices WHERE year = 2020 AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, city VARCHAR(255), visitors INT); INSERT INTO Exhibitions (id, city, visitors) VALUES (1, 'New York', 2500), (2, 'Los Angeles', 1800), (3, 'Chicago', 2200);
What is the maximum number of visitors who attended an exhibition in Chicago?
SELECT MAX(visitors) FROM Exhibitions WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (id INT PRIMARY KEY, leader VARCHAR(50), region VARCHAR(50)); INSERT INTO military_innovation (id, leader, region) VALUES (1, 'John Smith', 'North America'), (2, 'Sara Ahmed', 'Asia-Pacific');
What is the total number of military innovation projects led by women in the Asia-Pacific region?
SELECT COUNT(*) FROM military_innovation WHERE leader IN (SELECT leader FROM military_innovation WHERE region = 'Asia-Pacific') AND region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Gender VARCHAR(10), Manufacturer VARCHAR(50), MedicalHistory TEXT); INSERT INTO Astronauts VALUES (1, 'John Davis', 'Male', 'SpaceX', 'Minor cold'), (2, 'Emily Johnson', 'Female', 'SpaceX', 'Fractured arm'), (3, 'Michael Brown', 'Male', 'SpaceX', 'Healthy'), (...
Which astronauts have experienced health issues during SpaceX missions?
SELECT Name FROM Astronauts WHERE Manufacturer = 'SpaceX' AND MedicalHistory <> 'Healthy';
gretelai_synthetic_text_to_sql
CREATE TABLE water_infrastructure (id INT, project_name TEXT, location TEXT, cost INT, completion_date DATE); INSERT INTO water_infrastructure (id, project_name, location, cost, completion_date) VALUES (1, 'New York Water Treatment Plant', 'New York', 5000000, '2020-05-15'); INSERT INTO water_infrastructure (id, projec...
What is the average cost of projects in the 'water_infrastructure' table where the 'completion_date' is in 2020?
SELECT AVG(cost) FROM water_infrastructure WHERE YEAR(completion_date) = 2020 AND project_type = 'water';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE employee (id INT, mine_id INT, gender VARCHAR(10), role VARCHAR(20), salary INT, hire_date DATE);
What is the number of employees by mine, gender, and year?
SELECT mine.name, employee.gender, YEAR(employee.hire_date) AS hire_year, COUNT(employee.id) FROM employee JOIN mine ON employee.mine_id = mine.id GROUP BY mine.name, employee.gender, hire_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (ID INT PRIMARY KEY, Gender VARCHAR(10), TotalWorkouts INT, TotalDuration DECIMAL(10,2)); CREATE TABLE Workouts (ID INT PRIMARY KEY, UserID INT, Duration DECIMAL(10,2), Date DATE);
What is the total number of workouts and the total duration of workouts for each user gender in the past month, and what is the percentage of total workouts and total duration for each gender?
SELECT u.Gender, SUM(w.TotalWorkouts) AS TotalWorkouts, SUM(w.TotalDuration) AS TotalDuration, 100.0 * SUM(w.TotalWorkouts) / (SELECT SUM(TotalWorkouts) FROM Users) AS WorkoutsPercentage, 100.0 * SUM(w.TotalDuration) / (SELECT SUM(TotalDuration) FROM Users) AS DurationPercentage FROM Users u JOIN (SELECT UserID, COUNT(...
gretelai_synthetic_text_to_sql
CREATE TABLE Systems (system VARCHAR(50)); CREATE TABLE IncidentLog (system VARCHAR(50), incident_date DATETIME);
How many security incidents were there in the past week for each system in the Systems table, according to the IncidentLog table?
SELECT Systems.system, COUNT(IncidentLog.incident_date) as weekly_incidents FROM Systems INNER JOIN IncidentLog ON Systems.system = IncidentLog.system WHERE IncidentLog.incident_date >= DATEADD(week, -1, GETDATE()) GROUP BY Systems.system;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (UserID INT, Country VARCHAR(255), Devices INT); INSERT INTO Users (UserID, Country, Devices) VALUES (1, 'USA', 3), (2, 'Canada', 2), (3, 'USA', 1);
What is the minimum number of devices owned by users in each country?
SELECT Country, MIN(Devices) FROM Users GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeSkills (EmployeeID INT, Skill VARCHAR(50)); CREATE TABLE JobHistory (EmployeeID INT, JobStartDate DATE); INSERT INTO EmployeeSkills (EmployeeID, Skill) VALUES (1, 'Cybersecurity'), (2, 'Project Management'); INSERT INTO JobHistory (EmployeeID, JobStartDate) VALUES (1, '2020-01-01'), (2, '2019-01-01...
List all job titles with the number of employees who have completed cybersecurity training.
SELECT JobHistory.JobTitle, COUNT(*) AS NumberOfEmployees FROM (EmployeeSkills INNER JOIN JobHistory ON EmployeeSkills.EmployeeID = JobHistory.EmployeeID) INNER JOIN (SELECT DISTINCT EmployeeID, JobTitle FROM EmployeeDemographics) AS EmployeeDemographics ON JobHistory.EmployeeID = EmployeeDemographics.EmployeeID WHERE ...
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, state VARCHAR(50), month VARCHAR(50), strain VARCHAR(50), quantity INT); INSERT INTO sales (id, state, month, strain, quantity) VALUES (1, 'Colorado', 'January', 'Purple Kush', 40), (2, 'Colorado', 'February', 'Northern Lights', 60), (3, 'Colorado', 'March', 'Bubba Kush', 75);
What was the total quantity of indica strains sold in Colorado in the first quarter of 2022?
SELECT SUM(quantity) FROM sales WHERE state = 'Colorado' AND (month = 'January' OR month = 'February' OR month = 'March') AND strain LIKE '%Indica%';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Site A', 'Country X'), (2, 'Site B', 'Country Y'); CREATE TABLE workers (worker_id INT, site_id INT, num_workers INT); INSERT INTO workers (worker_id, site_id, num_workers) VALUES ...
What is the productivity of each mining site, calculated as the ratio of workers to expenditure?
SELECT mining_sites.site_name, num_workers/amount AS productivity FROM mining_sites INNER JOIN (SELECT site_id, SUM(num_workers) AS num_workers, SUM(amount) AS amount FROM workers INNER JOIN expenditure ON workers.site_id = expenditure.site_id GROUP BY site_id) AS subquery ON mining_sites.site_id = subquery.site_id;
gretelai_synthetic_text_to_sql
CREATE TABLE GenreRevenue (Genre VARCHAR(20), Revenue FLOAT); INSERT INTO GenreRevenue (Genre, Revenue) VALUES ('Pop', '5000000'), ('Rock', '4000000'), ('Jazz', '3000000'), ('Hip Hop', '6000000');
What is the total revenue generated by different music genres through digital sales?
SELECT Genre, SUM(Revenue) FROM GenreRevenue GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), total_investment INT, investment_type VARCHAR(255)); INSERT INTO renewable_energy_projects (project_id, project_name, location, total_investment, investment_type) VALUES (1, 'Renewable Energy Project A', 'Californi...
List all renewable energy projects with a total investment over 500000 and their respective investment types
SELECT * FROM renewable_energy_projects WHERE total_investment > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_disability (attorney_id INT, disability_status VARCHAR(20)); CREATE TABLE billing (attorney_id INT, hours DECIMAL(5,2)); CREATE TABLE cases (case_id INT, attorney_id INT);
Identify the total count of cases and total billable hours for attorneys in the 'billing' and 'cases' tables, grouped by attorney disability status.
SELECT d.disability_status, COUNT(c.attorney_id) AS total_cases, SUM(b.hours) AS total_hours FROM attorney_disability d JOIN billing b ON d.attorney_id = b.attorney_id JOIN cases c ON d.attorney_id = c.attorney_id GROUP BY d.disability_status;
gretelai_synthetic_text_to_sql
CREATE TABLE physician (physician_id INT, name TEXT, specialty TEXT, location TEXT);
What is the total number of physicians in rural areas of each state?
SELECT location, COUNT(physician_id) FROM physician WHERE location LIKE '%rural%' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, release_year INT, country VARCHAR(50)); INSERT INTO movies (id, title, rating, release_year, country) VALUES (1, 'Movie1', 7.5, 2010, 'Italy'), (2, 'Movie2', 8.2, 2012, 'Italy'), (3, 'Movie3', 6.8, 2015, 'Italy'), (4, 'Movie4', 8.1, 2011, 'Italy'), (5, 'Mov...
How many movies were produced in Italy each year?
SELECT release_year, COUNT(*) FROM movies WHERE country = 'Italy' GROUP BY release_year;
gretelai_synthetic_text_to_sql
athlete_stats
Create a view for the top 5 goal scorers
CREATE VIEW top_5_goal_scorers AS SELECT athlete_id, games_played, goals_scored, assists, RANK() OVER (ORDER BY goals_scored DESC) as rank FROM athlete_stats;
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, hotel_name TEXT, booking_date DATE); INSERT INTO bookings (id, hotel_name, booking_date) VALUES (1, 'Hotel Ritz', '2022-01-05'), (2, 'Hotel George V', '2022-01-10'), (3, 'Hotel Ritz', '2022-01-15');
How many online bookings were made in 'January' for 'hotels'?
SELECT COUNT(*) FROM bookings WHERE hotel_name = 'Hotel Ritz' AND EXTRACT(MONTH FROM booking_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50)); INSERT INTO animal_population (animal_id, animal_name, program) VALUES (1, 'Grizzly Bear', 'habitat_preservation'), (2, 'Gray Wolf', 'community_education');
Delete the animal with animal_id 2
DELETE FROM animal_population WHERE animal_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, company_id INT, sector VARCHAR(255), year INT, amount FLOAT); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (1, 1, 'Financial Services', 2020, 300000.0); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (2, 2, 'Financial Services', 2020, 400...
What is the maximum investment in a single company in the 'Financial Services' sector in the year 2020?
SELECT MAX(amount) FROM investments WHERE sector = 'Financial Services' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Accounts (AccountID INT, AccountType VARCHAR(20), Balance DECIMAL(10, 2)); INSERT INTO Accounts (AccountID, AccountType, Balance) VALUES (1001, 'Checking', 3000.00), (1002, 'Savings', 5000.00), (1003, 'Checking', 1500.00), (1004, 'Savings', 2000.00);
What is the distribution of account balances for each account type?
SELECT AccountType, COUNT(*), AVG(Balance) AS AverageBalance, MIN(Balance) AS MinBalance, MAX(Balance) AS MaxBalance FROM Accounts GROUP BY AccountType;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, Product TEXT, Price DECIMAL, Origin TEXT); INSERT INTO Products (ProductID, Product, Price, Origin) VALUES (3, 'Cassava', 10, 'Local'); CREATE TABLE Retailers (RetailerID INT, Retailer TEXT, Size TEXT); INSERT INTO Retailers (RetailerID, Retailer, Size) VALUES (2, 'Farmers Market',...
List the total sales of 'Local Products' from 'Medium Retailers'?
SELECT Products.Product, SUM(Sales.Quantity * Products.Price) as TotalSales FROM Sales INNER JOIN Products ON Sales.ProductID = Products.ProductID INNER JOIN Retailers ON Sales.RetailerID = Retailers.RetailerID WHERE Products.Origin = 'Local' AND Retailers.Size = 'Medium' GROUP BY Products.Product;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, material VARCHAR(20), co2_emissions INT); INSERT INTO suppliers (id, material, co2_emissions) VALUES (1, 'cotton', 500), (2, 'silk', 800), (3, 'wool', 300);
What is the total CO2 emissions for each material in the 'suppliers' table?
SELECT material, SUM(co2_emissions) FROM suppliers GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT PRIMARY KEY, region VARCHAR(50), size INT); INSERT INTO customers (customer_id, region, size) VALUES (1, 'Asia-Pacific', 14), (2, 'North America', 12), (3, 'Europe', 16);
How many customers in the Asia-Pacific region have a size 16 or larger?
SELECT COUNT(*) FROM customers WHERE region = 'Asia-Pacific' AND size >= 16;
gretelai_synthetic_text_to_sql
CREATE TABLE Galaxies (id INT, name VARCHAR(255), type VARCHAR(255), right_ascension VARCHAR(255), declination VARCHAR(255), diameter_ly DECIMAL(10,2), distance_Mpc DECIMAL(10,2)); INSERT INTO Galaxies (id, name, type, right_ascension, declination, diameter_ly, distance_Mpc) VALUES (5, 'Large Magellanic Cloud', 'Irregu...
What is the average diameter in light years for irregular galaxies?
SELECT type, AVG(diameter_ly) as avg_diameter_ly FROM Galaxies WHERE type = 'Irregular' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, running_time INT, genre VARCHAR(50)); INSERT INTO movies (id, title, release_year, running_time, genre) VALUES (1, 'Movie1', 2018, 120, 'Action'), (2, 'Movie2', 2019, 150, 'Action'), (3, 'Movie3', 2015, 105, 'Comedy'), (4, 'Movie4', 2021, 135, 'Action')...
What is the average running time of movies in the 'Action' genre produced in the last 5 years?
SELECT AVG(running_time) FROM movies WHERE genre = 'Action' AND release_year >= (SELECT MAX(release_year) - 5 FROM movies);
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id VARCHAR(20), product_name VARCHAR(20), product_type VARCHAR(20)); INSERT INTO products (product_id, product_name, product_type) VALUES ('Organic Apple', 'Fruit', 'Organic'), ('Organic Banana', 'Fruit', 'Organic'); CREATE TABLE sales(product_id VARCHAR(20), store_location VARCHAR(20), sa...
What is the total quantity of organic fruits sold in New York in the last week?
SELECT SUM(quantity) FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.product_type = 'Organic' AND store_location = 'New York' AND sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE News (id INT, topic VARCHAR(50), published_date DATE); INSERT INTO News (id, topic, published_date) VALUES (1, 'Politics', '2022-01-01'); INSERT INTO News (id, topic, published_date) VALUES (2, 'Sports', '2022-01-02'); INSERT INTO News (id, topic, published_date) VALUES (3, 'Entertainment', '2022-01-03'); ...
Find the average number of articles published per day for each unique topic
SELECT topic, AVG(COUNT(*)) as avg_articles_per_day FROM News GROUP BY topic;
gretelai_synthetic_text_to_sql
CREATE TABLE CarbonSequestration (id INT, name VARCHAR(255), region VARCHAR(255), year INT, rate FLOAT); INSERT INTO CarbonSequestration (id, name, region, year, rate) VALUES (1, 'Mangrove Forest', 'Australia', 2010, 5.5);
What is the average carbon sequestration rate for mangrove forests in Australia?
SELECT AVG(rate) FROM CarbonSequestration WHERE name = 'Mangrove Forest' AND region = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Transportation_Infrastructure (id INT, project_name VARCHAR(50), completion_date DATE); INSERT INTO Transportation_Infrastructure (id, project_name, completion_date) VALUES (1, 'Light Rail Extension', '2023-01-01'); INSERT INTO Transportation_Infrastructure (id, project_name, completion_date) VALUES (2, 'B...
What is the name of the first project in the Transportation_Infrastructure table?
SELECT project_name FROM Transportation_Infrastructure LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites(id INT, name TEXT, country TEXT); INSERT INTO heritage_sites(id, name, country) VALUES (1, 'Site A', 'Japan'), (2, 'Site B', 'Japan'), (3, 'Site C', 'South Korea'), (4, 'Site D', 'China');
Insert a new cultural heritage site in Thailand named 'Site E'.
INSERT INTO heritage_sites(name, country) VALUES ('Site E', 'Thailand');
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (year INT, region VARCHAR(50), material VARCHAR(50), volume FLOAT); INSERT INTO WasteGeneration (year, region, material, volume) VALUES (2020, 'North America', 'Plastic', 12000), (2020, 'Europe', 'Plastic', 15000), (2020, 'Asia', 'Plastic', 20000), (2020, 'South America', 'Plastic', 8000), ...
What is the total volume of plastic waste generated in 2020 across all regions?
SELECT SUM(volume) FROM WasteGeneration WHERE year = 2020 AND material = 'Plastic';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2), is_cruelty_free BOOLEAN); INSERT INTO products (id, name, category, price, is_cruelty_free) VALUES (1, 'Nourishing Face Cream', 'Organic', 25.99, true), (2, 'Revitalizing Serum', 'Natural', 34.99, false), (3, 'Soothing Eye Cr...
Delete all cruelty-free certified products
DELETE FROM products WHERE is_cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_types (vehicle_type_id INT, vehicle_type VARCHAR(255)); CREATE TABLE maintenance_requests (request_id INT, vehicle_type_id INT, request_type VARCHAR(255), request_date DATE);
What are the most common types of maintenance requests for each vehicle type?
SELECT vt.vehicle_type, mr.request_type, COUNT(mr.request_id) as num_requests FROM vehicle_types vt INNER JOIN maintenance_requests mr ON vt.vehicle_type_id = mr.vehicle_type_id GROUP BY vt.vehicle_type, mr.request_type ORDER BY num_requests DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityTraining (WorkerID INT, Completed BOOLEAN); INSERT INTO HealthEquityTraining (WorkerID, Completed) VALUES (1, TRUE), (2, FALSE), (3, TRUE);
What is the percentage of community health workers who have completed health equity training?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM CommunityHealthWorkers) AS Percentage FROM HealthEquityTraining WHERE Completed = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE state_departments (dept_id INT, dept_name VARCHAR(50), state VARCHAR(20), year INT, budget INT); INSERT INTO state_departments (dept_id, dept_name, state, year, budget) VALUES (1, 'California Education Department', 'California', 2020, 100000);
Show the total budget for each department in the state of California for the year 2020
SELECT dept_name, SUM(budget) FROM state_departments WHERE state = 'California' AND year = 2020 GROUP BY dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investment_type VARCHAR(255), value DECIMAL(10,2)); INSERT INTO investments (id, investment_type, value) VALUES (1, 'Shariah-compliant', 15000.00), (2, 'Conventional', 20000.00);
What is the total value of Shariah-compliant investments?
SELECT SUM(value) FROM investments WHERE investment_type = 'Shariah-compliant';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255), college VARCHAR(255));CREATE TABLE grant (id INT, department_id INT, title VARCHAR(255), amount DECIMAL(10,2), year INT);
What is the average number of research grants awarded per year to the Department of Computer Science in the College of Engineering?
SELECT AVG(amount) FROM grant g JOIN department d ON g.department_id = d.id WHERE d.name = 'Department of Computer Science' AND d.college = 'College of Engineering' GROUP BY g.year;
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (id INT, member_type VARCHAR(20), monthly_spending DECIMAL(5,2)); INSERT INTO memberships (id, member_type, monthly_spending) VALUES (1, 'Basic', 25.99), (2, 'Premium', 54.99), (3, 'Elite', 89.99);
Which membership types have the highest average monthly spending?
SELECT member_type, AVG(monthly_spending) as avg_spending FROM memberships GROUP BY member_type ORDER BY avg_spending DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, sale_year INT, equipment_type VARCHAR(50), country VARCHAR(50), sale_value FLOAT); INSERT INTO MilitaryEquipmentSales (id, sale_year, equipment_type, country, sale_value) VALUES (1, 2020, 'Aircraft', 'United States', 12000000), (2, 2021, 'Vehicles', 'United State...
Update the sale value of military equipment sales to the United States in 2021 to 10000000.
UPDATE MilitaryEquipmentSales SET sale_value = 10000000 WHERE sale_year = 2021 AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE treatments (treatment_id INT, treatment_type VARCHAR(10), patient_id INT); INSERT INTO treatments (treatment_id, treatment_type, patient_id) VALUES (1, 'medication', 1), (2, 'therapy', 2), (3, 'medication', 3), (4, 'therapy', 4);
What is the total number of patients who received medication-based treatment?
SELECT COUNT(*) FROM treatments WHERE treatment_type = 'medication';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, district VARCHAR(20), mental_health_score INT); INSERT INTO students (student_id, district, mental_health_score) VALUES (1, 'Springfield', 75), (2, 'Springfield', 80), (3, 'Shelbyville', 85);
What is the average mental health score of students in the "Springfield" school district?
SELECT AVG(mental_health_score) FROM students WHERE district = 'Springfield';
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales(id INT, country VARCHAR(255), year INT, value FLOAT); INSERT INTO Military_Equipment_Sales(id, country, year, value) VALUES (1, 'India', 2020, 50000000), (2, 'India', 2019, 45000000), (3, 'US', 2020, 80000000), (4, 'India', 2018, 40000000), (5, 'US', 2019, 75000000), (6, 'China', 2...
How many military equipment sales were made to each country in 2020, ranked by the total value of sales in descending order?
SELECT country, SUM(value) as Total_Value, ROW_NUMBER() OVER (ORDER BY SUM(value) DESC) as Rank FROM Military_Equipment_Sales WHERE year = 2020 GROUP BY country ORDER BY Rank;
gretelai_synthetic_text_to_sql
CREATE SCHEMA CityOfFuture; USE CityOfFuture; CREATE TABLE SmartCityProjects (id INT, project_name VARCHAR(100), cost DECIMAL(10,2)); INSERT INTO SmartCityProjects (id, project_name, cost) VALUES (1, 'Smart Lighting', 50000.00), (2, 'Smart Waste Management', 25000.00);
Find the total cost of all smart city projects in the CityOfFuture schema
SELECT SUM(cost) FROM CityOfFuture.SmartCityProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, budget FLOAT, focus VARCHAR(255)); INSERT INTO projects (id, budget, focus) VALUES (1, 100000.00, 'digital divide'), (2, 150000.00, 'climate change'), (3, 120000.00, 'technology accessibility'), (4, 75000.00, 'healthcare'), (5, 200000.00, 'technology accessibility');
What is the total budget of projects focused on technology accessibility in Europe?
SELECT SUM(budget) FROM projects WHERE focus = 'technology accessibility' AND country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE grant_amounts_max (id INT, student_id INT, amount DECIMAL(10,2)); INSERT INTO grant_amounts_max (id, student_id, amount) VALUES (1, 1, 50000.00), (2, 2, 30000.00), (3, 3, 40000.00);
What is the maximum grant amount awarded to a graduate student?
SELECT MAX(amount) FROM grant_amounts_max;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, state VARCHAR(2), billing_amount DECIMAL(10, 2), outcome VARCHAR(10)); INSERT INTO cases (case_id, state, billing_amount, outcome) VALUES (1, 'CA', 5000.00, 'Favorable'), (2, 'CA', 7000.00, 'Unfavorable'), (3, 'NY', 3000.00, 'Favorable'), (4, 'NY', 4000.00, 'Favorable'), (5, 'TX', 8000....
What is the total billing amount for cases with a favorable outcome, grouped by state?
SELECT state, SUM(billing_amount) FROM cases WHERE outcome = 'Favorable' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Crimes (crime_id INT, crime_type VARCHAR(10), neighborhood VARCHAR(20), date DATE); INSERT INTO Crimes VALUES (1, 'Assault', 'Parkside', '2021-01-01'), (2, 'Murder', 'Parkside', '2021-01-03'), (3, 'Assault', 'Downtown', '2021-01-05'), (4, 'Murder', 'Downtown', '2021-01-07');
Find the top 3 neighborhoods with the most violent crimes in the last year.
SELECT neighborhood, COUNT(*) AS violent_crimes FROM Crimes WHERE crime_type IN ('Assault', 'Murder') AND date >= DATEADD(year, -1, CURRENT_TIMESTAMP) GROUP BY neighborhood ORDER BY violent_crimes DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID int, Name varchar(50), Division varchar(50)); INSERT INTO Customers (CustomerID, Name, Division) VALUES (1, 'John Doe', 'Banking'), (2, 'Jane Smith', 'Investment'), (3, 'Mike Johnson', 'Banking'); CREATE TABLE Accounts (AccountID int, CustomerID int, Balance decimal(10,2)); INSERT INT...
What is the customer balance for each customer who has an account in the 'Banking' division?
SELECT c.Name, SUM(a.Balance) as TotalBalance FROM Customers c INNER JOIN Accounts a ON c.CustomerID = a.CustomerID WHERE c.Division = 'Banking' GROUP BY c.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE EndangeredLanguages (id INT, language VARCHAR(50), status VARCHAR(50), country VARCHAR(50)); INSERT INTO EndangeredLanguages (id, language, status, country) VALUES (1, 'Mapudungun', 'Vulnerable', 'Chile'); INSERT INTO EndangeredLanguages (id, language, status, country) VALUES (2, 'Quechua', 'Vulnerable', '...
What are the endangered languages in South America?
SELECT EndangeredLanguages.language FROM EndangeredLanguages WHERE EndangeredLanguages.status = 'Vulnerable' AND EndangeredLanguages.country IN ('Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador', 'Guyana', 'Paraguay', 'Peru', 'Suriname', 'Uruguay', 'Venezuela');
gretelai_synthetic_text_to_sql
CREATE TABLE SALES_BY_SIZE(city VARCHAR(20), size VARCHAR(5), quantity INT); INSERT INTO SALES_BY_SIZE(city, size, quantity) VALUES('Rio de Janeiro', 'P', 30), ('Rio de Janeiro', 'M', 50), ('Rio de Janeiro', 'G', 20), ('Sao Paulo', 'P', 40), ('Sao Paulo', 'M', 60), ('Sao Paulo', 'G', 35);
What is the most common size of clothing sold in Rio de Janeiro and Sao Paulo?
SELECT size FROM (SELECT size, ROW_NUMBER() OVER (ORDER BY quantity DESC) AS rn FROM (SELECT size, SUM(quantity) AS quantity FROM SALES_BY_SIZE WHERE city IN ('Rio de Janeiro', 'Sao Paulo') GROUP BY size) x) y WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), content TEXT, publication_date DATE, country VARCHAR(50));
Find the total number of articles published in each country from the 'news_articles' table.
SELECT country, COUNT(*) FROM news_articles GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name TEXT, nationality TEXT, birth_year INT, death_year INT); INSERT INTO Artists (id, name, nationality, birth_year, death_year) VALUES (1, 'Pablo Picasso', 'Spanish', 1881, 1973), (2, 'Salvador Dali', 'Spanish', 1904, 1989);
What is the number of artworks created by artists from Spain in the 20th century?
SELECT COUNT(*) FROM Artists WHERE nationality = 'Spanish' AND birth_year <= 1900 AND death_year >= 1900;
gretelai_synthetic_text_to_sql
CREATE TABLE brand_safety_rating (brand_name VARCHAR(100), is_cruelty_free BOOLEAN, safety_rating DECIMAL(3,2)); INSERT INTO brand_safety_rating (brand_name, is_cruelty_free, safety_rating) VALUES ('Lush', true, 4.8), ('The Body Shop', true, 4.6), ('Pacifica', true, 4.9);
Which cruelty-free cosmetic brand has the highest average safety rating?
SELECT brand_name, AVG(safety_rating) as avg_safety_rating FROM brand_safety_rating WHERE is_cruelty_free = true GROUP BY brand_name ORDER BY avg_safety_rating DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (dept_id INT, dept_name TEXT); CREATE TABLE employees (emp_id INT, dept_id INT, hire_date DATE); INSERT INTO departments (dept_id, dept_name) VALUES (1, 'HR'), (2, 'IT'), (3, 'Marketing'), (4, 'Accessibility'); INSERT INTO employees (emp_id, dept_id, hire_date) VALUES (1, 1, '2018-01-01'), (2, ...
Delete all employee records with a hire date before 2020-01-01.
DELETE FROM employees WHERE hire_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE SCHEMA approval;CREATE TABLE approval.drugs (country VARCHAR(20), approval_year INT, num_drugs INT);INSERT INTO approval.drugs (country, approval_year, num_drugs) VALUES ('CountryZ', 2015, 30), ('CountryZ', 2016, 35), ('CountryZ', 2017, 40), ('CountryZ', 2018, 45), ('CountryA', 2015, 25), ('CountryA', 2016, 30),...
How many drugs were approved in 'CountryZ' between 2015 and 2018?
SELECT SUM(num_drugs) FROM approval.drugs WHERE country = 'CountryZ' AND approval_year BETWEEN 2015 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_staff (country VARCHAR(20), center_name VARCHAR(50), num_staff INT); INSERT INTO medical_staff (country, center_name, num_staff) VALUES ('Indonesia', 'Center LL', 10), ('Indonesia', 'Center MM', 15), ('Thailand', 'Center NN', 20), ('Thailand', 'Center OO', 25);
What is the total number of medical staff members in rural health centers in Indonesia and Thailand?
SELECT country, SUM(num_staff) FROM medical_staff GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(255)); INSERT INTO factories VALUES (1, 'Assembly'), (1, 'Quality Control'), (2, 'Design'), (2, 'Testing'); CREATE TABLE workers (worker_id INT, factory_id INT, department VARCHAR(255), role VARCHAR(255)); INSERT INTO workers VALUES (1, 1, 'Assembly', 'Engineer...
What is the total number of workers in the 'Design' department for each factory?
SELECT f.factory_id, COUNT(w.worker_id) as total_workers FROM factories f JOIN workers w ON f.factory_id = w.factory_id WHERE f.department = 'Design' GROUP BY f.factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity_brazil (state VARCHAR(50), year INT, capacity FLOAT); INSERT INTO landfill_capacity_brazil (state, year, capacity) VALUES ('Acre', 2020, 1200000.0), ('Alagoas', 2020, 1500000.0), ('Amapa', 2020, 2000000.0), ('Amazonas', 2020, 1800000.0), ('Bahia', 2020, 1300000.0);
What is the total landfill capacity in cubic meters for each state in Brazil in 2020?
SELECT state, SUM(capacity) FROM landfill_capacity_brazil WHERE year = 2020 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (id INT, name VARCHAR(50), manufacturing_country VARCHAR(50), in_service_date DATE, out_of_service_date DATE); INSERT INTO spacecrafts VALUES (1, 'Shenzhou 5', 'China', '2003-12-15', '2003-12-15'), (2, 'Shenzhou 6', 'China', '2005-10-12', '2005-10-16'), (3, 'Tiangong-1', 'China', '2011-09-29', ...
Which spacecraft has the longest lifespan among Chinese-made spacecrafts?
SELECT name, DATEDIFF(out_of_service_date, in_service_date) as lifespan FROM spacecrafts WHERE manufacturing_country = 'China' ORDER BY lifespan DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE oakland_housing(id INT, type VARCHAR(20), price INT); INSERT INTO oakland_housing VALUES (1, 'affordable', 300000); CREATE TABLE boston_housing(id INT, type VARCHAR(20), price INT); INSERT INTO boston_housing VALUES (1, 'affordable', 400000);
Show the total number of affordable housing units in Oakland and Boston.
SELECT COUNT(*) FROM oakland_housing WHERE type = 'affordable' UNION ALL SELECT COUNT(*) FROM boston_housing WHERE type = 'affordable';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, community_name VARCHAR(255), region VARCHAR(255), year INT); CREATE TABLE community_funding (id INT, community_name VARCHAR(255), funding DECIMAL(10,2));
Get the number of community development initiatives and total funding for each community from the "community_development" and "community_funding" tables
SELECT community_name, COUNT(*), SUM(funding) FROM community_development d JOIN community_funding f ON d.community_name = f.community_name GROUP BY community_name;
gretelai_synthetic_text_to_sql