context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE africa_scores (region TEXT, index_score INT); INSERT INTO africa_scores (region, index_score) VALUES ('Region1', 65), ('Region2', 75), ('Region3', 85), ('Region4', 95), ('Region5', 55); | What is the distribution of digital divide index scores by region in Africa? | SELECT region, index_score, COUNT(*) FROM africa_scores GROUP BY index_score ORDER BY index_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE DiversificationEfforts (id INT, effort_name TEXT, location TEXT, investment FLOAT); INSERT INTO DiversificationEfforts (id, effort_name, location, investment) VALUES (1, 'Renewable Energy', 'Sub-Saharan Africa', 1500000); INSERT INTO DiversificationEfforts (id, effort_name, location, investment) VALUES (2,... | Identify the economic diversification efforts in Sub-Saharan Africa with an investment of over 1 million USD. | SELECT effort_name, location FROM DiversificationEfforts WHERE investment > 1000000 AND location LIKE '%Sub-Saharan Africa%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists contract_negotiations;CREATE TABLE if not exists defense_contractor_negotiations(contractor text, partner text, negotiation_year integer);INSERT INTO defense_contractor_negotiations(contractor, partner, negotiation_year) VALUES('Lockheed Martin', 'Russia', 2018), ('Boeing', 'China', 2018), (... | Which defense contractors had contracts with Russia in 2018? | SELECT DISTINCT contractor FROM defense_contractor_negotiations WHERE partner = 'Russia' AND negotiation_year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (accom_id INT, name VARCHAR(50), continent VARCHAR(50), sustainability_rating INT); | Show the number of cultural heritage accommodations in each continent. | SELECT continent, COUNT(accom_id) AS num_cultural_heritage_accoms FROM accommodations WHERE sustainability_rating = 5 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_temperature (crop_name VARCHAR(255), avg_temperature FLOAT); INSERT INTO crop_temperature (crop_name, avg_temperature) VALUES ('Corn', 20.5), ('Soybean', 22.3), ('Wheat', 18.7); | What is the average temperature for each crop type in the 'crop_temperature' table? | SELECT crop_name, AVG(avg_temperature) as avg_temp FROM crop_temperature GROUP BY crop_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryPersonnel (branch TEXT, num_personnel INTEGER); INSERT INTO MilitaryPersonnel (branch, num_personnel) VALUES ('Army', 500000), ('Navy', 350000), ('AirForce', 300000), ('Marines', 200000); | What is the minimum number of military personnel in each branch of the military? | SELECT branch, MIN(num_personnel) FROM MilitaryPersonnel GROUP BY branch; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT); | Delete records with a quantity of zero from the Inventory table | DELETE FROM Inventory WHERE quantity = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE SUVs (id INT, name VARCHAR(255), safety_rating DECIMAL(3,2), release_year INT, country VARCHAR(50)); INSERT INTO SUVs (id, name, safety_rating, release_year, country) VALUES (1, 'Mahindra XUV500', 4.6, 2019, 'India'); INSERT INTO SUVs (id, name, safety_rating, release_year, country) VALUES (2, 'Tata Hexa',... | What is the maximum safety rating of sports utility vehicles (SUVs) in India in 2019? | SELECT MAX(safety_rating) FROM SUVs WHERE country = 'India' AND release_year = 2019 AND name IN ('Mahindra XUV500', 'Tata Hexa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE retail (id INT, union_member BOOLEAN); INSERT INTO retail (id, union_member) VALUES (1, TRUE), (2, FALSE); CREATE TABLE hospitality (id INT, union_member BOOLEAN); INSERT INTO hospitality (id, union_member) VALUES (1, TRUE), (2, TRUE); | What is the total number of union members in the retail and hospitality industries? | SELECT SUM(IF(union_member = TRUE, 1, 0)) FROM retail; SELECT SUM(IF(union_member = TRUE, 1, 0)) FROM hospitality; SELECT SUM(result) FROM (SELECT SUM(IF(union_member = TRUE, 1, 0)) AS result FROM retail) AS retail_result CROSS JOIN (SELECT SUM(IF(union_member = TRUE, 1, 0)) AS result FROM hospitality) AS hospitality_r... | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (item_id INT, quantity INT, unit_price DECIMAL(5,2)); INSERT INTO inventory (item_id, quantity, unit_price) VALUES (1, 10, 12.99), (2, 20, 7.50), (3, 30, 9.99), (4, 40, 15.49), (5, 50, 8.99); CREATE TABLE orders (order_id INT, item_id INT, order_date DATE, restaurant_id INT); INSERT INTO orders (... | Identify the most popular vegan dish in the West region. | SELECT m.name, SUM(i.quantity) as total_quantity FROM inventory i JOIN orders o ON i.item_id = o.item_id JOIN menu_items m ON i.item_id = m.item_id JOIN restaurants r ON o.restaurant_id = r.restaurant_id WHERE m.is_vegan = true GROUP BY i.item_id ORDER BY total_quantity DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_bikes (bike_id INT, bike_type VARCHAR(20)); INSERT INTO public_bikes (bike_id, bike_type) VALUES (1, 'Standard'), (2, 'Electric'), (3, 'Standard'), (4, 'Standard'), (5, 'Electric'); | What is the total number of bicycles in public bike-sharing programs in Tokyo? | SELECT COUNT(*) as total_bikes FROM public_bikes WHERE bike_type IN ('Standard', 'Electric'); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (id INT, provider_id INT, provider_type VARCHAR(50), location VARCHAR(100), population INT); INSERT INTO healthcare_providers (id, provider_id, provider_type, location, population) VALUES (1, 501, 'Doctor', 'Nairobi, Kenya', 500000); INSERT INTO healthcare_providers (id, provider_id, p... | Find the number of healthcare providers per 100,000 people in Kenya. | SELECT location, COUNT(*) * 100000.0 / SUM(population) FROM healthcare_providers WHERE location LIKE '%Kenya' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE children_under_5 (id INT PRIMARY KEY, country VARCHAR(50), unvaccinated_children INT); INSERT INTO children_under_5 (id, country, unvaccinated_children) VALUES (1, 'Afghanistan', 500000); INSERT INTO children_under_5 (id, country, unvaccinated_children) VALUES (2, 'Brazil', 250000); | Which countries have the most unvaccinated children under 5 in the children_under_5 table? | SELECT country, SUM(unvaccinated_children) as total_unvaccinated_children FROM children_under_5 GROUP BY country ORDER BY total_unvaccinated_children DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), year INT, operations INT); INSERT INTO peacekeeping_operations (id, country, year, operations) VALUES (1, 'Brazil', 2019, 10), (2, 'Brazil', 2020, 15), (3, 'China', 2019, 12), (4, 'China', 2020, 25), (5, 'Canada', 2019, 18), (6, 'Canada', 2020, 20); | What is the number of peacekeeping operations conducted by each country in 2019 and 2020? | SELECT country, year, SUM(operations) as total_operations FROM peacekeeping_operations WHERE year IN (2019, 2020) GROUP BY country, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE impact_investments (id INT, region VARCHAR(20), investment_year INT, investment_amount FLOAT); INSERT INTO impact_investments (id, region, investment_year, investment_amount) VALUES (1, 'Asia', 2020, 150000), (2, 'Africa', 2019, 120000), (3, 'Asia', 2020, 180000); | Delete all impact investments in the 'Africa' region. | DELETE FROM impact_investments WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, ip_address VARCHAR(15), activity VARCHAR(20)); | Which external IP addresses have been associated with suspicious activity in the last month, according to the threat intelligence database? | SELECT ip_address FROM threat_intelligence WHERE activity = 'suspicious' AND timestamp >= NOW() - INTERVAL 1 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(255)); INSERT INTO ports (id, name) VALUES (1, 'Japan'), (2, 'San Francisco'); CREATE TABLE vessel_movements (id INT, vessel_id INT, departure_port_id INT, arrival_port_id INT, speed DECIMAL(5,2), date DATE); INSERT INTO vessel_movements (id, vessel_id, departure_port_id, arriva... | What is the average speed of vessels arriving from Japan to San Francisco? | SELECT AVG(speed) FROM vessel_movements WHERE departure_port_id = (SELECT id FROM ports WHERE name = 'Japan') AND arrival_port_id = (SELECT id FROM ports WHERE name = 'San Francisco'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (DepartmentID INT, DepartmentName VARCHAR(255)); CREATE TABLE Programs (ProgramID INT, DepartmentID INT, ProgramName VARCHAR(255)); CREATE TABLE Budget (BudgetID INT, DepartmentID INT, Amount DECIMAL(10,2), BudgetDate DATE); CREATE TABLE ProgramOutcomes (ProgramID INT, ProgramOutcomeDate DATE); | What is the total budget for each department that has a program outcome in 2021? | SELECT Departments.DepartmentID, Departments.DepartmentName, SUM(Budget.Amount) as TotalBudget FROM Budget INNER JOIN Departments ON Budget.DepartmentID = Departments.DepartmentID INNER JOIN Programs ON Departments.DepartmentID = Programs.DepartmentID INNER JOIN ProgramOutcomes ON Programs.ProgramID = ProgramOutcomes.P... | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkplaceSafety (union_id INT, year INT, incidents INT); CREATE TABLE Unions (union_id INT, industry TEXT); | How many workplace incidents were reported in 'Construction' unions in 2021? | SELECT SUM(incidents) FROM WorkplaceSafety INNER JOIN Unions ON WorkplaceSafety.union_id = Unions.union_id WHERE Unions.industry = 'Construction' AND WorkplaceSafety.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, Name VARCHAR(50), Country VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO Events (EventID, Name, Country, StartDate, EndDate) VALUES (1, 'Evo', 'USA', '2023-08-04', '2023-08-06'); INSERT INTO Events (EventID, Name, Country, StartDate, EndDate) VALUES (2, 'DreamHack', 'Sweden', ... | Which eSports events are happening in the USA? | SELECT * FROM Events WHERE Country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteInfo (Id INT, Agency VARCHAR(50), Name VARCHAR(50), LaunchYear INT); INSERT INTO SatelliteInfo (Id, Agency, Name, LaunchYear) VALUES (1, 'NASA', 'Explorer 1', 1958), (2, 'NASA', 'TIROS-1', 1960); | Provide the names and deployment years for all satellites launched by NASA. | SELECT Agency, Name FROM SatelliteInfo WHERE Agency = 'NASA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT, avg_mental_health_score FLOAT); INSERT INTO districts (district_id, district_name, avg_mental_health_score) VALUES (1, 'Downtown', 75.2), (2, 'Uptown', 68.9), (3, 'Midtown', 82.1); | What is the average mental health score of students in each district, only showing districts with an average score below 70? | SELECT district_name, AVG(avg_mental_health_score) as avg_score FROM districts GROUP BY district_name HAVING AVG(avg_mental_health_score) < 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingFacilities (facility_id INT, country VARCHAR(50), type VARCHAR(50)); | How many plastic waste recycling facilities are there in China and Indonesia? | SELECT COUNT(*) FROM RecyclingFacilities WHERE country IN ('China', 'Indonesia') AND type = 'plastic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT PRIMARY KEY, species VARCHAR(30), name VARCHAR(20), population INT); | Delete all records from the 'animal_population' table where the 'population' is 0 | DELETE FROM animal_population WHERE population = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (ID INT, Level TEXT); INSERT INTO CulturalCompetency (ID, Level) VALUES (1, 'Beginner'); INSERT INTO CulturalCompetency (ID, Level) VALUES (2, 'Intermediate'); INSERT INTO CulturalCompetency (ID, Level) VALUES (3, 'Advanced'); CREATE TABLE MentalHealthAppointment (AppointmentID INT, Cult... | List the number of mental health appointments for each cultural competency level, in descending order. | SELECT CulturalCompetencyID, COUNT(AppointmentID) as NumAppointments FROM MentalHealthAppointment GROUP BY CulturalCompetencyID ORDER BY NumAppointments DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicle_stats (country VARCHAR(50), adoption_rate DECIMAL(3,1), year INT, make VARCHAR(50)); | What is the distribution of electric vehicle adoption rates by make? | SELECT make, AVG(adoption_rate) FROM electric_vehicle_stats GROUP BY make; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_data (country VARCHAR(255), seafood_weight FLOAT, year INT); CREATE TABLE country (id INT, name VARCHAR(255), continent VARCHAR(255)); | Identify the top 3 countries with the highest seafood consumption by weight in the past year. | SELECT c.country, SUM(country_data.seafood_weight) as total_weight, RANK() OVER (ORDER BY SUM(country_data.seafood_weight) DESC) as rank FROM country_data JOIN country ON c.country = country_data.country WHERE country_data.year = EXTRACT(YEAR FROM CURRENT_DATE) - 1 GROUP BY c.country ORDER BY total_weight DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name TEXT); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, is_fraudulent BOOLEAN); | List all customers who have made fraudulent transactions in Q4 2022. | SELECT c.customer_id, c.customer_name FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date BETWEEN '2022-10-01' AND '2022-12-31' AND t.is_fraudulent = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tech_Social_Good (region VARCHAR(50), gender VARCHAR(10), participants INT); INSERT INTO Tech_Social_Good (region, gender, participants) VALUES ('Africa', 'Female', 30000), ('Asia', 'Female', 45000), ('South America', 'Female', 25000), ('Europe', 'Male', 55000), ('North America', 'Female', 60000); | Which regions have more than 50% female representation in technology for social good initiatives? | SELECT region, CASE WHEN SUM(CASE WHEN gender = 'Female' THEN participants ELSE 0 END) / SUM(participants) > 0.5 THEN 'Yes' ELSE 'No' END as high_female_representation FROM Tech_Social_Good GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), launch_date DATE); INSERT INTO space_missions (id, mission_name, launch_date) VALUES (1, 'Apollo 11', '1969-07-16'), (2, 'Mars Rover', '2004-01-04'), (3, 'Apollo 13', '1970-04-11'), (4, 'Cassini', '1997-10-15'); | How many space missions were launched per year? | SELECT EXTRACT(YEAR FROM launch_date) AS Year, COUNT(*) OVER (PARTITION BY EXTRACT(YEAR FROM launch_date)) as MissionsPerYear FROM space_missions; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id INT, location VARCHAR(10), item VARCHAR(10), quantity INT); INSERT INTO warehouses (id, location, item, quantity) VALUES (1, 'NY', 'A101', 200), (2, 'NJ', 'A101', 300), (3, 'CA', 'B203', 150), (4, 'NY', 'C304', 50); | What is the total quantity of items in warehouse 2 and 3? | SELECT SUM(quantity) FROM warehouses WHERE id IN (2, 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEvents (id INT, location VARCHAR(255), start_date DATE, end_date DATE); | How many community events were held in New York between 2018 and 2020? | SELECT COUNT(*) FROM CommunityEvents WHERE location = 'New York' AND start_date BETWEEN '2018-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_stations (station_id INT, station_name TEXT); INSERT INTO marine_life_research_stations (station_id, station_name) VALUES (1, 'Station A'), (2, 'Station B'), (3, 'Station C'); CREATE TABLE maritime_law_compliance_initiatives (initiative_id INT, initiative_name TEXT, station_id INT); IN... | Get the names of all marine life research stations that are not part of any maritime law compliance initiatives | SELECT m.station_name FROM marine_life_research_stations m LEFT JOIN maritime_law_compliance_initiatives mlci ON m.station_id = mlci.station_id WHERE mlci.initiative_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, price DECIMAL, CO2_emission INT, fairly_traded BOOLEAN); INSERT INTO products (product_id, product_name, price, CO2_emission, fairly_traded) VALUES (1, 'ProductA', 25.99, 450, true), (2, 'ProductB', 18.49, 600, false), (3, 'ProductC', 29.99, 350, true); | What is the maximum CO2 emission for fairly traded products? | SELECT MAX(CO2_emission) FROM products WHERE fairly_traded = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name TEXT, race TEXT); INSERT INTO founders (id, name, race) VALUES (1, 'Charles', 'African American'), (2, 'Dana', 'Latinx'), (3, 'Eli', 'Asian'), (4, 'Fiona', 'Caucasian'); CREATE TABLE startups (id INT, name TEXT, funding FLOAT); INSERT INTO startups (id, name, funding) VALUES (1, 'Del... | What is the total funding raised by startups founded by underrepresented racial or ethnic groups? | SELECT SUM(startups.funding) FROM startups INNER JOIN underrepresented_founders ON startups.id = underrepresented_founders.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE tribal_area_3 (farmer_id TEXT, indigenous BOOLEAN, gender TEXT, community_food BOOLEAN); INSERT INTO tribal_area_3 (farmer_id, indigenous, gender, community_food) VALUES ('i010', true, 'female', true), ('i011', true, 'male', false), ('i012', false, 'non-binary', true), ('i013', false, 'male', false); | How many indigenous women farmers in 'tribal_area_3' produce food for their community? | SELECT COUNT(*) FROM tribal_area_3 WHERE indigenous = true AND gender = 'female' AND community_food = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryName VARCHAR(50)); CREATE TABLE JazzAlbums (AlbumID INT, CountryName VARCHAR(50)); INSERT INTO Countries VALUES ('USA', 'Canada', 'France', 'UK', 'Japan'); INSERT INTO JazzAlbums VALUES (1, 'USA'), (2, 'USA'), (3, 'Canada'), (4, 'France'), (5, 'Japan'), (6, 'USA'); | What are the top 3 countries with the most jazz albums released? | SELECT CountryName, COUNT(*) as JazzAlbumCount FROM JazzAlbums JOIN Countries ON JazzAlbums.CountryName = Countries.CountryName GROUP BY CountryName ORDER BY JazzAlbumCount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (Id INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), LastLogin DATETIME); | Delete records of users who have not logged in for the past 6 months from the "Members" table | DELETE FROM Members WHERE LastLogin < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature (date DATE, location TEXT, temperature FLOAT); CREATE TABLE sea_level_anomalies (date DATE, location TEXT, anomaly FLOAT); | What is the average temperature of the ocean surface in each month for the past year, and the corresponding sea level anomalies? | SELECT MONTH(temperature.date) AS month, AVG(temperature.temperature) AS avg_temperature, sea_level_anomalies.anomaly FROM temperature INNER JOIN sea_level_anomalies ON temperature.date = sea_level_anomalies.date GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerability_assessments (id INT, department VARCHAR(50), vulnerability_count INT); | What is the total number of vulnerabilities found in the 'vulnerability_assessments' table for each department? | SELECT department, SUM(vulnerability_count) as total_vulnerabilities FROM vulnerability_assessments GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (ID INT PRIMARY KEY, Country VARCHAR(50), AccommodationType VARCHAR(50), Quantity INT); INSERT INTO Accommodations (ID, Country, AccommodationType, Quantity) VALUES (1, 'USA', 'Sign Language Interpretation', 300), (2, 'Canada', 'Wheelchair Ramp', 250), (3, 'Mexico', 'Assistive Listening Devi... | What is the total number of accommodations provided by type, across all countries? | SELECT AccommodationType, SUM(Quantity) as Total FROM Accommodations GROUP BY AccommodationType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 75000.00), (2, 'IT', 80000.00), (3, 'HR', 60000.00); | What is the average salary of employees in the IT department? | SELECT AVG(Salary) FROM Employees WHERE Department = 'IT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_div (id INT, name VARCHAR(255), region VARCHAR(255), status VARCHAR(255)); INSERT INTO economic_div (id, name, region, status) VALUES (1, 'Sustainable Tourism', 'Caribbean', 'completed'); | Update the status of completed economic diversification projects in the Caribbean to 'closed'. | UPDATE economic_div SET status = 'closed' WHERE region = 'Caribbean' AND status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (year INT, forest_type VARCHAR(255), volume INT); INSERT INTO timber_production (year, forest_type, volume) VALUES (2018, 'Coniferous', 300), (2019, 'Coniferous', 350), (2020, 'Coniferous', 400), (2018, 'Deciduous', 200), (2019, 'Deciduous', 250), (2020, 'Deciduous', 300); | What is the average volume of timber produced annually for the 'Coniferous' forest type? | SELECT AVG(volume) FROM timber_production WHERE forest_type = 'Coniferous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accidents (accident_id INT, aircraft_model VARCHAR(50), num_injuries INT); INSERT INTO accidents (accident_id, aircraft_model, num_injuries) VALUES (1, 'Boeing 747', 50), (2, 'Airbus A320', 20), (3, 'Boeing 777', 30); | What is the safety record of the Airbus A320? | SELECT AVG(num_injuries) FROM accidents WHERE aircraft_model = 'Airbus A320'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, company_name VARCHAR(50), founder_1_gender VARCHAR(10), founder_2_gender VARCHAR(10)); INSERT INTO companies VALUES (1, 'Gamma Ltd', 'Female', 'Male'); INSERT INTO companies VALUES (2, 'Delta Co', 'Non-binary', NULL); | List all companies with diverse founding teams (more than one gender represented) | SELECT company_name FROM companies WHERE founder_1_gender IS NOT NULL AND founder_2_gender IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE event_attendees (id INT, name VARCHAR(100), age INT, city VARCHAR(50), event_date DATE); INSERT INTO event_attendees (id, name, age, city, event_date) VALUES (1, 'John Doe', 30, 'New York', '2021-06-01'); INSERT INTO event_attendees (id, name, age, city, event_date) VALUES (2, 'Jane Smith', 45, 'New York',... | What is the average age of visitors who attended events in New York in 2021? | SELECT AVG(age) FROM event_attendees WHERE city = 'New York' AND YEAR(event_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT); INSERT INTO mobile_customers (customer_id, data_usage) VALUES (1, 12.5), (2, 3.2), (3, 7.8); | What is the percentage of mobile customers who have used more than 10GB of data in a month? | SELECT (COUNT(*) FILTER (WHERE data_usage > 10)) * 100.0 / COUNT(*) FROM mobile_customers; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, well_name VARCHAR(50), year INT, production_volume INT); INSERT INTO production (id, well_name, year, production_volume) VALUES (1, 'Well X', 2019, 1000); INSERT INTO production (id, well_name, year, production_volume) VALUES (2, 'Well Y', 2020, 1500); INSERT INTO production (id, well_n... | Find the well with the highest production volume in 2019 | SELECT well_name, MAX(production_volume) FROM production WHERE year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris_tiny (id INT, mass FLOAT, size FLOAT); INSERT INTO space_debris_tiny (id, mass, size) VALUES (1, 0.01, 0.1), (2, 0.02, 0.2), (3, 0.03, 0.3), (4, 0.04, 0.4), (5, 0.05, 0.5); | What is the total mass of space debris smaller than 1 cm? | SELECT SUM(mass) FROM space_debris_tiny WHERE size < 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(100), department VARCHAR(50), gender VARCHAR(50), grant_amount DECIMAL(10,2)); INSERT INTO faculty (id, name, department, gender, grant_amount) VALUES (1, 'Kavi', 'Education', 'Non-binary', 120000.00); | What is the average number of research grants awarded to non-binary faculty members in the College of Education? | SELECT AVG(grant_amount) FROM faculty WHERE department = 'Education' AND gender = 'Non-binary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, years_of_experience INT); CREATE TABLE cases (case_id INT, attorney_id INT, outcome TEXT); | What is the success rate of cases handled by attorneys with more than 10 years of experience? | SELECT AVG(CASE WHEN cases.outcome = 'Success' THEN 1.0 ELSE 0.0 END) AS success_rate FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.years_of_experience > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, founder_ethnicity TEXT); CREATE TABLE investments (id INT, startup_id INT, funding_amount INT); | List the names and total funding of startups founded by individuals who identify as Latinx or Hispanic in the technology sector. | SELECT startups.name, SUM(investments.funding_amount) FROM startups INNER JOIN investments ON startups.id = investments.startup_id WHERE startups.founder_ethnicity IN ('Latinx', 'Hispanic') AND startups.name IN (SELECT name FROM startups WHERE industry = 'Technology'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, first_name VARCHAR, last_name VARCHAR, email VARCHAR, phone_number VARCHAR, date_joined DATE); INSERT INTO Volunteers (id, first_name, last_name, email, phone_number, date_joined) VALUES (1, 'John', 'Doe', 'john.doe@email.com', '555-123-4567', '2021-05-01'), (2, 'Jane', 'Doe', 'jane.doe... | Delete a volunteer's record, given their ID | DELETE FROM Volunteers WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE threats (id INT, category VARCHAR(50), ip_address VARCHAR(50), threat_date DATE); INSERT INTO threats (id, category, ip_address, threat_date) VALUES (1, 'Malware', '192.168.0.1', '2022-01-01'), (2, 'Phishing', '192.168.0.2', '2022-01-03'), (3, 'Ransomware', '192.168.0.3', '2022-01-02'); | How many unique IP addresses have been associated with each threat category in the last week? | SELECT category, COUNT(DISTINCT ip_address) as unique_ips FROM threats WHERE threat_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Baltic_Maritime_Law (law_name TEXT, nox_limit INT); INSERT INTO Baltic_Maritime_Law (law_name, nox_limit) VALUES ('Baltic Sea Emission Control Area', 8.3); | What is the minimum legal limit of nitrogen oxide emissions for ships in the Baltic Sea? | SELECT nox_limit FROM Baltic_Maritime_Law WHERE law_name = 'Baltic Sea Emission Control Area'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Veteran_Employment (employment_id INT, industry TEXT, state TEXT, employment_rate FLOAT, quarter INT, year INT); INSERT INTO Veteran_Employment (employment_id, industry, state, employment_rate, quarter, year) VALUES (1, 'Defense', 'New York', 0.12, 2, 2021); | What is the employment rate for veterans in the defense industry in New York in Q2 2021? | SELECT employment_rate FROM Veteran_Employment WHERE industry = 'Defense' AND state = 'New York' AND quarter = 2 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE tx_permits (id INT, permit_id VARCHAR(50), permit_value FLOAT, permit_date DATE, city VARCHAR(50), state VARCHAR(50)); INSERT INTO tx_permits (id, permit_id, permit_value, permit_date, city, state) VALUES (1, '123456', 1000000, '2021-07-01', 'Dallas', 'TX'), (2, '789101', 1500000, '2021-06-15', 'Houston', ... | What is the total number of construction permits issued in Texas in the past 12 months, ranked by the permit value? | SELECT permit_id, permit_value, RANK() OVER (ORDER BY permit_value DESC) as rank FROM tx_permits WHERE state = 'TX' AND permit_date >= DATEADD(YEAR, -1, CURRENT_DATE) GROUP BY permit_id, permit_value ORDER BY permit_value DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (customer_name VARCHAR(255), order_date DATE); | Insert new record into 'orders' table for customer 'John Doe' and order_date '2022-03-21' | INSERT INTO orders (customer_name, order_date) VALUES ('John Doe', '2022-03-21'); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, volunteer_name VARCHAR(50), city VARCHAR(50), hours DECIMAL(5,2)); | Show the number of volunteer hours contributed by city in the 'volunteer_hours' table. | SELECT city, COUNT(*) FROM volunteer_hours GROUP BY city; | 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, donation_date DATE, amount DECIMAL(10, 2)); INSERT INTO donations (id, program_id, donation_date, amount) VALUES (1, 1, '2022-01-... | What is the average donation amount per program, per quarter? | SELECT program_id, DATE_TRUNC('quarter', donation_date) AS quarter, AVG(amount) OVER (PARTITION BY program_id, quarter) AS avg_donation_amount FROM donations; | gretelai_synthetic_text_to_sql |
CREATE TABLE institution_lifelong_learning (institution_id INT, course_count INT); | What is the total number of lifelong learning courses offered by each institution? | SELECT institution_id, SUM(course_count) as total_courses FROM institution_lifelong_learning GROUP BY institution_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_comments (comment_id INT, comment_text TEXT, meeting_id INT); INSERT INTO public_comments (comment_id, comment_text, meeting_id) VALUES (1, 'Comment A', 1), (2, 'Comment B', 1), (3, 'Comment C', 2); CREATE TABLE public_meetings (meeting_id INT, meeting_name VARCHAR(255), state VARCHAR(255), region V... | What is the average number of public comments received per public meeting in the West? | SELECT AVG(cnt) FROM (SELECT meeting_id, COUNT(*) AS cnt FROM public_comments GROUP BY meeting_id) AS subquery JOIN public_meetings ON subquery.meeting_id = public_meetings.meeting_id WHERE region = 'West'; | gretelai_synthetic_text_to_sql |
CREATE TABLE international_roaming_usage (customer_id INT, data_usage FLOAT, country VARCHAR(50)); INSERT INTO international_roaming_usage (customer_id, data_usage, country) VALUES (1, 2000, 'USA'), (2, 1500, 'Mexico'), (3, 3000, 'Canada'); | What is the average monthly usage of mobile customers who have used international roaming, segmented by country? | SELECT country, AVG(data_usage) AS avg_data_usage FROM international_roaming_usage WHERE used = TRUE GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidity (ocean VARCHAR(255), level FLOAT); INSERT INTO ocean_acidity (ocean, level) VALUES ('Arctic Ocean', 7.8), ('Antarctic Ocean', 8.1); | What is the average ocean acidity level in the Arctic Ocean? | SELECT AVG(level) FROM ocean_acidity WHERE ocean = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (program_id INT, year INT, victims_served INT); INSERT INTO restorative_justice_programs (program_id, year, victims_served) VALUES (1, 2018, 300), (2, 2019, 400), (3, 2020, 550), (4, 2021, 600); | Find the number of victims served by restorative justice programs in 2020 | SELECT SUM(victims_served) FROM restorative_justice_programs WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonatedAmount decimal(10,2)); INSERT INTO Donors (DonorID, DonorName, DonatedAmount) VALUES (1, 'World Health Organization', 1200.00), (2, 'Gates Philanthropy Partners', 1800.00); CREATE TABLE PandemicRelief (CampaignID int, DonorID int, PandemicType varchar(50),... | What is the total number of medical supplies donated by each organization for the COVID-19 pandemic? | SELECT DonorName, SUM(DonatedAmount) as TotalDonated FROM Donors INNER JOIN PandemicRelief ON Donors.DonorID = PandemicRelief.DonorID WHERE PandemicType = 'COVID-19' GROUP BY DonorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE Movies (id INT, title VARCHAR(255), country VARCHAR(255), actor VARCHAR(255)); INSERT INTO Movies (id, title, country, actor) VALUES (1, 'Movie1', 'USA', 'Actor1'), (2, 'Movie2', 'Canada', 'Actor2'), (3, 'Movie3', 'Mexico', 'Actor3'), (4, 'Movie4', 'USA', 'Actor1'), (5, 'Movie5', 'USA', 'Actor4'); | Who are the top 5 actors by number of movies in the USA? | SELECT actor, COUNT(*) as num_movies FROM Movies WHERE country = 'USA' GROUP BY actor ORDER BY num_movies DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_education_budgets (city varchar(50), year int, budget int); INSERT INTO city_education_budgets (city, year, budget) VALUES ('Los Angeles', 2025, 20000000), ('Los Angeles', 2025, 10000000), ('San Diego', 2025, 15000000), ('San Diego', 2025, 5000000), ('San Jose', 2025, 25000000), ('San Jose', 2025, 700... | What is the total budget allocated for education in the cities of Los Angeles, San Diego, and San Jose for the year 2025? | SELECT SUM(budget) FROM city_education_budgets WHERE city IN ('Los Angeles', 'San Diego', 'San Jose') AND year = 2025; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (inventory_id INT, ingredient_id INT, quantity FLOAT, reorder_threshold FLOAT); | What is the total quantity of each ingredient used in the last week? | SELECT i.ingredient_id, i.ingredient_name, SUM(quantity) as total_quantity FROM inventory i JOIN (SELECT ingredient_id, ingredient_name FROM ingredients WHERE date(created_at) >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK)) i2 ON i.ingredient_id = i2.ingredient_id GROUP BY i.ingredient_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (id INT, project_name VARCHAR(50), project_type VARCHAR(20), state VARCHAR(20)); INSERT INTO building_permits (id, project_name, project_type, state) VALUES (1, 'Green Building', 'Sustainable', 'Oregon'); INSERT INTO building_permits (id, project_name, project_type, state) VALUES (2, 'Sola... | List all building permits issued for sustainable projects in the state of Oregon. | SELECT * FROM building_permits WHERE project_type = 'Sustainable' AND state = 'Oregon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftMissions(ID INT, SpacecraftName VARCHAR(50), MissionID INT); | Find the total number of missions for each spacecraft | SELECT SpacecraftName, COUNT(DISTINCT MissionID) FROM SpacecraftMissions GROUP BY SpacecraftName; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (name TEXT, production_location TEXT, industry TEXT, circular_economy BOOLEAN); INSERT INTO factories (name, production_location, industry, circular_economy) VALUES ('ABC Electronics', 'San Francisco', 'Electronics', TRUE), ('XYZ Robotics', 'Tokyo', 'Robotics', FALSE); | What are the names and production locations of factories that produce electronics and have implemented circular economy principles? | SELECT name, production_location FROM factories WHERE industry = 'Electronics' AND circular_economy = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicle_stats (country VARCHAR(50), adoption_rate DECIMAL(3,1), year INT); | What is the adoption rate of electric vehicles in Asia? | SELECT adoption_rate FROM electric_vehicle_stats WHERE country = 'China' OR country = 'Japan' AND year = 2025; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (ID INT, Age INT, Disease VARCHAR(20), State VARCHAR(20)); INSERT INTO Patients (ID, Age, Disease, State) VALUES (1, 30, 'HIV', 'California'), (2, 35, 'HIV', 'New York'); | What is the minimum age of patients diagnosed with HIV in each state? | SELECT State, MIN(Age) AS MinAge FROM Patients WHERE Disease = 'HIV' GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tank6 (species VARCHAR(20), individual_id INT, growth_rate FLOAT); INSERT INTO Tank6 (species, individual_id, growth_rate) VALUES ('Tilapia', 1, 0.025), ('Tilapia', 2, 0.015), ('Cod', 1, 0.02), ('Cod', 2, 0.03); | Delete all records for Tank6 that have a growth rate of less than 0.02 kg/day. | DELETE FROM Tank6 WHERE growth_rate < 0.02; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID int, FirstName varchar(20), LastName varchar(20), Age int, Gender varchar(10), Grade int); | Update the 'Age' field for a student in the 'Students' table | UPDATE Students SET Age = 17 WHERE StudentID = 1234; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_sessions (id INT, trainer VARCHAR(255), country VARCHAR(255), sessions_conducted INT); INSERT INTO training_sessions (id, trainer, country, sessions_conducted) VALUES ('1', 'Rajan', 'Nepal', '5'), ('2', 'Kamala', 'Nepal', '4'), ('3', 'Tariq', 'Bangladesh', '6'), ('4', 'Nargis', 'Bangladesh', '7'),... | What is the total number of disaster response training sessions conducted in Nepal and Bangladesh, grouped by trainer? | SELECT trainer, SUM(sessions_conducted) as total_sessions FROM training_sessions WHERE country IN ('Nepal', 'Bangladesh') GROUP BY trainer; | gretelai_synthetic_text_to_sql |
CREATE TABLE world_heritage_sites (site_id INT, site_name VARCHAR(100), country VARCHAR(100), is_unesco_site BOOLEAN); INSERT INTO world_heritage_sites (site_id, site_name, country, is_unesco_site) VALUES (1, 'Taj Mahal', 'India', true); INSERT INTO world_heritage_sites (site_id, site_name, country, is_unesco_site) VAL... | How many UNESCO World Heritage sites are in Brazil? | SELECT COUNT(*) FROM world_heritage_sites WHERE country = 'Brazil' AND is_unesco_site = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (station_id INT, station_type VARCHAR(20)); INSERT INTO charging_stations (station_id, station_type) VALUES (1, 'Level 1'), (2, 'Level 2'), (3, 'Level 3'), (4, 'Level 2'), (5, 'Level 2'); | What is the total number of electric vehicle charging stations in Los Angeles? | SELECT COUNT(*) as num_stations FROM charging_stations WHERE station_type IN ('Level 1', 'Level 2', 'Level 3'); | gretelai_synthetic_text_to_sql |
CREATE TABLE newspapers (id INT, name VARCHAR(255), country VARCHAR(255));CREATE TABLE readership (id INT, newspaper_id INT, year INT, country VARCHAR(255)); INSERT INTO newspapers (id, name, country) VALUES (1, 'New York Times', 'USA'), (2, 'Le Monde', 'France'); INSERT INTO readership (id, newspaper_id, year, country... | Which countries had the highest and lowest readership in 2021? | SELECT readership.country, COUNT(*) as readership_count FROM readership GROUP BY readership.country ORDER BY readership_count DESC LIMIT 1; SELECT readership.country, COUNT(*) as readership_count FROM readership GROUP BY readership.country ORDER BY readership_count LIMIT 1 OFFSET 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousDrivingResearch (ID INT, Lab VARCHAR(255), Year INT, NumPapers INT); INSERT INTO AutonomousDrivingResearch (ID, Lab, Year, NumPapers) VALUES (1, 'SmartLabs', 2019, 15), (2, 'SmartLabs', 2020, 25), (3, 'RoboLabs', 2020, 18); | How many autonomous driving research papers were published by 'SmartLabs' in 2020? | SELECT NumPapers FROM AutonomousDrivingResearch WHERE Lab = 'SmartLabs' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_conditions (id INT, location VARCHAR(50), temperature DECIMAL(5,2), humidity DECIMAL(5,2), ph DECIMAL(5,2), timestamp TIMESTAMP); INSERT INTO soil_conditions (id, location, temperature, humidity, ph, timestamp) VALUES (1, 'Field7', 26.5, 55.0, 6.8, '2022-03-06 15:00:00'); | List the distinct pH values for fields with temperatures above 25°C and humidity below 60%. | SELECT DISTINCT ph FROM soil_conditions WHERE temperature > 25 AND humidity < 60; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_courses(course_id INT, course_name VARCHAR(100)); INSERT INTO training_courses VALUES (1, 'SQL Fundamentals'), (2, 'Python Programming'), (3, 'Data Analysis'); | List all training courses and the number of employees who have completed each one | SELECT c.course_name, COUNT(tr.emp_id) as num_completions FROM training_courses c JOIN training_records tr ON c.course_id = tr.course_id GROUP BY c.course_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkplaceDisputes (State TEXT, Disputes INT); INSERT INTO WorkplaceDisputes (State, Disputes) VALUES ('California', 150), ('Texas', 100), ('New York', 200), ('Florida', 50); | List the states with the most and fewest number of workplaces that have experienced labor disputes in the past year. | SELECT State, Disputes FROM WorkplaceDisputes WHERE Disputes = (SELECT MAX(Disputes) FROM WorkplaceDisputes) OR Disputes = (SELECT MIN(Disputes) FROM WorkplaceDisputes); | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), country VARCHAR(50), age INT); | What is the average age of fans by country? | SELECT f.country, AVG(f.age) as avg_age FROM fans f GROUP BY f.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (id INT, plant_id INT, incident_date DATE, report_type VARCHAR(255)); CREATE TABLE plants (id INT, num_employees INT, region VARCHAR(255)); | How many safety incidents were reported in North America in the last 6 months, for manufacturing plants with over 500 employees? | SELECT COUNT(*) FROM safety_incidents JOIN plants ON safety_incidents.plant_id = plants.id WHERE plants.region = 'North America' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND num_employees > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (subscriber_id INT, subscription_type VARCHAR(10), data_usage FLOAT, data_limit FLOAT, usage_date DATE); INSERT INTO subscribers (subscriber_id, subscription_type, data_usage, data_limit, usage_date) VALUES (1, 'postpaid', 3.5, 2.0, '2022-03-01'), (2, 'prepaid', 2.0, 1.5, '2022-03-01'), (3, 'po... | Identify mobile subscribers who have exceeded their data usage limit in the current month, for each subscription type, ordered by subscription type and subscriber count? | SELECT subscription_type, COUNT(subscriber_id) as subscriber_count FROM subscribers WHERE data_usage > data_limit AND usage_date >= LAST_DAY(CURRENT_DATE) AND usage_date < LAST_DAY(CURRENT_DATE) + INTERVAL 1 DAY GROUP BY subscription_type ORDER BY subscription_type, subscriber_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_manufacturers (manufacturer_id INT, name VARCHAR(100)); CREATE TABLE space_missions (mission_id INT, spacecraft_manufacturer_id INT, mission_status VARCHAR(10)); INSERT INTO spacecraft_manufacturers (manufacturer_id, name) VALUES (1, 'SpaceX'), (2, 'NASA'), (3, 'Blue Origin'); INSERT INTO space_... | How many missions have been aborted by each spacecraft manufacturer? | SELECT sm.name, COUNT(*) as aborted_missions FROM spacecraft_manufacturers sm INNER JOIN space_missions smm ON sm.manufacturer_id = smm.spacecraft_manufacturer_id WHERE smm.mission_status = 'aborted' GROUP BY sm.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE conditions (condition_id INT, condition_name VARCHAR(50), state VARCHAR(20), year INT, patient_count INT); INSERT INTO conditions VALUES (1, 'Depression', 'California', 2021, 1500), (2, 'Anxiety', 'California', 2021, 1200), (3, 'Bipolar', 'California', 2021, 800); | List the top 3 mental health conditions by number of patients in California in 2021. | SELECT condition_name, patient_count FROM (SELECT condition_name, patient_count, ROW_NUMBER() OVER (ORDER BY patient_count DESC) AS rn FROM conditions WHERE state = 'California' AND year = 2021) t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE game_results (game_id INT, home_team VARCHAR(20), away_team VARCHAR(20), home_score INT, away_score INT, city VARCHAR(20), stadium VARCHAR(50)); | Find the number of games won by the home_team and the away_team for each city in the game_results table. | SELECT city, home_team, SUM(CASE WHEN home_score > away_score THEN 1 ELSE 0 END) as num_home_wins, away_team, SUM(CASE WHEN away_score > home_score THEN 1 ELSE 0 END) as num_away_wins FROM game_results GROUP BY city, home_team, away_team; | gretelai_synthetic_text_to_sql |
CREATE TABLE mineral_extraction (id INT, mine_id INT, year INT, quantity INT);CREATE TABLE mine (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mine (id, name, location) VALUES (1, 'Quebec Gold', 'Quebec'); INSERT INTO mineral_extraction (id, mine_id, year, quantity) VALUES (1, 1, 2019, 1000); | What is the total mineral extraction in Quebec by year? | SELECT year, SUM(quantity) as total_mineral_extraction FROM mineral_extraction JOIN mine ON mineral_extraction.mine_id = mine.id WHERE mine.location = 'Quebec' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, organic TEXT, product_id INT, price FLOAT); INSERT INTO ingredients VALUES (1, 'Jojoba Oil', 'Organic', 1, 2.99), (2, 'Shea Butter', 'Organic', 2, 3.99), (3, 'Aloe Vera', 'Organic', 3, 1.99), (4, 'Rosehip Oil', 'Organic', 4, 4.99), (5, 'Cocoa Butter', '... | Find the top 3 most expensive cruelty-free cosmetic products that contain at least one organic ingredient. | SELECT cosmetics.product_id, cosmetics.product_name, cosmetics.cruelty_free, ingredients.ingredient_name, ingredients.price FROM cosmetics JOIN ingredients ON cosmetics.product_id = ingredients.product_id WHERE cosmetics.cruelty_free = true AND ingredients.organic = 'Organic' ORDER BY price DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Country (name VARCHAR(50), obesity_rate FLOAT); INSERT INTO Country (name, obesity_rate) VALUES ('Germany', 24.3), ('United Kingdom', 27.8); | What is the obesity rate in Europe? | SELECT AVG(obesity_rate) FROM Country WHERE name IN ('Germany', 'United Kingdom'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, crop_name VARCHAR(50), yield_mt_ha INT, area_ha INT); INSERT INTO crops (id, crop_name, yield_mt_ha, area_ha) VALUES (1, 'Quinoa', 1.3, 250), (2, 'Amaranth', 1.8, 180), (3, 'Wheat', 3, 420); | What is the average yield, in metric tons per hectare, of 'Quinoa' and 'Amaranth' crops, and the total production, in metric tons, for those crops? | SELECT crop_name, AVG(yield_mt_ha) as avg_yield_mt_ha, SUM(yield_mt_ha * area_ha * 0.01) as total_production_mt FROM crops WHERE crop_name IN ('Quinoa', 'Amaranth') GROUP BY crop_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), paraben_free BOOLEAN); INSERT INTO products (id, name, category, price, paraben_free) VALUES (1, 'Cleanser', 'skincare', 19.99, true), (2, 'Toner', 'skincare', 24.99, false), (3, 'Moisturizer', 'skincare', 14.99, true); | What are the names of all paraben-free skincare products priced above $20? | SELECT name FROM products WHERE category = 'skincare' AND price > 20 AND paraben_free = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stations (City VARCHAR(20), Number INT); INSERT INTO Stations (City, Number) VALUES ('New Delhi', 12), ('Bangkok', 8); | How many police stations are there in New Delhi and Bangkok? | SELECT SUM(Number) FROM Stations WHERE City IN ('New Delhi', 'Bangkok'); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO customers (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2)); INSERT INTO transactions (id, customer_id, amount) VALUES (1, 1, 100.... | What are the total transactions and their values for all customers from the United States and Canada? | SELECT SUM(amount) FROM transactions WHERE customer_id IN (SELECT id FROM customers WHERE country IN ('USA', 'Canada')); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, country TEXT); INSERT INTO donors (id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Germany'); CREATE TABLE donations (id INT, donor INT, amount FLOAT); INSERT INTO donations (id, donor, amount) VALUES (1, 1, 1000), (2, 2, 1500), (3, 1, 750); | What is the percentage of total humanitarian aid contributed by each donor country? | SELECT d.country, (SUM(donation) / (SELECT SUM(amount) FROM donations)) * 100 as contribution_percentage FROM donations d GROUP BY d.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (id INT, astronaut_country VARCHAR, mission_status VARCHAR); CREATE TABLE Astronauts (id INT, country VARCHAR); | What is the percentage of space missions completed by astronauts from the United States? | SELECT PERCENTAGE(COUNT(*)) OVER (PARTITION BY mission_status) FROM SpaceMissions sm JOIN Astronauts a ON sm.astronaut_country = a.country WHERE a.country = 'United States'; | 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.