context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE SecurityIncidents(id INT, analyst_id VARCHAR(50), incidents INT, resolution_date DATE);
What is the maximum number of security incidents resolved by a single analyst in the last month?
SELECT MAX(incidents) as max_incidents FROM SecurityIncidents WHERE resolution_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) GROUP BY analyst_id ORDER BY max_incidents DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE illegal_logging (id INT, location VARCHAR(255), area DECIMAL(5,2), year INT); INSERT INTO illegal_logging (id, location, area, year) VALUES (1, 'Congo Basin', 350.0, 2018), (2, 'Amazon Rainforest', 450.0, 2020);
What are the locations where the area of illegal logging is greater than 400 in 2020?
SELECT location FROM illegal_logging WHERE area > 400 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_name VARCHAR(255), developer_id INT, creation_date DATE); CREATE TABLE developers (developer_id INT, developer_name VARCHAR(255));
List all smart contracts and their developers in the 'smart_contracts' and 'developers' tables, including contracts with no associated developers.
SELECT s.contract_name, d.developer_name FROM smart_contracts s LEFT JOIN developers d ON s.developer_id = d.developer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name VARCHAR(255)); CREATE TABLE cargo (id INT, port_id INT, cargo_type VARCHAR(255), timestamp TIMESTAMP); INSERT INTO ports VALUES (1, 'Port A'), (2, 'Port B'), (3, 'Port C'); INSERT INTO cargo VALUES (1, 1, 'container', '2022-01-01 10:00:00'), (2, 2, 'container', '2022-01-05 12:00:00'), (...
How many containers were handled by each port in the last month?
SELECT p.name, COUNT(c.id) as container_count FROM ports p JOIN cargo c ON p.id = c.port_id WHERE c.timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND c.cargo_type = 'container' GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, customer_id INT, fund_type VARCHAR(50), investment_amount DECIMAL(10,2)); INSERT INTO investments (id, customer_id, fund_type, investment_amount) VALUES (1, 1, 'Bond', 10000.00); INSERT INTO investments (id, customer_id, fund_type, investment_amount) VALUES (2, 2, 'Equity', 15000.00); ...
What is the total investment in the 'Equity' fund type for customers in the 'Europe' region?
SELECT SUM(investment_amount) FROM investments WHERE fund_type = 'Equity' AND customer_id IN (SELECT id FROM customers WHERE region = 'Europe');
gretelai_synthetic_text_to_sql
CREATE TABLE GameScores (GameID INT, GameCategory VARCHAR(255), Score INT);
Calculate the average score for each game category in the 'GameScores' table
SELECT GameCategory, AVG(Score) as AverageScore FROM GameScores GROUP BY GameCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE mine_stats (mine_name VARCHAR(255), mine_type VARCHAR(255), production_capacity FLOAT); INSERT INTO mine_stats (mine_name, mine_type, production_capacity) VALUES ('Diamond Dell', 'diamond', 5000.2), ('Gemstone Gorge', 'diamond', 6000.4), ('Precious Point', 'diamond', 7000.1);
What is the maximum production capacity of all diamond mines in the 'mine_stats' table?
SELECT MAX(production_capacity) FROM mine_stats WHERE mine_type = 'diamond';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (union_id INT, union_name TEXT, advocacy TEXT, cb_agreements INT); INSERT INTO unions (union_id, union_name, advocacy, cb_agreements) VALUES (1001, 'United Steelworkers', 'workplace safety', 20); INSERT INTO unions (union_id, union_name, advocacy, cb_agreements) VALUES (1002, 'Transport Workers Unio...
What is the total number of unions advocating for workplace safety and their total number of collective bargaining agreements?
SELECT u.advocacy, SUM(u.cb_agreements), COUNT(u.union_id) FROM unions u WHERE u.advocacy = 'workplace safety' GROUP BY u.advocacy;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name TEXT); INSERT INTO countries VALUES (1, 'United States'); CREATE TABLE states (state_id INT, state_name TEXT, country_id INT); INSERT INTO states VALUES (1, 'Nevada', 1); CREATE TABLE mining_operations (operation_id INT, state_id INT, minerals_extracted FLOAT);
How many mining operations are there in the United States, and what is the total amount of minerals extracted in the state of Nevada?
SELECT COUNT(*) AS num_operations, SUM(minerals_extracted) AS total_minerals_extracted FROM mining_operations MO JOIN states S ON MO.state_id = S.state_id WHERE S.country_name = 'United States' AND S.state_name = 'Nevada';
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);
What is the average depth of all expeditions for the 'Ocean Explorer' organization?
SELECT AVG(depth) FROM expedition WHERE org = 'Ocean Explorer';
gretelai_synthetic_text_to_sql
CREATE TABLE CrimeStats (ID INT, District VARCHAR(50), Year INT, NumberOfCrimes INT);
How many crimes were reported in each district last year?
SELECT District, Year, SUM(NumberOfCrimes) FROM CrimeStats GROUP BY District, Year;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ai_rating (hotel_id INT, hotel_name TEXT, country TEXT, ai_services TEXT, rating FLOAT); INSERT INTO hotel_ai_rating (hotel_id, hotel_name, country, ai_services, rating) VALUES (1, 'The Smart Hotel', 'Brazil', 'yes', 4.5), (2, 'The Traditional Inn', 'Brazil', 'no', 3.8), (3, 'The AI Resort', 'Argenti...
What is the correlation between AI adoption and hotel ratings in South America?
SELECT correlation(ai_services, rating) FROM hotel_ai_rating WHERE country = 'South America'
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_value FLOAT); INSERT INTO transactions (transaction_id, client_id, transaction_value) VALUES (1, 1, 1000.00), (2, 1, 2000.00), (3, 2, 500.00);
What is the total number of transactions and the total transaction value per client?
SELECT c.name, COUNT(t.transaction_id) as total_transactions, SUM(t.transaction_value) as total_transaction_value FROM clients c JOIN transactions t ON c.client_id = t.client_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselTypes (TypeID INT, Type TEXT); CREATE TABLE Incidents (IncidentID INT, VesselID INT, IncidentType TEXT, Date DATE); INSERT INTO VesselTypes VALUES (1, 'Oil Tanker'), (2, 'Cargo Ship'); INSERT INTO Incidents VALUES (1, 1, 'Oil Spill', '2020-01-01'); INSERT INTO Incidents VALUES (2, 2, 'Collision', '20...
List the number of incidents for each vessel type in the safety records.
SELECT VesselTypes.Type, COUNT(Incidents.IncidentID) FROM VesselTypes LEFT JOIN Incidents ON VesselTypes.TypeID = Incidents.VesselID GROUP BY VesselTypes.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, location TEXT, date DATE); INSERT INTO visitors (id, location, date) VALUES (1, 'Kenya', '2022-01-15'), (2, 'Egypt', '2021-12-01');
What is the total number of visitors to Africa in the last 6 months?
SELECT COUNT(*) FROM visitors WHERE location LIKE 'Africa%' AND date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, material TEXT, price DECIMAL, country_of_manufacture TEXT); INSERT INTO products (product_id, product_name, material, price, country_of_manufacture) VALUES (1, 'Cotton Shirt', 'Cotton', 25.99, 'United States');
What is the average price of products, grouped by their material, that were manufactured in the US?
SELECT material, AVG(price) FROM products WHERE country_of_manufacture = 'United States' GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_metrics (id INT, country TEXT, metric INT, year INT, PRIMARY KEY (id, year)); INSERT INTO agricultural_metrics (id, country, metric, year) VALUES (1, 'Country A', 200, 2021), (2, 'Country B', 150, 2021), (3, 'Country A', 250, 2022), (4, 'Country B', 180, 2022);
Find the percentage change in agricultural innovation metrics for each country between 2021 and 2022, sorted by the highest increase?
SELECT country, ((LAG(metric, 1) OVER (PARTITION BY country ORDER BY year) - metric) * 100.0 / LAG(metric, 1) OVER (PARTITION BY country ORDER BY year)) as pct_change FROM agricultural_metrics WHERE year IN (2021, 2022) GROUP BY country ORDER BY pct_change DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, model_name VARCHAR(50), domain VARCHAR(50), training_location VARCHAR(50), training_date DATE, explainability_score DECIMAL(3,2));
Determine the average explainability score for AI models involved in autonomous driving systems, in the last 4 years, and display the average score, model name, and training location, grouped by the year of training.
SELECT YEAR(training_date) AS year, AVG(explainability_score) AS avg_explainability_score, model_name, training_location FROM ai_models WHERE domain = 'autonomous driving systems' AND training_date >= DATE(CURRENT_DATE) - INTERVAL 4 YEAR GROUP BY year, model_name, training_location ORDER BY year ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE packages (id INT, type TEXT); INSERT INTO packages (id, type) VALUES (1, 'Box'), (2, 'Pallet'), (3, 'Envelope'); CREATE TABLE shipments (id INT, package_id INT, warehouse_id INT); INSERT INTO shipments (id, package_id, warehouse_id) VALUES (1, 1, 3), (2, 2, 3), (3, 3, 4), (4, 1, 2); CREATE TABLE warehouses...
Find the total number of pallets shipped from the 'AMER' region
SELECT SUM(shipments.id) AS total_pallets FROM shipments JOIN packages ON shipments.package_id = packages.id JOIN warehouses ON shipments.warehouse_id = warehouses.id WHERE packages.type = 'Pallet' AND warehouses.region = 'AMER';
gretelai_synthetic_text_to_sql
CREATE TABLE calls (cid INT, call_time TIME);
What is the maximum number of emergency calls in each hour of the day?
SELECT HOUR(call_time) AS hour_of_day, MAX(COUNT(*)) FROM calls GROUP BY hour_of_day;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, HireDate, Salary) VALUES (1, '2020-01-01', 75000.00), (2, '2019-01-01', 60000.00), (3, '2020-03-01', 80000.00), (4, '2018-01-01', 90000.00), (5, '2020-05-01', 95000.00), (6, '2019-06-01', 65000.00);
What is the average salary for employees who were hired in 2020?
SELECT AVG(Salary) FROM Employees WHERE YEAR(HireDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (maker TEXT, model TEXT); INSERT INTO aircraft (maker, model) VALUES ('Boeing', '747'), ('Boeing', '777'), ('Airbus', 'A320'), ('Airbus', 'A350');
What is the count of aircraft manufactured by Boeing?
SELECT COUNT(*) FROM aircraft WHERE maker = 'Boeing';
gretelai_synthetic_text_to_sql
CREATE TABLE budget (category TEXT, amount INTEGER); INSERT INTO budget (category, amount) VALUES ('national security', 15000), ('intelligence operations', 10000), ('cybersecurity', 12000);
Display the total budget allocated for 'national security' and 'cybersecurity' combined.
SELECT (SUM(CASE WHEN category = 'national security' THEN amount ELSE 0 END) + SUM(CASE WHEN category = 'cybersecurity' THEN amount ELSE 0 END)) FROM budget
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, type VARCHAR(20), style VARCHAR(20), price DECIMAL(10,2)); INSERT INTO Artworks (artwork_id, type, style, price) VALUES (1, 'Painting', 'Impressionist', 1200.00), (2, 'Sculpture', 'Modern', 2500.00), (3, 'Painting', 'Impressionist', 1800.00);
How many sculptures are there in the 'Modern' style that cost over $2000?
SELECT COUNT(*) FROM Artworks WHERE type = 'Sculpture' AND style = 'Modern' AND price > 2000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (id INT, name TEXT, type TEXT, services TEXT);
What is the percentage of rural healthcare providers that offer telemedicine services, grouped by provider type?
SELECT type, AVG(telemedicine) * 100 AS percentage FROM (SELECT type, (CASE WHEN services LIKE '%Telemedicine%' THEN 1 ELSE 0 END) AS telemedicine FROM healthcare_providers) AS telemedicine_providers GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing(region VARCHAR(20), revenue INT, manufacturing_date DATE); INSERT INTO manufacturing (region, revenue, manufacturing_date) VALUES ('Africa', 5000, '2022-07-01'); INSERT INTO manufacturing (region, revenue, manufacturing_date) VALUES ('Europe', 7000, '2022-07-02');
What is the total revenue generated from garment manufacturing in 'Africa' in Q3 2022?
SELECT SUM(revenue) FROM manufacturing WHERE region = 'Africa' AND manufacturing_date >= '2022-07-01' AND manufacturing_date <= '2022-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices_ca (id INT, market TEXT, state TEXT, price FLOAT, year INT); INSERT INTO carbon_prices_ca (id, market, state, price, year) VALUES (1, 'California Cap-and-Trade Program', 'California', 13.57, 2013);
What is the minimum carbon price (USD/ton) in the California Cap-and-Trade Program since its inception?
SELECT MIN(price) FROM carbon_prices_ca WHERE market = 'California Cap-and-Trade Program' AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), state VARCHAR(255), cultivation_date DATE); CREATE TABLE sales (id INT PRIMARY KEY, strain_id INT, quantity INT, sale_date DATE);
What are the total sales, in terms of quantity, for each cannabis strain in the state of California for the year 2021, excluding strains with no sales?
SELECT strains.name, SUM(sales.quantity) as total_sales FROM strains INNER JOIN sales ON strains.id = sales.strain_id WHERE strains.state = 'California' AND YEAR(sales.sale_date) = 2021 GROUP BY strains.name HAVING total_sales > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE poverty (state VARCHAR(255), population INT, below_poverty_line INT); INSERT INTO poverty (state, population, below_poverty_line) VALUES ('California', 40000000, 5000000), ('Texas', 30000000, 4000000), ('New York', 20000000, 3000000);
What is the percentage of the population in each state that is below the poverty line?
SELECT s1.state, (s1.below_poverty_line * 100.0 / s1.population) as pct_below_poverty_line FROM poverty s1;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name VARCHAR(100), program_id INT, signup_date DATE); INSERT INTO Volunteers (id, name, program_id, signup_date) VALUES (1, 'John Doe', 1, '2020-06-01'); INSERT INTO Volunteers (id, name, program_id, signup_date) VALUES (2, 'Jane Smith', 2, '2021-03-15');
How many volunteers have participated in each program, in the last 12 months?
SELECT program_id, COUNT(*) as total_volunteers FROM Volunteers WHERE signup_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, name VARCHAR(255), ip_address VARCHAR(50), threat_level VARCHAR(10));
What are the names and types of columns in the 'threat_intelligence' table?
SELECT * FROM information_schema.columns WHERE table_name = 'threat_intelligence';
gretelai_synthetic_text_to_sql
CREATE TABLE construction_equipment (equipment_id INT, equipment_name TEXT, equipment_age INT, equipment_status TEXT);
Delete all records from the 'construction_equipment' table where the 'equipment_age' is greater than 10
DELETE FROM construction_equipment WHERE equipment_age > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (region VARCHAR(255), event_count INT);
What is the total number of defense diplomacy events held in the Asia-Pacific region?
SELECT SUM(event_count) FROM defense_diplomacy WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Technologies (Name VARCHAR(255), Operation VARCHAR(255)); INSERT INTO Military_Technologies (Name, Operation) VALUES ('M1 Abrams', 'Operation Desert Storm'), ('AH-64 Apache', 'Operation Desert Storm'), ('M2 Bradley', 'Operation Desert Storm');
List the military technologies used in Operation Desert Storm.
SELECT Name FROM Military_Technologies WHERE Operation = 'Operation Desert Storm';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'HR'), (2, 'IT'), (3, 'Sales'); CREATE TABLE training_programs (id INT, department_id INT, duration INT); INSERT INTO training_programs (id, department_id, duration) VALUES (1, 1, 20), (2, 2, 30), (3, 3, 15);
What is the average training program duration by department?
SELECT departments.name, AVG(training_programs.duration) as avg_duration FROM departments JOIN training_programs ON departments.id = training_programs.department_id GROUP BY departments.name;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name TEXT, country TEXT, start_date DATE); INSERT INTO carbon_offset_programs (id, name, country, start_date) VALUES (1, 'GreenEra', 'Canada', '2016-01-01');
List the carbon offset programs in Canada and Australia that have a start date on or after 2015.
SELECT name, country, start_date FROM carbon_offset_programs WHERE country IN ('Canada', 'Australia') AND start_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, organization_id INT, country TEXT, grant_amount DECIMAL(10,2), grant_date DATE); INSERT INTO grants (id, organization_id, country, grant_amount, grant_date) VALUES (1, 1, 'India', 10000.00, '2021-01-01'), (2, 2, 'China', 20000.00, '2021-02-15'), (3, 1, 'India', 15000.00, '2021-12-31');
What was the total amount of grants awarded to organizations in Asia in 2021?
SELECT SUM(grant_amount) FROM grants WHERE country = 'Asia' AND grant_date >= '2021-01-01' AND grant_date <= '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE inmates (inmate_id INT, inmate_name VARCHAR(255), org_id INT, sentence_length INT, PRIMARY KEY (inmate_id)); CREATE TABLE legal_organizations (org_id INT, org_name VARCHAR(255), PRIMARY KEY (org_id)); INSERT INTO inmates (inmate_id, inmate_name, org_id, sentence_length) VALUES (1, 'Inmate 1', 1, 60), (2, '...
Calculate the average sentence length for inmates in each legal organization
SELECT o.org_name, AVG(i.sentence_length) FROM inmates i INNER JOIN legal_organizations o ON i.org_id = o.org_id GROUP BY o.org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL); INSERT INTO donors (donor_id, donor_name, donation_amount) VALUES (1, 'John Doe', 50.00), (2, 'Jane Smith', 100.00);
What is the total amount donated by individuals in the "donors" table?
SELECT SUM(donation_amount) FROM donors WHERE donor_type = 'individual';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_number INT PRIMARY KEY, case_name VARCHAR(255), date_filed DATE, case_type VARCHAR(255), status VARCHAR(50), victim_id INT, defendant_id INT, program_id INT);
Insert a new case record into the 'cases' table
INSERT INTO cases (case_number, case_name, date_filed, case_type, status, victim_id, defendant_id, program_id) VALUES (2022002, 'USA v. Garcia', '2022-01-03', 'Misdemeanor', 'In Progress', 1005, 2006, 3006);
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID int, Name varchar(50), Country varchar(50), StartDate date); INSERT INTO ExcavationSites (SiteID, Name, Country, StartDate) VALUES (6, 'Site F', 'France', '2014-12-12'); CREATE TABLE Artifacts (ArtifactID int, SiteID int, Name varchar(50), Description text, DateFound date);
Display the names and countries of excavation sites without artifacts
SELECT es.Name, es.Country FROM ExcavationSites es LEFT JOIN Artifacts a ON es.SiteID = a.SiteID WHERE a.ArtifactID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), community VARCHAR(50), country VARCHAR(50)); INSERT INTO customers (customer_id, name, community, country) VALUES (1, 'Jamal Johnson', 'Black', 'US'), (2, 'Maria Rodriguez', 'Latino', 'US'); CREATE TABLE products (product_id INT, name VARCHAR(50), sustainable B...
How many customers from marginalized communities have purchased sustainable fashion items in the US?
SELECT COUNT(*) FROM sales s INNER JOIN customers c ON s.customer_id = c.customer_id INNER JOIN products p ON s.product_id = p.product_id WHERE c.country = 'US' AND p.name = 'Eco-Friendly Dress' AND c.community IN ('Black', 'Latino', 'Native American', 'Asian', 'Pacific Islander');
gretelai_synthetic_text_to_sql
CREATE TABLE Teachers (TeacherID INT, Name VARCHAR(100), Subject VARCHAR(50));
Create a table named 'Teachers' with columns 'TeacherID', 'Name', 'Subject'
CREATE TABLE Teachers (TeacherID INT, Name VARCHAR(100), Subject VARCHAR(50));
gretelai_synthetic_text_to_sql
CREATE TABLE country_protected_areas (country TEXT, protected_area TEXT, max_depth_m FLOAT); INSERT INTO country_protected_areas (country, protected_area, max_depth_m) VALUES ('Canada', 'Fathom Five National Marine Park', 150.0), ('USA', 'Channel Islands National Marine Sanctuary', 1500.0), ('Australia', 'Lord Howe Mar...
Which countries have marine protected areas deeper than 1000 meters?
SELECT country FROM country_protected_areas WHERE max_depth_m > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title TEXT, topic TEXT); INSERT INTO articles (article_id, title, topic) VALUES (1, 'Climate Change Impact', 'climate change'), (2, 'Climate Change Solutions', 'climate change'); CREATE TABLE user_comments (comment_id INT, article_id INT, user_id INT, comment TEXT); INSERT INTO u...
How many users have commented on articles about climate change, excluding users who have commented more than 5 times?
SELECT COUNT(DISTINCT user_id) FROM user_comments JOIN articles ON user_comments.article_id = articles.article_id WHERE articles.topic = 'climate change' HAVING COUNT(user_comments.user_id) <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE hydro ( country VARCHAR(20), capacity INT, status VARCHAR(20) );
Insert new records for a 'hydro' table: Canada, 10, operational
INSERT INTO hydro (country, capacity, status) VALUES ('Canada', 10, 'operational');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovations (id INT PRIMARY KEY, country VARCHAR(50), year INT, innovation VARCHAR(100)); INSERT INTO MilitaryInnovations (id, country, year, innovation) VALUES (2, 'Russia', 2012, 'Stealth submarine');
How many military innovations were made by Russia between 2010 and 2015?
SELECT COUNT(*) FROM MilitaryInnovations WHERE country = 'Russia' AND year BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (id INT PRIMARY KEY, aircraft_model VARCHAR(100), manufacturer VARCHAR(100), severity VARCHAR(50), report_date DATE);
Return all flight safety records with a severity level of "High" for aircraft manufactured by Boeing from the flight_safety table
SELECT * FROM flight_safety WHERE manufacturer = 'Boeing' AND severity = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (Id INT, Country VARCHAR(50), Year INT, VehicleType VARCHAR(50), QuantitySold INT); INSERT INTO SalesData (Id, Country, Year, VehicleType, QuantitySold) VALUES (1, 'Japan', 2018, 'Hybrid', 250000), (2, 'Japan', 2020, 'Hybrid', 400000), (3, 'Japan', 2019, 'Hybrid', 300000), (4, 'Japan', 2021, 'Hyb...
How many hybrid vehicles were sold in Japan in 2020?
SELECT SUM(QuantitySold) FROM SalesData WHERE Country = 'Japan' AND VehicleType = 'Hybrid' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_conferences(id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); INSERT INTO ai_conferences (id, name, location) VALUES (1, 'NeurIPS', 'USA'), (2, 'ICML', 'Canada'), (3, 'AAAI', 'Australia');
Which AI conferences have been held in Canada?
SELECT * FROM ai_conferences WHERE location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10, 2)); INSERT INTO rural_infrastructure (id, project_name, location, budget) VALUES (1, 'Bridge A', 'Bridgetown', 50000.00); INSERT INTO rural_infrastructure (id, project_name, location, budget) VALUES (2, 'Bridg...
What is the total budget for rural infrastructure projects in 'Bridgetown'?
SELECT SUM(budget) FROM rural_infrastructure WHERE location = 'Bridgetown';
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_support.organizations (id INT, name VARCHAR(50), people_supported INT);
What is the number of organizations that support more than 1000 people?
SELECT COUNT(*) FROM refugee_support.organizations WHERE people_supported > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryDefenseDiplomacyOperations (id INT, country VARCHAR(50), military_personnel INT);
What is the average number of military personnel in defense diplomacy operations by country, for countries with more than 150 personnel?
SELECT country, AVG(military_personnel) FROM CountryDefenseDiplomacyOperations GROUP BY country HAVING COUNT(*) > 150;
gretelai_synthetic_text_to_sql
CREATE TABLE atlantic_protected_areas (id INT, name VARCHAR(255), depth FLOAT, area_size FLOAT); INSERT INTO atlantic_protected_areas (id, name, depth, area_size) VALUES (1, 'Azores', 1500, 97810);
What is the average depth of all marine protected areas in the Atlantic Ocean, ranked by depth?
SELECT depth, name FROM (SELECT depth, name, ROW_NUMBER() OVER (ORDER BY depth DESC) AS rn FROM atlantic_protected_areas) t WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, name VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO vessels (vessel_id, name, type, capacity) VALUES (1, 'MV Ocean Wave', 'Container Ship', 12000), (2, 'MS Ocean Breeze', 'Tanker', 8000);
What is the total capacity of all vessels in the 'vessels' table?
SELECT SUM(capacity) FROM vessels;
gretelai_synthetic_text_to_sql
CREATE TABLE feedback (service VARCHAR(255), date DATE); INSERT INTO feedback (service, date) VALUES ('education', '2023-01-01'), ('education', '2023-01-15'), ('healthcare', '2023-02-01'), ('transportation', '2023-03-01');
How many citizen feedback records were received for each public service in the state of California in the last month?
SELECT service, COUNT(*) FROM feedback WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY service;
gretelai_synthetic_text_to_sql
CREATE TABLE exports (id INT, element TEXT, location TEXT, date DATE, quantity INT); INSERT INTO exports (id, element, location, date, quantity) VALUES (1, 'scandium', 'Europe', '2019-01-01', 500), (2, 'scandium', 'Europe', '2020-01-01', 600);
What is the total amount of scandium exported to Europe in the last 3 years?
SELECT SUM(quantity) FROM exports WHERE element = 'scandium' AND location = 'Europe' AND extract(year from date) >= 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (id INT, policyholder_id INT, claim_amount DECIMAL(10,2), claim_date DATE); INSERT INTO Claims (id, policyholder_id, claim_amount, claim_date) VALUES (3, 1003, 7000.00, '2021-03-20'); INSERT INTO Claims (id, policyholder_id, claim_amount, claim_date) VALUES (4, 1003, 2000.00, '2021-08-12');
Calculate the total claim amount for policyholder 1003 for the year 2021.
SELECT policyholder_id, SUM(claim_amount) FROM Claims WHERE policyholder_id = 1003 AND claim_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY policyholder_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Healthcare (District VARCHAR(255), FacilityType VARCHAR(255), Quantity INT); INSERT INTO Healthcare (District, FacilityType, Quantity) VALUES ('DistrictA', 'Hospital', 2), ('DistrictA', 'Clinic', 5), ('DistrictB', 'Hospital', 3), ('DistrictB', 'Clinic', 4);
How many healthcare facilities are there in each district?
SELECT District, FacilityType, SUM(Quantity) FROM Healthcare GROUP BY District, FacilityType;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_accounts (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10,2));
Find the top 10 customers by the total balance in their Shariah-compliant accounts.
SELECT customer_id, SUM(balance) FROM shariah_accounts WHERE account_type = 'Shariah-compliant' GROUP BY customer_id ORDER BY SUM(balance) DESC FETCH FIRST 10 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_revenue (restaurant_id INT, revenue FLOAT, date DATE); INSERT INTO daily_revenue (restaurant_id, revenue, date) VALUES (1, 5000.00, '2022-01-01'), (1, 6000.00, '2022-01-02'), (1, 4000.00, '2022-01-03');
What is the average revenue per day for a specific restaurant?
SELECT AVG(revenue) as avg_daily_revenue FROM daily_revenue WHERE restaurant_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureC(id INT, city VARCHAR(20), project VARCHAR(30), budget DECIMAL(10,2)); INSERT INTO InfrastructureC(id, city, project, budget) VALUES (1, 'Paris', 'Storm Drainage', 750000.00), (2, 'Berlin', 'Sewer System', 1000000.00);
What is the average budget for all infrastructure projects in 'Paris'?
SELECT AVG(budget) FROM InfrastructureC WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50));
Create a table named 'farmers'
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50));
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Salary DECIMAL(10, 2), HireDate DATE); INSERT INTO Employees (EmployeeID, Name, Salary, HireDate) VALUES (1, 'John Doe', 50000, '2018-01-01'), (2, 'Jane Smith', 55000, '2020-03-15'), (3, 'Mike Johnson', 60000, '2019-08-25'), (4, 'Sara Doe', 45000, '2019-11-04');
Display the names and salaries of employees who were hired before 2020, ordered by salary.
SELECT Name, Salary FROM Employees WHERE YEAR(HireDate) < 2020 ORDER BY Salary;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), hire_date DATE, salary INT, country VARCHAR(50));
Update the salary of all employees hired in the North America region in 2021 to 55000.
UPDATE employees SET salary = 55000 WHERE hire_date >= '2021-01-01' AND hire_date < '2022-01-01' AND country IN (SELECT region FROM regions WHERE region_name = 'North America');
gretelai_synthetic_text_to_sql
CREATE TABLE player_demographics (player_id INT, age INT, favorite_genre VARCHAR(20)); INSERT INTO player_demographics (player_id, age, favorite_genre) VALUES (1, 25, 'Action'), (2, 30, 'RPG'), (3, 22, 'Action'), (4, 35, 'Simulation');
What's the average age of players who play action games?
SELECT AVG(age) FROM player_demographics WHERE favorite_genre = 'Action';
gretelai_synthetic_text_to_sql
CREATE TABLE DisabilitySupportPrograms (ProgramID int, ProgramName varchar(50), Country varchar(50)); INSERT INTO DisabilitySupportPrograms (ProgramID, ProgramName, Country) VALUES (1, 'Assistive Technology', 'USA'), (2, 'Sign Language Interpretation', 'Canada'), (3, 'Mental Health Services', 'Australia'), (4, 'Physica...
What is the total number of participants in disability support programs by country?
SELECT Country, COUNT(*) as TotalParticipants FROM DisabilitySupportPrograms GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, region VARCHAR(255), savings DECIMAL(10,2), has_socially_responsible_loan BOOLEAN);
Show the total savings of customers who have a socially responsible loan in a specific region
SELECT SUM(savings) FROM customers WHERE region = 'Asia' AND has_socially_responsible_loan = TRUE;
gretelai_synthetic_text_to_sql
CREATE SCHEMA trans schemas.trans; CREATE TABLE red_line (route_id INT, fare FLOAT, date DATE); INSERT INTO red_line (route_id, fare, date) VALUES (101, 2.50, '2021-06-01'), (101, 2.50, '2021-06-02'), (101, 2.50, '2021-06-03'), (101, 2.50, '2021-06-04'), (101, 2.50, '2021-06-05'), (101, 2.50, '2021-06-06'), (101, 2.50,...
What was the average daily fare collection for the 'Red Line' in June 2021?
SELECT AVG(fare) FROM red_line WHERE route_id = 101 AND EXTRACT(MONTH FROM date) = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (id INT, name TEXT); CREATE TABLE MedicalData (id INT, astronaut_id INT, timestamp TIMESTAMP); CREATE TABLE SpaceMissions (id INT, astronaut_id INT, mission TEXT, start_date DATE, end_date DATE);
What is the average medical data record frequency for each astronaut during space missions?
SELECT a.name, AVG(DATEDIFF('second', m.start_date, m.end_date) / COUNT(*)) FROM Astronauts a JOIN MedicalData m ON a.id = m.astronaut_id JOIN SpaceMissions s ON a.id = s.astronaut_id GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, workers INT); INSERT INTO hospitals (id, name, state, workers) VALUES (1, 'Hospital A', 'NY', 50), (2, 'Hospital B', 'NY', 75), (3, 'Hospital C', 'FL', 60), (4, 'Hospital D', 'FL', 80), (5, 'Hospital E', 'CA', 65), (6, 'Hospital F', 'CA', 70);
What is the average number of healthcare workers per hospital in each state?
SELECT state, AVG(workers) FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_id INT, state_name TEXT, unvaccinated_children INT); INSERT INTO states (state_id, state_name, unvaccinated_children) VALUES (1, 'California', 2500), (2, 'Texas', 3000), (3, 'New York', 1800);
What is the percentage of unvaccinated children in each state?
SELECT state_name, (unvaccinated_children::float/SUM(unvaccinated_children) OVER ()) * 100 AS percentage FROM states;
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, product TEXT, weight FLOAT, is_fair_trade BOOLEAN, country TEXT); INSERT INTO imports (id, product, weight, is_fair_trade, country) VALUES (1, 'Coffee Beans', 150.0, true, 'Australia'); INSERT INTO imports (id, product, weight, is_fair_trade, country) VALUES (2, 'Coffee Beans', 200.0, fals...
What is the total weight of fair trade coffee beans imported to Australia?
SELECT SUM(weight) FROM imports WHERE product = 'Coffee Beans' AND is_fair_trade = true AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(50), region VARCHAR(20)); INSERT INTO donors (donor_id, donor_name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'), (3, 'Alice Johnson', 'East'), (4, 'Bob Brown', 'North'), (5, 'Charlie Davis', 'West'); CREATE TABLE donations (donor_id INT, dona...
What is the average donation amount for donors in each region?
SELECT AVG(donation_amount) AS avg_donation, region FROM donations d JOIN donors don ON d.donor_id = don.donor_id GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE tuberculosis_cases (country TEXT, num_cases INT); INSERT INTO tuberculosis_cases (country, num_cases) VALUES ('India', 2500000), ('Indonesia', 1000000), ('China', 850000), ('Philippines', 600000), ('Pakistan', 500000);
What is the number of tuberculosis cases for each country in the tuberculosis_cases table?
SELECT country, num_cases FROM tuberculosis_cases;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (id INT, customer_id INT, balance DECIMAL(10,2), transaction_date DATE);
Calculate the average daily balance for each customer in Q3 2021.
SELECT customer_id, AVG(balance) as avg_balance FROM accounts WHERE transaction_date >= '2021-07-01' AND transaction_date < '2021-10-01' GROUP BY customer_id, DATEADD(day, DATEDIFF(day, 0, transaction_date), 0) ORDER BY customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE AssistiveTechnology (studentID INT, accommodationType VARCHAR(50), cost DECIMAL(5,2));
What is the average cost of accommodations per student in the AssistiveTechnology table?
SELECT AVG(cost) FROM AssistiveTechnology;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Players VALUES (1,25,'Male'),(2,30,'Female'),(3,35,'Non-binary');
Update the age of the player with PlayerID 1 to 26.
UPDATE Players SET Age = 26 WHERE PlayerID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_registry (id INT, vessel_name VARCHAR(50), build_date DATE);
Find the number of vessels in the 'vessel_registry' table that were built after 2015
SELECT COUNT(*) FROM vessel_registry WHERE YEAR(build_date) > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE Survival (Country VARCHAR(20), Species VARCHAR(20), SurvivalRate FLOAT, TimePeriod INT); INSERT INTO Survival (Country, Species, SurvivalRate, TimePeriod) VALUES ('Norway', 'Seabass', 0.85, 2), ('Norway', 'Mussels', 0.92, 2), ('Spain', 'Seabass', 0.88, 3), ('Spain', 'Mussels', 0.90, 3), ('Japan', 'Seabass'...
What is the survival rate of seabass and mussels by country, and which countries have the lowest survival rates for these species over a specific time period?
SELECT Country, Species, SurvivalRate, TimePeriod FROM Survival WHERE Species IN ('Seabass', 'Mussels') AND SurvivalRate = (SELECT MIN(SurvivalRate) FROM Survival WHERE Species IN ('Seabass', 'Mussels') AND TimePeriod = Survival.TimePeriod) ORDER BY TimePeriod;
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_management (vessel_id INT, vessel_name VARCHAR(50), launch_date DATE); INSERT INTO fleet_management (vessel_id, vessel_name, launch_date) VALUES (1, 'Vessel_A', '2015-01-01'), (2, 'Vessel_B', '2016-01-01'), (3, 'Vessel_C', '2017-01-01'), (4, 'Vessel_D', '2017-01-02');
What is the average age of vessels launched in 2017 in the fleet_management table?
SELECT AVG(DATEDIFF(CURDATE(), launch_date) / 365.25) FROM fleet_management WHERE YEAR(launch_date) = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name TEXT, league TEXT, sport TEXT); INSERT INTO teams (team_id, team_name, league, sport) VALUES (1, 'Seattle Seahawks', 'NFL', 'American Football'); CREATE TABLE games (game_id INT, team_id INT, touchdowns INT, season_year INT); INSERT INTO games (game_id, team_id, touchdowns, se...
What is the highest number of touchdowns scored by the 'Seattle Seahawks' in a single game in the 'NFL'?
SELECT MAX(touchdowns) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'Seattle Seahawks') AND league = 'NFL';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (country VARCHAR(50), year INT, grant_amount INT, grant_type VARCHAR(20)); INSERT INTO grants (country, year, grant_amount, grant_type) VALUES ('Kenya', 2015, 50000, 'climate'), ('Kenya', 2016, 55000, 'climate'), ('Nigeria', 2015, 60000, 'climate'), ('Nigeria', 2016, 65000, 'climate'), ('Egypt', 201...
Show the number of climate-related grants and their total value awarded to each African country from 2015 to 2020?
SELECT country, COUNT(grant_amount) as num_grants, SUM(grant_amount) as total_grant_value FROM grants WHERE country IN ('Kenya', 'Nigeria', 'Egypt') AND grant_type = 'climate' AND year BETWEEN 2015 AND 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation (id INT, farm_id INT, irrigation_amount INT); INSERT INTO irrigation (id, farm_id, irrigation_amount) VALUES (1, 1, 1000), (2, 2, 1500);
What is the average water requirement for crops grown in each province in India?
SELECT provinces.name, AVG(crops.water_requirement) FROM crops JOIN (SELECT farm_id FROM farms WHERE provinces.name = provinces.name) as subquery ON crops.id = subquery.farm_id JOIN irrigation ON crops.id = irrigation.farm_id JOIN provinces ON farms.id = provinces.id GROUP BY provinces.name;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (movie_id INT, movie_title VARCHAR(100), release_year INT, studio VARCHAR(50), runtime INT); INSERT INTO movies (movie_id, movie_title, release_year, studio, runtime) VALUES (1, 'Gladiator', 2000, 'DreamWorks Pictures', 155);
What is the total runtime of all movies produced by a specific studio?
SELECT studio, SUM(runtime) as total_runtime FROM movies WHERE studio = 'DreamWorks Pictures' GROUP BY studio;
gretelai_synthetic_text_to_sql
CREATE TABLE Universities (UniversityID INT PRIMARY KEY, UniversityName VARCHAR(50), UniversityLocation VARCHAR(50)); CREATE TABLE Departments (DepartmentID INT PRIMARY KEY, DepartmentName VARCHAR(50), BudgetForDisabilityAccommodations DECIMAL(10,2)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMA...
What is the minimum budget allocated for disability accommodations in each department in a specific university?
SELECT d.DepartmentName, MIN(ud.BudgetForDisabilityAccommodations) as MinBudget FROM Departments d JOIN UniversityDepartments ud ON d.DepartmentID = ud.DepartmentID JOIN Universities u ON ud.UniversityID = u.UniversityID WHERE u.UniversityName = 'University of Toronto' GROUP BY d.DepartmentName;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT PRIMARY KEY AUTO_INCREMENT, company_id INT, amount FLOAT, funding_date DATE);
Delete funding records older than 2021 for "GreenTech Solutions"
DELETE FROM funding WHERE funding_date < '2021-01-01' AND company_id IN (SELECT id FROM company WHERE name = 'GreenTech Solutions');
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);
Display the number of peacekeeping operations by country
SELECT location, COUNT(*) FROM peacekeeping_operations GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative VARCHAR(50), budget FLOAT, status VARCHAR(20));
What is the total budget for successful community development initiatives in the 'community_development' table?
SELECT SUM(budget) FROM community_development WHERE status = 'successful';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, garment_id INT, price DECIMAL(5,2), country VARCHAR(255)); CREATE TABLE garments (id INT, garment_type VARCHAR(255), material VARCHAR(255), sustainable BOOLEAN);
Calculate the total revenue of sustainable fabric sales in the US
SELECT SUM(sales.price) FROM sales JOIN garments ON sales.garment_id = garments.id WHERE garments.sustainable = TRUE AND sales.country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimeline (Project VARCHAR(50), PermitIssueDate DATE, ProjectCompletionDate DATE, SustainableBuilding INT);
What is the average number of days between permit issuance and project completion, for sustainable building projects in each state, ordered from shortest to longest?
SELECT State, AVG(DATEDIFF(ProjectCompletionDate, PermitIssueDate)) as AvgDays FROM ProjectTimeline WHERE SustainableBuilding = 1 GROUP BY State ORDER BY AvgDays;
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (id INT, name VARCHAR(50)); CREATE TABLE species (id INT, ocean_id INT, name VARCHAR(50), max_size FLOAT, avg_temp FLOAT); INSERT INTO oceans VALUES (1, 'Pacific Ocean'); INSERT INTO species VALUES (1, 1, 'Whale Shark', 1200, 22), (2, 1, 'Basking Shark', 1000, 18), (3, 1, 'Swordfish', 450, 28);
What is the average water temperature in the Pacific Ocean for fish species with a maximum size over 200 cm?
SELECT AVG(s.avg_temp) as avg_temp FROM species s INNER JOIN oceans o ON s.ocean_id = o.id WHERE o.name = 'Pacific Ocean' AND s.max_size > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE Species_5 (id INT, name VARCHAR(255), region VARCHAR(255), year INT); INSERT INTO Species_5 (id, name, region, year) VALUES (1, 'Shark', 'Europe', 2015); INSERT INTO Species_5 (id, name, region, year) VALUES (2, 'Whale', 'Europe', 2016); INSERT INTO Species_5 (id, name, region, year) VALUES (3, 'Turtle', '...
Update marine species records in 'Europe' from 2015 to 'Dolphin'.
UPDATE Species_5 SET name = 'Dolphin' WHERE region = 'Europe' AND year IN (2015, 2016, 2017, 2018);
gretelai_synthetic_text_to_sql
CREATE TABLE community_initiatives (initiative VARCHAR(50), farmer_count INT); INSERT INTO community_initiatives (initiative, farmer_count) VALUES ('Clean Water Access', 350), ('Renewable Energy', 200), ('Education', 400);
How many farmers are involved in each community development initiative?
SELECT initiative, farmer_count FROM community_initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY, name VARCHAR, description VARCHAR);
List all waste types and their descriptions
SELECT name, description FROM WasteTypes;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridge (bridge_id INT, state VARCHAR(20), construction_cost DECIMAL(10,2)); INSERT INTO Bridge (bridge_id, state, construction_cost) VALUES (1, 'California', 1500000.00), (2, 'Texas', 2000000.00);
What is the total construction cost for bridges in California?
SELECT SUM(construction_cost) FROM Bridge WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Providers (ID INT, Name TEXT, State TEXT, Type TEXT); INSERT INTO Providers VALUES (1, 'Dr. Smith', 'KY', 'Doctor'); INSERT INTO Providers VALUES (2, 'Jane Doe, RN', 'WV', 'Nurse'); INSERT INTO Providers VALUES (3, 'Mobile Medical Unit', 'KY', 'Clinic');
Count the number of healthcare providers in each state in the rural healthcare system.
SELECT State, COUNT(*) AS Total FROM Providers GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); CREATE TABLE Maintenance (id INT, infrastructure_id INT, maintenance_date DATE, maintenance_type VARCHAR(255)); INSERT INTO Infrastructure (id, name, type, location) VALUES (1, 'Road A', 'Road', 'Texas'); INSERT INTO Infr...
Determine the number of road maintenance activities performed in Texas
SELECT COUNT(*) FROM Maintenance WHERE maintenance_type = 'Road Maintenance' AND infrastructure_id IN (SELECT id FROM Infrastructure WHERE location = 'Texas' AND type = 'Road');
gretelai_synthetic_text_to_sql
CREATE TABLE SocialServicesProjects (ProjectID INT, Name VARCHAR(100), Budget DECIMAL(10,2), Year INT, State VARCHAR(50)); INSERT INTO SocialServicesProjects (ProjectID, Name, Budget, Year, State) VALUES (1, 'Homeless Shelter', 2000000, 2022, 'Texas'), (2, 'Food Assistance Program', 500000, 2022, 'Texas'), (3, 'Job Tra...
What is the minimum budget for any project related to social services in the state of Texas in the year 2022?
SELECT MIN(Budget) FROM SocialServicesProjects WHERE Year = 2022 AND State = 'Texas' AND Name LIKE '%social services%';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_spending_ext (id INT, country VARCHAR(50), year INT, international_visitors INT, total_expenditure FLOAT, sustainability_practice BOOLEAN); INSERT INTO tourism_spending_ext (id, country, year, international_visitors, total_expenditure, sustainability_practice) VALUES (1, 'Canada', 2018, 21000000, 2...
Identify the top 3 countries with the highest increase in international visitor expenditure between 2018 and 2022 that have implemented sustainable tourism practices.
SELECT t1.country, (t1.total_expenditure - t2.total_expenditure) as expenditure_increase FROM tourism_spending_ext t1 JOIN tourism_spending_ext t2 ON t1.country = t2.country AND t1.year = 2022 AND t2.year = 2018 WHERE t1.sustainability_practice = true GROUP BY t1.country ORDER BY expenditure_increase DESC LIMIT 3;
gretelai_synthetic_text_to_sql