context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(50), source_id INT, installation_year INT); INSERT INTO renewable_projects (project_id, project_name, source_id, installation_year) VALUES (1, 'Solar Farm A', 1, 2015), (2, 'Wind Farm B', 2, 2018), (3, 'Hydro Plant C', 3, 2012);
How many renewable energy projects were installed each year?
SELECT installation_year, COUNT(*) as num_projects FROM renewable_projects GROUP BY installation_year;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (name VARCHAR(255), birth_year INT, death_year INT);
Insert data into 'artists' table from a CSV file
INSERT INTO artists (name, birth_year, death_year) SELECT * FROM csv_file('artists.csv') AS t(name VARCHAR(255), birth_year INT, death_year INT);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, last_purchase_date DATE); INSERT INTO customers (id, last_purchase_date) VALUES (1, '2022-03-15'), (2, '2022-02-10'), (3, '2022-03-28'); CREATE TABLE purchases (id INT, customer_id INT, store_type VARCHAR(20)); INSERT INTO purchases (id, customer_id, store_type) VALUES (1, 1, 'Circular Economy'), (2, 2, 'Second-Hand'), (3, 3, 'Circular Economy');
How many unique customers made purchases from circular economy stores in the last month?
SELECT COUNT(DISTINCT c.id) FROM customers c JOIN purchases p ON c.id = p.customer_id WHERE p.store_type = 'Circular Economy' AND c.last_purchase_date >= DATEADD(MONTH, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (id, material, year, recycling_rate) VALUES (1, 'plastic', 2017, 0.25), (2, 'plastic', 2018, 0.28), (3, 'plastic', 2019, 0.31), (4, 'paper', 2017, 0.60), (5, 'paper', 2018, 0.63), (6, 'paper', 2019, 0.66), (7, 'glass', 2017, 0.35), (8, 'glass', 2018, 0.37), (9, 'glass', 2019, 0.39), (10, 'metal', 2017, 0.45), (11, 'metal', 2018, 0.47), (12, 'metal', 2019, 0.49);
What is the recycling rate for metal in 2018 and 2019?
SELECT recycling_rate FROM recycling_rates WHERE material = 'metal' AND (year = 2018 OR year = 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city VARCHAR(20), year INT, quantity INT); INSERT INTO waste_generation (city, year, quantity) VALUES ('Sydney', 2019, 150), ('Sydney', 2019, 250);
Calculate the total quantity of waste generated in the city of Sydney in 2019.
SELECT SUM(quantity) AS total_waste_generated FROM waste_generation WHERE city = 'Sydney' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_name TEXT, therapy_area TEXT, country TEXT, year NUMERIC, expenditure NUMERIC); INSERT INTO rd_expenditure (drug_name, therapy_area, country, year, expenditure) VALUES ('Drug1', 'Oncology', 'USA', 2018, 5000000), ('Drug2', 'Oncology', 'UK', 2019, 7000000), ('Drug3', 'Cardiology', 'USA', 2018, 3000000), ('Drug4', 'Oncology', 'UK', 2018, 4000000), ('Drug5', 'Oncology', 'USA', 2019, 6000000);
What is the total R&D expenditure for oncology drugs in the USA and UK in 2018 and 2019?
SELECT country, therapy_area, SUM(expenditure) FROM rd_expenditure WHERE country IN ('USA', 'UK') AND therapy_area = 'Oncology' AND year IN (2018, 2019) GROUP BY country, therapy_area;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50), EnvironmentalImpactScore INT);
List all the mining sites located in California with their respective environmental impact scores.
SELECT SiteName, EnvironmentalImpactScore FROM MiningSites WHERE Location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, HoursPlayed INT, DaysPlayed INT); INSERT INTO Players (PlayerID, HoursPlayed, DaysPlayed) VALUES (1, 50, 25); INSERT INTO Players (PlayerID, HoursPlayed, DaysPlayed) VALUES (2, 100, 50);
Find the average number of hours played per day by players
SELECT AVG(HoursPlayed / DaysPlayed) FROM Players;
gretelai_synthetic_text_to_sql
CREATE TABLE global_tech_users (id INT PRIMARY KEY, user_name VARCHAR(50), country VARCHAR(50), last_login DATETIME);
Show a pivot table of the number of users by country and their last login date in the 'global_tech_users' table
SELECT country, last_login, COUNT(*) as user_count FROM global_tech_users GROUP BY country, last_login ORDER BY last_login;
gretelai_synthetic_text_to_sql
CREATE TABLE language_stats_2 (id INT, city VARCHAR(20), country VARCHAR(10), language VARCHAR(10), num_tourists INT); INSERT INTO language_stats_2 (id, city, country, language, num_tourists) VALUES (1, 'Cape Town', 'South Africa', 'Afrikaans', 25000), (2, 'Cape Town', 'Germany', 'German', 15000), (3, 'Cape Town', 'Netherlands', 'Dutch', 10000);
What percentage of tourists visiting Cape Town speak Afrikaans?
SELECT (SUM(CASE WHEN language = 'Afrikaans' THEN num_tourists ELSE 0 END) * 100.0 / SUM(num_tourists)) AS percentage FROM language_stats_2 WHERE city = 'Cape Town';
gretelai_synthetic_text_to_sql
CREATE TABLE AgricultureSystems (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50)); INSERT INTO AgricultureSystems (id, name, location, type) VALUES (1, 'Urban Vertical Farms', 'Africa', 'Urban Agriculture');
Get the details of the urban agriculture systems in Africa.
SELECT * FROM AgricultureSystems WHERE location = 'Africa' AND type = 'Urban Agriculture';
gretelai_synthetic_text_to_sql
CREATE TABLE process (process_id INT, process_name VARCHAR(50)); CREATE TABLE waste (waste_id INT, process_id INT, waste_amount DECIMAL(5,2)); INSERT INTO process (process_id, process_name) VALUES (1, 'Process 1'), (2, 'Process 2'), (3, 'Process 3'); INSERT INTO waste (waste_id, process_id, waste_amount) VALUES (1, 1, 50), (2, 1, 55), (3, 2, 45), (4, 3, 30), (5, 3, 32);
Find the total waste produced by each manufacturing process, ordered by the highest waste amount.
SELECT process_name, SUM(waste_amount) AS total_waste FROM waste JOIN process ON waste.process_id = process.process_id GROUP BY process_name ORDER BY total_waste DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (Id INT, City VARCHAR(50), Type VARCHAR(50), Cost FLOAT, Year INT); INSERT INTO Infrastructure (Id, City, Type, Cost, Year) VALUES (1, 'New York', 'Bridge', 2000000, 2010); INSERT INTO Infrastructure (Id, City, Type, Cost, Year) VALUES (2, 'Los Angeles', 'Road', 5000000, 2015);
What is the total cost of infrastructure projects in New York and Los Angeles, grouped by project type and year?
SELECT City, Type, SUM(Cost) as Total_Cost, Year FROM Infrastructure GROUP BY City, Type, Year;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10), State VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender, State) VALUES (1, 34, 'Female', 'California'), (2, 42, 'Male', 'Texas'), (3, 50, 'Female', 'California'), (4, 48, 'Non-binary', 'New York');
What is the average age of community health workers by state, ranked by the number of workers?
SELECT State, AVG(Age) as AvgAge FROM (SELECT WorkerID, Age, Gender, State, ROW_NUMBER() OVER(PARTITION BY State ORDER BY Age) as rn FROM CommunityHealthWorkers) tmp WHERE rn = 1 GROUP BY State ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, name VARCHAR(255), country VARCHAR(255), recurring BOOLEAN); CREATE TABLE Donations (donation_id INT, donor_id INT, event_id INT, amount DECIMAL(10, 2));
What is the average donation amount for recurring donors?
SELECT AVG(amount) FROM Donations D JOIN Donors DD ON D.donor_id = DD.donor_id WHERE DD.recurring = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (museum_id INT, museum_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255)); INSERT INTO Museums (museum_id, museum_name, city, country) VALUES (1, 'Museum of Art', 'New York', 'USA'); CREATE TABLE Events (event_id INT, museum_id INT, event_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Events (event_id, museum_id, event_name, start_date, end_date) VALUES (1, 1, 'Art Showcase', '2021-05-01', '2021-05-31'), (2, 1, 'Community Day', '2021-07-04', '2021-07-04');
How many community events were organized by the museum in 2021?
SELECT COUNT(*) FROM Events WHERE museum_id = 1 AND YEAR(start_date) = 2021 AND YEAR(end_date) = 2021 AND event_name LIKE '%community%';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, is_fraudulent BOOLEAN, transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, is_fraudulent, transaction_value) VALUES (1, FALSE, 100.00), (2, TRUE, 500.00), (3, FALSE, 200.00), (4, TRUE, 300.00), (5, FALSE, 150.00);
What is the total number of fraudulent transactions and their total value for the month of July 2021?
SELECT COUNT(transaction_id) as total_fraudulent_transactions, SUM(transaction_value) as total_fraudulent_transaction_value FROM transactions WHERE transaction_date BETWEEN '2021-07-01' AND '2021-07-31' AND is_fraudulent = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (fabric_type VARCHAR(20), month VARCHAR(10), units_produced INT); INSERT INTO production_data (fabric_type, month, units_produced) VALUES ('Eco-friendly', 'August', 5500), ('Regular', 'August', 7500);
How many units of the "Regular" fabric were produced in August 2021?
SELECT SUM(units_produced) FROM production_data WHERE fabric_type = 'Regular' AND month = 'August';
gretelai_synthetic_text_to_sql
CREATE TABLE union_info (id INT, union_affiliation TEXT, collective_bargaining_agreement_expiration DATE); INSERT INTO union_info (id, union_affiliation, collective_bargaining_agreement_expiration) VALUES (1, 'Union A', '2022-12-31'), (2, 'Union B', '2023-06-30'), (3, 'Union C', '2024-01-31');
Update the collective bargaining agreement expiration date for a specific union affiliation.
UPDATE union_info SET collective_bargaining_agreement_expiration = '2025-01-31' WHERE union_affiliation = 'Union A';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(50), location VARCHAR(50), avg_depth FLOAT); INSERT INTO marine_protected_areas (id, name, location, avg_depth) VALUES (1, 'MPA1', 'Pacific Ocean', 3500), (2, 'MPA2', 'Atlantic Ocean', 4200), (3, 'MPA3', 'Indian Ocean', 2700);
What is the maximum depth of any marine protected area in the Atlantic Ocean?
SELECT MAX(avg_depth) FROM marine_protected_areas WHERE location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE physicians (physician_id INT, physician_name VARCHAR, specialty VARCHAR, rural_county VARCHAR, state VARCHAR); INSERT INTO physicians (physician_id, physician_name, specialty, rural_county, state) VALUES (1, 'Dr. Smith', 'Primary Care', 'County A', 'Ohio'); INSERT INTO physicians (physician_id, physician_name, specialty, rural_county, state) VALUES (2, 'Dr. Johnson', 'Primary Care', 'County B', 'Texas'); CREATE TABLE population (county VARCHAR, state VARCHAR, population INT); INSERT INTO population (county, state, population) VALUES ('County A', 'Ohio', 50000); INSERT INTO population (county, state, population) VALUES ('County B', 'Texas', 75000);
What is the number of primary care physicians per 100,000 people in each rural county?
SELECT rural_county, state, COUNT(*) * 100000.0 / (SELECT population FROM population WHERE county = hospitals.rural_county AND state = hospitals.state) AS physicians_per_100k FROM physicians GROUP BY rural_county, state;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (threat_id INT, threat_source VARCHAR(50), threat_level VARCHAR(50), threat_description VARCHAR(50), threat_date DATE);
Insert a new record into the "threat_intelligence" table with a threat_id of 67890, a threat_source of "NATO", a threat_level of "high", a threat_description of "Cyber attack", and a threat_date of '2022-02-15'
INSERT INTO threat_intelligence (threat_id, threat_source, threat_level, threat_description, threat_date) VALUES (67890, 'NATO', 'high', 'Cyber attack', '2022-02-15');
gretelai_synthetic_text_to_sql
CREATE TABLE Property_Value (Property_ID INT, Owner_Disability VARCHAR(10), Property_Value INT); INSERT INTO Property_Value (Property_ID, Owner_Disability, Property_Value) VALUES (1, 'Yes', 1000000), (2, 'No', 800000), (3, 'Yes', 1200000), (4, 'No', 900000);
What is the total value of properties owned by people with disabilities?
SELECT SUM(Property_Value) FROM Property_Value WHERE Owner_Disability = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE extraction_stats (year INT, mine_name TEXT, material TEXT, quantity INT); INSERT INTO extraction_stats (year, mine_name, material, quantity) VALUES (2015, 'Aggromine A', 'Gold', 1200), (2015, 'Aggromine A', 'Silver', 2500), (2016, 'Borax Bravo', 'Boron', 18000), (2016, 'Borax Bravo', 'Copper', 3000), (2017, 'Carbon Cat', 'Coal', 12300), (2017, 'Carbon Cat', 'Diamonds', 250), (2018, 'Diamond Delta', 'Graphite', 1500), (2018, 'Diamond Delta', 'Graphite', 1800), (2019, 'Emerald Echo', 'Emerald', 2000), (2019, 'Emerald Echo', 'Emerald', 2200), (2020, 'Jade Juliet', 'Copper', 4000), (2020, 'Jade Juliet', 'Copper', 4500);
What is the total quantity of copper extracted by the Jade Juliet mine for each year?
SELECT year, mine_name, SUM(quantity) as total_copper_quantity FROM extraction_stats WHERE mine_name = 'Jade Juliet' AND material = 'Copper' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, publication_year INT, topic TEXT, author TEXT); INSERT INTO articles (id, title, publication_year, topic, author) VALUES (1, 'Article1', 2020, 'Climate Change', 'Underrepresented Author1'); INSERT INTO articles (id, title, publication_year, topic, author) VALUES (2, 'Article2', 2019, 'Politics', 'Underrepresented Author2');
How many articles were published in 2020 about climate change by authors from underrepresented communities?
SELECT COUNT(*) FROM articles WHERE publication_year = 2020 AND topic = 'Climate Change' AND author IN (SELECT author FROM authors WHERE underrepresented = true);
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryAircrafts (Country VARCHAR(50), NumberOfAircrafts INT); INSERT INTO MilitaryAircrafts (Country, NumberOfAircrafts) VALUES ('Brazil', 600), ('Argentina', 350), ('Colombia', 250), ('Peru', 150), ('Venezuela', 200);
What is the total number of military aircrafts in South America?
SELECT SUM(NumberOfAircrafts) FROM MilitaryAircrafts WHERE Country IN ('Brazil', 'Argentina', 'Colombia', 'Peru', 'Venezuela');
gretelai_synthetic_text_to_sql
CREATE TABLE labor_partners (product_id INT, category VARCHAR(20), partner_id INT, is_ethical BOOLEAN); INSERT INTO labor_partners (product_id, category, partner_id, is_ethical) VALUES (1, 'home goods', 100, true), (1, 'home goods', 101, false), (2, 'home goods', 102, true);
What is the total number of ethical partners in the 'home goods' category?
SELECT COUNT(*) FROM labor_partners WHERE category = 'home goods' AND is_ethical = true;
gretelai_synthetic_text_to_sql
CREATE VIEW long_description_conditions AS SELECT condition_id, name, description FROM conditions WHERE LENGTH(description) > 200;
Create a view to display all conditions with a description longer than 200 characters
CREATE VIEW long_description_conditions AS SELECT condition_id, name, description FROM conditions WHERE LENGTH(description) > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerEvents (EventID INT, EventName TEXT, Location TEXT, EventType TEXT); INSERT INTO VolunteerEvents (EventID, EventName, Location, EventType) VALUES (1, 'Tutoring Session', 'Texas', 'Education'), (2, 'Coding Workshop', 'New York', 'Education');
How many volunteers participated in educational programs in Texas?
SELECT COUNT(DISTINCT VolunteerID) FROM VolunteerEvents JOIN VolunteerHours ON VolunteerEvents.EventID = VolunteerHours.EventID WHERE VolunteerEvents.Location = 'Texas' AND VolunteerEvents.EventType = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices (date DATE, eu_ets FLOAT, primary key (date)); INSERT INTO carbon_prices (date, eu_ets) VALUES ('2010-01-01', 15), ('2010-01-02', 15.5), ('2011-01-01', 18), ('2011-01-02', 17.5), ('2012-01-01', 16.5), ('2012-01-02', 17);
What is the yearly variation in carbon prices in the European Union Emissions Trading System (EU ETS)?
SELECT date, eu_ets, LAG(eu_ets) OVER (ORDER BY date) as prev_year_price FROM carbon_prices WHERE date BETWEEN '2010-01-01' AND '2012-12-31' ORDER BY date
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (Name TEXT, Age INT, Gender TEXT, Nationality TEXT); INSERT INTO Astronauts (Name, Age, Gender, Nationality) VALUES ('Yuri Ivanov', 50, 'Male', 'Russian'); CREATE TABLE Spacecraft (Name TEXT, Manufacturer TEXT, LaunchDate DATE); INSERT INTO Spacecraft (Name, Manufacturer, LaunchDate) VALUES ('Soyuz-2.1b', 'Roscosmos', '2022-03-18'); CREATE TABLE Mission_Astronauts (Astronaut TEXT, Spacecraft TEXT); INSERT INTO Mission_Astronauts (Astronaut, Spacecraft) VALUES ('Yuri Ivanov', 'Soyuz-2.1b'); CREATE TABLE Research_Data (Astronaut TEXT, Experiment TEXT, Result TEXT); INSERT INTO Research_Data (Astronaut, Experiment, Result) VALUES ('Yuri Ivanov', 'Astrobiology', 'Positive');
Which astronauts are part of a space mission with a manufacturer from Japan or Russia and have conducted astrobiology experiments?
SELECT Astronaut FROM Mission_Astronauts WHERE Manufacturer IN ('JAXA', 'Roscosmos') INTERSECT SELECT Astronaut FROM Research_Data WHERE Experiment = 'Astrobiology';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations2021 (DonationID int, DonorType varchar(50), DonationAmount decimal(10,2), DonorCommunity varchar(50)); INSERT INTO Donations2021 (DonationID, DonorType, DonationAmount, DonorCommunity) VALUES (1, 'Corporation', 500, 'LGBTQ+'); INSERT INTO Donations2021 (DonationID, DonorType, DonationAmount, DonorCommunity) VALUES (2, 'Foundation', 1000, 'None');
What is the minimum donation amount received in 2021 by a donor from the LGBTQ+ community?
SELECT MIN(DonationAmount) FROM Donations2021 WHERE DonorType = 'Individual' AND DonorCommunity = 'LGBTQ+' AND YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE trees (id INT, species VARCHAR(255), carbon_sequestered DECIMAL(10,2), year INT);
What is the total carbon sequestered by each tree species in 2020?
SELECT species, SUM(carbon_sequestered) as total_carbon_sequestered FROM trees WHERE year = 2020 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects_capacity (id INT, project_type VARCHAR(255), project_date DATE, capacity INT);
What is the average renewable energy capacity (in MW) for projects that were completed in the first half of 2019, grouped by project type?
SELECT project_type, AVG(capacity / 1000000) FROM renewable_energy_projects_capacity WHERE project_date BETWEEN '2019-01-01' AND '2019-06-30' GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), HomeRuns INT, BattingAverage DECIMAL(3,2)); INSERT INTO Players (PlayerID, PlayerName, HomeRuns, BattingAverage) VALUES (1, 'Bonds', 762, .302), (2, 'Aaron', 755, .305);
How many baseball players have hit more than 300 home runs and have a batting average above .300?
SELECT COUNT(*) FROM Players WHERE HomeRuns > 300 AND BattingAverage > .300
gretelai_synthetic_text_to_sql
CREATE TABLE ResponseTimes (District TEXT, Quarter INT, ResponseTime FLOAT); INSERT INTO ResponseTimes (District, Quarter, ResponseTime) VALUES ('Downtown', 2, 12.5), ('North Side', 2, 13.7), ('South Side', 2, 14.2), ('West Side', 2, 15.1);
What was the average response time for public service requests in each district of Chicago in Q2 2022?
SELECT AVG(ResponseTime) as AvgResponseTime, District FROM ResponseTimes WHERE Quarter = 2 GROUP BY District;
gretelai_synthetic_text_to_sql
CREATE TABLE rainfall_data (country VARCHAR(20), year INT, avg_rainfall FLOAT); INSERT INTO rainfall_data (country, year, avg_rainfall) VALUES ('Kenya', 2000, 800), ('Kenya', 2001, 810), ('Nigeria', 2000, 1200), ('Nigeria', 2001, 1215);
What is the average annual rainfall change in Kenya and Nigeria since 2000, ranked by the greatest change?
SELECT country, AVG(avg_rainfall) as avg_rainfall_change, ROW_NUMBER() OVER (ORDER BY AVG(avg_rainfall) DESC) as rank FROM rainfall_data WHERE country IN ('Kenya', 'Nigeria') AND year >= 2000 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_assessments (assessment_id INT, assessment_date DATE, country TEXT); INSERT INTO fairness_assessments (assessment_id, assessment_date, country) VALUES (1, '2022-01-02', 'India'), (2, '2022-02-15', 'India'), (3, '2022-03-27', 'India');
What is the average number of algorithmic fairness assessments conducted per month in India in 2022?
SELECT AVG(num_assessments) as avg_assessments_per_month FROM (SELECT COUNT(*) as num_assessments, EXTRACT(MONTH FROM assessment_date) as month FROM fairness_assessments WHERE country = 'India' AND assessment_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_id INT, product_name TEXT, cruelty_free BOOLEAN, price FLOAT); INSERT INTO cosmetics VALUES (1, 'Lipstick A', true, 12.99), (2, 'Foundation B', false, 18.50), (3, 'Mascara C', true, 9.99), (4, 'Eyeshadow D', true, 14.99), (5, 'Blush E', false, 11.99);
What are the top 3 cruelty-free cosmetic products with the highest price?
SELECT product_name, cruelty_free, price FROM cosmetics WHERE cruelty_free = true ORDER BY price DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE praseodymium_production (country VARCHAR(50), year INT, quantity INT); INSERT INTO praseodymium_production (country, year, quantity) VALUES ('China', 2018, 75000), ('United States', 2018, 10000), ('Malaysia', 2018, 8000), ('India', 2018, 5000);
What is the minimum Praseodymium production in 2018?
SELECT MIN(quantity) FROM praseodymium_production WHERE year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(50), type VARCHAR(50), mass FLOAT, orbit VARCHAR(50)); INSERT INTO space_debris (id, name, type, mass, orbit) VALUES (1, 'ISS', 'Space Station', 419000, 'LEO'); INSERT INTO space_debris (id, name, type, mass, orbit) VALUES (2, 'Envisat', 'Satellite', 8212, 'LEO');
What is the total mass of space debris in LEO (Low Earth Orbit)?
SELECT SUM(mass) FROM space_debris WHERE orbit = 'LEO';
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (id INT, restaurant_id INT, inspection_date DATE, score INT); INSERT INTO Inspections (id, restaurant_id, inspection_date, score) VALUES (1, 1, '2021-01-01', 95); INSERT INTO Inspections (id, restaurant_id, inspection_date, score) VALUES (2, 2, '2021-01-02', 85); INSERT INTO Inspections (id, restaurant_id, inspection_date, score) VALUES (3, 3, '2021-01-03', 65);
What is the name and inspection date for the inspections with the lowest scores?
SELECT name, inspection_date, score FROM Inspections i JOIN Restaurants r ON i.restaurant_id = r.id WHERE score = (SELECT MIN(score) FROM Inspections);
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (item_id INT, organic BOOLEAN, quantity INT, order_date DATE); INSERT INTO inventory (item_id, organic, quantity, order_date) VALUES (1, true, 50, '2021-01-01'), (2, false, 100, '2021-01-02');
What is the total quantity of organic ingredients used in the last month?
SELECT SUM(quantity) FROM inventory WHERE organic = true AND order_date BETWEEN '2021-01-01' AND '2021-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(20)); INSERT INTO customers (id, name, region) VALUES (1, 'John Doe', 'Southwest'), (2, 'Jane Smith', 'Northeast'), (3, 'Michael Johnson', 'North America'), (4, 'Sarah Lee', 'North America'), (5, 'Emma Watson', 'Europe'), (6, 'Oliver Twist', 'Europe'), (7, 'Ali Ahmed', 'Middle East'), (8, 'Aisha Al-Fahad', 'Middle East');
How many customers are there in the 'Middle East' region?
SELECT COUNT(*) FROM customers WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityIncidents(id INT PRIMARY KEY, year INT, incidents INT);INSERT INTO CybersecurityIncidents(id, year, incidents) VALUES (1, 2005, 50), (2, 2010, 100), (3, 2015, 150);
What is the earliest year a cybersecurity incident was reported?
SELECT MIN(year) FROM CybersecurityIncidents;
gretelai_synthetic_text_to_sql
CREATE TABLE software (id INT, name VARCHAR(255)); INSERT INTO software (id, name) VALUES (1, 'Product A'), (2, 'Product B'), (3, 'Product C'); CREATE TABLE vulnerabilities (id INT, software_id INT, severity VARCHAR(255)); INSERT INTO vulnerabilities (id, software_id, severity) VALUES (1, 1, 'High'), (2, 1, 'Medium'), (3, 2, 'High'), (4, 2, 'Low'), (5, 3, 'Medium');
List the software products with no high severity vulnerabilities.
SELECT software.name FROM software LEFT JOIN vulnerabilities ON software.id = vulnerabilities.software_id WHERE vulnerabilities.severity IS NULL OR vulnerabilities.severity != 'High';
gretelai_synthetic_text_to_sql
CREATE SCHEMA public;
Create a table for citizen demographics
CREATE TABLE public.citizen_demographics (citizen_id SERIAL PRIMARY KEY, age INT, gender VARCHAR(10), region VARCHAR(50));
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255));
Update the port name for port ID 12 in the "ports" table
WITH updated_port AS (UPDATE ports SET name = 'New Port Name' WHERE id = 12 RETURNING id, name, location) SELECT * FROM updated_port;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (startup_id INT PRIMARY KEY, round_type VARCHAR(255), funding_amount FLOAT);
What is the average funding per round for series B rounds?
SELECT AVG(funding_amount) FROM investment_rounds WHERE round_type = 'series B';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT, status VARCHAR(50));
Insert a new record for a habitat preservation project into the 'habitat' table
INSERT INTO habitat (id, name, location, size, status) VALUES (1, 'Amazon Rainforest Conservation', 'Amazon Rainforest', 6700000.0, 'In Progress');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id int, product_id int, sale_date date, revenue decimal(5,2)); CREATE TABLE products (product_id int, product_name varchar(255), is_recycled boolean, country varchar(50)); INSERT INTO sales (sale_id, product_id, sale_date, revenue) VALUES (1, 1, '2022-01-01', 50.00); INSERT INTO products (product_id, product_name, is_recycled, country) VALUES (1, 'Recycled Tote Bag', true, 'Italy');
What is the daily sales revenue of recycled products in Italy?
SELECT sale_date, SUM(revenue) AS daily_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE is_recycled = true AND country = 'Italy' GROUP BY sale_date;
gretelai_synthetic_text_to_sql
CREATE TABLE unemployment (id INT, region VARCHAR(50), unemployed INT); INSERT INTO unemployment (id, region, unemployed) VALUES (1, 'Region 1', 3000); INSERT INTO unemployment (id, region, unemployed) VALUES (2, 'Region 2', 4000);
How many unemployed people are there in each region of Japan?
SELECT region, unemployed FROM unemployment GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (ShipmentID int, WarehouseID int, ProductName varchar(255), Quantity int, ShippedDate date); INSERT INTO Shipments (ShipmentID, WarehouseID, ProductName, Quantity, ShippedDate) VALUES (11, 1, 'Peaches', 130, '2022-05-25'), (12, 2, 'Plums', 140, '2022-05-26');
What is the total quantity of each product shipped in the last month?
SELECT ProductName, SUM(Quantity) AS TotalQuantity FROM Shipments WHERE ShippedDate BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE() GROUP BY ProductName;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_ticket_sales (ticket_id INT, artist_id INT, venue_id INT, price DECIMAL(10,2), date DATE, city VARCHAR(50), state VARCHAR(50));
What is the total revenue for concert ticket sales in 'concert_ticket_sales' table for artists who have performed in Texas?
SELECT SUM(price) FROM concert_ticket_sales WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock (species VARCHAR(255), turbidity FLOAT); CREATE TABLE ocean_health (species VARCHAR(255), turbidity FLOAT); INSERT INTO fish_stock (species, turbidity) VALUES ('Tilapia', 25.5), ('Salmon', 20.1); INSERT INTO ocean_health (species, turbidity) VALUES ('Tilapia', 24.0), ('Salmon', 19.0);
What is the average water turbidity level for each species, grouped by species, from the 'fish_stock' and 'ocean_health' tables, excluding those with no records in either table?
SELECT f.species, AVG(f.turbidity + o.turbidity)/2 FROM fish_stock f INNER JOIN ocean_health o ON f.species = o.species WHERE f.species IS NOT NULL AND o.species IS NOT NULL GROUP BY f.species;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(20)); INSERT INTO factories VALUES (1, 'textile'), (2, 'metal'), (3, 'textile'), (4, 'renewable energy'); CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2)); INSERT INTO workers VALUES (1, 1, 50000.00), (2, 1, 55000.00), (3, 2, 60000.00), (4, 3, 52000.00), (5, 3, 57000.00);
Update the salary of all workers in the 'textile' department to be $58,000.
UPDATE workers SET salary = 58000.00 WHERE worker_id IN (SELECT worker_id FROM workers INNER JOIN factories ON workers.factory_id = factories.factory_id WHERE factories.department = 'textile');
gretelai_synthetic_text_to_sql
CREATE TABLE company_sales(company_name TEXT, sale_amount INT, sale_quarter INT, sale_year INT); INSERT INTO company_sales(company_name, sale_amount, sale_quarter, sale_year) VALUES('CompanyY', 4000, 3, 2019);
What were the sales figures for 'CompanyY' in Q3 2019?
SELECT SUM(sale_amount) FROM company_sales WHERE company_name = 'CompanyY' AND sale_quarter = 3 AND sale_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistFunding (id INT, artist_name VARCHAR(30), artist_community VARCHAR(30), funding_amount INT, funding_year INT); INSERT INTO ArtistFunding (id, artist_name, artist_community, funding_amount, funding_year) VALUES (1, 'Amy Whispering Wind', 'Indigenous', 4000, 2021), (2, 'Brian Eagle Feather', 'Indigenous', 5000, 2021), (3, 'Chelsea Northern Lights', 'Indigenous', 3000, 2021);
What was the average funding received by Indigenous artists in 2021?
SELECT AVG(funding_amount) as avg_funding FROM ArtistFunding WHERE artist_community = 'Indigenous' AND funding_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_factories (factory_id INT, name TEXT, location TEXT, avg_waste_monthly FLOAT);
What is the total waste produced per month for each factory in the 'ethical_factories' table?
SELECT factory_id, SUM(avg_waste_monthly) as total_waste_monthly FROM ethical_factories GROUP BY factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE trainings (id INT, employee_id INT, training_type VARCHAR(20), training_date DATE, region VARCHAR(20)); INSERT INTO trainings (id, employee_id, training_type, training_date, region) VALUES (1, 1, 'Diversity', '2022-01-10', 'North'), (2, 2, 'Diversity', '2022-01-10', 'South'), (3, 3, 'Diversity', '2022-02-15', 'East'), (4, 4, 'Diversity', '2022-02-15', 'West');
What is the average diversity training attendance by region?
SELECT region, AVG(attendance) as avg_attendance FROM (SELECT region, training_type, COUNT(DISTINCT employee_id) as attendance FROM trainings WHERE training_type = 'Diversity' GROUP BY region, training_type) as diversity_trainings GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, transparency_score DECIMAL(3,2), product_origin VARCHAR(50)); INSERT INTO products (product_id, transparency_score, product_origin) VALUES (1, 8.5, 'Asia'), (2, 9.2, 'Europe'), (3, 7.8, 'Americas'), (4, 6.9, 'Asia'), (5, 9.1, 'Europe');
What is the average transparency score for products made in the Americas?
SELECT AVG(transparency_score) AS avg_score FROM products WHERE product_origin = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation FLOAT, quarter TEXT, year INT); INSERT INTO Donors (id, name, country, donation, quarter, year) VALUES (1, 'Charlie', 'USA', 120.0, 'Q3', 2021), (2, 'David', 'Mexico', 90.0, 'Q3', 2021), (3, 'Eve', 'Canada', 110.0, 'Q3', 2021), (4, 'Frank', 'USA', 130.0, 'Q3', 2021);
What is the minimum donation amount made by donors from each country in Q3 of 2021?
SELECT country, MIN(donation) FROM Donors WHERE quarter = 'Q3' AND year = 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE SportsCars (Id INT, Name VARCHAR(50), Year INT, Horsepower INT); INSERT INTO SportsCars (Id, Name, Year, Horsepower) VALUES (1, 'Corvette', 2016, 460), (2, '911 Turbo', 2017, 540), (3, 'M4 GTS', 2016, 493);
What is the average horsepower of sports cars released after 2015?
SELECT AVG(Horsepower) FROM SportsCars WHERE Year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE accommodations (id INT PRIMARY KEY, name VARCHAR(255), country_id INT, FOREIGN KEY (country_id) REFERENCES countries(id), eco_friendly BOOLEAN);CREATE TABLE descriptions (id INT PRIMARY KEY, accommodation_id INT, FOREIGN KEY (accommodation_id) REFERENCES accommodations(id), text TEXT);CREATE VIEW eco_friendly_accommodations_in_australia AS SELECT a.name, d.text FROM accommodations a JOIN countries c ON a.country_id = c.id JOIN descriptions d ON a.id = d.accommodation_id WHERE c.name = 'Australia' AND a.eco_friendly = true;
What are the names and descriptions of eco-friendly accommodations in Australia?
SELECT name, text FROM eco_friendly_accommodations_in_australia;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title TEXT, publish_date DATE, likes INT);
What is the average number of likes received by articles published in 2020?
SELECT AVG(likes) as avg_likes FROM articles WHERE publish_date >= '2020-01-01' AND publish_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage ( date DATE, usage_category VARCHAR(20), region VARCHAR(20), usage_amount INT ); INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ( '2022-07-01', 'Residential', 'Northeast', 15000), ('2022-07-02', 'Industrial', 'Midwest', 200000), ('2022-07-03', 'Agricultural', 'West', 800000);
Provide the usage_category and usage_amount for the water_usage table where the date is between '2022-07-01' and '2022-07-15'
SELECT usage_category, usage_amount FROM water_usage WHERE date BETWEEN '2022-07-01' AND '2022-07-15';
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, gender VARCHAR(10), company_domain VARCHAR(20)); INSERT INTO founders (id, gender, company_domain) VALUES (1, 'Male', 'Finance'); INSERT INTO founders (id, gender, company_domain) VALUES (2, 'Female', 'Technology');
Find the number of female founders in technology companies
SELECT COUNT(*) FROM founders WHERE gender = 'Female' AND company_domain = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, price DECIMAL(5,2), country TEXT); INSERT INTO products (product_id, product_name, price, country) VALUES (1, 'T-Shirt', 20.99, 'Italy'); INSERT INTO products (product_id, product_name, price, country) VALUES (2, 'Jeans', 50.49, 'France'); INSERT INTO products (product_id, product_name, price, country) VALUES (3, 'Shoes', 75.99, 'Italy'); INSERT INTO products (product_id, product_name, price, country) VALUES (4, 'Hat', 15.99, 'Germany'); INSERT INTO products (product_id, product_name, price, country) VALUES (5, 'Jacket', 100.00, 'Italy');
What is the highest priced product made in each country?
SELECT country, MAX(price) FROM products GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesignLibrary (GameID INT, GameName VARCHAR(20), VRGame BOOLEAN); INSERT INTO GameDesignLibrary VALUES (1, 'CS:GO', FALSE); INSERT INTO GameDesignLibrary VALUES (2, 'VRChat', TRUE); CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Players VALUES (1, 25, 'Male'); INSERT INTO Players VALUES (2, 22, 'Female');
Identify the total number of players, the number of female players, and the number of VR games offered in the game design library.
SELECT COUNT(Players.PlayerID) AS TotalPlayers, SUM(CASE WHEN Players.Gender = 'Female' THEN 1 ELSE 0 END) AS FemalePlayers, SUM(GameDesignLibrary.VRGame) AS VRGames FROM Players CROSS JOIN GameDesignLibrary;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), has_parabens BOOLEAN, country VARCHAR(255)); INSERT INTO products (product_id, product_name, has_parabens, country) VALUES (1, 'Liquid Foundation', true, 'Canada'); INSERT INTO products (product_id, product_name, has_parabens, country) VALUES (2, 'Mascara', false, 'Canada');
Count the number of makeup products that contain parabens and were sold in Canada.
SELECT COUNT(*) FROM products WHERE has_parabens = true AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Genres (GenreID INT, Genre VARCHAR(50)); CREATE TABLE Songs (SongID INT, GenreID INT, SongName VARCHAR(50), Sales INT);
What is the total number of songs for each genre and the total sales for those songs?
SELECT G.Genre, COUNT(DISTINCT S.SongID) as SongCount, SUM(S.Sales) as TotalSales FROM Songs S JOIN Genres G ON S.GenreID = G.GenreID GROUP BY G.Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE SiteTypes (SiteTypeID INT, SiteType VARCHAR(50)); CREATE TABLE HeritageSites (SiteID INT, SiteTypeID INT, CountryID INT, SiteName VARCHAR(50), SiteYear INT); INSERT INTO SiteTypes VALUES (1, 'Historic Building'), (2, 'National Park'), (3, 'Archaeological Site'); INSERT INTO HeritageSites VALUES (1, 1, 1, 'Statue of Liberty', 1886), (2, 2, 1, 'Yellowstone NP', 1872), (3, 3, 2, 'Chichen Itza', 1988), (4, 1, 3, 'Banff NP', 1885);
What is the distribution of heritage sites by type?
SELECT SiteTypes.SiteType, COUNT(HeritageSites.SiteID) AS SiteCount FROM SiteTypes INNER JOIN HeritageSites ON SiteTypes.SiteTypeID = HeritageSites.SiteTypeID GROUP BY SiteTypes.SiteType;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name VARCHAR(100), start_date DATE);
Which carbon_offset_programs were implemented in the last 3 years, ordered by the program id?
SELECT * FROM carbon_offset_programs WHERE start_date >= DATEADD(YEAR, -3, GETDATE()) ORDER BY id;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (id INT, name VARCHAR(50)); CREATE TABLE materials_used (id INT, brand_id INT, material VARCHAR(50), quantity INT); INSERT INTO brands (id, name) VALUES (1, 'Brand A'), (2, 'Brand B'), (3, 'Brand C'); INSERT INTO materials_used (id, brand_id, material, quantity) VALUES (1, 1, 'Organic Cotton', 100), (2, 1, 'Recycled Polyester', 150), (3, 2, 'Organic Cotton', 200), (4, 3, 'Recycled Polyester', 125);
What is the total quantity of materials used in production for each brand?
SELECT b.name, SUM(mu.quantity) as total_quantity FROM brands b INNER JOIN materials_used mu ON b.id = mu.brand_id GROUP BY b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Shipments (ShipmentID INT, WarehouseID INT, Quantity INT, DeliveryTime INT, ExpectedDeliveryTime INT);
What is the total quantity of shipments in each country, with on-time and delayed shipments broken down?
SELECT W.Country, SUM(Quantity) AS TotalQuantity, SUM(CASE WHEN DeliveryTime <= ExpectedDeliveryTime THEN Quantity ELSE 0 END) AS OnTimeQuantity, SUM(CASE WHEN DeliveryTime > ExpectedDeliveryTime THEN Quantity ELSE 0 END) AS DelayedQuantity FROM Warehouses W JOIN Shipments S ON W.WarehouseID = S.WarehouseID GROUP BY W.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE product_ingredients (product_id INT, ingredient VARCHAR(255), percentage FLOAT, PRIMARY KEY (product_id, ingredient));
Create a table that shows the average percentage of natural ingredients in each product
CREATE TABLE avg_natural_ingredients AS SELECT product_id, AVG(percentage) as avg_natural_ingredients FROM product_ingredients WHERE ingredient LIKE 'natural%' GROUP BY product_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); CREATE TABLE Menu (MenuID int, ItemName varchar(50), Category varchar(50)); CREATE TABLE MenuSales (MenuID int, RestaurantID int, QuantitySold int, Revenue decimal(5,2), SaleDate date);
What is the total revenue for each sustainable category, including the total quantity sold, in California during the month of April 2021?'
SELECT C.Category, SUM(M.Revenue) as Revenue, SUM(M.QuantitySold) as QuantitySold FROM Menu M JOIN MenuSales MS ON M.MenuID = MS.MenuID JOIN Restaurants R ON MS.RestaurantID = R.RestaurantID JOIN (SELECT * FROM Restaurants WHERE Location LIKE '%California%') C ON R.RestaurantID = C.RestaurantID WHERE MS.SaleDate >= '2021-04-01' AND MS.SaleDate <= '2021-04-30' GROUP BY C.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT);CREATE TABLE emergencies (id INT, district_id INT, response_time INT, date DATE);
What is the minimum response time for emergency calls in each district in the last month?
SELECT d.name, MIN(e.response_time) FROM districts d JOIN emergencies e ON d.id = e.district_id WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels(id INT, name VARCHAR(100), region VARCHAR(50));CREATE TABLE incidents(id INT, vessel_id INT, incident_date DATE);
List the vessels with the most safety incidents in the Mediterranean Sea in 2020.
SELECT v.name FROM vessels v JOIN (SELECT vessel_id, COUNT(*) AS incident_count FROM incidents WHERE incident_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY vessel_id) i ON v.id = i.vessel_id WHERE v.region = 'Mediterranean Sea' ORDER BY incident_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), total_donations DECIMAL(10,2)); INSERT INTO donors (id, name, total_donations) VALUES (1, 'John Doe', 7000.00); INSERT INTO donors (id, name, total_donations) VALUES (2, 'Jane Smith', 12000.00); INSERT INTO donors (id, name, total_donations) VALUES (3, 'Bob Johnson', 6000.00);
List the names and total donations for donors who have donated more than $5000
SELECT name, total_donations FROM donors WHERE total_donations > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE community_service_sentences (offender_id INT, state VARCHAR(255), hours_served INT); INSERT INTO community_service_sentences (offender_id, state, hours_served) VALUES (1, 'Texas', 50); INSERT INTO community_service_sentences (offender_id, state, hours_served) VALUES (2, 'Florida', 75);
What is the maximum number of hours of community service assigned to offenders who have been sentenced to community service in the state of Texas?
SELECT state, MAX(hours_served) as max_hours_served FROM community_service_sentences WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name TEXT, region TEXT, avg_depth FLOAT); INSERT INTO marine_protected_areas (id, name, region, avg_depth) VALUES (1, 'Galapagos Marine Reserve', 'Pacific', 200.0), (2, 'Great Barrier Reef', 'Pacific', 100.0);
What is the average depth of all marine protected areas in the Pacific Ocean region?
SELECT AVG(avg_depth) FROM marine_protected_areas WHERE region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE SCHEMA fitness; CREATE TABLE participation (member_id INT, activity VARCHAR(20), participation_date DATE); INSERT INTO participation (member_id, activity, participation_date) VALUES (1, 'Running', '2022-07-01'), (1, 'Yoga', '2022-07-02'), (2, 'Swimming', '2022-07-03'), (3, 'Yoga', '2022-07-04'), (1, 'Running', '2022-07-05'), (3, 'Yoga', '2022-07-06');
Identify the members who participated in both Running and Yoga activities in the month of July 2022.
SELECT member_id FROM participation WHERE activity = 'Running' AND participation_date >= '2022-07-01' AND participation_date < '2022-08-01' INTERSECT SELECT member_id FROM participation WHERE activity = 'Yoga' AND participation_date >= '2022-07-01' AND participation_date < '2022-08-01';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_statistics (id INT, community_type VARCHAR(20), statistic_value INT);
Delete a community health statistic record for a specific community type
DELETE FROM community_health_statistics WHERE community_type = 'Suburban';
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (HotelID INT, HotelType VARCHAR(20), Location VARCHAR(20)); INSERT INTO Hotels (HotelID, HotelType, Location) VALUES (1, 'Eco-Friendly', 'Asia'); CREATE TABLE Visitors (VisitorID INT, Nationality VARCHAR(20), HotelID INT, StayLength INT, VisitYear INT); INSERT INTO Visitors (VisitorID, Nationality, HotelID, StayLength, VisitYear) VALUES (1, 'Chinese', 1, 14, 2022), (2, 'Japanese', 1, 21, 2022);
What is the average length of stay in weeks for visitors from Asia who visited eco-friendly hotels in 2022?
SELECT AVG(StayLength/7.0) FROM Visitors WHERE Nationality IN ('Chinese', 'Japanese') AND HotelID = 1 AND VisitYear = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE libraries (library_id INT, county_id INT, library_name TEXT);CREATE TABLE counties (county_id INT, county_name TEXT);
Show the number of public libraries in each county, ordered by the number of libraries in descending order
SELECT c.county_name, COUNT(l.library_id) FROM libraries l INNER JOIN counties c ON l.county_id = c.county_id GROUP BY c.county_name ORDER BY COUNT(l.library_id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50), birth_date DATE, country VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name, birth_date, country) VALUES (1, 'Clara Peeters', '1594-01-15', 'Netherlands'); ; CREATE TABLE Artworks (artwork_id INT, title VARCHAR(50), year_made INT, artist_id INT, price FLOAT); INSERT INTO Artworks (artwork_id, title, year_made, artist_id, price) VALUES (1, 'Still Life with Flowers', 1612, 1, 1000.0); ;
What is the maximum price of artworks created by Mexican artists?
SELECT MAX(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id WHERE Artists.country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE Locations (id INT, country VARCHAR(255), region VARCHAR(255), impact_category VARCHAR(255));
List all 'impact_categories' associated with 'WaterAccess' in the 'Locations' table.
SELECT DISTINCT impact_category FROM Locations WHERE country = 'WaterAccess';
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_games (id INT, team_id INT, game_date DATE, is_home BOOLEAN); INSERT INTO baseball_games (id, team_id, game_date, is_home) VALUES (1, 1, '2021-04-01', true), (2, 2, '2021-04-05', false), (3, 1, '2021-05-03', true);
Show the number of home games each baseball team has played
SELECT team_id, COUNT(*) as home_games_played FROM baseball_games WHERE is_home = true GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Trees (id INT, species VARCHAR(255), age INT); INSERT INTO Trees (id, species, age) VALUES (1, 'Oak', 50), (2, 'Pine', 30), (3, 'Maple', 40), (4, 'Oak', 45), (5, 'Pine', 35), (6, 'Birch', 25);
List all the tree species in the Trees table that have more than 3 trees.
SELECT species FROM Trees GROUP BY species HAVING COUNT(*) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO Players (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Pedro Alvarez', 'Mexico');
Count the number of players from each country
SELECT country, COUNT(*) FROM Players GROUP BY country;
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 male and female readers in a specific age range?
SELECT gender, COUNT(*) as count FROM readers WHERE age BETWEEN 18 AND 30 GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE AffordableHousing (id INT, state VARCHAR(20), size FLOAT);
List all affordable housing units in the state of New York that have a size less than 1000 square feet.
SELECT * FROM AffordableHousing WHERE state = 'New York' AND size < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE education_projects (project VARCHAR(50), budget INT); INSERT INTO education_projects (project, budget) VALUES ('School Construction', 3000000); INSERT INTO education_projects (project, budget) VALUES ('Curriculum Development', 1500000); INSERT INTO education_projects (project, budget) VALUES ('Teacher Training', 2000000);
What is the total budget for education projects in the 'education_projects' table?
SELECT SUM(budget) FROM education_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (title VARCHAR(255), year INT, citations INT, domain VARCHAR(255)); INSERT INTO research_papers (title, year, citations, domain) VALUES ('Paper1', 2018, 50, 'AI Safety'); INSERT INTO research_papers (title, year, citations, domain) VALUES ('Paper2', 2019, 75, 'AI Safety');
Which AI safety research papers were published before 2020, ordered by the number of citations?
SELECT title, year, citations FROM research_papers WHERE year < 2020 AND domain = 'AI Safety' ORDER BY citations DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (machine_id INT, plant VARCHAR(10), category VARCHAR(10)); INSERT INTO machines (machine_id, plant, category) VALUES (1, 'plant1', 'molding'), (2, 'plant2', 'tooling'), (3, 'plant1', 'tooling'), (4, 'plant3', 'molding');
List all plants that have machines in the 'tooling' category.
SELECT plant FROM machines WHERE category = 'tooling';
gretelai_synthetic_text_to_sql
CREATE TABLE legal_technology_projects (id INT, project_name VARCHAR(50), budget INT);
What is the maximum budget for a legal technology project?
SELECT MAX(budget) FROM legal_technology_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (machine_id INT, division TEXT, machine_type TEXT, next_maintenance_date DATE); INSERT INTO machines VALUES (1, 'Recycling', 'Shredder', '2023-02-15'), (2, 'Manufacturing', 'Molder', '2023-03-20'), (3, 'Recycling', 'Grinder', '2023-04-05');
List the machine types and their maintenance schedules for machines in the recycling division.
SELECT machine_type, next_maintenance_date FROM machines WHERE division = 'Recycling';
gretelai_synthetic_text_to_sql
CREATE TABLE scooter_sharing (id INT, trip_id INT, start_time TIMESTAMP, end_time TIMESTAMP, start_station TEXT, end_station TEXT, trip_distance FLOAT);
What is the maximum trip distance for scooter-sharing in Madrid?
SELECT MAX(trip_distance) FROM scooter_sharing WHERE start_station = 'Madrid';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_vulnerabilities (id INT, severity VARCHAR(255), department VARCHAR(255));
List all cybersecurity vulnerabilities in the 'cybersecurity_vulnerabilities' table along with their corresponding severity level and department responsible, sorted by the severity level in ascending order.
SELECT severity, department FROM cybersecurity_vulnerabilities ORDER BY severity ASC;
gretelai_synthetic_text_to_sql