context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE security_incidents (id INT, country VARCHAR(255), timestamp TIMESTAMP);
|
Which countries have had the most security incidents in the last 6 months?
|
SELECT country, COUNT(*) FROM security_incidents WHERE timestamp >= NOW() - INTERVAL 6 MONTH GROUP BY country ORDER BY COUNT(*) DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE midwest_region (region VARCHAR(20), budget INT); INSERT INTO midwest_region (region, budget) VALUES ('Midwest', 50000); INSERT INTO midwest_region (region, budget) VALUES ('Midwest', 75000);
|
What is the average budget for assistive technology programs in the Midwest region?
|
SELECT AVG(budget) FROM midwest_region WHERE region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteDeployments (id INT, organization VARCHAR(50), launch_year INT, launch_success BOOLEAN); INSERT INTO SatelliteDeployments (id, organization, launch_year, launch_success) VALUES (1, 'NASA', 2010, true), (2, 'NASA', 2015, true), (3, 'SpaceX', 2017, true), (4, 'SpaceX', 2018, false), (5, 'ISRO', 2020, true);
|
List the number of satellites deployed per year by each organization.
|
SELECT organization, launch_year, COUNT(*) as total_satellites FROM SatelliteDeployments GROUP BY organization, launch_year ORDER BY organization, launch_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_practices (id INT, project_name VARCHAR(255), country VARCHAR(255));
|
Update the name of the project to 'Soil Conservation' in the 'agricultural_practices' table
|
UPDATE agricultural_practices SET project_name = 'Soil Conservation' WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(255), severity FLOAT, discovered_at TIMESTAMP); INSERT INTO vulnerabilities (id, sector, severity, discovered_at) VALUES (1, 'healthcare', 7.0, '2021-04-01 12:00:00'), (2, 'finance', 5.5, '2021-05-05 14:30:00');
|
What is the average severity of vulnerabilities in the healthcare sector in the last quarter?
|
SELECT AVG(severity) FROM vulnerabilities WHERE discovered_at >= DATE_SUB(NOW(), INTERVAL 3 MONTH) AND sector = 'healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diabetes_patients_asia (name TEXT, location TEXT, country TEXT); INSERT INTO diabetes_patients_asia (name, location, country) VALUES ('Patient 1', 'Rural India', 'India'), ('Patient 2', 'Rural Pakistan', 'Pakistan'), ('Patient 3', 'Urban Pakistan', 'Pakistan'), ('Patient 4', 'Rural Bangladesh', 'Bangladesh');
|
What is the prevalence of diabetes in rural areas of India, Pakistan, and Bangladesh?
|
SELECT country, ROUND(COUNT(*)*100.0/((SELECT COUNT(*) FROM diabetes_patients_asia WHERE country = t.country)::FLOAT), 2) AS prevalence FROM diabetes_patients_asia t WHERE location LIKE 'Rural%' GROUP BY country
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recalls_data (id INT, recall_date DATE, make VARCHAR(50), model VARCHAR(50), num_recalled INT);
|
Find the total number of vehicle recalls for each make in the 'recalls_data' table.
|
SELECT make, SUM(num_recalled) FROM recalls_data GROUP BY make;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthProvider (ProviderID INT, WorkerID INT, WorkerName VARCHAR(50)); INSERT INTO MentalHealthProvider (ProviderID, WorkerID, WorkerName) VALUES (1, 1, 'John'), (2, 2, 'Jane'), (3, 3, 'Jim'), (4, 4, 'Joan'), (5, 5, 'Jake'), (6, 1, 'Jill'), (7, 2, 'Jeff'), (8, 3, 'Jessica'), (9, 4, 'Jeremy'), (10, 5, 'Jamie');
|
List the names of community health workers who serve the most mental health providers.
|
SELECT WorkerName, COUNT(*) as NumProviders FROM MentalHealthProvider GROUP BY WorkerName ORDER BY NumProviders DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trams (id INT PRIMARY KEY, delay INT, delay_time TIMESTAMP);
|
Display the hourly breakdown of tram delays for the second half of 2021
|
SELECT HOUR(delay_time) AS delay_hour, AVG(delay) AS avg_delay FROM trams WHERE delay_time >= '2021-07-01 00:00:00' AND delay_time < '2022-01-01 00:00:00' GROUP BY delay_hour;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shelters (id INT, name TEXT, capacity INT, area TEXT); INSERT INTO shelters (id, name, capacity, area) VALUES (1, 'ShelterA', 200, 'urban'), (2, 'ShelterB', 150, 'urban'), (3, 'ShelterC', 300, 'rural');
|
What's the total number of shelters and their capacities in urban areas of Colombia and Peru?
|
SELECT capacity FROM shelters WHERE area = 'urban' AND (area = 'colombia' OR area = 'peru')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE neodymium_prices (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO neodymium_prices (country, price, year) VALUES ('Australia', 85.00, 2020), ('Australia', 88.50, 2021);
|
What is the average price of neodymium produced in Australia?
|
SELECT AVG(price) FROM neodymium_prices WHERE country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (id INT, site_name TEXT, location TEXT, protection_level TEXT); INSERT INTO heritage_sites (id, site_name, location, protection_level) VALUES (1, 'Great Wall of China', 'China', 'UNESCO World Heritage Site'), (2, 'Temple of Heaven', 'China', 'National Heritage Site');
|
What are the names and protection levels of heritage sites in East Asia?
|
SELECT site_name, protection_level FROM heritage_sites WHERE location LIKE '%%East Asia%%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE loans (id INT, customer_id INT, state VARCHAR(50), value DECIMAL(10,2)); INSERT INTO loans (id, customer_id, state, value) VALUES (1, 1, 'California', 10000.00), (2, 2, 'New York', 20000.00), (3, 3, 'Texas', 15000.00);
|
What is the total value of loans issued to customers in each state?
|
SELECT state, SUM(value) FROM loans GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DroughtImpact (Id INT, Location VARCHAR(50), Impact DECIMAL(5,2), Date DATE); INSERT INTO DroughtImpact (Id, Location, Impact, Date) VALUES (1, 'California', 0.9, '2021-06-15'); INSERT INTO DroughtImpact (Id, Location, Impact, Date) VALUES (2, 'California', 0.7, '2021-07-01');
|
On which dates did California have a drought impact greater than 0.8?
|
SELECT Date, AVG(Impact) FROM DroughtImpact WHERE Location = 'California' GROUP BY Date HAVING AVG(Impact) > 0.8;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE international_visitors (visitor_country VARCHAR(50), total_visits INT); INSERT INTO international_visitors (visitor_country, total_visits) VALUES ('Brazil', 30000);
|
What is the total number of international tourists visiting Brazil, grouped by their countries of origin?
|
SELECT visitor_country, SUM(total_visits) FROM international_visitors WHERE visitor_country = 'Brazil' GROUP BY visitor_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (property_id INT, city VARCHAR(50), co_owned BOOLEAN, price INT); INSERT INTO properties (property_id, city, co_owned, price) VALUES (1, 'Portland', TRUE, 400000); INSERT INTO properties (property_id, city, co_owned, price) VALUES (2, 'Portland', TRUE, 450000); INSERT INTO properties (property_id, city, co_owned, price) VALUES (3, 'Portland', FALSE, 300000); INSERT INTO properties (property_id, city, co_owned, price) VALUES (4, 'Portland', FALSE, 500000); INSERT INTO properties (property_id, city, co_owned, price) VALUES (5, 'Portland', FALSE, 550000);
|
What is the total number of co-owned properties in the city of Portland?
|
SELECT COUNT(*) AS total_co_owned FROM properties WHERE city = 'Portland' AND co_owned = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_cars (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, horsepower INT, is_electric BOOLEAN);
|
What is the average horsepower of electric vehicles in the 'green_cars' table?
|
SELECT AVG(horsepower) FROM green_cars WHERE is_electric = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure (id INT, project_name TEXT, location TEXT, project_type TEXT); INSERT INTO infrastructure (id, project_name, location, project_type) VALUES (1, 'Smart City 1', 'Singapore', 'smart_city'), (2, 'Green Building 1', 'Japan', 'green_building');
|
List all smart city projects in the 'infrastructure' table for the 'Asia' region.
|
SELECT project_name FROM infrastructure WHERE location LIKE '%Asia%' AND project_type = 'smart_city';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RenewableCapacity (Country TEXT, Year INT, Capacity NUMBER); INSERT INTO RenewableCapacity (Country, Year, Capacity) VALUES ('China', 2020, 750000), ('United States', 2020, 500000), ('Germany', 2020, 300000), ('India', 2020, 250000), ('Brazil', 2020, 200000), ('Australia', 2020, 150000);
|
What is the total installed renewable energy capacity for the top 5 countries in 2020?
|
SELECT Country, SUM(Capacity) AS Total_Capacity FROM RenewableCapacity WHERE Year = 2020 GROUP BY Country ORDER BY Total_Capacity DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (claim_id INT, policy_number INT, claim_amount DECIMAL(10,2), claim_date DATE);
|
Display the policy numbers and claim dates for claims that were processed between '2021-01-01' and '2021-12-31'
|
SELECT policy_number, claim_date FROM claims WHERE claim_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, production_country VARCHAR(50)); INSERT INTO movies (id, title, rating, production_country) VALUES (1, 'MovieA', 7.5, 'USA'), (2, 'MovieB', 8.2, 'Spain'), (3, 'MovieC', 6.8, 'USA'), (4, 'MovieD', 9.0, 'USA');
|
What is the distribution of ratings for movies produced in the USA?
|
SELECT rating, COUNT(*) FROM movies WHERE production_country = 'USA' GROUP BY rating;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance_commitments (commitment_id INT, commitment_amount DECIMAL(10, 2), funder VARCHAR(50), region VARCHAR(50)); INSERT INTO climate_finance_commitments (commitment_id, commitment_amount, funder, region) VALUES (1, 1500000.00, 'European Investment Bank', 'Middle East and North Africa'), (2, 2000000.00, 'World Bank', 'Middle East and North Africa'), (3, 1000000.00, 'German Development Bank', 'Middle East and North Africa');
|
What is the total climate finance committed by development banks in the Middle East and North Africa?
|
SELECT SUM(commitment_amount) FROM climate_finance_commitments WHERE region = 'Middle East and North Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Resources (id INT PRIMARY KEY, resource VARCHAR(255), location VARCHAR(255), quantity INT); INSERT INTO Resources (id, resource, location, quantity) VALUES (1, 'oil', 'Russia', 10000000); INSERT INTO Resources (id, resource, location, quantity) VALUES (2, 'gas', 'Norway', 8000000);
|
Calculate the total amount of oil and gas resources in each Arctic country.
|
SELECT location, SUM(CASE WHEN resource IN ('oil', 'gas') THEN quantity ELSE 0 END) as total_quantity FROM Resources GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (id INT, name TEXT, completion_date DATE, budget INT); INSERT INTO Projects (id, name, completion_date, budget) VALUES (1, 'I-405 Widening', '2022-01-01', 2000000), (2, 'LA River Revitalization', '2020-12-31', 15000000);
|
Which public works projects were completed in the last 5 years, and what was their budget?
|
SELECT name, budget FROM Projects WHERE completion_date > (CURRENT_DATE - INTERVAL '5 years')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_workers (id INT, name TEXT, age INT, position TEXT, hospital_id INT); INSERT INTO healthcare_workers (id, name, age, position, hospital_id) VALUES (1, 'John Doe', 45, 'Doctor', 2), (2, 'Jane Smith', 30, 'Nurse', 2); CREATE TABLE rural_hospitals (id INT, name TEXT, location TEXT, state TEXT); INSERT INTO rural_hospitals (id, name, location, state) VALUES (2, 'Hospital B', 'Rural Area 2', 'California');
|
What is the average age of rural healthcare workers by position?
|
SELECT position, AVG(age) FROM healthcare_workers WHERE hospital_id IN (SELECT id FROM rural_hospitals) GROUP BY position;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_providers_training (id INT, provider_id INT, state VARCHAR(20), completed_training BOOLEAN); INSERT INTO healthcare_providers_training (id, provider_id, state, completed_training) VALUES (1, 1, 'California', TRUE), (2, 2, 'New York', FALSE), (3, 3, 'Texas', TRUE);
|
How many healthcare providers in each state have completed cultural competency training?
|
SELECT state, SUM(completed_training) as providers_trained FROM healthcare_providers_training GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transaction_amounts (customer_id INT, region VARCHAR(20), transaction_amount NUMERIC(12,2)); INSERT INTO transaction_amounts (customer_id, region, transaction_amount) VALUES (1, 'Asia', 1000), (2, 'Europe', 1500), (3, 'Africa', 750), (4, 'North America', 2000), (5, 'South America', 1200), (6, 'Australia', 1750), (7, 'Asia', 1500), (8, 'Europe', 2000), (9, 'Africa', 1000), (10, 'North America', 2500);
|
Determine the difference in average transaction amounts between customers from 'North America' and 'Asia'.
|
SELECT AVG(transaction_amount) as avg_asia FROM transaction_amounts WHERE region = 'Asia' INTERSECT SELECT AVG(transaction_amount) as avg_north_america FROM transaction_amounts WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_contract_companies (id INT, company VARCHAR(50), country VARCHAR(50), year INT, contract_value FLOAT); INSERT INTO defense_contract_companies (id, company, country, year, contract_value) VALUES (1, 'BAE Systems', 'UK', 2021, 5000000); INSERT INTO defense_contract_companies (id, company, country, year, contract_value) VALUES (2, 'Airbus Group', 'France', 2021, 1000000);
|
What is the total number of defense contracts awarded to companies in Europe in 2021?
|
SELECT SUM(contract_value) FROM defense_contract_companies WHERE country IN ('UK', 'France', 'Germany', 'Italy', 'Spain') AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE webapp_vulnerabilities (id INT, asset_type VARCHAR(50), vulnerability_count INT, vulnerability_date DATE);
|
What are the top 5 most common vulnerabilities in the 'web application' asset type in the last quarter?
|
SELECT asset_type, vulnerability_count, vulnerability_date, RANK() OVER (PARTITION BY asset_type ORDER BY vulnerability_count DESC) as rank FROM webapp_vulnerabilities WHERE asset_type = 'web application' AND vulnerability_date >= DATEADD(quarter, -1, GETDATE()) AND rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, type VARCHAR(20), location VARCHAR(20), report_date DATE); INSERT INTO crimes (id, type, location, report_date) VALUES (1, 'theft', 'downtown', '2021-08-01');
|
Calculate the percentage of reported thefts in the 'downtown' and 'westside' precincts in the month of August 2021.
|
SELECT (COUNT(*) FILTER (WHERE type = 'theft')) * 100.0 / COUNT(*) FROM crimes WHERE location IN ('downtown', 'westside') AND report_date BETWEEN '2021-08-01' AND '2021-08-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_projects(id INT, project_name VARCHAR(50), start_date DATE, end_date DATE);
|
Identify the defense projects that have experienced delays of over 6 months?
|
SELECT project_name FROM defense_projects WHERE DATEDIFF(end_date, start_date) > 180;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Textile_Certifications (id INT, fabric VARCHAR(20), certification VARCHAR(50), expiration_date DATE); INSERT INTO Textile_Certifications (id, fabric, certification, expiration_date) VALUES (1, 'Cotton', 'GOTS', '2023-06-01'), (2, 'Polyester', 'OEKO-TEX', '2023-07-15'), (3, 'Wool', 'RWS', '2023-08-30'), (4, 'Silk', 'Organic Content Standard', '2023-04-20'), (5, 'Denim', 'Global Recycled Standard', '2023-09-10');
|
List all fabrics and their certifications that are expiring in the next 3 months.
|
SELECT fabric, certification FROM Textile_Certifications WHERE expiration_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fifa_world_cup (team VARCHAR(50), penalties INT); INSERT INTO fifa_world_cup (team, penalties) VALUES ('Germany', 12), ('Brazil', 10), ('France', 11), ('Croatia', 10);
|
Which team received the most penalties in the FIFA World Cup?
|
SELECT team, SUM(penalties) AS total_penalties FROM fifa_world_cup GROUP BY team ORDER BY total_penalties DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, age INT, name VARCHAR(255)); INSERT INTO donors (id, age, name) VALUES (1, 27, 'Effective Altruism Funds'); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, organization_id, amount, donation_date) VALUES (1, 1, 3, 5000, '2021-06-15');
|
Which organizations have received donations from donors aged 25-34 in the past year?
|
SELECT organizations.name FROM donations JOIN donors ON donations.donor_id = donors.id JOIN organizations ON donations.organization_id = organizations.id WHERE donors.age BETWEEN 25 AND 34 AND donation_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmer (id INT PRIMARY KEY, name VARCHAR(50), crop_id INT, region_id INT); CREATE TABLE crop (id INT PRIMARY KEY, name VARCHAR(50)); CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO crop (id, name) VALUES (1, 'Rice'); INSERT INTO region (id, name) VALUES (1, 'Delta Region'); INSERT INTO farmer (id, name, crop_id, region_id) VALUES (1, 'John Doe', 1, 1);
|
List all farmers who cultivate 'Rice' and their corresponding regions.
|
SELECT f.name, r.name AS region_name FROM farmer f INNER JOIN crop c ON f.crop_id = c.id INNER JOIN region r ON f.region_id = r.id WHERE c.name = 'Rice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Faculty (id INT, name VARCHAR(255), gender VARCHAR(10), department_id INT); INSERT INTO Faculty (id, name, gender, department_id) VALUES (1, 'John Doe', 'Male', 1), (2, 'Jane Smith', 'Female', 1), (3, 'Jamie Johnson', 'Non-binary', 2), (4, 'Alice Davis', 'Female', 3), (5, 'Bob Brown', 'Male', 3);
|
List faculty diversity metrics including the number of female, male, and non-binary faculty members
|
SELECT f.department_id, f.gender, COUNT(*) as num_faculty FROM Faculty f GROUP BY f.department_id, f.gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_safety_incidents_type (id INT, incident_name VARCHAR(50), date_reported DATE, ai_system_type VARCHAR(50)); INSERT INTO ai_safety_incidents_type (id, incident_name, date_reported, ai_system_type) VALUES (1, 'Self-driving car crash', '2022-03-15', 'Autonomous Vehicles'), (2, 'Medical diagnosis error', '2021-11-27', 'Healthcare AI'), (3, 'Financial loss due to algorithmic trading', '2022-01-10', 'Finance AI');
|
What is the total number of AI safety incidents, grouped by the type of AI system involved?
|
SELECT ai_system_type, COUNT(*) FROM ai_safety_incidents_type GROUP BY ai_system_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE articles (id INT PRIMARY KEY, title TEXT NOT NULL, author_id INT, published_at DATE);
|
Find total number of articles by each author, published in 2020
|
SELECT authors.name, COUNT(articles.id) as total_articles FROM authors INNER JOIN articles ON authors.id = articles.author_id WHERE YEAR(published_at) = 2020 GROUP BY authors.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'JPMorgan Chase', 'Financial', 80.1); INSERT INTO companies (id, name, sector, ESG_score) VALUES (2, 'Visa', 'Financial', 85.6); INSERT INTO companies (id, name, sector, ESG_score) VALUES (3, 'Bank of America', 'Financial', 79.2); CREATE TABLE sectors (id INT, sector VARCHAR(255)); INSERT INTO sectors (id, sector) VALUES (1, 'Financial'); INSERT INTO sectors (id, sector) VALUES (2, 'Healthcare');
|
What is the maximum ESG score for companies in the financial sector?
|
SELECT MAX(ESG_score) AS max_ESG_score FROM companies c JOIN sectors s ON c.sector = s.sector WHERE s.sector = 'Financial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE membership (member_id INT, membership_type VARCHAR(20), country VARCHAR(30)); INSERT INTO membership (member_id, membership_type, country) VALUES (1, 'Platinum', 'USA'), (2, 'Gold', 'Canada'), (3, 'Platinum', 'Mexico'); CREATE TABLE workout_data (member_id INT, duration INT, timestamp TIMESTAMP); INSERT INTO workout_data (member_id, duration, timestamp) VALUES (1, 180, '2022-02-01 10:00:00'), (1, 240, '2022-02-01 11:00:00'), (2, 300, '2022-02-01 10:00:00'), (2, 360, '2022-02-01 11:00:00'), (3, 90, '2022-02-01 10:00:00'), (3, 120, '2022-02-01 11:00:00');
|
Calculate the total workout duration in minutes for each country, in the last month.
|
SELECT country, SUM(duration)/60 as total_minutes FROM workout_data w JOIN membership m ON w.member_id = m.member_id WHERE timestamp BETWEEN '2022-02-01 00:00:00' AND '2022-02-28 23:59:59' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (id INT, project VARCHAR(255), budget INT);
|
Update the budget of a specific military innovation project.
|
UPDATE military_innovation SET budget = 5000000 WHERE project = 'Stealth Drone';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_revenue (sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO daily_revenue (sale_date, revenue) VALUES ('2022-01-01', 5000.00), ('2022-01-02', 6000.00), ('2022-01-03', 4000.00), ('2022-01-04', 7000.00), ('2022-01-05', 8000.00), ('2022-01-06', 3000.00), ('2022-01-07', 9000.00);
|
What is the maximum daily revenue recorded in the database?
|
SELECT MAX(revenue) FROM daily_revenue;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, product_category VARCHAR(255), sales FLOAT, sale_date DATE); INSERT INTO sales (sale_id, product_id, product_category, sales, sale_date) VALUES (1, 1, 'Electronics', 100, '2022-01-01'), (2, 2, 'Clothing', 200, '2022-01-02'), (3, 3, 'Electronics', 150, '2022-01-03');
|
Find the top 10 product categories with the highest sales in the last quarter
|
SELECT product_category, SUM(sales) FROM sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY product_category ORDER BY SUM(sales) DESC LIMIT 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), value DECIMAL(10,2)); INSERT INTO digital_assets (asset_id, asset_name, value) VALUES (1, 'Asset1', 50.5), (2, 'Asset2', 100.2), (3, 'Asset3', 75.0); CREATE TABLE smart_contracts (contract_id INT, asset_id INT, contract_name VARCHAR(50)); INSERT INTO smart_contracts (contract_id, asset_id, contract_name) VALUES (101, 1, 'Contract1'), (102, 2, 'Contract2'), (103, 3, 'Contract3');
|
Find the total number of smart contracts associated with digital assets having a value greater than 80?
|
SELECT COUNT(*) FROM smart_contracts INNER JOIN digital_assets ON smart_contracts.asset_id = digital_assets.asset_id WHERE digital_assets.value > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_adaptation (id INT, project_name TEXT, budget INT, location TEXT); INSERT INTO climate_adaptation (id, project_name, budget, location) VALUES (1, 'Flood Prevention', 75000, 'Asia'); INSERT INTO climate_adaptation (id, project_name, budget, location) VALUES (2, 'Drought Resistance', 40000, 'Africa');
|
What is the total number of climate adaptation projects in Asia with a budget less than $30,000?
|
SELECT COUNT(*) FROM climate_adaptation WHERE location = 'Asia' AND budget < 30000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Meals (MealID INT, MealName VARCHAR(50), ContainsGMO BOOLEAN); INSERT INTO Meals VALUES (1, 'Meal1', true); INSERT INTO Meals VALUES (2, 'Meal2', false); CREATE TABLE Restaurants (RestaurantID INT, MealID INT, City VARCHAR(20)); INSERT INTO Restaurants VALUES (1, 1); INSERT INTO Restaurants VALUES (2, 2);
|
Find all meals containing genetically modified ingredients served in our California restaurants.
|
SELECT Meals.MealName FROM Meals INNER JOIN Restaurants ON Meals.MealID = Restaurants.MealID WHERE Restaurants.City = 'California' AND Meals.ContainsGMO = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, name VARCHAR(50), country VARCHAR(50), energy_consumption INT); INSERT INTO green_buildings (id, name, country, energy_consumption) VALUES (1, 'GreenHub', 'USA', 1200), (2, 'EcoTower', 'Canada', 1500), (3, 'SolarVista', 'Mexico', 1800), (4, 'WindHaven', 'USA', 1000), (5, 'SolarCity', 'China', 1600), (6, 'EcoRail', 'Japan', 2000);
|
How many green building projects have been implemented in each country?
|
SELECT country, COUNT(*) FROM green_buildings GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE unions (id INT, name TEXT, location TEXT); INSERT INTO unions (id, name, location) VALUES (1, 'Union X', 'USA'), (2, 'Union Y', 'Canada'), (3, 'Union Z', 'Mexico'); CREATE TABLE regions (id INT, region TEXT); INSERT INTO regions (id, region) VALUES (1, 'North'), (2, 'South'), (3, 'Central'); CREATE TABLE safety_scores (id INT, union_id INT, region_id INT, score INT); INSERT INTO safety_scores (id, union_id, region_id, score) VALUES (1, 1, 1, 85), (2, 1, 2, 90), (3, 2, 1, 70), (4, 2, 3, 80), (5, 3, 2, 85);
|
What is the rank of each union by total safety score, partitioned by region?
|
SELECT u.name, RANK() OVER (PARTITION BY r.region ORDER BY SUM(s.score) DESC) as rank FROM safety_scores s JOIN unions u ON s.union_id = u.id JOIN regions r ON s.region_id = r.id GROUP BY u.name, r.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_applications (app_id INT, app_name TEXT, safety_rating FLOAT);
|
What is the average safety rating of all creative AI applications in the 'ai_applications' table?
|
SELECT AVG(safety_rating) FROM ai_applications;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, ingredient VARCHAR(255), product_id INT, price DECIMAL(5,2), gram_weight DECIMAL(5,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), brand VARCHAR(255)); INSERT INTO ingredients (ingredient_id, ingredient, product_id, price, gram_weight) VALUES (1, 'Aqua', 1, 0.01, 1000), (2, 'Glycerin', 1, 0.1, 100), (3, 'Sodium Laureth Sulfate', 2, 0.2, 50), (4, 'Cocamidopropyl Betaine', 2, 0.3, 50), (5, 'Parfum', 3, 1.5, 10), (6, 'Shea Butter', 4, 2.5, 25), (7, 'Jojoba Oil', 4, 3.5, 15); INSERT INTO products (product_id, product_name, brand) VALUES (1, 'Loreal Shampoo', 'Loreal'), (2, 'Loreal Conditioner', 'Loreal'), (3, 'Estee Lauder Foundation', 'Estee Lauder'), (4, 'The Body Shop Moisturizer', 'The Body Shop');
|
List the product names and their sourced ingredients, ordered by the ingredient cost, for products from 'The Body Shop'?
|
SELECT products.product_name, ingredients.ingredient, ingredients.price FROM ingredients JOIN products ON ingredients.product_id = products.product_id WHERE products.brand = 'The Body Shop' ORDER BY ingredients.price DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title TEXT, publication_year INT, topic TEXT, author TEXT); INSERT INTO articles (id, title, publication_year, topic, author) VALUES (1, 'Article1', 2019, 'Disinformation', 'Latinx Author1'); INSERT INTO articles (id, title, publication_year, topic, author) VALUES (2, 'Article2', 2018, 'Politics', 'Author2');
|
How many articles published in 2019 were written by Latinx authors about disinformation?
|
SELECT COUNT(*) FROM articles WHERE publication_year = 2019 AND topic = 'Disinformation' AND author IN (SELECT author FROM authors WHERE ethnicity = 'Latinx');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (state VARCHAR(2), generation INT); INSERT INTO waste_generation (state, generation) VALUES ('CA', 5000000), ('NY', 4000000), ('NJ', 3000000);
|
What is the minimum waste generation in the state of New York?
|
SELECT MIN(generation) FROM waste_generation WHERE state = 'NY';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CarbonPrices (id INT, country VARCHAR(50), year INT, price FLOAT); INSERT INTO CarbonPrices (id, country, year, price) VALUES (1, 'Canada', 2020, 22.34), (2, 'Canada', 2019, 18.97), (3, 'USA', 2020, 14.56);
|
What is the average carbon price (in USD/tonne) in Canada in 2019 and 2020?
|
SELECT AVG(price) FROM CarbonPrices WHERE country = 'Canada' AND year IN (2019, 2020);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_downloads (download_id INT, game_name VARCHAR(100), download_count INT, region VARCHAR(50), date DATE);
|
Update the 'game_downloads' table to set the 'download_count' column as 10000 for the game 'Game2' in the 'North America' region
|
UPDATE game_downloads SET download_count = 10000 WHERE game_name = 'Game2' AND region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_members (id INT, member_id INT, gender VARCHAR(6), years_of_membership INT); INSERT INTO union_members (id, member_id, gender, years_of_membership) VALUES (1, 1001, 'Male', 5), (2, 1002, 'Female', 10), (3, 1003, 'Male', 7), (4, 1004, 'Non-binary', 3);
|
What is the average number of years of union membership per gender?
|
SELECT gender, AVG(years_of_membership) OVER (PARTITION BY gender) AS avg_years_of_membership FROM union_members;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region_investment (region_name VARCHAR(50), investment_amount FLOAT, population INT);
|
Identify the top 5 regions with the highest monthly mobile and broadband network infrastructure investment, including the region name, total investment amount, and average investment per capita.
|
SELECT region_name, SUM(investment_amount) as total_investment, AVG(investment_amount / population) as avg_investment_per_capita FROM region_investment WHERE investment_type IN ('mobile', 'broadband') GROUP BY region_name ORDER BY total_investment DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WaterData (Country VARCHAR(50), Population INT, CleanWaterPopulation INT); INSERT INTO WaterData (Country, Population, CleanWaterPopulation) VALUES ('Indonesia', 273523615, 221523615), ('Philippines', 113523615, 81523615);
|
What is the percentage of the population that has access to clean water in Southeast Asia?
|
SELECT Country, (CleanWaterPopulation / Population) * 100 AS PercentCleanWater FROM WaterData WHERE Country IN ('Indonesia', 'Philippines');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, region VARCHAR(50), sustainable_fabric_cost DECIMAL(5,2));
|
What is the average sustainable fabric cost per order for each region in the past month?
|
SELECT region, AVG(sustainable_fabric_cost) FROM orders WHERE sustainable = TRUE AND order_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE olympic_athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(20), country VARCHAR(50), gold_medals INT); INSERT INTO olympic_athletes (athlete_id, name, sport, country, gold_medals) VALUES (1, 'Usain Bolt', 'Track and Field', 'Jamaica', 8); INSERT INTO olympic_athletes (athlete_id, name, sport, country, gold_medals) VALUES (2, 'Michael Phelps', 'Swimming', 'USA', 23);
|
List the names of athletes who have won a gold medal in the olympic_athletes table.
|
SELECT name FROM olympic_athletes WHERE gold_medals > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_quantity INT); INSERT INTO mines (id, name, location, production_quantity) VALUES (1, 'Greenbushes', 'Australia', 3500), (2, 'Mount Weld', 'Australia', 6000);
|
What is the average production quantity (in metric tons) of Neodymium from mines located in Australia?
|
SELECT AVG(production_quantity) FROM mines WHERE location = 'Australia' AND element = 'Neodymium';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_site (site_id INT, mineral_type VARCHAR(50), production_date DATE, num_employees INT); INSERT INTO mining_site (site_id, mineral_type, production_date, num_employees) VALUES (1, 'gold', '2014-01-02', 60), (2, 'copper', '2013-12-31', 150), (3, 'gold', '2016-03-04', 20), (4, 'copper', '2015-06-10', 50);
|
What is the average number of employees per mining site, grouped by mineral type, for mining sites having a production date on or after 2014-01-01?
|
SELECT mineral_type, AVG(num_employees) as avg_employees FROM mining_site WHERE production_date >= '2014-01-01' GROUP BY mineral_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (ID INT PRIMARY KEY, Name TEXT, Manufacturer TEXT); CREATE TABLE Manufacturers (ID INT PRIMARY KEY, Name TEXT);
|
How many spacecraft were manufactured by each company?
|
SELECT m.Name, COUNT(s.ID) as Manufactured_Spacecraft FROM Manufacturers m INNER JOIN Spacecraft s ON m.Name = s.Manufacturer GROUP BY m.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationDate DATE, DonationAmount FLOAT); INSERT INTO Donors (DonorID, DonorName, DonationDate, DonationAmount) VALUES (1, 'John Smith', '2021-01-01', 50.00), (2, 'Jane Doe', '2021-02-14', 100.00);
|
What is the total amount donated by each donor in 2021?
|
SELECT DonorName, SUM(DonationAmount) as TotalDonation FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(50), industry VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, industry, funding) VALUES (1, 'StartupA', 'CA', 'Biotech', 3000000.0); INSERT INTO startups (id, name, location, industry, funding) VALUES (2, 'StartupB', 'CA', 'Biotech', 6000000.0); INSERT INTO startups (id, name, location, industry, funding) VALUES (3, 'StartupC', 'NY', 'Biotech', 5000000.0);
|
What is the total funding for biotech startups in California?
|
SELECT SUM(funding) FROM startups WHERE location = 'CA' AND industry = 'Biotech';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE language_preservation (id INT, name TEXT, location TEXT); INSERT INTO language_preservation (id, name, location) VALUES (1, 'Hawaiian Language Immersion Program', 'Hawaii, USA'), (2, 'Ainu Language Revitalization Project', 'Hokkaido, Japan');
|
What are the names and locations of all language preservation programs in the Asia-Pacific region?
|
SELECT name, location FROM language_preservation WHERE location LIKE '%%Asia-Pacific%%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (sale_id INT, product_id INT, quantity INT, price DECIMAL(10, 2), customer_id INT); CREATE TABLE Inventory (product_id INT, product_name VARCHAR(255), fabric_type VARCHAR(255)); CREATE TABLE Geography (customer_id INT, country VARCHAR(255), region VARCHAR(255));
|
What are the most popular fabric types in the Asian market?
|
SELECT I.fabric_type, COUNT(S.sale_id) AS sales_count FROM Sales S INNER JOIN Inventory I ON S.product_id = I.product_id INNER JOIN Geography G ON S.customer_id = G.customer_id WHERE G.region = 'Asia' GROUP BY I.fabric_type ORDER BY sales_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SustainableBank (id INT, loan_type VARCHAR(20), amount INT, issue_date DATE); INSERT INTO SustainableBank (id, loan_type, amount, issue_date) VALUES (1, 'SociallyResponsible', 4000, '2022-04-01');
|
What is the total amount of socially responsible loans issued by Sustainable Bank in Q2 2022?
|
SELECT SUM(amount) FROM SustainableBank WHERE loan_type = 'SociallyResponsible' AND QUARTER(issue_date) = 2 AND YEAR(issue_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species_observation (id INT PRIMARY KEY, year INT, species VARCHAR(255), location VARCHAR(255), number INT); INSERT INTO species_observation (id, year, species, location, number) VALUES (1, 2010, 'Polar Bear', 'Arctic', 300), (2, 2015, 'Beluga Whale', 'Arctic', 120);
|
Delete records of the 'Beluga Whale' species from the 'species_observation' table.
|
DELETE FROM species_observation WHERE species = 'Beluga Whale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (CHWId INT, Name VARCHAR(50)); CREATE TABLE HealthEquityMetricTrainings (HEMTrainingId INT, CHWId INT, TrainingDate DATE); INSERT INTO CommunityHealthWorkers (CHWId, Name) VALUES (1, 'Jasmine'), (2, 'Kareem'), (3, 'Leah'), (4, 'Mohammed'); INSERT INTO HealthEquityMetricTrainings (HEMTrainingId, CHWId, TrainingDate) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'), (4, 3, '2021-04-01'), (5, 4, '2021-05-01');
|
Count of community health workers who have completed health equity metric trainings.
|
SELECT COUNT(DISTINCT CHWId) FROM HealthEquityMetricTrainings;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (subscriber_id INT, subscriber_name VARCHAR(255), subscribe_date DATE, state VARCHAR(255));
|
How many new broadband subscribers have there been in each state in the past week?
|
SELECT state, COUNT(subscriber_id) as new_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transportation (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Transportation (project_id, project_name, location) VALUES (1, 'Bridge Replacement', 'Texas'); INSERT INTO Transportation (project_id, project_name, location) VALUES (2, 'Road Construction', 'Florida');
|
What are the names of the projects in the 'Transportation' table?
|
SELECT project_name FROM Transportation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (id INT, company_id INT, country VARCHAR(255));INSERT INTO warehouses (id, company_id, country) VALUES (1, 1, 'USA'), (2, 1, 'Canada'), (3, 2, 'USA');
|
Which countries do not have any warehouse locations for the company?
|
SELECT country FROM warehouses GROUP BY country HAVING COUNT(company_id) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_permits (id INT, state VARCHAR(255), year INT, assessment_score INT);
|
How many mining permits were issued in California between 2015 and 2020, and what was the environmental impact assessment score for each permit?
|
SELECT state, year, assessment_score FROM mining_permits WHERE state = 'California' AND year BETWEEN 2015 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (employee_id INT, name TEXT, gender TEXT, job_title TEXT, mining_company_id INT); INSERT INTO employees (employee_id, name, gender, job_title, mining_company_id) VALUES (1, 'Rami Hamad', 'Male', 'Miner', 1001), (2, 'Sophia Nguyen', 'Female', 'Engineer', 1001), (3, 'Carlos Mendoza', 'Male', 'Miner', 1002), (4, 'Amina Diop', 'Female', 'Manager', 1002), (5, 'Hugo Sanchez', 'Male', 'Engineer', 1003); CREATE TABLE mining_companies (mining_company_id INT, company_name TEXT); INSERT INTO mining_companies (mining_company_id, company_name) VALUES (1001, 'Aswan Gold'), (1002, 'Buzwagi Mines'), (1003, 'Cadia Valley');
|
What is the number of employees of each job title per mining company?
|
SELECT company_name, job_title, COUNT(*) AS employee_count FROM employees JOIN mining_companies ON employees.mining_company_id = mining_companies.mining_company_id GROUP BY company_name, job_title;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare.CulturalCompetency( cc_id INT PRIMARY KEY, healthcare_provider VARCHAR(100), cultural_competency_score FLOAT); INSERT INTO healthcare.CulturalCompetency (cc_id, healthcare_provider, cultural_competency_score) VALUES (1, 'Dr. Ravi Shankar', 0.88), (2, 'Dr. Chen Wei', 0.91), (3, 'Dr. Souad Haddad', 0.93), (4, 'Dr. Abdullahi Yusuf', 0.85);
|
List all healthcare providers with cultural competency score greater than or equal to 0.9
|
SELECT * FROM healthcare.CulturalCompetency WHERE cultural_competency_score >= 0.9;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Ethnicity VARCHAR(50), Gender VARCHAR(50)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Ethnicity, Gender) VALUES (1, 'John', 'Doe', 'Workforce Development', 'Hispanic', 'Male'), (2, 'Jane', 'Doe', 'Quality', 'Caucasian', 'Female'), (3, 'Mike', 'Smith', 'Workforce Development', 'African American', 'Male');
|
Identify the ethnicity and gender diversity among the employees in the 'Workforce Development' program.
|
SELECT DISTINCT Ethnicity, Gender FROM Employees WHERE Department = 'Workforce Development';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ContractNegotiations (ContractID INT, Company VARCHAR(50), Equipment VARCHAR(50), NegotiationDate DATE, ContractValue DECIMAL(10, 2)); INSERT INTO ContractNegotiations (ContractID, Company, Equipment, NegotiationDate, ContractValue) VALUES (3, 'Lockheed Martin', 'Satellite Technology', '2021-06-30', 5000000); INSERT INTO ContractNegotiations (ContractID, Company, Equipment, NegotiationDate, ContractValue) VALUES (4, 'Raytheon', 'Radar Systems', '2022-03-20', 4000000);
|
Which defense contractor has the highest average contract value for satellite technology in the last 12 months?
|
SELECT Company, AVG(ContractValue) AS AverageContractValue FROM ContractNegotiations WHERE Equipment = 'Satellite Technology' AND NegotiationDate >= DATEADD(month, -12, GETDATE()) GROUP BY Company ORDER BY AverageContractValue DESC
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerIdentities (PlayerID INT, Identity VARCHAR(50)); INSERT INTO PlayerIdentities (PlayerID, Identity) VALUES (1, 'Male'), (2, 'Female'), (3, 'Non-Binary'), (4, 'Male'), (5, 'Female'), (6, 'Non-Binary'); CREATE TABLE PlayerTechnologies (PlayerID INT, Technology VARCHAR(50)); INSERT INTO PlayerTechnologies (PlayerID, Technology) VALUES (1, 'VR'), (2, 'Non-VR'), (3, 'AR'), (4, 'VR'), (5, 'VR'), (6, 'AR');
|
How many players who identify as non-binary have used AR technology in gaming?
|
(SELECT COUNT(*) FROM PlayerIdentities JOIN PlayerTechnologies ON PlayerIdentities.PlayerID = PlayerTechnologies.PlayerID WHERE PlayerIdentities.Identity = 'Non-Binary' AND PlayerTechnologies.Technology = 'AR')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students_lifelong_learning (student_id INT, school_id INT, completed_course INT); INSERT INTO students_lifelong_learning VALUES (1, 1, 1); INSERT INTO students_lifelong_learning VALUES (2, 1, 0); INSERT INTO students_lifelong_learning VALUES (3, 2, 1); INSERT INTO students_lifelong_learning VALUES (4, 2, 1); CREATE TABLE school_roster (student_id INT, school_id INT, school_name VARCHAR(255)); INSERT INTO school_roster VALUES (1, 1, 'East High'); INSERT INTO school_roster VALUES (2, 1, 'East High'); INSERT INTO school_roster VALUES (3, 2, 'West Middle'); INSERT INTO school_roster VALUES (4, 2, 'West Middle');
|
What is the percentage of students who have completed a lifelong learning course in 'East High' school?
|
SELECT s.school_name, 100.0 * SUM(CASE WHEN sl.completed_course = 1 THEN 1 ELSE 0 END) / COUNT(sr.student_id) AS completion_percentage FROM school_roster sr INNER JOIN students_lifelong_learning sl ON sr.student_id = sl.student_id INNER JOIN schools s ON sr.school_id = s.school_id WHERE s.school_name = 'East High' GROUP BY s.school_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, country TEXT, occupancy_rate DECIMAL(5,2)); INSERT INTO hotels (hotel_id, name, city, country, occupancy_rate) VALUES (1, 'Hotel Ritz', 'Paris', 'France', 0.85);
|
What is the average occupancy rate of hotels in Paris?
|
SELECT AVG(occupancy_rate) FROM hotels 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));
|
List all records from 'farmers' table sorted by age
|
SELECT * FROM farmers ORDER BY age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles (id INT, title TEXT, publish_date DATE); INSERT INTO news_articles (id, title, publish_date) VALUES (1, 'Article 1', '2021-01-01'); INSERT INTO news_articles (id, title, publish_date) VALUES (2, 'Article 2', '2021-02-15');
|
What is the total number of news articles published in 2021, in the news_articles table?
|
SELECT COUNT(*) FROM news_articles WHERE publish_date >= '2021-01-01' AND publish_date < '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_evs (id INT, ev_battery_level INT, ev_status VARCHAR(50), ev_city VARCHAR(50));
|
Delete shared EVs with less than 80% battery in Seoul
|
DELETE FROM shared_evs WHERE ev_status = 'shared' AND ev_city = 'Seoul' AND ev_battery_level < 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meals (id INT, name TEXT, restaurant_type TEXT); INSERT INTO meals (id, name, restaurant_type) VALUES (1, 'Filet Mignon', 'fine dining'), (2, 'Chicken Caesar', 'casual dining'), (3, 'Tofu Stir Fry', 'fine dining'); CREATE TABLE nutrition (meal_id INT, calorie_count INT); INSERT INTO nutrition (meal_id, calorie_count) VALUES (1, 1200), (2, 800), (3, 900);
|
What is the maximum calorie count for meals served at fine dining restaurants?
|
SELECT MAX(nutrition.calorie_count) FROM nutrition JOIN meals ON nutrition.meal_id = meals.id WHERE meals.restaurant_type = 'fine dining';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing (Manufacturer VARCHAR(255), Country VARCHAR(255), SpacecraftModel VARCHAR(255), SpacecraftMass INT, ManufactureDate DATE); INSERT INTO SpacecraftManufacturing (Manufacturer, Country, SpacecraftModel, SpacecraftMass, ManufactureDate) VALUES ('National Aeronautics and Space Administration', 'USA', 'ApolloLunarModule', 15000, '1968-12-12'), ('National Aeronautics and Space Administration', 'USA', 'ApolloCommandModule', 30000, '1968-12-12');
|
What is the total mass of spacecraft manufactured by 'National Aeronautics and Space Administration' in the USA, grouped by the decade of their manufacture?
|
SELECT CONCAT(DATE_FORMAT(ManufactureDate, '%Y'), '0-', DATE_FORMAT(DATE_ADD(ManufactureDate, INTERVAL 10 YEAR), '%Y')) AS Decade, SUM(SpacecraftMass) AS Total_Spacecraft_Mass FROM SpacecraftManufacturing WHERE Manufacturer = 'National Aeronautics and Space Administration' GROUP BY Decade;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_consumption_yearly (year INT, consumption FLOAT); INSERT INTO energy_consumption_yearly (year, consumption) VALUES (2020, 50000.0), (2021, 55000.1), (2022, 60000.2), (2023, 65000.3), (2024, 70000.4), (2025, 75000.5);
|
Year-over-year percentage change in energy consumption from 2020 to 2025?
|
SELECT ec1.year + INTERVAL '1 year' AS year, (ec2.consumption - ec1.consumption) / ec1.consumption * 100.0 AS percentage_change FROM energy_consumption_yearly ec1 JOIN energy_consumption_yearly ec2 ON ec1.year + 1 = ec2.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exoplanets (id INT, name VARCHAR(255), discovery_date DATE, discovery_method VARCHAR(255));
|
What is the earliest discovery date for an exoplanet?
|
SELECT MIN(exoplanets.discovery_date) FROM exoplanets;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ships (name VARCHAR(50), region VARCHAR(20), last_inspection_date DATE); INSERT INTO ships (name, region, last_inspection_date) VALUES ('Ship A', 'Caribbean', '2022-02-15'), ('Ship B', 'Caribbean', '2022-03-01'), ('Ship C', 'Atlantic', '2022-03-10');
|
Identify all ships in the 'Caribbean' region with an overspeeding incident in the last month.'
|
SELECT * FROM ships WHERE region = 'Caribbean' AND last_inspection_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND last_inspection_date NOT IN (SELECT last_inspection_date FROM ships WHERE region = 'Caribbean' AND speed_violation = 'yes');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_clinic_1 (patient_id INT, age INT, gender VARCHAR(10)); INSERT INTO rural_clinic_1 (patient_id, age, gender) VALUES (1, 35, 'Male'), (2, 50, 'Female'), (3, 42, 'Male');
|
What is the average age of patients in the 'rural_clinic_1' table?
|
SELECT AVG(age) FROM rural_clinic_1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (id INT, name VARCHAR(100), sport VARCHAR(50), wellbeing_program BOOLEAN); INSERT INTO athletes (id, name, sport, wellbeing_program) VALUES (1, 'Alice', 'Soccer', TRUE); INSERT INTO athletes (id, name, sport, wellbeing_program) VALUES (2, 'Bella', 'Basketball', TRUE); INSERT INTO athletes (id, name, sport, wellbeing_program) VALUES (3, 'Charlie', 'Soccer', FALSE);
|
How many athletes participate in each sport in the Wellbeing program?
|
SELECT sport, COUNT(*) FROM athletes WHERE wellbeing_program = TRUE GROUP BY sport;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE paper_data (paper_id INT, author_id INT, field VARCHAR(50), publication_year INT); CREATE TABLE author_data (author_id INT, author_name VARCHAR(50));
|
List the number of papers published by each author in the field of Explainable AI, ordered by the most prolific?
|
SELECT a.author_name, COUNT(pd.paper_id) as num_papers FROM paper_data pd JOIN author_data a ON pd.author_id = a.author_id WHERE pd.field = 'Explainable AI' GROUP BY a.author_name ORDER BY num_papers DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthParity (ViolationID INT, ViolationType VARCHAR(255), ViolationCost FLOAT);
|
What is the minimum mental health parity violation cost in the 'MentalHealthParity' table, where the violation type is 'Service'?
|
SELECT MIN(ViolationCost) as Min_Cost FROM MentalHealthParity WHERE ViolationType = 'Service';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates_canada(year INT, material VARCHAR(20), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates_canada VALUES (2018, 'Plastic', 0.2), (2018, 'Glass', 0.3), (2018, 'Metal', 0.4);
|
What is the recycling rate for each material type in Canada in 2018?
|
SELECT material, AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates_canada WHERE year = 2018 GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Patients (ID INT, Gender VARCHAR(10), Disease VARCHAR(20), Country VARCHAR(30), Diagnosis_Date DATE); INSERT INTO Patients (ID, Gender, Disease, Country, Diagnosis_Date) VALUES (1, 'Male', 'Ebola', 'Democratic Republic of Congo', '2021-01-01');
|
What is the total number of patients diagnosed with Ebola in Democratic Republic of Congo in 2021?
|
SELECT COUNT(*) FROM Patients WHERE Disease = 'Ebola' AND Country = 'Democratic Republic of Congo' AND YEAR(Diagnosis_Date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_farms (id INT, name TEXT, country TEXT, energy_efficiency_rating FLOAT); INSERT INTO solar_farms (id, name, country, energy_efficiency_rating) VALUES (1, 'Kamuthi', 'India', 0.18), (2, 'Bhadla', 'India', 0.19);
|
What is the average energy efficiency rating of solar farms in India?
|
SELECT AVG(energy_efficiency_rating) FROM solar_farms WHERE country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), course_duration VARCHAR(20));
|
List all courses and their duration from the 'courses' table
|
SELECT course_name, course_duration FROM courses;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), IsDiscontinued BOOLEAN); INSERT INTO Products (ProductID, ProductName, IsDiscontinued) VALUES (1, 'Lip Balm', false), (2, 'Face Cream', true), (3, 'Moisturizer', false);
|
Delete records of discontinued cosmetic products from the Products table.
|
DELETE FROM Products WHERE IsDiscontinued = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT); INSERT INTO spacecraft (id, name, manufacturer, mass) VALUES (1, 'New Glenn', 'Blue Origin', 720000.0); INSERT INTO spacecraft (id, name, manufacturer, mass) VALUES (2, 'Shepard', 'Blue Origin', 3200.0);
|
What is the total mass (in kg) of all spacecraft manufactured by Blue Origin?
|
SELECT SUM(mass) FROM spacecraft WHERE manufacturer = 'Blue Origin';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE relief_camps (id INT, region VARCHAR(50), num_beneficiaries INT); INSERT INTO relief_camps (id, region, num_beneficiaries) VALUES (1, 'Asia', 600), (2, 'Africa', 300), (3, 'Europe', 700), (4, 'South America', 400), (5, 'North America', 500);
|
List the regions and total number of relief camps for each region in the 'relief_camps' table.
|
SELECT region, COUNT(*) as total_relief_camps FROM relief_camps GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, name_grade VARCHAR(50));
|
Unpivot the 'students' table to display student name and grade level in separate rows
|
SELECT student_id, UNNEST(STRING_TO_ARRAY(name_grade, ' ')) AS student_details FROM students;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.