context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE customers (customer_id INT, purchase_date DATE); INSERT INTO customers (customer_id, purchase_date) VALUES (1, '2021-01-01'), (2, '2021-02-01'), (3, '2021-01-15'), (4, '2021-04-01'), (5, '2021-07-01');
How many new customers made a purchase in each quarter of 2021?
SELECT DATE_TRUNC('quarter', purchase_date) as quarter, COUNT(DISTINCT customer_id) as new_customers FROM customers WHERE purchase_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans (loan_id INT, region_id INT, loan_amount DECIMAL(10, 2)); INSERT INTO socially_responsible_loans (loan_id, region_id, loan_amount) VALUES (1, 1, 3000.00), (2, 1, 4000.00), (3, 2, 5000.00), (4, 2, 2500.00), (5, 3, 6000.00), (6, 3, 7000.00); CREATE TABLE regions (region_id INT, reg...
Find the top 2 regions with the highest average socially responsible loan amounts, and display their names and average loan amounts.
SELECT region_name, AVG(loan_amount) AS avg_loan_amount FROM socially_responsible_loans JOIN regions ON socially_responsible_loans.region_id = regions.region_id GROUP BY region_name ORDER BY avg_loan_amount DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, strain TEXT, yield INT, month INT); INSERT INTO production (id, strain, yield, month) VALUES (1, 'Purple Haze', 120, 6), (2, 'Green Crack', 150, 7), (3, 'OG Kush', 135, 6), (4, 'Purple Haze', 110, 5);
What is the average production yield for the month of June?
SELECT AVG(yield) FROM production WHERE month = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (CHWId INT, Name VARCHAR(50), State VARCHAR(50)); CREATE TABLE CulturalCompetencyTrainings (TrainingId INT, CHWId INT, TrainingDate DATE); INSERT INTO CommunityHealthWorkers (CHWId, Name, State) VALUES (1, 'Jasmine', 'Florida'), (2, 'Kareem', 'Texas'), (3, 'Leah', 'California'); INSE...
List unique cultural competency training dates for community health workers in Florida.
SELECT CHW.Name, TrainingDate FROM CommunityHealthWorkers CHW INNER JOIN CulturalCompetencyTrainings CCT ON CHW.CHWId = CCT.CHWId WHERE CHW.State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_plans (id INT, plan_name VARCHAR(50), monthly_fee FLOAT, num_subscribers INT); INSERT INTO broadband_plans (id, plan_name, monthly_fee, num_subscribers) VALUES (1, 'Plan A', 60.0, 1000); INSERT INTO broadband_plans (id, plan_name, monthly_fee, num_subscribers) VALUES (2, 'Plan B', 70.0, 1500); IN...
What is the top broadband plan in terms of the number of subscribers and its monthly fee?
SELECT plan_name, monthly_fee, num_subscribers FROM (SELECT plan_name, monthly_fee, num_subscribers, RANK() OVER (ORDER BY num_subscribers DESC, monthly_fee DESC) as rn FROM broadband_plans) x WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales (sale_date DATE, customer_country VARCHAR(50), sale_value INT); CREATE TABLE Geopolitical_Risk_Assessments (assessment_date DATE, customer_country VARCHAR(50), risk_score INT); INSERT INTO Military_Equipment_Sales (sale_date, customer_country, sale_value) VALUES ('2020-01-01', 'Chi...
What is the geopolitical risk assessment score for China on the earliest military equipment sale date?
SELECT R.customer_country, MIN(M.sale_date) AS earliest_sale_date, R.risk_score AS risk_assessment_score FROM Military_Equipment_Sales M JOIN Geopolitical_Risk_Assessments R ON M.customer_country = R.customer_country WHERE M.sale_date = (SELECT MIN(sale_date) FROM Military_Equipment_Sales) GROUP BY R.customer_country, ...
gretelai_synthetic_text_to_sql
CREATE TABLE assistive_tech (id INT, device VARCHAR(50), type VARCHAR(50), description TEXT, users INT, country VARCHAR(50)); INSERT INTO assistive_tech (id, device, type, description, users, country) VALUES (3, 'Learning App', 'Mobile App', 'A mobile app that promotes digital literacy among children.', 200000, 'India'...
What is the total number of users for mobile apps that promote digital literacy in India and China?
SELECT country, SUM(users) as total_users FROM assistive_tech WHERE country IN ('India', 'China') AND type = 'Mobile App' AND description LIKE '%digital literacy%' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(255), publication_date DATE, topic VARCHAR(50), news_org VARCHAR(50)); INSERT INTO articles (id, title, publication_date, topic, news_org) VALUES (1, 'Article1', '2021-01-01', 'Media Representation', 'Org1'), (2, 'Article2', '2021-02-15', 'Politics', 'Org2'), (3, 'Article3',...
What percentage of articles published by news organizations in Europe in 2021 focused on media representation?
SELECT (COUNT(*) FILTER (WHERE topic = 'Media Representation'))::DECIMAL / COUNT(*) AS media_representation_percentage FROM articles WHERE YEAR(publication_date) = 2021 AND news_org LIKE '%Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Department VARCHAR(50), AdvisorID INT); INSERT INTO GraduateStudents (StudentID, Name, Department, AdvisorID) VALUES (1001, 'Sara Smith', 'Computer Science', 2001), (1002, 'Bob Brown', 'Physics', NULL), (1003, 'Charlie Davis', 'Mathematics', 3001);
Delete records of graduate students who have not selected an advisor
DELETE FROM GraduateStudents WHERE AdvisorID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (type VARCHAR(50), city VARCHAR(50), system VARCHAR(50), lines INT, last_updated DATE, PRIMARY KEY (type, city, system));
Insert a new record into the "public_transportation" table with the following values: "Light Rail", "Los Angeles", "Metro", 12, "2022-01-01"
INSERT INTO public_transportation (type, city, system, lines, last_updated) VALUES ('Light Rail', 'Los Angeles', 'Metro', 12, '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, district TEXT, year INT, cases INT); INSERT INTO cases (id, district, year, cases) VALUES (1, 'DistrictA', 2020, 25), (2, 'DistrictA', 2021, 30), (3, 'DistrictB', 2020, 10), (4, 'DistrictB', 2021, 40);
Which districts had the highest number of disaster response cases in 2020 and 2021?
SELECT district, MAX(cases) FROM cases WHERE year IN (2020, 2021) GROUP BY district ORDER BY MAX(cases) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE aus_tourism (year INT, visitors INT); INSERT INTO aus_tourism (year, visitors) VALUES (2015, 6000000), (2016, 6500000), (2017, 7000000), (2018, 7500000), (2019, 8000000), (2020, 5000000), (2021, 5500000), (2022, 6000000), (2023, 6500000);
What is the average number of visitors per year for Australia between 2015 and 2023?
SELECT AVG(visitors) FROM aus_tourism WHERE year BETWEEN 2015 AND 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (species TEXT, ocean TEXT, biomass INT); INSERT INTO marine_life (species, ocean, biomass) VALUES ('Whale Shark', 'Indian Ocean', 2000), ('Manta Ray', 'Indian Ocean', 300), ('Tuna', 'Indian Ocean', 150), ('Dolphin', 'Indian Ocean', 100);
What is the total biomass of all marine life in the Indian Ocean, restricted to species with a recorded biomass greater than 500?
SELECT SUM(biomass) FROM marine_life WHERE ocean = 'Indian Ocean' AND biomass > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists policyholders (policyholder_id INT, first_name VARCHAR(50), last_name VARCHAR(50), state VARCHAR(2), policy_type VARCHAR(20), annual_premium DECIMAL(10,2)); INSERT INTO policyholders (policyholder_id, first_name, last_name, state, policy_type, annual_premium) VALUES (1, 'John', 'Doe', 'CA', '...
List policyholders in California with auto insurance policies and their respective annual premiums, sorted by the premium in descending order.
SELECT policyholder_id, first_name, last_name, annual_premium FROM policyholders WHERE state = 'CA' AND policy_type = 'Auto' ORDER BY annual_premium DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE case_outcomes (case_id INT, outcome TEXT, precedent TEXT);
Show all unique legal precedents mentioned in case outcomes
SELECT DISTINCT precedent FROM case_outcomes;
gretelai_synthetic_text_to_sql
CREATE TABLE public_works (id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO public_works (id, project_name, location) VALUES (1, 'Park Development', 'City F'), (2, 'Sidewalk Construction', 'Neighborhood G'), (3, 'Street Lighting', 'District H');
Find the total number of projects in the 'public_works' table.
SELECT COUNT(*) FROM public_works;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (diplomacy_id INT, event_name VARCHAR(50), participant_country VARCHAR(50), event_date DATE, event_description TEXT);
Show all records in the defense_diplomacy table where the participant_country is 'United States' or 'Canada'
SELECT * FROM defense_diplomacy WHERE participant_country IN ('United States', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); CREATE TABLE inspections (inspection_id INT, restaurant_id INT, violation_count INT, date DATE);
How many food safety inspections were conducted for Restaurant Y in 2022?
SELECT COUNT(*) as inspection_count FROM inspections i WHERE i.restaurant_id = (SELECT restaurant_id FROM restaurants WHERE name = 'Restaurant Y') AND i.date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name VARCHAR(100), cause VARCHAR(50), hours DECIMAL(5, 2)); INSERT INTO volunteers VALUES (1, 'John Doe', 'Environment', 25); INSERT INTO volunteers VALUES (2, 'Jane Smith', 'Animals', 15);
List all volunteers who have contributed more than 20 hours in total, along with the number of hours they have volunteered and the causes they supported.
SELECT name, cause, SUM(hours) as total_hours FROM volunteers WHERE hours > 20 GROUP BY name, cause;
gretelai_synthetic_text_to_sql
CREATE TABLE Product (ProductID INT, ProductName VARCHAR(50), HasVeganIngredients BOOLEAN); CREATE TABLE Rating (RatingID INT, ProductID INT, Rating INT); INSERT INTO Product (ProductID, ProductName, HasVeganIngredients) VALUES (101, 'Organic Lipstick', TRUE), (102, 'Natural Mascara', FALSE), (103, 'Vegan Foundation', ...
What is the average rating of beauty products with vegan ingredients?
SELECT AVG(r.Rating) as AverageRating FROM Product p JOIN Rating r ON p.ProductID = r.ProductID WHERE p.HasVeganIngredients = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholder (id INT, name VARCHAR(50), policy_type VARCHAR(50)); CREATE TABLE claims (id INT, policyholder_id INT, claim_amount DECIMAL(10, 2)); INSERT INTO policyholder (id, name, policy_type) VALUES (1, 'John Doe', 'Auto'); INSERT INTO policyholder (id, name, policy_type) VALUES (2, 'Jane Smith', 'Home'...
List the top 3 policy types with the highest claim frequency, ordered by claim frequency in descending order.
SELECT policy_type, COUNT(*) OVER (PARTITION BY policy_type) as claim_frequency FROM policyholder p JOIN claims c ON p.id = c.policyholder_id GROUP BY policy_type ORDER BY claim_frequency DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (id INT, strain VARCHAR(255), added_date DATE);
Insert a new record for 'Purple Haze' strain in the Inventory table with an added date of 2021-08-01.
INSERT INTO Inventory (strain, added_date) VALUES ('Purple Haze', '2021-08-01');
gretelai_synthetic_text_to_sql
CREATE TABLE project_timeline (project VARCHAR(255), type VARCHAR(255), year INT, region VARCHAR(255));
How many climate adaptation projects were initiated in South America in 2021?
SELECT COUNT(*) FROM project_timeline WHERE type = 'climate adaptation' AND year = 2021 AND region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE cruelty_free_sales AS SELECT sales_regions.*, products.is_cruelty_free FROM sales_regions JOIN products ON sales_regions.product_id = products.product_id;
Find the total number of cruelty-free products sold in each region.
SELECT regions.region_name, SUM(CASE WHEN cruelty_free_sales.is_cruelty_free = true THEN 1 ELSE 0 END) as total_cruelty_free_sales FROM regions JOIN cruelty_free_sales ON regions.region_id = cruelty_free_sales.region_id GROUP BY regions.region_name
gretelai_synthetic_text_to_sql
CREATE TABLE astrophysics_research (id INT, year INT, cost FLOAT);INSERT INTO astrophysics_research (id, year, cost) VALUES (1, 2018, 1000000.0), (2, 2019, 1200000.0), (3, 2018, 1500000.0), (4, 2019, 800000.0);
What is the total cost of astrophysics research for each year?
SELECT year, SUM(cost) FROM astrophysics_research GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices (date DATE, region VARCHAR(255), price FLOAT); INSERT INTO carbon_prices (date, region, price) VALUES ('2020-01-01', 'EU ETS', 25), ('2020-02-01', 'EU ETS', 26), ('2021-01-01', 'EU ETS', 30), ('2021-02-01', 'EU ETS', 32);
What was the average carbon price in the EU ETS in 2020 and 2021?
SELECT AVG(price) as avg_price, YEAR(date) as year FROM carbon_prices WHERE region = 'EU ETS' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_variety (variety_id INT, add_date DATE); INSERT INTO crop_variety (variety_id, add_date) VALUES (1001, '2021-04-03'), (1002, '2021-05-17'), (1003, '2021-04-01'), (1004, '2021-05-15'), (1005, '2021-03-30');
How many new crop varieties were added in the past month?
SELECT COUNT(*) FROM crop_variety WHERE add_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND add_date < CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE SpeciesLocation (ID INT, Species VARCHAR(50), Location VARCHAR(50), Count INT, ObservationDate DATE); INSERT INTO SpeciesLocation (ID, Species, Location, Count, ObservationDate) VALUES (1, 'Starfish', 'Atlantic', 300, '2020-01-01'), (2, 'Dolphin', 'Pacific', 250, '2020-01-02'), (3, 'Shark', 'Atlantic', 400...
Show the most common marine species by location.
SELECT Location, Species, Count, RANK() OVER (PARTITION BY Location ORDER BY Count DESC) as Rank FROM SpeciesLocation;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage_site (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year_of_establishment INT); INSERT INTO cultural_heritage_site (id, name, location, year_of_establishment) VALUES (1, 'Himeji Castle', 'Japan', 1333);
List the cultural heritage sites in Japan and their establishment years, sorted by establishment year.
SELECT chs.name, chs.year_of_establishment FROM cultural_heritage_site chs WHERE chs.location = 'Japan' ORDER BY chs.year_of_establishment;
gretelai_synthetic_text_to_sql
CREATE TABLE ipl (team VARCHAR(50), matches_won INT); INSERT INTO ipl (team, matches_won) VALUES ('Mumbai Indians', 125), ('Chennai Super Kings', 110), ('Kolkata Knight Riders', 100);
Which team won the most matches in the IPL?
SELECT team, SUM(matches_won) AS total_matches_won FROM ipl GROUP BY team ORDER BY total_matches_won DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT PRIMARY KEY, name VARCHAR(50), city VARCHAR(50), adopted_circular_practices BOOLEAN); INSERT INTO factories (id, name, city, adopted_circular_practices) VALUES (1, 'Green Manufacturing', 'New York', true), (2, 'EcoStitch', 'Los Angeles', false), (3, 'Circular Weaves', 'Chicago', true), (4...
What is the number of factories in each city that have adopted circular economy practices, ordered by city?
SELECT city, COUNT(*) as num_factories FROM factories WHERE adopted_circular_practices = true GROUP BY city ORDER BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(20)); INSERT INTO Policy VALUES (1, 'Auto'), (2, 'Home'), (3, 'Life'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Claims VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 3000), (4, 3, 25000), (5, 2, 2000);
What is the policy type with the highest average claim amount?
SELECT PolicyType, AVG(ClaimAmount) as AvgClaimAmount FROM Policy P JOIN Claims C ON P.PolicyID = C.PolicyID GROUP BY PolicyType ORDER BY AvgClaimAmount DESC FETCH FIRST 1 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (state VARCHAR(50), race_ethnicity VARCHAR(50), workers INT); INSERT INTO community_health_workers (state, race_ethnicity, workers) VALUES ('California', 'Hispanic', 200), ('California', 'White', 150), ('Texas', 'Hispanic', 250), ('Texas', 'White', 100), ('New York', 'Black', 180),...
Delete all community health workers for California with the race/ethnicity of White?
DELETE FROM community_health_workers WHERE state = 'California' AND race_ethnicity = 'White';
gretelai_synthetic_text_to_sql
CREATE TABLE food_justice_contributors (id INT, name TEXT, contributions FLOAT); INSERT INTO food_justice_contributors (id, name, contributions) VALUES (1, 'Contributor 1', 25000.0), (2, 'Contributor 2', 30000.0), (3, 'Contributor 3', 15000.0), (4, 'Contributor 4', 20000.0);
Who are the top 2 contributors to food justice initiatives in Asia?
SELECT name, contributions FROM (SELECT name, contributions, ROW_NUMBER() OVER (ORDER BY contributions DESC) as rank FROM food_justice_contributors WHERE country = 'Asia') as ranked_contributors WHERE rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (Id INT, Project VARCHAR(255), StartDate DATE, EndDate DATE); INSERT INTO DefenseProjects (Id, Project, StartDate, EndDate) VALUES (3, 'Air Defense System', '2017-01-01', '2021-12-31'); INSERT INTO DefenseProjects (Id, Project, StartDate, EndDate) VALUES (4, 'Drone Surveillance', '2019-06-1...
Identify defense projects with a duration greater than the average project duration.
SELECT Project, DATEDIFF(day, StartDate, EndDate) as ProjectDuration FROM DefenseProjects WHERE DATEDIFF(day, StartDate, EndDate) > (SELECT AVG(DATEDIFF(day, StartDate, EndDate)) FROM DefenseProjects);
gretelai_synthetic_text_to_sql
CREATE TABLE smoking_data (id INT, age_group VARCHAR(20), country VARCHAR(20), smokers INT); INSERT INTO smoking_data (id, age_group, country, smokers) VALUES (1, '18-24', 'India', 5000), (2, '25-34', 'India', 8000), (3, '35-44', 'India', 10000);
What is the percentage of smokers in India by age group?
SELECT age_group, smokers * 100 / (SELECT SUM(smokers) FROM smoking_data WHERE country = 'India') FROM smoking_data WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_ethical BOOLEAN, revenue FLOAT); INSERT INTO products (product_id, product_name, is_ethical, revenue) VALUES (1, 'Organic Cotton T-Shirt', TRUE, 25.99), (2, 'Regular Cotton T-Shirt', FALSE, 19.99);
What is the total revenue generated from ethical product sales in the United States?
SELECT SUM(revenue) FROM products WHERE is_ethical = TRUE AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, project_type VARCHAR(255), initiator VARCHAR(255), initiated_year INT, capacity FLOAT);
Insert a new record into the 'renewable_energy_projects' table for a wind farm project initiated by 'WindForce' in 2018 with a capacity of 500 MW
INSERT INTO renewable_energy_projects (id, project_type, initiator, initiated_year, capacity) VALUES (1, 'wind farm', 'WindForce', 2018, 500);
gretelai_synthetic_text_to_sql
CREATE TABLE claims (id INT, policy_id INT, claim_amount INT); INSERT INTO claims (id, policy_id, claim_amount) VALUES (1, 1, 1500), (2, 2, 2500), (3, 3, 1000); CREATE TABLE policies (id INT, state VARCHAR(2)); INSERT INTO policies (id, state) VALUES (1, 'NY'), (2, 'TX'), (3, 'CA');
What is the average claim amount for policies in 'TX'?
SELECT AVG(claim_amount) FROM claims JOIN policies ON claims.policy_id = policies.id WHERE policies.state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, product VARCHAR(20), size INT, country VARCHAR(10), date DATE); INSERT INTO Sales (id, product, size, country, date) VALUES (1, 'dress', 14, 'USA', '2021-08-01'), (2, 'shirt', 12, 'Canada', '2021-09-15');
How many size 14 dresses were sold in the US in the last quarter?
SELECT COUNT(*) FROM Sales WHERE product = 'dress' AND size = 14 AND country = 'USA' AND date >= '2021-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), size INT);
Add a new habitat preservation record into the habitats table
INSERT INTO habitats (id, name, location, size) VALUES (1, 'Snow Leopard Habitat', 'Himalayas', 12000);
gretelai_synthetic_text_to_sql
CREATE TABLE expedition (org VARCHAR(20), depth INT); INSERT INTO expedition VALUES ('Ocean Explorer', 2500), ('Ocean Explorer', 3000), ('Sea Discoverers', 2000), ('Marine Investigators', 4000), ('Marine Investigators', 4500);
Which organization has the highest average expedition depth?
SELECT org, AVG(depth) AS avg_depth FROM expedition GROUP BY org ORDER BY avg_depth DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (preference_id INT, consumer_id INT, product_id INT, shade VARCHAR(255), country VARCHAR(255)); INSERT INTO consumer_preferences (preference_id, consumer_id, product_id, shade, country) VALUES (1, 1, 1, 'Light Beige', 'USA'), (2, 2, 1, 'Medium Beige', 'Canada'), (3, 3, 2, 'Dark Beige',...
What is the most preferred foundation shade among consumers in the US?
SELECT shade, COUNT(*) AS preference_count FROM consumer_preferences WHERE product_id = 1 AND country = 'USA' GROUP BY shade ORDER BY preference_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE PersonalInjuryCases (CaseID INT, CaseType VARCHAR(20), AttorneyLastName VARCHAR(20), BillingAmount DECIMAL(10,2)); INSERT INTO PersonalInjuryCases (CaseID, CaseType, AttorneyLastName, BillingAmount) VALUES (1, 'Personal Injury', 'Williams', 5000.00), (2, 'Personal Injury', 'Brown', 2000.00);
List all unique attorney last names who have billed for cases in the 'Personal Injury' case type.
SELECT DISTINCT AttorneyLastName FROM PersonalInjuryCases WHERE CaseType = 'Personal Injury';
gretelai_synthetic_text_to_sql
CREATE TABLE ExplainableAIs (ID INT, Model VARCHAR(255), Explainability_Score FLOAT, Date DATE, Company_Location VARCHAR(255)); INSERT INTO ExplainableAIs (ID, Model, Explainability_Score, Date, Company_Location) VALUES (1, 'ModelX', 0.88, '2022-07-25', 'USA'), (2, 'ModelY', 0.79, '2022-08-12', 'Canada'), (3, 'ModelZ',...
What is the minimum explainability score for AI models created in Q3 2022, by companies located in North America?
SELECT MIN(Explainability_Score) as Min_Score FROM ExplainableAIs WHERE Date BETWEEN '2022-07-01' AND '2022-09-30' AND Company_Location IN ('USA', 'Canada', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE BusinessPartnerships(id INT, business_id INT, hotel_id INT); INSERT INTO BusinessPartnerships(id, business_id, hotel_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, null); CREATE TABLE LocalBusinesses(id INT, name TEXT, country TEXT); INSERT INTO LocalBusinesses(id, name, country) VALUES (1, 'Surf Shop', 'Australi...
How many local businesses have partnered with hotels in Australia?
SELECT COUNT(*) FROM BusinessPartnerships JOIN LocalBusinesses ON BusinessPartnerships.business_id = LocalBusinesses.id JOIN Hotels ON BusinessPartnerships.hotel_id = Hotels.id WHERE LocalBusinesses.country = 'Australia' AND Hotels.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE LinenProduction (id INT, country VARCHAR, water_usage DECIMAL);
What is the average water usage for linen production in France?
SELECT AVG(water_usage) FROM LinenProduction WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_uk (id INT, product_name TEXT, consumer_preference FLOAT, country TEXT); INSERT INTO cosmetics_uk (id, product_name, consumer_preference, country) VALUES (1, 'Lipstick', 4.2, 'UK'), (2, 'Foundation', 4.5, 'UK'), (3, 'Mascara', 4.7, 'USA');
What are the top 2 preferred cosmetic products by consumers from the United Kingdom?
SELECT product_name, consumer_preference FROM cosmetics_uk WHERE country = 'UK' ORDER BY consumer_preference DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2), transaction_date DATE);
Identify customers who have had a balance greater than $10,000 for at least two consecutive months, partitioned by account type.
SELECT customer_id, account_type, balance FROM (SELECT customer_id, account_type, balance, transaction_date, COUNT(*) OVER (PARTITION BY customer_id, account_type, grp) AS consecutive_months FROM (SELECT customer_id, account_type, balance, transaction_date, SUM(CASE WHEN balance > 10000 THEN 1 ELSE 0 END) OVER (PARTITI...
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT PRIMARY KEY, name VARCHAR(100), update_date DATE); INSERT INTO regulatory_frameworks (framework_id, name, update_date) VALUES (1, 'Framework1', '2022-01-15'), (2, 'Framework2', '2022-02-01'), (3, 'Framework3', '2022-03-05');
Which regulatory frameworks in the blockchain domain have been updated in the last month?
SELECT * FROM regulatory_frameworks WHERE update_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT, category TEXT, publication_date DATE, word_count INT, author_id INT);
What is the total number of articles published in the "articles" table for each unique combination of day and month?
SELECT EXTRACT(MONTH FROM publication_date) AS month, EXTRACT(DAY FROM publication_date) AS day, COUNT(*) AS articles_per_day_month FROM articles GROUP BY month, day ORDER BY month, day;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (building_id INT, city VARCHAR(255), energy_efficiency FLOAT); INSERT INTO buildings (building_id, city, energy_efficiency) VALUES (1, 'Berlin', 150), (2, 'Berlin', 160), (3, 'Berlin', 140), (4, 'Berlin', 170), (5, 'Berlin', 130), (6, 'Paris', 180), (7, 'Paris', 190), (8, 'Paris', 175), (9, 'Lond...
What is the average energy efficiency (in kWh/m2) of buildings in the city of London?
SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE site (site_id INT, site_name VARCHAR(50)); CREATE TABLE reactor (reactor_id INT, site_id INT, temperature DECIMAL(5,2)); INSERT INTO site (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'); INSERT INTO reactor (reactor_id, site_id, temperature) VALUES (1, 1, 85), (2, 1, 75), (3, 2, 78), (4, 2, 68);
Show the percentage of reactors that exceed the maximum temperature limit (80 degrees Celsius) per site.
SELECT site_name, 100.0 * AVG(CASE WHEN temperature > 80 THEN 1 ELSE 0 END) AS pct_exceeded FROM reactor JOIN site ON reactor.site_id = site.site_id GROUP BY site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE BudgetAllocation (Department VARCHAR(25), Location VARCHAR(25), Budget INT); INSERT INTO BudgetAllocation (Department, Location, Budget) VALUES ('Education', 'City A', 10000000), ('Health', 'City A', 8000000), ('Education', 'City B', 12000000);
What is the total budget allocated for education services in urban areas?
SELECT SUM(Budget) FROM BudgetAllocation WHERE Department = 'Education' AND Location = 'City A';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, name TEXT, country TEXT, capacity_mw FLOAT); INSERT INTO wind_farms (id, name, country, capacity_mw) VALUES (1, 'Windfarm 1', 'Germany', 120.5), (2, 'Windfarm 2', 'Germany', 250.6);
What is the total capacity (MW) of wind farms in Germany?
SELECT SUM(capacity_mw) FROM wind_farms WHERE country = 'Germany' AND technology = 'onshore';
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_costs (id INT, fabric_id INT, production_cost FLOAT); INSERT INTO fabric_costs (id, fabric_id, production_cost) VALUES (1, 1, 3.2), (2, 2, 4.1), (3, 3, 2.8), (4, 4, 3.9), (5, 5, 4.5);
Which sustainable fabric has the lowest production cost?
SELECT f.name, MIN(fc.production_cost) as lowest_cost FROM fabrics f JOIN fabric_costs fc ON f.id = fc.fabric_id WHERE f.sustainability_rating >= 4 GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, project VARCHAR(50), status VARCHAR(10)); INSERT INTO community_development (id, project, status) VALUES (1, 'Water Supply', 'Completed'), (2, 'School Building', 'In Progress'), (3, 'Road Construction', 'Completed');
List all unique types of 'community_development' projects and their statuses.
SELECT DISTINCT project, status FROM community_development;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, customer_id INT, dish TEXT, dish_type TEXT, location TEXT); INSERT INTO orders (id, customer_id, dish, dish_type, location) VALUES (1, 1, 'Veggie Pizza', 'Vegetarian', 'Texas'); INSERT INTO orders (id, customer_id, dish, dish_type, location) VALUES (2, 1, 'Falafel', 'Vegetarian', 'Texas'); ...
List the top 5 most ordered vegetarian dishes by customers in Texas?
SELECT dish, dish_type, COUNT(*) AS orders_count FROM orders WHERE location = 'Texas' AND dish_type = 'Vegetarian' GROUP BY dish, dish_type ORDER BY orders_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE DepartmentExhibits (department_name TEXT, exhibit_name TEXT, visitor_count INTEGER); INSERT INTO DepartmentExhibits (department_name, exhibit_name, visitor_count) VALUES ('Art', 'Impressionism', 2000), ('Art', 'Cubism', 1500), ('History', 'Ancient Egypt', 3000); CREATE TABLE DepartmentTotals (department_na...
Find the top 3 departments with the highest average visitor counts for their temporary exhibitions.
SELECT department_name, AVG(visitor_count) AS avg_visitor_count FROM DepartmentExhibits GROUP BY department_name ORDER BY avg_visitor_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE FoiaRequests ( RequestId INT, RequestDate DATE, RequestCity VARCHAR(255) ); INSERT INTO FoiaRequests (RequestId, RequestDate, RequestCity) VALUES (1, '2021-01-01', 'New York'), (2, '2020-01-01', 'New York'), (3, '2019-01-01', 'New York');
What is the oldest FOIA request in the city of New York?
SELECT RequestCity, MIN(RequestDate) OVER (PARTITION BY RequestCity) as OldestRequestDate FROM FoiaRequests WHERE RequestCity = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE token_holders (holder_id INT, address VARCHAR(42), asset_id INT, balance DECIMAL(20, 2));
Who are the top 10 token holders of a specific digital asset?
SELECT ah.address, SUM(th.balance) FROM token_holders th JOIN digital_assets da ON th.asset_id = da.asset_id GROUP BY ah.address ORDER BY SUM(th.balance) DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Base (Country VARCHAR(50), Region VARCHAR(50), Number INT); INSERT INTO Base (Country, Region, Number) VALUES ('United States', 'Asia-Pacific', 120), ('Japan', 'Asia-Pacific', 20), ('South Korea', 'Asia-Pacific', 30), ('Australia', 'Asia-Pacific', 15), ('Philippines', 'Asia-Pacific', 10);
How many military bases does the US have in the Asia-Pacific region?
SELECT Country, Region, Number FROM Base WHERE Country = 'United States' AND Region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, country TEXT, rd_expenditure FLOAT); INSERT INTO company (id, name, country, rd_expenditure) VALUES (1, 'ABC Pharma', 'France', 12000000); INSERT INTO company (id, name, country, rd_expenditure) VALUES (2, 'XYZ Labs', 'France', 15000000); INSERT INTO company (id, name, country, ...
What is the minimum R&D expenditure for companies located in France?
SELECT MIN(rd_expenditure) FROM company WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists mental_health_parity_laws (law_id INT, state VARCHAR(255), enactment_date DATE); INSERT INTO mental_health_parity_laws (law_id, state, enactment_date) VALUES (1, 'California', '2010-09-30'), (2, 'New York', '2016-04-01'), (3, 'Texas', '2017-06-01');
Which mental health parity laws were enacted in California?
SELECT state, enactment_date FROM mental_health_parity_laws WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE ship_inspections (id INT, inspection_date DATE, region TEXT, tonnage INT); INSERT INTO ship_inspections (id, inspection_date, region, tonnage) VALUES (1, '2020-01-01', 'Caribbean', 800), (2, '2020-02-01', 'Caribbean', 900), (3, '2019-01-01', 'Caribbean', 700);
How many ships were inspected in the 'Caribbean' sea in the year 2020, and what was the average tonnage of those ships?
SELECT COUNT(*), AVG(tonnage) FROM ship_inspections WHERE region = 'Caribbean' AND inspection_date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city VARCHAR(255), year INT, material_type VARCHAR(255), amount INT); INSERT INTO waste_generation (city, year, material_type, amount) VALUES ('San Francisco', 2020, 'Plastic', 1500), ('San Francisco', 2020, 'Paper', 2000), ('San Francisco', 2020, 'Glass', 1000);
What is the total waste generation by material type in the city of San Francisco in 2020?
SELECT material_type, SUM(amount) FROM waste_generation WHERE city = 'San Francisco' AND year = 2020 GROUP BY material_type;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (product_id INT, product_name VARCHAR(30), is_non_gmo BOOLEAN); INSERT INTO inventory (product_id, product_name, is_non_gmo) VALUES (1, 'Quinoa Salad', true), (2, 'Chicken Stir Fry', false);
How many non-GMO products are available?
SELECT COUNT(*) FROM inventory WHERE is_non_gmo = true;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (id INT, units INT, PRIMARY KEY (id)); INSERT INTO inclusive_housing (id, units) VALUES (1, 50), (2, 75), (3, 100), (4, 80);
How many inclusive housing units exist in the 'inclusive_housing' table?
SELECT COUNT(*) FROM inclusive_housing;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'Chicago', 'Chicago'), (2, 'New York', 'New York'); CREATE TABLE Handling (id INT, shipment_id INT, warehouse_id INT, pallets INT); INSERT INTO Handling (id, shipment_id, warehouse_id, pallets) VALUES ...
How many pallets were handled by each warehouse?
SELECT Warehouse.name, SUM(Handling.pallets) FROM Handling JOIN Warehouse ON Handling.warehouse_id = Warehouse.id GROUP BY Handling.warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_health_indicators (indicator_id INT PRIMARY KEY, indicator_name VARCHAR(255)); CREATE TABLE farm_locations (location_id INT PRIMARY KEY, location_name VARCHAR(255), country VARCHAR(255), ocean VARCHAR(255)); CREATE TABLE ocean_health_metrics (metric_id INT PRIMARY KEY, location_id INT, indicator_id I...
Create a view that displays ocean health metrics by location and year
CREATE VIEW ocean_health_metrics_by_location_year AS SELECT ohm.location_id, ohm.year, ohi.indicator_name, ohm.value FROM ocean_health_metrics ohm JOIN ocean_health_indicators ohi ON ohm.indicator_id = ohi.indicator_id JOIN farm_locations fl ON ohm.location_id = fl.location_id;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, total_assets DECIMAL(10,2)); INSERT INTO customers (customer_id, total_assets) VALUES (1, 50000), (2, 75000), (3, 30000), (4, 60000), (5, 80000); CREATE TABLE investments (customer_id INT, stock_symbol VARCHAR(5), investment_amount DECIMAL(10,2)); INSERT INTO investments (custom...
Calculate the average assets of customers who have invested in stock 'GOOG' or 'AMZN'
SELECT AVG(customers.total_assets) FROM customers INNER JOIN investments ON customers.customer_id = investments.customer_id WHERE investments.stock_symbol IN ('GOOG', 'AMZN');
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_hash VARCHAR(255), gas_limit INT, timestamp TIMESTAMP); INSERT INTO transactions (id, transaction_hash, gas_limit, timestamp) VALUES (1, '0x123...', 21000, '2022-01-01 00:00:00'), (2, '0x456...', 22000, '2022-01-02 12:34:56'), (3, '0x789...', 20000, '2022-01-15 14:23:01');
What is the average gas limit for transactions in the last 30 days?
SELECT AVG(gas_limit) as avg_gas_limit FROM transactions WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE diving_expeditions (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, fuel_cost FLOAT);
What is the total amount spent on fuel for diving expeditions in the last year?
SELECT SUM(fuel_cost) FROM diving_expeditions WHERE date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE();
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.studies (id INT, name VARCHAR(100), location VARCHAR(100)); INSERT INTO genetics.studies (id, name, location) VALUES (1, 'StudyA', 'Toronto'), (2, 'StudyB', 'Montreal'), (3, 'StudyC', 'Vancouver');
Which genetic research studies have been conducted in Canada?
SELECT name FROM genetics.studies WHERE location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, units INT); CREATE TABLE products (product_id INT, product_name VARCHAR(50), product_type VARCHAR(50));
How many units of each garment type were sold in 2021?
SELECT p.product_type, SUM(s.units) as total_units FROM sales s JOIN products p ON s.product_id = p.product_id WHERE s.sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY p.product_type;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_virtual_tours (hotel TEXT, region TEXT, has_virtual_tour BOOLEAN); INSERT INTO hotel_virtual_tours (hotel, region, has_virtual_tour) VALUES ('Hotel Mumbai', 'Asia', true), ('Hotel Tokyo', 'Asia', false), ('Hotel Bangkok', 'Asia', true), ('Hotel Seoul', 'Asia', false), ('Hotel Jakarta', 'Asia', true);
What is the number of hotels in 'Asia' that offer virtual tours?
SELECT COUNT(*) FROM hotel_virtual_tours WHERE region = 'Asia' AND has_virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO sports_teams (team_id, team_name) VALUES (1, 'TeamA'), (2, 'TeamB'); CREATE TABLE ticket_sales (ticket_id INT, team_id INT, price DECIMAL(5,2)); INSERT INTO ticket_sales (ticket_id, team_id, price) VALUES (1, 1, 75.50), (2, 1, 85.20), (3, 2, 65...
Show the total revenue for each sports team
SELECT s.team_name, SUM(t.price) FROM sports_teams s INNER JOIN ticket_sales t ON s.team_id = t.team_id GROUP BY s.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (equipment_id INT, customer_country VARCHAR(50), sale_price DECIMAL(10,2)); CREATE TABLE Contracts (contract_id INT, customer_country VARCHAR(50)); INSERT INTO MilitaryEquipmentSales (equipment_id, customer_country, sale_price) VALUES (1, 'Indonesia', 500000.00), (2, 'Singapore', 900...
Find the number of military equipment sales to ASEAN countries and the number of contracts with those countries.
SELECT COUNT(*) FROM MilitaryEquipmentSales WHERE customer_country IN ('Indonesia', 'Singapore', 'Thailand', 'Malaysia', 'Philippines', 'Vietnam', 'Myanmar', 'Cambodia', 'Brunei', 'Laos') UNION SELECT COUNT(*) FROM Contracts WHERE customer_country IN ('Indonesia', 'Singapore', 'Thailand', 'Malaysia', 'Philippines', 'Vi...
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Seafood_Restaurants (id INT, name VARCHAR(255), continent VARCHAR(255), revenue INT); INSERT INTO Sustainable_Seafood_Restaurants (id, name, continent, revenue) VALUES (1, 'SustainaSea', 'Europe', 500000), (2, 'OceanWise', 'North America', 800000), (3, 'SeaTrue', 'Asia', 700000), (4, 'BlueFish'...
What is the number of sustainable seafood restaurants in each continent and their total revenue?
SELECT continent, COUNT(*), SUM(revenue) FROM Sustainable_Seafood_Restaurants GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (site VARCHAR(255), score INT); INSERT INTO environmental_impact (site, score) VALUES ('Site A', 80), ('Site B', 70), ('Site C', 90), ('Site D', 60), ('Site E', 100);
Identify mining sites with the highest environmental impact scores
SELECT ei.site, ei.score FROM environmental_impact ei ORDER BY ei.score DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_units (unit_id INT, commanding_officer VARCHAR(20));
Update peacekeeping units with unit_id 104, 105, and 106 with commanding officers "Officer D", "Officer E", and "Officer F"
UPDATE peacekeeping_units SET commanding_officer = CASE unit_id WHEN 104 THEN 'Officer D' WHEN 105 THEN 'Officer E' WHEN 106 THEN 'Officer F' ELSE commanding_officer END WHERE unit_id IN (104, 105, 106);
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_sessions (session_id INT, duration INT, country VARCHAR(255)); INSERT INTO therapy_sessions (session_id, duration, country) VALUES (1, 60, 'Australia'); INSERT INTO therapy_sessions (session_id, duration, country) VALUES (2, 90, 'Australia');
What is the maximum duration of therapy sessions in Australia?
SELECT MAX(duration) FROM therapy_sessions WHERE country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE construction_projects (id INT, city VARCHAR(20), completion_date DATE);
Delete records from construction_projects table where city is 'NewTown' and completion_date is NULL
DELETE FROM construction_projects WHERE city = 'NewTown' AND completion_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (maintenance_id INT, equipment_type TEXT, state TEXT, request_date DATE); INSERT INTO equipment_maintenance (maintenance_id, equipment_type, state, request_date) VALUES (1, 'Helicopter', 'Texas', '2022-01-10'), (2, 'Tank', 'Texas', '2021-12-20'), (3, 'Helicopter', 'Texas', '2022-05-05...
List military equipment maintenance requests for helicopters in Texas in the last 6 months, along with the number of requests.
SELECT equipment_type, COUNT(*) as requests FROM equipment_maintenance WHERE equipment_type = 'Helicopter' AND state = 'Texas' AND request_date >= '2021-12-01' GROUP BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ContractNegotiations (ContractID INT, Company VARCHAR(50), Equipment VARCHAR(50), NegotiationDate DATE, ContractValue DECIMAL(10, 2)); INSERT INTO ContractNegotiations (ContractID, Company, Equipment, NegotiationDate, ContractValue) VALUES (5, 'Raytheon', 'Drone Technology', '2022-01-10', 12000000); INSERT...
Which defense contractor has the highest contract value for drone technology?
SELECT ContractID, Company, Equipment, NegotiationDate, ContractValue, RANK() OVER(PARTITION BY Equipment ORDER BY ContractValue DESC) AS HighestValueContract FROM ContractNegotiations WHERE Equipment = 'Drone Technology'
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_chains (chain_id INT, chain_name TEXT, country TEXT, heritage_rating INT); INSERT INTO hotel_chains (chain_id, chain_name, country, heritage_rating) VALUES (1, 'GreenJapan', 'Japan', 85), (2, 'HeritageInn', 'Japan', 90);
Who are the top 2 hotel chains in Japan with the highest cultural heritage preservation ratings?
SELECT chain_name FROM hotel_chains WHERE country = 'Japan' ORDER BY heritage_rating DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE MarginalizedArtists (id INT, region VARCHAR(20), year INT, community VARCHAR(50), exhibitions INT); INSERT INTO MarginalizedArtists (id, region, year, community, exhibitions) VALUES (15, 'Caribbean', 2019, 'Marginalized', 3); INSERT INTO MarginalizedArtists (id, region, year, community, exhibitions) VALUES...
How many artists from historically marginalized communities had exhibitions in the Caribbean in 2019?
SELECT SUM(exhibitions) FROM MarginalizedArtists WHERE region = 'Caribbean' AND year = 2019 AND community = 'Marginalized';
gretelai_synthetic_text_to_sql
CREATE TABLE Investments (CustomerID INT, Market VARCHAR(20), Value DECIMAL(10,2)); INSERT INTO Investments (CustomerID, Market, Value) VALUES (1, 'US', 5000); INSERT INTO Investments (CustomerID, Market, Value) VALUES (2, 'Canada', 3000);
Which customers have investments in both the US and Canadian stock markets?
SELECT CustomerID FROM Investments WHERE Market = 'US' INTERSECT SELECT CustomerID FROM Investments WHERE Market = 'Canada'
gretelai_synthetic_text_to_sql
CREATE TABLE CircularEconomyFactories (id INT, factory_location VARCHAR(255), is_circular_economy BOOLEAN); INSERT INTO CircularEconomyFactories (id, factory_location, is_circular_economy) VALUES (1, 'Milan, Italy', true), (2, 'Paris, France', false), (3, 'Berlin, Germany', true);
How many factories are producing garments using circular economy principles in Europe?
SELECT COUNT(*) FROM CircularEconomyFactories WHERE factory_location LIKE '%Europe%' AND is_circular_economy = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (program_id INT, target_group VARCHAR(50), funding_amount DECIMAL(10,2), funding_date DATE); INSERT INTO Programs (program_id, target_group, funding_amount, funding_date) VALUES (4, 'seniors', 8000.00, '2021-04-01'), (5, 'children', 6000.00, '2021-05-01'), (6, 'adults', 3000.00, '2021-06-01');
What was the total funding received by programs targeting 'seniors'?
SELECT SUM(funding_amount) AS total_funding FROM Programs WHERE target_group = 'seniors';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, gender TEXT, state TEXT, disease TEXT); INSERT INTO patients (id, age, gender, state, disease) VALUES (1, 25, 'Female', 'California', 'Chlamydia'); INSERT INTO patients (id, age, gender, state, disease) VALUES (2, 30, 'Male', 'California', 'Chlamydia');
What is the average age of patients who tested positive for chlamydia in California?
SELECT AVG(age) FROM patients WHERE state = 'California' AND disease = 'Chlamydia';
gretelai_synthetic_text_to_sql
CREATE TABLE agri_patents (id INT, patent_number INT, title TEXT, team_leader TEXT, grant_year INT); INSERT INTO agri_patents (id, patent_number, title, team_leader, grant_year) VALUES (1, 12345, 'Smart Irrigation System', 'Sarah Johnson', 2017), (2, 67890, 'Vertical Farming Design', 'Alex Thompson', 2018), (3, 11121, ...
How many agricultural innovation patents were granted to women-led teams between 2017 and 2021?
SELECT COUNT(*) FROM agri_patents WHERE team_leader LIKE '%[Ww]%' AND grant_year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE fishing_regulations (id INT, region VARCHAR(50), regulation VARCHAR(50)); INSERT INTO fishing_regulations (id, region, regulation) VALUES (1, 'Southern Ocean', 'Commercial fishing ban'); INSERT INTO fishing_regulations (id, region, regulation) VALUES (2, 'Southern Ocean', 'Antarctic krill fishing quota');
Delete all records in the 'fishing_regulations' table where the 'region' is 'Southern Ocean'
DELETE FROM fishing_regulations WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjectTypes (TypeID INT, TypeName VARCHAR(50));CREATE TABLE RenewableEnergyProjects (ProjectID INT, TypeID INT, EnergyConsumption FLOAT, EnergySavings FLOAT);
Show the total energy consumption and total energy savings for each renewable energy project type.
SELECT RenewableEnergyProjectTypes.TypeName, SUM(RenewableEnergyProjects.EnergyConsumption) AS TotalEnergyConsumption, SUM(RenewableEnergyProjects.EnergySavings) AS TotalEnergySavings FROM RenewableEnergyProjectTypes INNER JOIN RenewableEnergyProjects ON RenewableEnergyProjectTypes.TypeID = RenewableEnergyProjects.Type...
gretelai_synthetic_text_to_sql
CREATE TABLE TrainSchedules (id INT, station VARCHAR(255), delay INT, schedule_time TIME); CREATE TABLE Stations (id INT, city VARCHAR(255));
How many train delays occurred in NYC during rush hours in Q1 2022?
SELECT COUNT(*) FROM TrainSchedules TS INNER JOIN Stations S ON TS.station = S.id WHERE S.city = 'NYC' AND HOUR(schedule_time) BETWEEN 6 AND 10 AND delay > 0 AND QUARTER(schedule_time) = 1 AND YEAR(schedule_time) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE items (item_id INT, category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO items (item_id, category, price) VALUES (1, 'Organic Food', 50.00), (2, 'Sustainable Home Goods', 100.00), (3, 'Organic Food', 75.00);
What is the maximum price of items in the 'Organic Food' category?
SELECT category, MAX(price) as max_price FROM items WHERE category = 'Organic Food' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(50), sector VARCHAR(50), total_funding DECIMAL(10,2)); INSERT INTO biotech.startups (id, name, sector, total_funding) VALUES (1, 'StartupA', 'Genetic Research', 5000000.00), (2, 'StartupB', 'Biosensor Technology', 3000...
What is the total funding for startups in the 'Bioprocess Engineering' sector?
SELECT SUM(total_funding) FROM biotech.startups WHERE sector = 'Bioprocess Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(100)); CREATE TABLE smart_contracts (contract_id INT, developer_id INT, transaction_fee DECIMAL(10,2)); INSERT INTO developers (developer_id, name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); INSERT INTO smart_contracts (contract_id, developer_id, transaction...
List the names and total transaction fees for all developers who have created smart contracts in the 'developers_smart_contracts' table.
SELECT d.name, SUM(sc.transaction_fee) as total_fees FROM developers d JOIN smart_contracts sc ON d.developer_id = sc.developer_id GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Strategies (id INT, name VARCHAR(50), year INT, continent VARCHAR(50)); INSERT INTO Strategies (id, name, year, continent) VALUES (1, 'National Security Strategy 2008', 2008, 'North America'); INSERT INTO Strategies (id, name, year, continent) VALUES (2, 'National Security Strategy 2010', 2010, 'Europe');
What is the total number of national security strategies implemented before 2010 in the 'Strategies' table?
SELECT COUNT(*) FROM Strategies WHERE year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication(project_name TEXT, country TEXT, budget FLOAT); INSERT INTO climate_communication(project_name, country, budget) VALUES ('Project M', 'Argentina', 50000.00), ('Project N', 'Brazil', 60000.00), ('Project O', 'Colombia', 70000.00), ('Project P', 'Peru', 80000.00);
What is the total budget for climate communication projects in each country in South America?
SELECT country, SUM(budget) FROM climate_communication GROUP BY country;
gretelai_synthetic_text_to_sql