context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE shipping_lines (shipping_line_id INT, shipping_line_name VARCHAR(100)); CREATE TABLE containers (container_id INT, container_weight INT, shipping_line_id INT, shipped_date DATE); INSERT INTO shipping_lines VALUES (1, 'Maersk Line'); INSERT INTO shipping_lines VALUES (2, 'MSC Mediterranean Shipping Company'); INSERT INTO containers VALUES (1, 10, 1, '2022-03-01'); INSERT INTO containers VALUES (2, 15, 2, '2022-02-15'); INSERT INTO containers VALUES (3, 20, 1, '2022-01-10');
|
What is the total cargo weight transported by each shipping line in the first quarter of 2022, and what is the percentage of the total weight each shipping line transported during that time?
|
SELECT shipping_lines.shipping_line_name, SUM(containers.container_weight) as total_weight, (SUM(containers.container_weight) / (SELECT SUM(container_weight) FROM containers WHERE shipped_date BETWEEN '2022-01-01' AND '2022-03-31')) * 100 as percentage_of_total FROM shipping_lines INNER JOIN containers ON shipping_lines.shipping_line_id = containers.shipping_line_id WHERE containers.shipped_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY shipping_lines.shipping_line_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, name TEXT, country TEXT, reviews INT); INSERT INTO hotels (id, name, country, reviews) VALUES (1, 'Hotel A', 'South America', 120), (2, 'Hotel B', 'South America', 80), (3, 'Hotel C', 'North America', 150);
|
Calculate the average number of reviews for hotels in South America
|
SELECT AVG(reviews) FROM hotels WHERE country = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete_demographics (id INT, name VARCHAR(50), age INT, sport VARCHAR(50));
|
Show athlete names and their age from the athlete_demographics table for athletes that play basketball.
|
SELECT name, age FROM athlete_demographics WHERE sport = 'basketball';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceans (id INT, name TEXT, avg_depth FLOAT, max_depth FLOAT); INSERT INTO oceans (id, name, avg_depth, max_depth) VALUES (1, 'Indian', 3962, 7258);
|
What is the maximum depth of the Indian Ocean?"
|
SELECT max_depth FROM oceans WHERE name = 'Indian Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (org_id INT, org_name TEXT, industry TEXT, esg_score DECIMAL(3,2)); INSERT INTO organizations (org_id, org_name, industry, esg_score) VALUES (1, 'Tech Org 1', 'Technology', 75.2), (2, 'Tech Org 2', 'Technology', 82.5), (3, 'Non-Tech Org 1', 'Manufacturing', 68.1);
|
What is the average ESG score of organizations in the technology sector?
|
SELECT AVG(esg_score) FROM organizations WHERE industry = 'Technology';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics.certifications (certification_id INT, certification_name VARCHAR(255), awarded_by VARCHAR(255)); INSERT INTO cosmetics.certifications (certification_id, certification_name, awarded_by) VALUES (1, 'Leaping Bunny', 'CCIC'), (2, 'Cruelty Free', 'CCIC'), (3, 'Vegan', 'PETA');
|
Add a new vegan certification awarded by the 'CCF' organization to the cosmetics."certifications" table
|
INSERT INTO cosmetics.certifications (certification_id, certification_name, awarded_by) VALUES (4, '100% Vegan', 'CCF');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (astronaut_id INT, name VARCHAR(50), flights INT); CREATE TABLE Flights (flight_id INT, spacecraft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO Astronauts (astronaut_id, name, flights) VALUES (1, 'Astronaut1', 3), (2, 'Astronaut2', 1); INSERT INTO Flights (flight_id, spacecraft, manufacturer) VALUES (1, 'Spacecraft1', 'SpaceTech Inc.'), (2, 'Spacecraft2', 'SpaceTech Inc.');
|
What are the names of all astronauts who have flown on a SpaceTech Inc. spacecraft?
|
SELECT DISTINCT a.name FROM Astronauts a JOIN Flights f ON a.flights = f.flight_id WHERE f.manufacturer = 'SpaceTech Inc.';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_health (id INT, farm_id INT, survival_rate FLOAT); INSERT INTO fish_health (id, farm_id, survival_rate) VALUES (1, 1, 0.9); INSERT INTO fish_health (id, farm_id, survival_rate) VALUES (2, 2, 0.85); INSERT INTO fish_health (id, farm_id, survival_rate) VALUES (3, 3, 0.95);
|
What is the survival rate of fish in the 'fish_health' table?
|
SELECT survival_rate FROM fish_health WHERE farm_id = (SELECT id FROM farms ORDER BY RAND() LIMIT 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_data (date DATE, ocean TEXT, temperature FLOAT); INSERT INTO temperature_data (date, ocean, temperature) VALUES ('2018-01-01', 'Pacific', 12.5); INSERT INTO temperature_data (date, ocean, temperature) VALUES ('2019-01-01', 'Pacific', 13.0); INSERT INTO temperature_data (date, ocean, temperature) VALUES ('2020-01-01', 'Pacific', 11.8); INSERT INTO temperature_data (date, ocean, temperature) VALUES ('2021-01-01', 'Pacific', 12.3); INSERT INTO temperature_data (date, ocean, temperature) VALUES ('2022-01-01', 'Pacific', 12.9);
|
What is the average water temperature in the Pacific Ocean for January, for the past 5 years, from the temperature_data table?
|
SELECT AVG(temperature) FROM temperature_data WHERE ocean = 'Pacific' AND MONTH(date) = 1 AND YEAR(date) BETWEEN 2018 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (city VARCHAR(255), year INT, domestic_consumption INT, commercial_consumption INT, agricultural_consumption INT); INSERT INTO water_usage (city, year, domestic_consumption, commercial_consumption, agricultural_consumption) VALUES ('CityA', 2020, 350, 250, 550), ('CityB', 2020, 450, 350, 650), ('CityC', 2020, 500, 400, 700), ('CityD', 2020, 400, 300, 600);
|
What is the total water consumption by city in 2020, considering domestic, commercial, and agricultural consumption?
|
SELECT city, (domestic_consumption + commercial_consumption + agricultural_consumption) as total_consumption FROM water_usage WHERE year = 2020 GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), Location VARCHAR(50), Year INT); INSERT INTO EsportsEvents (EventID, EventName, Location, Year) VALUES (1, 'Event1', 'USA', 2022); INSERT INTO EsportsEvents (EventID, EventName, Location, Year) VALUES (2, 'Event2', 'Canada', 2021); INSERT INTO EsportsEvents (EventID, EventName, Location, Year) VALUES (3, 'Event3', 'China', 2022);
|
Count the number of esports events held in Asia in 2022.
|
SELECT COUNT(*) FROM EsportsEvents WHERE Location = 'China' AND Year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories_eco_friendly(factory_id INT, workers INT, material VARCHAR(20)); INSERT INTO factories_eco_friendly(factory_id, workers, material) VALUES(1, 100, 'organic cotton'), (2, 150, 'recycled polyester'), (3, 200, 'hemp');
|
How many workers are employed in factories that use eco-friendly materials?
|
SELECT SUM(workers) FROM factories_eco_friendly WHERE material IN ('organic cotton', 'recycled polyester', 'hemp');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hiv_tests (test_id INT, patient_id INT, city TEXT, date DATE, tests INT); INSERT INTO hiv_tests (test_id, patient_id, city, date, tests) VALUES (1, 1, 'San Francisco', '2021-01-01', 50);
|
What is the maximum number of HIV tests performed in a single day in the city of San Francisco in 2021?
|
SELECT MAX(tests) FROM hiv_tests WHERE city = 'San Francisco' AND date LIKE '2021-%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workout_attendance (user_id INT, date DATE); INSERT INTO workout_attendance (user_id, date) VALUES (1, '2022-03-01'), (1, '2022-03-03'), (2, '2022-02-15'), (1, '2022-03-05'), (3, '2022-02-28'), (1, '2022-03-07'), (4, '2022-03-05');
|
Find the number of users who have not completed any workout in the last 7 days.
|
SELECT COUNT(DISTINCT user_id) FROM workout_attendance WHERE user_id NOT IN (SELECT user_id FROM workout_attendance WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (id INT, country VARCHAR(255), year INT, sector VARCHAR(255), emissions FLOAT);
|
What are the total CO2 emissions for the power sector in each country?
|
SELECT country, SUM(emissions) FROM co2_emissions WHERE sector = 'Power' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE package_weights (id INT, package_weight FLOAT, shipped_from VARCHAR(20), shipped_to VARCHAR(20), shipped_date DATE); INSERT INTO package_weights (id, package_weight, shipped_from, shipped_to, shipped_date) VALUES (1, 5.0, 'France', 'Germany', '2022-02-01');
|
What is the maximum package weight shipped between France and Germany in the last week?
|
SELECT MAX(package_weight) FROM package_weights WHERE shipped_from = 'France' AND shipped_to = 'Germany' AND shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Clothing (id INT, brand VARCHAR(255), price DECIMAL(5,2), sustainable VARCHAR(10)); INSERT INTO Clothing (id, brand, price, sustainable) VALUES (1, 'BrandA', 25.99, 'yes'), (2, 'BrandB', 150.00, 'yes'), (3, 'BrandC', 79.99, 'no'), (4, 'BrandD', 19.99, 'yes');
|
What is the minimum price of sustainable clothing items, grouped by brand?
|
SELECT brand, MIN(price) FROM Clothing WHERE sustainable = 'yes' GROUP BY brand;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE otas (ota_id INT, ota_name TEXT, region TEXT); CREATE TABLE virtual_tours (vt_id INT, ota_id INT, engagements INT); INSERT INTO otas (ota_id, ota_name, region) VALUES (1, 'OTA 1', 'Oceania'), (2, 'OTA 2', 'Europe'), (3, 'OTA 3', 'Asia'); INSERT INTO virtual_tours (vt_id, ota_id, engagements) VALUES (1, 1, 500), (2, 2, 300), (3, 3, 700), (4, 1, 800);
|
What is the total number of virtual tour engagements in Oceania?
|
SELECT SUM(engagements) FROM virtual_tours JOIN otas ON virtual_tours.ota_id = otas.ota_id WHERE region = 'Oceania';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE caribbean_sites (site_id INT, site_name VARCHAR(255), longitude DECIMAL(9,6), latitude DECIMAL(9,6), depth DECIMAL(5,2)); CREATE VIEW caribbean_sites_view AS SELECT * FROM caribbean_sites WHERE latitude BETWEEN 10 AND 25 AND longitude BETWEEN -80 AND -60;
|
Get the average depth of marine life research sites in the Caribbean sea
|
SELECT AVG(depth) FROM caribbean_sites_view;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, vulnerability VARCHAR(50), country VARCHAR(50)); INSERT INTO vulnerabilities (id, vulnerability, country) VALUES (1, 'SQL Injection', 'USA'), (2, 'Cross-Site Scripting', 'Canada'), (3, 'Privilege Escalation', 'Brazil'), (4, 'SQL Injection', 'Mexico'), (5, 'SQL Injection', 'Brazil'), (6, 'Cross-Site Scripting', 'USA');
|
What are the top 3 countries with the highest number of unique vulnerabilities in the vulnerabilities table?
|
SELECT country, COUNT(DISTINCT vulnerability) AS num_vulnerabilities FROM vulnerabilities GROUP BY country ORDER BY num_vulnerabilities DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Product_Safety (ProductID INT, Recall BOOLEAN, Country VARCHAR(50)); INSERT INTO Product_Safety (ProductID, Recall, Country) VALUES (2001, TRUE, 'Canada'), (2002, FALSE, 'Canada'), (2003, TRUE, 'Canada'), (2004, FALSE, 'Canada'), (2005, TRUE, 'Canada');
|
Which cosmetic products have had safety recalls in Canada?
|
SELECT ProductID FROM Product_Safety WHERE Recall = TRUE AND Country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_papers (title VARCHAR(50), publication_year INT, is_autonomous BOOLEAN);
|
Which autonomous driving research papers were published in the last 3 years?
|
SELECT * FROM research_papers WHERE is_autonomous = TRUE AND publication_year BETWEEN (SELECT MAX(publication_year) - 3) AND MAX(publication_year);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospital_admissions (id INT, age_group TEXT, state TEXT, num_admissions INT); INSERT INTO hospital_admissions (id, age_group, state, num_admissions) VALUES (1, '0-17', 'California', 250), (2, '18-34', 'California', 750), (3, '35-49', 'California', 900), (4, '50+', 'California', 1200);
|
What is the number of hospital admissions by age group in California?
|
SELECT age_group, SUM(num_admissions) FROM hospital_admissions WHERE state = 'California' GROUP BY age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_grants (grant_id INT, title VARCHAR(50), amount DECIMAL(10, 2), year INT, student_id INT, degree VARCHAR(50)); INSERT INTO research_grants VALUES (1, 'Grant1', 50000, 2019, 789, 'Master of Arts'); CREATE TABLE students (student_id INT, name VARCHAR(50), degree VARCHAR(50)); INSERT INTO students VALUES (789, 'Jasmine Lee', 'Master of Arts');
|
What is the total number of research grants awarded to students with a 'Master of Arts' degree?
|
SELECT COUNT(*) FROM research_grants rg JOIN students s ON rg.student_id = s.student_id WHERE degree = 'Master of Arts';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE JapaneseSwimmers (SwimmerID INT, Name VARCHAR(50), Age INT, Medals INT, Sport VARCHAR(20), Country VARCHAR(50)); INSERT INTO JapaneseSwimmers (SwimmerID, Name, Age, Medals, Sport, Country) VALUES (1, 'Daiya Seto', 27, 15, 'Swimming', 'Japan'); INSERT INTO JapaneseSwimmers (SwimmerID, Name, Age, Medals, Sport, Country) VALUES (2, 'Rikako Ikee', 22, 8, 'Swimming', 'Japan');
|
What is the total number of medals won by athletes from Japan in Swimming?
|
SELECT SUM(Medals) FROM JapaneseSwimmers WHERE Sport = 'Swimming' AND Country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aircrafts (aircraft_id INT, model VARCHAR(50), launch_date DATE); INSERT INTO aircrafts (aircraft_id, model, launch_date) VALUES (1, 'Boeing 747', '2000-01-01'), (2, 'Airbus A320', '2010-01-01'), (3, 'Boeing 737', '1995-01-01'); CREATE TABLE accidents (accident_id INT, aircraft_id INT, date DATE); INSERT INTO accidents (accident_id, aircraft_id) VALUES (1, 1), (2, 1), (3, 3), (4, 2), (5, 2);
|
What is the earliest launch date for each aircraft model?
|
SELECT model, MIN(launch_date) as earliest_launch_date FROM aircrafts WHERE aircraft_id NOT IN (SELECT aircraft_id FROM accidents) GROUP BY model;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tokyo_metro_entries (id INT, station_name VARCHAR(255), entries INT, entry_date DATE); INSERT INTO tokyo_metro_entries (id, station_name, entries, entry_date) VALUES (1, 'Station 1', 12000, '2022-01-01'), (2, 'Station 2', 8000, '2022-01-01');
|
What is the total number of entries for all metro stations in Tokyo on January 1, 2022?
|
SELECT SUM(entries) FROM tokyo_metro_entries WHERE entry_date = '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CrimeStatistics (Id INT, Crime VARCHAR(20), Location VARCHAR(20), Date TIMESTAMP, Population INT);
|
What is the maximum number of crimes and the corresponding crime type in each city?
|
SELECT c.Location, MAX(cc.CrimeCount) as MaxCrimes, cc.CrimeType FROM CrimeStatistics cc JOIN (SELECT Location, COUNT(*) as CrimeCount, Crime as CrimeType FROM CrimeStatistics GROUP BY Location, Crime) c ON cc.Location = c.Location AND cc.Crime = c.CrimeType GROUP BY c.Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_incidents (id INT, incident_type VARCHAR(50), location_latitude FLOAT, location_longitude FLOAT, ocean VARCHAR(50)); INSERT INTO pollution_incidents (id, incident_type, location_latitude, location_longitude, ocean) VALUES (1, 'Oil Spill', -60.6667, 148.9667, 'Southern Ocean'), (2, 'Garbage Patch', -46.6333, 81.1833, 'Southern Ocean');
|
Display the number of pollution incidents in the Southern Ocean.
|
SELECT COUNT(*) FROM pollution_incidents WHERE ocean = 'Southern Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (clinical_trial_id INT, drug_id INT, trial_name TEXT, country TEXT); CREATE TABLE adverse_events (adverse_event_id INT, clinical_trial_id INT, event_description TEXT); INSERT INTO clinical_trials (clinical_trial_id, drug_id, trial_name, country) VALUES (1, 1, 'TrialX', 'USA'), (2, 2, 'TrialY', 'Canada');
|
List all clinical trials, including those without any reported adverse events, for a specific drug in the 'clinical_trials' and 'adverse_events' tables in the USA?
|
SELECT ct.trial_name, COALESCE(COUNT(ae.adverse_event_id), 0) AS event_count FROM clinical_trials ct LEFT JOIN adverse_events ae ON ct.clinical_trial_id = ae.clinical_trial_id WHERE ct.country = 'USA' AND ct.drug_id = 1 GROUP BY ct.trial_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, Country, Amount) VALUES (1, 'DonorA', 'USA', 1500.00), (2, 'DonorB', 'Canada', 2000.00);
|
Insert a new record for DonorC from India with an amount of 2500.00
|
INSERT INTO Donors (DonorName, Country, Amount) VALUES ('DonorC', 'India', 2500.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders(id INT, product_id INT, quantity INT, order_date DATE, is_sustainable BOOLEAN); INSERT INTO orders (id, product_id, quantity, order_date, is_sustainable) VALUES (1, 1, 2, '2022-01-01', true);
|
What is the average quantity of sustainable material orders?
|
SELECT AVG(quantity) FROM orders WHERE is_sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Warehouses (WarehouseID, WarehouseName, Country) VALUES (1, 'Australia Warehouse', 'Australia'); CREATE TABLE Shipments (ShipmentID INT, WarehouseID INT, DeliveryTime INT);
|
What is the average delivery time per shipment in Australia?
|
SELECT AVG(DeliveryTime) / COUNT(*) FROM Shipments WHERE WarehouseID = (SELECT WarehouseID FROM Warehouses WHERE Country = 'Australia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title TEXT, rating FLOAT, director TEXT); INSERT INTO movies (id, title, rating, director) VALUES (1, 'Movie1', 4.5, 'Director1'), (2, 'Movie2', 3.2, 'Director2'), (3, 'Movie3', 4.7, 'Director1');
|
What is the average rating of movies directed by 'Director1'?
|
SELECT AVG(rating) FROM movies WHERE director = 'Director1';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BudgetAllocation (Id INT, CityId INT, Category VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO BudgetAllocation (Id, CityId, Category, Amount) VALUES (1, 1, 'Transportation', 5000000), (2, 1, 'Infrastructure', 3000000), (3, 2, 'Transportation', 7000000), (4, 2, 'Infrastructure', 6000000);
|
What is the total budget allocated for each category, and what is the percentage of the total budget allocated to each category for each city?
|
SELECT CityId, Category, SUM(Amount) AS TotalBudget, SUM(Amount) OVER (PARTITION BY CityId) AS CityTotal, (SUM(Amount) OVER (PARTITION BY CityId)) * 100.0 / SUM(Amount) OVER () AS CategoryPercentage FROM BudgetAllocation GROUP BY CityId, Category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE expenses (id INT, category TEXT, year INT, amount_spent DECIMAL(10,2)); INSERT INTO expenses
|
What was the total amount spent on food aid in 2019?
|
SELECT SUM(amount_spent) FROM expenses WHERE category = 'food aid' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policy (policy_id INT, policy_region VARCHAR(20)); INSERT INTO policy (policy_id, policy_region) VALUES (1001, 'Northeast'), (1002, 'Southeast'), (1003, 'Northeast'), (1004, 'Southwest'); CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount INT); INSERT INTO claims (claim_id, policy_id, claim_amount) VALUES (1, 1001, 500), (2, 1002, 1200), (3, 1003, 2500), (4, 1004, 3000);
|
Pivot policy region and sum of claim amounts
|
SELECT policy_region, SUM(CASE WHEN policy_region = 'Northeast' THEN claim_amount ELSE 0 END) AS northeast_claim_amount, SUM(CASE WHEN policy_region = 'Southeast' THEN claim_amount ELSE 0 END) AS southeast_claim_amount, SUM(CASE WHEN policy_region = 'Southwest' THEN claim_amount ELSE 0 END) AS southwest_claim_amount FROM policy p JOIN claims c ON p.policy_id = c.policy_id GROUP BY policy_region WITH ROLLUP;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (subscriber_id INT, network_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, network_type, data_usage, region) VALUES (1, '3G', 15.5, 'Asia'), (2, '4G', 20.0, 'Asia'), (3, '3G', 30.0, 'Europe'), (4, '5G', 10.0, 'Asia');
|
Update subscribers' data usage who have '3G' network type and are from 'Asia' region.
|
UPDATE subscribers SET data_usage = 22.5 WHERE network_type = '3G' AND region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (id INT, country VARCHAR(50), year INT, cost FLOAT); INSERT INTO rural_infrastructure (id, country, year, cost) VALUES (1, 'Vietnam', 2020, 50000), (2, 'Vietnam', 2020, 60000), (3, 'Vietnam', 2020, 70000);
|
What is the average cost of rural infrastructure projects in Vietnam in 2020?
|
SELECT AVG(cost) FROM rural_infrastructure WHERE country = 'Vietnam' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE launch_costs (id INT, mission VARCHAR(50), launch_date DATE, company VARCHAR(50), cost FLOAT);
|
What is the average launch cost (in USD) of SpaceX missions?
|
SELECT AVG(cost) FROM launch_costs WHERE company = 'SpaceX';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL, payment_method VARCHAR);
|
Find the total number of donations and their sum, grouped by payment method
|
SELECT payment_method, COUNT(*) as total_donations, SUM(amount) as total_amount FROM donations GROUP BY payment_method;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE field_4 (id INT PRIMARY KEY, x_coordinate INT, y_coordinate INT, crop_type TEXT, area_hectares FLOAT); INSERT INTO field_4 (id, x_coordinate, y_coordinate, crop_type, area_hectares) VALUES (1, 650, 750, 'corn', 7.2), (2, 700, 800, 'sunflowers', 9.1), (3, 750, 850, 'rice', 4.6);
|
Delete all records from the 'field_4' table where crop_type is 'corn'
|
DELETE FROM field_4 WHERE crop_type = 'corn';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name VARCHAR(20)); INSERT INTO cities VALUES (1, 'CityZ'); CREATE TABLE budget_allocation (service VARCHAR(20), city_id INT, amount INT); INSERT INTO budget_allocation VALUES ('Healthcare', 1, 500000), ('Education', 1, 800000), ('Education', 1, 300000), ('Public Service', 1, 200000);
|
What is the minimum budget allocation for any service in CityZ?
|
SELECT MIN(amount) FROM budget_allocation WHERE city_id = (SELECT id FROM cities WHERE name = 'CityZ');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA province; CREATE SCHEMA territory; CREATE TABLE province.participation_data (id INT, name VARCHAR(255), is_public BOOLEAN); CREATE TABLE territory.participation_data (id INT, name VARCHAR(255), is_public BOOLEAN); INSERT INTO province.participation_data (id, name, is_public) VALUES (1, 'consultations', true), (2, 'surveys', false); INSERT INTO territory.participation_data (id, name, is_public) VALUES (1, 'consultations', true), (2, 'hearings', true);
|
Find the total number of public participation data sets in 'province' and 'territory' schemas.
|
SELECT COUNT(*) FROM ( (SELECT * FROM province.participation_data WHERE is_public = true) UNION (SELECT * FROM territory.participation_data WHERE is_public = true) ) AS combined_participation_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (InventoryId INT, WarehouseId INT, ProductId INT, Quantity INT, Country VARCHAR(50)); INSERT INTO Inventory (InventoryId, WarehouseId, ProductId, Quantity, Country) VALUES (1, 1, 1, 100, 'USA'); INSERT INTO Inventory (InventoryId, WarehouseId, ProductId, Quantity, Country) VALUES (2, 1, 2, 200, 'USA'); INSERT INTO Inventory (InventoryId, WarehouseId, ProductId, Quantity, Country) VALUES (3, 2, 1, 300, 'Canada'); INSERT INTO Inventory (InventoryId, WarehouseId, ProductId, Quantity, Country) VALUES (4, 2, 2, 400, 'Canada'); INSERT INTO Inventory (InventoryId, WarehouseId, ProductId, Quantity, Country) VALUES (5, 3, 1, 500, 'Mexico');
|
What is the average quantity of items in the inventory for the top 3 countries with the most inventory?
|
SELECT AVG(Quantity) AS AvgQuantity FROM Inventory GROUP BY Country ORDER BY SUM(Quantity) DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supply_chain (id INTEGER, product_id VARCHAR(10), shipped_date DATE, expiration_date DATE);
|
Get all products shipped after their expiration date.
|
SELECT supply_chain.* FROM supply_chain JOIN (SELECT product_id, MIN(shipped_date) AS min_shipped_date FROM supply_chain GROUP BY product_id) AS min_shipped_dates ON supply_chain.product_id = min_shipped_dates.product_id WHERE min_shipped_dates.min_shipped_date > supply_chain.expiration_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Contract_Negotiations (negotiation_id INT, sales_rep VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Contract_Negotiations (negotiation_id, sales_rep, start_date, end_date) VALUES (1, 'John Doe', '2020-01-01', '2020-01-15'), (2, 'Jane Smith', '2020-02-01', '2020-02-20'), (3, 'John Doe', '2020-03-01', '2020-03-10'), (4, 'Jane Smith', '2020-04-01', '2020-04-15');
|
What is the average contract negotiation duration for each sales representative, ranked by duration?
|
SELECT sales_rep, AVG(DATEDIFF(end_date, start_date)) AS avg_duration, RANK() OVER (ORDER BY AVG(DATEDIFF(end_date, start_date)) DESC) AS duration_rank FROM Contract_Negotiations GROUP BY sales_rep;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteer_data (id INT, volunteer_country VARCHAR, donation_country VARCHAR, num_volunteers INT, total_donation_amount DECIMAL);
|
Get the total number of volunteers and total donation amount per country.
|
SELECT volunteer_country, SUM(total_donation_amount) as total_donation_amount, SUM(num_volunteers) as total_num_volunteers FROM volunteer_data GROUP BY volunteer_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ota_revenue (ota_id INT, city TEXT, revenue FLOAT, year INT); INSERT INTO ota_revenue (ota_id, city, revenue, year) VALUES (1, 'London', 5000, 2022), (2, 'London', 7000, 2022), (3, 'Paris', 6000, 2022);
|
What is the total revenue generated by OTAs in 'London' in 2022?
|
SELECT SUM(revenue) FROM ota_revenue WHERE city = 'London' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists countries (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO countries (id, name, continent) VALUES (1, 'Afghanistan', 'Asia'); INSERT INTO countries (id, name, continent) VALUES (2, 'Algeria', 'Africa'); CREATE TABLE if not exists projects (id INT PRIMARY KEY, name VARCHAR(50), country_id INT); INSERT INTO projects (id, name, country_id) VALUES (1, 'Disaster Response', 2); INSERT INTO projects (id, name, country_id) VALUES (2, 'Community Development', 2); CREATE TABLE if not exists volunteers (id INT PRIMARY KEY, name VARCHAR(50), project_id INT); INSERT INTO volunteers (id, name, project_id) VALUES (1, 'John Doe', 1); INSERT INTO volunteers (id, name, project_id) VALUES (2, 'Jane Smith', NULL); INSERT INTO volunteers (id, name, project_id) VALUES (3, 'Jim Brown', 2);
|
Which volunteers are not assigned to any project in Asia?
|
SELECT v.name FROM volunteers v LEFT JOIN projects p ON v.project_id = p.id WHERE p.id IS NULL AND c.continent = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50), email VARCHAR(50)); INSERT INTO graduate_students VALUES (1, 'Charlie', 'Physics', 'charlie@math.edu'), (2, 'David', 'Physics', 'david@gmail.com'), (3, 'Eve', 'Chemistry', 'eve@chemistry.edu');
|
Update the email addresses of all graduate students in the Physics department with the domain 'physics.ac.uk'.
|
UPDATE graduate_students SET email = CONCAT(SUBSTRING_INDEX(email, '@', 1), '@physics.ac.uk') WHERE department = 'Physics';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityEvents (event_id INT, region VARCHAR(50), event_type VARCHAR(50), event_date DATE);
|
Delete community engagement events held more than 6 months ago
|
DELETE FROM CommunityEvents WHERE event_date < NOW() - INTERVAL '6 month';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cultural_Sites (site_id INT, site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO Cultural_Sites (site_id, site_name, country) VALUES (1, 'Alhambra', 'Spain'), (2, 'Colosseum', 'Italy');
|
List all cultural heritage sites in Spain and Italy.
|
SELECT site_name FROM Cultural_Sites WHERE country IN ('Spain', 'Italy');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pipelines (pipeline_name TEXT, location TEXT); INSERT INTO pipelines (pipeline_name, location) VALUES ('Pipeline A', 'Gulf of Mexico'), ('Pipeline B', 'Siberia'), ('Pipeline C', 'Gulf of Mexico');
|
List all the pipelines located in 'Siberia'
|
SELECT pipeline_name FROM pipelines WHERE location = 'Siberia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LaborProductivity (SiteID INT, EmployeeID INT, Role VARCHAR(50), HoursWorkedDecimal FLOAT, Date DATE); ALTER TABLE Employees ADD CONSTRAINT FK_SiteID FOREIGN KEY (SiteID) REFERENCES LaborProductivity(SiteID);
|
Find the total number of hours worked by miners in each mine site, located in South Africa.
|
SELECT MineSites.Name, SUM(LaborProductivity.HoursWorkedDecimal) AS TotalHoursWorked FROM MineSites JOIN Employees ON MineSites.SiteID = Employees.SiteID JOIN LaborProductivity ON Employees.EmployeeID = LaborProductivity.EmployeeID WHERE Employees.Role = 'Miner' AND MineSites.Country = 'South Africa' GROUP BY MineSites.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE court_cases (case_id INT, court_date DATE); INSERT INTO court_cases (case_id, court_date) VALUES (1, '2022-01-01'), (2, '2021-12-20'), (3, '2022-02-15'); CREATE TABLE defendant_info (defendant_id INT, case_id INT, age INT, gender VARCHAR(50)); INSERT INTO defendant_info (defendant_id, case_id, age, gender) VALUES (1, 1, 35, 'Male'), (2, 2, 27, 'Female'), (3, 1, 42, 'Non-binary'), (4, 3, 19, 'Female'), (5, 3, 50, 'Male');
|
What is the average age of defendants per court case?
|
SELECT AVG(age) as avg_age, court_date FROM defendant_info d INNER JOIN court_cases c ON d.case_id = c.case_id GROUP BY court_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(50), total_assets DECIMAL(10,2), first_transaction_date DATE);CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE);
|
What is the number of clients who made their first transaction in Q1 2023 and their total assets value?
|
SELECT c.total_assets, COUNT(*) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.first_transaction_date = t.transaction_date AND t.transaction_date BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY c.total_assets
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), TotalRevenue decimal(10,2));CREATE TABLE SustainableSourcing (SourcingID int, RestaurantID int, Cost decimal(10,2));
|
What is the total revenue for each restaurant, including their sustainable sourcing costs, for the month of January 2021?
|
SELECT R.Name, SUM(R.TotalRevenue + SS.Cost) as TotalRevenueWithSustainableCosts FROM Restaurants R INNER JOIN SustainableSourcing SS ON R.RestaurantID = SS.RestaurantID WHERE MONTH(R.OrderDate) = 1 AND YEAR(R.OrderDate) = 2021 GROUP BY R.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_mine_water_consumption (mine_id INT, consumption_date DATE, total_water_consumption FLOAT); INSERT INTO daily_mine_water_consumption (mine_id, consumption_date, total_water_consumption) VALUES (1, '2021-01-01', 30000), (1, '2021-01-02', 31000), (1, '2021-01-03', 32000), (1, '2021-01-04', 33000), (2, '2021-01-01', 40000), (2, '2021-01-02', 41000), (2, '2021-01-03', 42000), (2, '2021-01-04', 41000);
|
List the mines that have shown an increase in water consumption compared to the previous day.
|
SELECT mine_id, consumption_date, total_water_consumption, LAG(total_water_consumption) OVER (PARTITION BY mine_id ORDER BY consumption_date) as prev_day_consumption, total_water_consumption - LAG(total_water_consumption) OVER (PARTITION BY mine_id ORDER BY consumption_date) as consumption_change FROM daily_mine_water_consumption WHERE total_water_consumption > LAG(total_water_consumption) OVER (PARTITION BY mine_id ORDER BY consumption_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredient_sourcing(ingredient_id INT, product_id INT, ingredient VARCHAR(50), organic BOOLEAN);
|
What is the total number of organic ingredients used in cosmetics products for each category?
|
SELECT cosmetics_products.category, SUM(CASE WHEN ingredient_sourcing.organic THEN 1 ELSE 0 END) as organic_ingredient_count FROM ingredient_sourcing JOIN cosmetics_products ON ingredient_sourcing.product_id = cosmetics_products.product_id GROUP BY cosmetics_products.category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_sources (funding_source_id INT, funding_category VARCHAR(255), year INT, amount INT); INSERT INTO funding_sources (funding_source_id, funding_category, year, amount) VALUES (1, 'Visual Arts', 2022, 5000), (2, 'Theater', 2021, 7000), (3, 'Theater', 2022, 12000);
|
What is the total funding amount for the 'Theater' category in 2022?
|
SELECT SUM(amount) as total_funding FROM funding_sources WHERE funding_category = 'Theater' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WaterAccess (country_name TEXT, continent TEXT, population INTEGER, clean_water_access BOOLEAN); INSERT INTO WaterAccess (country_name, continent, population, clean_water_access) VALUES ('Algeria', 'Africa', 43073003, true), ('Angola', 'Africa', 32898569, false), ('Benin', 'Africa', 12131338, true), ('Botswana', 'Africa', 2359373, true), ('Burkina Faso', 'Africa', 20807289, false), ('Burundi', 'Africa', 11526794, false), ('Cameroon', 'Africa', 25678974, true);
|
What is the total population in Africa with access to clean water?
|
SELECT SUM(population) FROM WaterAccess WHERE clean_water_access = true AND continent = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TravelAdvisories (id INT, city TEXT, issued_date DATE);
|
How many travel advisories have been issued for European cities in the past month?
|
SELECT COUNT(*) FROM TravelAdvisories WHERE city IN ('Paris', 'London', 'Rome', 'Berlin', 'Madrid') AND issued_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage_mwh (region VARCHAR(20), sector VARCHAR(20), year INT, month INT, units VARCHAR(10), value FLOAT); INSERT INTO water_usage_mwh (region, sector, year, month, units, value) VALUES ('California', 'Residential', 2020, 1, 'MWh', 1500000);
|
What is the total water usage in MW for the residential sector in January 2020?
|
SELECT value FROM water_usage_mwh WHERE sector = 'Residential' AND region = 'California' AND year = 2020 AND month = 1 AND units = 'MWh';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_safety_incidents (incident_id INT, incident_date DATE, incident_country TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_date, incident_country) VALUES (1, '2021-03-15', 'USA'), (2, '2020-12-21', 'Canada'), (3, '2021-08-01', 'UK'), (4, '2020-01-10', 'Mexico'), (5, '2021-06-12', 'France');
|
How many AI safety incidents were reported in each country for the past 2 years?
|
SELECT incident_country, EXTRACT(YEAR FROM incident_date) as year, COUNT(*) as num_incidents FROM ai_safety_incidents GROUP BY incident_country, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_id INT, debris_name VARCHAR(255), launch_date DATE, location VARCHAR(255), type VARCHAR(255)); CREATE VIEW space_debris_view AS SELECT * FROM space_debris;
|
Create a view named 'space_debris_view' showing all debris entries
|
CREATE VIEW space_debris_view AS SELECT * FROM space_debris;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO restaurants (id, name, category) VALUES (1, 'Pizza Palace', 'Vegan Pizza'); CREATE TABLE menu_items (id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu_items (id, name, category, price) VALUES (101, 'Vegan Pepperoni Pizza', 'Vegan Pizza', 14.99), (102, 'Vegan Margherita Pizza', 'Vegan Pizza', 12.99); CREATE TABLE orders (id INT, menu_item_id INT, quantity INT, order_date DATE); INSERT INTO orders (id, menu_item_id, quantity, order_date) VALUES (1001, 101, 1, '2021-08-01'), (1002, 102, 3, '2021-08-01'), (1003, 101, 2, '2021-08-03');
|
Find the daily revenue for 'Vegan Pizza' on 2021-08-01
|
SELECT SUM(menu_items.price * orders.quantity) AS daily_revenue FROM orders JOIN menu_items ON orders.menu_item_id = menu_items.id WHERE menu_items.category = 'Vegan Pizza' AND orders.order_date = '2021-08-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_treatment_plants (id INT, plant_name VARCHAR(50), maintenance_cost INT); INSERT INTO water_treatment_plants (id, plant_name, maintenance_cost) VALUES (1, 'Plant A', 30000), (2, 'Plant B', 50000), (3, 'Plant C', 40000), (4, 'Plant D', 35000);
|
What is the 'maintenance_cost' for 'Plant D' in 'water_treatment_plants'?
|
SELECT maintenance_cost FROM water_treatment_plants WHERE plant_name = 'Plant D';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factory_wages (id INT, factory VARCHAR(100), location VARCHAR(100), min_wage DECIMAL(5,2)); INSERT INTO factory_wages (id, factory, location, min_wage) VALUES (1, 'Vietnam Factory', 'Vietnam', 5), (2, 'Thailand Factory', 'Thailand', 7), (3, 'Cambodia Factory', 'Cambodia', 3);
|
What is the minimum wage in factories in Southeast Asia?
|
SELECT MIN(min_wage) FROM factory_wages WHERE location = 'Southeast Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_pollution (location VARCHAR(255), pollution_level FLOAT); INSERT INTO ocean_pollution (location, pollution_level) VALUES ('Pacific Ocean', 7.5), ('Atlantic Ocean', 6.2);
|
What is the maximum pollution level recorded in the Pacific Ocean?
|
SELECT MAX(pollution_level) FROM ocean_pollution WHERE location = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (artist_id INT, name VARCHAR(50), birth_place VARCHAR(50)); INSERT INTO artists (artist_id, name, birth_place) VALUES (1, 'Vincent Van Gogh', 'Netherlands');
|
How many artists were born in each country?
|
SELECT a.birth_place, COUNT(*) FROM artists a GROUP BY a.birth_place;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryBases (BaseID int, BaseName varchar(100), Country varchar(50), NumSoldiers int); INSERT INTO MilitaryBases (BaseID, BaseName, Country, NumSoldiers) VALUES (1, 'Fort Bragg', 'USA', 53000), (2, 'Camp Bastion', 'UK', 28000), (3, 'Camp Taji', 'Iraq', 15000);
|
What is the total number of military bases grouped by country?
|
SELECT Country, COUNT(*) as TotalBases FROM MilitaryBases GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (menu_id INT, dish_name VARCHAR(255), allergen_count INT);CREATE TABLE dish_ratings (dish_name VARCHAR(255), dish_rating VARCHAR(20));
|
Identify the number of food allergens for each dish in the 'menu_items' table, with a dish rating of 'excellent' or 'good' in the 'dish_ratings' table?
|
SELECT menu_items.dish_name, SUM(menu_items.allergen_count) as total_allergens FROM menu_items INNER JOIN dish_ratings ON menu_items.dish_name = dish_ratings.dish_name WHERE dish_ratings.dish_rating IN ('excellent', 'good') GROUP BY menu_items.dish_name;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists renewables; CREATE TABLE if not exists renewables.renewable_projects (project_id int, name varchar(255), location varchar(255), installed_capacity float); INSERT INTO renewables.renewable_projects (project_id, name, location, installed_capacity) VALUES (1, 'Renewable Project 1', 'Country A', 100.0), (2, 'Renewable Project 2', 'Country B', 150.0), (3, 'Renewable Project 3', 'Country C', 200.0);
|
What is the average installed capacity for a renewable energy project in the 'renewables' schema?
|
SELECT AVG(installed_capacity) FROM renewables.renewable_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product VARCHAR(255), is_organic BOOLEAN, is_local BOOLEAN); INSERT INTO products (product, is_organic, is_local) VALUES ('Apples', true, false), ('Carrots', true, true), ('Chicken', false, false), ('Eggs', true, true);
|
What is the total number of 'organic' and 'local' food products in the 'products' table?
|
SELECT COUNT(*) as total_organic_local_products FROM products WHERE is_organic = true OR is_local = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crime_incidents (id INT, date DATE, type VARCHAR(20)); INSERT INTO crime_incidents (id, date, type) VALUES (1, '2022-01-01', 'theft'), (2, '2022-01-02', 'burglary'); CREATE TABLE emergency_calls (id INT, date DATE, type VARCHAR(20)); INSERT INTO emergency_calls (id, date, type) VALUES (1, '2022-01-01', 'emergency call'); CREATE TABLE fire_incidents (id INT, date DATE, type VARCHAR(20)); INSERT INTO fire_incidents (id, date, type) VALUES (1, '2022-01-02', 'fire incident'); CREATE TABLE locations (id INT, city VARCHAR(20), state VARCHAR(20)); INSERT INTO locations (id, city, state) VALUES (1, 'Oakland', 'CA');
|
What is the total number of crime incidents, emergency calls, and fire incidents in the last week in Oakland, CA?
|
SELECT 'crime incidents' AS type, COUNT(*) FROM crime_incidents INNER JOIN locations ON crime_incidents.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND locations.city = 'Oakland' AND locations.state = 'CA' UNION ALL SELECT 'emergency calls' AS type, COUNT(*) FROM emergency_calls INNER JOIN locations ON emergency_calls.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND locations.city = 'Oakland' AND locations.state = 'CA' UNION ALL SELECT 'fire incidents' AS type, COUNT(*) FROM fire_incidents INNER JOIN locations ON fire_incidents.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND locations.city = 'Oakland' AND locations.state = 'CA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (satellite_id INT, satellite_name VARCHAR(100), launch_country VARCHAR(50), launch_date DATE); INSERT INTO satellites (satellite_id, satellite_name, launch_country, launch_date) VALUES (1, 'Sentinel-1A', 'France', '2012-04-03'); INSERT INTO satellites (satellite_id, satellite_name, launch_country, launch_date) VALUES (2, 'Sentinel-1B', 'Germany', '2016-04-22'); CREATE TABLE countries (country_id INT, country_name VARCHAR(50), region VARCHAR(50)); INSERT INTO countries (country_id, country_name, region) VALUES (1, 'France', 'Europe'); INSERT INTO countries (country_id, country_name, region) VALUES (2, 'Germany', 'Europe'); INSERT INTO countries (country_id, country_name, region) VALUES (3, 'Australia', 'Asia-Pacific'); INSERT INTO countries (country_id, country_name, region) VALUES (4, 'China', 'Asia-Pacific');
|
What is the total number of satellites launched by countries in the Asia-Pacific region?
|
SELECT COUNT(*) FROM satellites s JOIN countries c ON s.launch_country = c.country_name WHERE c.region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, donor_reg_date DATE); INSERT INTO donors (id, donor_reg_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-03-30');
|
How many donors registered in Q1 2022?
|
SELECT COUNT(*) FROM donors WHERE donor_reg_date BETWEEN '2022-01-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (Id INT, Name VARCHAR(100), MaxSpeed FLOAT); INSERT INTO Vessels (Id, Name, MaxSpeed) VALUES (1, 'VesselA', 30.5), (2, 'VesselB', 24.3), (3, 'VesselC', 28.8);
|
What is the average speed of vessels that have a maximum speed greater than 25 knots?
|
SELECT AVG(MaxSpeed) FROM Vessels WHERE MaxSpeed > 25;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance) VALUES (1, 'Savings', 'New York', 5000.00), (2, 'Checking', 'New York', 7000.00), (3, 'Checking', 'Seattle', 3000.00), (4, 'Savings', 'Seattle', 4000.00), (5, 'Credit Card', 'Seattle', 1000.00);
|
What is the total balance for customers in the Seattle branch?
|
SELECT SUM(balance) FROM accounts WHERE branch = 'Seattle';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ratings (product_id INT, rating INT, country_name VARCHAR(20)); INSERT INTO ratings (product_id, rating, country_name) VALUES (1, 4, 'India'), (2, 3, 'USA'), (3, 5, 'Canada'), (4, 2, 'Brazil');
|
What is the average rating for products sold in India?
|
SELECT AVG(rating) FROM ratings WHERE country_name = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, artist_name VARCHAR(100), period VARCHAR(50), artwork_name VARCHAR(100)); INSERT INTO Artworks (id, artist_name, period, artwork_name) VALUES (1, 'Pablo Picasso', 'Cubism', 'Guernica'); INSERT INTO Artworks (id, artist_name, period, artwork_name) VALUES (2, 'Georges Braque', 'Cubism', 'Woman with a Guitar'); INSERT INTO Artworks (id, artist_name, period, artwork_name) VALUES (3, 'Fernand Léger', 'Cubism', 'The Seasons');
|
List all artists and their artwork counts in the 'Cubism' period.
|
SELECT artist_name, COUNT(*) as artwork_count FROM Artworks WHERE period = 'Cubism' GROUP BY artist_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(255), rating FLOAT); INSERT INTO movies (id, title, genre, rating) VALUES (1, 'Movie1', 'Action', 7.5), (2, 'Movie2', 'Drama', 8.2), (3, 'Movie3', 'Comedy', 6.8), (4, 'Movie4', 'Action', 8.0), (5, 'Movie5', 'Drama', 7.0);
|
What is the average rating of movies by genre?
|
SELECT genre, AVG(rating) as avg_rating FROM movies GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (id INT, region VARCHAR(20), investment_date DATE, amount DECIMAL(10,2)); INSERT INTO network_investments (id, region, investment_date, amount) VALUES (1, 'Europe', '2022-01-01', 50000.00), (2, 'Asia', '2022-02-01', 75000.00), (3, 'Europe', '2022-03-01', 60000.00), (4, 'Africa', '2022-04-01', 45000.00), (5, 'Africa', '2022-05-01', 55000.00);
|
What is the average network investment in the 'Africa' region over the last year?
|
SELECT AVG(amount) FROM network_investments WHERE region = 'Africa' AND investment_date BETWEEN DATE_SUB('2022-04-01', INTERVAL 1 YEAR) AND '2022-04-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu (id INT, name VARCHAR(255), price DECIMAL(5,2), vegetarian BOOLEAN); INSERT INTO Menu (id, name, price, vegetarian) VALUES (1, 'Chicken Burger', 7.99, FALSE), (2, 'Veggie Wrap', 6.49, TRUE), (3, 'Chicken Caesar Salad', 9.99, FALSE);
|
Update all records in the 'Menu' table with a price less than 7.00 and set their price to 7.00.
|
UPDATE Menu SET price = 7.00 WHERE price < 7.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT, company_id INT, sector VARCHAR(255), year INT, amount FLOAT); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (1, 1, 'Renewable Energy', 2020, 500000.0); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (2, 2, 'Renewable Energy', 2019, 600000.0); INSERT INTO investments (id, company_id, sector, year, amount) VALUES (3, 3, 'Renewable Energy', 2020, 700000.0);
|
What is the total investment in the Renewable Energy sector for the past 3 years?
|
SELECT SUM(amount) FROM investments WHERE sector = 'Renewable Energy' AND year BETWEEN 2019 AND 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE donations (id INT, program_id INT, amount DECIMAL(10, 2)); INSERT INTO donations (id, program_id, amount) VALUES (1, 1, 500), (2, 1, 300), (3, 2, 800), (4, 3, 400);
|
What is the minimum donation amount received by each program?
|
SELECT program_id, MIN(amount) OVER (PARTITION BY program_id) AS min_donation_amount FROM donations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (id INT, incident_date DATE, resolution_time INT); INSERT INTO incidents (id, incident_date, resolution_time) VALUES (1, '2021-04-01', 5); INSERT INTO incidents (id, incident_date, resolution_time) VALUES (2, '2021-07-15', 7); INSERT INTO incidents (id, incident_date, resolution_time) VALUES (3, '2021-10-02', 3);
|
What is the total number of security incidents and their average resolution time, grouped by quarter?
|
SELECT YEAR(incident_date) as year, QUARTER(incident_date) as quarter, COUNT(*) as num_incidents, AVG(resolution_time) as avg_resolution_time FROM incidents GROUP BY year, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Orders (id INT, product_id INT, quantity INT, order_date DATE); INSERT INTO Orders (id, product_id, quantity, order_date) VALUES (1, 1, 10, '2021-01-01'), (2, 2, 5, '2021-01-02'), (3, 3, 2, '2021-01-03'), (4, 4, 15, '2021-01-04'), (5, 5, 8, '2021-01-05'), (6, 1, 12, '2021-01-06');
|
What is the maximum quantity of a single product sold in a day?
|
SELECT product_id, MAX(quantity) FROM Orders GROUP BY product_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget_allocations (allocation_id INT, borough TEXT, category TEXT, budget INT); INSERT INTO budget_allocations (allocation_id, borough, category, budget) VALUES (1, 'Manhattan', 'Parks', 5000000), (2, 'Brooklyn', 'Libraries', 3000000), (3, 'Bronx', 'Parks', 2000000);
|
What is the maximum budget allocated to libraries in each borough?
|
SELECT borough, MAX(budget) FROM budget_allocations WHERE category = 'Libraries' GROUP BY borough;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SafetyTesting (id INT, vehicle_type VARCHAR(50), rating INT, release_year INT); INSERT INTO SafetyTesting (id, vehicle_type, rating, release_year) VALUES (1, 'Sedan', 5, 2018), (2, 'Sedan', 5, 2019), (3, 'Sedan', 4, 2018), (4, 'Sedan', 5, 2020), (5, 'Sedan', 4, 2019), (6, 'Sedan', 4, 2021), (7, 'Sedan', 5, 2021);
|
What is the average safety rating of sedans released since 2018?
|
SELECT AVG(rating) FROM SafetyTesting WHERE vehicle_type = 'Sedan' AND release_year >= 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MenuItems (MenuItemID int, MenuItemName varchar(255), MenuItemType varchar(255), Cost int); INSERT INTO MenuItems (MenuItemID, MenuItemName, MenuItemType, Cost) VALUES (1, 'Margherita Pizza', 'Entree', 8), (2, 'Spaghetti Bolognese', 'Entree', 9), (3, 'Caprese Salad', 'Appetizer', 7), (4, 'Veggie Burger', 'Entree', 10), (5, 'Garden Salad', 'Appetizer', 5), (6, 'Chickpea Curry', 'Entree', 11), (7, 'Falafel Wrap', 'Entree', 9), (8, 'Tofu Stir Fry', 'Entree', 12), (9, 'Vegan Cheese Pizza', 'Entree', 10), (10, 'Quinoa Salad', 'Entree', 13);
|
Find the average cost of ingredients for vegan menu items?
|
SELECT AVG(Cost) FROM MenuItems WHERE MenuItemType = 'Entree' AND MenuItemName IN ('Vegan Cheese Pizza', 'Quinoa Salad', 'Chickpea Curry');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_certifications (country VARCHAR(50), certified INT); INSERT INTO hotel_certifications (country, certified) VALUES ('India', 1000), ('China', 1500);
|
What is the total number of hotels in India and China that have received a sustainability certification?
|
SELECT SUM(certified) FROM hotel_certifications WHERE country IN ('India', 'China');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MalwareDetections(id INT, malware_name VARCHAR(50), detection_date DATE);
|
How many times has a specific malware been detected in the last month?
|
SELECT COUNT(*) as detections FROM MalwareDetections WHERE malware_name = 'specific_malware' AND detection_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecrafts (id INT, name VARCHAR(255), launch_date DATE, manufacturing_cost FLOAT); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (1, 'Sputnik 1', '1957-10-04', 140000); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (2, 'Explorer 1', '1958-01-31', 150000); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (3, 'Vostok 1', '1961-04-12', 240000); INSERT INTO Spacecrafts (id, name, launch_date, manufacturing_cost) VALUES (4, 'Voyager 1', '1977-09-05', 250000);
|
What was the manufacturing cost of the last spacecraft launched?
|
SELECT manufacturing_cost FROM Spacecrafts ORDER BY launch_date DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mlb_2021 (team TEXT, wins INT);
|
Find the team with the most wins in the MLB in the 2021 season.
|
SELECT team, MAX(wins) FROM mlb_2021 GROUP BY team ORDER BY wins DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aid_distribution_europe (family_id INT, region VARCHAR(20), disaster_type VARCHAR(20), amount_aid FLOAT); INSERT INTO aid_distribution_europe (family_id, region, disaster_type, amount_aid) VALUES (1, 'Europe', 'Flood', 5000), (2, 'Europe', 'Earthquake', 7000), (3, 'Europe', 'Flood', 6000), (4, 'Europe', 'Tsunami', 8000), (5, 'Europe', 'Tornado', 9000);
|
What is the average amount of humanitarian aid received per family in Europe, grouped by disaster type, ordered by the highest average?
|
SELECT disaster_type, AVG(amount_aid) as avg_aid FROM aid_distribution_europe GROUP BY disaster_type ORDER BY avg_aid DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id INT, crop_type VARCHAR(255), yield INT, acres INT); INSERT INTO crops (id, crop_type, yield, acres) VALUES (1, 'corn', 100, 100), (2, 'soybeans', 80, 150), (3, 'wheat', 70, 120);
|
What is the total number of acres of corn and soybeans in the 'crops' table?
|
SELECT SUM(acres) as total_acres FROM crops WHERE crop_type IN ('corn', 'soybeans');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClinicalTrial (ID INT, Name TEXT, Mutations TEXT); INSERT INTO ClinicalTrial (ID, Name, Mutations) VALUES (1, 'Trial_A', 'MT1,MT2');
|
Which genetic mutations were discovered in the clinical trial 'Trial_A'?
|
SELECT Mutations FROM ClinicalTrial WHERE Name = 'Trial_A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AutonomousVehicles (Id INT, TestLocation VARCHAR(50), TestDate DATE, VehicleCount INT); INSERT INTO AutonomousVehicles (Id, TestLocation, TestDate, VehicleCount) VALUES (1, 'California', '2018-01-01', 500), (2, 'California', '2019-01-01', 1000), (3, 'California', '2020-01-01', 1500), (4, 'California', '2021-01-01', 2000);
|
What is the total number of autonomous vehicles tested in the state of California?
|
SELECT SUM(VehicleCount) FROM AutonomousVehicles WHERE TestLocation = 'California';
|
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.