context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE tv_show_ratings (title VARCHAR(255), rating FLOAT, release_year INT); INSERT INTO tv_show_ratings (title, rating, release_year) VALUES ('Breaking Bad', 9.5, 2008), ('Mad Men', 8.6, 2007); | What is the average rating of TV shows by release year? | SELECT release_year, AVG(rating) FROM tv_show_ratings GROUP BY release_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (city TEXT, date DATE, waste_kg INT); INSERT INTO waste_generation (city, date, waste_kg) VALUES ('Johannesburg', '2022-02-01', 500), ('Johannesburg', '2022-02-02', 550), ('Johannesburg', '2022-02-03', 600); | What is the total waste generation in metric tons for the month of February 2022 in the city of Johannesburg? | SELECT SUM(waste_kg / 1000) FROM waste_generation WHERE city = 'Johannesburg' AND date BETWEEN '2022-02-01' AND '2022-02-28'; | gretelai_synthetic_text_to_sql |
CREATE TABLE adaptation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT); INSERT INTO adaptation_projects (id, name, location, description, start_date, end_date, budget) VALUES (1, 'Sea Wall Construction', 'Miami', 'Coastal protectio... | How many climate adaptation projects were completed before '2020' in the 'adaptation_projects' table? | SELECT COUNT(*) FROM adaptation_projects WHERE end_date < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fabrics (id INT, fabric_name VARCHAR(20), is_sustainable BOOLEAN, usage INT); INSERT INTO fabrics (id, fabric_name, is_sustainable, usage) VALUES (1, 'cotton', true, 5000), (2, 'polyester', false, 7000), (3, 'linen', true, 3000), (4, 'silk', false, 4000), (5, 'wool', true, 6000), (6, 'nylon', false, 3000); | Find the top 5 most popular sustainable fabrics | SELECT fabric_name, is_sustainable, SUM(usage) as total_usage FROM fabrics WHERE is_sustainable = true GROUP BY fabric_name ORDER BY total_usage DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (Origin VARCHAR(20), Destination VARCHAR(20), Distance INT); | Add a new delivery route from Dallas to Phoenix to the 'Routes' table | INSERT INTO Routes (Origin, Destination, Distance) VALUES ('Dallas', 'Phoenix', 900); | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_operations (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO intelligence_operations (id, name, location, start_date, end_date) VALUES (1, 'Operation Timber Sycamore', 'Syria', '2015-09-30', '2017-07-18'), (2, 'Operation Inherent Resolve', 'Iraq', ... | What are the intelligence operations conducted in the Middle East and North Africa region from 2015 to 2020? | SELECT io.* FROM intelligence_operations AS io WHERE io.location LIKE '%Middle East%' OR io.location LIKE '%North Africa%' AND io.start_date BETWEEN '2015-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (id INT, start_time TIMESTAMP, end_time TIMESTAMP, route_id INT, vehicle_id INT); | Delete all records from the 'trips' table where the 'start_time' is on or after '2021-12-31 23:59:59' | DELETE FROM trips WHERE start_time >= '2021-12-31 23:59:59'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dishes (dish_id INT, dish_name TEXT, dish_type TEXT, quantity_sold INT, sale_date DATE, city TEXT); INSERT INTO Dishes (dish_id, dish_name, dish_type, quantity_sold, sale_date, city) VALUES (1, 'Pizza Slice', 'vegetarian', 50, '2022-07-01', 'New York'); | What is the total quantity of dishes sold in the city of New York for the month of July 2022? | SELECT SUM(quantity_sold) FROM Dishes WHERE city = 'New York' AND sale_date >= '2022-07-01' AND sale_date < '2022-08-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainability_initiatives (location VARCHAR(50), year INT); INSERT INTO sustainability_initiatives (location, year) VALUES ('Sydney, Australia', 2020), ('Auckland, New Zealand', 2021), ('Melbourne, Australia', 2021), ('Brisbane, Australia', 2022); | How many sustainable tourism initiatives were launched in Oceania in the last 3 years? | SELECT COUNT(*) as total_initiatives FROM sustainability_initiatives WHERE location LIKE '%Oceania%' AND year >= (SELECT YEAR(CURDATE()) - 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (id INT, title VARCHAR(100), release_year INT, revenue INT); INSERT INTO tv_shows (id, title, release_year, revenue) VALUES (1, 'TVShow1', 2018, 1000000); INSERT INTO tv_shows (id, title, release_year, revenue) VALUES (2, 'TVShow2', 2019, 1500000); INSERT INTO tv_shows (id, title, release_year, re... | What's the total revenue for TV shows released in 2020? | SELECT SUM(revenue) FROM tv_shows WHERE release_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (transaction_id INT, user_id INT, application_type VARCHAR(255)); INSERT INTO creative_ai (transaction_id, user_id, application_type) VALUES (1, 1001, 'text-generation'), (2, 1002, 'image-synthesis'), (3, 1001, 'text-generation'); | What is the total number of transactions and unique users for creative AI applications? | SELECT COUNT(transaction_id) AS total_transactions, COUNT(DISTINCT user_id) AS unique_users FROM creative_ai WHERE application_type = 'creative AI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SecurityAudit (id INT, user VARCHAR(50), policy VARCHAR(100), timestamp DATETIME, violation_count INT); INSERT INTO SecurityAudit (id, user, policy, timestamp, violation_count) VALUES (1, 'Eve', 'Data Handling Policy', '2021-01-01 10:00:00', 3), (2, 'Frank', 'Password Policy', '2021-01-01 10:00:00', 2); | Which security policies have been violated the most by users in the Marketing department in the last quarter, according to our Security Audit database? | SELECT policy FROM SecurityAudit WHERE user IN (SELECT user FROM SecurityAudit WHERE department = 'Marketing') AND timestamp >= DATE_SUB(NOW(), INTERVAL 3 MONTH) GROUP BY policy ORDER BY SUM(violation_count) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sydney_trains (train_id INT, ride_date DATE, is_accessible BOOLEAN, is_weekday BOOLEAN); INSERT INTO sydney_trains (train_id, ride_date, is_accessible, is_weekday) VALUES (1, '2021-01-01', TRUE, TRUE), (2, '2021-01-02', FALSE, FALSE); | Calculate the percentage of accessible train rides in Sydney by day of the week. | SELECT is_weekday, ROUND(100.0 * SUM(is_accessible) / COUNT(*), 2) AS accessibility_percentage FROM sydney_trains GROUP BY is_weekday; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (id INT, workout_date DATE); INSERT INTO Workouts (id, workout_date) VALUES (1, '2022-01-01'), (2, '2022-01-05'); | How many workouts were performed in January 2022? | SELECT COUNT(*) FROM Workouts WHERE workout_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(5,2), donation_date DATE, region VARCHAR(20)); INSERT INTO donations (donor_id, donation_amount, donation_date, region) VALUES (1, 50.00, '2020-01-01', 'Africa'); INSERT INTO donations (donor_id, donation_amount, donation_date, region) VALUES (1, 100.00, '20... | What is the average donation amount per donor from '2020' partitioned by 'region'? | SELECT region, AVG(donation_amount) avg_donation FROM (SELECT donor_id, donation_amount, donation_date, region, ROW_NUMBER() OVER (PARTITION BY donor_id ORDER BY donation_date) rn FROM donations WHERE EXTRACT(YEAR FROM donation_date) = 2020) x GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainability_data (id INT, location TEXT, practice TEXT, start_date DATE); INSERT INTO sustainability_data (id, location, practice, start_date) VALUES (1, 'Bali', 'Reduced water usage', '2021-01-01'), (2, 'Bali', 'Plastic reduction', '2021-03-15'), (3, 'Phuket', 'Carbon offsetting', '2021-06-01'); | Which sustainable tourism practices were implemented in Bali in 2021? | SELECT practice FROM sustainability_data WHERE location = 'Bali' AND start_date <= '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), hire_date DATE); INSERT INTO employees (id, name, hire_date) VALUES (1, 'John Doe', '2021-02-14'), (2, 'Jane Smith', '2021-05-02'); | What is the latest hire date for employees? | SELECT MAX(hire_date) FROM employees; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_principles (principle_name TEXT, region TEXT); INSERT INTO ai_safety_principles (principle_name, region) VALUES ('Beneficence', 'Asia'), ('Nonmaleficence', 'Europe'), ('Autonomy', 'Americas'), ('Justice', 'Africa'); | What is the distribution of AI safety principles across different regions? | SELECT principle_name, region, COUNT(*) FROM ai_safety_principles GROUP BY principle_name, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites_visitors (id INT, site_name VARCHAR(100), country VARCHAR(50), visitor_count INT); INSERT INTO heritage_sites_visitors (id, site_name, country, visitor_count) VALUES (1, 'Colosseum', 'Italy', 7000000), (2, 'Great Wall', 'China', 10000000), (3, 'Eiffel Tower', 'France', 7000000); | What are the top 5 heritage sites with the largest visitor count? | SELECT site_name, visitor_count FROM heritage_sites_visitors ORDER BY visitor_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name TEXT, region TEXT); INSERT INTO marine_species (species_name, region) VALUES ('Krill', 'Southern Ocean'), ('Blue Whale', 'Southern Ocean'), ('Seal', 'Arctic'); | List all marine species in the 'Southern Ocean'. | SELECT species_name FROM marine_species WHERE region = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitats (name VARCHAR(255), area FLOAT, location VARCHAR(255)); INSERT INTO wildlife_habitats (name, area, location) VALUES ('Habitat 1', 1234.56, 'North America'), ('Habitat 2', 2345.67, 'Europe'); | What's the average area of all wildlife habitats not located in 'Europe'? | SELECT AVG(area) FROM wildlife_habitats WHERE location != 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life (id INT, marine_life_type VARCHAR(255), habitat_depth FLOAT); INSERT INTO marine_life (id, marine_life_type, habitat_depth) VALUES (1, 'Coral', 10.0), (2, 'Anglerfish', 5000.0); | Update the habitat depth for a specific Coral record in the marine_life table. | UPDATE marine_life SET habitat_depth = 12.0 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), waste_type VARCHAR(255), amount INT); | Delete all records from the 'waste_generation' table where the 'state' is 'California' | DELETE FROM waste_generation WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT, name VARCHAR(50), department VARCHAR(50), sales FLOAT); INSERT INTO drugs (id, name, department, sales) VALUES (1, 'DrugA', 'Oncology', 100000), (2, 'DrugB', 'Oncology', 150000), (3, 'DrugC', 'Cardiology', 120000), (4, 'DrugD', 'Cardiology', 160000), (5, 'DrugE', 'Cardiology', 180000); | What are the total sales figures for each department? | SELECT department, SUM(sales) as total_sales FROM drugs GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE football_teams (team_id INT, team_name VARCHAR(50), roster_size INT); INSERT INTO football_teams (team_id, team_name, roster_size) VALUES (1, 'New England Patriots', 53); INSERT INTO football_teams (team_id, team_name, roster_size) VALUES (2, 'Dallas Cowboys', 55); | List the teams and the number of players in each team's roster in the 'football_teams' table. | SELECT team_name, roster_size FROM football_teams; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_scores (id INT, worker_id INT, score INT); CREATE TABLE mental_health_training (id INT, worker_id INT); INSERT INTO mental_health_scores (id, worker_id, score) VALUES (1, 1, 80), (2, 2, 90), (3, 3, 70); INSERT INTO mental_health_training (id, worker_id) VALUES (1, 1), (2, 2); | What is the average mental health score of community health workers who have completed mental health training? | SELECT AVG(mhs.score) FROM mental_health_scores mhs INNER JOIN mental_health_training mht ON mhs.worker_id = mht.worker_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(50), jersey_number INT, team_id INT); INSERT INTO athletes (id, name, jersey_number, team_id) VALUES (1, 'John Doe', 10, 1), (2, 'Jane Smith', 20, 1), (3, 'Bob Johnson', 30, 2); | Update the jersey number of a basketball player in the athletes table | UPDATE athletes SET jersey_number = 15 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE service (student_id INT, service_type TEXT); INSERT INTO service (student_id, service_type) VALUES (1, 'Assistive Technology'), (2, 'Note Taker'), (3, 'Assistive Technology'), (4, 'Extended Testing Time'); | List all the services and the number of students who received each service, ordered by the number of students. | SELECT service_type, COUNT(DISTINCT student_id) as count FROM service GROUP BY service_type ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (id INT, name TEXT, construction_date DATE, location TEXT); INSERT INTO bridges (id, name, construction_date, location) VALUES (1, 'Bridge A', '1975-01-01', 'Washington'), (2, 'Bridge B', '1982-06-30', 'Texas'); | List all the bridges in Washington and their construction dates | SELECT * FROM bridges WHERE location = 'Washington'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DailyParkVisits (VisitID INT, ParkName VARCHAR(50), VisitDate DATE); INSERT INTO DailyParkVisits (VisitID, ParkName, VisitDate) VALUES (1, 'Millennium Park', '2022-08-01'), (2, 'Grant Park', '2022-08-02'), (3, 'Lincoln Park', '2022-08-03'); | What is the average number of public parks visited per day in the city of Chicago in the month of August? | SELECT AVG(DailyVisits) FROM (SELECT COUNT(*) AS DailyVisits FROM DailyParkVisits WHERE ParkName = 'Chicago' AND MONTH(VisitDate) = 8 GROUP BY DATE(VisitDate)) AS VisitsPerDay; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, StartDate DATE, EndDate DATE); INSERT INTO Programs (ProgramID, ProgramName, StartDate, EndDate) VALUES (1, 'ProgramA', '1990-01-01', '2010-12-31'), (2, 'ProgramB', '2005-05-15', '2025-04-30'), (3, 'ProgramC', '2018-09-09', '2023-06-15'); | Identify the language preservation programs that have been active for more than 15 years, ordered by the start date in ascending order. | SELECT ProgramName, StartDate FROM Programs WHERE DATEDIFF(year, StartDate, GETDATE()) > 15 ORDER BY StartDate ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE gulf_oil_production (year INT, region VARCHAR(50), oil_production FLOAT);CREATE TABLE gulf_gas_production (year INT, region VARCHAR(50), gas_production FLOAT); INSERT INTO gulf_oil_production VALUES (2020, 'Gulf of Mexico', 1200000); INSERT INTO gulf_oil_production VALUES (2020, 'Gulf of Mexico', 1100000);... | What are the average production figures for oil and gas in the Gulf of Mexico region for the year 2020? | SELECT AVG(oil_production) AS avg_oil_production, AVG(gas_production) AS avg_gas_production FROM gulf_oil_production INNER JOIN gulf_gas_production ON gulf_oil_production.year = gulf_gas_production.year WHERE gulf_oil_production.region = 'Gulf of Mexico' AND gulf_oil_production.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE garments (id INT, name VARCHAR(100), price DECIMAL(5,2), category VARCHAR(50)); | Update the price of all garments in the 'Tops' category to 25.00 in the garments table | UPDATE garments SET price = 25.00 WHERE category = 'Tops'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Permit_Data (PermitID INT, City VARCHAR(50), Quarter INT, Year INT, Cost FLOAT); | What is the total cost of construction permits issued in Los Angeles in Q1 of 2019? | SELECT SUM(Cost) FROM Permit_Data WHERE City = 'Los Angeles' AND Quarter = 1 AND Year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT, state VARCHAR(2), parity_law VARCHAR(255)); | Delete all records from the 'mental_health_parity' table where 'parity_law' is NULL | DELETE FROM mental_health_parity WHERE parity_law IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (Id INT, Race VARCHAR(25), Salary DECIMAL(10,2)); INSERT INTO CommunityHealthWorkers (Id, Race, Salary) VALUES (1, 'Caucasian', 70000.00), (2, 'Latino', 72000.00), (3, 'Caucasian', 75000.00), (4, 'Latino', 78000.00), (5, 'Caucasian', 80000.00); | What is the minimum salary of community health workers who identify as Caucasian or Latino? | SELECT MIN(Salary) as MinSalary FROM CommunityHealthWorkers WHERE Race IN ('Caucasian', 'Latino'); | gretelai_synthetic_text_to_sql |
CREATE TABLE music_sales (sale_id INT, genre VARCHAR(10), year INT, revenue FLOAT); INSERT INTO music_sales (sale_id, genre, year, revenue) VALUES (1, 'Pop', 2021, 50000.00), (2, 'Rock', 2021, 45000.00), (3, 'Pop', 2020, 40000.00); CREATE VIEW genre_sales AS SELECT genre, SUM(revenue) as total_revenue FROM music_sales ... | What is the highest-grossing music genre so far? | SELECT genre, MAX(total_revenue) as max_revenue FROM genre_sales GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT PRIMARY KEY, name TEXT, country TEXT, budget INT); INSERT INTO community_development (id, name, country, budget) VALUES (1, 'Youth Skills Training', 'USA', 2000000); INSERT INTO community_development (id, name, country, budget) VALUES (2, 'Women Empowerment Program', 'Mexico',... | What is the total budget allocated for community development initiatives in 'Africa' and 'Asia' in the 'rural_development' database? | SELECT SUM(budget) as total_budget FROM community_development WHERE country IN ('Africa', 'Asia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE UrbanAreas (id INT, name VARCHAR(255), is_urban BOOLEAN, country VARCHAR(255), population INT, avg_income DECIMAL(10,2)); INSERT INTO UrbanAreas (id, name, is_urban, country, population, avg_income) VALUES (1, 'Toronto', TRUE, 'Canada', 2900000, 65000.00); | What is the average income of residents in urban areas in Canada in 2020? | SELECT AVG(avg_income) FROM UrbanAreas WHERE is_urban = TRUE AND country = 'Canada' AND YEAR(datetime('2020-01-01')) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT, habitat_status VARCHAR(50)); | Update the population of the Giant Panda in the 'animals' table | UPDATE animals SET population = 1864 WHERE name = 'Giant Panda'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(10)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender) VALUES (1, 35, 'Female'), (2, 42, 'Male'), (3, 48, 'Non-binary'); | Update the records of community health workers whose age is above 45 and set their new age to 45. | UPDATE CommunityHealthWorkers SET Age = 45 WHERE Age > 45; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT PRIMARY KEY, location VARCHAR(50), waste_type VARCHAR(50), quantity INT); | Drop the table for waste generation data | DROP TABLE waste_generation; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_trains( train_id INT, charging_time_min INT, city VARCHAR(50)); | What is the minimum charging time required for an electric train in New Delhi? | SELECT MIN(charging_time_min) FROM electric_trains WHERE city = 'New Delhi'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_platforms (player_id INT, game_id INT, platform VARCHAR(50), PRIMARY KEY (player_id, game_id)); INSERT INTO player_platforms VALUES (1, 1, 'PC'), (1, 2, 'PC'), (2, 1, 'Console'), (2, 2, 'Console'), (3, 1, 'Mobile'), (3, 2, 'PC'); CREATE TABLE game_titles (game_id INT, title VARCHAR(50), PRIMARY KEY ... | Find the top 5 games with the highest number of players who have played on console | SELECT gt.title, COUNT(DISTINCT pp.player_id) as num_players FROM player_platforms pp INNER JOIN game_titles gt ON pp.game_id = gt.game_id WHERE pp.platform = 'Console' GROUP BY gt.title ORDER BY num_players DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_usage (id INT, chemical_name VARCHAR(50), usage_quantity INT, usage_date DATE); | Insert new record into 'chemical_usage' table with values ('Calcium Chloride', 100, '2022-06-01') | INSERT INTO chemical_usage (chemical_name, usage_quantity, usage_date) VALUES ('Calcium Chloride', 100, '2022-06-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE veterans_v2 (veteran_id INT, state VARCHAR(255), employment_status VARCHAR(255));INSERT INTO veterans_v2 (veteran_id, state, employment_status) VALUES (1, 'CA', 'Employed'), (2, 'TX', 'Unemployed'), (3, 'NY', 'Employed'), (4, 'CA', 'Employed'), (5, 'TX', 'Employed'); | List the number of veterans in each state with the employment status 'Employed'. | SELECT state, COUNT(*) as employed_veterans FROM veterans_v2 WHERE employment_status = 'Employed' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID int, RouteName varchar(50)); INSERT INTO Routes VALUES (1, 'Green Line'); INSERT INTO Routes VALUES (2, 'Red Line'); CREATE TABLE Fares (FareID int, RouteID int, FareAmount decimal(5,2)); INSERT INTO Fares VALUES (1, 1, 2.50); INSERT INTO Fares VALUES (2, 1, 3.00); INSERT INTO Fares VALUES ... | What is the average fare for each route? | SELECT Routes.RouteName, AVG(Fares.FareAmount) as AvgFare FROM Routes INNER JOIN Fares ON Routes.RouteID = Fares.RouteID GROUP BY Routes.RouteName; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_trends (ai_trend_id INT, trend_name VARCHAR(30), description TEXT); | Create a table named 'ai_trends' to store data about AI adoption in hospitality | CREATE TABLE ai_trends (ai_trend_id INT, trend_name VARCHAR(30), description TEXT); | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farm (farm_id INT, location VARCHAR(20), num_fish INT); INSERT INTO fish_farm (farm_id, location, num_fish) VALUES (1, 'Mediterranean sea', 9000), (2, 'Arabian sea', 11000), (3, 'Mediterranean sea', 8500), (4, 'Arabian sea', 10500); | How many fish are raised in total in the farms located in the Mediterranean sea and the Arabian sea? | SELECT SUM(num_fish) FROM fish_farm WHERE location IN ('Mediterranean sea', 'Arabian sea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cb_agreements (id INT, union_id INT, industry VARCHAR(20), duration INT); INSERT INTO cb_agreements (id, union_id, industry, duration) VALUES (1, 123, 'education', 36), (2, 456, 'healthcare', 24), (3, 789, 'construction', 12), (4, 901, 'retail', 48), (5, 111, 'retail', 72); | What is the total number of collective bargaining agreements in the 'retail' industry? | SELECT COUNT(*) FROM cb_agreements WHERE industry = 'retail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE japan_aquaculture_sites (site_id INT, site_name TEXT, biomass FLOAT, country TEXT); INSERT INTO japan_aquaculture_sites (site_id, site_name, biomass, country) VALUES (1, 'Site F', 1200.0, 'Japan'), (2, 'Site G', 1500.0, 'Japan'), (3, 'Site H', 900.0, 'Japan'); | Delete the record of the aquaculture site in Japan with the lowest biomass? | DELETE FROM japan_aquaculture_sites WHERE biomass = (SELECT MIN(biomass) FROM japan_aquaculture_sites); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, Department varchar(20), Age int); INSERT INTO Employees (EmployeeID, Department, Age) VALUES (1, 'HR', 35), (2, 'IT', 32), (3, 'Sales', 28), (4, 'HR', 25), (5, 'IT', 22); | What is the average age of the youngest employee in each department? | SELECT Department, AVG(Age) FROM (SELECT Department, MIN(Age) AS Age FROM Employees GROUP BY Department) AS Subquery GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE patents(company varchar(20), country varchar(20), year int, num_patents int); INSERT INTO patents VALUES ('CompanyB', 'CountryC', 2017, 15); INSERT INTO patents VALUES ('CompanyB', 'CountryC', 2018, 20); INSERT INTO patents VALUES ('CompanyB', 'CountryC', 2019, 25); INSERT INTO patents VALUES ('CompanyB', ... | How many patents were filed by 'CompanyB' in 'CountryC' between 2017 and 2020? | SELECT SUM(num_patents) FROM patents WHERE company = 'CompanyB' AND country = 'CountryC' AND year BETWEEN 2017 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT PRIMARY KEY, size VARCHAR(10)); INSERT INTO customers (id, size) VALUES (1, 'S'), (2, 'M'), (3, 'L'), (4, 'XL'); | How many customers in the customers table have a size that is not available in the fashion_trends table? | SELECT COUNT(*) FROM customers LEFT JOIN fashion_trends ON customers.size = fashion_trends.size WHERE fashion_trends.size IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts(ID INT, Name VARCHAR(50), FirstMissionDate DATE); | List all astronauts who have never been on a space mission | SELECT Name FROM Astronauts WHERE FirstMissionDate IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (id INT, student VARCHAR(255), date DATE); CREATE TABLE Students (id INT, name VARCHAR(255), age INT, disability VARCHAR(255)); | What is the average age of students with visual impairments who have received accommodations in the last year? | SELECT AVG(age) FROM Students INNER JOIN Accommodations ON Students.id = Accommodations.student WHERE disability = 'visual impairment' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility (id INT, disability VARCHAR(255), concern VARCHAR(255)); | What are the unique technology accessibility concerns for people with visual impairments in the accessibility table? | SELECT DISTINCT concern FROM accessibility WHERE disability = 'people with visual impairments'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo (id INT, vessel_name VARCHAR(255), vessel_type VARCHAR(255), cargo_weight INT, port VARCHAR(255), unload_date DATE); INSERT INTO cargo (id, vessel_name, vessel_type, cargo_weight, port, unload_date) VALUES (1, 'VesselA', 'Cargo', 12000, 'Nice', '2022-01-15'); | What is the total cargo weight transported by each vessel type in the Mediterranean Sea, sorted by the total weight? | SELECT vessel_type, SUM(cargo_weight) as total_weight FROM cargo WHERE port IN ('Barcelona', 'Nice', 'Genoa', 'Marseille', 'Athens') GROUP BY vessel_type ORDER BY total_weight DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, name TEXT, location TEXT, diversity_score DECIMAL(3,2)); INSERT INTO suppliers VALUES (1, 'Acme Supplies', 'London', 0.92), (2, 'Global Sources', 'Paris', 0.85), (3, 'Beta Supplies', 'Berlin', 0.95), (4, 'Alpha Supplies', 'New York', 0.78), (5, 'Omega Supplies', 'Sydney', 0.89); | List the names and locations of all suppliers that have a diversity score above 0.9 and are located in Europe. | SELECT name, location FROM suppliers WHERE diversity_score > 0.9 AND location LIKE '%Europe%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50), added_date DATE); INSERT INTO animal_population (animal_id, animal_name, program, added_date) VALUES (1, 'Grizzly Bear', 'habitat_preservation', '2022-01-01'), (2, 'Gray Wolf', 'community_education', '2022-02-01'), (3, 'Bald Ea... | Update the program for the animal with animal_id 3 to 'community_education' | UPDATE animal_population SET program = 'community_education' WHERE animal_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (id INT, cultural_competency VARCHAR(20)); INSERT INTO community_health_workers (id, cultural_competency) VALUES (1, 'High'), (2, 'Medium'), (3, 'Low'), (4, 'High'), (5, 'Medium'); | How many community health workers have a high cultural competency level? | SELECT COUNT(*) FROM community_health_workers WHERE cultural_competency = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HumanitarianAssistance (Country VARCHAR(50), Year INT, Amount FLOAT); INSERT INTO HumanitarianAssistance (Country, Year, Amount) VALUES ('Country 1', 2013, 1200000), ('Country 2', 2013, 1300000); | What was the total humanitarian assistance provided in 2013? | SELECT SUM(Amount) FROM HumanitarianAssistance WHERE Year = 2013; | gretelai_synthetic_text_to_sql |
CREATE TABLE origin_countries (destination_country VARCHAR(50), visitor_country VARCHAR(50), percentage FLOAT); INSERT INTO origin_countries (destination_country, visitor_country, percentage) VALUES ('India', 'United States', 0.30); | What is the percentage of tourists visiting India who are from the United States? | SELECT (percentage * 100) FROM origin_countries WHERE destination_country = 'India' AND visitor_country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_violations (country VARCHAR(255), violation_count INT); INSERT INTO policy_violations (country, violation_count) VALUES ('United States', 15), ('United Kingdom', 12), ('Canada', 8), ('Australia', 7), ('Germany', 6); | Identify the top 3 countries with the highest number of cybersecurity policy violations. | SELECT country, violation_count FROM (SELECT country, violation_count, ROW_NUMBER() OVER (ORDER BY violation_count DESC) as row_num FROM policy_violations) AS ranked_violations WHERE row_num <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, name VARCHAR(255), country VARCHAR(255)); | Insert a new volunteer record for Carlos with country Mexico. | INSERT INTO Volunteers (name, country) VALUES ('Carlos', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, name VARCHAR(50), launch_date DATE, mission_status VARCHAR(20), company VARCHAR(50)); | How many active space missions are currently being conducted by SpaceX? | SELECT COUNT(*) FROM space_missions WHERE mission_status = 'Active' AND company = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm_biomass (farm_id INT, year INT, biomass FLOAT, species VARCHAR(50)); INSERT INTO farm_biomass (farm_id, year, biomass, species) VALUES (1, 2022, 250.3, 'Salmon'), (2, 2022, 320.5, 'Tilapia'), (3, 2022, 180.7, 'Carp'), (4, 2022, 450.9, 'Salmon'), (5, 2022, 220.1, 'Tuna'), (6, 2022, 370.2, 'Cod'); | Which are the top 3 species by total biomass in aquatic farms in Oceania for the current year? | SELECT species, SUM(biomass) FROM farm_biomass WHERE year = 2022 GROUP BY species ORDER BY SUM(biomass) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics_by_game (id INT, game_id INT, gender VARCHAR(50), count INT); INSERT INTO fan_demographics_by_game (id, game_id, gender, count) VALUES (1, 1, 'Male', 2000), (2, 1, 'Female', 3000), (3, 2, 'Male', 1500), (4, 2, 'Female', 4000); | What is the total number of fans for each game? | SELECT game_id, SUM(count) as total_fans FROM fan_demographics_by_game GROUP BY game_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, artist_name VARCHAR(255), tickets_sold INT); INSERT INTO concerts (id, artist_name, tickets_sold) VALUES (1, 'Taylor Swift', 12000), (2, 'BTS', 15000), (3, 'Taylor Swift', 10000), (4, 'Ariana Grande', 9000); | Show the total number of tickets sold for each artist | SELECT artist_name, SUM(tickets_sold) as total_tickets_sold FROM concerts GROUP BY artist_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'VesselA'), (2, 'VesselB'); CREATE TABLE cargo (id INT, vessel_id INT, load_date DATE); INSERT INTO cargo (id, vessel_id, load_date) VALUES (1, 1, '2021-06-15'), (2, 1, '2021-07-20'), (3, 2, '2021-05-05'); | Which vessels have not loaded cargo in the past month? | SELECT v.name FROM vessels v LEFT JOIN cargo c ON v.id = c.vessel_id WHERE c.load_date IS NULL OR c.load_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY v.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtMovements (MovementID int, Name varchar(50)); CREATE TABLE ArtPieces (ArtPieceID int, Title varchar(50), YearCreated int, MovementID int); | Which art movements had the most pieces produced? | SELECT ArtMovements.Name, COUNT(ArtPieces.ArtPieceID) AS ArtPiecesCount FROM ArtMovements INNER JOIN ArtPieces ON ArtMovements.MovementID = ArtPieces.MovementID GROUP BY ArtMovements.Name ORDER BY ArtPiecesCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (id INT, country TEXT, price FLOAT, date DATE); | What is the minimum carbon price in China in Q1 2020? | SELECT MIN(price) FROM carbon_prices WHERE country = 'China' AND QUARTER(date) = 1 AND YEAR(date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR(100), artist VARCHAR(100), release_date DATE); INSERT INTO songs (id, title, artist, release_date) VALUES (1, 'Song1', 'Artist1', '2020-01-01'), (2, 'Song2', 'Artist2', '2019-12-31'), (3, 'Song3', 'Artist1', '2020-06-01'); | How many songs were released by each artist in 2020? | SELECT artist, COUNT(*) as song_count FROM songs WHERE YEAR(release_date) = 2020 GROUP BY artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, join_date DATE, hours_per_week FLOAT); INSERT INTO volunteers (volunteer_id, join_date, hours_per_week) VALUES (1, '2021-01-05', 5.0), (2, '2020-12-10', 8.0), (3, '2021-02-01', 3.0); CREATE TABLE donations_by_volunteers (volunteer_id INT, donation_amount FLOAT); INSERT INTO do... | What is the average donation amount by new volunteers who joined in Q1 2021? | SELECT AVG(donation_amount) FROM donations_by_volunteers JOIN volunteers ON donations_by_volunteers.volunteer_id = volunteers.volunteer_id WHERE QUARTER(join_date) = 1 AND volunteers.volunteer_id NOT IN (SELECT volunteer_id FROM donations_by_volunteers JOIN volunteers ON donations_by_volunteers.volunteer_id = volunteer... | gretelai_synthetic_text_to_sql |
CREATE TABLE national_parks.timber_volume (species VARCHAR(255), volume DECIMAL(5,2)); | Find the species with the lowest timber volume in the national_parks schema. | SELECT species FROM national_parks.timber_volume WHERE volume = (SELECT MIN(volume) FROM national_parks.timber_volume); | gretelai_synthetic_text_to_sql |
CREATE TABLE Product_Ratings (product_id INT, rating INT); INSERT INTO Product_Ratings (product_id, rating) VALUES (1, 4), (2, 3), (3, 5), (4, 2), (5, 5); | What is the average product rating for the ethically sourced products sold in Florida? | SELECT AVG(rating) FROM Ethical_Products EP JOIN Sales S ON EP.product_id = S.product_id JOIN Product_Ratings PR ON EP.product_id = PR.product_id WHERE is_ethically_sourced = true AND sale_location = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TennisMatches (match_id INTEGER, player_1 TEXT, player_2 TEXT, points_player_1 INTEGER, points_player_2 INTEGER); INSERT INTO TennisMatches (match_id, player_1, player_2, points_player_1, points_player_2) VALUES (1, 'Player 1', 'Player 2', 30, 20), (2, 'Player 3', 'Player 1', 40, 10), (3, 'Player 2', 'Play... | What is the highest number of points scored by a tennis player in a single match? | SELECT MAX(GREATEST(points_player_1, points_player_2)) FROM TennisMatches; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(255));CREATE TABLE Garments (GarmentID INT, CountryID INT, SalePrice DECIMAL(10,2));CREATE TABLE Sales (SaleID INT, GarmentID INT, SaleDate DATE, Quantity INT); | What is the total sales revenue for each country, ordered by the total sales revenue in descending order? | SELECT c.CountryName, SUM(g.SalePrice * s.Quantity) AS TotalRevenue FROM Countries c JOIN Garments g ON c.CountryID = g.CountryID JOIN Sales s ON g.GarmentID = s.GarmentID GROUP BY c.CountryName ORDER BY TotalRevenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(255)); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type VARCHAR(255), historical_period VARCHAR(255)); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'site_a'), (2, 'site_b'), (3, 'site_c'), (4, 'site_d'), (5, 'site_e'); INSE... | Which sites have artifacts from the 'Stone Age' and 'Iron Age'? | SELECT site_name FROM excavation_sites s JOIN artifacts a ON s.site_id = a.site_id WHERE historical_period IN ('Stone Age', 'Iron Age') GROUP BY site_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE nyc_hotels (id INT, name VARCHAR(50), rating FLOAT); INSERT INTO nyc_hotels (id, name, rating) VALUES (1, 'Plaza Hotel', 4.5), (2, 'Hilton Times Square', 4.0); | What is the average hotel rating in New York City? | SELECT AVG(rating) FROM nyc_hotels; | gretelai_synthetic_text_to_sql |
CREATE TABLE Candidates(CandidateID INT, Department VARCHAR(255), InterviewDate DATE, Gender VARCHAR(255)); | How many female candidates were interviewed for the marketing department in the last quarter? | SELECT COUNT(*) FROM Candidates WHERE Department = 'Marketing' AND Gender = 'Female' AND InterviewDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE offices (office_id INT, office_name VARCHAR(20)); INSERT INTO offices (office_id, office_name) VALUES (1, 'Boston'), (2, 'New York'), (3, 'Chicago'); CREATE TABLE cases (case_id INT, attorney_id INT, office_id INT, case_outcome VARCHAR(10)); INSERT INTO cases (case_id, attorney_id, office_id, case_outcome)... | What is the total number of cases won by attorneys from the 'Boston' office? | SELECT COUNT(*) FROM cases JOIN offices ON cases.office_id = offices.office_id WHERE offices.office_name = 'Boston' AND case_outcome = 'Won'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_icu_beds INT, state TEXT); INSERT INTO hospitals (id, name, location, num_icu_beds, state) VALUES (1, 'General Hospital', 'Urban, Illinois', 30, 'Illinois'); INSERT INTO hospitals (id, name, location, num_icu_beds, state) VALUES (2, 'Community Hospital', 'Ur... | Update the number of ICU beds in urban hospitals in Illinois and Michigan by 10%. | UPDATE hospitals SET num_icu_beds = num_icu_beds * 1.1 WHERE state IN ('Illinois', 'Michigan') AND location = 'Urban' | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(255)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO customers (id, name) VALUES (1, 'Jane Smith'); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (1, 1, 500.00, '2022-01-01'); INSER... | Find the top 5 customers by total transaction amount in the last quarter. | SELECT c.name, SUM(t.amount) as total_amount FROM customers c JOIN transactions t ON c.id = t.customer_id WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY c.name ORDER BY total_amount DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, supplier_id INT, certified TEXT); INSERT INTO products (product_id, product_name, supplier_id, certified) VALUES (1, 'Lipstick A', 1001, 'organic'), (2, 'Eye Shadow B', 1002, 'vegan'), (3, 'Mascara C', 1001, 'organic'), (4, 'Foundation D', 1003, 'cruelty-free'),... | Who are the top 2 suppliers of cosmetic products that are certified paraben-free? | SELECT s.supplier_name, COUNT(p.product_id) AS product_count FROM suppliers s JOIN products p ON s.supplier_id = p.supplier_id WHERE p.certified = 'paraben-free' GROUP BY s.supplier_name ORDER BY product_count DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Renewable_Energy_Projects (id INT, region VARCHAR(10), budget FLOAT, installed_capacity FLOAT); INSERT INTO Renewable_Energy_Projects (id, region, budget, installed_capacity) VALUES (1, 'Asia', 12000000, 5000), (2, 'Europe', 8000000, 6000), (3, 'Asia', 15000000, 7000); | What is the total installed capacity of renewable energy projects in Asia with a budget greater than $10 million? | SELECT SUM(installed_capacity) FROM Renewable_Energy_Projects WHERE region = 'Asia' AND budget > 10000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, ManufacturingCountry VARCHAR); | How many spacecraft have been manufactured in each country? | SELECT ManufacturingCountry, COUNT(*) FROM Spacecraft GROUP BY ManufacturingCountry; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, location TEXT, product TEXT, production_volume INT); INSERT INTO mines (id, name, location, product, production_volume) VALUES (1, 'Cerro Verde', 'Peru', 'Copper', 20000); | What is the average production volume of copper per mine in Peru? | SELECT AVG(production_volume) FROM mines WHERE location = 'Peru' AND product = 'Copper'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts_2 (id INT, customer_id INT, type VARCHAR(255), balance DECIMAL(10,2)); INSERT INTO accounts_2 (id, customer_id, type, balance) VALUES (1, 1, 'Checking', 5000.00), (2, 1, 'Savings', 10000.00), (3, 2, 'Checking', 2000.00), (4, 3, 'Savings', 8000.00), (5, 4, 'Checking', 7000.00), (6, 4, 'Savings', 30... | What are the names and account balances of customers who have more than one account with a balance greater than $5000? | SELECT DISTINCT a.customer_id, a.balance FROM accounts_2 a INNER JOIN (SELECT customer_id FROM accounts_2 WHERE balance > 5000 GROUP BY customer_id HAVING COUNT(*) > 1) b ON a.customer_id = b.customer_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (donor_name VARCHAR(255), donation_amount INT, donation_date DATE, team_name VARCHAR(255)); INSERT INTO Donations (donor_name, donation_amount, donation_date, team_name) VALUES ('John Doe', 500, '2020-01-01', 'Emergency Response Team'); | What was the total amount of donations received by the 'Emergency Response Team' in '2020'? | SELECT SUM(donation_amount) FROM Donations WHERE team_name = 'Emergency Response Team' AND YEAR(donation_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Region (RegionID INT, RegionName VARCHAR(100)); INSERT INTO Region VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE Program (ProgramID INT, ProgramName VARCHAR(100), RegionID INT, StartDate DATE, EndDate DATE); INSERT INTO Program VALUES (1, 'Energy Efficiency Program 1', 2), (2, '... | List all the energy efficiency programs in the 'South' region, along with their start and end dates, if applicable. | SELECT ProgramName, RegionName, StartDate, EndDate FROM Program JOIN Region ON Program.RegionID = Region.RegionID WHERE RegionName = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (Id INT, Name VARCHAR(50), StartDate DATE, EndDate DATE, State VARCHAR(50), SustainabilityCost FLOAT); INSERT INTO Projects (Id, Name, StartDate, EndDate, State, SustainabilityCost) VALUES (1, 'Green Building', '2020-01-01', '2020-06-01', 'New York', 50000); | What is the total cost of sustainable building practices in New York? | SELECT SUM(SustainabilityCost) AS TotalSustainabilityCost FROM Projects WHERE State = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (name TEXT, state TEXT); INSERT INTO Bridges (name, state) VALUES ('St. Anthony Falls Bridge', 'Minnesota'); CREATE TABLE Dams (name TEXT, state TEXT); INSERT INTO Dams (name, state) VALUES ('Minnehaha Creek Dam', 'Minnesota'); | What is the number of bridges and the number of dams in 'Minnesota'? | SELECT COUNT(*) FROM Bridges WHERE state = 'Minnesota'; SELECT COUNT(*) FROM Dams WHERE state = 'Minnesota'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges_canada (country VARCHAR(50), name VARCHAR(50), length INT); INSERT INTO bridges_canada (country, name, length) VALUES ('Canada', 'Confederation Bridge', 13850), ('Canada', 'Port Mann Bridge', 2027); | Find the number of bridges and their total length in Canada, excluding the Confederation Bridge. | SELECT COUNT(*), SUM(length) FROM bridges_canada WHERE country = 'Canada' AND name != 'Confederation Bridge'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(255), continent VARCHAR(255)); CREATE VIEW continent_summary AS SELECT continent, COUNT(DISTINCT country_code) as num_countries FROM countries GROUP BY continent; | How many users have streamed music from each continent? | SELECT continent, COUNT(DISTINCT mus.country_code) as num_users FROM music_streams mus JOIN countries cnt ON mus.country_code = cnt.country_code GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Subscribers (SubscriberID INT, SubscriberType VARCHAR(20), DataUsage FLOAT, BillingCycle DATE); INSERT INTO Subscribers (SubscriberID, SubscriberType, DataUsage, BillingCycle) VALUES (1, 'Mobile', 3.5, '2021-06-01'); | What is the average data usage for postpaid mobile subscribers since January 2021? | SELECT AVG(DataUsage) as AvgDataUsage FROM Subscribers WHERE SubscriberType = 'Mobile' AND BillingCycle >= '2021-01-01' AND SubscriberType IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (id, name, category) VALUES (1, 'Hemp Hoodie', 'Clothing'); CREATE TABLE product_trends (id INT PRIMARY KEY, product_id INT, trend_score FLOAT, date DATE, FOREIGN KEY (product_id) REFERENCES products(id)); INSERT ... | Which products have had a decrease in trend score compared to the previous week? | SELECT p.name, pt1.trend_score AS prev_week_trend_score, pt2.trend_score AS this_week_trend_score FROM products p JOIN product_trends pt1 ON p.id = pt1.product_id JOIN product_trends pt2 ON p.id = pt2.product_id WHERE pt1.date = DATE_SUB(pt2.date, INTERVAL 1 WEEK) AND pt2.trend_score < pt1.trend_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy ( id INT PRIMARY KEY, location VARCHAR(255), project_name VARCHAR(255), installed_capacity INT ); INSERT INTO renewable_energy (id, location, project_name, installed_capacity) VALUES (1, 'Germany', 'Solarpark Finow Tower', 45000); INSERT INTO renewable_energy (id, location, project_name, i... | Calculate the total installed capacity of renewable energy projects for each location, excluding projects with installed capacity less than 40000 | SELECT location, SUM(installed_capacity) FROM renewable_energy WHERE installed_capacity >= 40000 GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_data (sector VARCHAR(20), capacity FLOAT); INSERT INTO landfill_data (sector, capacity) VALUES ('City', 500), ('City', 600), ('County', 700), ('County', 800), ('Private', 900); | Insert new landfill capacity data for the 'State' sector in the 'landfill_data' table. | INSERT INTO landfill_data (sector, capacity) VALUES ('State', 1100); | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT PRIMARY KEY, region VARCHAR(50), num_volunteers INT, event_date DATE); INSERT INTO events (event_id, region, num_volunteers, event_date) VALUES (1, 'Pacific', 75, '2019-01-01'), (2, 'Pacific', 30, '2019-02-03'), (3, 'Pacific', 50, '2019-03-05'), (4, 'Pacific', 60, '2019-04-01'); | What's the total number of events held in the Pacific region with more than 20 volunteers in 2019? | SELECT COUNT(*) FROM events WHERE region = 'Pacific' AND num_volunteers > 20 AND YEAR(event_date) = 2019; | 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.