context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE posts (id INT, topic VARCHAR(255), shares INT); INSERT INTO posts (id, topic, shares) VALUES (1, 'Vegan Recipes', 50), (2, 'Vegan Recipes', 75), (3, 'Tech News', 100), (4, 'Movie Reviews', 125), (5, 'Vegan Recipes', 150), (6, 'Vegan Recipes', 175); | What is the minimum number of shares for posts about vegan recipes? | SELECT MIN(posts.shares) AS min_shares FROM posts WHERE posts.topic = 'Vegan Recipes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityYearPopulation (CityId INT, Year INT, Population INT, PRIMARY KEY (CityId, Year)); INSERT INTO CityYearPopulation (CityId, Year, Population) VALUES (1, 2019, 8400000); INSERT INTO CityYearPopulation (CityId, Year, Population) VALUES (1, 2020, 8600000); INSERT INTO CityYearPopulation (CityId, Year, Population) VALUES (2, 2019, 3900000); INSERT INTO CityYearPopulation (CityId, Year, Population) VALUES (2, 2020, 3800000); | Which cities had a population decrease between 2019 and 2020? | SELECT CityId, Year, Population, Population - LAG(Population, 1) OVER (PARTITION BY CityId ORDER BY Year) as PopulationChange FROM CityYearPopulation WHERE PopulationChange < 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (EquipmentID INT, Manufacturer VARCHAR(50), DestinationCountry VARCHAR(50), SaleDate DATE, Quantity INT, UnitPrice FLOAT); INSERT INTO MilitaryEquipmentSales (EquipmentID, Manufacturer, DestinationCountry, SaleDate, Quantity, UnitPrice) VALUES (1, 'Lockheed Martin', 'Algeria', '2020-01-10', 5, 1000000.00), (2, 'Northrop Grumman', 'Egypt', '2020-02-15', 3, 1500000.00), (3, 'Lockheed Martin', 'Nigeria', '2020-03-20', 7, 800000.00), (4, 'Boeing', 'France', '2020-04-15', 4, 1100000.00); | What are the total military equipment sales by Lockheed Martin to European countries in 2020? | SELECT SUM(Quantity * UnitPrice) FROM MilitaryEquipmentSales WHERE Manufacturer = 'Lockheed Martin' AND DestinationCountry LIKE 'Europe%' AND YEAR(SaleDate) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE WeatherData (id INT, Temperature INT, Timestamp DATETIME); INSERT INTO WeatherData (id, Temperature, Timestamp) VALUES (1, 32, '2022-05-15 12:00:00'), (2, 28, '2022-05-16 12:00:00'); | What is the daily maximum temperature for the last 30 days, with a running total of the number of days above 30 degrees Celsius? | SELECT Temperature, Timestamp, SUM(CASE WHEN Temperature > 30 THEN 1 ELSE 0 END) OVER (ORDER BY Timestamp) as RunningTotal FROM WeatherData WHERE Timestamp BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (tx_id INT, sender VARCHAR(42), receiver VARCHAR(42), amount DECIMAL(20, 2), timestamp DATETIME); | What is the transaction history between two blockchain addresses? | SELECT * FROM transactions WHERE (sender = '0x1234567890abcdef1234567890abcdef' AND receiver = '0x87654321f0abcdef1234567890abcdef') OR (sender = '0x87654321f0abcdef1234567890abcdef' AND receiver = '0x1234567890abcdef1234567890abcdef') ORDER BY timestamp; | gretelai_synthetic_text_to_sql |
CREATE TABLE DrillingPlatforms (PlatformID int, PlatformName varchar(50), Location varchar(50), PlatformType varchar(50), NumberOfWells int); INSERT INTO DrillingPlatforms (PlatformID, PlatformName, Location, PlatformType, NumberOfWells) VALUES (1, 'A01', 'North Sea', 'Offshore', 10), (2, 'B02', 'Gulf of Mexico', 'Offshore', 15); | What is the total number of offshore drilling platforms in the North Sea? | SELECT COUNT(*) FROM DrillingPlatforms WHERE PlatformType = 'Offshore' AND Location = 'North Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT PRIMARY KEY, name VARCHAR(255), beds INT, location VARCHAR(255)); INSERT INTO hospitals (id, name, beds, location) VALUES (1, 'Johns Hopkins Hospital', 1138, 'Baltimore, MD'); INSERT INTO hospitals (id, name, beds, location) VALUES (2, 'Massachusetts General Hospital', 999, 'Boston, MA'); INSERT INTO hospitals (id, name, beds, location) VALUES (3, 'University of California Medical Center', 500, 'Los Angeles, CA'); | What is the total number of hospital beds in hospitals located in California? | SELECT SUM(beds) FROM hospitals WHERE location LIKE '%California%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE loans (loan_id INT, is_shariah_compliant BOOLEAN, issue_date DATE); INSERT INTO loans (loan_id, is_shariah_compliant, issue_date) VALUES (1, true, '2021-10-01'), (2, false, '2021-08-15'), (3, true, '2021-12-30'), (4, false, '2021-06-22'); | List all the loans issued in Q4 2021 that are Shariah-compliant. | SELECT loan_id FROM loans WHERE is_shariah_compliant = true AND issue_date BETWEEN '2021-10-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (trip_id INT, trip_date DATE, trip_type VARCHAR(50), city VARCHAR(50)); INSERT INTO trips (trip_id, trip_date, trip_type, city) VALUES (1, '2022-01-01', 'Public Transportation', 'New York City'), (2, '2022-01-05', 'Taxi', 'New York City'), (3, '2022-01-10', 'Public Transportation', 'New York City'); | Count the number of public transportation trips taken in New York City for the month of January in the year 2022. | SELECT COUNT(*) FROM trips WHERE trip_type = 'Public Transportation' AND EXTRACT(MONTH FROM trip_date) = 1 AND EXTRACT(YEAR FROM trip_date) = 2022 AND city = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team VARCHAR(255), games INT); CREATE TABLE games_played (team VARCHAR(255), year INT, games INT); INSERT INTO teams VALUES ('TeamA', 50), ('TeamB', 45), ('TeamC', 40), ('TeamD', 35); INSERT INTO games_played VALUES ('TeamA', 2018, 20), ('TeamA', 2019, 25), ('TeamA', 2020, 20), ('TeamB', 2018, 15), ('TeamB', 2019, 15), ('TeamB', 2020, 15), ('TeamC', 2018, 15), ('TeamC', 2019, 12), ('TeamC', 2020, 13), ('TeamD', 2018, 12), ('TeamD', 2019, 12), ('TeamD', 2020, 11); | Which teams have played more than 40 games in the last 3 years? | SELECT team, SUM(games) as total_games FROM games_played WHERE year BETWEEN 2018 AND 2020 GROUP BY team HAVING total_games > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (brand TEXT, region TEXT, amount FLOAT); INSERT INTO revenue (brand, region, amount) VALUES ('BrandA', 'Asia-Pacific', 5000000), ('BrandB', 'Asia-Pacific', 7000000), ('BrandC', 'Asia-Pacific', 6000000), ('BrandD', 'Asia-Pacific', 8000000), ('BrandE', 'Asia-Pacific', 9000000); | What is the total revenue of ethical fashion brands in the Asia-Pacific region? | SELECT SUM(amount) FROM revenue WHERE region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (program_id INT, volunteer_id INT); CREATE TABLE Volunteers (volunteer_id INT, name VARCHAR(255)); INSERT INTO Programs (program_id, volunteer_id) VALUES (101, 1), (101, 3), (102, 3), (103, 4); INSERT INTO Volunteers (volunteer_id, name) VALUES (1, 'John Doe'), (2, 'Jane Doe'), (3, 'Ahmed Patel'), (4, 'Sophia Williams'); | Remove the volunteer with volunteer_id 3 from all programs. | DELETE FROM Programs WHERE volunteer_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, region TEXT, success BOOLEAN); INSERT INTO projects (id, name, region, success) VALUES (1, 'Project 1', 'Asia', TRUE), (2, 'Project 2', 'Asia', FALSE), (3, 'Project 3', 'Asia', TRUE); | What is the success rate of 'agricultural innovation projects' in 'Asia'? | SELECT AVG(projects.success) FROM projects WHERE projects.region = 'Asia' AND projects.name LIKE 'agricultural innovation%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LabArtifacts (LabID varchar(5), ArtifactsAnalyzed int); INSERT INTO LabArtifacts (LabID, ArtifactsAnalyzed) VALUES ('L001', 400), ('L002', 500); | How many artifacts were analyzed by each lab? | SELECT LabID, SUM(ArtifactsAnalyzed) FROM LabArtifacts GROUP BY LabID; | gretelai_synthetic_text_to_sql |
CREATE TABLE DigitalAssets (asset_id INT, asset_name TEXT, transaction_fee DECIMAL(10, 2)); INSERT INTO DigitalAssets (asset_id, asset_name, transaction_fee) VALUES (1, 'Asset1', 10.50), (2, 'Asset2', 5.00), (3, 'Asset3', 20.00); | What is the minimum transaction fee for any digital asset? | SELECT MIN(transaction_fee) FROM DigitalAssets; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterTowers (TowerID int, State varchar(2), Height decimal(10,2)); INSERT INTO WaterTowers (TowerID, State, Height) VALUES (1, 'TX', 120.5), (2, 'TX', 130.2), (3, 'NY', 110.0); | What is the average design standard height for water towers in Texas? | SELECT AVG(Height) FROM WaterTowers WHERE State = 'TX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist_songs_2018 (artist VARCHAR(255), num_songs INT); INSERT INTO artist_songs_2018 (artist, num_songs) VALUES ('Taylor Swift', 5), ('BTS', 8), ('Ed Sheeran', 10); | How many songs were released by each artist in 2018? | SELECT artist, num_songs FROM artist_songs_2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE factory_wages (id INT, factory VARCHAR(100), location VARCHAR(100), min_wage DECIMAL(5,2)); INSERT INTO factory_wages (id, factory, location, min_wage) VALUES (1, 'Argentina Factory', 'Argentina', 10), (2, 'Brazil Factory', 'Brazil', 12), (3, 'Chile Factory', 'Chile', 15); | What is the minimum wage in factories in South America? | SELECT MIN(min_wage) FROM factory_wages WHERE location = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Equipment_Sales(sale_id INT, sale_date DATE, equipment_type VARCHAR(50), supplier VARCHAR(50), region VARCHAR(50), sale_value DECIMAL(10,2)); | Who is the top supplier of military equipment to the Pacific Islands in H2 of 2021? | SELECT supplier, SUM(sale_value) FROM Military_Equipment_Sales WHERE region = 'Pacific Islands' AND sale_date BETWEEN '2021-07-01' AND '2021-12-31' GROUP BY supplier ORDER BY SUM(sale_value) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA aircraft_manufacturing; CREATE TABLE aircraft_manufacturing.production (production_id INT, manufacturer VARCHAR(50), production_year INT, quantity INT); INSERT INTO aircraft_manufacturing.production VALUES (1, 'Boeing', 2000, 500); INSERT INTO aircraft_manufacturing.production VALUES (2, 'Airbus', 2001, 600); INSERT INTO aircraft_manufacturing.production VALUES (3, 'Bombardier', 2002, 400); | How many aircraft were manufactured per year by each manufacturer? | SELECT manufacturer, production_year, SUM(quantity) OVER (PARTITION BY manufacturer ORDER BY production_year) as total_produced FROM aircraft_manufacturing.production GROUP BY manufacturer, production_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50)); INSERT INTO marine_species (species_id, species_name) VALUES (1, 'Spinner Dolphin'), (2, 'Clownfish'), (3, 'Shark'); | How many distinct species are there in the 'marine_species' table? | SELECT COUNT(DISTINCT species_name) FROM marine_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, city VARCHAR(50), year INT, visitor_age INT); | What is the average age of visitors who attended exhibitions in Paris last year? | SELECT AVG(visitor_age) FROM Exhibitions WHERE city = 'Paris' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE stores (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(10,2), is_ethically_sourced BOOLEAN, supplier_id INT); CREATE TABLE supplier_location (supplier_id INT, country VARCHAR(255)); CREATE TABLE certifications (product_id INT, certification_type VARCHAR(255)); | List all stores located in New York that carry products with ethical labor certifications and their respective suppliers. | SELECT s.name, p.name, sl.country FROM stores s JOIN products p ON s.id = p.store_id JOIN supplier_location sl ON p.supplier_id = sl.supplier_id JOIN certifications c ON p.id = c.product_id WHERE s.state = 'New York' AND p.is_ethically_sourced = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE influenza_hospitalizations (age_group TEXT, num_hospitalizations INT); INSERT INTO influenza_hospitalizations (age_group, num_hospitalizations) VALUES ('0-4', 1000), ('5-17', 2000), ('18-49', 3000), ('50-64', 4000), ('65+', 5000); | What is the number of hospitalizations due to influenza for each age group in the influenza_hospitalizations table? | SELECT age_group, num_hospitalizations FROM influenza_hospitalizations; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeTrainings (EmployeeID INT, Training VARCHAR(50), TrainingDate DATE); INSERT INTO EmployeeTrainings (EmployeeID, Training, TrainingDate) VALUES (1, 'Diversity and Inclusion', '2021-01-01'), (2, 'Sexual Harassment Prevention', '2021-01-01'), (3, 'Diversity and Inclusion', '2019-01-01'); | Identify employees who have not received diversity and inclusion training in the last two years. | SELECT EmployeeID FROM EmployeeTrainings WHERE Training = 'Diversity and Inclusion' AND TrainingDate < DATEADD(year, -2, GETDATE()) GROUP BY EmployeeID HAVING COUNT(*) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN, price DECIMAL(5,2), attendance INT);INSERT INTO teams (team_id, team_name) VALUES (1, 'Red Sox'), (2, 'Yankees');INSERT INTO games (game_id, team_id, home_team, price, attendance) VALUES (1, 1, 1, 35.50, 45000), (2, 2, 1, 42.75, 32000), (3, 1, 0, 28.00, 22000); | What is the total revenue for home games of each team, considering only games with attendance greater than 30000? | SELECT t.team_name, SUM(g.price * g.attendance) AS revenue FROM teams t INNER JOIN games g ON t.team_id = g.team_id AND g.home_team = t.team_id WHERE g.attendance > 30000 GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_preparedness (id INT, equipment_type VARCHAR(255), status VARCHAR(255), location VARCHAR(255)); INSERT INTO disaster_preparedness (id, equipment_type, status, location) VALUES (1, 'Water Purifier', 'Unavailable', 'Warehouse 2'), (2, 'First Aid Kit', 'Available', 'Warehouse 1'); | Update the disaster_preparedness table to mark the 'status' column as 'Available' for records with 'equipment_type' 'Water Purifier' and 'location' 'Warehouse 2'? | UPDATE disaster_preparedness SET status = 'Available' WHERE equipment_type = 'Water Purifier' AND location = 'Warehouse 2'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleets(fleet_id INT, company TEXT, launch_year INT);CREATE TABLE vessels(vessel_id INT, fleet_id INT, name TEXT, launch_year INT);INSERT INTO fleets VALUES (1,'Company A',2000),(2,'Company B',2010),(3,'Company C',2005);INSERT INTO vessels VALUES (1,1,'Vessel 1',2001),(2,1,'Vessel 2',2002),(3,2,'Vessel 3',2012),(4,3,'Vessel 4',2006),(5,3,'Vessel 5',2007); | Display the average age (in years) of all vessels in each fleet, excluding fleets with no vessels, and show the results for the top 2 fleets with the oldest average vessel age. | SELECT f.company, AVG(v.launch_year) as avg_age FROM fleets f JOIN vessels v ON f.fleet_id = v.fleet_id GROUP BY f.fleet_id HAVING avg_age > 0 ORDER BY avg_age DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(30), LaunchDate DATETIME); INSERT INTO Spacecraft (SpacecraftID, Name, Manufacturer, LaunchDate) VALUES (1, 'Starliner', 'Boeing', '2019-08-02'), (2, 'New Glenn', 'Boeing', '2020-04-21'), (3, 'X-37B', 'Boeing', '2010-04-22'); | How many spacecraft have been manufactured by Boeing and launched before 2020? | SELECT COUNT(*) FROM Spacecraft WHERE Manufacturer = 'Boeing' AND YEAR(LaunchDate) < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE energy_efficiency (efficiency_id INT, state VARCHAR(255), energy_efficiency_score INT, region_id INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'West'); INSERT INTO energy_efficiency (efficiency_id, state, energy_efficiency_score, region_id) VALUES (1, 'California', 90, 1); INSERT INTO energy_efficiency (efficiency_id, state, energy_efficiency_score, region_id) VALUES (2, 'Texas', 75, 2); | What is the average energy efficiency score for each region? | SELECT r.region_name, AVG(ee.energy_efficiency_score) FROM regions r INNER JOIN energy_efficiency ee ON r.region_id = ee.region_id GROUP BY r.region_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Gender, JobTitle, Salary) VALUES (1, 'Female', 'Software Engineer', 85000.00), (2, 'Male', 'Project Manager', 95000.00), (3, 'Non-binary', 'Data Analyst', 70000.00), (4, 'Female', 'Software Engineer', 80000.00); | What is the average salary of employees who identify as female, grouped by their job title? | SELECT e.JobTitle, AVG(e.Salary) as AvgSalary FROM Employees e WHERE e.Gender = 'Female' GROUP BY e.JobTitle; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_data (id INT, crop_type VARCHAR(255), temperature INT, humidity INT, measurement_date DATE); INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (1, 'Corn', 22, 55, '2021-05-01'); INSERT INTO sensor_data (id, crop_type, temperature, humidity, measurement_date) VALUES (2, 'Cotton', 28, 65, '2021-05-03'); | Update temperature readings for a specific sensor record of crop type 'Cotton'. | UPDATE sensor_data SET temperature = 30 WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, Name TEXT); CREATE TABLE Volunteers (VolunteerID INT, Name TEXT); | What is the total number of donors and volunteers? | SELECT COUNT(*) FROM Donors; SELECT COUNT(*) FROM Volunteers; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.research (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), status VARCHAR(255)); INSERT INTO biotech.research (id, name, country, status) VALUES (1, 'Genome UK', 'UK', 'Ongoing'); INSERT INTO biotech.research (id, name, country, status) VALUES (2, 'Brain UK', 'UK', 'Completed'); | Which genetic research projects have been completed in the UK? | SELECT name FROM biotech.research WHERE country = 'UK' AND status = 'Completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft_Missions (id INT, spacecraft_id INT, mission_name VARCHAR(100), mission_date DATE, commander_gender VARCHAR(10)); INSERT INTO Spacecraft_Missions (id, spacecraft_id, mission_name, mission_date, commander_gender) VALUES (1, 1, 'Apollo 11', '1969-07-16', 'Male'); | Find the most recent mission for each spacecraft that had a female commander. | SELECT spacecraft_id, MAX(mission_date) as most_recent_mission FROM Spacecraft_Missions WHERE commander_gender = 'Female' GROUP BY spacecraft_id | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(100), donation_amount DECIMAL(10,2), donation_date DATE); | What are the top 5 donors by total donation amount for the year 2020, grouped by quarter? | SELECT QUARTER(donation_date) AS quarter, donor_name, SUM(donation_amount) AS total_donation FROM donors WHERE YEAR(donation_date) = 2020 GROUP BY quarter, donor_name ORDER BY total_donation DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, country TEXT, followers INT); INSERT INTO users (id, name, country, followers) VALUES (1, 'Alice', 'France', 700), (2, 'Bob', 'France', 600), (3, 'Charlie', 'Germany', 800); CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-02-01 12:00:00'), (2, 1, '2022-02-05 13:00:00'), (3, 2, '2022-02-03 11:00:00'), (4, 3, '2022-02-04 14:00:00'); | How many posts were created by users living in France, having less than 1000 followers, in the last week? | SELECT COUNT(posts.id) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country = 'France' AND users.followers < 1000 AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (id INT PRIMARY KEY, name TEXT, conference TEXT, division TEXT, wins INT); INSERT INTO teams (id, name, conference, division, wins) VALUES (1, 'Green Bay Packers', 'NFC', 'North', 13), (2, 'Tampa Bay Buccaneers', 'NFC', 'South', 12), (3, 'Arizona Cardinals', 'NFC', 'West', 11), (4, 'Buffalo Bills', 'AFC', 'East', 11), (5, 'Kansas City Chiefs', 'AFC', 'West', 9), (6, 'Tennessee Titans', 'AFC', 'South', 9); | List the top 3 teams with the most wins in the NFL this season | SELECT name FROM teams ORDER BY wins DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'San Francisco'); CREATE TABLE parks (id INT, city_id INT, name VARCHAR(255)); INSERT INTO parks (id, city_id, name) VALUES (1, 1, 'Golden Gate Park'); INSERT INTO parks (id, city_id, name) VALUES (2, 1, 'Golden Gate Park'); | What is the total number of parks in the city of San Francisco? | SELECT COUNT(*) FROM parks WHERE city_id = (SELECT id FROM cities WHERE name = 'San Francisco'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, country TEXT); INSERT INTO hospitals (id, name, location, country) VALUES (1, 'Hospital A', 'Rural Canada', 'Canada'), (2, 'Hospital B', 'Rural USA', 'USA'); CREATE TABLE clinics (id INT, name TEXT, location TEXT, country TEXT); INSERT INTO clinics (id, name, location, country) VALUES (1, 'Clinic A', 'Rural Canada', 'Canada'), (2, 'Clinic B', 'Rural USA', 'USA'); | What is the total number of hospitals and clinics in rural areas of Canada and the United States? | SELECT COUNT(*) FROM hospitals WHERE location LIKE '%rural%' UNION ALL SELECT COUNT(*) FROM clinics WHERE location LIKE '%rural%' | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_sites (site_id INT, site_name TEXT, region TEXT, product TEXT, quantity INT, mining_date DATE); INSERT INTO mine_sites (site_id, site_name, region, product, quantity, mining_date) VALUES (1, 'ABC Mine', 'West', 'Coal', 500, '2022-01-03'), (2, 'DEF Mine', 'East', 'Coal', 700, '2022-01-10'), (3, 'GHI Mine', 'North', 'Coal', 800, '2022-01-15'); | What is the total quantity of coal mined by each region in Q1 2022? | SELECT region, SUM(quantity) as total_qty FROM mine_sites WHERE product = 'Coal' AND mining_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity_violations (id INT, state VARCHAR(50), violation_type VARCHAR(50), violation_date DATE); INSERT INTO mental_health_parity_violations (id, state, violation_type, violation_date) VALUES (1, 'California', 'Denial of Coverage', '2022-04-15'), (2, 'Texas', 'Inadequate Facilities', '2022-05-20'), (3, 'New York', 'Denial of Coverage', '2022-06-05'); | List the number of mental health parity violations by violation type in Q2 2022. | SELECT violation_type, COUNT(*) as num_violations FROM mental_health_parity_violations WHERE violation_date >= '2022-04-01' AND violation_date < '2022-07-01' GROUP BY violation_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE products(product_id INT, country_of_origin VARCHAR(50), price DECIMAL(10,2)); | What is the average price of products made in a specific country? | SELECT AVG(price) FROM products WHERE country_of_origin = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (name, depth) VALUES ('Deep Sea Research Area', 5000); | What is the maximum depth of all marine protected areas? | SELECT MAX(depth) FROM marine_protected_areas; | gretelai_synthetic_text_to_sql |
CREATE TABLE membership_data (member_id INT, join_date DATE); CREATE TABLE workout_data (workout_id INT, member_id INT, workout_type VARCHAR(20), workout_date DATE); | List members who did both yoga and zumba workouts and their total workouts. | SELECT m.member_id, m.join_date, COUNT(w.workout_id) as total_workouts FROM membership_data m JOIN workout_data w ON m.member_id = w.member_id WHERE w.workout_type IN ('yoga', 'zumba') GROUP BY m.member_id HAVING COUNT(DISTINCT w.workout_type) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing_client (client_id INT PRIMARY KEY, name VARCHAR(100), age INT, income DECIMAL(10, 2));CREATE TABLE financial_wellbeing_payment (payment_id INT PRIMARY KEY, client_id INT, payment_amount DECIMAL(10, 2), payment_date DATE);INSERT INTO financial_wellbeing_client (client_id, name, age, income) VALUES (7, 'Emma Johnson', 28, 5000.00), (8, 'Michael Brown', 38, 9000.00); | Insert records for new clients from the Financial Wellbeing database | INSERT INTO financial_wellbeing_payment (payment_id, client_id, payment_amount, payment_date) SELECT payment_id, client_id, payment_amount, payment_date FROM (SELECT payment_id, client_id, 0.00 payment_amount, CURRENT_DATE payment_date FROM generate_series(1, 5) payment_id, UNNEST(ARRAY[7, 8]) client_id) new_payments WHERE NOT EXISTS (SELECT 1 FROM financial_wellbeing_payment p WHERE p.payment_id = new_payments.payment_id AND p.client_id = new_payments.client_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_driving_research (id INT, vehicle_name VARCHAR(50), research_topic VARCHAR(50)); | Delete records related to 'NVIDIA' from the 'autonomous_driving_research' table | DELETE FROM autonomous_driving_research WHERE vehicle_name = 'NVIDIA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Fish ( id INT PRIMARY KEY, species VARCHAR(50) ); CREATE TABLE Biomass ( fish_id INT, harvest_date DATE, biomass INT, FOREIGN KEY (fish_id) REFERENCES Fish(id) ); | What is the total biomass of fish by species and harvest date? | SELECT Fish.species, Biomass.harvest_date, SUM(Biomass.biomass) FROM Fish INNER JOIN Biomass ON Fish.id = Biomass.fish_id GROUP BY Fish.species, Biomass.harvest_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_deliveries (supplier VARCHAR(50), deliveries INT, date DATE); INSERT INTO supplier_deliveries (supplier, deliveries, date) VALUES ('GreenGrowers', 15, '2022-01-01'), ('OrganicOrigins', 20, '2022-01-02'); CREATE VIEW supplier_frequencies AS SELECT supplier, COUNT(*) as delivery_frequency FROM supplier_deliveries GROUP BY supplier; CREATE VIEW last_month_supplier_deliveries AS SELECT supplier, deliveries FROM supplier_deliveries WHERE date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE(); | Find the top 5 suppliers with the highest delivery frequency in the last month? | SELECT supplier FROM last_month_supplier_deliveries JOIN supplier_frequencies ON last_month_supplier_deliveries.supplier = supplier_frequencies.supplier GROUP BY supplier ORDER BY delivery_frequency DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_plans (id INT, name VARCHAR(255), price DECIMAL(10,2), created_at TIMESTAMP); | What is the total revenue for each mobile plan in the last quarter? | SELECT name, SUM(price) as total_revenue FROM mobile_plans WHERE created_at >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE housing_assistance (id INT, country VARCHAR(50), aid_type VARCHAR(50), amount FLOAT, date DATE); INSERT INTO housing_assistance (id, country, aid_type, amount, date) VALUES (1, 'Syria', 'housing', 800000, '2017-01-01'); | Which countries have received the most humanitarian aid in the form of housing assistance in the last 5 years? | SELECT country, SUM(amount) as total_housing_aid FROM housing_assistance WHERE aid_type = 'housing' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY country ORDER BY total_housing_aid DESC; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(100), founder_gender VARCHAR(10), funding FLOAT); INSERT INTO biotech.startups (id, name, founder_gender, funding) VALUES (1, 'StartupA', 'Female', 5000000.0), (2, 'StartupB', 'Male', 7000000.0), (3, 'StartupC', 'Female', 6000000.0); | What is the average funding amount for biotech startups founded by women? | SELECT AVG(funding) FROM biotech.startups WHERE founder_gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_stats (id INT, car_model VARCHAR(20), MPG FLOAT, safety_rating INT); INSERT INTO vehicle_stats (id, car_model, MPG, safety_rating) VALUES (1, 'Prius', 50.0, 5), (2, 'Corolla', 35.0, 4), (3, 'Insight', 60.0, 5); | Update the safety rating of the 'Corolla' model to 5 in the 'vehicle_stats' table. | UPDATE vehicle_stats SET safety_rating = 5 WHERE car_model = 'Corolla'; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name TEXT, location TEXT, contact_name TEXT, contact_email TEXT); INSERT INTO heritage_sites (id, name, location, contact_name, contact_email) VALUES (1, 'Chichen Itza', 'Mexico', 'Pedro Sanchez', 'chichenitza@mail.com'); | What is the contact information for the heritage site in 'Mexico'? | SELECT contact_name, contact_email FROM heritage_sites WHERE location = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EthicalFashionBrands(brand VARCHAR(255), carbon_emissions INT, reduction_year INT); | How many ethical fashion brands have reduced their carbon emissions in the past year? | SELECT brand, COUNT(*) FROM EthicalFashionBrands WHERE reduction_year = YEAR(CURRENT_DATE) - 1 GROUP BY brand HAVING COUNT(*) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE product (product_id INT, product_name VARCHAR(255), sales_quantity INT, sale_date DATE); CREATE TABLE region (region_id INT, region_name VARCHAR(255)); | List the top 3 chemical products with the highest sales for the past 12 months, by month, for the North America region? | SELECT product_name, EXTRACT(MONTH FROM sale_date) AS month, SUM(sales_quantity) AS total_sales FROM product JOIN region ON 1=1 WHERE region_name = 'North America' AND sale_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY product_name, EXTRACT(MONTH FROM sale_date) ORDER BY total_sales DESC, month, product_name LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streaming (SongID INT, Song TEXT, Genre TEXT, Streams INT, Country TEXT, Quarter INT, Year INT); INSERT INTO Streaming (SongID, Song, Genre, Streams, Country, Quarter, Year) VALUES (1, 'Shape of You', 'Pop', 20000000, 'Canada', 4, 2020); INSERT INTO Streaming (SongID, Song, Genre, Streams, Country, Quarter, Year) VALUES (2, 'Bad Guy', 'Pop', 18000000, 'Canada', 4, 2020); | What is the total number of streams for pop songs in Canada in Q4 of 2020? | SELECT SUM(Streams) FROM Streaming WHERE Genre = 'Pop' AND Country = 'Canada' AND Quarter = 4 AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (program_id INT, program_name TEXT, state TEXT); INSERT INTO carbon_offset_programs (program_id, program_name, state) VALUES (1, 'California Solar Initiative', 'California'), (2, 'California Cap-and-Trade Program', 'California'); | How many carbon offset programs exist in the state of California? | SELECT COUNT(*) FROM carbon_offset_programs WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_america_sourcing (id INT, material VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO south_america_sourcing (id, material, country, quantity) VALUES (1, 'organic cotton', 'Brazil', 2000); | What is the total quantity of sustainable materials sourced from South America? | SELECT SUM(quantity) FROM south_america_sourcing WHERE material = 'organic cotton' AND country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecrafts (spacecraft_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (1, 'Voyager 1', '1977-09-05'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (2, 'Voyager 2', '1977-08-20'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (3, 'Pioneer 10', '1972-03-03'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (4, 'Pioneer 11', '1973-04-06'); | What is the latest launch date in the spacecrafts table? | SELECT MAX(launch_date) FROM spacecrafts; | gretelai_synthetic_text_to_sql |
CREATE TABLE contractors (id INT, name VARCHAR(255), region VARCHAR(255), training_hours INT); INSERT INTO contractors (id, name, region, training_hours) VALUES (1, 'John Doe', 'North America', 40), (2, 'Jane Smith', 'Europe', 30), (3, 'Alice Johnson', 'North America', 50); | What is the total number of training hours for contractors in the North America region? | SELECT SUM(training_hours) as total_training_hours FROM contractors WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name VARCHAR(50), ethnicity VARCHAR(20), company_id INT, founding_year INT); CREATE TABLE funding (id INT, company_id INT, amount INT); | What is the minimum funding received by a company founded by an Indigenous person? | SELECT MIN(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id WHERE founders.ethnicity = 'Indigenous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_biomass (species VARCHAR(50), biomass INT); INSERT INTO fish_biomass (species, biomass) VALUES ('Tilapia', 50), ('Salmon', 75), ('Trout', 60); CREATE TABLE protected_species (species VARCHAR(50)); INSERT INTO protected_species (species) VALUES ('Sturgeon'), ('Salmon'); | What is the total biomass (in tons) of fish species in the fish_biomass table that are listed in the protected_species table? | SELECT SUM(fb.biomass) as total_biomass FROM fish_biomass fb WHERE fb.species IN (SELECT ps.species FROM protected_species ps); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, student_name VARCHAR(50), race VARCHAR(10), mental_health_score INT); INSERT INTO students (student_id, student_name, race, mental_health_score) VALUES (1, 'John Doe', 'Asian', 75), (2, 'Jane Smith', 'Black', 85), (3, 'Alice Johnson', 'White', 80), (4, 'Bob Lee', 'Hispanic', 88); | What is the average mental health score of students by race? | SELECT race, AVG(mental_health_score) as avg_score FROM students GROUP BY race; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_buildings (project_id INT, project_name TEXT, workers INT, timeline_days INT); | What is the maximum timeline for sustainable building projects in the 'sustainable_buildings' table with more than 500 workers? | SELECT MAX(timeline_days) FROM sustainable_buildings WHERE workers > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE aquaculture_farms (id INT, farm_name VARCHAR(50), biomass DECIMAL(10,2), carbon_footprint DECIMAL(10,2)); | What are the total biomass and carbon footprint for each aquaculture farm? | SELECT farm_name, SUM(biomass) as total_biomass, SUM(carbon_footprint) as total_carbon_footprint FROM aquaculture_farms GROUP BY farm_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products VALUES (1, 'Mascara', 5000, 'cruelty-free'), (2, 'Lipstick', 7000, 'not_certified'), (3, 'Foundation', 6000, 'cruelty-free'); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions VALUES (1, 'Canada'), (2, 'USA'); | What are the total sales of cruelty-free cosmetics in Canada and the USA? | SELECT region_name, SUM(sales) FROM products JOIN regions ON products.product_id = regions.region_id WHERE certification = 'cruelty-free' GROUP BY region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE bay_area_properties (property_id INT, co_owned BOOLEAN, property_type VARCHAR(50), size_sqft INT); | What is the average property size for co-owned properties in the Bay Area, partitioned by property type? | SELECT property_type, AVG(size_sqft) AS avg_size_sqft FROM bay_area_properties WHERE co_owned = TRUE GROUP BY property_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProgramDonations (DonationID int, ProgramID int, DonationAmount numeric(10,2), DonationDate date); CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), ProgramCategory varchar(50), ProgramImpactScore numeric(3,1)); INSERT INTO ProgramDonations (DonationID, ProgramID, DonationAmount, DonationDate) VALUES (1, 1, 1200, '2021-06-15'), (2, 2, 350, '2021-08-02'), (3, 3, 800, '2021-04-10'); INSERT INTO Programs (ProgramID, ProgramName, ProgramCategory, ProgramImpactScore) VALUES (1, 'Education for All', 'Children', 8.5), (2, 'Healthcare for the Needy', 'Children', 7.8), (3, 'Nutrition for Seniors', 'Elderly', 9.2); | Which programs have received the most donations in 2021? | SELECT Programs.ProgramName, SUM(ProgramDonations.DonationAmount) as TotalDonated FROM Programs INNER JOIN ProgramDonations ON Programs.ProgramID = ProgramDonations.ProgramID WHERE YEAR(DonationDate) = 2021 GROUP BY Programs.ProgramName ORDER BY TotalDonated DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle_Insurance (Type VARCHAR(20), Policy_Count INT, Claim_Count INT); INSERT INTO Vehicle_Insurance (Type, Policy_Count, Claim_Count) VALUES ('Auto', 500, 300), ('Motorcycle', 250, 120), ('RV', 100, 50); | What is the total number of policies and claims for each type of vehicle insurance in the state of California? | SELECT Type, SUM(Policy_Count) AS Total_Policies, SUM(Claim_Count) AS Total_Claims FROM Vehicle_Insurance WHERE State = 'California' GROUP BY Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT); CREATE TABLE user_actions (id INT, user_id INT, action TEXT, album_id INT); CREATE TABLE albums (id INT, title TEXT, artist_id INT, platform TEXT); CREATE VIEW hiphop_mobile_users AS SELECT DISTINCT ua.user_id FROM user_actions ua JOIN albums a ON ua.album_id = a.id WHERE a.genre = 'hip-hop' AND a.platform = 'mobile'; | Find the number of unique users who have streamed hip-hop music on the 'mobile' platform. | SELECT COUNT(DISTINCT user_id) FROM hiphop_mobile_users; | gretelai_synthetic_text_to_sql |
CREATE TABLE Orders (OrderID INT, CustomerID INT, OrderDate DATETIME, MealType VARCHAR(50)); CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50), DietaryRestrictions VARCHAR(500)); | What is the number of special dietary request orders, grouped by meal type and day of the week? | SELECT EXTRACT(DOW FROM Orders.OrderDate) as DayOfWeek, MealType, COUNT(*) as NumberOfOrders FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID WHERE DietaryRestrictions IS NOT NULL GROUP BY DayOfWeek, MealType; | gretelai_synthetic_text_to_sql |
CREATE TABLE PotatoProduction (Country VARCHAR(50), Year INT, Production INT); | Identify the top 3 countries with the highest potato production in 2019, in descending order. | SELECT Country, Production FROM (SELECT Country, Production, ROW_NUMBER() OVER (ORDER BY Production DESC) as rank FROM PotatoProduction WHERE Year = 2019) tmp WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Salary DECIMAL(10, 2)); INSERT INTO Employees (EmployeeID, HireDate, Salary) VALUES (1, '2021-01-01', 50000.00), (2, '2020-05-15', 60000.00), (3, '2019-03-20', 55000.00), (4, '2022-04-01', 70000.00); | What is the average salary for employees who joined after 2020? | SELECT AVG(Salary) as AvgSalary FROM Employees WHERE YEAR(HireDate) > 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE vegan_beauty_products (country VARCHAR(255), product_count INTEGER, vegan BOOLEAN); INSERT INTO vegan_beauty_products (country, product_count, vegan) VALUES ('UK', 1500, true), ('Germany', 2000, false), ('Spain', 1000, true), ('Italy', 1200, false); | How many vegan beauty products are sold in each country? | SELECT country, SUM(product_count) as total_vegan_products FROM vegan_beauty_products WHERE vegan = true GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE contractors (id INT, company_name TEXT, green_building_id INT, annual_energy_savings_kWh INT); | List the top 5 green building contractors with the highest total annual energy savings | SELECT contractors.company_name, SUM(green_buildings.annual_energy_savings_kWh) AS total_annual_energy_savings FROM contractors JOIN green_buildings ON contractors.green_building_id = green_buildings.id GROUP BY company_name ORDER BY total_annual_energy_savings DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_ESG_ratings (company_id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO company_ESG_ratings (company_id, sector, ESG_rating) VALUES (1, 'technology', 78.2), (2, 'healthcare', 65.3), (3, 'technology', 81.5), (4, 'healthcare', 85.7); | What is the minimum ESG rating for companies in the 'healthcare' sector? | SELECT MIN(ESG_rating) FROM company_ESG_ratings WHERE sector = 'healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleets (fleet_id INT, number_of_vessels INT); INSERT INTO fleets (fleet_id, number_of_vessels) VALUES (1, 10), (2, 15), (3, 20); | What is the maximum number of vessels owned by a fleet? | SELECT MAX(number_of_vessels) FROM fleets; | gretelai_synthetic_text_to_sql |
CREATE TABLE singapore_uk_deliveries (id INT, delivery_time INT); INSERT INTO singapore_uk_deliveries (id, delivery_time) VALUES (1, 6), (2, 8); | What is the maximum delivery time for packages shipped from Singapore to the United Kingdom? | SELECT MAX(delivery_time) FROM singapore_uk_deliveries; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_mammals(id INT, name VARCHAR(50), species VARCHAR(50)); INSERT INTO arctic_mammals(id, name, species) VALUES (1, 'Polar Bear', 'Ursus maritimus'), (2, 'Arctic Fox', 'Vulpes lagopus'); | How many species of mammals are present in the Arctic? | SELECT COUNT(DISTINCT species) num_species FROM arctic_mammals; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArcticTemperatureYearly(year INT, temperature FLOAT);INSERT INTO ArcticTemperatureYearly(year, temperature) VALUES(2017, -25.0), (2018, -30.0), (2019, -20.0), (2017, -20.0), (2018, -35.0); | What is the maximum and minimum temperature recorded in the Arctic each year? | SELECT year, MAX(temperature), MIN(temperature) FROM ArcticTemperatureYearly GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE cb_agreements (id INT PRIMARY KEY, union_id INT); CREATE TABLE reports (id INT PRIMARY KEY, violation VARCHAR(255), union_id INT); INSERT INTO unions (id, name) VALUES (1, 'Union A'), (2, 'Union B'), (3, 'Union C'), (4, 'Union D'); INSERT INTO cb_agreements (id, union_id) VALUES (1, 1), (2, 2), (3, 4); INSERT INTO reports (id, violation, union_id) VALUES (1, 'Violation 1', 2), (2, 'Violation 2', 3); | Display the unions involved in collective bargaining agreements, but not involved in any labor rights violations. | SELECT name FROM unions u WHERE u.id IN (SELECT union_id FROM cb_agreements) AND u.id NOT IN (SELECT union_id FROM reports); | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (Dispensary_ID INT, Dispensary_Name TEXT, State TEXT); INSERT INTO Dispensaries (Dispensary_ID, Dispensary_Name, State) VALUES (1, 'Colorado Cannabis', 'CO'); CREATE TABLE Sales (Sale_ID INT, Dispensary_ID INT, Strain TEXT, Total_Sales DECIMAL); INSERT INTO Sales (Sale_ID, Dispensary_ID, Strain, Total_Sales) VALUES (1, 1, 'Gorilla Glue', 1500.00); | Find the top 5 strains with the highest total sales in Colorado dispensaries in Q2 2022. | SELECT Strain, SUM(Total_Sales) as Total FROM Sales JOIN Dispensaries ON Sales.Dispensary_ID = Dispensaries.Dispensary_ID WHERE State = 'CO' AND QUARTER(Sale_Date) = 2 GROUP BY Strain ORDER BY Total DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA renewable_energy; CREATE TABLE wind_farms (id INT, name VARCHAR(100), capacity FLOAT); INSERT INTO wind_farms (id, name, capacity) VALUES (1, 'Wind Farm M', 100.0), (2, 'Wind Farm N', 110.0); | What is the maximum capacity of a wind farm in the 'renewable_energy' schema? | SELECT MAX(capacity) FROM renewable_energy.wind_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE islamic_microfinance (product VARCHAR(50), loan_amount FLOAT); INSERT INTO islamic_microfinance (product, loan_amount) VALUES ('Islamic Microenterprise Loan', 2000.00), ('Islamic Education Loan', 5000.00), ('Islamic Housing Loan', 10000.00); | What is the maximum loan amount for the Islamic Microfinance Loan product? | SELECT MAX(loan_amount) FROM islamic_microfinance WHERE product = 'Islamic Microenterprise Loan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (id INT PRIMARY KEY, origin VARCHAR(255), destination VARCHAR(255), distance INT, duration INT); | What is the average distance of routes between 'LA' and 'NY'? | SELECT AVG(distance) as avg_distance FROM Routes WHERE origin = 'LA' AND destination = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cyber_attacks (id INT, country VARCHAR(50), date DATE, attack_type VARCHAR(50), attack_details VARCHAR(50)); INSERT INTO cyber_attacks (id, country, date, attack_type, attack_details) VALUES (1, 'USA', '2022-01-01', 'Phishing', 'Targeted government employees'), (2, 'China', '2022-01-02', 'Malware', 'Infected government systems'), (3, 'Russia', '2022-01-03', 'Ransomware', 'Encrypted government data'), (4, 'USA', '2022-02-01', 'SQL Injection', 'Targeted government databases'), (5, 'China', '2022-02-02', 'DDOS', 'Targeted government websites'), (6, 'Russia', '2022-02-03', 'APT', 'Targeted government networks'), (7, 'USA', '2022-03-01', 'Phishing', 'Targeted government employees'), (8, 'China', '2022-03-02', 'Malware', 'Infected government systems'), (9, 'Russia', '2022-03-03', 'Ransomware', 'Encrypted government data'); | Which countries have been targeted by cyber attacks in the last 6 months, and what was the nature of each attack? | SELECT country, date, attack_type, attack_details FROM cyber_attacks WHERE date BETWEEN '2022-01-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification(id INT, investment TEXT, location TEXT, year INT, amount INT); INSERT INTO economic_diversification (id, investment, location, year, amount) VALUES (1, 'Renewable Energy Project', 'Latin America', 2018, 1000000); | What is the total economic diversification investment in 'Latin America' from '2018' to '2020'? | SELECT SUM(amount) FROM economic_diversification WHERE location = 'Latin America' AND year BETWEEN 2018 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_devices (id INT, incident_id INT, device_type VARCHAR(255)); INSERT INTO incident_devices (id, incident_id, device_type) VALUES (1, 1, 'Laptop'), (2, 1, 'Mobile'), (3, 2, 'Desktop'), (4, 3, 'Laptop'), (5, 3, 'Server'), (6, 4, 'Mobile'), (7, 4, 'Tablet'), (8, 5, 'Server'); | How many security incidents were caused by each device type in the last month? | SELECT device_type, COUNT(DISTINCT incident_id) as incident_count FROM incident_devices WHERE incident_date >= DATEADD(day, -30, GETDATE()) GROUP BY device_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseContractors (contractor_id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO DefenseContractors (contractor_id, name, state) VALUES (1, 'Contractor X', 'California'), (2, 'Contractor Y', 'Texas'), (3, 'Contractor Z', 'New York'); | What are the names of all defense contractors operating in California and Texas? | SELECT name FROM DefenseContractors WHERE state IN ('California', 'Texas'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_type VARCHAR(20), open_date DATE, close_date DATE); INSERT INTO cases (case_id, case_type, open_date, close_date) VALUES (1, 'Civil', '2022-01-10', '2022-01-15'), (2, 'Criminal', '2022-01-12', '2022-01-20'), (3, 'Civil', '2022-01-15', '2022-01-22'); | What is the maximum duration of a case, for each case type? | SELECT case_type, MAX(DATEDIFF(day, open_date, close_date)) as max_duration FROM cases GROUP BY case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members(id INT, name VARCHAR(50), gender VARCHAR(6), union_state VARCHAR(14));INSERT INTO union_members(id, name, gender, union_state) VALUES (1, 'John Doe', 'Male', 'California'), (2, 'Jane Smith', 'Female', 'New York'); | What is the total number of female and male members in unions located in California and New York? | SELECT SUM(gender = 'Male') AS total_male, SUM(gender = 'Female') AS total_female FROM union_members WHERE union_state IN ('California', 'New York'); | gretelai_synthetic_text_to_sql |
CREATE TABLE research_projects (id INT, name TEXT, principal_investigator TEXT); INSERT INTO research_projects (id, name, principal_investigator) VALUES (1, 'Project X', 'Dr. Smith'); INSERT INTO research_projects (id, name, principal_investigator) VALUES (2, 'Project Y', NULL); | Identify genetic research projects that do not have a principal investigator assigned. | SELECT * FROM research_projects WHERE principal_investigator IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_costs (year INT, location VARCHAR(20), material VARCHAR(20), cost FLOAT); INSERT INTO production_costs (year, location, material, cost) VALUES (2015, 'Canada', 'Gold', 500.5), (2015, 'Canada', 'Silver', 250.2), (2016, 'Mexico', 'Gold', 600.0), (2016, 'Mexico', 'Silver', 300.0), (2018, 'Australia', 'Gold', 700.0), (2018, 'Australia', 'Silver', 350.0); | What is the average production cost for Silver in Australia in 2018? | SELECT material, AVG(cost) as avg_cost FROM production_costs WHERE location = 'Australia' AND material = 'Silver' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_outcomes_mumbai (id INT, patient_id INT, outcome VARCHAR(20), age INT); INSERT INTO patient_outcomes_mumbai (id, patient_id, outcome, age) VALUES (1, 1, 'Improved', 30), (2, 2, 'Unchanged', 45), (3, 3, 'Deteriorated', 25), (4, 4, 'Improved', 50), (5, 5, 'Improved', 35), (6, 6, 'Unchanged', 40), (7, 7, 'Deteriorated', 55), (8, 8, 'Improved', 20); | What is the number of patients who improved, worsened, or stayed the same, partitioned by age group in Mumbai? | SELECT age_group, AVG(outcome = 'Improved') * 100 AS improved, AVG(outcome = 'Unchanged') * 100 AS unchanged, AVG(outcome = 'Deteriorated') * 100 AS deteriorated FROM (SELECT patient_outcomes_mumbai.*, (age - 18) / 10 * 10 AS age_group FROM patient_outcomes_mumbai WHERE city = 'Mumbai') t GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE attendance (id INT, age INT, event VARCHAR(50), visitors INT); INSERT INTO attendance (id, age, event, visitors) VALUES (1, 18, 'Art of the Americas', 500), (2, 25, 'Art of the Americas', 700), (3, 35, 'Art of the Americas', 800); | Calculate attendance by age group for the 'Art of the Americas'. | SELECT event, AVG(age) as avg_age, COUNT(*) as total FROM attendance WHERE event = 'Art of the Americas' GROUP BY event; | gretelai_synthetic_text_to_sql |
CREATE TABLE binance_smart_chain_contracts (contract_id INT, gas_fee DECIMAL(10, 2), name VARCHAR(255)); INSERT INTO binance_smart_chain_contracts (contract_id, gas_fee, name) VALUES (1, 0.02, 'Contract1'), (2, 0.04, 'Contract2'), (3, 0.05, 'Contract3'); | What is the maximum gas fee for smart contracts on the Binance Smart Chain, and which contract has the highest fee? | SELECT MAX(gas_fee), name FROM binance_smart_chain_contracts GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, state VARCHAR(50), quarter VARCHAR(10), strain VARCHAR(50)); | How many unique strains were sold in the state of New York in Q3 2022? | SELECT COUNT(DISTINCT strain) FROM sales WHERE state = 'New York' AND quarter = 'Q3'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT PRIMARY KEY, program_name VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO Programs (id, program_name, budget) VALUES (1, 'Education', 10000.00), (2, 'Health', 15000.00); | Update the budget for the program named 'Health' in the 'Programs' table to $20,000 | UPDATE Programs SET budget = 20000.00 WHERE program_name = 'Health'; | gretelai_synthetic_text_to_sql |
CREATE TABLE causes (cause_id INT, cause_name TEXT, avg_donation DECIMAL(10, 2)); | What is the average donation amount for each cause in the 'causes' table, ordered by the average donation amount in descending order? | SELECT cause_name, AVG(avg_donation) as avg_donation_amount FROM causes GROUP BY cause_name ORDER BY avg_donation_amount DESC; | 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.