context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE hospitals (name VARCHAR(255), type VARCHAR(255), region VARCHAR(255)); INSERT INTO hospitals (name, type, region) VALUES ('Hospital A', 'Public', 'West'), ('Hospital B', 'Private', 'West'), ('Hospital C', 'Teaching', 'West'), ('Hospital D', 'Public', 'East'), ('Hospital E', 'Private', 'East');
What is the percentage of hospitals that are public in the West region?
SELECT 100.0 * COUNT(*) FILTER (WHERE type = 'Public') / COUNT(*) FROM hospitals WHERE region = 'West';
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyID INT, PolicyholderID INT, Product VARCHAR(10), UpdateDate DATE); INSERT INTO Policy (PolicyID, PolicyholderID, Product, UpdateDate) VALUES (1, 1, 'Auto', '2020-05-05'), (2, 2, 'Home', '2021-01-01'), (3, 3, 'Auto', '2019-09-09'), (4, 4, 'Home', '2022-04-04');
Delete policies that have not been updated in the last 2 years.
DELETE FROM Policy WHERE UpdateDate < DATEADD(YEAR, -2, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE workers (worker_id INT, name TEXT, trained_in TEXT); INSERT INTO workers (worker_id, name, trained_in) VALUES (1, 'James Smith', 'Industry 4.0'), (2, 'Emily Johnson', 'ERP'), (3, 'Robert Brown', 'AI'), (4, 'Jessica Davis', 'Circular Economy'); CREATE TABLE trainings (training_id INT, worker_id INT, trainin...
List all workers who have been trained in Industry 4.0 technologies and their corresponding training dates and locations.
SELECT w.name, t.training_date, t.location FROM workers w INNER JOIN trainings t ON w.worker_id = t.worker_id WHERE w.trained_in = 'Industry 4.0';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); CREATE TABLE DonationEvents (EventID INT PRIMARY KEY, EventName VARCHAR(100), EventType VARCHAR(100), DonationID INT, FOREIGN KEY (DonationID) REFERENCES Donors(DonorID)); CREATE ...
What is the total donation amount for 'Awareness' events organized by 'Greenpeace' and 'World Wildlife Fund'?
SELECT SUM(DonationAmount) as TotalDonationAmount FROM Donors d JOIN DonationEvents e ON d.DonorID = e.DonationID JOIN Organizations o ON d.DonorID = o.VolunteerID WHERE e.EventType = 'Awareness' AND o.OrganizationName IN ('Greenpeace', 'World Wildlife Fund');
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT PRIMARY KEY, operation_name VARCHAR(50), start_date DATE, end_date DATE, participating_countries INT);
Insert a new record into the 'peacekeeping_operations' table for 'Operation Restore Hope' with 9 participating countries
INSERT INTO peacekeeping_operations (operation_id, operation_name, start_date, end_date, participating_countries) VALUES (1, 'Operation Restore Hope', '1992-12-03', '1993-05-04', 9);
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales(id INT, year INT, country TEXT, value FLOAT);INSERT INTO military_sales(id, year, country, value) VALUES (1, 2019, 'USA', 20000000);
Delete all military sales records for 2019
DELETE FROM military_sales WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Public_Works (Project_ID INT, Project_Name VARCHAR(255), Cost FLOAT, Year INT, Location VARCHAR(255));
What is the minimum cost of public works projects in the Pacific Northwest for the year 2021?
SELECT Year, MIN(Cost) FROM Public_Works WHERE Location LIKE '%Pacific Northwest%' AND Year = 2021 GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE OceaniaSites (id INT, site VARCHAR(50), continent VARCHAR(50), added_date DATE); INSERT INTO OceaniaSites (id, site, continent, added_date) VALUES (1, 'Great Barrier Reef', 'Oceania', '2022-06-15'), (2, 'Sydney Opera House', 'Oceania', '2022-07-22'), (3, 'Uluru', 'Oceania', '2022-08-01');
How many heritage sites in Oceania have been added to the database in the last 3 months?
SELECT COUNT(*) FROM OceaniaSites WHERE continent = 'Oceania' AND added_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE forestry (id INT, name VARCHAR(50), carbon_sequestration_id INT, PRIMARY KEY (id), FOREIGN KEY (carbon_sequestration_id) REFERENCES carbon_sequestration(id));
Delete records with no carbon sequestration data.
DELETE FROM forestry WHERE carbon_sequestration_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, usage FLOAT, purpose VARCHAR(20), date DATE); INSERT INTO water_usage (id, usage, purpose, date) VALUES (1, 0, 'industrial', '2021-10-01'); INSERT INTO water_usage (id, usage, purpose, date) VALUES (2, 150, 'residential', '2021-10-01');
Find the number of days in 'October 2021' with zero water usage for 'industrial' purposes in the 'water_usage' table
SELECT COUNT(*) FROM (SELECT date FROM water_usage WHERE purpose = 'industrial' AND usage = 0 AND date BETWEEN '2021-10-01' AND '2021-10-31' GROUP BY date HAVING COUNT(*) = 1) as zero_days;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (id INT, category TEXT, region TEXT); INSERT INTO dapps (id, category, region) VALUES (1, 'Finance', 'Global');
What is the total number of decentralized applications in the finance category worldwide?
SELECT COUNT(*) FROM dapps WHERE category = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (restaurant_id INT, inspection_date DATE); INSERT INTO Inspections (restaurant_id, inspection_date) VALUES (5, '2020-01-01'), (5, '2020-02-01');
How many food safety inspections were conducted for 'Green Garden' in 2020?
SELECT COUNT(*) FROM Inspections WHERE restaurant_id = 5 AND EXTRACT(YEAR FROM inspection_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, category VARCHAR(255), subcategory VARCHAR(255), gender VARCHAR(50), material VARCHAR(50), price DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO garments (id, category, subcategory, gender, material, price, country) VALUES (1, 'Tops', 'T-Shirts', 'Unisex', 'Tencel', 29.99, 'South Korea'...
Find the average retail price of unisex garments made from Tencel in South Korea.
SELECT AVG(price) FROM garments WHERE gender = 'Unisex' AND material = 'Tencel' AND country = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, location TEXT, revenue FLOAT, date DATE); INSERT INTO virtual_tours (tour_id, location, revenue, date) VALUES (1, 'London Eye', 50000, '2021-10-01'), (2, 'Stonehenge', 40000, '2021-11-01');
What is the total revenue generated by virtual tours in the United Kingdom last year?
SELECT SUM(revenue) FROM virtual_tours WHERE location = 'United Kingdom' AND date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE crime_incidents (incident_id INT, did INT, incident_type VARCHAR(255), incident_date DATE); INSERT INTO crime_incidents (incident_id, did, incident_type, incident_date) VALUES (1, 1, 'Theft', '2022-01-01'), (2, 2, 'Vandalism', '2022-01-02'), (3, 3, 'Assault', '2022-01-03'), (4, 1, 'Minor Traffic Violation'...
Delete records of crime incidents with an 'incident_type' of 'Minor Traffic Violation'
DELETE FROM crime_incidents WHERE incident_type = 'Minor Traffic Violation';
gretelai_synthetic_text_to_sql
CREATE TABLE eu_ets_data (date DATE, price FLOAT); INSERT INTO eu_ets_data (date, price) VALUES ('2022-01-01', 30.0), ('2022-01-02', 31.0), ('2022-01-03', 32.0);
Identify the carbon price (€/tCO2) in the EU ETS for the past 3 months?
SELECT price FROM eu_ets_data WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_id INT, country VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, donor_id, country, amount, donation_date) VALUES (1, 1001, 'USA', 200.00, '2023-01-05'); INSERT INTO Donations (id, donor_id, country, amount, donation_date) VALUES (2, 1002, 'Canada...
Identify the top 3 countries with the highest total donation amount in Q1 2023.
SELECT country, SUM(amount) as total_donation FROM Donations WHERE donation_date >= '2023-01-01' AND donation_date < '2023-04-01' GROUP BY country ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trial (trial_id INT, drug_name TEXT, trial_region TEXT, trial_outcome TEXT, trial_date DATE);
Insert a new clinical trial record for a specific drug and region with a given outcome and date.
INSERT INTO clinical_trial (trial_id, drug_name, trial_region, trial_outcome, trial_date) VALUES (4, 'DrugD', 'Asia', 'successful', '2022-03-25');
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_applications (id INT, name VARCHAR(255), developer VARCHAR(255), transaction_volume DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO decentralized_applications (id, name, developer, transaction_volume, country) VALUES (1, 'App 1', 'Dev 1', 5000.00, 'Brazil'), (2, 'App 2', 'Dev 2', 7000.00, ...
Who are the developers of the top 3 decentralized applications by transaction volume in South America?
SELECT developer, SUM(transaction_volume) FROM decentralized_applications WHERE country IN ('Brazil', 'Argentina', 'Colombia', 'Chile', 'Peru') GROUP BY developer ORDER BY SUM(transaction_volume) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name VARCHAR(50), funding_org VARCHAR(50), org_location VARCHAR(50)); INSERT INTO community_development (id, initiative_name, funding_org, org_location) VALUES (1, 'Youth Empowerment Program', 'LocalAid', 'USA'), (2, 'Renewable Energy Workshops', 'GreenAsia', 'Chin...
List the unique community development initiatives from the 'community_development' table that have not received any funding from organizations based in Asia?
SELECT initiative_name FROM community_development WHERE initiative_name NOT IN (SELECT initiative_name FROM community_development WHERE org_location LIKE '%Asia%');
gretelai_synthetic_text_to_sql
CREATE TABLE site_capacity (site VARCHAR(20), state VARCHAR(20), capacity INT); INSERT INTO site_capacity (site, state, capacity) VALUES ('SiteA', 'NSW', 2000), ('SiteB', 'QLD', 1500), ('SiteC', 'NSW', 2500);
What is the maximum production capacity for each site in NSW?
SELECT site, MAX(capacity) FROM site_capacity WHERE state = 'NSW' GROUP BY site;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), population INT, conservation_status VARCHAR(255));
Create a table named "marine_mammals"
CREATE TABLE marine_mammals (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), population INT, conservation_status VARCHAR(255));
gretelai_synthetic_text_to_sql
CREATE TABLE RetailSales (id INT, garment_type VARCHAR(20), sustainable BOOLEAN, country VARCHAR(20), revenue DECIMAL(10, 2), year INT); INSERT INTO RetailSales (id, garment_type, sustainable, country, revenue, year) VALUES (1, 'Dress', TRUE, 'South Korea', 75.50, 2021), (2, 'Shirt', FALSE, 'South Korea', 120.00, 2021)...
Find the minimum retail sales revenue for any sustainable garment type in South Korea in 2021.
SELECT MIN(revenue) as min_revenue FROM RetailSales WHERE sustainable = TRUE AND country = 'South Korea' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE NationalSecurity (Id INT PRIMARY KEY, Country VARCHAR(50), Budget INT);
Reveal national security budgets larger than the average budget
SELECT Country FROM NationalSecurity WHERE Budget > (SELECT AVG(Budget) FROM NationalSecurity);
gretelai_synthetic_text_to_sql
CREATE TABLE station_counts (region VARCHAR(10), num_stations INT, num_buses INT); INSERT INTO station_counts (region, num_stations, num_buses) VALUES ('east', 10, 50), ('west', 12, 60), ('north', 15, 75), ('south', 8, 40);
What is the maximum number of buses per station in the 'south' region?
SELECT MAX(num_buses/num_stations) FROM station_counts WHERE region = 'south';
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, state VARCHAR(20), type VARCHAR(20), hours INT); INSERT INTO project (id, state, type, hours) VALUES (1, 'Texas', 'Sustainable', 400), (2, 'Texas', 'Traditional', 300), (3, 'Seattle', 'Sustainable', 500), (4, 'California', 'Traditional', 200);
What is the minimum labor hours for any traditional building project in the state of California?
SELECT MIN(hours) FROM project WHERE state = 'California' AND type = 'Traditional';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (id INT, species TEXT, dissolved_oxygen_tolerance FLOAT);CREATE TABLE temperature_readings (id INT, species TEXT, date DATE, temperature FLOAT, dissolved_oxygen FLOAT);
What is the average temperature and dissolved oxygen level for each species of fish in the aquaculture facility?
SELECT species, AVG(temperature) AS avg_temperature, AVG(dissolved_oxygen) AS avg_dissolved_oxygen FROM temperature_readings tr JOIN fish_species fs ON tr.species = fs.species GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(50), location VARCHAR(50), production_count INT); INSERT INTO factories (id, name, location, production_count) VALUES (1, 'Factory A', 'Europe', 1500), (2, 'Factory B', 'Europe', 800), (3, 'Factory C', 'Asia', 1800);
Which factories in Europe have a production count greater than 1000?
SELECT name FROM factories WHERE location = 'Europe' AND production_count > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE donation (donation_id INT, donor_id INT, org_id INT, program_id INT, amount DECIMAL(10,2)); INSERT INTO donation (donation_id, donor_id, org_id, program_id, amount) VALUES (1, 1001, 1, 101, 5000.00), (2, 1001, 1, 102, 7500.00), (3, 1002, 2, 201, 1000.00), (4, 1002, 2, 202, 2000.00), (5, 1003, 3, 301, 3000....
Which programs received the most funding from donors?
SELECT program.program_name, SUM(donation.amount) as total_funding FROM donation JOIN program ON donation.program_id = program.program_id GROUP BY program.program_name ORDER BY total_funding DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, country TEXT); INSERT INTO artists (id, name, country) VALUES (1, 'Ed Sheeran', 'United Kingdom'); CREATE TABLE concerts (id INT, artist_id INT, location TEXT); INSERT INTO concerts (id, artist_id, location) VALUES (1, 1, 'Paris, France');
Find the artist with the most concerts in Europe.
SELECT artists.name FROM artists JOIN concerts ON artists.id = concerts.artist_id WHERE location LIKE '%Europe%' GROUP BY artists.name ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_outcomes (id INT, patient_id INT, outcome VARCHAR(20), age INT); INSERT INTO patient_outcomes (id, patient_id, outcome, age) VALUES (1, 1, 'Improved', 30), (2, 2, 'Unchanged', 45), (3, 3, 'Deteriorated', 25), (4, 4, 'Improved', 50), (5, 5, 'Improved', 35);
What is the distribution of patient outcomes in Toronto, partitioned by age group?
SELECT age_group, AVG(outcome = 'Improved') * 100 AS improved, AVG(outcome = 'Unchanged') * 100 AS unchanged, AVG(outcome = 'Deteriorated') * 100 AS deteriorated FROM (SELECT patient_outcomes.*, (age - 18) / 10 * 10 AS age_group FROM patient_outcomes WHERE city = 'Toronto') t GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategies (company_name VARCHAR(255), exit_year INT, exit_type VARCHAR(50));
Update the exit type for "Beta Inc" to "Acquisition" in the "exit_strategies" table
UPDATE exit_strategies SET exit_type = 'Acquisition' WHERE company_name = 'Beta Inc';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, degree VARCHAR(255)); INSERT INTO attorneys (id, degree) VALUES (1, 'JD'), (2, 'LLM'), (3, 'JD'), (4, 'BA'); CREATE TABLE cases (id INT, attorney_id INT); INSERT INTO cases (id, attorney_id) VALUES (1, 1), (2, 1), (3, 3), (4, 4), (5, 2);
What is the total number of cases handled by attorneys with a 'JD' degree?
SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.degree = 'JD';
gretelai_synthetic_text_to_sql
CREATE TABLE neodymium_production (year INT, production_volume INT); INSERT INTO neodymium_production VALUES (2015, 110), (2016, 120), (2017, 130), (2018, 140), (2019, 150);
What was the total production volume of Neodymium in 2018?
SELECT SUM(production_volume) FROM neodymium_production WHERE year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans (bank_name VARCHAR(255), loan_amount DECIMAL(10,2), loan_date DATE);
What is the total amount of socially responsible loans issued by each bank?
SELECT bank_name, SUM(loan_amount) FROM socially_responsible_loans GROUP BY bank_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sector (id INT, name VARCHAR(255)); CREATE TABLE project (id INT, sector_id INT, budget DECIMAL(10, 2)); INSERT INTO sector (id, name) VALUES (1, 'healthcare'); INSERT INTO project (id, sector_id, budget) VALUES (1, 1, 5000), (2, 1, 7000), (3, 1, 3000);
What is the total budget for all projects in the 'healthcare' sector?
SELECT sector_id, SUM(budget) as total_budget FROM project WHERE sector_id = (SELECT id FROM sector WHERE name = 'healthcare') GROUP BY sector_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (ID INT, CaseNumber INT, DateOpened DATE, DateClosed DATE, Resolution VARCHAR(255)); INSERT INTO Cases (ID, CaseNumber, DateOpened, DateClosed, Resolution) VALUES (1, 12345, '2022-01-01', '2022-03-15', 'Community Service'), (2, 67890, '2022-02-15', '2022-04-30', 'Fine'), (3, 111213, '2022-03-28', NUL...
What is the average time taken for case resolution through community service in the past 6 months?
SELECT AVG(DATEDIFF(DateClosed, DateOpened)) as AvgTimeToResolve FROM Cases WHERE Resolution = 'Community Service' AND DateClosed IS NOT NULL AND DateOpened >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_healthcare (name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO rural_healthcare (name, type, location) VALUES ('Rural General Hospital', 'Hospital', 'Bushland'), ('Rural Community Hospital', 'Hospital', 'Forest Region');
Update the location of 'Rural General Hospital' to 'Mountain Region'
UPDATE rural_healthcare SET location = 'Mountain Region' WHERE name = 'Rural General Hospital' AND type = 'Hospital';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, city TEXT, country TEXT, funding FLOAT); INSERT INTO startups (id, name, city, country, funding) VALUES (1, 'Genetech', 'San Francisco', 'USA', 50000000); INSERT INTO startups (id, name, city, country, funding) VALUES (2, 'BioSteward', 'Boston', 'USA', 75000000);
What is the total funding received by biotech startups located in the US, grouped by their city?
SELECT city, SUM(funding) FROM startups WHERE country = 'USA' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE species_per_region (region_id INT, species_count INT); INSERT INTO species_per_region (region_id, species_count) VALUES (1, 3), (2, 2), (3, 1);
List marine research stations and the number of marine species in their region
SELECT r.station_name, sp.species_count FROM research_stations r JOIN species_per_region sp ON r.region_id = sp.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); INSERT INTO Restaurants (RestaurantID, Name, Location) VALUES (1, 'Organic Bites', 'California'); CREATE TABLE Meals (MealID int, Name varchar(50), Type varchar(20), Calories int); INSERT INTO Meals (MealID, Name, Type, Calories) VALUE...
What is the average calorie count for organic meals served in restaurants located in California?
SELECT AVG(Meals.Calories) FROM Meals INNER JOIN Restaurants ON Meals.Name = Restaurants.Name WHERE Restaurants.Location = 'California' AND Meals.Type = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE Airports (id INT, name TEXT, state TEXT, passengers INT); INSERT INTO Airports (id, name, state, passengers) VALUES (1, 'Miami International Airport', 'Florida', 22000000); INSERT INTO Airports (id, name, state, passengers) VALUES (2, 'Orlando International Airport', 'Florida', 4400000);
How many airports are there in the state of Florida that have more than 10,000 passengers per year?
SELECT COUNT(*) FROM Airports WHERE state = 'Florida' AND passengers > 10000
gretelai_synthetic_text_to_sql
CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50)); INSERT INTO Species (id, name, type) VALUES (1, 'Tuna', 'Fish'); INSERT INTO Species (id, name, type) VALUES (2, 'Krill', 'Crustacean'); CREATE TABLE Observations (id INT PRIMARY KEY, species_id INT, location VARCHAR(50), weight REAL); INS...
Delete records of species with a weight greater than 10 in the Arctic Ocean.
DELETE O FROM Observations O JOIN Species S ON O.species_id = S.id WHERE S.name = 'Tuna' AND O.location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(50), state VARCHAR(20));
Insert a new mining site named 'Site X' located in 'Nevada' into the 'mining_sites' table.
INSERT INTO mining_sites (site_name, state) VALUES ('Site X', 'Nevada');
gretelai_synthetic_text_to_sql
CREATE TABLE wind_projects (project_id INT, project_name TEXT, country TEXT, capacity_mw FLOAT); INSERT INTO wind_projects (project_id, project_name, country, capacity_mw) VALUES (1, 'Wind Farm 1', 'USA', 50.0), (2, 'Wind Farm 2', 'Canada', 100.0), (3, 'Wind Farm 3', 'Mexico', 75.0);
What is the total installed capacity (in MW) of wind power projects in each country?
SELECT country, SUM(capacity_mw) FROM wind_projects GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (UserID INT, UserName TEXT, Country TEXT, Playtime INT); INSERT INTO Users (UserID, UserName, Country, Playtime) VALUES (1, 'Ravi', 'India', 200), (2, 'Priya', 'USA', 300), (3, 'Krishna', 'India', 250);
What is the average playtime per user for players from India?
SELECT AVG(Playtime) FROM Users WHERE Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE storage_facilities (id INT, facility_name TEXT, state TEXT); INSERT INTO storage_facilities (id, facility_name, state) VALUES (1, 'Facility A', 'Texas'), (2, 'Facility B', 'California');
Insert new records of chemical storage facilities in California.
INSERT INTO storage_facilities (id, facility_name, state) VALUES (3, 'Facility C', 'California'), (4, 'Facility D', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE ohio_water_usage (id INT, building_type VARCHAR(20), water_consumption FLOAT, month VARCHAR(10)); INSERT INTO ohio_water_usage (id, building_type, water_consumption, month) VALUES (1, 'Agricultural', 40000, 'January'), (2, 'Agricultural', 50000, 'February');
What is the total water consumption for agricultural buildings in Ohio for each month?
SELECT month, SUM(water_consumption) FROM ohio_water_usage WHERE building_type = 'Agricultural' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales(salesperson VARCHAR(20), region VARCHAR(20), product VARCHAR(20), quantity INT); INSERT INTO Sales(salesperson, region, product, quantity) VALUES('John', 'West', 'Fair Trade Coffee', 50), ('Jane', 'East', 'Fair Trade Coffee', 75), ('John', 'East', 'Bananas', 30);
What is the total quantity of "Fair Trade Coffee" sold by each salesperson in the "West" region?
SELECT salesperson, SUM(quantity) as total_quantity FROM Sales WHERE product = 'Fair Trade Coffee' AND region = 'West' GROUP BY salesperson;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_date, founder_gender) VALUES (1, 'StyleHub', 'Fashion', '2014-07-22', 'Female'); INSERT INTO companies (id, name, industry, founding_date, founder_gender) VALUES (2, 'T...
What is the number of companies founded by women in the fashion industry?
SELECT COUNT(*) FROM companies WHERE industry = 'Fashion' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE artifacts (id INT PRIMARY KEY, site_id INT, artifact_id INT, description TEXT);
Insert new artifact record for site 456
INSERT INTO artifacts (id, site_id, artifact_id, description) VALUES (1, 456, 789, 'Bronze spearhead with intricate engravings');
gretelai_synthetic_text_to_sql
CREATE TABLE mine (mine_id INT, mine_name TEXT, location TEXT, environmental_impact_score DECIMAL(5,2)); INSERT INTO mine VALUES (1, 'ABC Mine', 'Wyoming, USA', 45.67), (2, 'DEF Mine', 'West Virginia, USA', 33.45), (3, 'GHI Mine', 'Kentucky, USA', 47.89), (4, 'JKL Mine', 'Colorado, USA', 31.24);
List the top 3 mines with the highest environmental impact score, ordered by the score in descending order.
SELECT mine_name, environmental_impact_score FROM (SELECT mine_name, environmental_impact_score, ROW_NUMBER() OVER (ORDER BY environmental_impact_score DESC) as rank FROM mine) AS ranked_mines WHERE rank <= 3 ORDER BY environmental_impact_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_ethics (tool_name VARCHAR(255), country VARCHAR(255), date DATE, impact_score INT); INSERT INTO ai_ethics (tool_name, country, date, impact_score) VALUES ('DeepRed', 'USA', '2022-01-01', 7), ('GreenAI', 'Canada', '2022-02-01', 8), ('FairAI', 'Mexico', '2022-03-01', 9);
Delete records in the "ai_ethics" table where the "tool_name" is 'DeepRed' and the "country" is 'USA'
DELETE FROM ai_ethics WHERE tool_name = 'DeepRed' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE mine_workers (worker_id INT, mine_id INT); INSERT INTO mine_workers (worker_id, mine_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3); CREATE TABLE mine_roles (role_id INT, role VARCHAR(20)); INSERT INTO mine_roles (role_id, role) VALUES (1, 'Miner'), (2, 'Engineer'), (3, 'Manager'), (4, 'Administrator');
Count the number of workers in each mine and their roles in the "mine_workers" and "mine_roles" tables
SELECT mw.mine_id, mr.role, COUNT(mw.worker_id) as worker_count FROM mine_workers mw JOIN mine_roles mr ON mw.mine_id = mr.role_id GROUP BY mw.mine_id, mr.role;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(100), country VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'Canada', 50.00, '2020-01-01'); INSERT INTO donors (id, name, country, donation_amount, donation_date) VA...
What is the total amount donated by individual donors based in Canada in the year 2020?
SELECT SUM(donation_amount) FROM donors WHERE country = 'Canada' AND YEAR(donation_date) = 2020 AND donors.id NOT IN (SELECT donor_id FROM corporations);
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Region VARCHAR(2)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Region) VALUES (1, 35, 'NY'), (2, 40, 'CA'), (3, 45, 'NY'), (4, 50, 'IL'), (5, 55, 'IL');
Delete the record of the oldest community health worker in the 'IL' region.
DELETE FROM CommunityHealthWorkers WHERE WorkerID = (SELECT WorkerID FROM (SELECT WorkerID, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY Age DESC) rn FROM CommunityHealthWorkers) t WHERE t.rn = 1 AND t.Region = 'IL');
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, type TEXT, cost INT, date DATE); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (1, 6, 'wheelchair', 700, '2022-04-01'); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (2, 7, 'note taker', 500, '2022-05-01');
What is the maximum cost of accommodations provided to students with mobility impairments in the past year?
SELECT MAX(cost) FROM accommodations WHERE type = 'wheelchair' AND date >= DATE_SUB(NOW(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE, weight FLOAT); INSERT INTO satellite_deployment (id, name, country, launch_date, weight) VALUES (1, 'Sentinel-2A', 'European Union', '2015-06-23', 1234.5); INSERT INTO satellite_deployment (id, name, countr...
Update the 'weight' column for the satellite 'Sentinel-2A'
UPDATE satellite_deployment SET weight = 1234.5 WHERE name = 'Sentinel-2A';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (id INT, model_name VARCHAR(50), domain VARCHAR(50), country VARCHAR(50), fairness_score FLOAT); INSERT INTO ai_models VALUES (1, 'ModelA', 'Healthcare', 'USA', 0.82), (2, 'ModelB', 'Finance', 'USA', 0.78), (3, 'ModelC', 'Healthcare', 'Canada', 0.85);
List the algorithmic fairness scores for AI models used in healthcare in the US.
SELECT model_name, fairness_score FROM ai_models WHERE domain = 'Healthcare' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, building_name VARCHAR(100), certification_level VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), carbon_offset INT);
Show the average carbon offset of buildings in 'WA' state
SELECT AVG(carbon_offset) FROM GreenBuildings WHERE state = 'WA';
gretelai_synthetic_text_to_sql
CREATE TABLE sports_team_c_ticket_sales (sale_id INT, sale_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sports_team_c_ticket_sales (sale_id, sale_date, quantity, price) VALUES (1, '2022-01-01', 100, 50.00), (2, '2022-01-02', 120, 55.00), (3, '2022-01-03', 150, 60.00); CREATE TABLE sports_team_d_ticket_sale...
Display the UNION of 'sports_team_c_ticket_sales' and 'sports_team_d_ticket_sales' tables
SELECT * FROM sports_team_c_ticket_sales UNION SELECT * FROM sports_team_d_ticket_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (year INT, animal_name VARCHAR(255), population INT); INSERT INTO animal_population (year, animal_name, population) VALUES (2019, 'Tiger', 200), (2020, 'Tiger', 220), (2021, 'Tiger', 240), (2019, 'Elephant', 300), (2020, 'Elephant', 320), (2021, 'Elephant', 340), (2019, 'Crane', 150), (20...
Identify animal populations with increasing trends over the last 3 years
SELECT animal_name, population, LAG(population) OVER (PARTITION BY animal_name ORDER BY year) as previous_population FROM animal_population WHERE year > 2019 AND population > previous_population;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (drug VARCHAR(50), region VARCHAR(50), quarter INT, year INT, revenue FLOAT); INSERT INTO sales_data (drug, region, quarter, year, revenue) VALUES ('DrugE', 'Canada', 3, 2021, 4000000);
What was the total sales revenue for 'DrugE' in the 'Canada' region in Q3 2021?
SELECT SUM(revenue) FROM sales_data WHERE drug = 'DrugE' AND region = 'Canada' AND quarter = 3 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ConstructionLabor (id INT, city VARCHAR(20), year INT, num_workers INT); INSERT INTO ConstructionLabor (id, city, year, num_workers) VALUES (1, 'Chicago', 2020, 5000), (2, 'Chicago', 2019, 4500), (3, 'Houston', 2020, 6000);
How many construction workers were employed in the city of Chicago in 2020?
SELECT num_workers FROM ConstructionLabor WHERE city = 'Chicago' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (name VARCHAR(255), city VARCHAR(255), date DATE); INSERT INTO Exhibitions (name, city, date) VALUES ('Modern Art', 'New York', '2023-03-01'), ('Contemporary Art', 'Los Angeles', '2023-04-01');
Insert a new record of an art exhibition.
INSERT INTO Exhibitions (name, city, date) VALUES ('Classic Art', 'Chicago', '2023-02-01');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(100), contract_value DECIMAL(10, 2), contract_date DATE);
Find the number of defense contracts awarded per quarter in the 'defense_contracts' table
SELECT EXTRACT(QUARTER FROM contract_date) as quarter, COUNT(*) as num_contracts FROM defense_contracts GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), JoinDate DATETIME);
Insert new records for 2 members who joined in February 2022 with no workouts yet into the 'Workouts' table
INSERT INTO Workouts (WorkoutID, MemberID, Duration, MembershipType) SELECT NULL, m.MemberID, 0, 'Standard' FROM (SELECT MemberID FROM Members WHERE MONTH(JoinDate) = 2 AND YEAR(JoinDate) = 2022 LIMIT 2) m WHERE NOT EXISTS (SELECT 1 FROM Workouts w WHERE w.MemberID = m.MemberID);
gretelai_synthetic_text_to_sql
CREATE TABLE flights (id INT, airline VARCHAR(255), safety_issue BOOLEAN); INSERT INTO flights (id, airline, safety_issue) VALUES (1, 'GalacticAirlines', true), (2, 'GalacticAirlines', false), (3, 'AstroFlights', true), (4, 'GalacticAirlines', false), (5, 'AstroFlights', false);
What is the percentage of flights operated by 'GalacticAirlines' with safety issues?
SELECT 100.0 * COUNT(*) FILTER (WHERE safety_issue = true) / COUNT(*) as percentage FROM flights WHERE airline = 'GalacticAirlines';
gretelai_synthetic_text_to_sql
CREATE TABLE customer_transactions (transaction_id INT, customer_id INT, transaction_value DECIMAL(10,2)); INSERT INTO customer_transactions (transaction_id, customer_id, transaction_value) VALUES (1, 1, 100.00), (2, 2, 200.50), (3, 3, 75.00);
What is the minimum transaction value for customers in Texas?
SELECT MIN(transaction_value) FROM customer_transactions WHERE customer_id IN (SELECT customer_id FROM customers WHERE state = 'TX');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_status (id INT, species_name VARCHAR(255), conservation_status VARCHAR(255), ocean VARCHAR(255)); INSERT INTO marine_species_status (id, species_name, conservation_status, ocean) VALUES (1, 'Killer Whale', 'Endangered', 'Pacific Ocean'), (2, 'Killer Whale', 'Endangered', 'Atlantic Ocean'); C...
Find the number of marine species in each ocean, excluding the Southern Ocean, and the total number of marine species in the oceanography table.
SELECT ocean, COUNT(*) FROM marine_species_status WHERE ocean NOT IN ('Southern Ocean') GROUP BY ocean UNION ALL SELECT 'Total', COUNT(*) FROM marine_species_status;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircrafts (aircraft_id INT, model VARCHAR(50), top_speed FLOAT, production_year INT); INSERT INTO Aircrafts (aircraft_id, model, top_speed, production_year) VALUES (1, 'B747', 913.0, 1968), (2, 'A320', 845.0, 1987);
What is the average speed of all airplanes in the Aircrafts table?
SELECT AVG(top_speed) AS avg_speed FROM Aircrafts;
gretelai_synthetic_text_to_sql
CREATE TABLE tour_guides (guide_id INT, guide_name VARCHAR(50), language VARCHAR(20), years_of_experience INT, PRIMARY KEY (guide_id));
Insert a new record into the "tour_guides" table with the following information: guide_id = 301, guide_name = 'Alexander', language = 'English', years_of_experience = 10
INSERT INTO tour_guides (guide_id, guide_name, language, years_of_experience) VALUES (301, 'Alexander', 'English', 10);
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name TEXT, city TEXT); INSERT INTO attorneys (id, name, city) VALUES (1, 'Paul Lewiston', 'Boston'); CREATE TABLE cases (id INT, attorney_id INT, result TEXT); INSERT INTO cases (id, attorney_id, result) VALUES (1, 1, 'won'), (2, 1, 'won'), (3, 1, 'lost');
Determine the number of cases and the winning percentage for attorneys in Boston.
SELECT attorneys.city, COUNT(cases.id) AS total_cases, 100.0 * SUM(CASE WHEN cases.result = 'won' THEN 1 ELSE 0 END) / COUNT(cases.id) AS win_percentage FROM attorneys INNER JOIN cases ON attorneys.id = cases.attorney_id WHERE attorneys.city = 'Boston' GROUP BY attorneys.city;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, region VARCHAR(255), year INT, recycling_rate DECIMAL(5,4)); INSERT INTO recycling_rates (id, region, year, recycling_rate) VALUES (1, 'Asia', 2020, 0.35), (2, 'Europe', 2020, 0.45), (3, 'Africa', 2020, 0.25);
Find the recycling rate for the top 3 regions with the highest waste generation in 2020.
SELECT region, recycling_rate FROM (SELECT region, recycling_rate, ROW_NUMBER() OVER (ORDER BY recycling_rate DESC) AS rn FROM recycling_rates WHERE year = 2020) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_research (id INT, species TEXT, location TEXT, year INT); INSERT INTO marine_species_research (id, species, location, year) VALUES (1, 'Whale Shark', 'Indian Ocean', 2010), (2, 'Dolphin', 'Atlantic Ocean', 2005), (3, 'Turtle', 'Indian Ocean', 2018);
How many marine species have been researched in the Indian Ocean?
SELECT COUNT(*) FROM marine_species_research WHERE location = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'Climate Action Now'); CREATE TABLE Programs (ProgramID INT, Program TEXT); INSERT INTO Programs (ProgramID, Program) VALUES (1, 'Climate Change'); CREATE TABLE Contributions (ContributionID INT, DonorID INT, ProgramID...
Insert a new record for a donation of 1500 by 'Climate Action Now' on 'Climate Change' program
INSERT INTO Contributions (ContributionID, DonorID, ProgramID, Amount) VALUES (1, 1, 1, 1500);
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, ClientName VARCHAR(100), Region VARCHAR(50), FinanciallyCapable BOOLEAN, LastLoanDate DATE); INSERT INTO Clients (ClientID, ClientName, Region, FinanciallyCapable, LastLoanDate) VALUES (1, 'AB Johnson', 'Europe', FALSE, '2020-02-01'), (2, 'CD Smith', 'Europe', TRUE, '2021-05-15');
Delete records of financially incapable clients from the European region who have not taken any loans in the past year.
DELETE FROM Clients WHERE FinanciallyCapable = FALSE AND Region = 'Europe' AND LastLoanDate < DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE heavy_machinery (id INT, make VARCHAR(50), model VARCHAR(50), year INT, owned BOOLEAN);
What is the total number of heavy machinery units owned by the company?
SELECT COUNT(*) FROM heavy_machinery WHERE owned = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRatesAsia (country VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRatesAsia (country, year, recycling_rate) VALUES ('China', 2020, 0.42), ('India', 2020, 0.38), ('Indonesia', 2020, 0.35), ('Japan', 2020, 0.60), ('South Korea', 2020, 0.63);
What are the recycling rates in Asia for the year 2020, grouped by country?
SELECT country, AVG(recycling_rate) FROM RecyclingRatesAsia WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_clinics (clinic_id INT, state VARCHAR(2));
What is the number of legal aid clinics in each state?
SELECT state, COUNT(*) FROM legal_aid_clinics GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing (id INT, year INT, cost FLOAT, country TEXT);
What is the distribution of spacecraft manufacturing costs by country?
SELECT country, AVG(cost) as avg_cost, STDDEV(cost) as stddev_cost FROM SpacecraftManufacturing GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE CO2Emissions (id INT, fabric VARCHAR(50), emission DECIMAL); INSERT INTO CO2Emissions (id, fabric, emission) VALUES (1, 'Organic Cotton', 4.5), (2, 'Recycled Polyester', 7.0), (3, 'Hemp', 2.0), (4, 'Tencel', 3.5);
What is the average CO2 emission for each type of fabric?
SELECT fabric, AVG(emission) FROM CO2Emissions GROUP BY fabric;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (donor_id, donation_amount, donation_date) VALUES (1, 50.00, '2022-01-05'), (2, 100.00, '2022-03-15'), (3, 200.00, '2022-01-10');
What was the total donation amount from first-time donors in Q1 2022?
SELECT SUM(donation_amount) FROM Donations WHERE donor_id IN (SELECT donor_id FROM Donations GROUP BY donor_id HAVING COUNT(*) = 1) AND donation_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY, exhibition_name VARCHAR(255), city VARCHAR(255));
Count the number of exhibitions in each city
SELECT city, COUNT(exhibition_id) as num_exhibitions FROM exhibitions GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_activity (customer_id INT, activity_date DATE); INSERT INTO customer_activity (customer_id, activity_date) VALUES (1, '2022-01-01'), (1, '2022-02-01'), (2, '2022-03-01'), (3, '2022-04-01');
Identify customers who have made purchases in the last 30 days
SELECT * FROM customer_activity WHERE activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID INT, CityName VARCHAR(50), Population INT, LandfillID INT); INSERT INTO Cities VALUES (1, 'CityA', 600000, 1), (2, 'CityB', 800000, 2), (3, 'CityC', 550000, 3); CREATE TABLE Landfills (LandfillID INT, LandfillName VARCHAR(50), Capacity FLOAT); INSERT INTO Landfills VALUES (1, 'Landfill1', 20...
What is the capacity of landfills that serve cities with a population above 500,000?
SELECT LandfillName, Capacity FROM Landfills WHERE LandfillID IN (SELECT Cities.LandfillID FROM Cities WHERE Population > 500000);
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_quebec (court_location VARCHAR(50), date DATE); INSERT INTO legal_aid_quebec VALUES ('Montreal', '2022-02-01'), ('Quebec City', '2021-06-15'), ('Sherbrooke', '2020-09-03'); CREATE TABLE legal_aid_nova_scotia (court_location VARCHAR(50), date DATE); INSERT INTO legal_aid_nova_scotia VALUES ('Halif...
List the unique court locations where legal aid was provided in Quebec and Nova Scotia in the last 5 years.
SELECT DISTINCT court_location FROM legal_aid_quebec WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) UNION ALL SELECT DISTINCT court_location FROM legal_aid_nova_scotia WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE VIEW FarmersMarket AS SELECT * FROM Products WHERE is_organic = TRUE; INSERT INTO Products (id, name, is_organic) VALUES (1, 'Product1', TRUE), (2, 'Product2', FALSE), (3, 'Product3', TRUE);
Insert new product 'Eco-friendly Product4' with is_organic = TRUE in 'FarmersMarket' view
INSERT INTO Products (id, name, is_organic) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM Products), 'Eco-friendly Product4', TRUE); INSERT INTO FarmersMarket SELECT * FROM Products WHERE is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, practices TEXT); CREATE TABLE workforce_development (factory_id INT, program TEXT);
Display the factory IDs, names, and locations of factories with ethical labor practices and workforce development programs.
SELECT factories.factory_id, factories.name, factories.location FROM factories INNER JOIN workforce_development ON factories.factory_id = workforce_development.factory_id WHERE factories.practices = 'ethical' AND workforce_development.program IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, gender VARCHAR(20), condition VARCHAR(50), therapy_date DATE); INSERT INTO patients (id, age, gender, condition, therapy_date) VALUES (1, 35, 'Female', 'Depression', '2020-02-01'); INSERT INTO patients (id, age, gender, condition, therapy_date) VALUES (2, 45, 'Male', 'Anxiety...
What is the average age of patients who received therapy in 2020?
SELECT AVG(age) FROM patients WHERE YEAR(therapy_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE NuclearCapabilities (ID INT, Country VARCHAR(50), Capable BOOLEAN);
Which countries have nuclear weapons capabilities?
SELECT Country FROM NuclearCapabilities WHERE Capable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, article_title VARCHAR(100), article_text TEXT, topic VARCHAR(50)); INSERT INTO articles VALUES (1, 'Article 1', 'Climate change is...', 'climate change'), (2, 'Article 2', 'Global warming is...', 'climate change'), (3, 'Article 3', 'The environment is...', 'environment');
What is the average word count for articles related to climate change?
SELECT AVG(LENGTH(article_text) - LENGTH(REPLACE(article_text, ' ', '')) + 1) as avg_word_count FROM articles WHERE topic = 'climate change';
gretelai_synthetic_text_to_sql
CREATE TABLE company_info (company_name VARCHAR(255)); INSERT INTO company_info (company_name) VALUES ('Acme Inc'), ('Beta Corp'), ('Charlie LLC'), ('Delta Co'); CREATE TABLE funding (company_name VARCHAR(255), funding_amount INT); INSERT INTO funding (company_name, funding_amount) VALUES ('Acme Inc', 500000), ('Beta C...
Identify companies that have not received any funding
SELECT company_name FROM company_info WHERE company_name NOT IN (SELECT company_name FROM funding);
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (id INT, cost FLOAT, state TEXT, hourly BOOLEAN); INSERT INTO labor_costs (id, cost, state, hourly) VALUES (1, 30.00, 'Texas', true), (2, 500.00, 'New York', false);
What is the median construction labor cost per hour in 'Texas'?
SELECT AVG(cost) FROM labor_costs WHERE state = 'Texas' AND hourly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, item_name VARCHAR(50), is_vegetarian BOOLEAN, price DECIMAL(5,2)); INSERT INTO menu VALUES (1, 'Quinoa Salad', true, 12.99), (2, 'Cheeseburger', false, 7.99), (3, 'Falafel Wrap', true, 9.99); CREATE TABLE orders (order_id INT, menu_id INT, order_date DATE); INSERT INTO orders VALUES (1, ...
What are the top 3 most ordered vegetarian dishes?
SELECT item_name, COUNT(*) as order_count FROM menu INNER JOIN orders ON menu.menu_id = orders.menu_id WHERE is_vegetarian = true GROUP BY item_name ORDER BY order_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, ota_name TEXT, region TEXT); CREATE TABLE virtual_tours (vt_id INT, ota_id INT, engagements INT); INSERT INTO otas (ota_id, ota_name, region) VALUES (1, 'OTA 1', 'South America'), (2, 'OTA 2', 'Europe'), (3, 'OTA 3', 'Asia'); INSERT INTO virtual_tours (vt_id, ota_id, engagements) VALUES (...
What is the total number of virtual tour engagements in South America?
SELECT SUM(engagements) FROM virtual_tours JOIN otas ON virtual_tours.ota_id = otas.ota_id WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE employment_data (state VARCHAR(255), employed INT, unemployed INT, total_population INT); INSERT INTO employment_data (state, employed, unemployed, total_population) VALUES ('Illinois', 5900000, 600000, 12900000);
What is the percentage of the population in 'Illinois' that is unemployed?
SELECT (unemployed * 100.0 / total_population) AS percentage FROM employment_data WHERE state = 'Illinois';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_bookings (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT, online_bookings INT); INSERT INTO hotel_bookings (hotel_id, hotel_name, country, rating, online_bookings) VALUES (1, 'The Grand Palace', 'France', 4.7, 800), (2, 'The Majestic Hotel', 'Germany', 4.5, 700), (3, 'The Royal Resort', 'I...
What is the distribution of online bookings for hotels in Europe with a rating of 4.5 or higher?
SELECT country, COUNT(hotel_id) AS total_hotels, AVG(online_bookings) AS avg_online_bookings, STDDEV(online_bookings) AS stddev_online_bookings FROM hotel_bookings WHERE country = 'Europe' AND rating >= 4.5 GROUP BY country
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO Restaurants (id, name, type) VALUES (1, 'Green Garden', 'Vegan'); INSERT INTO Restaurants (id, name, type) VALUES (2, 'Bistro Bella', 'Italian'); INSERT INTO Restaurants (id, name, type) VALUES (3, 'Taqueria Tina', 'Mexican'); INSERT INT...
What is the average price of vegetarian dishes in Mexican restaurants?
SELECT AVG(price) FROM Menu WHERE vegetarian = true AND restaurant_id IN (SELECT id FROM Restaurants WHERE type LIKE '%Mexican%');
gretelai_synthetic_text_to_sql
CREATE TABLE health_facilities (facility_id INT, name VARCHAR(50), type VARCHAR(50), population INT, city VARCHAR(50), state VARCHAR(50));
What is the total population of clinics in 'New York' in the 'health_facilities' table?
SELECT SUM(population) FROM health_facilities WHERE type = 'clinic' AND state = 'New York';
gretelai_synthetic_text_to_sql