context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), quarter INT, year INT, rate DECIMAL(5,2));
Create a view to show the average recycling rate by material type for the first quarter of 2021.
CREATE VIEW avg_recycling_rates AS SELECT material, AVG(rate) AS avg_rate FROM recycling_rates WHERE quarter = 1 AND year = 2021 GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE bias_evaluations (id INT, algorithm_name VARCHAR(50), biased BOOLEAN);
List the unique algorithms used for bias evaluation in the 'bias_evaluations' table.
SELECT DISTINCT algorithm_name FROM bias_evaluations WHERE biased = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, state VARCHAR(2));CREATE TABLE petitions (id INT PRIMARY KEY, user_id INT, title VARCHAR(255));
Find the total number of petitions submitted by users from 'NY' and 'CA' in the 'petitions' table, excluding duplicate entries.
SELECT COUNT(DISTINCT p.id) FROM petitions p JOIN users u ON p.user_id = u.id WHERE u.state IN ('NY', 'CA');
gretelai_synthetic_text_to_sql
CREATE TABLE trees (id INT, species VARCHAR(50), volume DECIMAL(10,2)); INSERT INTO trees (id, species, volume) VALUES (1, 'Oak', 12.50), (2, 'Maple', 15.00), (3, 'Pine', 20.00), (4, 'Spruce', 18.50);
Show the total volume of timber harvested in each forest
SELECT f.name, SUM(h.volume) FROM forests f JOIN harvests h ON f.id = h.forest_id JOIN trees t ON h.tree_id = t.id GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME, HistoricalSignificance TEXT); INSERT INTO Artifacts (ArtifactID, Name, CreationDate, HistoricalSignificance) VALUES (1, 'Ancient Dagger', '1500-01-01', 'Ceremonial weapon of ancient civilization');
Which artifact has the latest creation date, and what is its historical significance?
SELECT Name, HistoricalSignificance FROM (SELECT Name, CreationDate, HistoricalSignificance, ROW_NUMBER() OVER (ORDER BY CreationDate DESC) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50));INSERT INTO oceans (ocean_id, name) VALUES (1, 'Arctic'), (2, 'Antarctic'), (3, 'Pacific');CREATE TABLE sightings (sighting_id INT, species VARCHAR(50), ocean_id INT);INSERT INTO sightings (sighting_id, species, ocean_id) VALUES (1, 'Blue Whale', 1), (2, 'Beluga Whal...
Find the number of whale sightings in the Arctic and Antarctic oceans.
SELECT COUNT(*) FROM sightings WHERE species LIKE '%Whale%' AND ocean_id IN (1, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTests (Id INT, TestType VARCHAR(50), VehicleId INT, TestDate DATE); CREATE TABLE AutonomousVehicles (Id INT, Name VARCHAR(100), Program VARCHAR(50)); INSERT INTO SafetyTests (Id, TestType, VehicleId, TestDate) VALUES (1, 'Lane Keeping', 1, '2020-01-10'); INSERT INTO SafetyTests (Id, TestType, Vehicle...
What is the total number of safety tests performed in the autonomous driving research program?
SELECT COUNT(*) FROM SafetyTests INNER JOIN AutonomousVehicles ON SafetyTests.VehicleId = AutonomousVehicles.Id WHERE AutonomousVehicles.Program = 'ResearchProgram';
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (vehicle_id INT, vehicle_type VARCHAR(20), max_speed INT); INSERT INTO Vehicles (vehicle_id, vehicle_type, max_speed) VALUES (1, 'AutonomousCar', 120), (2, 'ManualCar', 150), (3, 'AutonomousCar', 130);
Find the 'vehicle_id' of the 'AutonomousCar' with the highest 'max_speed' in the 'Vehicles' table
SELECT vehicle_id FROM Vehicles WHERE vehicle_type = 'AutonomousCar' AND max_speed = (SELECT MAX(max_speed) FROM Vehicles WHERE vehicle_type = 'AutonomousCar');
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, region VARCHAR(20)); INSERT INTO clients (client_id, region) VALUES (1, 'Eastern Europe'), (2, 'Western Europe'), (3, 'Eastern Europe'); CREATE TABLE assets (asset_id INT, client_id INT, value INT); INSERT INTO assets (asset_id, client_id, value) VALUES (1, 1, 5000), (2, 1, 7000), (...
What is the average assets value for clients in the Eastern Europe region?
SELECT AVG(value) FROM assets JOIN clients ON assets.client_id = clients.client_id WHERE clients.region = 'Eastern Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (cost_id INT, project_type VARCHAR(20), labor_cost DECIMAL(5,2)); INSERT INTO labor_costs (cost_id, project_type, labor_cost) VALUES (1, 'Residential', 15000), (2, 'Commercial', 35000), (3, 'Public', 25000);
What is the average labor cost per project type?
SELECT project_type, AVG(labor_cost) as avg_labor_cost FROM labor_costs GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, founder TEXT, exit_strategy_valuation FLOAT, country TEXT); INSERT INTO startups(id, name, founder, exit_strategy_valuation, country) VALUES (1, 'Acme Inc', 'John Doe', 50000000.00, 'US'), (2, 'Beta Corp', 'Jane Smith', 75000000.00, 'UK'), (3, 'Gamma Startup', 'Pedro Sanchez', 1...
What is the maximum exit strategy valuation for startups founded by immigrants in the US?
SELECT MAX(exit_strategy_valuation) FROM startups WHERE founder IN ('John Doe', 'Pedro Sanchez') AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation(project_name TEXT, country TEXT, budget FLOAT); INSERT INTO climate_mitigation(project_name, country, budget) VALUES ('Project P', 'USA', 800000.00), ('Project Q', 'Brazil', 900000.00), ('Project R', 'South Africa', 700000.00);
What is the maximum budget for climate mitigation projects in each continent?
SELECT country, MAX(budget) FROM climate_mitigation GROUP BY (CASE WHEN country = 'USA' THEN 'North America' WHEN country = 'Brazil' THEN 'South America' WHEN country = 'South Africa' THEN 'Africa' END);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (region VARCHAR(255), amount INT); INSERT INTO carbon_sequestration (region, amount) VALUES ('Amazon', 2000), ('Congo', 1500), ('Boreal', 1800), ('Temperate', 1200);
What is the average carbon sequestration for the 'Temperate' region?
SELECT AVG(amount) FROM carbon_sequestration WHERE region = 'Temperate';
gretelai_synthetic_text_to_sql
CREATE TABLE consumers (consumer_id INT, consumer_name VARCHAR(100), product_id INT, purchases INT); INSERT INTO consumers VALUES (1, 'Alice', 2, 100), (2, 'Bob', 1, 200), (3, 'Charlie', 3, 150), (4, 'David', 2, 250), (5, 'Eve', 1, 300); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions...
Who are the top 5 consumers of non-cruelty-free cosmetics in the USA?
SELECT consumer_name, purchases FROM consumers JOIN products ON consumers.product_id = products.product_id WHERE certification != 'cruelty-free' AND region_name = 'USA' ORDER BY purchases DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, author VARCHAR(50), title VARCHAR(100), category VARCHAR(50), word_count INT, publication_date DATE);
What is the total number of articles published in each category, and what percentage does each category represent of the total number of articles?
SELECT category, COUNT(article_id) AS articles_in_category, 100.0 * COUNT(article_id) / (SELECT COUNT(article_id) FROM articles) AS category_percentage FROM articles GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteLaunch ( id INT, satellite_name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO SatelliteLaunch (id, satellite_name, country, launch_date) VALUES (1, 'Sat1', 'USA', '2018-12-12'), (2, 'Sat2', 'China', '2020-04-05'), (3, 'Sat3', 'India', '2021-02-20'), (4, 'Sat4', 'Russia', '2021...
Which countries have launched the most satellites?
SELECT country, COUNT(*) AS satellites_launched FROM SatelliteLaunch GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_energy (project_id INT, project_name VARCHAR(255), country VARCHAR(255), commissioned_date DATE);
Delete all solar energy projects in Spain that were commissioned before 2010.
DELETE FROM solar_energy WHERE country = 'Spain' AND commissioned_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_latinx VARCHAR(10)); INSERT INTO Companies (id, name, industry, country, founding_year, founder_latinx) VALUES (1, 'GreenTech', 'Renewable Energy', 'Mexico', 2019, 'Yes'); INSERT INTO Companies (id, n...
What is the percentage of companies founded by Latinx individuals in each country?
SELECT country, ROUND(100.0 * SUM(CASE WHEN founder_latinx = 'Yes' THEN 1 ELSE 0 END) / COUNT(*), 2) as latinx_percentage FROM Companies GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE SalesReps (SalesRepID INT, SalesRepName VARCHAR(50), FiscalYear INT, Revenue DECIMAL(10,2), Country VARCHAR(50)); INSERT INTO SalesReps (SalesRepID, SalesRepName, FiscalYear, Revenue, Country) VALUES (1, 'John Doe', 2022, 150000.00, 'USA'), (2, 'Jane Smith', 2022, 200000.00, 'Canada'), (3, 'Marie Johnson',...
What is the total military equipment sales revenue by country for the current fiscal year?
SELECT Country, SUM(Revenue) OVER (PARTITION BY Country ORDER BY Country) AS TotalRevenue FROM SalesReps WHERE FiscalYear = YEAR(GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, city TEXT); INSERT INTO eco_hotels (hotel_id, name, city) VALUES (1, 'New Eco Hotel Rome', 'Rome'), (2, 'Green Hotel Rome', 'Rome');
How many eco-friendly hotels are there in Rome?
SELECT COUNT(*) FROM eco_hotels WHERE city = 'Rome';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_health (id INT PRIMARY KEY, metric VARCHAR(255), value DECIMAL(5,2));
Update the value for Phosphorus metric in the ocean_health table
UPDATE ocean_health SET value = 0.12 WHERE metric = 'Phosphorus';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_manufacturers2 (manufacturer_id INT, drug_name TEXT, manufacturer TEXT, sales FLOAT, region TEXT); INSERT INTO drug_manufacturers2 (manufacturer_id, drug_name, manufacturer, sales, region) VALUES (1, 'DrugM', 'Manufacturer4', 9000000, 'Europe'), (2, 'DrugN', 'Manufacturer5', 10000000, 'Europe');
What is the total sales for each drug by manufacturer in Europe?
SELECT manufacturer, SUM(sales) as total_sales FROM drug_manufacturers2 WHERE region = 'Europe' GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (ID INT, EventName VARCHAR(255), EventType VARCHAR(255), EventDate DATE);
How many events of each type were held in the last 3 years, and what was their total attendance?
SELECT e.EventType, COUNT(e.ID) as EventCount, SUM(a.Attendees) as TotalAttendance FROM Events e JOIN (SELECT EventID, COUNT(DISTINCT VisitorID) as Attendees FROM Attendance GROUP BY EventID) a ON e.ID = a.EventID WHERE e.EventDate >= DATEADD(year, -3, GETDATE()) GROUP BY e.EventType;
gretelai_synthetic_text_to_sql
CREATE TABLE Contracts (ID INT, Vendor TEXT, Amount DECIMAL(10,2), Quarter INT); INSERT INTO Contracts (ID, Vendor, Amount, Quarter) VALUES (1, 'Vendor A', 150000.00, 4), (2, 'Vendor B', 250000.00, 4);
Insert new contract records for contracts awarded in Q4 2021
INSERT INTO Contracts (ID, Vendor, Amount, Quarter) VALUES (3, 'Vendor C', 300000.00, 4), (4, 'Vendor D', 100000.00, 4);
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (Language_Name VARCHAR(50), Continent VARCHAR(50), Number_Speakers INT, Endangered BOOLEAN); INSERT INTO Languages (Language_Name, Continent, Number_Speakers, Endangered) VALUES ('English', 'North America', 330000000, FALSE), ('Spanish', 'South America', 410000000, FALSE), ('Hindi', 'Asia', 63000...
What are the total number of speakers and number of endangered languages in each continent, excluding Antarctica?
SELECT Continent, SUM(Number_Speakers) AS Total_Speakers, COUNT(*) AS Endangered_Languages FROM Languages WHERE Continent NOT IN ('Antarctica') GROUP BY Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityEngagement (id INT, community VARCHAR(255), contribution FLOAT); INSERT INTO CommunityEngagement (id, community, contribution) VALUES (1, 'Chinese Community', 0.30), (2, 'Indian Community', 0.25), (3, 'Indigenous Australian Community', 0.20);
Who are the top 3 contributing communities in heritage site preservation?
SELECT community, contribution FROM CommunityEngagement ORDER BY contribution DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(50), Gender VARCHAR(10), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Department, Gender, Salary, HireDate) VALUES (1, 'IT', 'Male', 85000, '2021-04-20'), (2, 'HR', 'Female', 75000, '2019-12-15'), (3, 'IT', 'Female', 80000, '2020-01-08'), (4...
What is the maximum salary for male employees hired before June 2021?
SELECT MAX(Salary) FROM Employees WHERE Gender = 'Male' AND HireDate < '2021-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Suburbs'); CREATE TABLE students (student_id INT, student_name TEXT, district_id INT, mental_health_score INT); INSERT INTO students (student_id, student_name, dis...
What is the maximum mental health score for students in each district?
SELECT districts.district_name, MAX(students.mental_health_score) FROM districts JOIN students ON districts.district_id = students.district_id GROUP BY districts.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_price DECIMAL(5,2), label VARCHAR(255));
What is the total revenue for products with 'organic' label in the 'sales' table?
SELECT SUM(sale_price) FROM sales WHERE label = 'organic';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_plans (plan_id INT, plan_name VARCHAR(50), download_speed INT, upload_speed INT, price DECIMAL(5,2), contract_length INT, created_at TIMESTAMP);
Update the download speed for a broadband plan in the broadband_plans table
UPDATE broadband_plans SET download_speed = 400 WHERE plan_id = 3001;
gretelai_synthetic_text_to_sql
CREATE TABLE green_apartments (unit_id INT, num_bedrooms INT, square_footage FLOAT); INSERT INTO green_apartments (unit_id, num_bedrooms, square_footage) VALUES (1, 2, 800.0), (2, 1, 600.0), (3, 2, 900.0);
What is the total number of 3-bedroom units in the green_apartments table?
SELECT SUM(CASE WHEN num_bedrooms = 3 THEN 1 ELSE 0 END) FROM green_apartments;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT PRIMARY KEY, brand VARCHAR(255), vendor VARCHAR(255), transaction_date DATE, amount INT); INSERT INTO transactions (id, brand, vendor, transaction_date, amount) VALUES (1, 'SustainableStyles', 'FairTrade Fabrics', '2022-01-01', 1000), (2, 'SustainableStyles', 'Ethical Sources', '2022-0...
List all transactions involving fair labor practices, including the transaction date, vendor name, and total amount, for the ethical fashion brand 'SustainableStyles' in the last quarter.
SELECT t.transaction_date, t.vendor, SUM(t.amount) as total_amount FROM transactions t JOIN fair_labor_practices flp ON t.vendor = flp.vendor WHERE t.brand = 'SustainableStyles' AND t.transaction_date BETWEEN '2022-01-01' AND '2022-04-01' GROUP BY t.transaction_date, t.vendor;
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(50)); INSERT INTO stores VALUES (1, 'Store A'), (2, 'Store B'); CREATE TABLE inventory (product_id INT, product_name VARCHAR(50), store_id INT, daily_sales INT); INSERT INTO inventory VALUES (1, 'organic cotton shirt', 1, 25), (2, 'organic cotton pants', 1, 18), (3,...
What is the average quantity of 'organic cotton' products sold daily in each store?
SELECT store_id, AVG(daily_sales) as avg_daily_sales FROM inventory WHERE product_name LIKE '%organic cotton%' GROUP BY store_id;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_regulations (id INT, parameter VARCHAR(50), value INT); INSERT INTO medical_regulations (id, parameter, value) VALUES (1, 'medical_age_limit', 60);
What is the maximum medical age limit for astronauts?
SELECT value FROM medical_regulations WHERE parameter = 'medical_age_limit';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_providers (id INT, name VARCHAR(50), state VARCHAR(50), cultural_competency_score DECIMAL(3,2)); INSERT INTO mental_health_providers (id, name, state, cultural_competency_score) VALUES (1, 'Dr. Sarah Johnson', 'California', 4.75), (2, 'Dr. Michael Davis', 'Texas', 4.50), (3, 'Dr. Emily Garcia...
What is the average cultural competency score for mental health providers in each state?
SELECT state, AVG(cultural_competency_score) FROM mental_health_providers GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (MetricID INT, State VARCHAR(25)); INSERT INTO HealthEquityMetrics (MetricID, State) VALUES (1, 'NY'), (2, 'CA'), (3, 'TX'), (4, 'CA'), (5, 'NY'), (6, 'NJ'), (7, 'FL'), (8, 'PA'), (9, 'IL'), (10, 'GA'), (11, 'CA'), (12, 'NY'), (13, 'TX'), (14, 'FL'), (15, 'PA'); CREATE TABLE AllHealthEq...
What is the total number of unique health equity metrics being tracked in each state?
SELECT State, COUNT(DISTINCT MetricID) as TotalMetrics FROM HealthEquityMetrics GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists countries (country_name text); INSERT INTO countries (country_name) VALUES ('Brazil'); CREATE TABLE if not exists attractions (attraction_name text, country text, is_international boolean, num_reviews integer); INSERT INTO attractions (attraction_name, country, is_international, num_reviews) ...
Delete all international attractions in Brazil with no reviews.
DELETE FROM attractions WHERE country = 'Brazil' AND is_international = true AND num_reviews = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE product_details(product_id INT, product_type VARCHAR(255), contains_parabens BOOLEAN); CREATE TABLE cosmetics_sales(product_id INT, country VARCHAR(255), sales_quantity INT, sales_revenue DECIMAL(10,2));
Show the percentage of skincare products in India that are paraben-free.
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cosmetics_sales cs WHERE cs.country = 'India' AND cs.product_type = 'skincare') AS pct_paraben_free FROM product_details pd WHERE pd.product_type = 'skincare' AND pd.contains_parabens = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteID INT PRIMARY KEY, Name VARCHAR(100), Country VARCHAR(50), Category VARCHAR(50)); INSERT INTO HeritageSites (SiteID, Name, Country, Category) VALUES (1, 'Statue of Liberty', 'USA', 'Cultural'), (2, 'Banff National Park', 'Canada', 'Natural');
What is the total number of heritage sites in North America with 'Cultural' category?
SELECT COUNT(*) FROM HeritageSites WHERE Category = 'Cultural' AND Country = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE atlantic_ocean_salinity (date DATE, salinity FLOAT, ocean VARCHAR(50));
What is the average salinity for the 'Atlantic Ocean' in each season?
SELECT DATE_FORMAT(date, '%Y-%m') AS month, AVG(salinity) FROM atlantic_ocean_salinity WHERE ocean = 'Atlantic Ocean' AND (DATE_FORMAT(date, '%m') BETWEEN 1 AND 3 OR DATE_FORMAT(date, '%m') BETWEEN 7 AND 9) GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(id INT, investment VARCHAR(25), date DATE, region VARCHAR(20)); INSERT INTO investments(id, investment, date, region) VALUES (1, 'FTTH deployment', '2020-01-01', 'Europe'), (2, '5G upgrade', '2019-12-15', 'Asia'), (3, 'Data center expansion', '2020-06-30', 'Asia');
Delete all records of network infrastructure investments in the 'Asia' region.
DELETE FROM investments WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE hair_dye_launches (id INT, product VARCHAR(50), launch_date DATE, country VARCHAR(50)); INSERT INTO hair_dye_launches (id, product, launch_date, country) VALUES (1, 'Natural Hair Dye', '2021-04-01', 'India');
Show the number of hair dye products launched in India each quarter.
SELECT EXTRACT(QUARTER FROM launch_date) AS quarter, COUNT(*) FROM hair_dye_launches WHERE country = 'India' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, age INT, veteran_identification VARCHAR(10)); INSERT INTO community_health_workers (worker_id, age, veteran_identification) VALUES (1, 35, 'Yes'), (2, 42, 'No'), (3, 28, 'Yes');
What is the average age of community health workers who identify as veterans?
SELECT AVG(age) as avg_age FROM community_health_workers WHERE veteran_identification = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (id INT, name TEXT, riverBasin TEXT, waterFlowRate DECIMAL(5,2));
What is the minimum water flow rate for each dam in the 'Mississippi' river basin?
SELECT riverBasin, MIN(waterFlowRate) FROM Dams WHERE riverBasin = 'Mississippi' GROUP BY riverBasin;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, region TEXT, savings REAL);
What is the average savings of customers in the South region?
SELECT AVG(savings) FROM customers WHERE region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE Road_Maintenance (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Road_Maintenance (project_id, project_name, location) VALUES (1, 'Road Resurfacing', 'Downtown'), (2, 'Pothole Repair', 'Eastside'), (3, 'Traffic Signal Installation', 'Northside');
How many projects are there in the 'Road_Maintenance' table?
SELECT COUNT(*) FROM Road_Maintenance;
gretelai_synthetic_text_to_sql
CREATE TABLE phishing (id INT, ip_address VARCHAR(15), attack_time TIMESTAMP);CREATE TABLE malware (id INT, ip_address VARCHAR(15), attack_time TIMESTAMP);
Identify unique IP addresses that have been associated with phishing attempts and malware distribution in the last month.
SELECT DISTINCT ip_address FROM phishing WHERE attack_time >= NOW() - INTERVAL 1 MONTH UNION SELECT DISTINCT ip_address FROM malware WHERE attack_time >= NOW() - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE VulnAssess (id INT, system VARCHAR(50), vulnerability INT, last_patched DATETIME);
Identify the top 3 most vulnerable systems, according to our VulnAssess table, that have not been patched in the last 30 days.
SELECT system, vulnerability FROM VulnAssess WHERE last_patched < DATEADD(day, -30, GETDATE()) ORDER BY vulnerability DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE world_cup_goals (id INT, player VARCHAR(100), team VARCHAR(50), goals INT, world_cup BOOLEAN); INSERT INTO world_cup_goals (id, player, team, goals, world_cup) VALUES (1, 'Messi', 'Argentina', 5, true), (2, 'Ronaldo', 'Portugal', 4, true), (3, 'Neymar', 'Brazil', 6, true);
Who are the top 5 goal scorers in the 2022 FIFA World Cup?
SELECT player, goals FROM world_cup_goals WHERE world_cup = true ORDER BY goals DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (UserID INT, Age INT, UsedAccessibleTech BOOLEAN); INSERT INTO Users (UserID, Age, UsedAccessibleTech) VALUES (1, 34, true), (2, 45, false), (3, 29, true);
What is the average age of users who have used accessible technology?
SELECT AVG(Age) FROM Users WHERE UsedAccessibleTech = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_id INT, name VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT, gender VARCHAR(50));
Which exhibition had the highest number of visitors aged 60 or above?
SELECT e.name, COUNT(v.visitor_id) as visitor_count FROM Exhibitions e JOIN Visitors v ON e.exhibition_id = v.exhibition_id WHERE v.age >= 60 GROUP BY e.name ORDER BY visitor_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE soldiers (division TEXT, soldiers INT); INSERT INTO soldiers (division, soldiers) VALUES ('East', 2000); INSERT INTO soldiers (division, soldiers) VALUES ('South', 2500);
What is the minimum number of soldiers in the 'South' division?
SELECT MIN(soldiers) FROM soldiers WHERE division = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, name VARCHAR(50), type VARCHAR(50), year_built INT);
Add a new record to the "vessels" table for a vessel named "Alice" with a type "Tanker" and a year built of 2012.
INSERT INTO vessels (vessel_id, name, type, year_built) VALUES (1, 'Alice', 'Tanker', 2012);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donation_date DATE, amount DECIMAL(10, 2), region VARCHAR(50)); INSERT INTO donations (id, donation_date, amount, region) VALUES (1, '2020-01-01', 50.00, 'North'), (2, '2020-01-15', 100.00, 'South'), (3, '2020-03-30', 200.00, 'North');
Which region had the highest average donation in H1 2020?
SELECT region, AVG(amount) AS avg_donation FROM donations WHERE donation_date BETWEEN '2020-01-01' AND '2020-06-30' GROUP BY region ORDER BY avg_donation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, name TEXT, location TEXT, energy_consumption FLOAT); INSERT INTO GreenBuildings (id, name, location, energy_consumption) VALUES (1, 'EcoTower', 'New York', 1500.0), (2, 'GreenSpire', 'California', 1200.0), (3, 'GreenVista', 'Florida', 1000.0);
What is the maximum and minimum energy consumption in the 'GreenBuildings' table?
SELECT MAX(energy_consumption) AS MaxEnergy, MIN(energy_consumption) AS MinEnergy FROM GreenBuildings;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales_region (drug_name VARCHAR(50), region VARCHAR(50), sales FLOAT, year INT); INSERT INTO drug_sales_region (drug_name, region, sales, year) VALUES ('DrugA', 'North America', 1200, 2019), ('DrugB', 'North America', 1000, 2019), ('DrugC', 'Europe', 800, 2019), ('DrugD', 'Europe', 900, 2019), ('DrugE...
List the top 2 drugs with the highest sales in each region in 2019.
SELECT drug_name, region, SUM(sales) as total_sales FROM drug_sales_region WHERE year = 2019 GROUP BY drug_name, region HAVING COUNT(*) FILTER (WHERE region IS NOT NULL) >= 2 ORDER BY total_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contract (contract_address VARCHAR(42)); CREATE TABLE transaction (contract_address VARCHAR(42), tx_hash VARCHAR(66));
How many transactions occurred for each smart contract on the Binance Smart Chain?
SELECT sc.contract_address, COUNT(tx.tx_hash) as tx_count FROM smart_contract sc JOIN transaction tx ON sc.contract_address = tx.contract_address GROUP BY sc.contract_address;
gretelai_synthetic_text_to_sql
CREATE TABLE textile_working_hours (country VARCHAR(50), min_hours INT, max_hours INT); INSERT INTO textile_working_hours (country, min_hours, max_hours) VALUES ('Bangladesh', 40, 60), ('Vietnam', 45, 65), ('Cambodia', 48, 72), ('India', 50, 75), ('Indonesia', 52, 78);
What is the maximum and minimum number of hours worked per week for workers in the textile industry, by country?
SELECT country, MAX(max_hours) as max_hours, MIN(min_hours) as min_hours FROM textile_working_hours GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselArrivals (ID INT, VesselName VARCHAR(50), ArrivalPort VARCHAR(50), ArrivalDate DATE, AverageSpeed DECIMAL(5,2)); INSERT INTO VesselArrivals (ID, VesselName, ArrivalPort, ArrivalDate, AverageSpeed) VALUES (1, 'Test Vessel 1', 'Havana', '2022-01-01', 15.0), (2, 'Test Vessel 2', 'Havana', '2022-01-02', ...
List the vessels arriving in Havana, ordered by their arrival date and then average speed?
SELECT VesselName, ArrivalDate, AverageSpeed FROM VesselArrivals WHERE ArrivalPort = 'Havana' ORDER BY ArrivalDate, AverageSpeed;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (ID INT, Name VARCHAR(50), Age INT, Ethnicity VARCHAR(50), State VARCHAR(50)); INSERT INTO CommunityHealthWorkers (ID, Name, Age, Ethnicity, State) VALUES (1, 'John Doe', 45, 'Hispanic', 'California'); INSERT INTO CommunityHealthWorkers (ID, Name, Age, Ethnicity, State) VALUES (2, 'J...
What is the average age of community health workers in California and Texas, grouped by their ethnicity?
SELECT Ethnicity, AVG(Age) as AverageAge FROM CommunityHealthWorkers WHERE State IN ('California', 'Texas') GROUP BY Ethnicity;
gretelai_synthetic_text_to_sql
CREATE VIEW courier_performances AS SELECT courier_id, order_id, delivery_time, PERCENTILE_CONT(0.1) WITHIN GROUP (ORDER BY delivery_time) OVER (PARTITION BY courier_id) as pct_10 FROM orders;
What is the order ID and delivery time for the 10th percentile delivery time for each courier in the 'courier_performances' view, ordered by the 10th percentile delivery time?
SELECT courier_id, order_id, delivery_time FROM courier_performances WHERE pct_10 = delivery_time ORDER BY delivery_time;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, case_type VARCHAR(20), arrest_date DATE, arraignment_date DATE); INSERT INTO cases (id, case_type, arrest_date, arraignment_date) VALUES (1, 'Misdemeanor', '2021-01-01', '2021-01-15'), (2, 'Misdemeanor', '2021-02-01', '2021-02-28'), (3, 'Felony', '2021-03-01', '2021-04-01');
What is the average number of days between arrest and arraignment for misdemeanor cases?
SELECT AVG(DATEDIFF(day, arrest_date, arraignment_date)) FROM cases WHERE case_type = 'Misdemeanor';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_aid (donation_id INT, organization VARCHAR(50), amount DECIMAL(10,2), donation_date DATE); INSERT INTO humanitarian_aid (donation_id, organization, amount, donation_date) VALUES (1, 'Doctors Without Borders (advocacy)', 300.00, '2021-01-01'), (2, 'UNICEF (humanitarian aid)', 400.00, '2021-02-0...
List all donations made by 'advocacy' organizations in the 'humanitarian_aid' table.
SELECT * FROM humanitarian_aid WHERE organization LIKE '%advocacy%';
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (MovieID INT, Title VARCHAR(255), Genre VARCHAR(50), ReleaseYear INT, RunningTime INT); CREATE TABLE TVShows (ShowID INT, Title VARCHAR(255), Genre VARCHAR(50), ReleaseYear INT, RunningTime INT);
What is the number of unique genres for movies and TV shows in the database, and their average running times?
SELECT AVG(Movies.RunningTime) AS Avg_Movie_Runtime, AVG(TVShows.RunningTime) AS Avg_TVShow_Runtime, COUNT(DISTINCT Movies.Genre) + COUNT(DISTINCT TVShows.Genre) AS Total_Unique_Genres FROM Movies, TVShows;
gretelai_synthetic_text_to_sql
CREATE TABLE VRHardware (HardwareID INT, HardwareName VARCHAR(50), Manufacturer VARCHAR(20), ReleaseDate DATE, Price NUMERIC(10,2)); INSERT INTO VRHardware (HardwareID, HardwareName, Manufacturer, ReleaseDate, Price) VALUES (1, 'Oculus Rift', 'Oculus', '2016-03-28', 599); INSERT INTO VRHardware (HardwareID, HardwareNam...
What is the price range for VR hardware, and how many products fall into each range, ranked by the number of products?
SELECT Price, NTILE(3) OVER (ORDER BY Price) as PriceRange, COUNT(*) as ProductsInRange, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM VRHardware GROUP BY Price;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (donor_id, organization_id, amount, donation_date) VALUES (1, 101, 500.00, '2022-09-01'), (2, 102, 350.00, '2022-07-05'), (3, 101, 200.00, '2022-09-25');
What is the average donation amount for each organization in Q3 2022?
SELECT organization_id, AVG(amount) as avg_donation FROM donations WHERE donation_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_initiatives ( id INT PRIMARY KEY, project_name VARCHAR(255), total_offset INT );
Update the carbon offset initiative records for project 'Urban Forest' to have a total offset of 5000 tons.
UPDATE carbon_offset_initiatives SET total_offset = 5000 WHERE project_name = 'Urban Forest';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, product TEXT, production_volume INT); INSERT INTO mines (id, name, location, product, production_volume) VALUES (1, 'Media Luna', 'Mexico', 'Silver', 30000);
What is the maximum production volume of silver in Mexico?
SELECT MAX(production_volume) FROM mines WHERE location = 'Mexico' AND product = 'Silver';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, comments INT, hashtags TEXT, post_date DATE);
What is the average number of comments on posts by users from Japan, for posts containing the hashtag #technology, in the last month?
SELECT AVG(comments) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'Japan' AND hashtags LIKE '%#technology%' AND post_date >= DATE(NOW()) - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovations (id INT, project TEXT, country TEXT, investment FLOAT); INSERT INTO agricultural_innovations (id, project, country, investment) VALUES (1, 'Drip Irrigation', 'Kenya', 30000), (2, 'Genetic Modification', 'Kenya', 50000);
What is the total investment in agricultural innovation projects in Kenya?
SELECT SUM(investment) FROM agricultural_innovations WHERE country = 'Kenya';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name TEXT, manager TEXT); INSERT INTO departments (id, name, manager) VALUES (1, 'electronics', 'Jane'), (2, 'textiles', 'Bob'), (3, 'metals', 'John'), (4, 'chemicals', 'Alice'); CREATE TABLE workers (id INT, department_id INT, salary FLOAT); INSERT INTO workers (id, department_id, sal...
Determine the number of workers in the 'electronics' department who earn less than the average salary.
SELECT COUNT(*) FROM workers INNER JOIN departments ON workers.department_id = departments.id WHERE departments.name = 'electronics' AND salary < (SELECT AVG(salary) FROM workers INNER JOIN departments ON workers.department_id = departments.id WHERE departments.name = 'electronics');
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), capacity_mw INT); INSERT INTO renewable_energy_projects (id, project_name, location, capacity_mw) VALUES (1, 'Wind Farm XYZ', 'Texas, USA', 500); INSERT INTO renewable_energy_projects (id, project_name, location, capacity_mw...
How many renewable energy projects are located in each country?
SELECT SUBSTRING_INDEX(location, ',', 1) AS country, COUNT(*) FROM renewable_energy_projects GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(255), age INT, team_id INT);
Create a new table for athlete wellbeing programs
CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, program_name VARCHAR(255), start_date DATE, end_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE mission_costs(cost_id INT, mission_id INT, mission_type VARCHAR(50), year INT, cost FLOAT); INSERT INTO mission_costs VALUES (1, 1, 'Robotic', 2018, 1000.5); INSERT INTO mission_costs VALUES (2, 2, 'Human', 2019, 2000.2); INSERT INTO mission_costs VALUES (3, 3, 'Robotic', 2020, 1500.3);
What is the average cost of space missions by mission type and year?
SELECT mission_type, year, AVG(cost) as avg_cost FROM mission_costs GROUP BY mission_type, year;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, organization VARCHAR(50), object_count INT); INSERT INTO space_debris (id, organization, object_count) VALUES (1, 'NASA', 25000), (2, 'ESA', 18000), (3, 'JAXA', 12000);
How many space debris objects are currently being tracked by different organizations?
SELECT organization, SUM(object_count) as total_objects FROM space_debris GROUP BY organization ORDER BY total_objects DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_id INT, project_name TEXT, location TEXT, funding_year INT, amount FLOAT); INSERT INTO renewable_energy_projects (project_id, project_name, location, funding_year, amount) VALUES (1, 'Solar Farm 1', 'USA', 2020, 5000000.00), (2, 'Wind Farm 2', 'Germany', 2020, 7000000.00)...
What is the total amount of climate finance committed to renewable energy projects in 2020?
SELECT SUM(amount) FROM renewable_energy_projects WHERE funding_year = 2020 AND location IN ('USA', 'Germany', 'Brazil');
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), gender VARCHAR(10), program VARCHAR(50), publications INT); INSERT INTO students (id, name, gender, program, publications) VALUES (1, 'Charlie', 'Non-binary', 'Mathematics', 2), (2, 'Dana', 'Female', 'Physics', 0), (3, 'Eli', 'Male', 'Engineering', 1);
How many graduate students are enrolled in STEM programs and have published at least one paper?
SELECT COUNT(*) FROM students WHERE program LIKE 'STEM%' AND publications > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE underwater_volcanoes (name VARCHAR(255), region VARCHAR(255), active BOOLEAN);INSERT INTO underwater_volcanoes (name, region, active) VALUES ('Volcano 1', 'Arctic Ocean', true), ('Volcano 2', 'Atlantic Ocean', false), ('Volcano 3', 'Arctic Ocean', true);
How many underwater volcanoes are there in the Arctic Ocean?
SELECT COUNT(*) FROM underwater_volcanoes WHERE region = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE tours(id INT, name TEXT, city TEXT, type TEXT, revenue FLOAT); INSERT INTO tours(id, name, city, type, revenue) VALUES (1, 'Tokyo Imperial Palace Tour', 'Tokyo', 'cultural heritage', 20000.0);
What is the total revenue for cultural heritage tours in Tokyo?
SELECT SUM(revenue) FROM tours WHERE city = 'Tokyo' AND type = 'cultural heritage';
gretelai_synthetic_text_to_sql
CREATE TABLE Platforms (PlatformID INT, Platform TEXT); INSERT INTO Platforms (PlatformID, Platform) VALUES (1, 'PC'), (2, 'Xbox'), (3, 'PlayStation'); CREATE TABLE GameResults (GameID INT, PlayerID INT, CoinsEarned INT, PlatformID INT); INSERT INTO GameResults (GameID, PlayerID, CoinsEarned, PlatformID) VALUES (1, 1, ...
What is the maximum coins earned by a player in a single game, broken down by game platform?
SELECT Platform, MAX(CoinsEarned) FROM GameResults GROUP BY Platform;
gretelai_synthetic_text_to_sql
CREATE TABLE unsafe_ai_deployments (deployment_date DATE, ai_algorithm VARCHAR(255), region VARCHAR(50)); INSERT INTO unsafe_ai_deployments (deployment_date, ai_algorithm, region) VALUES ('2022-01-01', 'Algorithm I', 'APAC'), ('2022-02-15', 'Algorithm J', 'APAC'), ('2022-03-03', 'Algorithm K', 'Europe');
What is the total number of unsafe AI algorithm deployments in APAC region?
SELECT ai_algorithm, SUM(IIF(region = 'APAC', 1, 0)) AS total_unsafe_deployments FROM unsafe_ai_deployments GROUP BY ai_algorithm HAVING SUM(IIF(region = 'APAC', 1, 0)) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_name VARCHAR(255), country VARCHAR(255), engagement_date DATE);
How many virtual tours were engaged in the last month for hotels in the US?
SELECT COUNT(*) FROM virtual_tours WHERE country = 'US' AND engagement_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE subway_stations (id INT, name TEXT, lines TEXT, daily_ridership INT); CREATE VIEW subway_station_summary AS SELECT name, MAX(daily_ridership) as max_ridership FROM subway_stations GROUP BY name;
Which subway station in Tokyo has the highest ridership?
SELECT name FROM subway_station_summary WHERE max_ridership = (SELECT MAX(daily_ridership) FROM subway_stations);
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (farmer_id INT, farm_name VARCHAR(50), location VARCHAR(50), area_ha FLOAT); INSERT INTO organic_farms (farmer_id, farm_name, location, area_ha) VALUES (1, 'Farm 1', 'Location 1', 15.6);
What is the total area (in hectares) of farmland in the 'organic_farms' table?
SELECT SUM(area_ha) FROM organic_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (project_name VARCHAR(255), project_type VARCHAR(255), completion_year INT); INSERT INTO rural_infrastructure (project_name, project_type, completion_year) VALUES ('Greenhouse Project', 'Agricultural Innovation', 2018), ('Drip Irrigation System', 'Agricultural Innovation', 2019), ('Rur...
List all rural infrastructure projects in the 'rural_infrastructure' table along with their completion years and project types.
SELECT project_name, project_type, completion_year FROM rural_infrastructure;
gretelai_synthetic_text_to_sql
CREATE TABLE alaska_wells (well_id INT, well_name TEXT, drilling_date DATE, well_depth INT); INSERT INTO alaska_wells (well_id, well_name, drilling_date, well_depth) VALUES (1, 'Well J', '2015-01-01', 12000); INSERT INTO alaska_wells (well_id, well_name, drilling_date, well_depth) VALUES (2, 'Well K', '2016-05-15', 150...
What is the minimum well depth for wells drilled in Alaska?
SELECT MIN(well_depth) FROM alaska_wells WHERE country = 'Alaska';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_buses (bus_id INT, city VARCHAR(20), is_autonomous BOOLEAN); INSERT INTO autonomous_buses (bus_id, city, is_autonomous) VALUES (1, 'San Francisco', true), (2, 'New York', false), (3, 'San Francisco', true);
How many autonomous buses are there in each city in the autonomous_buses table?
SELECT city, SUM(is_autonomous) FROM autonomous_buses GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, volunteer_hours INT);
How many volunteers are there in 'volunteers' table?
SELECT COUNT(*) FROM volunteers;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean (id INT, name TEXT, deepest_part_depth FLOAT); CREATE TABLE deep_sea_measurements (id INT, ocean_id INT, depth FLOAT); INSERT INTO ocean VALUES (1, 'Atlantic', -8000), (2, 'Pacific', -8000), (3, 'Indian', -7500); INSERT INTO deep_sea_measurements VALUES (1, 1, -8500), (2, 2, -8400), (3, 3, -7600);
What is the average depth of the deepest parts of each ocean?
SELECT o.name, AVG(ds.depth) as avg_deepest_part_depth FROM ocean o INNER JOIN deep_sea_measurements ds ON o.id = ds.ocean_id GROUP BY o.name;
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_projects (project_id INT, continent VARCHAR(10), budget DECIMAL(10,2)); INSERT INTO accessible_tech_projects (project_id, continent, budget) VALUES (1, 'Asia', 300000.00), (2, 'Africa', 400000.00), (3, 'Europe', 500000.00);
What is the total budget for accessible technology projects in Africa?
SELECT SUM(budget) FROM accessible_tech_projects WHERE continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableUrbanismProjects (ProjectID INT, ProjectName VARCHAR(50), Cost DECIMAL(10,2)); INSERT INTO SustainableUrbanismProjects (ProjectID, ProjectName, Cost) VALUES (1, 'Project X', 450000.00), (2, 'Project Y', 650000.00), (3, 'Project Z', 525000.00);
Show sustainable urbanism projects that have a cost between $300,000 and $400,000.
SELECT ProjectName FROM SustainableUrbanismProjects WHERE Cost BETWEEN 300000.00 AND 400000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE AquacultureFarms (Country VARCHAR(50), FarmName VARCHAR(50)); INSERT INTO AquacultureFarms (Country, FarmName) VALUES ('Norway', 'FjordFarms'), ('Mexico', 'CoastalCultures'), ('Chile', 'PatagoniaPonds'); CREATE TABLE SeafoodCertifications (Country VARCHAR(50), Certification BOOLEAN); INSERT INTO SeafoodCer...
What is the number of aquaculture farms in each country in the AquacultureFarms table that do not have a sustainable seafood certification in the SeafoodCertifications table?
SELECT AquacultureFarms.Country, COUNT(AquacultureFarms.Country) FROM AquacultureFarms LEFT JOIN SeafoodCertifications ON AquacultureFarms.Country = SeafoodCertifications.Country WHERE SeafoodCertifications.Certification IS NULL GROUP BY AquacultureFarms.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE housing (id INT, state VARCHAR(20), inclusive BOOLEAN); INSERT INTO housing (id, state, inclusive) VALUES (1, 'Florida', TRUE), (2, 'Florida', FALSE), (3, 'Florida', TRUE);
What is the total number of inclusive housing units in the state of Florida?
SELECT COUNT(*) FROM housing WHERE state = 'Florida' AND inclusive = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShanghai (Id INT, Name VARCHAR(100), Horsepower FLOAT); INSERT INTO AutoShanghai (Id, Name, Horsepower) VALUES (1, 'Model S', 469), (2, 'Model 3', 322), (3, 'Golf', 150), (4, 'Polo', 116), (5, 'Tesla Model X', 518), (6, 'Audi e-Tron', 402);
What is the average horsepower of vehicles participating in the Auto Shanghai 2021?
SELECT AVG(Horsepower) FROM AutoShanghai WHERE Name LIKE '%Auto Shanghai 2021%'
gretelai_synthetic_text_to_sql
CREATE TABLE journeys (vessel VARCHAR(20), speed INT, distance INT); INSERT INTO journeys (vessel, speed, distance) VALUES ('Aurelia', 20, 100), ('Aurelia', 22, 120), ('Belfast', 25, 150), ('Belfast', 24, 140), ('Belfast', 26, 160), ('Caledonia', 21, 110), ('Caledonia', 23, 130);
What was the maximum speed of vessel 'Caledonia' during its journeys?
SELECT MAX(speed) FROM journeys WHERE vessel = 'Caledonia';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artist_name VARCHAR(50), artwork_year INT, artwork_region VARCHAR(20), artwork_style VARCHAR(20));
Find the number of artworks in the 'Artworks' table that have a 'sculpture' style and were created by artists from 'Europe' between '1500' and '1600'.
SELECT COUNT(*) FROM Artworks WHERE artwork_style = 'sculpture' AND artwork_region = 'Europe' AND artwork_year BETWEEN 1500 AND 1600;
gretelai_synthetic_text_to_sql
CREATE TABLE port_office ( id INT PRIMARY KEY, port VARCHAR(255), region VARCHAR(255) );
Show the ports and their corresponding regional offices for the port_office table.
SELECT port, region FROM port_office;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE papers (id INT, student_id INT, title VARCHAR(100)); INSERT INTO students VALUES (1, 'Mia', 'Law'), (2, 'Nathan', 'Law'), (3, 'Oliver', 'Law'); INSERT INTO papers VALUES (1, 1, 'Paper 1'), (2, 1, 'Paper 2'), (3, 2, 'Paper 3');
List the graduate students in the College of Law who have not published any papers.
SELECT students.id, students.name FROM students LEFT JOIN papers ON students.id = papers.student_id WHERE papers.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_categories (category VARCHAR(255)); INSERT INTO infrastructure_categories (category) VALUES ('Water Resources'), ('Food Security'), ('Energy'); CREATE TABLE rural_infrastructure (name VARCHAR(255), category VARCHAR(255), budget INT); INSERT INTO rural_infrastructure (name, category, budget) ...
Show the total budget for each category of infrastructure project in the 'rural_infrastructure' table.
SELECT category, SUM(budget) FROM rural_infrastructure GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency ( id INT PRIMARY KEY, building VARCHAR(20), energy_consumption FLOAT, grade VARCHAR(1) ); INSERT INTO energy_efficiency (id, building, energy_consumption, grade) VALUES (1, 'House', 45, 'B'), (2, 'Apartment', 30, 'C'), (3, 'Office', 20, 'D');
Update the 'energy_efficiency' table, setting the 'grade' to 'A' for any record where energy_consumption is less than 50
WITH cte AS (UPDATE energy_efficiency SET grade = 'A' WHERE energy_consumption < 50) SELECT * FROM cte;
gretelai_synthetic_text_to_sql