context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE if not exists engagement (user_id INT, country VARCHAR(50), score FLOAT, month INT, year INT); INSERT INTO engagement (user_id, country, score) VALUES (1, 'Brazil', 10.5), (2, 'Brazil', 12.0);
What is the minimum engagement score for users in Brazil in December 2021?
SELECT MIN(score) FROM engagement WHERE country = 'Brazil' AND month = 12 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, strain VARCHAR(50), state VARCHAR(50), year INT, yield FLOAT); INSERT INTO production (id, strain, state, year, yield) VALUES (1, 'OG Kush', 'Washington', 2021, 3.5), (2, 'Blue Dream', 'California', 2021, 4.0), (3, 'Sour Diesel', 'California', 2021, 3.0);
What was the minimum production yield (in pounds) for the strain 'Blue Dream' in the state of California in 2021?
SELECT MIN(yield) FROM production WHERE strain = 'Blue Dream' AND state = 'California' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (TransactionID int, DAppName varchar(50), Country varchar(50), Transactions int); INSERT INTO Transactions (TransactionID, DAppName, Country, Transactions) VALUES (1, 'DApp1', 'USA', 1000), (2, 'DApp2', 'Canada', 2000), (3, 'DApp3', 'USA', 3000);
Find the decentralized application with the highest transaction count for each country in descending order.
SELECT Country, DAppName, MAX(Transactions) as MaxTransactions FROM Transactions GROUP BY Country, DAppName ORDER BY MaxTransactions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE author (author_id INT, author_name VARCHAR(255)); CREATE TABLE research_paper (paper_id INT, paper_title VARCHAR(255), author_id INT, category VARCHAR(255)); INSERT INTO author (author_id, author_name) VALUES (1, 'Dr. Grace Hopper'); INSERT INTO research_paper (paper_id, paper_title, author_id, category) V...
Determine the number of unique AI safety and algorithmic fairness research papers published by each author, sorted by the total count in descending order.
SELECT a.author_name, COUNT(DISTINCT rp.paper_id) as paper_count FROM author a INNER JOIN research_paper rp ON a.author_id = rp.author_id WHERE rp.category IN ('AI Safety', 'Algorithmic Fairness') GROUP BY a.author_name ORDER BY paper_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE attractions (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), type VARCHAR(50));
Insert a new record into the "attractions" table with id 201, name "Sustainable Winery", city "Napa", country "USA", and type "Wine Tasting"
INSERT INTO attractions VALUES (201, 'Sustainable Winery', 'Napa', 'USA', 'Wine Tasting');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (id INT, law_name TEXT, state TEXT); INSERT INTO mental_health_parity (id, law_name, state) VALUES (1, 'Parity Act 1', 'NY'), (2, 'Parity Act 2', 'NY'), (3, 'Parity Act 3', 'CA');
Find the number of distinct mental health parity laws in each state.
SELECT state, COUNT(DISTINCT law_name) as num_laws FROM mental_health_parity GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(255), country VARCHAR(255), industry VARCHAR(255)); INSERT INTO Suppliers (supplier_id, supplier_name, country, industry) VALUES (1, 'ABC Inc.', 'USA', 'Textile'), (2, 'XYZ Ltd.', 'Brazil', 'Garment'), (3, 'LMN Corp.', 'China', 'Accessories'), (4, ' DEF Gmb...
What is the total quantity of garments supplied by companies based in Africa or South America?
SELECT SUM(quantity) FROM (SELECT 1 AS quantity UNION ALL SELECT 0) q LEFT JOIN Suppliers s ON q.quantity = 1 WHERE s.country IN ('Africa', 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, species VARCHAR(255), population INT);
How many unique species are there in 'animal_population' table?
SELECT species FROM animal_population GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels(id INT, name VARCHAR(255)); INSERT INTO vessels VALUES (1, 'MSC Chariot'); CREATE TABLE cargo(id INT, name VARCHAR(255), delivery_time INT, vessel_id INT, port_id INT); CREATE TABLE ports(id INT, name VARCHAR(255));
What are the names and average delivery times of all cargoes that were transported by the vessel 'MSC Chariot' and unloaded at the port of Oakland?
SELECT cargo.name, AVG(cargo.delivery_time) FROM cargo INNER JOIN vessels ON cargo.vessel_id = vessels.id INNER JOIN ports ON cargo.port_id = ports.id WHERE vessels.name = 'MSC Chariot' AND ports.name = 'Oakland' GROUP BY cargo.name;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_countries (id INT, country VARCHAR(255), num_registered_voters INT); INSERT INTO eu_countries (id, country, num_registered_voters) VALUES (1, 'Germany', 61478000);
Identify the top 5 countries with the most registered voters in the European Union.
SELECT country, num_registered_voters FROM eu_countries ORDER BY num_registered_voters DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), email VARCHAR(50), phone VARCHAR(15)); INSERT INTO teachers (teacher_id, teacher_name, email, phone) VALUES (1, 'John Doe', 'johndoe@email.com', '555-123-4567'), (2, 'Jane Smith', 'janesmith@email.com', '555-987-6543'), (3, 'Jim Brown', 'jimbrown@email....
Which teachers have participated in professional development programs related to open pedagogy and what are their contact details?
SELECT t.teacher_name, t.email, t.phone, pd.program_name FROM teachers t JOIN professional_development pd ON t.teacher_id = pd.teacher_id WHERE pd.program_name LIKE '%open pedagogy%';
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, category VARCHAR(255), subcategory VARCHAR(255), sustainability VARCHAR(50), price DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO garments (id, category, subcategory, sustainability, price, country) VALUES (1, 'Activewear', 'Tops', 'Eco-Friendly', 49.99, 'Australia'); INSERT INTO garme...
What is the maximum retail price of eco-friendly activewear sold in Australia?
SELECT MAX(price) FROM garments WHERE category = 'Activewear' AND sustainability = 'Eco-Friendly' AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_records (id INT, vessel_id INT, incident_type VARCHAR(20), resolution VARCHAR(20));
Delete records in the safety_records table where the vessel_id is 801 and incident_type is 'Grounding'
DELETE FROM safety_records WHERE vessel_id = 801 AND incident_type = 'Grounding';
gretelai_synthetic_text_to_sql
CREATE TABLE daily_data_usage(subscriber_id INT, usage FLOAT, date DATE);
What is the average daily data usage for the top 10 data consuming mobile customers?
SELECT subscriber_id, AVG(usage) FROM daily_data_usage WHERE date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY subscriber_id ORDER BY AVG(usage) DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE audience (id INT, age INT, gender VARCHAR(10), location VARCHAR(100));
Insert a new record in the 'audience' table
INSERT INTO audience (id, age, gender, location) VALUES (1, 30, 'Female', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (Id INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Age INT, Gender VARCHAR(10), State VARCHAR(50)); CREATE TABLE Policies (Id INT PRIMARY KEY, PolicyholderId INT, PolicyType VARCHAR(50), CoverageAmount DECIMAL(10,2), FOREIGN KEY (PolicyholderId) REFERENCES Policyholders(Id)); C...
What is the total premium amount and number of policies for policyholders who have a risk assessment score less than 60 and live in the state of Texas?
SELECT P.State, U.RiskAssessmentScore, SUM(U.Premium) as TotalPremiumAmount, COUNT(P.Id) as NumberOfPolicies FROM Policyholders P JOIN Policies PL ON P.Id = PL.PolicyholderId JOIN Underwriting U ON P.Id = U.PolicyholderId WHERE P.State = 'Texas' AND U.RiskAssessmentScore < 60 GROUP BY P.State ORDER BY TotalPremiumAmoun...
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (id INT, project_name VARCHAR(50), country VARCHAR(50), year INT, cost FLOAT); INSERT INTO climate_adaptation (id, project_name, country, year, cost) VALUES (1, 'Coastal Protection', 'Brazil', 2018, 2000000);
What is the average cost of climate adaptation projects in Latin America over the last 5 years?
SELECT AVG(cost) FROM climate_adaptation WHERE country LIKE '%Latin%' AND year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE rd_expenditures (id INT, drug_id INT, year INT, amount DECIMAL(10, 2));
What is the total R&D expenditure for a specific drug in a certain year?
SELECT SUM(rd_expenditures.amount) FROM rd_expenditures JOIN drugs ON rd_expenditures.drug_id = drugs.id WHERE drugs.name = 'DrugA' AND rd_expenditures.year = 2020;
gretelai_synthetic_text_to_sql
CREATE SCHEMA agriculture; CREATE TABLE crops (farmer_id INT, crop_production INT, crop_year INT, region VARCHAR(50)); INSERT INTO crops (farmer_id, crop_production, crop_year, region) VALUES (1, 800, 2022, 'Asia'), (2, 900, 2022, 'Africa'), (3, 700, 2021, 'Europe'), (4, 600, 2022, 'Asia'), (5, 1000, 2021, 'Africa');
Calculate the average crop production by farmers in the 'agriculture' schema, grouped by region, for crops produced in 2022.
SELECT region, AVG(crop_production) FROM agriculture.crops WHERE crop_year = 2022 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT); INSERT INTO routes (route_id, route_name) VALUES (101, 'Bus Route 101'); CREATE TABLE fare_collection (collection_id INT, passenger_type TEXT, route_id INT, fare_amount DECIMAL); INSERT INTO fare_collection (collection_id, passenger_type, route_id) VALUES (1, 'Ambula...
What is the total fare collected from passengers with disabilities for bus route 101?
SELECT SUM(fare_amount) FROM fare_collection JOIN routes ON fare_collection.route_id = routes.route_id WHERE passenger_type = 'Wheelchair';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Golden State Warriors'), (2, 'Los Angeles Lakers'); CREATE TABLE games (game_id INT, home_team_id INT, away_team_id INT); INSERT INTO games (game_id, home_team_id, away_team_id) VALUES (1, 1, 2), (2, 2, 1), (3, ...
What is the total number of home games played by each team?
SELECT t.team_name, COUNT(CASE WHEN g.home_team_id = t.team_id THEN 1 END) as home_games_played FROM teams t INNER JOIN games g ON t.team_id IN (g.home_team_id, g.away_team_id) GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Public_Transportation (Id INT, System VARCHAR(50), Ridership INT, Year INT); INSERT INTO Public_Transportation (Id, System, Ridership, Year) VALUES (1, 'Tokyo Metro', 5500000, 2023); INSERT INTO Public_Transportation (Id, System, Ridership, Year) VALUES (2, 'Paris Metro', 4500000, 2023);
Identify the public transportation systems with the highest and lowest ridership in 2023?
SELECT System, Ridership FROM (SELECT System, Ridership, ROW_NUMBER() OVER (ORDER BY Ridership DESC) AS Rank, COUNT(*) OVER () AS Total FROM Public_Transportation WHERE Year = 2023) AS Subquery WHERE Rank = 1 OR Rank = Total;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_rice_production (country VARCHAR(50), crop VARCHAR(50), production FLOAT); INSERT INTO organic_rice_production (country, crop, production) VALUES ('Thailand', 'Rice', 2500.0), ('Vietnam', 'Rice', 3000.0), ('Indonesia', 'Rice', 2000.0);
What is the total production (in tons) of organic rice in Southeast Asia?
SELECT SUM(production) FROM organic_rice_production WHERE country IN ('Thailand', 'Vietnam', 'Indonesia') AND crop = 'Rice';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours_v2 (hotel_region VARCHAR(20), engagement_time TIME); INSERT INTO virtual_tours_v2 (hotel_region, engagement_time) VALUES ('Africa', '00:10:00'), ('Middle East', '00:25:00'), ('South America', '00:15:00');
What is the maximum virtual tour engagement time for hotels in the 'Middle East' region?
SELECT MAX(engagement_time) FROM virtual_tours_v2 WHERE hotel_region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE ConsumerPreference (ProductID INT, ConsumerID INT, Preference VARCHAR(255)); INSERT INTO ConsumerPreference (ProductID, ConsumerID, Preference) VALUES (4, 6, 'Likes'), (4, 7, 'Likes'), (5, 6, 'Likes'), (5, 7, 'Dislikes'); CREATE TABLE Product (ProductID INT, ProductName VARCHAR(255), Price DECIMAL(5,2)); I...
List the cruelty-free certified products and their preference data.
SELECT P.ProductName, C.Preference FROM CrueltyFree CF INNER JOIN Product P ON CF.ProductID = P.ProductID INNER JOIN ConsumerPreference C ON P.ProductID = C.ProductID;
gretelai_synthetic_text_to_sql
CREATE TABLE Garments (garment_id INT, garment_produced_fair_labor BOOLEAN, garment_country VARCHAR(50));
What is the total number of garments produced using fair labor practices in Turkey?
SELECT COUNT(*) AS total_garments FROM Garments WHERE garment_produced_fair_labor = TRUE AND garment_country = 'Turkey';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders_underrepresented_communities BOOLEAN, funding FLOAT);
What is the average funding received by companies founded by people from underrepresented communities in the clean energy sector?
SELECT AVG(funding) FROM companies WHERE founders_underrepresented_communities = true AND industry = 'clean energy';
gretelai_synthetic_text_to_sql
CREATE TABLE dates (transaction_id INT, transaction_date DATE); INSERT INTO dates (transaction_id, transaction_date) VALUES (1, '2022-01-03'), (2, '2022-01-04'), (3, '2022-01-05'), (4, '2022-01-06'); CREATE TABLE customers_4 (customer_id INT, name VARCHAR(50), region VARCHAR(20)); INSERT INTO customers_4 (customer_id, ...
How many transactions were made by customers in the Americas region on a Wednesday?
SELECT COUNT(*) FROM transactions_5 t JOIN dates d ON t.transaction_id = d.transaction_id JOIN customers_4 c ON t.customer_id = c.customer_id WHERE EXTRACT(DAY FROM d.transaction_date) = 3 AND c.region = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(50), opted_in_push BOOLEAN);
List the top 5 countries with the most users who have opted in to receive push notifications, along with the total number of users in each country.
SELECT country, SUM(CASE WHEN opted_in_push THEN 1 ELSE 0 END) as total_opted_in FROM users GROUP BY country ORDER BY total_opted_in DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, drug_id INT, region VARCHAR(255), sales_amount DECIMAL(10, 2), quarter INT, year INT);
What were the average sales per drug in the West region in Q4 2021?
SELECT d.drug_name, AVG(s.sales_amount) as avg_sales FROM sales s JOIN drugs d ON s.drug_id = d.drug_id WHERE s.region = 'West' AND s.quarter = 4 AND s.year = 2021 GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_housing (property_id INT, building_type VARCHAR(255), PRIMARY KEY (property_id)); INSERT INTO affordable_housing (property_id, building_type) VALUES (1, 'Apartment'), (2, 'Townhouse'), (3, 'Single-family'), (4, 'Townhouse');
List the 'property_id' and 'building_type' of affordable townhouses in the 'affordable_housing' table.
SELECT property_id, building_type FROM affordable_housing WHERE building_type = 'Townhouse' AND price < 300000;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtifactAnalysis (AnalysisID int, ArtifactID int, AnalystName text); INSERT INTO ArtifactAnalysis (AnalysisID, ArtifactID, AnalystName) VALUES (1, 2, 'John Doe');
Who analyzed the artifacts from site 'SiteB'?
SELECT AnalystName FROM ArtifactAnalysis INNER JOIN Artifacts ON ArtifactAnalysis.ArtifactID = Artifacts.ArtifactID WHERE Artifacts.Name = 'SiteB';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_disputes (id INT, year INT, days_of_work_stoppage INT, industry VARCHAR(255)); INSERT INTO labor_disputes (id, year, days_of_work_stoppage, industry) VALUES (1, 2022, 45, 'manufacturing'), (2, 2021, 32, 'manufacturing'), (3, 2022, 38, 'retail');
How many labor disputes occurred in '2022' in the 'manufacturing' schema, which resulted in a work stoppage of more than 30 days?
SELECT COUNT(*) FROM labor_disputes WHERE year = 2022 AND days_of_work_stoppage > 30 AND industry = 'manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerGames (PlayerID INT, Game TEXT, Date DATE); INSERT INTO PlayerGames (PlayerID, Game, Date) VALUES (1, 'Astral Archers', '2022-03-01'), (2, 'Astral Archers', '2022-03-05'), (3, 'Galactic Golf', '2022-03-03');
Count the number of unique players who have played "Astral Archers" and "Galactic Golf" in the last 30 days.
SELECT COUNT(DISTINCT PlayerID) FROM PlayerGames WHERE Game IN ('Astral Archers', 'Galactic Golf') AND Date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT PRIMARY KEY, donation_amount DECIMAL(10, 2), donation_date DATE, first_donation_date DATE); INSERT INTO donors (donor_id, donation_amount, donation_date, first_donation_date) VALUES (1, 250, '2022-01-01', '2022-01-01'), (2, 750, '2022-01-03', '2021-01-01'), (3, 900, '2022-02-05', '2022...
What is the total amount donated by new donors (those who have donated for the first time) in the year 2022?
SELECT SUM(donation_amount) FROM donors WHERE YEAR(donation_date) = 2022 AND YEAR(first_donation_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT); INSERT INTO company (id, name, founding_year) VALUES (10, 'InnoGreen', 2016), (11, 'GreenVentures', 2017), (12, 'EcoPower', 2015); CREATE TABLE diversity_metrics (id INT, company_id INT, diversity_score DECIMAL); INSERT INTO diversity_metrics (id, company_id,...
Delete records from the diversity_metrics table for companies founded before 2017
WITH cte_company AS (DELETE FROM company WHERE founding_year < 2017 RETURNING id) DELETE FROM diversity_metrics WHERE company_id IN (SELECT id FROM cte_company);
gretelai_synthetic_text_to_sql
CREATE TABLE professionals (id INT, name TEXT, country TEXT, age INT, profession TEXT);
What is the minimum age requirement for medical professionals in Colombia?
SELECT MIN(age) FROM professionals WHERE country = 'Colombia';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainable_practices BOOLEAN); CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), supplier_id INT, sustainable BOOLEAN, FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); INSERT INTO suppliers (id,...
List suppliers who do not provide any sustainable products.
SELECT name FROM suppliers WHERE id NOT IN (SELECT supplier_id FROM products WHERE sustainable = TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE returns (id INT, value FLOAT, origin VARCHAR(20), destination VARCHAR(20), returned_date DATE); INSERT INTO returns (id, value, origin, destination, returned_date) VALUES (1, 120, 'California', 'New York', '2022-04-15'), (2, 80, 'California', 'New York', '2022-06-01');
How many returns were there from California to New York with a value greater than $100 in Q2?
SELECT COUNT(*) FROM returns WHERE origin = 'California' AND destination = 'New York' AND value > 100 AND MONTH(returned_date) BETWEEN 4 AND 6;
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), start_date DATE, end_date DATE, budget DECIMAL(10,2)); INSERT INTO mitigation_projects (id, name, location, start_date, end_date, budget) VALUES (1, 'Solar Farm', 'California', '2020-01-01', '2022-12-31', 5000000.00);
Add data to the 'mitigation_projects' table
INSERT INTO mitigation_projects (id, name, location, start_date, end_date, budget) VALUES (1, 'Solar Farm', 'California', '2020-01-01', '2022-12-31', 5000000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE Student (StudentID INT, StudentName VARCHAR(50)); INSERT INTO Student (StudentID, StudentName) VALUES (1, 'John Doe'); INSERT INTO Student (StudentID, StudentName) VALUES (2, 'Jane Smith'); CREATE TABLE SupportProgram (ProgramID INT, ProgramName VARCHAR(50), StudentID INT); INSERT INTO SupportProgram (Prog...
Find the number of support programs each student is enrolled in, ordered by the number of enrollments in descending order.
SELECT StudentID, COUNT(*) AS Enrollments FROM SupportProgram GROUP BY StudentID ORDER BY Enrollments DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS sales (id INT, product VARCHAR(50), region VARCHAR(50), quantity INT); INSERT INTO sales (id, product, region, quantity) VALUES (1, 'productA', 'regionB', 100), (2, 'productB', 'regionC', 50);
How many 'productA' items were sold in 'regionB'?
SELECT SUM(quantity) FROM sales WHERE product = 'productA' AND region = 'regionB';
gretelai_synthetic_text_to_sql
CREATE TABLE GREEN_LINE (station_name TEXT, num_docks_available INT); INSERT INTO GREEN_LINE (station_name, num_docks_available) VALUES ('Government Center', 400), ('Park Street', 350), ('North Station', 500);
Which stations on the Green Line have more than 300 docks available for bike return?
SELECT station_name FROM GREEN_LINE WHERE num_docks_available > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildingTypes (TypeID INT, TypeName VARCHAR(50));CREATE TABLE GreenBuildings (BuildingID INT, TypeID INT, YearBuilt INT, CityID INT);
List all green building types and the number of each type constructed in a specific year, for buildings in New York City.
SELECT GreenBuildingTypes.TypeName, COUNT(GreenBuildings.BuildingID) FROM GreenBuildingTypes INNER JOIN GreenBuildings ON GreenBuildingTypes.TypeID = GreenBuildings.TypeID WHERE GreenBuildings.YearBuilt = 2020 AND GreenBuildings.CityID = 1 GROUP BY GreenBuildingTypes.TypeName;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (ID INT, Gender VARCHAR(10), Age INT, State VARCHAR(50), LGBTQ BOOLEAN); INSERT INTO CommunityHealthWorkers (ID, Gender, Age, State, LGBTQ) VALUES (1, 'Female', 45, 'California', FALSE); INSERT INTO CommunityHealthWorkers (ID, Gender, Age, State, LGBTQ) VALUES (2, 'Male', 50, 'Califo...
What is the minimum age of community health workers who identify as LGBTQ+ in California?
SELECT MIN(Age) FROM CommunityHealthWorkers WHERE LGBTQ = TRUE AND State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE grant (id INT, researcher VARCHAR(50), gender VARCHAR(10), department VARCHAR(30), amount FLOAT, date DATE); INSERT INTO grant (id, researcher, gender, department, amount, date) VALUES (1, 'Tanvi', 'Female', 'Physics', 200000.00, '2021-01-01'), (2, 'Umair', 'Male', 'Physics', 150000.00, '2020-07-14');
Show the total number of research grants awarded to each gender, sorted by the total amount.
SELECT gender, SUM(amount) as total_amount FROM grant GROUP BY gender ORDER BY total_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE route_segments (route_id INT, segment_id INT, start_station VARCHAR(255), end_station VARCHAR(255), fare FLOAT);
What is the average fare for each route segment in the 'route_segments' table?
SELECT route_id, segment_id, AVG(fare) as avg_fare FROM route_segments GROUP BY route_id, segment_id;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_projects (project_id INT, project_name VARCHAR(100), project_cost FLOAT, year INT); INSERT INTO sustainable_projects (project_id, project_name, project_cost, year) VALUES (1, 'Green Skyscraper', 5000000, 2020), (2, 'Eco-Friendly Townhomes', 3000000, 2019), (3, 'Solar Power Plant', 8000000, 2020...
What was the total cost of all sustainable building projects in 2020?
SELECT SUM(project_cost) FROM sustainable_projects WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_transactions (transaction_time TIMESTAMP, transaction_value INT);
What is the total number of transactions and their corresponding value for the Ethereum network, grouped by day for the past week?
SELECT DATE(transaction_time) AS transaction_day, SUM(transaction_value) AS total_transaction_value, COUNT(*) AS total_transactions FROM ethereum_transactions WHERE transaction_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY) GROUP BY transaction_day;
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_canada (id INT, program_name VARCHAR(50), start_date DATE, end_date DATE, country VARCHAR(50)); INSERT INTO restorative_justice_canada (id, program_name, start_date, end_date, country) VALUES (1, 'Restorative Canada', '2015-01-01', '2018-12-31', 'Canada'), (2, 'Justice Heals', '2016-01-...
What is the total number of restorative justice programs implemented in Canada between 2015 and 2018?
SELECT SUM(id) FROM restorative_justice_canada WHERE country = 'Canada' AND start_date >= '2015-01-01' AND end_date <= '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(255), role VARCHAR(255), followers INT, created_at TIMESTAMP);
Find the average number of daily followers gained by users with the "influencer" role in Q2 2021.
SELECT AVG(followers_gained_per_day) FROM (SELECT DATEDIFF('2021-04-01', created_at) / 30.4375 AS followers_gained_per_day FROM users WHERE role = 'influencer') AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_donations (volunteer_id INT, donation DECIMAL(10, 2)); INSERT INTO volunteer_donations (volunteer_id, donation) VALUES (1, 100.00), (1, 200.00), (2, 150.00), (3, 50.00), (4, 300.00);
What are the names of volunteers who have donated more than $200 in total, and have participated in the 'Education' program?
SELECT DISTINCT volunteers.name FROM volunteers JOIN volunteer_programs ON volunteers.id = volunteer_programs.volunteer_id JOIN volunteer_donations ON volunteers.id = volunteer_donations.volunteer_id WHERE volunteer_programs.program_id = 1 AND (SELECT SUM(donation) FROM volunteer_donations WHERE volunteer_id = voluntee...
gretelai_synthetic_text_to_sql
CREATE TABLE project (name VARCHAR(50), country VARCHAR(50), year INT, wind_energy_production DECIMAL(5,2)); INSERT INTO project (name, country, year, wind_energy_production) VALUES ('Project A', 'Germany', 2019, 500.2), ('Project A', 'Germany', 2020, 522.1), ('Project B', 'Germany', 2019, 600.5), ('Project B', 'German...
Show the change in wind energy production for each project in Germany between 2019 and 2020.
SELECT name, (LEAD(wind_energy_production, 1, 0) OVER (PARTITION BY name ORDER BY year) - wind_energy_production) AS change FROM project WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthFacilities (ID INT, Name VARCHAR(100), LinguisticCompetency BOOLEAN, CulturalCompetency BOOLEAN, State VARCHAR(50)); INSERT INTO MentalHealthFacilities (ID, Name, LinguisticCompetency, CulturalCompetency, State) VALUES (1, 'Facility1', TRUE, TRUE, 'California'); INSERT INTO MentalHealthFaciliti...
Find the number of mental health facilities that provide linguistically and culturally competent services in California.
SELECT COUNT(*) FROM MentalHealthFacilities WHERE LinguisticCompetency = TRUE AND CulturalCompetency = TRUE AND State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (DishID INT, DishName VARCHAR(50), Type VARCHAR(20), Calories INT); INSERT INTO Dishes (DishID, DishName, Type, Calories) VALUES (1, 'Quinoa Salad', 'Vegan', 400), (2, 'Chickpea Curry', 'Vegan', 600), (3, 'Beef Stew', 'Non-vegan', 1200), (4, 'Veggie Burger', 'Vegan', 500), (5, 'Chicken Stir Fry', 'N...
Find the total calories for all dishes that are both vegan and gluten-free.
SELECT SUM(Calories) FROM Dishes WHERE Type = 'Vegan' AND Type = 'Gluten-free';
gretelai_synthetic_text_to_sql
CREATE TABLE news_reports (id INT, title VARCHAR(100), publication_date DATE, word_count INT); INSERT INTO news_reports (id, title, publication_date, word_count) VALUES (1, 'Climate Change Impact', '2022-03-01', 1500), (2, 'Political Turmoil in Europe', '2021-12-15', 2000), (3, 'Technology Advancements in Healthcare', ...
What is the maximum word count for news reports in the "news_reports" table published in 2021?
SELECT MAX(word_count) FROM news_reports WHERE YEAR(publication_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (title VARCHAR(100), publication VARCHAR(50), word_count INT); INSERT INTO news_articles (title, publication, word_count) VALUES ('How to reduce your carbon footprint', 'The Guardian', 1200), ('Interview with local artist', 'The Guardian', 800), ('New study reveals ocean pollution', 'The Guar...
List all news articles published by "The Guardian" that have a word count greater than 1000.
SELECT title FROM news_articles WHERE publication = 'The Guardian' AND word_count > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_data_usage (usage_id INT, subscriber_id INT, data_usage FLOAT, usage_date DATE); INSERT INTO mobile_data_usage (usage_id, subscriber_id, data_usage, usage_date) VALUES (1, 1, 200, '2022-03-01'), (2, 2, 150, '2022-03-02'), (3, 3, 250, '2022-03-03'), (4, 4, 300, '2022-03-04'), (5, 5, 400, '2022-03-05'...
What is the top 5 most data-intensive days for mobile subscribers in the current month?
SELECT usage_date, SUM(data_usage) AS total_data_usage FROM mobile_data_usage WHERE usage_date >= DATE_SUB(CURDATE(), INTERVAL DAY(CURDATE()) DAY) GROUP BY usage_date ORDER BY total_data_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_loans (id INT, customer_name VARCHAR(50), amount DECIMAL(10, 2), issue_date DATE); INSERT INTO shariah_compliant_loans (id, customer_name, amount, issue_date) VALUES (1, 'Ahmed', 5000, '2022-01-01'), (2, 'Fatima', 3000, '2022-02-14'), (3, 'Hamza', 7000, '2022-03-31');
How many Shariah-compliant loans were issued in each month of 2022?
SELECT MONTH(issue_date), COUNT(*) FROM shariah_compliant_loans WHERE issue_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY MONTH(issue_date);
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, therapy_completion BOOLEAN);
What is the average age of patients who have completed the therapy program?
SELECT AVG(age) FROM patients WHERE therapy_completion = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE nigeria_farmers (farmer_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), participation BOOLEAN); INSERT INTO nigeria_farmers (farmer_id, name, age, gender, participation) VALUES (1, 'Ada', 45, 'female', true), (2, 'Bola', 30, 'male', false), (3, 'Chidinma', 50, 'female', true);
What is the average age of female farmers who have participated in community development initiatives in Nigeria?
SELECT AVG(age) FROM nigeria_farmers WHERE gender = 'female' AND participation = true;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255), duration INT); INSERT INTO virtual_tours (tour_id, hotel_name, city, country, duration) VALUES (1, 'Hotel Taj Mahal Palace', 'Mumbai', 'India', 180), (2, 'Hotel Trident', 'Mumbai', 'India', 210);
What is the average virtual tour engagement duration in Mumbai, India?
SELECT AVG(duration) FROM virtual_tours WHERE city = 'Mumbai' AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, state TEXT);CREATE TABLE orders (id INT, customer_id INT, item_type TEXT, price DECIMAL, order_date DATE);
Who are the top 5 customers with the highest total spending on cannabis products in Michigan dispensaries in the last quarter?
SELECT c.name, SUM(o.price) as total_spending FROM customers c INNER JOIN orders o ON c.id = o.customer_id WHERE c.state = 'Michigan' AND o.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY c.name ORDER BY total_spending DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_name TEXT); INSERT INTO attorneys (attorney_id, attorney_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE cases (case_id INT, attorney_id INT, open_date DATE); INSERT INTO cases (case_id, attorney_id, open_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-...
What is the number of cases opened by each attorney?
SELECT a.attorney_name, COUNT(*) as cases_opened FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id GROUP BY a.attorney_name;
gretelai_synthetic_text_to_sql
CREATE TABLE SiteCategories (CategoryID INT, Category VARCHAR(50)); CREATE TABLE CommunityEvents (EventID INT, EventName VARCHAR(50), CategoryID INT, EventYear INT); INSERT INTO SiteCategories VALUES (1, 'Historic Building'), (2, 'National Park'), (3, 'Archaeological Site'); INSERT INTO CommunityEvents VALUES (1, 'Cult...
How many community engagement events occurred for each heritage site category?
SELECT SiteCategories.Category, COUNT(CommunityEvents.EventID) AS EventCount FROM SiteCategories INNER JOIN CommunityEvents ON SiteCategories.CategoryID = CommunityEvents.CategoryID GROUP BY SiteCategories.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50), OpenDate DATE, EnvironmentalImpactScore INT);
List the top 3 mining sites with the highest environmental impact score and their location.
SELECT SiteName, Location, EnvironmentalImpactScore FROM MiningSites WHERE SiteID IN (SELECT SiteID FROM (SELECT SiteID, RANK() OVER(ORDER BY EnvironmentalImpactScore DESC) as rnk FROM MiningSites) tmp WHERE rnk <= 3) ORDER BY EnvironmentalImpactScore DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mediation_sessions (session_id INT PRIMARY KEY, session_date DATE, session_time TIME, location VARCHAR(255), facilitator_id INT, case_number INT);
Delete a mediation session from the 'mediation_sessions' table
DELETE FROM mediation_sessions WHERE session_id = 4002 AND case_number = 2022001;
gretelai_synthetic_text_to_sql
CREATE TABLE military_exercises (id INT, name TEXT, region TEXT, year INT);INSERT INTO military_exercises (id, name, region, year) VALUES (1, 'Arctic Edge', 'Arctic', 2017);INSERT INTO military_exercises (id, name, region, year) VALUES (2, 'Northern Edge', 'Arctic', 2019);
List all military exercises that took place in the Arctic region since 2017.
SELECT name FROM military_exercises WHERE region = 'Arctic' AND year >= 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE offshore_wind_farms (id INT, name TEXT, country TEXT, start_date DATE); INSERT INTO offshore_wind_farms (id, name, country, start_date) VALUES (1, 'Gode Wind 1 and 2', 'Germany', '2014-01-01');
List the offshore wind farms in Germany and Denmark that started operation after 2010.
SELECT name, country, start_date FROM offshore_wind_farms WHERE country IN ('Germany', 'Denmark') AND start_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Events (id INT, location VARCHAR(20), event_date DATE); INSERT INTO Community_Events (id, location, event_date) VALUES (1, 'Los Angeles', '2021-02-15'), (2, 'New York', '2020-09-01');
How many community events were held in Los Angeles in 2021?
SELECT COUNT(*) FROM Community_Events WHERE location = 'Los Angeles' AND event_date BETWEEN '2021-01-01' AND '2021-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE agroecology_projects (id INT, name TEXT, total_funding FLOAT); INSERT INTO agroecology_projects (id, name, total_funding) VALUES (1, 'Project 1', 50000.0), (2, 'Project 2', 25000.0), (3, 'Project 3', 75000.0);
Which agroecology projects have the highest and lowest total funding?
SELECT name, total_funding FROM (SELECT name, total_funding, ROW_NUMBER() OVER (ORDER BY total_funding DESC) as rank FROM agroecology_projects) as ranked_projects WHERE rank = 1 OR rank = (SELECT COUNT(*) FROM agroecology_projects) ORDER BY total_funding;
gretelai_synthetic_text_to_sql
CREATE TABLE Districts (DId INT, Name VARCHAR(50)); CREATE TABLE EmergencyResponses (ResponseId INT, DId INT, Type VARCHAR(50), Date DATE, Time TIME); CREATE TABLE DisasterRecovery (RecoveryId INT, DId INT, Type VARCHAR(50), Date DATE, Time TIME);
What is the maximum number of emergency responses and disaster recovery efforts in a single day in each district, separated by type and sorted by maximum number of responses/efforts in descending order?
SELECT D.Name, ER.Type, MAX(COUNT(*)) AS MaxResponses FROM Districts D LEFT JOIN EmergencyResponses ER ON D.DId = ER.DId WHERE ER.Time BETWEEN '00:00:00' AND '23:59:59' GROUP BY D.Name, ER.Type UNION SELECT D.Name, DR.Type, MAX(COUNT(*)) AS MaxEfforts FROM Districts D LEFT JOIN DisasterRecovery DR ON D.DId = DR.DId WHE...
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameType VARCHAR(20), Revenue INT, ReleaseYear INT); INSERT INTO Games (GameID, GameType, Revenue, ReleaseYear) VALUES (1, 'VR', 5000000, 2020), (2, 'Non-VR', 7000000, 2021), (3, 'VR', 6000000, 2020), (4, 'Non-VR', 8000000, 2021), (5, 'VR', 9000000, 2020);
What is the total revenue for virtual reality games in 2020 and 2021?
SELECT GameType, ReleaseYear, SUM(Revenue) as TotalRevenue FROM Games WHERE GameType = 'VR' GROUP BY GameType, ReleaseYear
gretelai_synthetic_text_to_sql
CREATE TABLE candidate_demographics (id INT, candidate_id INT, race VARCHAR(255), offered_job BOOLEAN); INSERT INTO candidate_demographics (id, candidate_id, race, offered_job) VALUES (1, 1001, 'Hispanic', true), (2, 1002, 'African American', false), (3, 1003, 'Asian', true), (4, 1004, 'Hispanic', false);
Calculate the percentage of candidates from underrepresented racial groups who were offered a job.
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM candidate_demographics WHERE race IN ('Hispanic', 'African American')) as percentage FROM candidate_demographics WHERE offered_job = true AND race IN ('Hispanic', 'African American');
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales (drug VARCHAR(50), quarter VARCHAR(5), year INT, revenue INT); INSERT INTO drug_sales (drug, quarter, year, revenue) VALUES ('DrugA', 'Q2', 2020, 30000), ('DrugB', 'Q2', 2020, 40000), ('DrugC', 'Q2', 2020, 50000);
What is the combined sales revenue for the drugs 'DrugA' and 'DrugB' in Q2 2020?
SELECT SUM(revenue) FROM drug_sales WHERE drug IN ('DrugA', 'DrugB') AND quarter = 'Q2' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, age INT, ethnicity VARCHAR(255)); INSERT INTO community_health_workers (worker_id, age, ethnicity) VALUES (1, 35, 'Hispanic'), (2, 40, 'African American'), (3, 30, 'Asian'), (4, 45, 'Caucasian');
Delete the record for the community health worker who is 30 years old.
DELETE FROM community_health_workers WHERE age = 30;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, country VARCHAR(20), investment_date DATE); INSERT INTO investments (id, country, investment_date) VALUES (1, 'Kenya', '2022-01-01'), (2, 'Nigeria', '2022-03-15'), (3, 'Kenya', '2022-04-05'), (4, 'Egypt', '2021-09-01');
Determine the number of network infrastructure investments made by each country in the Africa region over the past year.
SELECT country, COUNT(*) as num_investments FROM investments WHERE region = 'Africa' AND investment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE audience_demographics (id INT PRIMARY KEY, age INT, country VARCHAR(255), gender VARCHAR(255));
Update the "age" field to 35 for all records in the "audience_demographics" table where "country" is "Brazil" and "gender" is "Female"
UPDATE audience_demographics SET age = 35 WHERE country = 'Brazil' AND gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Position, Department) VALUES (3, 'Sara', 'Ali', 'Engineer', 'Aircraft Manufacturing');
Who are the engineers in the aircraft manufacturing department with IDs lower than 5?
SELECT EmployeeID, FirstName, LastName FROM Employees WHERE Department = 'Aircraft Manufacturing' AND Position = 'Engineer' AND EmployeeID < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (id INT, volunteer_id INT, year INT, num_hours INT); INSERT INTO volunteer_hours (id, volunteer_id, year, num_hours) VALUES (1, 1, 2019, 100), (2, 1, 2020, 150), (3, 2, 2019, 75), (4, 2, 2020, 200), (5, 3, 2019, 125), (6, 3, 2020, 175);
What is the average number of hours volunteered per volunteer each year?
SELECT year, AVG(num_hours) as avg_hours_per_volunteer FROM volunteer_hours GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, home_location VARCHAR(50), monthly_data_usage DECIMAL(10,2)); INSERT INTO mobile_subscribers (subscriber_id, home_location, monthly_data_usage) VALUES (1, 'USA', 3.5), (2, 'Mexico', 4.2), (3, 'Canada', 2.8), (4, 'USA', 4.5), (5, 'Canada', 3.2);
What is the maximum and minimum monthly data usage for each country?
SELECT home_location, MAX(monthly_data_usage) AS max_data_usage, MIN(monthly_data_usage) AS min_data_usage FROM mobile_subscribers GROUP BY home_location;
gretelai_synthetic_text_to_sql
CREATE TABLE EventOrganizers (OrganizerID INT, OrgName VARCHAR(50), Country VARCHAR(50)); INSERT INTO EventOrganizers (OrganizerID, OrgName, Country) VALUES (1, 'ESL', 'Germany'), (2, 'DreamHack', 'Sweden'), (3, 'MLG', 'USA');
Which country has the most esports event organizers?
SELECT Country, COUNT(*) as EventOrganizerCount FROM EventOrganizers GROUP BY Country ORDER BY EventOrganizerCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE EmergencyResponse (Id INT, IncidentId INT, ResponseTeam VARCHAR(50), ResponseTime INT, IncidentType VARCHAR(50)); CREATE VIEW EmergencyResponse_Team AS SELECT ResponseTeam, AVG(ResponseTime) as AvgResponseTime FROM EmergencyResponse WHERE IncidentType = 'Medical' GROUP BY ResponseTeam;
What is the average response time for medical emergencies, broken down by response team, where the average response time is greater than 15 minutes?
SELECT ert.ResponseTeam, AVG(ert.AvgResponseTime) as AvgResponseTime FROM EmergencyResponse_Team ert WHERE ert.AvgResponseTime > 15 GROUP BY ert.ResponseTeam;
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (id INT, name TEXT, crop TEXT, yield_per_acre FLOAT, region TEXT); INSERT INTO Farm (id, name, crop, yield_per_acre, region) VALUES (1, 'Smith Farm', 'Corn', 150, 'Midwest'), (2, 'Jones Farm', 'Soybeans', 80, 'Midwest'), (3, 'Brown Farm', 'Corn', 200, 'Western'), (4, 'Green Farm', 'Potatoes', 200, 'No...
List all the farms in the Western region that have a higher yield per acre for corn compared to the average yield per acre for corn in the entire database.
SELECT * FROM Farm WHERE region = 'Western' AND crop = 'Corn' AND yield_per_acre > (SELECT avg_yield FROM Average WHERE crop = 'Corn');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_project (project_id INT, project_name TEXT, project_type TEXT, start_date DATE); INSERT INTO climate_project (project_id, project_name, project_type, start_date) VALUES (1, 'North American Wind Farm', 'Mitigation', '2012-01-01');
How many climate mitigation projects were completed in North America before 2015?
SELECT COUNT(*) FROM climate_project WHERE project_type = 'Mitigation' AND start_date < DATEADD(year, -3, '2015-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(50), attorney_email VARCHAR(50), attorney_phone VARCHAR(15)); INSERT INTO attorneys (attorney_id, attorney_name, attorney_email, attorney_phone) VALUES (3, 'Sara White', 'sara.white@lawfirm.com', '555-555-2121');
Show the attorney_name and attorney_email for all attorneys in the 'attorneys' table
SELECT attorney_name, attorney_email FROM attorneys;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (region VARCHAR(255), usage FLOAT, date DATE); INSERT INTO water_usage (region, usage, date) VALUES ('New York', 5000, '2022-05-01'); INSERT INTO water_usage (region, usage, date) VALUES ('Los Angeles', 7000, '2022-05-01');
List the top 3 regions with the highest water usage in the past month.
SELECT region, usage FROM (SELECT region, usage, ROW_NUMBER() OVER (ORDER BY usage DESC) as rank FROM water_usage WHERE date >= '2022-05-01' GROUP BY region, usage) subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategies (id INT, company_name VARCHAR(100), exit_type VARCHAR(50), acquisition_price FLOAT, exit_date DATE);
Insert a new exit strategy into the "exit_strategies" table for 'India Inc.' with an acquisition price of $50M on 2021-10-01
INSERT INTO exit_strategies (id, company_name, exit_type, acquisition_price, exit_date) VALUES (7, 'India Inc.', 'Acquisition', 50000000, '2021-10-01');
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (sensor_id INT, crop_type VARCHAR(255), soil_moisture DECIMAL(5,2), record_date DATE);
Update soil moisture records for a specific sensor_id if the moisture level is below a specified threshold.
UPDATE sensor_data SET soil_moisture = 50 WHERE sensor_id = 2 AND soil_moisture < 20.0;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), state VARCHAR(2), training_programs VARCHAR(100)); INSERT INTO community_health_workers (worker_id, name, state, training_programs) VALUES (1, 'Jane Doe', 'NY', 'Cultural Competency, First Aid'); INSERT INTO community_health_workers (worker_id, nam...
Identify cultural competency training programs offered by community health workers in NY and CA.
SELECT state, training_programs FROM community_health_workers WHERE state IN ('NY', 'CA') AND training_programs LIKE '%Cultural Competency%';
gretelai_synthetic_text_to_sql
CREATE TABLE european_tourism (destination VARCHAR(255), year INT, quarter INT, visitors INT); INSERT INTO european_tourism (destination, year, quarter, visitors) VALUES ('Barcelona', 2021, 1, 800000); INSERT INTO european_tourism (destination, year, quarter, visitors) VALUES ('Barcelona', 2021, 2, 900000); INSERT INTO...
What is the percentage change in international visitor numbers for each destination in Europe compared to the same quarter last year?
SELECT destination, year, quarter, visitors, NTILE(4) OVER (ORDER BY visitors) as quartile, (visitors - LAG(visitors) OVER (PARTITION BY destination ORDER BY year, quarter))*100.0 / LAG(visitors) OVER (PARTITION BY destination ORDER BY year, quarter) as pct_change FROM european_tourism;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtWorks (ArtworkID int, Title varchar(100), Value int, Period varchar(100));
Find the total value of artworks created in the Impressionist period.
SELECT SUM(Value) FROM ArtWorks WHERE Period = 'Impressionist'
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude FLOAT, longitude FLOAT);
Create a table named "stations" with columns "station_id", "name", "latitude", and "longitude".
CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude FLOAT, longitude FLOAT);
gretelai_synthetic_text_to_sql
CREATE SCHEMA MarineLife; CREATE TABLE Species (id INT, name TEXT, biomass FLOAT); CREATE SCHEMA Geography; CREATE TABLE Habitats (id INT, species_id INT, region_type TEXT);
What is the total biomass of marine life species in the 'MarineLife' schema's cold-water regions?
SELECT SUM(s.biomass) FROM MarineLife.Species s JOIN MarineLife.Habitats h ON s.id = h.species_id WHERE h.region_type = 'cold-water';
gretelai_synthetic_text_to_sql
CREATE TABLE social_responsibility.transactions (transaction_id INT, account_number INT, transaction_amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO social_responsibility.transactions (transaction_id, account_number, transaction_amount, transaction_date) VALUES (1, 1001, 100.00, '2022-01-01'), (2, 1002, 200....
What is the total value of transactions for socially responsible lending accounts in the 'social_responsibility' schema's 'transactions' table, excluding transactions made within the last 30 days?
SELECT SUM(transaction_amount) FROM social_responsibility.transactions WHERE account_number IN (SELECT account_number FROM social_responsibility.accounts WHERE is_socially_responsible = true) AND transaction_date < NOW() - INTERVAL '30 days';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), rate FLOAT); INSERT INTO recycling_rates (id, material, rate) VALUES (1, 'cotton', 0.75), (2, 'wool', 0.60), (3, 'polyester', 0.50), (4, 'silk', 0.80);
What is the average recycling rate for each material type in the 'recycling_rates' table?
SELECT material, AVG(rate) FROM recycling_rates GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID int, Department varchar(50)); INSERT INTO Students (StudentID, Department) VALUES (5, 'Physics'); CREATE TABLE Grants (GrantID int, StudentID int, Department varchar(50), Amount int); INSERT INTO Grants (GrantID, StudentID, Department, Amount) VALUES (7, 5, 'Physics', 3000); INSERT INTO...
What is the total amount of research grants awarded to graduate students in each department?
SELECT Students.Department, SUM(Grants.Amount) FROM Students INNER JOIN Grants ON Students.StudentID = Grants.StudentID GROUP BY Students.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_name TEXT, country TEXT, trial_phase TEXT, trial_date DATE); INSERT INTO clinical_trials (trial_name, country, trial_phase, trial_date) VALUES ('Trial1', 'Germany', 'Phase1', '2008-03-23'), ('Trial2', 'Japan', 'Phase3', '2006-07-09'), ('Trial3', 'Germany', 'Phase2', '2009-11-17'), ('...
Count the number of clinical trials conducted in Germany and Japan before 2010, grouped by trial phase.
SELECT trial_phase, COUNT(*) FROM clinical_trials WHERE country IN ('Germany', 'Japan') AND trial_date < '2010-01-01' GROUP BY trial_phase;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, event_name VARCHAR(255), event_type VARCHAR(255), city_id INT);CREATE TABLE attendees (id INT, event_id INT, attendee_name VARCHAR(255));
Show the number of public events and the number of attendees for each event in the city of San Francisco.
SELECT e.event_name, COUNT(a.id) as num_attendees FROM events e INNER JOIN attendees a ON e.id = a.event_id WHERE e.city_id = (SELECT id FROM cities WHERE city_name = 'San Francisco') GROUP BY e.id;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_id INT, delivery_location VARCHAR(20), shipped_date DATE, weight FLOAT); INSERT INTO warehouse (id, name) VALUES (1, 'Seattle'), (2, 'NY'), (3, 'LA'), (4, 'Paris'), (5, 'London'), (6, 'Melbourne'); INSERT INTO shipment (id, ware...
What is the maximum weight of packages shipped to 'Sydney' from the 'Melbourne' warehouse in April 2021?
SELECT MAX(weight) AS max_weight FROM shipment WHERE warehouse_id = 6 AND delivery_location = 'Sydney' AND shipped_date >= '2021-04-01' AND shipped_date < '2021-05-01';
gretelai_synthetic_text_to_sql