context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Production (item_id INT, material VARCHAR(255), weight DECIMAL(5,2), sustainable BOOLEAN); INSERT INTO Production (item_id, material, weight, sustainable) VALUES (1, 'Organic Cotton', 2.5, true), (2, 'Polyester', 1.5, false), (3, 'Recycled Wool', 3.0, true);
|
What is the average weight of sustainable materials used in production per item?
|
SELECT AVG(weight) FROM Production WHERE sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (id INT, name VARCHAR(50), connection_speed FLOAT, plan_type VARCHAR(10), region VARCHAR(10)); INSERT INTO broadband_subscribers (id, name, connection_speed, plan_type, region) VALUES (1, 'Priya Patel', 120, 'rural', 'Rural'); INSERT INTO broadband_subscribers (id, name, connection_speed, plan_type, region) VALUES (2, 'Ravi Verma', 135, 'rural', 'Rural');
|
What is the maximum connection speed for rural broadband customers?
|
SELECT MAX(connection_speed) FROM broadband_subscribers WHERE plan_type = 'rural' AND region = 'Rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_biodiversity (id INTEGER, species_name TEXT, biomass FLOAT, animal_class TEXT);
|
What is the total biomass of mammals, birds, and reptiles in the 'arctic_biodiversity' table?
|
SELECT animal_class, SUM(biomass) as total_biomass FROM arctic_biodiversity WHERE animal_class IN ('mammals', 'birds', 'reptiles') GROUP BY animal_class;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dams (DamID INT, Name TEXT, Height FLOAT, Location TEXT, State TEXT); INSERT INTO Dams (DamID, Name, Height, Location, State) VALUES (1, 'Oroville Dam', 230.0, 'Oroville, California', 'CA');
|
What is the name and location of all dams with a height greater than 50 meters in the state of California, USA?
|
SELECT Dams.Name, Dams.Location FROM Dams WHERE Dams.Height > 50.0 AND Dams.State = 'CA'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name VARCHAR(255), num_lifelong_learning_programs INT); CREATE TABLE lifelong_learning_programs (id INT, name VARCHAR(255), num_students INT); INSERT INTO students (id, name, num_lifelong_learning_programs) VALUES (1, 'Student A', 2), (2, 'Student B', 1), (3, 'Student C', 0); INSERT INTO lifelong_learning_programs (id, name, num_students) VALUES (1, 'Program 1', 3), (2, 'Program 2', 2);
|
What is the percentage of students who have completed lifelong learning programs?
|
SELECT 100.0 * SUM(CASE WHEN s.num_lifelong_learning_programs > 0 THEN 1 ELSE 0 END) / COUNT(s.id) AS pct_completed_programs FROM students s;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dapps (dapp_id INT, dapp_name VARCHAR(255), total_transactions INT); CREATE TABLE contracts_dapps (contract_id INT, dapp_id INT); CREATE TABLE smart_contracts (contract_id INT, contract_name VARCHAR(255), total_transactions INT);
|
Identify the top 3 decentralized applications with the highest number of transactions, along with the total number of transactions for the smart contracts associated with each application.
|
SELECT d.dapp_name, sc.contract_name, SUM(sc.total_transactions) as total_transactions FROM dapps d JOIN contracts_dapps cd ON d.dapp_id = cd.dapp_id JOIN smart_contracts sc ON cd.contract_id = sc.contract_id GROUP BY d.dapp_id, sc.contract_name ORDER BY total_transactions DESC, d.dapp_id DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE california_energy_storage (id INT PRIMARY KEY, year INT, technology VARCHAR(30), num_projects INT); INSERT INTO california_energy_storage (id, year, technology, num_projects) VALUES (1, 2019, 'Batteries', 7), (2, 2019, 'Pumped Hydro', 3), (3, 2019, 'Flywheels', 2);
|
How many energy storage projects were completed in California in 2019, by technology?
|
SELECT year, technology, SUM(num_projects) as total_projects FROM california_energy_storage WHERE year = 2019 GROUP BY year, technology;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employment (EmploymentID INT, Country VARCHAR(50), Change INT); INSERT INTO Employment (EmploymentID, Country, Change) VALUES (1, 'Italy', 500), (2, 'Italy', 600);
|
What is the increase in employment due to cultural heritage preservation in Italy?
|
SELECT SUM(Change) FROM Employment WHERE Country = 'Italy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, name VARCHAR(50), type VARCHAR(20), state VARCHAR(2)); INSERT INTO products (id, name, type, state) VALUES (1, 'Savings Account', 'Shariah', 'ME'); CREATE TABLE financial_institutions (id INT, name VARCHAR(50), state VARCHAR(2)); INSERT INTO financial_institutions (id, name, state) VALUES (1, 'Al Baraka Bank', 'ME');
|
How many Shariah-compliant savings accounts are offered by financial institutions in the Middle East?
|
SELECT COUNT(products.id) FROM products INNER JOIN financial_institutions ON products.state = financial_institutions.state WHERE products.type = 'Shariah';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (id INT, name VARCHAR(255)); INSERT INTO Manufacturers (id, name) VALUES (1, 'Manufacturer A'), (2, 'Manufacturer B'); CREATE TABLE Production (id INT, manufacturer_id INT, quantity INT, production_date DATE, price DECIMAL(5, 2)); INSERT INTO Production (id, manufacturer_id, quantity, production_date, price) VALUES (1, 1, 500, '2020-01-01', 10.00), (2, 1, 700, '2020-02-01', 12.00), (3, 2, 300, '2020-01-15', 15.00), (4, 2, 400, '2020-03-10', 18.00);
|
Calculate the total revenue for each manufacturer in the year 2020
|
SELECT m.name, SUM(p.quantity * p.price) as total_revenue FROM Manufacturers m JOIN Production p ON m.id = p.manufacturer_id WHERE YEAR(p.production_date) = 2020 GROUP BY m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id INT, crop_name VARCHAR(255), organic INT); INSERT INTO crops (id, crop_name, organic) VALUES (1, 'Quinoa', 0), (2, 'Rice', 1), (3, 'Wheat', 0);
|
Update the 'crops' table to set the 'organic' column to '1' for all entries where the crop_name is 'Quinoa'.
|
UPDATE crops SET organic = 1 WHERE crop_name = 'Quinoa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (city VARCHAR(255), year INT, recycling_rate FLOAT);
|
Insert a new record for recycling rate in Istanbul in 2021.
|
INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('Istanbul', 2021, 25);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seoul_metro_inventory (inventory_id int, vehicle_type varchar(255), model varchar(255)); INSERT INTO seoul_metro_inventory (inventory_id, vehicle_type, model) VALUES (1, 'Train', 'Type A'), (2, 'Train', 'Type B'), (3, 'Tram', 'Type C');
|
List the number of vehicles of each type in the Seoul Metro fleet
|
SELECT vehicle_type, COUNT(*) AS count FROM seoul_metro_inventory GROUP BY vehicle_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE models (model_id INT, name VARCHAR(50), safety FLOAT); INSERT INTO models (model_id, name, safety) VALUES (1, 'ModelA', 0.91), (2, 'ModelB', 0.78), (3, 'ModelC', 0.87), (4, 'ModelD', 0.65);
|
List the names of models with a safety score greater than 0.85.
|
SELECT name FROM models WHERE safety > 0.85;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT, company_id INT, gender VARCHAR(10), ethnicity VARCHAR(20), percentage DECIMAL(5,2)); INSERT INTO diversity_metrics (id, company_id, gender, ethnicity, percentage) VALUES (1, 1, 'Female', 'Caucasian', 0.35), (2, 1, 'Male', 'Caucasian', 0.65), (3, 2, 'Female', 'Asian', 0.45), (4, 2, 'Male', 'Asian', 0.55), (5, 3, 'Female', 'African', 0.5), (6, 3, 'Male', 'African', 0.5);
|
What is the rank of diversity metrics for each company?
|
SELECT company_id, gender, ethnicity, percentage, RANK() OVER(ORDER BY percentage DESC) as rank FROM diversity_metrics;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TraditionalArtForms (id INT, name VARCHAR(50), language VARCHAR(50), region VARCHAR(50)); CREATE TABLE ArtPieces (id INT, art_form_id INT, site_id INT); CREATE TABLE HeritageSites (id INT, name VARCHAR(50), site_id INT, region VARCHAR(50));
|
Identify the traditional art forms that are unique to each language's native region.
|
SELECT TAF.name, TAF.region FROM TraditionalArtForms TAF INNER JOIN ArtPieces AP ON TAF.id = AP.art_form_id INNER JOIN HeritageSites HS ON AP.site_id = HS.id WHERE TAF.region = HS.region GROUP BY TAF.name, TAF.region HAVING COUNT(*) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), country VARCHAR(50)); CREATE TABLE grants (id INT, faculty_id INT, amount INT); INSERT INTO faculty VALUES (1, 'Penelope', 'Science', 'USA'), (2, 'Quinn', 'Science', 'Canada'), (3, 'Riley', 'Science', 'USA'); INSERT INTO grants VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000), (4, 3, 4000);
|
Find the total grant amount awarded to faculty members in the College of Science who are not from the United States.
|
SELECT SUM(amount) FROM grants INNER JOIN faculty ON grants.faculty_id = faculty.id WHERE country != 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (id INT, customerID INT, country VARCHAR(50)); INSERT INTO Customers (id, customerID, country) VALUES (1, 4001, 'Brazil'), (2, 4002, 'Argentina'), (3, 4003, 'Brazil'), (4, 4004, 'Chile'); CREATE TABLE Sales (id INT, customerID INT, garmentID INT, quantity INT, saleDate DATE); INSERT INTO Sales (id, customerID, garmentID, quantity, saleDate) VALUES (1, 4001, 405, 1, '2021-01-10'), (2, 4002, 406, 2, '2021-02-15'), (3, 4003, 407, 1, '2021-03-20'), (4, 4004, 408, 3, '2021-04-12'); CREATE TABLE Garments (id INT, garmentID INT, size INT, country VARCHAR(50)); INSERT INTO Garments (id, garmentID, size, country) VALUES (1, 405, 18, 'Brazil'), (2, 406, 12, 'Argentina'), (3, 407, 10, 'Chile'), (4, 408, 16, 'Brazil');
|
What is the number of unique customers who purchased size 18 garments in Brazil?
|
SELECT COUNT(DISTINCT Customers.customerID) FROM Customers INNER JOIN Sales ON Customers.customerID = Sales.customerID INNER JOIN Garments ON Sales.garmentID = Garments.garmentID WHERE Garments.size = 18 AND Customers.country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists rural_development; use rural_development; CREATE TABLE IF NOT EXISTS rural_infrastructure (id INT, name VARCHAR(255), cost FLOAT, PRIMARY KEY (id)); INSERT INTO rural_infrastructure (id, name, cost) VALUES (1, 'Rural Electrification', 150000.00), (2, 'Irrigation System', 75000.00), (3, 'Rural Telecommunications', 200000.00);
|
Update the name of the 'Rural Electrification' project to 'Electrification for Rural Development' in the 'rural_infrastructure' table.
|
UPDATE rural_infrastructure SET name = 'Electrification for Rural Development' WHERE name = 'Rural Electrification';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT, name TEXT, city TEXT); INSERT INTO teams (id, name, city) VALUES (2, 'Golden State Warriors', 'Oakland'); CREATE TABLE games (id INT, home_team_id INT, away_team_id INT, points_home INT, points_away INT);
|
What is the highest scoring game for the Golden State Warriors?
|
SELECT MAX(GREATEST(points_home, points_away)) FROM games WHERE home_team_id = (SELECT id FROM teams WHERE name = 'Golden State Warriors' AND city = 'Oakland') OR away_team_id = (SELECT id FROM teams WHERE name = 'Golden State Warriors' AND city = 'Oakland');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name VARCHAR(50), treatment VARCHAR(50)); CREATE TABLE treatments (treatment VARCHAR(50), cost INT);
|
Count unique patients treated with CBT or medication
|
SELECT COUNT(DISTINCT p.name) FROM patients p JOIN treatments t ON p.treatment = t.treatment WHERE t.treatment IN ('CBT', 'medication');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE biotech.startups_funding (id INT, startup_name VARCHAR(50), funding_date DATE, funding_amount DECIMAL(10,2));INSERT INTO biotech.startups_funding (id, startup_name, funding_date, funding_amount) VALUES (1, 'StartupA', '2022-01-15', 5000000.00), (2, 'StartupB', '2022-06-30', 3000000.00), (3, 'StartupC', '2021-12-31', 2000000.00);
|
List all biotech startups that received funding in the last 6 months.
|
SELECT * FROM biotech.startups_funding WHERE funding_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE training_times (id INT, model_name VARCHAR(50), algorithm VARCHAR(50), training_time FLOAT); INSERT INTO training_times (id, model_name, algorithm, training_time) VALUES (1, 'ModelA', 'Neural Network', 2.1), (2, 'ModelB', 'Decision Tree', 1.5), (3, 'ModelC', 'Neural Network', 2.9);
|
What is the minimum, maximum, and average training time for models that use different algorithms?
|
SELECT algorithm, MIN(training_time) as min_training_time, MAX(training_time) as max_training_time, AVG(training_time) as avg_training_time FROM training_times GROUP BY algorithm;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (id INT, initiative VARCHAR(50), status VARCHAR(50)); INSERT INTO community_development (id, initiative, status) VALUES (1, 'Youth Education', 'Completed'); INSERT INTO community_development (id, initiative, status) VALUES (2, 'Women Empowerment', 'In Progress');
|
How many community development initiatives are in the 'community_development' table?
|
SELECT COUNT(*) FROM community_development;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_channels (channel_language VARCHAR(50), channel_name VARCHAR(50), country VARCHAR(50)); INSERT INTO news_channels (channel_language, channel_name, country) VALUES ('English', 'CNN', 'USA'); INSERT INTO news_channels (channel_language, channel_name, country) VALUES ('Arabic', 'Al Jazeera', 'Qatar');
|
What is the distribution of news channels by language?
|
SELECT channel_language, COUNT(*) as channel_count FROM news_channels GROUP BY channel_language;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE department (id INT, name VARCHAR(255)); CREATE TABLE department_vulnerabilities (department_id INT, vulnerability_count INT); INSERT INTO department (id, name) VALUES (1, 'Finance'), (2, 'IT'); INSERT INTO department_vulnerabilities (department_id, vulnerability_count) VALUES (1, 2), (2, 5);
|
What is the average number of vulnerabilities recorded per department?
|
SELECT AVG(vulnerability_count) FROM department_vulnerabilities;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (id INT, model_id INT, incident_type VARCHAR(255)); INSERT INTO incidents (id, model_id, incident_type) VALUES (1, 1, 'Unintended Consequences'), (2, 2, 'Lack of Robustness'), (3, 1, 'Lack of Robustness'), (4, 3, 'Unintended Consequences');
|
How many AI safety incidents have been recorded for each AI model, sorted by the number of incidents in descending order?
|
SELECT model_id, COUNT(*) as incident_count FROM incidents GROUP BY model_id ORDER BY incident_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_renewable_projects (city VARCHAR(50), project_type VARCHAR(50), PRIMARY KEY (city, project_type));
|
List cities with more than one type of renewable energy project
|
SELECT city FROM city_renewable_projects GROUP BY city HAVING COUNT(DISTINCT project_type) > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(255));CREATE TABLE employees (id INT, department_id INT, hire_date DATE);
|
Find the number of employees hired in each department for 2021.
|
SELECT d.name, COUNT(e.id) AS hires FROM departments d INNER JOIN employees e ON d.id = e.department_id WHERE e.hire_date >= '2021-01-01' AND e.hire_date < '2022-01-01' GROUP BY d.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HaircareProducts(productId INT, productName VARCHAR(100), isNatural BOOLEAN, saleYear INT, country VARCHAR(50), price DECIMAL(5,2)); INSERT INTO HaircareProducts(productId, productName, isNatural, saleYear, country, price) VALUES (1, 'Rice Water Shampoo', true, 2019, 'Japan', 19.99), (2, 'Lavender Conditioner', false, 2020, 'Japan', 14.99);
|
What is the total revenue generated from natural haircare products sold in Japan in 2019?
|
SELECT SUM(price) FROM HaircareProducts WHERE isNatural = true AND saleYear = 2019 AND country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (InventoryID INT, ProductID INT, ProductName VARCHAR(50), QuantityOnHand INT, ReorderLevel INT, Department VARCHAR(50)); INSERT INTO Inventory (InventoryID, ProductID, ProductName, QuantityOnHand, ReorderLevel, Department) VALUES (1, 1001, 'Eco-Friendly Parts', 500, 300, 'Manufacturing'); INSERT INTO Inventory (InventoryID, ProductID, ProductName, QuantityOnHand, ReorderLevel, Department) VALUES (2, 1002, 'Recycled Materials', 300, 200, 'Engineering'); INSERT INTO Inventory (InventoryID, ProductID, ProductName, QuantityOnHand, ReorderLevel) VALUES (3, 1003, 'Solar Panels', 200, 150);
|
List the products in the Inventory table that are not associated with any department.
|
SELECT ProductName FROM Inventory WHERE Department IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FisheryData (FisheryID int, Year int, FishingMethod varchar(50), Weight int);
|
What is the total weight of fish caught by each fishery, grouped by the fishing method and year?
|
SELECT FishingMethod, Year, SUM(Weight) FROM FisheryData GROUP BY FishingMethod, Year ORDER BY SUM(Weight) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(20), team_id INT);
|
What is the average age of players in the 'players' table?
|
SELECT AVG(age) FROM players;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClothingManufacturers (manufacturer TEXT, item_id INTEGER); INSERT INTO ClothingManufacturers (manufacturer, item_id) VALUES ('Manufacturer1', 111), ('Manufacturer2', 222), ('Manufacturer3', 333), ('Manufacturer4', 444), ('Manufacturer5', 555), ('Manufacturer6', 666);
|
Display the total number of items produced by each clothing manufacturer, and show only those manufacturers with less than 500 items produced.
|
SELECT manufacturer, COUNT(*) as total_items FROM ClothingManufacturers GROUP BY manufacturer HAVING COUNT(*) < 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_permits (id INT PRIMARY KEY, permit_number VARCHAR(255), company_name VARCHAR(255), mine_location VARCHAR(255), element_type VARCHAR(255));
|
Display unique mining permit numbers for Praseodymium.
|
SELECT DISTINCT permit_number FROM mining_permits WHERE element_type = 'Praseodymium';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE golf_teams (team_name TEXT, athlete_name TEXT, athlete_age INTEGER);
|
What is the maximum age of athletes in the golf_teams table?
|
SELECT MAX(athlete_age) FROM golf_teams;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage(state VARCHAR(20), year INT, usage FLOAT);
|
Delete the records for Texas in 2019.
|
DELETE FROM water_usage WHERE state='Texas' AND year=2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatment_durations (patient_id INT, condition VARCHAR(50), duration INT); INSERT INTO treatment_durations (patient_id, condition, duration) VALUES (1, 'Anxiety', 12), (2, 'Depression', 10), (3, 'PTSD', 25), (4, 'Anxiety', 18), (5, 'Depression', 15), (6, 'Bipolar Disorder', 20), (7, 'Washington', 22); CREATE TABLE patient_location (patient_id INT, location VARCHAR(50)); INSERT INTO patient_location (patient_id, location) VALUES (1, 'Washington'), (2, 'Washington'), (3, 'California'), (4, 'Arizona'), (5, 'Florida'), (6, 'Texas'), (7, 'Washington');
|
What is the maximum duration of any mental health treatment provided in Washington?
|
SELECT MAX(duration) FROM treatment_durations JOIN patient_location ON treatment_durations.patient_id = patient_location.patient_id WHERE location = 'Washington';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(255), ocean VARCHAR(255));
|
Insert a new marine species into the species table
|
INSERT INTO species (id, name, ocean) VALUES (7, 'Green Sea Turtle', 'Atlantic');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_mix (id INT PRIMARY KEY, country VARCHAR(50), energy_source VARCHAR(50), percentage FLOAT);
|
Delete records in the 'renewable_mix' table where the 'energy_source' is 'Geothermal'
|
DELETE FROM renewable_mix WHERE energy_source = 'Geothermal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), last_publication_date DATE); CREATE TABLE conferences (id INT, name VARCHAR(50), tier VARCHAR(10)); CREATE TABLE research_grants (id INT, faculty_id INT, amount DECIMAL(10,2));
|
What is the average number of research grants awarded to faculty members in the Electrical Engineering department who have published in top-tier conferences?
|
SELECT AVG(g.count) FROM (SELECT COUNT(*) AS count FROM research_grants rg JOIN faculty f ON rg.faculty_id = f.id WHERE f.department = 'Electrical Engineering' AND f.last_publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND f.id IN (SELECT p.faculty_id FROM publications p JOIN conferences c ON p.conference_id = c.id WHERE c.tier = 'Top-tier')) g;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence_reports (report_id INT, generation_date DATE); INSERT INTO threat_intelligence_reports (report_id, generation_date) VALUES (1, '2021-01-01'), (2, '2021-02-01'), (3, '2021-12-31');
|
Find the average number of threat intelligence reports generated per month in 2021
|
SELECT AVG(num_reports_per_month) FROM (SELECT MONTH(generation_date) AS month, COUNT(*) AS num_reports_per_month FROM threat_intelligence_reports WHERE generation_date >= '2021-01-01' AND generation_date < '2022-01-01' GROUP BY month) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_towers (tower_id INT, connected_devices INT, country VARCHAR(20)); INSERT INTO network_towers (tower_id, connected_devices, country) VALUES (1, 50, 'UK'); INSERT INTO network_towers (tower_id, connected_devices, country) VALUES (2, 75, 'UK');
|
Identify the top 5 mobile network towers with the highest number of connected devices, in descending order, in the United Kingdom.
|
SELECT tower_id, connected_devices FROM (SELECT tower_id, connected_devices, ROW_NUMBER() OVER (ORDER BY connected_devices DESC) AS rn FROM network_towers WHERE country = 'UK') subquery WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArcticResearchLab (id INT, year INT, month INT, temperature FLOAT); INSERT INTO ArcticResearchLab (id, year, month, temperature) VALUES (1, 2000, 1, -10.5), (2, 2000, 2, -12.3), (3, 2000, 3, -13.1);
|
What is the minimum temperature per month in the Arctic Research Lab?
|
SELECT month, MIN(temperature) FROM ArcticResearchLab GROUP BY year, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SkincareBrands (brand TEXT, product_name TEXT, price DECIMAL(5,2), sale_location TEXT); INSERT INTO SkincareBrands (brand, product_name, price, sale_location) VALUES ('Brand A', 'Cruelty-free Cleanser', 29.99, 'Australia'), ('Brand B', 'Vegan Moisturizer', 39.99, 'Australia'), ('Brand A', 'Organic Serum', 49.99, 'Australia'), ('Brand C', 'Cruelty-free Toner', 24.99, 'Australia'), ('Brand B', 'Natural Sunscreen', 19.99, 'Australia'), ('Brand C', 'Cruelty-free Scrub', 34.99, 'Australia');
|
What is the maximum selling price of cruelty-free skincare products in Australia, broken down by brand?
|
SELECT brand, MAX(price) FROM SkincareBrands WHERE product_name LIKE '%cruelty-free%' GROUP BY brand;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Road_Maintenance (road_id INT, road_name VARCHAR(50), location VARCHAR(50), maintenance_date DATE);
|
Determine the number of roads in each location in the Road_Maintenance table
|
SELECT location, COUNT(*) FROM Road_Maintenance GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE UnionMembers (id INT, union_name VARCHAR(50), country VARCHAR(50), member_count INT); INSERT INTO UnionMembers (id, union_name, country, member_count) VALUES (1, 'United Steelworkers', 'USA', 200000), (2, 'UNITE HERE', 'USA', 300000), (3, 'TUC', 'UK', 6000000), (4, 'CUPE', 'Canada', 650000), (5, 'USW', 'Canada', 120000);
|
List all union names and their member counts in Canada.
|
SELECT union_name, member_count FROM UnionMembers WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE continents (continent_id INT PRIMARY KEY, continent_name VARCHAR(255)); INSERT INTO continents (continent_id, continent_name) VALUES (1, 'Asia'), (2, 'Africa'), (3, 'Europe'), (4, 'North America'), (5, 'South America'), (6, 'Australia'); CREATE TABLE mobile_subscribers (subscriber_id INT PRIMARY KEY, continent_id INT); INSERT INTO mobile_subscribers (subscriber_id, continent_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 3), (6, 4), (7, 4), (8, 5), (9, 5), (10, 6); CREATE TABLE broadband_subscribers (subscriber_id INT PRIMARY KEY, continent_id INT); INSERT INTO broadband_subscribers (subscriber_id, continent_id) VALUES (1, 1), (2, 2), (3, 2), (4, 3), (5, 3), (6, 4), (7, 4), (8, 5), (9, 5), (10, 6);
|
How many mobile and broadband subscribers are there in each continent?
|
SELECT c.continent_name, COUNT(m.subscriber_id) + COUNT(b.subscriber_id) as total_subscribers FROM continents c LEFT JOIN mobile_subscribers m ON c.continent_id = m.continent_id LEFT JOIN broadband_subscribers b ON c.continent_id = b.continent_id GROUP BY c.continent_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO eco_hotels (hotel_id, name, city, rating) VALUES (1, 'Green Hotel', 'Tokyo', 4.2), (2, 'Eco Lodge', 'Tokyo', 4.5);
|
What is the average rating of eco-friendly hotels in Tokyo?
|
SELECT AVG(rating) FROM eco_hotels WHERE city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Mateo', 'Argentina'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Heidi', 'Germany'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL, DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate) VALUES (1, 1, 100.00, '2022-04-15'); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate) VALUES (2, 2, 200.00, '2022-06-30');
|
What is the average donation amount for each country in Q2 2022?
|
SELECT Donors.Country, AVG(Donations.DonationAmount) AS AverageDonationAmount FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE QUARTER(Donations.DonationDate) = 2 AND YEAR(Donations.DonationDate) = 2022 GROUP BY Donors.Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT, city VARCHAR(20), collections INT); INSERT INTO artists (id, city, collections) VALUES (1, 'Berlin', 2), (2, 'Berlin', 3), (3, 'Berlin', 1), (4, 'Berlin', 4), (5, 'Berlin', 5);
|
What is the lowest number of art collections does each artist have in 'Berlin'?
|
SELECT city, MIN(collections) FROM artists WHERE city = 'Berlin';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE endangered_species (id INT, animal_name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO endangered_species VALUES (1, 'Tiger', 2000, 'Asia'); CREATE TABLE community_outreach (id INT, animal_name VARCHAR(50), education INT, region VARCHAR(50)); INSERT INTO community_outreach VALUES (1, 'Tiger', 1000, 'Asia');
|
Find the number of animals and conservation efforts for 'endangered_species' and 'community_outreach' programs in Asia.
|
SELECT population FROM endangered_species WHERE region = 'Asia' UNION SELECT education FROM community_outreach WHERE region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artist_demographics (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), nationality VARCHAR(50));CREATE TABLE artwork (id INT, title VARCHAR(50), year INT, artist_id INT, medium VARCHAR(50));
|
What is the average number of artworks created per year for each artist in the 'artist_demographics' table?
|
SELECT artist_id, AVG(artwork_per_year) FROM (SELECT artist_id, year, COUNT(*) AS artwork_per_year FROM artwork GROUP BY artist_id, year) AS subquery GROUP BY artist_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Community_Development_Initiatives (Initiative_ID INT, Initiative_Name TEXT, Location TEXT, Status TEXT, Completion_Date DATE); INSERT INTO Community_Development_Initiatives (Initiative_ID, Initiative_Name, Location, Status, Completion_Date) VALUES (1, 'Rural Water Supply Project', 'Peru', 'Completed', '2018-06-30');
|
List all community development initiatives in Peru that were completed after 2017 and their completion dates.
|
SELECT Initiative_Name, Completion_Date FROM Community_Development_Initiatives WHERE Status = 'Completed' AND Location = 'Peru' AND Completion_Date > '2017-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo_ships (id INT, name VARCHAR(50), capacity INT, owner_id INT); INSERT INTO cargo_ships (id, name, capacity, owner_id) VALUES (1, 'Sea Titan', 150000, 1), (2, 'Ocean Marvel', 200000, 1), (3, 'Cargo Master', 120000, 2); CREATE TABLE owners (id INT, name VARCHAR(50)); INSERT INTO owners (id, name) VALUES (1, 'ACME Corporation'), (2, 'Global Shipping');
|
Insert new records for a cargo ship named 'Atlantic Explorer' with an ID of 4, owned by the Global Shipping company, and a capacity of 180,000.
|
INSERT INTO cargo_ships (id, name, capacity, owner_id) VALUES (4, 'Atlantic Explorer', 180000, (SELECT id FROM owners WHERE name = 'Global Shipping'));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title VARCHAR(255), genre VARCHAR(255), release_year INT); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, timestamp TIMESTAMP); INSERT INTO songs (id, title, genre, release_year) VALUES (1, 'Song1', 'Rock', 2010), (2, 'Song2', 'Hip Hop', 2015), (3, 'Song3', 'Rock', 2012); INSERT INTO streams (stream_id, song_id, user_id, timestamp) VALUES (1, 1, 1, '2022-01-01 10:00:00'), (2, 2, 2, '2022-01-02 10:00:00'), (3, 1, 3, '2022-01-03 10:00:00'), (4, 3, 4, '2022-01-04 10:00:00'), (5, 1, 5, '2022-01-05 10:00:00'), (6, 3, 6, '2022-01-06 10:00:00');
|
What is the maximum number of streams for a single song in the rock genre?
|
SELECT MAX(streams_per_song) FROM (SELECT COUNT(*) AS streams_per_song FROM streams JOIN songs ON streams.song_id = songs.id WHERE songs.genre = 'Rock' GROUP BY songs.id) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, patient_name TEXT, condition TEXT, therapist_id INT, treatment TEXT, success BOOLEAN); INSERT INTO patients (patient_id, patient_name, condition, therapist_id, treatment, success) VALUES (1, 'James Johnson', 'PTSD', 1, 'Medication', TRUE); INSERT INTO patients (patient_id, patient_name, condition, therapist_id, treatment, success) VALUES (2, 'Sophia Lee', 'PTSD', 1, 'Meditation', FALSE); CREATE TABLE therapists (therapist_id INT, therapist_name TEXT, state TEXT); INSERT INTO therapists (therapist_id, therapist_name, state) VALUES (1, 'Dr. Maria Rodriguez', 'Florida');
|
What is the success rate of medication for patients with PTSD in Florida?
|
SELECT COUNT(patients.success) * 100.0 / (SELECT COUNT(*) FROM patients WHERE patients.condition = 'PTSD' AND patients.therapist_id = 1) FROM patients WHERE patients.condition = 'PTSD' AND patients.treatment = 'Medication' AND patients.therapist_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museums (id INT, name TEXT, country TEXT, visitors INT); INSERT INTO museums (id, name, country, visitors) VALUES (1, 'Museum A', 'Italy', 100000), (2, 'Museum B', 'Italy', 120000), (3, 'Museum C', 'France', 80000);
|
List the top 3 most visited museums in Italy, ordered by visitor count
|
SELECT name, visitors FROM museums WHERE country = 'Italy' ORDER BY visitors DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, name TEXT, country TEXT); INSERT INTO organizations VALUES (1, 'UNICEF', 'Haiti'); INSERT INTO organizations VALUES (2, 'World Food Programme', 'Haiti'); CREATE TABLE donations (id INT, organization_id INT, amount DECIMAL); INSERT INTO donations VALUES (1, 1, 5000); INSERT INTO donations VALUES (2, 1, 7000); INSERT INTO donations VALUES (3, 2, 6000);
|
What is the total amount of donations received by each organization in Haiti?
|
SELECT o.name, SUM(d.amount) as total_donations FROM organizations o INNER JOIN donations d ON o.id = d.organization_id WHERE o.country = 'Haiti' GROUP BY o.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incident_resolution (incident_id INT, resolution_time INT, timestamp TIMESTAMP); INSERT INTO incident_resolution (incident_id, resolution_time, timestamp) VALUES (1, 120, '2022-01-01 00:00:00'); INSERT INTO incident_resolution (incident_id, resolution_time, timestamp) VALUES (2, 150, '2022-01-02 00:00:00');
|
Identify the safety incident with the longest resolution time.
|
SELECT incident_id, resolution_time FROM (SELECT incident_id, resolution_time, ROW_NUMBER() OVER (ORDER BY resolution_time DESC) as row_num FROM incident_resolution) as subquery WHERE row_num = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE maintenance_requests (request_id INT, request_date DATE, request_type VARCHAR(255), state VARCHAR(255)); INSERT INTO maintenance_requests (request_id, request_date, request_type, state) VALUES (1, '2021-01-01', 'Equipment Maintenance', 'Texas'); INSERT INTO maintenance_requests (request_id, request_date, request_type, state) VALUES (2, '2021-02-01', 'Facility Maintenance', 'Texas');
|
How many military equipment maintenance requests were submitted in Texas in the past year?
|
SELECT COUNT(*) as total_requests FROM maintenance_requests WHERE request_type = 'Equipment Maintenance' AND state = 'Texas' AND request_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtWorkSales (artworkID INT, country VARCHAR(50), saleDate DATE, revenue DECIMAL(10,2));
|
What was the total revenue for all artworks sold by country in 2021?
|
SELECT country, SUM(revenue) FROM ArtWorkSales WHERE YEAR(saleDate) = 2021 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm (id INT, species TEXT, weight FLOAT, age INT); INSERT INTO Farm (id, species, weight, age) VALUES (1, 'Tilapia', 500.3, 2), (2, 'Salmon', 300.1, 1), (3, 'Tilapia', 600.5, 3), (4, 'Tilapia', 700.2, 2), (5, 'Tilapia', 800.1, 4);
|
What is the minimum weight of fish in the 'Tilapia' species?
|
SELECT MIN(weight) FROM Farm WHERE species = 'Tilapia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup (id INT, industry TEXT, funding_firm TEXT); INSERT INTO startup (id, industry, funding_firm) VALUES (1, 'Software', 'VC Firm A'), (2, 'Hardware', 'VC Firm B'), (3, 'Healthcare', 'VC Firm A'), (4, 'AI', 'VC Firm B');
|
List the unique industries for startups that have received funding from both VC Firm A and VC Firm B.
|
SELECT industry FROM startup WHERE funding_firm IN ('VC Firm A', 'VC Firm B') GROUP BY industry HAVING COUNT(DISTINCT funding_firm) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AutoShowInfo (Show VARCHAR(50), City VARCHAR(50), Year INT, Vehicle VARCHAR(50)); INSERT INTO AutoShowInfo (Show, City, Year, Vehicle) VALUES ('Auto China', 'Shanghai', 2021, 'Tesla Model Y'), ('Auto China', 'Shanghai', 2021, 'NIO ES8'), ('Auto China', 'Shanghai', 2021, 'XPeng P7'), ('Paris Motor Show', 'Paris', 2021, 'Peugeot e-208'), ('Paris Motor Show', 'Paris', 2021, 'Renault ZOE');
|
Which vehicles were showcased at the last auto show in Shanghai?
|
SELECT Vehicle FROM AutoShowInfo WHERE Show = 'Auto China' AND City = 'Shanghai' AND Year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ny_emergency_responses (id INT, city VARCHAR(20), type VARCHAR(20), response_time INT); INSERT INTO ny_emergency_responses (id, city, type, response_time) VALUES (1, 'New York', 'emergency', 12); INSERT INTO ny_emergency_responses (id, city, type, response_time) VALUES (2, 'New York', 'fire', 18);
|
What is the maximum response time for emergency calls in the city of New York, and which type of emergency has the highest response time?
|
SELECT type, MAX(response_time) FROM ny_emergency_responses WHERE city = 'New York' GROUP BY type ORDER BY MAX(response_time) DESC LIMIT 1
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sharks (id INT, species VARCHAR(255), avg_depth FLOAT, region VARCHAR(255)); INSERT INTO sharks (id, species, avg_depth, region) VALUES (1, 'Hammerhead Shark', 200, 'Sargasso Sea');
|
What is the average depth at which sharks are found in the Sargasso Sea?
|
SELECT AVG(avg_depth) FROM sharks WHERE region = 'Sargasso Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IoT_Sensors (farm_type VARCHAR(30), country VARCHAR(20), num_sensors INTEGER); INSERT INTO IoT_Sensors (farm_type, country, num_sensors) VALUES ('Coffee Plantation', 'Japan', 200), ('Coffee Plantation', 'Japan', 220), ('Tea Garden', 'Japan', 250), ('Tea Garden', 'Japan', 280), ('Tea Garden', 'Japan', 300);
|
List the number of IoT sensors in coffee plantations and tea gardens in Japan.
|
SELECT farm_type, SUM(num_sensors) FROM IoT_Sensors WHERE country = 'Japan' AND farm_type IN ('Coffee Plantation', 'Tea Garden') GROUP BY farm_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infectious_diseases (disease VARCHAR(255), cases INT, city VARCHAR(255), population INT); INSERT INTO infectious_diseases (disease, cases, city, population) VALUES ('Influenza', 50, 'Chicago', 2700000); INSERT INTO infectious_diseases (disease, cases, city, population) VALUES ('COVID-19', 100, 'Chicago', 2700000); CREATE TABLE cities (name VARCHAR(255), population INT); INSERT INTO cities (name, population) VALUES ('Chicago', 2700000); INSERT INTO cities (name, population) VALUES ('New York', 8500000);
|
List all infectious diseases with their respective cases in cities with a population greater than 1,000,000.
|
SELECT disease, cases FROM infectious_diseases, cities WHERE infectious_diseases.city = cities.name AND population > 1000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MemberRegistry (memberID INT, joinDate DATE); INSERT INTO MemberRegistry (memberID, joinDate) VALUES (1, '2022-01-05'), (2, '2022-04-12'), (3, '2022-07-29');
|
How many new members joined the art museum in the past quarter?
|
SELECT COUNT(*) FROM MemberRegistry WHERE joinDate >= '2022-01-01' AND joinDate <= '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (tour_id INT, name TEXT, site TEXT); INSERT INTO virtual_tours (tour_id, name, site) VALUES (1, 'Paris Virtual Tour 1', 'Paris'); INSERT INTO virtual_tours (tour_id, name, site) VALUES (2, 'Paris Virtual Tour 2', 'Paris');
|
What is the total number of virtual tours offered in Paris?
|
SELECT COUNT(*) FROM virtual_tours WHERE site = 'Paris';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (id INT, region VARCHAR(20), data_usage INT, usage_date DATE);
|
List all mobile subscribers in the Asia-Pacific region who have used their data services more than 50% of the time in the last month.
|
SELECT m.id, m.region, m.data_usage, m.usage_date FROM mobile_subscribers m INNER JOIN (SELECT subscriber_id, SUM(data_usage) AS total_usage FROM mobile_subscribers WHERE usage_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY subscriber_id) d ON m.id = d.subscriber_id WHERE m.region = 'Asia-Pacific' AND m.data_usage > 0.5 * d.total_usage;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (year INT, capacity INT), landfill_utilization (year INT, utilization INT); INSERT INTO landfill_capacity (year, capacity) VALUES (2018, 12000), (2019, 13000), (2020, 14000), (2021, 15000); INSERT INTO landfill_utilization (year, utilization) VALUES (2018, 8000), (2019, 9000), (2020, 10000), (2021, NULL);
|
What was the landfill capacity utilization in 2021?
|
SELECT utilization FROM landfill_utilization WHERE year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameData (GameID INT, GameType VARCHAR(10), Playtime INT); INSERT INTO GameData (GameID, GameType, Playtime) VALUES (1, 'Adventure', 20), (2, 'Strategy', 30), (3, 'Simulation', 40);
|
What is the average playtime for simulation games?
|
SELECT AVG(Playtime) FROM GameData WHERE GameType = 'Simulation'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE US_Harvest (community VARCHAR(30), crop VARCHAR(20), quantity INT, year INT); INSERT INTO US_Harvest (community, crop, quantity, year) VALUES ('Community1', 'Corn', 5000, 2020), ('Community1', 'Soybeans', 3000, 2020);
|
What is the total quantity of 'Corn' and 'Soybeans' harvested in 'Indigenous Communities' in the USA for 2020?
|
SELECT SUM(uh.quantity) as total_quantity FROM US_Harvest uh WHERE uh.crop IN ('Corn', 'Soybeans') AND uh.community LIKE 'Indigenous%' AND uh.year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryPersonnel (id INT, name VARCHAR(100), rank VARCHAR(50), service VARCHAR(50)); INSERT INTO MilitaryPersonnel (id, name, rank, service) VALUES (1, 'John Doe', 'Colonel', 'Air Force'); INSERT INTO MilitaryPersonnel (id, name, rank, service) VALUES (2, 'Jane Smith', 'Captain', 'Navy'); INSERT INTO MilitaryPersonnel (id, name, rank, service) VALUES (3, 'Robert Johnson', 'General', 'Army'); INSERT INTO MilitaryPersonnel (id, name, rank, service) VALUES (4, 'Emily Davis', 'Lieutenant General', 'Marines');
|
What are the names and ranks of the highest-ranking personnel in each service?
|
SELECT name, rank, service FROM MilitaryPersonnel WHERE rank IN (SELECT MAX(rank) FROM MilitaryPersonnel GROUP BY service);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FLAG_STATE_CARGO (ID INT, FLAG_STATE_ID INT, CARGO_TYPE VARCHAR(50), WEIGHT INT); INSERT INTO FLAG_STATE_CARGO VALUES (1, 1, 'Container', 1000000); INSERT INTO FLAG_STATE_CARGO VALUES (2, 2, 'Bulk', 5000000);
|
Calculate the percentage of cargo weight that is container cargo for each flag state.
|
SELECT F.NAME AS FLAG_STATE, ROUND(100.0 * SUM(CASE WHEN FSC.CARGO_TYPE = 'Container' THEN FSC.WEIGHT ELSE 0 END) / SUM(FSC.WEIGHT), 2) AS PERCENTAGE FROM FLAG_STATE_CARGO FSC JOIN FLAG_STATES F ON FSC.FLAG_STATE_ID = F.ID GROUP BY F.ID, F.NAME
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerInfo (PlayerID INT, Gender VARCHAR(50), GameType VARCHAR(50)); INSERT INTO PlayerInfo (PlayerID, Gender, GameType) VALUES (1, 'Female', 'RPG'), (2, 'Male', 'FPS'), (3, 'Female', 'RPG'), (4, 'Non-binary', 'Simulation'); CREATE TABLE PlayerActivity (PlayerID INT, GameID INT, Playtime FLOAT); INSERT INTO PlayerActivity (PlayerID, GameID, Playtime) VALUES (1, 1, 50.5), (2, 2, 60.2), (3, 1, 75.1), (4, 3, 80.5);
|
What is the average playtime for female players in RPG games?
|
SELECT AVG(Playtime) as AvgPlaytime FROM PlayerActivity INNER JOIN PlayerInfo ON PlayerActivity.PlayerID = PlayerInfo.PlayerID WHERE Gender = 'Female' AND GameType = 'RPG';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY, exhibition_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255));
|
Update the city of an exhibition
|
UPDATE exhibitions SET city = 'New York' WHERE exhibition_id = 123;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(50)); CREATE TABLE cases (case_id INT, client_id INT, billing_amount DECIMAL(10,2)); INSERT INTO clients (client_id, name) VALUES (1, 'Smith'), (2, 'Johnson'), (3, 'Williams'), (4, 'Brown'); INSERT INTO cases (case_id, client_id, billing_amount) VALUES (1, 1, 3000.00), (2, NULL, 6000.00), (3, 3, 7000.00), (4, 4, NULL);
|
List all clients who have not paid any billing amount?
|
SELECT clients.name FROM clients LEFT JOIN cases ON clients.client_id = cases.client_id WHERE cases.client_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication_campaigns(campaign_id INT, campaign_name TEXT, location TEXT, amount_funded FLOAT);
|
What's the total funding spent on climate communication campaigns by each continent?
|
SELECT CONCAT(SUBSTRING(location, 1, 2), ': ', SUM(amount_funded)) FROM climate_communication_campaigns WHERE sector = 'climate communication' GROUP BY SUBSTRING(location, 1, 2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT); CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT);
|
What is the total number of volunteers and total volunteer hours for each country, sorted by the total number of volunteers in descending order?
|
SELECT V.Country, COUNT(V.VolunteerID) as TotalVolunteers, SUM(VH.Hours) as TotalHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID GROUP BY V.Country ORDER BY TotalVolunteers DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Movies (id INT, title VARCHAR(255), runtime INT); CREATE TABLE TVShows (id INT, title VARCHAR(255), runtime INT);
|
List all movies and TV shows with a runtime greater than the average movie runtime.
|
SELECT Movies.title UNION SELECT TVShows.title FROM Movies, TVShows WHERE Movies.runtime > (SELECT AVG(runtime) FROM Movies) OR TVShows.runtime > (SELECT AVG(runtime) FROM Movies);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ships (id INT, name VARCHAR(255), capacity INT); INSERT INTO ships (id, name, capacity) VALUES (1, 'ship1', 5000), (2, 'ship2', 7000);
|
What is the total capacity of all cargo ships owned by Acme Corp?
|
SELECT SUM(capacity) FROM ships WHERE name LIKE 'Acme%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_transportation (id INT, vehicle_type VARCHAR(20), quantity INT); INSERT INTO public_transportation (id, vehicle_type, quantity) VALUES (1, 'autonomous_bus', 200), (2, 'manual_bus', 800), (3, 'tram', 1000);
|
List all autonomous buses and their quantities in the public_transportation table.
|
SELECT vehicle_type, quantity FROM public_transportation WHERE vehicle_type = 'autonomous_bus';
|
gretelai_synthetic_text_to_sql
|
community_engagement (id, city, language, event_type, participants, event_date)
|
Insert new records into the community_engagement table with the following data: (1, 'Bangkok', 'Thai', 'workshops', 150, '2022-09-10') and (2, 'Delhi', 'Hindi', 'festivals', 200, '2022-11-15').
|
INSERT INTO community_engagement (id, city, language, event_type, participants, event_date) VALUES (1, 'Bangkok', 'Thai', 'workshops', 150, '2022-09-10'), (2, 'Delhi', 'Hindi', 'festivals', 200, '2022-11-15');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (1, 'John Doe', 50.00); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (2, 'Jane Smith', 100.00); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (3, 'Bob Johnson', 50.00);
|
What is the minimum donation amount and the number of donors who made donations equal to the minimum amount?
|
SELECT MIN(DonationAmount), COUNT(*) FROM Donors GROUP BY DonationAmount HAVING DonationAmount = (SELECT MIN(DonationAmount) FROM Donors);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Chicago'), (2, 'Houston'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT); INSERT INTO packages (id, warehouse_id, weight) VALUES (1, 1, 50.3), (2, 1, 30.1), (3, 2, 70.0), (4, 2, 100.0);
|
What is the maximum package weight sent from each warehouse?
|
SELECT warehouse_id, MAX(weight) as max_weight FROM packages GROUP BY warehouse_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE electric_vehicles (id INT, year INT, state VARCHAR(255), sales INT); INSERT INTO electric_vehicles (id, year, state, sales) VALUES (1, 2020, 'California', 50000), (2, 2021, 'California', 60000), (4, 2022, 'California', 80000), (5, 2022, 'Texas', 90000);
|
How many electric vehicles were sold in California in 2022?
|
SELECT SUM(sales) FROM electric_vehicles WHERE state = 'California' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Projects (id, name, type, budget) VALUES (1, 'Seawall', 'Resilience', 5000000.00), (2, 'Floodgate', 'Resilience', 3000000.00), (3, 'Bridge', 'Transportation', 8000000.00);
|
What is the total budget for all resilience projects in the infrastructure development database?
|
SELECT SUM(budget) FROM Projects WHERE type = 'Resilience';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE HeritageSites (SiteID INT, SiteName VARCHAR(50), RegionID INT); INSERT INTO Regions VALUES (1, 'RegionA'), (2, 'RegionB'), (3, 'RegionC'); INSERT INTO HeritageSites VALUES (1, 'SiteA', 1), (2, 'SiteB', 1), (3, 'SiteC', 2), (4, 'SiteD', 3), (5, 'SiteE', 3);
|
What is the total number of heritage sites per region?
|
SELECT R.RegionName, COUNT(HS.SiteID) AS TotalSites FROM Regions R JOIN HeritageSites HS ON R.RegionID = HS.RegionID GROUP BY R.RegionName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteComponents (ComponentID INT, ComponentName VARCHAR(20), Supplier VARCHAR(20), ComponentType VARCHAR(20), LaunchDate DATE); INSERT INTO SatelliteComponents (ComponentID, ComponentName, Supplier, ComponentType, LaunchDate) VALUES (1, 'Star Tracker', 'Honeywell', 'Attitude Control', '2018-04-01'); INSERT INTO SatelliteComponents (ComponentID, ComponentName, Supplier, ComponentType, LaunchDate) VALUES (2, 'S-Band Transponder', 'EMS Technologies', 'Communication', '2019-07-15'); INSERT INTO SatelliteComponents (ComponentID, ComponentName, Supplier, ComponentType, LaunchDate) VALUES (3, 'Xenon Ion Propulsion System', 'Busek', 'Propulsion', '2021-02-09'); INSERT INTO SatelliteComponents (ComponentID, ComponentName, Supplier, ComponentType, LaunchDate) VALUES (4, 'Solar Array', 'Solar Space Technologies', 'Power', '2020-06-05');
|
How many components were launched by each supplier in the first half of 2020?
|
SELECT Supplier, COUNT(*) FROM SatelliteComponents WHERE LaunchDate BETWEEN '2020-01-01' AND '2020-06-30' GROUP BY Supplier;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (id INT, state VARCHAR(2), policy_type VARCHAR(20), age INT); INSERT INTO policyholders (id, state, policy_type, age) VALUES (1, 'CA', 'Life', 35), (2, 'CA', 'Health', 45), (3, 'CA', 'Health', 55);
|
What is the average age of policyholders with health insurance policies in California?
|
SELECT AVG(age) FROM policyholders WHERE state = 'CA' AND policy_type = 'Health';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Education_Budget(Department VARCHAR(255), Allocation INT); INSERT INTO Education_Budget VALUES ('Primary Education', 5000000), ('Secondary Education', 7000000), ('Higher Education', 9000000);
|
What is the average budget allocation per department in the Education sector, ordered from highest to lowest?
|
SELECT Department, AVG(Allocation) as Avg_Allocation FROM Education_Budget GROUP BY Department ORDER BY Avg_Allocation DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, product TEXT, price_per_gram DECIMAL, city TEXT, sale_date DATE); INSERT INTO sales (id, product, price_per_gram, city, sale_date) VALUES (1, 'Blue Dream', 10.0, 'Denver', '2021-01-01'), (2, 'Gelato', 15.0, 'Denver', '2021-01-01');
|
What is the average price per gram of all cannabis products sold in Denver in 2021?
|
SELECT AVG(price_per_gram) FROM sales WHERE city = 'Denver' AND sale_date >= '2021-01-01' AND sale_date < '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Lanthanum_Market_Prices (id INT, year INT, country VARCHAR(255), market_price FLOAT);
|
What is the minimum market price of Lanthanum in Vietnam for 2018?
|
SELECT MIN(market_price) FROM Lanthanum_Market_Prices WHERE year = 2018 AND country = 'Vietnam';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY, patient_id INT, age_group VARCHAR(50), country VARCHAR(50), condition VARCHAR(50));
|
What is the most common age group for mental health conditions in Japan?
|
SELECT age_group FROM mental_health_conditions WHERE country = 'Japan' GROUP BY age_group ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grants (id INT, year INT, organization VARCHAR(50), state VARCHAR(50), type VARCHAR(50)); INSERT INTO grants (id, year, organization, state, type) VALUES (1, 2019, 'JusticeReformNY', 'New York', 'Grant'), (2, 2020, 'LegalAidNY', 'California', 'Grant'), (3, 2021, 'EmpowerJustice', 'New York', 'Donation'), (4, 2018, 'JusticeForAll', 'Texas', 'Grant'), (5, 2019, 'CriminalJusticeUSA', 'New York', 'Grant');
|
What is the total amount of grants awarded to non-profit organizations working on criminal justice reform in New York in the last 3 years?
|
SELECT SUM(amount) FROM (SELECT id, year, CASE WHEN type = 'Grant' THEN amount END AS amount FROM grants WHERE state = 'New York' AND type = 'Grant' AND year BETWEEN 2019 AND 2021) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_education (union_id INT, union_name TEXT, industry TEXT, incidents INT); INSERT INTO union_education (union_id, union_name, industry, incidents) VALUES (1, 'Union X', 'Education', 20), (2, 'Union Y', 'Education', 15), (3, 'Union Z', 'Healthcare', 10);
|
What is the average number of workplace safety incidents for each union in the education industry, grouped by union name?
|
SELECT union_name, AVG(incidents) FROM union_education WHERE industry = 'Education' GROUP BY union_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MonthlyDonations (Id INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO MonthlyDonations VALUES (1, '2022-01-01', 100.00), (2, '2022-02-01', 200.00);
|
What's the percentage of total donations received each month?
|
SELECT EXTRACT(MONTH FROM DonationDate) as Month, SUM(Amount) as TotalDonations, (SUM(Amount) / (SELECT SUM(Amount) FROM MonthlyDonations) * 100) as Percentage FROM MonthlyDonations GROUP BY Month;
|
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.