context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE tourism_stats (visitor_country VARCHAR(20), destination VARCHAR(20), tourists INT); INSERT INTO tourism_stats (visitor_country, destination, tourists) VALUES ('Australia', 'San Francisco', 600), ('Australia', 'Los Angeles', 550), ('Australia', 'New York City', 400);
|
Which destinations have more than 500 tourists from Australia?
|
SELECT destination FROM tourism_stats WHERE tourists > 500 AND visitor_country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (PolicyholderID INT, Premium DECIMAL(10, 2), PolicyholderCity VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Premium, PolicyholderCity) VALUES (1, 2500, 'Rio de Janeiro'), (2, 1500, 'New York'), (3, 1000, 'São Paulo');
|
What is the average policy premium for policyholders living in 'Rio de Janeiro' or 'São Paulo'?
|
SELECT AVG(Premium) FROM Policyholders WHERE PolicyholderCity IN ('Rio de Janeiro', 'São Paulo');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), age INT, category VARCHAR(255)); INSERT INTO news (title, author, age, category) VALUES ('Sample News', 'Jane Smith', 5, 'Sports');
|
How many articles are there in the 'sports' category?
|
SELECT COUNT(*) FROM news WHERE category = 'Sports';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, location) VALUES (1, 'Jane Doe', 35, 'Female', 'Rural Texas'), (2, 'Pedro Alvarez', 42, 'Male', 'Rural Mexico'), (3, 'Ali Omar', 30, 'Male', 'Rural Egypt');
|
Count of farmers by location
|
SELECT location, COUNT(*) FROM farmers GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE cargo_handling (id INT, port_id INT, weight FLOAT, handling_date DATE);
|
What is the total cargo weight handled by each port, grouped by year and month?
|
SELECT p.port_name, DATE_FORMAT(ch.handling_date, '%Y-%m') as time_period, SUM(ch.weight) as total_weight FROM cargo_handling ch JOIN ports p ON ch.port_id = p.port_id GROUP BY p.port_name, time_period;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(50), organization VARCHAR(50), amount INT); INSERT INTO donors (id, name, organization, amount) VALUES (1, 'John Doe', 'United Nations', 50000); INSERT INTO donors (id, name, organization, amount) VALUES (2, 'Jane Smith', 'World Food Programme', 40000); INSERT INTO donors (id, name, organization, amount) VALUES (3, 'Alice Johnson', 'Doctors Without Borders', 45000);
|
Identify the top 3 donors by amount in descending order from the donors table.
|
SELECT name, organization, amount FROM donors ORDER BY amount DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SalesRepresentatives (SalesRepID INT, SalesRepName VARCHAR(50)); INSERT INTO SalesRepresentatives (SalesRepID, SalesRepName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Alice Johnson'); CREATE TABLE SalesData (SalesID INT, SalesRepID INT, EquipmentType VARCHAR(50), Quantity INT, SalePrice DECIMAL(10,2)); INSERT INTO SalesData (SalesID, SalesRepID, EquipmentType, Quantity, SalePrice) VALUES (1, 1, 'Tank', 5, 5000000), (2, 1, 'Fighter Jet', 2, 25000000), (3, 2, 'Helicopter', 3, 12000000), (4, 3, 'Drone', 10, 2000000);
|
What is the total number of military equipment sales for each sales representative?
|
SELECT SalesRepName, SUM(Quantity * SalePrice) AS TotalSales FROM SalesData SD JOIN SalesRepresentatives SR ON SD.SalesRepID = SR.SalesRepID GROUP BY SalesRepName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatment_plants (plant_id INT, plant_name VARCHAR(50), location VARCHAR(50)); CREATE TABLE inflow (inflow_id INT, plant_id INT, inflow_rate INT); CREATE TABLE outflow (outflow_id INT, plant_id INT, outflow_rate INT); INSERT INTO treatment_plants VALUES (1, 'Plant A', 'City A'); INSERT INTO inflow VALUES (1, 1, 1200); INSERT INTO outflow VALUES (1, 1, 800);
|
List the water treatment facilities along with their wastewater inflow and outflow rates.
|
SELECT tp.plant_name, i.inflow_rate, o.outflow_rate FROM treatment_plants tp INNER JOIN inflow i ON tp.plant_id = i.plant_id INNER JOIN outflow o ON tp.plant_id = o.plant_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, name, location, production) VALUES (1, 'H1', 'Barents Sea', 9000), (2, 'H2', 'Barents Sea', 8000), (3, 'H3', 'Barents Sea', 10000);
|
What is the maximum production of wells in the Barents Sea?
|
SELECT MAX(production) FROM wells WHERE location = 'Barents Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (id INT, name TEXT, dob DATE, gender TEXT, state TEXT);
|
Find the number of policyholders from each state
|
SELECT state, COUNT(*) FROM policyholders GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Soil_Types (id INT PRIMARY KEY, type VARCHAR(50), ph VARCHAR(50), region VARCHAR(50)); INSERT INTO Soil_Types (id, type, ph, region) VALUES (1, 'Sandy', '6.0-7.5', 'Northeast'); INSERT INTO Soil_Types (id, type, ph, region) VALUES (2, 'Clay', '5.5-6.5', 'Midwest'); INSERT INTO Soil_Types (id, type, ph, region) VALUES (3, 'Loam', '6.0-7.0', 'West');
|
What is the ph level of soils in the Northeast?
|
SELECT ph FROM Soil_Types WHERE region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AstronautMissions (Id INT, Astronaut VARCHAR(50), Mission VARCHAR(50)); INSERT INTO AstronautMissions (Id, Astronaut, Mission) VALUES (1, 'John Glenn', 'Apollo 11'), (2, 'Neil Armstrong', 'Apollo 11'), (3, 'Sally Ride', 'Ares 3'), (4, 'Mark Watney', 'Ares 3');
|
What is the name of the astronaut who has been on the most space missions?
|
SELECT Astronaut FROM (SELECT Astronaut, ROW_NUMBER() OVER (PARTITION BY Astronaut ORDER BY COUNT(*) DESC) AS Rank FROM AstronautMissions GROUP BY Astronaut) AS Subquery WHERE Rank = 1
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE construction_projects_3 (project_id INT, city VARCHAR(20), state VARCHAR(20), value DECIMAL(10,2)); INSERT INTO construction_projects_3 (project_id, city, state, value) VALUES (1, 'Seattle', 'WA', 2000000.00), (2, 'Spokane', 'WA', 1000000.00), (3, 'Tacoma', 'WA', 1500000.00);
|
Get the total value of construction projects in each city in Washington, grouped by city
|
SELECT city, SUM(value) FROM construction_projects_3 WHERE state = 'WA' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), region VARCHAR(255), fair_trade BOOLEAN); INSERT INTO products (product_id, product_name, region, fair_trade) VALUES (1, 'Nourishing Cream', 'Asia Pacific', false), (2, 'Revitalizing Serum', 'Europe', false), (3, 'Gentle Cleanser', 'Asia Pacific', true), (4, 'Hydrating Lotion', 'North America', true), (5, 'Soothing Toner', 'Asia Pacific', true), (6, 'Brightening Essence', 'Europe', false), (7, 'Rejuvenating Mask', 'Africa', true), (8, 'Nourishing Lotion', 'Africa', true), (9, 'Revitalizing Shampoo', 'Africa', true);
|
How many products are sourced from fair trade suppliers in the African market?
|
SELECT COUNT(*) AS fair_trade_products FROM products WHERE region = 'Africa' AND fair_trade = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, subscriber_name VARCHAR(50), last_upgrade_date DATE); INSERT INTO mobile_subscribers (subscriber_id, subscriber_name, last_upgrade_date) VALUES (1, 'John Doe', '2019-01-01'), (2, 'Jane Smith', '2020-05-01'), (3, 'Bob Johnson', '2021-02-01');
|
List all the mobile subscribers who have not upgraded their mobile devices in the last 2 years.
|
SELECT subscriber_id, subscriber_name FROM mobile_subscribers WHERE last_upgrade_date <= DATE_SUB(CURDATE(), INTERVAL 2 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees(id INT, name VARCHAR(255), title VARCHAR(255), age INT); INSERT INTO employees(id, name, title, age) VALUES (1, 'John Doe', 'Geologist', 35);
|
What is the average age of geologists in the 'mining_company' database?
|
SELECT AVG(age) FROM employees WHERE title = 'Geologist';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE staff (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), role VARCHAR(50), hire_date DATE);
|
Delete a staff member from the 'staff' table
|
DELETE FROM staff WHERE first_name = 'David' AND last_name = 'Johnson';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists mining;CREATE TABLE mining.plant (id INT, name STRING, location STRING, num_employees INT);INSERT INTO mining.plant (id, name, location, num_employees) VALUES (1, 'processing_plant', 'Canada', 200), (2, 'refinery', 'Canada', 150);
|
How many employees work in the 'processing_plant' and 'refinery'?
|
SELECT SUM(num_employees) FROM mining.plant WHERE name IN ('processing_plant', 'refinery');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (shipment_id INT, customer_id INT, shipped_date TIMESTAMP, shipped_time TIME, delivered_date TIMESTAMP, delivered_time TIME, status TEXT, delay DECIMAL(3,2), destination_state TEXT);
|
What is the average delivery time for shipments to each state from the 'shipments' table?
|
SELECT destination_state, AVG(TIMESTAMPDIFF(MINUTE, shipped_date, delivered_date)) as avg_delivery_time FROM shipments GROUP BY destination_state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_data (waste_id INT, waste_type VARCHAR(10), disposal_method VARCHAR(20));
|
Insert a new record into the 'waste_data' table: 'waste_id' = 5678, 'waste_type' = 'Solid', 'disposal_method' = 'Landfill'
|
INSERT INTO waste_data (waste_id, waste_type, disposal_method) VALUES (5678, 'Solid', 'Landfill');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asian_production (country VARCHAR(255), element VARCHAR(255), year INT, production INT); INSERT INTO asian_production (country, element, year, production) VALUES ('China', 'Terbium', 2018, 1200), ('China', 'Terbium', 2019, 1500), ('Japan', 'Terbium', 2018, 800), ('Japan', 'Terbium', 2019, 900);
|
What is the total production of Terbium in Asia by year?
|
SELECT year, SUM(production) as total_production FROM asian_production WHERE element = 'Terbium' GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE living_wage (country VARCHAR(50), apparel_manufacturing_sector VARCHAR(50), living_wage_minimum FLOAT, living_wage_maximum FLOAT);
|
Create a table for the 'living_wage' of workers in the 'apparel_manufacturing' sector
|
CREATE TABLE living_wage (country VARCHAR(50), apparel_manufacturing_sector VARCHAR(50), living_wage_minimum FLOAT, living_wage_maximum FLOAT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_cost_usa (cost_id INT, state VARCHAR(50), project_type VARCHAR(50), cost FLOAT, year INT); INSERT INTO labor_cost_usa (cost_id, state, project_type, cost, year) VALUES (1, 'California', 'Construction', 25000, 2021);
|
What is the total construction labor cost for each state in the USA for 2021?
|
SELECT state, SUM(cost) AS total_cost FROM labor_cost_usa WHERE project_type = 'Construction' AND year = 2021 GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeritageSites (SiteID INT, Name VARCHAR(50), Location VARCHAR(50), PerformanceID INT); INSERT INTO HeritageSites VALUES (1, 'Taj Mahal', 'India', 101), (2, 'Machu Picchu', 'Peru', 201), (3, 'Angkor Wat', 'Cambodia', 301); CREATE TABLE Performances (PerformanceID INT, SiteID INT, Attendance INT); INSERT INTO Performances VALUES (101, 1, 500), (201, 2, 700), (301, 3, 600), (401, 1, 800), (501, 2, 900), (601, 3, 1000);
|
Calculate the average number of traditional music performances per heritage site, ranked by their average attendance.
|
SELECT hs.Name AS HeritageSite, AVG(p.Attendance) AS AvgAttendance FROM HeritageSites hs JOIN Performances p ON hs.PerformanceID = p.PerformanceID GROUP BY hs.Name ORDER BY AvgAttendance DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Members (MemberID INT, JoinDate DATE, HasSmartwatch BOOLEAN);
|
What is the percentage of members who have a smartwatch and joined in the last year?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Members)) AS Percentage FROM Members WHERE Members.JoinDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND Members.HasSmartwatch = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50), account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region, account_balance) VALUES (1, 'John Doe', 'Midwest', 5000.00), (2, 'Jane Smith', 'Northeast', 7000.00);
|
What is the average account balance for customers in the Midwest region?
|
SELECT AVG(account_balance) FROM customers WHERE region = 'Midwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE YearlyCropProduction (year INT, crop VARCHAR(20), quantity INT, price FLOAT);
|
What was the average production of 'Lettuce' in 'YearlyCropProduction' table?
|
SELECT AVG(quantity) as avg_lettuce_production FROM YearlyCropProduction WHERE crop = 'Lettuce';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT PRIMARY KEY, year INT, gender VARCHAR(10), percentage_representation DECIMAL(5,2));
|
Delete a diversity metric record from the 'diversity_metrics' table
|
DELETE FROM diversity_metrics WHERE year = 2022 AND gender = 'Male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Building_Construction (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Building_Construction (project_id, project_name, location) VALUES (1, 'School Construction', 'Illinois'); INSERT INTO Building_Construction (project_id, project_name, location) VALUES (2, 'Hospital Expansion', 'Georgia');
|
What are the locations of the projects in the 'Building_Construction' table?
|
SELECT location FROM Building_Construction;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA gov_data;CREATE TABLE gov_data.budget_allocation (state VARCHAR(20), service VARCHAR(20), budget INT); INSERT INTO gov_data.budget_allocation (state, service, budget) VALUES ('California', 'Education', 3000000), ('California', 'Healthcare', 4000000), ('Texas', 'Education', 2000000), ('Texas', 'Healthcare', 2500000), ('New York', 'Education', 2500000), ('New York', 'Healthcare', 3000000), ('Florida', 'Education', 1500000), ('Florida', 'Healthcare', 2000000);
|
Find the top 2 states with the highest total budget allocation for public services.
|
SELECT state, SUM(budget) as total_budget FROM gov_data.budget_allocation GROUP BY state ORDER BY total_budget DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Organizations (OrgID INT, OrgName TEXT); CREATE TABLE Volunteers (VolID INT, OrgID INT, VolunteerHours INT); INSERT INTO Organizations (OrgID, OrgName) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'); INSERT INTO Volunteers (VolID, OrgID, VolunteerHours) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 300), (4, 2, 400);
|
What is the total number of volunteers for each organization?
|
SELECT OrgName, SUM(VolunteerHours) FROM Volunteers JOIN Organizations ON Volunteers.OrgID = Organizations.OrgID GROUP BY OrgName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (id INT, firm TEXT, startup TEXT); INSERT INTO investment (id, firm, startup) VALUES (1, 'Tiger Global', 'GreenSolutions'), (2, 'Sequoia', 'InnovateIT'), (3, 'Accel', 'DataDriven'), (4, 'Kleiner Perkins', 'EcoTech'), (5, 'Andreessen Horowitz', 'AI4Good'), (6, 'LGBTQ+ Ventures', 'LGBTQ+ Tech');
|
Display the names of investment firms that have funded at least one startup founded by an individual who identifies as LGBTQ+.
|
SELECT DISTINCT firm FROM investment WHERE startup IN (SELECT name FROM startup WHERE founder_identity LIKE '%LGBTQ%');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), yield INT, country VARCHAR(50)); INSERT INTO crops (id, name, yield, country) VALUES (1, 'Rice', 7500, 'China'), (2, 'Sorghum', 1500, 'India'), (3, 'Wheat', 2600, 'India'); CREATE TABLE sales (id INT PRIMARY KEY, farmer_id INT, crop VARCHAR(50), quantity INT, price FLOAT); INSERT INTO sales (id, farmer_id, crop, quantity, price) VALUES (1, 1, 'Rice', 300, 4.5), (2, 2, 'Sorghum', 800, 3.2), (3, 3, 'Wheat', 500, 5.0); CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), crops VARCHAR(50)); INSERT INTO farmers (id, name, location, crops) VALUES (1, 'John Doe', 'China', 'Rice'), (2, 'Raj Patel', 'India', 'Sorghum, Wheat'), (3, 'Kim Lee', 'South Korea', 'Barley');
|
What is the average price of 'Sorghum' sold by farmers in 'Asia'?
|
SELECT AVG(s.price) as avg_price FROM sales s JOIN farmers f ON s.farmer_id = f.id WHERE f.location = 'Asia' AND s.crop = 'Sorghum';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, department VARCHAR(20));
|
What is the minimum age of male reporters in the "reporters" table?
|
SELECT MIN(age) FROM reporters WHERE gender = 'male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnvironmentalImpact (ImpactID INT, MineName VARCHAR(50), CarbonEmission DECIMAL(10,2), WaterUsage DECIMAL(10,2), WasteGeneration DECIMAL(10,2)); INSERT INTO EnvironmentalImpact (ImpactID, MineName, CarbonEmission, WaterUsage, WasteGeneration) VALUES (1, 'ABC Mine', 15000.00, 1000000.00, 5000.00); INSERT INTO EnvironmentalImpact (ImpactID, MineName, CarbonEmission, WaterUsage, WasteGeneration) VALUES (2, 'DEF Mine', 500.00, 500000.00, 100.00); INSERT INTO EnvironmentalImpact (ImpactID, MineName, CarbonEmission, WaterUsage, WasteGeneration) VALUES (3, 'GHI Mine', 8000.00, 800000.00, 3000.00);
|
What is the carbon emission percentage rank for each mine, with the highest emitter getting the closest rank to 1?
|
SELECT ImpactID, MineName, CarbonEmission, PERCENT_RANK() OVER (ORDER BY CarbonEmission DESC) as 'CarbonRank' FROM EnvironmentalImpact;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT, name TEXT, goals INT, season INT); INSERT INTO teams (id, name, goals, season) VALUES (1, 'Manchester United', 85, 2018), (2, 'Manchester City', 90, 2018), (3, 'Liverpool', 84, 2018), (4, 'Manchester United', 73, 2017), (5, 'Manchester City', 80, 2017), (6, 'Liverpool', 78, 2017);
|
How many goals has each team scored in the last 5 seasons?
|
SELECT name, AVG(goals) FROM teams GROUP BY name HAVING season >= 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TeacherRecords (TeacherID INT, State VARCHAR(10), Subject VARCHAR(10), Hours DECIMAL(5,2)); INSERT INTO TeacherRecords (TeacherID, State, Subject, Hours) VALUES (1, 'GA', 'History', 10.0);
|
Update the professional development hours for teachers in 'Georgia' who teach 'History'
|
UPDATE TeacherRecords SET Hours = 15.0 WHERE State = 'Georgia' AND Subject = 'History';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE world_temperature (country VARCHAR(255), temperature DECIMAL(5,2), measurement_date DATE); INSERT INTO world_temperature (country, temperature, measurement_date) VALUES ('Canada', 10.5, '2020-01-01'), ('Mexico', 22.3, '2020-01-01'), ('Canada', 12.0, '2020-02-01'), ('Mexico', 25.1, '2020-02-01');
|
What is the average temperature for each country in the 'world_temperature' table for 2020?
|
SELECT country, AVG(temperature) as avg_temperature FROM world_temperature WHERE YEAR(measurement_date) = 2020 GROUP BY country, YEAR(measurement_date), TO_CHAR(measurement_date, 'IYYY') ORDER BY avg_temperature;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (id INT, name VARCHAR(255), last_inspection DATE); INSERT INTO facilities (id, name, last_inspection) VALUES (1, 'Facility A', '2020-05-01'), (2, 'Facility B', '2019-12-15'), (3, 'Facility C', '2021-03-30');
|
List the facilities that have not passed their environmental impact assessments.
|
SELECT name FROM facilities WHERE last_inspection IS NULL OR last_inspection < DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_farms (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO wind_farms (id, name, country, capacity) VALUES (1, 'Windpark Nordsee', 'Germany', 330.0), (2, 'Bard Offshore 1', 'Germany', 400.0);
|
What is the total installed capacity of wind farms in Germany?
|
SELECT SUM(capacity) FROM wind_farms WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fleet_vessels (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), year INT);
|
Add a new vessel record to the "fleet_vessels" table
|
INSERT INTO fleet_vessels (id, name, type, year) VALUES (20, 'Seafarer', 'Container Ship', 2015);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transaction (transaction_date DATE, transaction_time TIME, transaction_volume DECIMAL(10,2));
|
What is the total transaction volume for each day in the past week, broken down by hour of the day?
|
SELECT DATE_FORMAT(t.transaction_date, '%Y-%m-%d') as transaction_date, HOUR(t.transaction_time) as hour_of_day, SUM(t.transaction_volume) as total_volume FROM transaction t WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY transaction_date, hour_of_day;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marcellus_wells (well_id INT, well_name VARCHAR(50), location VARCHAR(50), operational_status VARCHAR(15), year_drilled INT, daily_gas_production FLOAT); INSERT INTO marcellus_wells VALUES (1, 'Well A', 'Marcellus Shale', 'Active', 2020, 10000); INSERT INTO marcellus_wells VALUES (2, 'Well B', 'Marcellus Shale', 'Active', 2020, 12000);
|
What is the average daily natural gas production rate for wells in the Marcellus Shale region for the year 2020?
|
SELECT AVG(daily_gas_production) FROM marcellus_wells WHERE year_drilled = 2020 AND location = 'Marcellus Shale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_beds INT); INSERT INTO hospitals (id, name, location, num_beds) VALUES (1, 'Rural Hospital', 'Rural Area A', 100), (2, 'General Hospital', 'City A', 500); CREATE TABLE clinics (id INT, name TEXT, location TEXT, num_doctors INT, num_beds INT); INSERT INTO clinics (id, name, location, num_doctors, num_beds) VALUES (1, 'Rural Clinic', 'Rural Area A', 5, 25);
|
What is the total number of hospital beds in rural areas, excluding clinic beds?
|
SELECT SUM(h.num_beds) AS total_hospital_beds FROM hospitals h WHERE h.location NOT IN (SELECT c.location FROM clinics c);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtCollection (id INT, name VARCHAR(50), artist_name VARCHAR(50), on_loan BOOLEAN);
|
List the titles and artists of art pieces in the 'ArtCollection' table that are not on loan, and sort them alphabetically by title.
|
SELECT title, artist_name FROM ArtCollection WHERE on_loan = FALSE ORDER BY title;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipments (ShipmentID INT, ForwarderID INT, DestinationWarehouse INT, ShipmentDate DATETIME); INSERT INTO Shipments (ShipmentID, ForwarderID, DestinationWarehouse, ShipmentDate) VALUES (1, 1, 30, '2022-01-01 10:00:00'), (2, 2, 30, '2022-01-05 12:00:00'), (3, 1, 30, '2022-01-07 09:00:00'); CREATE TABLE Warehouses (WarehouseID INT, State VARCHAR(2)); INSERT INTO Warehouses (WarehouseID, State) VALUES (30, 'TX'); CREATE TABLE FreightForwarders (ForwarderID INT, Name VARCHAR(50)); INSERT INTO FreightForwarders (ForwarderID, Name) VALUES (1, 'Forwarder A'), (2, 'Forwarder B');
|
List the forwarders with the most shipments to a warehouse in TX between specific dates.
|
SELECT f.Name, COUNT(s.ShipmentID) as NumberOfShipments FROM Shipments s JOIN FreightForwarders f ON s.ForwarderID = f.ForwarderID JOIN Warehouses w ON s.DestinationWarehouse = w.WarehouseID WHERE w.State = 'TX' AND s.ShipmentDate BETWEEN '2022-01-01 00:00:00' AND '2022-01-31 23:59:59' GROUP BY f.Name ORDER BY NumberOfShipments DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE practice_timelines (practice VARCHAR(255), state VARCHAR(255), timeline INT);
|
What is the average timeline for each sustainable building practice in the northeast region?
|
SELECT practice, AVG(timeline) FROM practice_timelines WHERE state IN ('Connecticut', 'Maine', 'Massachusetts', 'New Hampshire', 'New Jersey', 'New York', 'Pennsylvania', 'Rhode Island', 'Vermont') GROUP BY practice;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteOrigin (Brand VARCHAR(255), Country VARCHAR(255), WasteQuantity INT); INSERT INTO WasteOrigin (Brand, Country, WasteQuantity) VALUES ('BrandX', 'BR', 5000), ('BrandY', 'AR', 7000), ('BrandZ', 'CO', 6000);
|
What percentage of sustainable textile waste is generated from South American countries?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM WasteOrigin)) AS Percentage FROM WasteOrigin WHERE Country IN ('BR', 'AR', 'CO');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (id INT, name TEXT, country TEXT); INSERT INTO Volunteers (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE Donors (id INT, name TEXT, country TEXT); INSERT INTO Donors (id, name, country) VALUES (3, 'Mike Johnson', 'USA'), (4, 'Sara Williams', 'Mexico');
|
Find the total number of volunteers and donors from each country.
|
SELECT country, COUNT(*) FROM Volunteers GROUP BY country UNION ALL SELECT country, COUNT(*) FROM Donors GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sa_polio (country VARCHAR(50), polio_immunization_rate DECIMAL(3,1)); INSERT INTO sa_polio (country, polio_immunization_rate) VALUES ('Argentina', 95.0), ('Brazil', 92.0), ('Peru', 88.0);
|
What is the immunization rate for polio in South America by country?
|
SELECT country, AVG(polio_immunization_rate) as avg_polio_immunization_rate FROM sa_polio GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (article_id INT, title VARCHAR(50), category VARCHAR(20), publication_date DATE); INSERT INTO articles (article_id, title, category, publication_date) VALUES (1, 'Opinion 1', 'opinion', '2022-01-01'), (2, 'News 2', 'news', '2022-02-01'), (3, 'Opinion 2', 'opinion', '2022-01-15');
|
What is the total number of articles and the percentage of articles in the 'opinion' category, for each month and year?
|
SELECT DATE_FORMAT(publication_date, '%Y-%m') as month_year, COUNT(*) as total_articles, 100.0 * COUNT(CASE WHEN category = 'opinion' THEN 1 END) / COUNT(*) as opinion_percentage FROM articles GROUP BY month_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Unions (UnionID INT, UnionName VARCHAR(50), Category VARCHAR(50)); CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE WorkersData (WorkerID INT, UnionID INT, RegionID INT, Date DATE);
|
What is the total number of workers by union category and region in the year 2020?
|
SELECT c.Category, r.RegionName, SUM(1) AS Workers FROM WorkersData w JOIN Unions u ON w.UnionID = u.UnionID JOIN Regions r ON w.RegionID = r.RegionID WHERE YEAR(w.Date) = 2020 GROUP BY c.Category, r.RegionName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(50), start_date DATE, end_date DATE, country VARCHAR(50)); INSERT INTO peacekeeping_operations (id, operation_name, start_date, end_date, country) VALUES (1, 'Operation United shield', '1992-03-26', '1995-06-04', 'Somalia'); INSERT INTO peacekeeping_operations (id, operation_name, start_date, end_date, country) VALUES (2, 'Operation Joint Endeavour', '1995-12-14', '2004-12-31', 'Bosnia and Herzegovina'); INSERT INTO peacekeeping_operations (id, operation_name, start_date, end_date, country) VALUES (3, 'Operation Restore Hope', '1992-12-04', '1993-05-04', 'Somalia');
|
Which countries in the 'peacekeeping_operations' table had the most operations?
|
SELECT country, COUNT(*) as operation_count FROM peacekeeping_operations GROUP BY country ORDER BY operation_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Advisories (id INT, country_id INT, level INT, year INT); INSERT INTO Advisories (id, country_id, level, year) VALUES (1, 1, 2, 2018); INSERT INTO Advisories (id, country_id, level, year) VALUES (2, 1, 3, 2019); INSERT INTO Advisories (id, country_id, level, year) VALUES (3, 2, 1, 2018); INSERT INTO Advisories (id, country_id, level, year) VALUES (4, 2, 2, 2019); INSERT INTO Advisories (id, country_id, level, year) VALUES (5, 3, 4, 2018); INSERT INTO Advisories (id, country_id, level, year) VALUES (6, 3, 3, 2019); INSERT INTO Advisories (id, country_id, level, year) VALUES (7, 4, 1, 2019); INSERT INTO Advisories (id, country_id, level, year) VALUES (8, 4, 2, 2019);
|
Rank countries based on the number of travel advisories in 2019.
|
SELECT country_id, COUNT(*) as num_advisories, RANK() OVER (ORDER BY num_advisories DESC) as rank FROM Advisories WHERE year = 2019 GROUP BY country_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (operation_id INT, name TEXT, location TEXT, personnel INT); INSERT INTO peacekeeping_operations (operation_id, name, location, personnel) VALUES (1, 'MINUSCA', 'Central African Republic', 12000), (2, 'MONUSCO', 'Democratic Republic of the Congo', 16000);
|
List all peacekeeping operations in Africa with more than 5,000 personnel.
|
SELECT name FROM peacekeeping_operations WHERE location LIKE 'Africa%' AND personnel > 5000
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Distributors (DistributorID varchar(10), DistributorName varchar(20)); INSERT INTO Distributors VALUES ('A', 'Distributor A'); CREATE TABLE Stores (StoreID int, StoreName varchar(10)); INSERT INTO Stores VALUES (3, 'Store 3'); CREATE TABLE Deliveries (DeliveryID int, DeliveryDate date, ProduceID varchar(10), StoreID int, DistributorID varchar(10)); INSERT INTO Deliveries VALUES (1, '2022-01-02', 'P001', 3, 'A');
|
Which produce items were delivered to store 3 from distributor A after 2022-01-01?
|
SELECT ProduceID FROM Deliveries WHERE StoreID = 3 AND DistributorID = 'A' AND DeliveryDate > '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(50)); CREATE TABLE employees (id INT, name VARCHAR(50), dept_id INT, salary DECIMAL(10, 2));
|
Find the second-highest salary in the 'administrative' department?
|
SELECT salary FROM (SELECT salary FROM employees WHERE dept_id = (SELECT id FROM departments WHERE name = 'administrative') ORDER BY salary DESC LIMIT 2) t ORDER BY salary LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales (id INT, supplier VARCHAR(50), country VARCHAR(50), quarter VARCHAR(10), year INT, quantity INT); INSERT INTO military_sales (id, supplier, country, quarter, year, quantity) VALUES (1, 'Supplier Y', 'Russian Federation', 'Q4', 2022, 600);
|
Who was the top supplier of military equipment to the Russian Federation in Q4 2022?
|
SELECT supplier, SUM(quantity) as total_quantity FROM military_sales WHERE country = 'Russian Federation' AND quarter = 'Q4' AND year = 2022 GROUP BY supplier ORDER BY total_quantity DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_support (id INT, organization VARCHAR(255), funding_amount INT, project_type VARCHAR(255), year INT); INSERT INTO community_support (id, organization, funding_amount, project_type, year) VALUES (1, 'Inuit Development Fund', 50000, 'research', 2019); INSERT INTO community_support (id, organization, funding_amount, project_type, year) VALUES (2, 'Sami Support Association', 75000, 'conservation', 2020); INSERT INTO community_support (id, organization, funding_amount, project_type, year) VALUES (3, 'Maori Resource Council', 80000, 'management', 2021);
|
What is the total funding for 'conservation' projects in 2020?
|
SELECT SUM(funding_amount) FROM community_support WHERE project_type = 'conservation' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TemperatureLog ( LogID INT, FarmID INT, LogDate DATE, WaterTemperature DECIMAL(5,2) ); INSERT INTO TemperatureLog (LogID, FarmID, LogDate, WaterTemperature) VALUES (1, 1, '2022-01-01', 28.5), (2, 1, '2022-01-02', 29.0), (3, 1, '2022-01-03', 28.0), (4, 1, '2022-01-04', 28.5), (5, 1, '2022-01-05', 27.8);
|
Find the difference in water temperature between each consecutive day for a specific aquaculture farm?
|
SELECT LogDate, WaterTemperature, LAG(WaterTemperature) OVER (ORDER BY LogDate) as PreviousTemp, WaterTemperature - LAG(WaterTemperature) OVER (ORDER BY LogDate) as TempDifference FROM TemperatureLog WHERE FarmID = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (element VARCHAR(10), country VARCHAR(20), quantity INT, year INT); INSERT INTO production (element, country, quantity, year) VALUES ('Lanthanum', 'Canada', 7000, 2016), ('Lanthanum', 'Canada', 8000, 2017), ('Lanthanum', 'Canada', 9000, 2018), ('Lanthanum', 'Canada', 10000, 2019), ('Lanthanum', 'Canada', 11000, 2020), ('Lanthanum', 'Canada', 12000, 2021);
|
What is the maximum quantity of 'Lanthanum' produced in a year by 'Canada'?
|
SELECT MAX(quantity) FROM production WHERE element = 'Lanthanum' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Orders (OrderID INT, MenuItemID INT, CustomerID INT, Location TEXT, Cuisine TEXT); CREATE VIEW DistinctLocations AS SELECT DISTINCT Location FROM Orders;
|
Display the most popular cuisine type in each region.
|
SELECT Location, Cuisine, COUNT(Cuisine) AS Popularity FROM Orders INNER JOIN DistinctLocations ON Orders.Location = DistinctLocations.Location GROUP BY Location, Cuisine ORDER BY Location, Popularity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'India'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3, 'Alice Johnson', 'Japan');
|
Show me the total number of donors from Asia.
|
SELECT COUNT(*) FROM Donors WHERE Donors.Country IN ('India', 'Japan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales(drug varchar(20), quarter varchar(10), amount int);INSERT INTO sales VALUES ('DrugA', 'Q1 2020', 15000);
|
What were the total sales of 'DrugA' in Q1 2020?
|
SELECT SUM(amount) FROM sales WHERE drug = 'DrugA' AND quarter = 'Q1 2020';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipments (id INT, weight FLOAT, destination VARCHAR(20), ship_date DATE); INSERT INTO Shipments (id, weight, destination, ship_date) VALUES (1, 50.3, 'Texas', '2021-01-01'), (2, 70.1, 'California', '2021-01-02');
|
What is the average weight of shipments sent to Texas from January 1, 2021 to January 15, 2021?
|
SELECT AVG(weight) FROM Shipments WHERE destination = 'Texas' AND ship_date BETWEEN '2021-01-01' AND '2021-01-15';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO species (id, name) VALUES (1, 'Spruce'); INSERT INTO species (id, name) VALUES (2, 'Pine'); CREATE TABLE trees (id INT PRIMARY KEY, species_id INT, height INT); INSERT INTO trees (id, species_id, height) VALUES (1, 1, 30); INSERT INTO trees (id, species_id, height) VALUES (2, 2, 40);
|
What is the name of the species with the highest average tree height?
|
SELECT s.name FROM species s JOIN (SELECT species_id, AVG(height) AS avg_height FROM trees GROUP BY species_id ORDER BY avg_height DESC LIMIT 1) t ON s.id = t.species_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceans (id INT, name TEXT, area FLOAT, average_depth FLOAT); INSERT INTO oceans (id, name, area, average_depth) VALUES (1, 'Pacific Ocean', 165200000, 4000); INSERT INTO oceans (id, name, area, average_depth) VALUES (2, 'Atlantic Ocean', 82300000, 3926.5); INSERT INTO oceans (id, name, area, average_depth) VALUES (3, 'Indian Ocean', 73400000, 3962.4); INSERT INTO oceans (id, name, area, average_depth) VALUES (4, 'Arctic Ocean', 14090000, 5527); INSERT INTO oceans (id, name, area, average_depth) VALUES (5, 'Southern Ocean', 20327000, 3278.6);
|
What is the total area of oceans with an average depth greater than 4000 meters?
|
SELECT SUM(area) FROM oceans WHERE average_depth > 4000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Pacific_Ocean (dissolved_oxygen FLOAT, farm_id INT); INSERT INTO Pacific_Ocean (dissolved_oxygen, farm_id) VALUES (5.0, 101); INSERT INTO Pacific_Ocean (dissolved_oxygen, farm_id) VALUES (6.0, 102); CREATE TABLE Shrimp_Farms (id INT, name VARCHAR(20)); INSERT INTO Shrimp_Farms (id, name) VALUES (101, 'Shrimp Farm A'); INSERT INTO Shrimp_Farms (id, name) VALUES (102, 'Shrimp Farm B');
|
Identify shrimp farms with poor water quality based on dissolved oxygen levels in the Pacific Ocean.
|
SELECT Shrimp_Farms.name FROM Pacific_Ocean INNER JOIN Shrimp_Farms ON Pacific_Ocean.farm_id = Shrimp_Farms.id WHERE dissolved_oxygen < 6.5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sustainable_Materials (Material_ID INT, Material_Name TEXT, Cost FLOAT, Green_Rating INT); INSERT INTO Sustainable_Materials (Material_ID, Material_Name, Cost, Green_Rating) VALUES (1, 'Recycled Steel', 700, 5), (2, 'Straw Bale', 350, 8), (3, 'Reclaimed Wood', 1200, 7); CREATE TABLE Conventional_Materials (Material_ID INT, Material_Name TEXT, Cost FLOAT); INSERT INTO Conventional_Materials (Material_ID, Material_Name, Cost) VALUES (1, 'Mild Steel', 800), (2, 'Brick', 600), (3, 'Concrete', 500);
|
What is the average cost of sustainable building materials used in green building projects, and how does it compare to the average cost of conventional building materials?
|
SELECT AVG(Sustainable_Materials.Cost) AS Avg_Sustainable_Cost, AVG(Conventional_Materials.Cost) AS Avg_Conventional_Cost FROM Sustainable_Materials, Conventional_Materials;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm_africa (farm_id INT, country VARCHAR(255), species VARCHAR(255)); INSERT INTO farm_africa (farm_id, country, species) VALUES (1, 'Egypt', 'Tilapia'), (2, 'Egypt', 'Salmon'), (3, 'Nigeria', 'Catfish'), (4, 'Nigeria', 'Tilapia'), (5, 'South Africa', 'Trout'), (6, 'South Africa', 'Salmon');
|
Find the number of fish farms in each country in the African region.
|
SELECT country, COUNT(*) FROM farm_africa WHERE country IN ('Egypt', 'Nigeria', 'South Africa') GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TVShows (ShowID INT, Title VARCHAR(255), Country VARCHAR(50), Seasons INT, Episodes INT);
|
What is the average number of episodes per season for TV shows grouped by their countries?
|
SELECT Country, AVG(Episodes/Seasons) AS Avg_Episodes_Per_Season FROM TVShows GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Labor_Productivity (Mine_Name VARCHAR(50), Productivity FLOAT, Year INT); INSERT INTO Labor_Productivity (Mine_Name, Productivity, Year) VALUES ('Emerald Peaks', 5.3, 2019), ('Ruby Ridge', 4.8, 2019), ('Sapphire Summit', 5.7, 2019);
|
What is the mine with the highest labor productivity in the most recent year?
|
SELECT Mine_Name FROM Labor_Productivity WHERE Productivity = (SELECT MAX(Productivity) FROM Labor_Productivity) AND Year = (SELECT MAX(Year) FROM Labor_Productivity);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduate_programs (id INT, program_name VARCHAR(50), num_students INT); INSERT INTO graduate_programs (id, program_name, num_students) VALUES (1, 'Computer Science', 500), (2, 'Physics', 300), (3, 'Mathematics', 400), (4, 'Biology', 200), (5, 'Chemistry', 250);
|
List the top 3 graduate programs with the highest number of international students.
|
SELECT program_name, num_students FROM graduate_programs ORDER BY num_students DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE media_content (id INT, genre VARCHAR(50), frequency INT); INSERT INTO media_content (id, genre, frequency) VALUES (1, 'Movie', 100), (2, 'TV Show', 30), (3, 'Documentary', 40);
|
What is the total frequency of content for each genre in the media_content table?
|
SELECT genre, SUM(frequency) FROM media_content GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, name VARCHAR(255), continent VARCHAR(255), status VARCHAR(255));
|
Delete the 'peacekeeping_operations' table
|
DROP TABLE peacekeeping_operations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenues (revenue FLOAT, region VARCHAR(20)); INSERT INTO revenues (revenue, region) VALUES (120000, 'Southern'), (150000, 'Northern'), (180000, 'Western'), (200000, 'Northern'), (250000, 'Eastern'); CREATE TABLE minimum_revenue (min_revenue FLOAT); INSERT INTO minimum_revenue (min_revenue) VALUES (100000);
|
What is the minimum total revenue for the telecom provider in all regions?
|
SELECT MIN(revenue) FROM revenues;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Age INT); INSERT INTO Employees (EmployeeID, Name, Department, Age) VALUES (1, 'John Doe', 'Mining Operations', 35); INSERT INTO Employees (EmployeeID, Name, Department, Age) VALUES (2, 'Jane Smith', 'Human Resources', 40); INSERT INTO Employees (EmployeeID, Name, Department, Age) VALUES (3, 'David Johnson', 'Finance', 30);
|
How many employees work in each department in the mining company?
|
SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_facilities (id INT, facility_name VARCHAR(255), country VARCHAR(255), ethical_rating INT); INSERT INTO ethical_facilities (id, facility_name, country, ethical_rating) VALUES (1, 'Green Textiles', 'USA', 9), (2, 'EcoMetal', 'Germany', 10), (3, 'SolarSteel', 'China', 8);
|
What is the total number of ethical facilities in Germany?
|
SELECT COUNT(*) FROM ethical_facilities WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VEHICLE_MAINTENANCE_WEEK (maintenance_center TEXT, service_day DATE); INSERT INTO VEHICLE_MAINTENANCE_WEEK (maintenance_center, service_day) VALUES ('North', '2022-03-01'), ('North', '2022-03-03'), ('South', '2022-03-02'), ('East', '2022-03-04'), ('West', '2022-03-05');
|
How many vehicles were serviced in the last week for each maintenance center, grouped by day?
|
SELECT maintenance_center, COUNT(*), service_day FROM VEHICLE_MAINTENANCE_WEEK WHERE service_day >= (CURRENT_DATE - INTERVAL '7 days') GROUP BY maintenance_center, service_day;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, garment_type VARCHAR(30), sale_date DATE, revenue DECIMAL(10,2));
|
What is the total revenue generated from each garment type in the year 2022?
|
SELECT garment_type, YEAR(sale_date) AS year, SUM(revenue) AS total_revenue FROM sales WHERE YEAR(sale_date) = 2022 GROUP BY garment_type, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE economic_impact (location VARCHAR(50), impact FLOAT); INSERT INTO economic_impact (location, impact) VALUES ('Cairo, Egypt', 1200000), ('Marrakesh, Morocco', 1000000), ('Rio de Janeiro, Brazil', 800000), ('Buenos Aires, Argentina', 900000);
|
What is the total local economic impact of cultural heritage preservation in Africa and South America?
|
SELECT SUM(impact) as total_impact FROM economic_impact WHERE location LIKE '%Africa%' OR location LIKE '%South America%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OpenData (InitiativeID INT, InitiativeName TEXT, InitiativeCategory TEXT); INSERT INTO OpenData (InitiativeID, InitiativeName, InitiativeCategory) VALUES (1, 'Public Transport Data', 'Transportation'), (2, 'Crime Statistics', 'Public Safety');
|
What is the total number of open data initiatives by category?
|
SELECT InitiativeCategory, COUNT(*) FROM OpenData WHERE InitiativeStatus = 'open' GROUP BY InitiativeCategory;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), word_count INT, category VARCHAR(255)); INSERT INTO news (title, author, word_count, category) VALUES ('Sample News', 'Jane Smith', 500, 'Opinion');
|
What is the total number of articles in the 'opinion' category by 'Jane Smith'?
|
SELECT COUNT(*) FROM news WHERE category = 'Opinion' AND author = 'Jane Smith';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salmon_farm (farm_id INT, location VARCHAR(20), growth_rate FLOAT); INSERT INTO salmon_farm (farm_id, location, growth_rate) VALUES (1, 'Pacific Northwest', 12.5), (2, 'Alaska', 13.3), (3, 'Pacific Northwest', 12.8);
|
What is the average growth rate of salmon in farms located in the Pacific Northwest?
|
SELECT AVG(growth_rate) FROM salmon_farm WHERE location = 'Pacific Northwest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE destinations (id INT, name VARCHAR(255), sustainability_score INT); INSERT INTO destinations (id, name, sustainability_score) VALUES (1, 'Japan', 90), (2, 'Thailand', 85), (3, 'Vietnam', 80), (4, 'India', 75), (5, 'China', 70);
|
What are the top 3 sustainable destinations in Asia?
|
SELECT name FROM destinations WHERE country IN ('Asia') ORDER BY sustainability_score DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Registrations (RegistrationID INT, UserID INT, RegistrationDate DATETIME, Game VARCHAR(50)); CREATE TABLE Transactions (TransactionID INT, UserID INT, TransactionDate DATETIME, TransactionValue DECIMAL(10, 2), Game VARCHAR(50)); INSERT INTO Registrations (RegistrationID, UserID, RegistrationDate, Game) VALUES (1, 1, '2021-12-10', 'Sports'), (2, 2, '2022-02-25', 'Sports'); INSERT INTO Transactions (TransactionID, UserID, TransactionDate, TransactionValue, Game) VALUES (1, 1, '2022-01-01', 50.00, 'Sports');
|
What is the total transaction value for users who registered for 'Sports' games in the last year and made at least one transaction?
|
SELECT SUM(t.TransactionValue) FROM Transactions t INNER JOIN Registrations r ON t.UserID = r.UserID WHERE r.Game = 'Sports' AND r.RegistrationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND EXISTS (SELECT 1 FROM Transactions tx WHERE t.UserID = tx.UserID);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plots (id INT, size_ha FLOAT, type TEXT); INSERT INTO plots (id, size_ha, type) VALUES (1, 2.5, 'Urban'); INSERT INTO plots (id, size_ha, type) VALUES (2, 1.8, 'Agroforestry');
|
What is the minimum size (in hectares) of a plot in the 'plots' table, where the plot is used for agroforestry?
|
SELECT MIN(size_ha) FROM plots WHERE type = 'Agroforestry';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Building_Permits (permit_number INT, permit_type VARCHAR(50), completion_date DATE, state VARCHAR(50), is_leed_certified BOOLEAN); INSERT INTO Building_Permits VALUES (1234, 'High Rise', '2025-05-01', 'Florida', true);
|
List the names, types, and completion dates of all LEED-certified projects in Florida, ordered by completion date in ascending order.
|
SELECT permit_number, permit_type, completion_date FROM Building_Permits WHERE state = 'Florida' AND is_leed_certified = true ORDER BY completion_date ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, name VARCHAR(50)); INSERT INTO ports (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'); CREATE TABLE cargo_ships (id INT, name VARCHAR(50), port_id INT); INSERT INTO cargo_ships (id, name, port_id) VALUES (1, 'Cargo Ship A', 1), (2, 'Cargo Ship B', 2);
|
What are the names of all cargo ships that have visited port 'New York'?
|
SELECT DISTINCT name FROM cargo_ships WHERE port_id = (SELECT id FROM ports WHERE name = 'New York')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier_info (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainable_practices BOOLEAN); CREATE VIEW sustainable_suppliers AS SELECT * FROM supplier_info WHERE sustainable_practices = TRUE;
|
Select names of all sustainable suppliers
|
SELECT name FROM sustainable_suppliers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); CREATE TABLE Donations (DonationID INT, ProgramID INT, DonorID INT, Amount DECIMAL(10,2));
|
Calculate the average donation amount for each program, and the total number of donations for each program.
|
SELECT Programs.ProgramName, AVG(Donations.Amount) AS AvgDonation, COUNT(Donations.DonationID) AS TotalDonations FROM Programs JOIN Donations ON Programs.ProgramID = Donations.ProgramID GROUP BY Programs.ProgramName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student (id INT, name VARCHAR(50), program VARCHAR(50)); CREATE TABLE publication (id INT, title VARCHAR(100), journal_name VARCHAR(50), impact_factor DECIMAL(3,1));
|
What are the names of graduate students who have published in journals with impact factors above 5?
|
SELECT s.name FROM student s JOIN publication p ON s.id IN (SELECT student_id FROM grant WHERE title IN (SELECT title FROM publication WHERE impact_factor > 5));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ferry_trips (trip_id INT, region_id INT, trip_date DATE); INSERT INTO ferry_trips (trip_id, region_id, trip_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-02'), (3, 3, '2022-01-03'), (4, 2, '2022-01-04');
|
How many ferry trips were there in the 'southeast' region in January 2022?
|
SELECT COUNT(*) FROM ferry_trips ft WHERE ft.region_id = (SELECT region_id FROM regions WHERE region_name = 'southeast') AND ft.trip_date BETWEEN '2022-01-01' AND '2022-01-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ride_data (ride_id INT, ride_start_time TIMESTAMP, ride_end_time TIMESTAMP, vehicle_id INT, vehicle_type VARCHAR(10));
|
Find the number of trips per day for each unique vehicle_id and vehicle_type in ride_data.
|
SELECT vehicle_id, vehicle_type, EXTRACT(DAY FROM ride_start_time) AS ride_day, COUNT(*) AS trips_per_day FROM ride_data GROUP BY vehicle_id, vehicle_type, ride_day;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_customers (customer_id INT, city VARCHAR(20), download_speed FLOAT); INSERT INTO broadband_customers (customer_id, city, download_speed) VALUES (1, 'Tokyo', 300), (2, 'Tokyo', 400), (3, 'Osaka', 500);
|
What is the average broadband download speed for customers in the city of Tokyo?
|
SELECT AVG(download_speed) FROM broadband_customers WHERE city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), location VARCHAR(255), production_figures DECIMAL(10,2), date DATE); INSERT INTO wells (well_id, well_name, location, production_figures, date) VALUES (1, 'Well A', 'Gulf of Mexico', 12000.50, '2021-01-01'), (2, 'Well B', 'Gulf of Mexico', 15000.25, '2021-02-01'), (3, 'Well C', 'Gulf of Mexico', 20000.00, '2021-03-01');
|
What are the average production figures for wells in the Gulf of Mexico, grouped by month?
|
SELECT EXTRACT(MONTH FROM date) AS month, AVG(production_figures) AS avg_production FROM wells WHERE location = 'Gulf of Mexico' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE videos_edu (id INT, title VARCHAR(100), topic VARCHAR(50), views INT, platform VARCHAR(50), comments INT); INSERT INTO videos_edu (id, title, topic, views, platform, comments) VALUES (1, 'Video1', 'education', 5000, 'CNN', 100), (2, 'Video2', 'science', 7000, 'CNN', 150), (3, 'Video3', 'education', 6000, 'CNN', 120);
|
What is the number of comments for the top 5 most viewed videos on the topic "education" on the media platform "CNN"?
|
SELECT v.title, v.comments FROM videos_edu v WHERE v.topic = 'education' AND v.platform = 'CNN' ORDER BY views DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (department_id INT, department VARCHAR(20)); INSERT INTO departments (department_id, department) VALUES (1, 'Human Resources'), (2, 'Operations'), (3, 'Engineering'), (4, 'Management'); CREATE TABLE mine_workers (worker_id INT, department_id INT, mine_id INT); INSERT INTO mine_workers (worker_id, department_id, mine_id) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 2), (4, 3, 3); CREATE TABLE mines (mine_id INT, mine_type VARCHAR(20)); INSERT INTO mines (mine_id, mine_type) VALUES (1, 'Underground'), (2, 'Open-pit'), (3, 'Underground');
|
Show the number of workers in each department and the number of mines they work in, in the "departments", "mine_workers", and "mines" tables
|
SELECT d.department, m.mine_type, COUNT(mw.mine_id) as mine_count, COUNT(DISTINCT mw.worker_id) as worker_count FROM departments d JOIN mine_workers mw ON d.department_id = mw.department_id JOIN mines m ON mw.mine_id = m.mine_id GROUP BY d.department, m.mine_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GraduateStudents(StudentID INT, Gender VARCHAR(255), Department VARCHAR(255)); INSERT INTO GraduateStudents VALUES (1, 'Male', 'Electrical Engineering'); CREATE TABLE ConferencePresentations(PresentationID INT, StudentID INT, PresentationDate DATE); INSERT INTO ConferencePresentations VALUES (1, 1, '2021-01-01');
|
What is the total number of conference presentations by male graduate students in the Electrical Engineering department?
|
SELECT COUNT(ConferencePresentations.PresentationID) FROM GraduateStudents INNER JOIN ConferencePresentations ON GraduateStudents.StudentID = ConferencePresentations.StudentID WHERE GraduateStudents.Gender = 'Male' AND GraduateStudents.Department = 'Electrical Engineering';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WeatherEvents (id INT, vessel_id INT, event_type VARCHAR(50), latitude DECIMAL(9,6), longitude DECIMAL(9,6), time TIMESTAMP);
|
Which vessels encountered severe weather events in the Pacific Ocean in the last 6 months?
|
SELECT DISTINCT vessel_id FROM WeatherEvents WHERE event_type = 'Severe' AND time > NOW() - INTERVAL '6 months' AND latitude BETWEEN -90 AND 90 AND longitude BETWEEN 100 AND -170;
|
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.