context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE users (user_id INT PRIMARY KEY, username VARCHAR(255), location VARCHAR(255)); INSERT INTO users (user_id, username, location) VALUES (1, 'user1', 'NYC'), (2, 'user2', 'LA'), (3, 'user3', 'NYC'), (4, 'user4', 'SF');CREATE TABLE posts (post_id INT PRIMARY KEY, user_id INT, content TEXT); INSERT INTO posts (... | What is the most common word used in posts for each user in the social_media database? | SELECT users.username, REGEXP_SPLIT_TO_TABLE(REGEXP_REPLACE(posts.content, 'W+', ' '), ' ') AS word, COUNT(*) AS frequency FROM users INNER JOIN posts ON users.user_id = posts.user_id GROUP BY users.username, word ORDER BY users.username, frequency DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE bikeshare (station_id INT, city VARCHAR(20), num_bikes INT); INSERT INTO bikeshare (station_id, city, num_bikes) VALUES (1, 'San Francisco', 8), (2, 'San Francisco', 12), (3, 'San Francisco', 7); | How many bike-share stations in the city of San Francisco have less than 10 bikes available? | SELECT COUNT(*) FROM bikeshare WHERE city = 'San Francisco' AND num_bikes < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE epicquest_underrepresented_players (player_id INT, level INT, region VARCHAR(20), underrepresented_community VARCHAR(20)); INSERT INTO epicquest_underrepresented_players (player_id, level, region, underrepresented_community) VALUES (1, 25, 'North America', 'African American'), (2, 30, 'Europe', 'Female'), ... | What is the distribution of player levels in "EpicQuest" for players from historically underrepresented communities, grouped by region? | SELECT region, AVG(level) AS avg_level, MIN(level) AS min_level, MAX(level) AS max_level FROM epicquest_underrepresented_players GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(255), jersey_number INT); INSERT INTO players (id, name, jersey_number) VALUES (1, 'Kevin Durant', 7), (2, 'Stephen Curry', 30); | Update the jersey number for player 'Kevin Durant' to 35 | UPDATE players SET jersey_number = 35 WHERE name = 'Kevin Durant'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (ClaimID INT, PolicyholderName VARCHAR(50), ClaimDate DATE); INSERT INTO Claims VALUES (1, 'John Doe', '2019-01-01'); INSERT INTO Claims VALUES (2, 'Jane Smith', '2020-05-05'); INSERT INTO Claims VALUES (3, 'John Doe', '2021-12-31'); INSERT INTO Claims VALUES (4, 'Jim Brown', '2018-09-09'); | Delete all records from the Claims table that are older than 3 years. | DELETE FROM Claims WHERE ClaimDate < NOW() - INTERVAL '3 years'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TECH_UPDATES (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), year INT, country VARCHAR(255)); | What are the names and types of military technology that were updated in the year 2019 in the TECH_UPDATES table? | SELECT name, type FROM TECH_UPDATES WHERE year = 2019 AND country = (SELECT country FROM TECH_UPDATES WHERE name = (SELECT MAX(name) FROM TECH_UPDATES WHERE year = 2019) AND type = (SELECT MAX(type) FROM TECH_UPDATES WHERE year = 2019) LIMIT 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_emissions (id INT, country VARCHAR(255), co2_emissions INT, visit_date DATE); INSERT INTO tourism_emissions (id, country, co2_emissions, visit_date) VALUES (1, 'United States', 5000, '2022-01-01'), (2, 'China', 4000, '2022-03-15'), (3, 'India', 3000, '2022-06-01'), (4, 'Russia', 2500, '2022-04-01')... | What are the top 5 countries with the highest CO2 emissions from tourism? | SELECT country, SUM(co2_emissions) FROM tourism_emissions WHERE visit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY country ORDER BY SUM(co2_emissions) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (id INT, country VARCHAR(255), project VARCHAR(255), carbon_offsets INT); INSERT INTO carbon_offset_programs (id, country, project, carbon_offsets) VALUES (1, 'Canada', 'Project A', 2000), (2, 'Canada', 'Project B', 2500), (3, 'Canada', 'Project C', 3000); | What is the maximum carbon offset per project in the carbon offset program in Canada? | SELECT MAX(carbon_offsets) FROM carbon_offset_programs WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Chemical_Plant (plant_name VARCHAR(255), location VARCHAR(255), chemical VARCHAR(255), quantity INT);INSERT INTO Chemical_Plant (plant_name, location, chemical, quantity) VALUES ('Chemical Plant I', 'Alabama', 'Phosphoric Acid', 700), ('Chemical Plant J', 'Alabama', 'Nitric Acid', 800), ('Chemical Plant K'... | What are the names of the chemicals that are produced in both 'Alabama' and 'Louisiana' but not in 'Mississippi'? | SELECT chemical FROM Chemical_Plant WHERE location = 'Alabama' INTERSECT SELECT chemical FROM Chemical_Plant WHERE location = 'Louisiana' EXCEPT SELECT chemical FROM Chemical_Plant WHERE location = 'Mississippi'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_exploration (mission_name VARCHAR(50), mission_type VARCHAR(50), launch_date DATE, max_speed NUMERIC(8,2)); INSERT INTO space_exploration (mission_name, mission_type, launch_date, max_speed) VALUES ('Voyager 1', 'Flyby', '1977-09-05', 61000), ('Voyager 2', 'Flyby', '1977-08-20', 57000), ('Cassini', '... | What is the average speed of spacecraft in the "space_exploration" table, grouped by mission type? | SELECT mission_type, AVG(max_speed) OVER (PARTITION BY mission_type) AS avg_speed FROM space_exploration; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'Chicago', 'Chicago'), (2, 'Montreal', 'Montreal'); CREATE TABLE Handling (id INT, shipment_id INT, warehouse_id INT, pallets INT); INSERT INTO Handling (id, shipment_id, warehouse_id, pallets) VALUES ... | What is the total number of shipments that were handled by the 'Montreal' warehouse? | SELECT COUNT(*) FROM Handling JOIN Warehouse ON Handling.warehouse_id = Warehouse.id WHERE Warehouse.city = 'Montreal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name TEXT, state TEXT, transaction_amount DECIMAL); INSERT INTO customers (customer_id, name, state, transaction_amount) VALUES (1, 'John Doe', 'Texas', 50.00), (2, 'Jane Smith', 'California', 100.00); | What is the average transaction amount for customers living in Texas? | SELECT AVG(transaction_amount) FROM customers WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutoShows (name VARCHAR(20), year INT); INSERT INTO AutoShows (name, year) VALUES ('Tokyo Auto Salon', 2023); INSERT INTO AutoShows (name, year) VALUES ('Paris Motor Show', 2022); | List the auto show events that are not happening in 2023. | SELECT name FROM AutoShows WHERE year != 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (project_id INT, project_name VARCHAR(100), state VARCHAR(100), energy_efficiency_rating FLOAT); | What is the average energy efficiency rating for renewable energy projects in the state of Washington? | SELECT AVG(energy_efficiency_rating) FROM Projects WHERE state = 'Washington'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Initiatives (Initiative VARCHAR(50), Department VARCHAR(50), InsertDate DATE); INSERT INTO Initiatives (Initiative, Department, InsertDate) VALUES ('New Park', 'Urban Development', '2021-04-05'), ('Traffic Light Upgrade', 'Urban Development', '2021-06-12'), ('Waste Management Plan', 'Urban Development', '2... | How many 'Urban Development' initiatives were inserted into the database in Q2 of 2021? | SELECT COUNT(*) FROM Initiatives WHERE Department = 'Urban Development' AND InsertDate >= '2021-04-01' AND InsertDate < '2021-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Request (RequestID INT, RequestDate DATE, City VARCHAR(50), RequestType VARCHAR(50)); INSERT INTO Request (RequestID, RequestDate, City, RequestType) VALUES (1, '2021-01-01', 'San Francisco', 'Disability Support'); INSERT INTO Request (RequestID, RequestDate, City, RequestType) VALUES (2, '2021-02-15', 'Ne... | Determine the number of disability support requests received in each quarter of the year, for the past 2 years. | SELECT DATEPART(YEAR, RequestDate) AS Year, DATEPART(QUARTER, RequestDate) AS Quarter, COUNT(*) AS Requests FROM Request WHERE RequestType = 'Disability Support' AND RequestDate >= DATEADD(YEAR, -2, GETDATE()) GROUP BY DATEPART(YEAR, RequestDate), DATEPART(QUARTER, RequestDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainability_metrics (factory_id INT, energy_consumption FLOAT, measurement_date DATE); INSERT INTO sustainability_metrics (factory_id, energy_consumption, measurement_date) VALUES (1, 25000.5, '2021-09-01'), (2, 18000.3, '2021-09-01'), (3, 22000.0, '2021-02-01'); | What was the total energy consumption for each factory in the past 6 months, ordered from highest to lowest? | SELECT factory_id, SUM(energy_consumption) as six_month_energy FROM sustainability_metrics WHERE measurement_date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY factory_id ORDER BY six_month_energy DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (initiative VARCHAR(50), location VARCHAR(50), carbon_offset INT); INSERT INTO carbon_offsets (initiative, location, carbon_offset) VALUES ('Smart Grid', 'Seattle', 1000), ('Smart Grid', 'Portland', 1200), ('Smart Transit', 'Seattle', 1500), ('Smart Transit', 'Portland', 1800); | What is the average carbon offset for each smart city initiative, broken down by location? | SELECT initiative, location, AVG(carbon_offset) FROM carbon_offsets GROUP BY initiative, location; | gretelai_synthetic_text_to_sql |
CREATE TABLE EthicalBrands (id INT, brand VARCHAR, waste_kg INT); CREATE TABLE BrandWasteData (brand VARCHAR, year INT, waste_kg INT, is_recycled BOOLEAN); | What is the total waste generated by each ethical fashion brand in the past year, and what percentage of it is recycled? | SELECT e.brand, SUM(e.waste_kg) as total_waste, 100.0 * AVG(CAST(bw.is_recycled AS FLOAT)) as recycled_percentage FROM EthicalBrands e JOIN BrandWasteData bw ON e.brand = bw.brand WHERE bw.year = YEAR(CURRENT_DATE()) - 1 GROUP BY e.brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_gender (fan_id INT, gender VARCHAR(10), ticket_type VARCHAR(10)); | Show the percentage of female fans who purchased season tickets | SELECT ((SUM(CASE WHEN gender = 'female' THEN 1 ELSE 0 END) / COUNT(*)) * 100) AS percentage FROM fan_gender WHERE ticket_type = 'season'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10), Rural BOOLEAN, Disease VARCHAR(20)); INSERT INTO Patients (PatientID, Age, Gender, Rural, Disease) VALUES (1, 34, 'Male', TRUE, 'Diabetes'), (2, 55, 'Female', FALSE, 'Diabetes'); | What is the average age of rural male patients with diabetes? | SELECT AVG(Age) FROM Patients WHERE Rural = TRUE AND Gender = 'Male' AND Disease = 'Diabetes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Support_Programs (program_id INT, region VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO Support_Programs (program_id, region, start_date, end_date) VALUES (1, 'Midwest', '2019-01-01', '2019-12-31'), (2, 'Northeast', '2018-12-01', '2020-01-01'); | How many support programs were offered in the "Midwest" region in 2019? | SELECT COUNT(*) FROM Support_Programs WHERE region = 'Midwest' AND EXTRACT(YEAR FROM start_date) = 2019 AND EXTRACT(YEAR FROM end_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), city VARCHAR(50)); INSERT INTO teams (team_id, team_name, city) VALUES (1, 'Atlanta Hawks', 'Atlanta'); INSERT INTO teams (team_id, team_name, city) VALUES (2, 'Boston Celtics', 'Boston'); | What are the top 5 cities with the highest average ticket sales for home games across all teams? | SELECT city, AVG(ticket_sales) as avg_ticket_sales FROM games JOIN teams ON games.team_id = teams.team_id GROUP BY city ORDER BY avg_ticket_sales DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, Name TEXT, Type TEXT, YearBuilt INT); INSERT INTO Vessels VALUES (1, 'Tanker 1', 'Oil Tanker', 2000), (2, 'Cargo Ship 1', 'Cargo Ship', 2010); | What is the average age of vessels in the registry? | SELECT AVG(YEAR(CURRENT_DATE) - Vessels.YearBuilt) FROM Vessels; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_engineering (menu_item_id INT, menu_item_name VARCHAR(255), restaurant_id INT, revenue DECIMAL(10,2), transaction_date DATE); INSERT INTO menu_engineering (menu_item_id, menu_item_name, restaurant_id, revenue, transaction_date) VALUES (1, 'Margherita Pizza', 1, 3000, '2022-01-01'), (2, 'Guacamole', 2,... | List the top 3 menu items by revenue for each restaurant in Q1 2022. | SELECT restaurant_id, menu_item_name, SUM(revenue) as total_revenue FROM menu_engineering WHERE transaction_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY restaurant_id, menu_item_name HAVING COUNT(*) <= 3 ORDER BY restaurant_id, total_revenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ChargingStations(id INT, city VARCHAR(20), state VARCHAR(20), quantity INT); | What is the number of electric vehicle charging stations in each city in Germany? | SELECT city, COUNT(*) as quantity FROM ChargingStations WHERE state = 'Germany' GROUP BY city ORDER BY quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (id INT, city VARCHAR(255), year INT, num_stations INT); INSERT INTO charging_stations (id, city, year, num_stations) VALUES (1, 'New York', 2018, 300), (2, 'Los Angeles', 2019, 400); | How many electric vehicle charging stations were installed in New York and Los Angeles before 2020? | SELECT SUM(num_stations) FROM charging_stations WHERE city IN ('New York', 'Los Angeles') AND year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Union_Membership (Union_Name VARCHAR(255), Members_2019 INT, Members_2020 INT); INSERT INTO Union_Membership (Union_Name, Members_2019, Members_2020) VALUES ('UnionA', 5000, 5500), ('UnionB', 6000, 6200), ('UnionC', 4500, 4000); | List all unions that have increased their membership by more than 10% since 2019, sorted by the percentage increase. | SELECT Union_Name, ((Members_2020 - Members_2019) * 100.0 / Members_2019) as Percentage_Increase FROM Union_Membership WHERE ((Members_2020 - Members_2019) * 100.0 / Members_2019) > 10 ORDER BY Percentage_Increase DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE municipalities (id INT, name VARCHAR(255), population INT); INSERT INTO municipalities (id, name, population) VALUES (1, 'CityA', 50000), (2, 'CityB', 75000), (3, 'CityC', 100000), (4, 'CityD', 125000), (5, 'CityE', 150000), (6, 'CityF', 175000), (7, 'CityG', 200000); CREATE TABLE waste_generation (municip... | What is the daily waste generation for the top 5 municipalities with the highest population? | SELECT municipality_id, date, generation FROM (SELECT municipality_id, date, generation, ROW_NUMBER() OVER (PARTITION BY municipality_id ORDER BY generation DESC) as rn FROM waste_generation) t WHERE rn <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects_emea (id INT, region VARCHAR(50), investment FLOAT); INSERT INTO projects_emea (id, region, investment) VALUES (1, 'EMEA', 500000); INSERT INTO projects_emea (id, region, investment) VALUES (2, 'EMEA', 750000); | What is the minimum investment required for any project in the EMEA region? | SELECT MIN(investment) FROM projects_emea WHERE region = 'EMEA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE documentaries (id INT, title VARCHAR(255), duration INT, topic VARCHAR(255)); INSERT INTO documentaries (id, title, duration, topic) VALUES (1, 'Doc1', 90, 'Indigenous Culture'), (2, 'Doc2', 120, 'Nature'), (3, 'Doc3', 100, 'Indigenous Culture'); | What is the total duration of all documentaries about Indigenous cultures? | SELECT SUM(duration) FROM documentaries WHERE topic = 'Indigenous Culture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Clients (ClientID INT, Age INT, Gender VARCHAR(10), Income FLOAT, WonCase BOOLEAN); CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50)); | What is the average income of clients who have won cases, grouped by their respective attorneys? | SELECT A.Name, AVG(C.Income) AS AverageIncome FROM Clients C INNER JOIN Attorneys A ON C.AttorneyID = A.AttorneyID WHERE C.WonCase = TRUE GROUP BY A.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, FairTrade BOOLEAN, QuantitySold INT); INSERT INTO Products (ProductID, ProductName, Price, FairTrade, QuantitySold) VALUES (1, 'Product1', 15.99, true, 10), (2, 'Product2', 12.49, false, 20), (3, 'Product3', 20.99, true, 15), (4, 'Product4', 10.99, ... | What is the total revenue of fair trade products? | SELECT SUM(Price * QuantitySold) FROM Products WHERE FairTrade = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (service text, date date, amount int); INSERT INTO revenue (service, date, amount) VALUES ('subway', '2023-01-01', 5000), ('bus', '2023-01-02', 6000), ('subway', '2023-02-01', 7000), ('bus', '2023-02-02', 8000), ('subway', '2023-03-01', 9000), ('bus', '2023-03-02', 10000); | What is the total revenue for each service in the first quarter of 2023? | SELECT service, SUM(amount) FROM revenue WHERE date BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY service; | gretelai_synthetic_text_to_sql |
CREATE TABLE sponsored_posts (id INT, category VARCHAR(50), revenue FLOAT); INSERT INTO sponsored_posts (id, category, revenue) VALUES (1, 'gaming', 100.50), (2, 'sports', 150.25), (3, 'gaming', 200.75); | What is the total revenue generated from sponsored posts in the gaming category? | SELECT SUM(revenue) FROM sponsored_posts WHERE category = 'gaming'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name TEXT, diversity_reported INT); INSERT INTO Companies (id, name, diversity_reported) VALUES (1, 'Tech Start', 1), (2, 'Green Visions', 0); CREATE TABLE Investment_Rounds (id INT, company_name TEXT); INSERT INTO Investment_Rounds (id, company_name) VALUES (1, 'Tech Start'); | Delete companies that have not reported diversity metrics and have no investments. | DELETE FROM Companies WHERE diversity_reported = 0 AND id NOT IN (SELECT company_name FROM Investment_Rounds); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetic_research;CREATE TABLE if not exists genetic_research.projects(id INT, name TEXT, lead_researcher TEXT, disease_category TEXT);INSERT INTO genetic_research.projects (id, name, lead_researcher, disease_category) VALUES (1, 'ProjectX', 'Dr. Jane Smith', 'Cancer'), (2, 'ProjectY', 'Dr. J... | Who are the lead researchers for the neurological disorder related projects? | SELECT lead_researcher FROM genetic_research.projects WHERE disease_category = 'Neurological Disorders'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.shared_mobility(id serial PRIMARY KEY, city varchar(255), mode varchar(255), num_vehicles int); | Which city has the highest number of shared bicycles? | SELECT city, MAX(num_vehicles) FROM public.shared_mobility WHERE mode = 'Bicycle' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), country_id INT, co2_emissions INT); | What is the total CO2 emissions for makeup products by country? | SELECT c.country_name, SUM(p.co2_emissions) as total_co2_emissions FROM countries c INNER JOIN products p ON c.country_id = p.country_id WHERE p.product_name LIKE '%makeup%' GROUP BY c.country_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post TEXT, date DATE); INSERT INTO posts (id, user_id, post, date) VALUES (1, 1, 'I am going to vote today', '2022-03-23'), (2, 2, 'I voted yesterday', '2022-03-24'), (3, 3, 'I will vote next week', '2022-03-25'); CREATE TABLE users (id INT, region VARCHAR(255)); INSERT INTO use... | What is the total number of users who have posted a message containing the word 'vote' in the last week, broken down by region? | SELECT COUNT(DISTINCT user_id) AS users_posted_vote, region FROM posts INNER JOIN users ON posts.user_id = users.id WHERE post LIKE '%vote%' AND date >= DATE(NOW()) - INTERVAL 1 WEEK GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, arrival_date DATE, port_id VARCHAR(5)); INSERT INTO shipments (id, arrival_date, port_id) VALUES (1001, '2022-01-03', 'P01'), (1002, '2022-01-15', 'P03'), (1003, '2022-02-01', 'P03'); CREATE TABLE ports (id VARCHAR(5), name VARCHAR(10)); INSERT INTO ports (id, name) VALUES ('P01', 'Port ... | How many shipments arrived at port 'P03' in January 2022? | SELECT COUNT(*) FROM shipments WHERE MONTH(arrival_date) = 1 AND port_id = 'P03'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, YearsOfExperience INT, Specialization VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization) VALUES (1, 12, 'Civil Law'), (2, 5, 'Criminal Law'), (3, 8, 'Family Law'), (4, 15, 'Family Law'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, CaseOpenDat... | What is the average number of cases handled per year by attorneys with more than 5 years of experience? | SELECT AVG(DATEDIFF(CaseCloseDate, CaseOpenDate) / YearsOfExperience) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE YearsOfExperience > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (type VARCHAR(20), capacity INT); INSERT INTO energy_storage (type, capacity) VALUES ('Batteries', 50000), ('Pumped Hydro', 75000), ('Thermal', 30000), ('Flywheels', 10000), ('CAES', 20000); | What is the total energy storage capacity for each type of energy storage? | SELECT type, SUM(capacity) FROM energy_storage GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_data (year INT, element TEXT, production_quantity FLOAT); INSERT INTO production_data (year, element, production_quantity) VALUES (2018, 'Europium', 120); INSERT INTO production_data (year, element, production_quantity) VALUES (2019, 'Europium', 150); INSERT INTO production_data (year, element, ... | Find the total production quantity (in metric tons) of Europium for 2018 and 2019. | SELECT SUM(production_quantity) FROM production_data WHERE element = 'Europium' AND year IN (2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE canada_shipments (id INT, cargo_weight INT, destination VARCHAR(20), shipment_date DATE); INSERT INTO canada_shipments (id, cargo_weight, destination, shipment_date) VALUES (1, 12000, 'Canada', '2021-02-02'); INSERT INTO canada_shipments (id, cargo_weight, destination, shipment_date) VALUES (2, 15000, 'Can... | What is the total cargo weight for shipments to Canada in February 2021? | SELECT SUM(cargo_weight) FROM canada_shipments WHERE destination = 'Canada' AND shipment_date >= '2021-02-01' AND shipment_date < '2021-03-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(30), genre VARCHAR(20), rating INT); | What is the average rating of artworks in the 'Impressionism' genre, excluding artworks with a rating of 0, and also show the total number of artworks in this genre? | SELECT AVG(Artwork.rating) AS avg_rating, COUNT(Artwork.artwork_id) AS total_artworks FROM Artwork WHERE Artwork.genre = 'Impressionism' AND Artwork.rating > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE exoplanets (mission VARCHAR(255), count INT); INSERT INTO exoplanets (mission, count) VALUES ('Kepler', 2326), ('CoRoT', 32), ('Hubble', 4), ('Spitzer', 7), ('K2', 428); | What is the total number of exoplanets discovered by the Kepler mission? | SELECT SUM(count) FROM exoplanets WHERE mission = 'Kepler'; | gretelai_synthetic_text_to_sql |
CREATE TABLE account_lockouts (id INT, user VARCHAR(255), lockout_count INT, lockout_date DATE); | Which users have been locked out of their accounts more than 3 times in the past day? | SELECT user FROM account_lockouts WHERE lockout_count > 3 AND lockout_date >= DATEADD(day, -1, GETDATE()) GROUP BY user HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE TextileSourcing (FabricType VARCHAR(255), Quantity INT, IsSustainable BOOLEAN); INSERT INTO TextileSourcing (FabricType, Quantity, IsSustainable) VALUES ('Organic Cotton', 1200, TRUE), ('Recycled Polyester', 800, TRUE), ('Tencel', 1500, TRUE), ('Virgin Polyester', 1000, FALSE), ('Conventional Cotton', 2000... | Show the total quantity of sustainable and non-sustainable fabric types used in all clothing items. | SELECT IsSustainable, SUM(Quantity) FROM TextileSourcing GROUP BY IsSustainable; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitor_statistics (id INT PRIMARY KEY, country VARCHAR(50), year INT, month INT, visitors INT); | Create a view for the international visitor statistics by month | CREATE VIEW visitor_statistics_by_month AS SELECT country, year, month, SUM(visitors) AS total_visitors FROM visitor_statistics GROUP BY country, year, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Survey_Responses(City VARCHAR(20), Age INT, Satisfaction INT); INSERT INTO Survey_Responses(City, Age, Satisfaction) VALUES('Toronto', 30, 8); INSERT INTO Survey_Responses(City, Age, Satisfaction) VALUES('Toronto', 40, 7); INSERT INTO Survey_Responses(City, Age, Satisfaction) VALUES('Montreal', 25, 9); INS... | What is the average satisfaction score for residents aged 20-40 in each city? | SELECT City, AVG(Satisfaction) FROM Survey_Responses WHERE Age BETWEEN 20 AND 40 GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers(id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO manufacturers(id, name, country) VALUES (1, 'ABC Manufacturing', 'China'), (2, 'XYZ Manufacturing', 'Bangladesh'), (3, 'LMN Manufacturing', 'India'); | Delete all records from the 'manufacturers' table where the country is 'China' | DELETE FROM manufacturers WHERE country = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artifact_catalog (artifact_id INT, site_id INT, artifact_type TEXT, artifact_description TEXT, quantity INT); INSERT INTO artifact_catalog (artifact_id, site_id, artifact_type, artifact_description, quantity) VALUES (1, 1, 'ceramic', 'small bowl', 25), (2, 1, 'metal', 'copper pin', 10), (3, 1, 'bone', 'ani... | What is the minimum and maximum quantity of ceramic artifacts at Site G? | SELECT MIN(quantity), MAX(quantity) FROM artifact_catalog WHERE site_id = 7 AND artifact_type = 'ceramic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE staff (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), role VARCHAR(50), hire_date DATE); | Add a new record for a staff member into the 'staff' table | INSERT INTO staff (id, first_name, last_name, role, hire_date) VALUES (1, 'John', 'Doe', 'Wildlife Biologist', '2020-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE City_EV_Adoption (id INT, city VARCHAR(50), ev_adoption DECIMAL(5,2)); | What is the average adoption rate of electric vehicles in each city? | SELECT city, AVG(ev_adoption) FROM City_EV_Adoption GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(50), data_usage FLOAT, usage_date DATE); INSERT INTO customers (customer_id, name, region, data_usage, usage_date) VALUES (1, 'John Doe', 'North', 45.6, '2022-01-01'), (2, 'Jane Smith', 'South', 30.9, '2022-02-01'), (3, 'Mike Johnson', 'East', 60... | What is the average data usage, in GB, for customers in each region, in the last 6 months? | SELECT r.region_name, AVG(c.data_usage) as avg_data_usage FROM customers c JOIN regions r ON c.region = r.region_name WHERE c.usage_date >= DATEADD(month, -6, GETDATE()) GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE agencies (agency VARCHAR(255)); INSERT INTO agencies (agency) VALUES ('NSA'), ('CIA'), ('FBI'), ('CSS'); CREATE VIEW agency_data AS SELECT a.agency, d.incident_count INTEGER FROM agencies a CROSS JOIN (SELECT 10 AS incident_count UNION ALL SELECT 15 UNION ALL SELECT 20 UNION ALL SELECT 25) d; | How many cybersecurity incidents were reported by each national security agency in the 'agency_data' table? | SELECT a.agency, SUM(d.incident_count) FROM agencies a INNER JOIN agency_data d ON 1=1 GROUP BY a.agency; | gretelai_synthetic_text_to_sql |
CREATE TABLE model_fairness (model_id INT, fairness_score DECIMAL(3,2)); INSERT INTO model_fairness (model_id, fairness_score) VALUES (1, 0.85), (2, 0.70), (3, 0.92), (4, 0.68), (5, 0.55); | Show the names and fairness scores of models, excluding any models with a fairness score less than 0.7. | SELECT model_id, fairness_score FROM model_fairness WHERE fairness_score >= 0.7; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_services (city VARCHAR(20), service VARCHAR(20), budget INT); INSERT INTO city_services (city, service, budget) VALUES ('Tokyo', 'Waste Management', 3000000); | What is the maximum budget allocated for waste management in the city of Tokyo? | SELECT MAX(budget) FROM city_services WHERE city = 'Tokyo' AND service = 'Waste Management'; | gretelai_synthetic_text_to_sql |
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT, location TEXT); INSERT INTO well_production (well_id, measurement_date, production_rate, location) VALUES (1, '2022-01-01', 500, 'Niger Delta'), (2, '2022-02-01', 700, 'Gulf of Mexico'), (3, '2022-03-01', 600, 'Siberia'); | Calculate the total production in the Niger Delta for the last 12 months. | SELECT SUM(production_rate) FROM well_production WHERE location = 'Niger Delta' AND measurement_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE platforms (id INT PRIMARY KEY, name VARCHAR(255), url VARCHAR(255)); INSERT INTO platforms (id, name, url) VALUES (1, 'VTravel', 'www.vtravel.com'); INSERT INTO platforms (id, name, url) VALUES (2, 'Culture360', 'www.culture360.org'); | Update the name of the virtual tourism platform 'VTravel' in the 'platforms' table | UPDATE platforms SET name = 'Virtual VTravel' WHERE name = 'VTravel'; | gretelai_synthetic_text_to_sql |
CREATE TABLE program_categories (id INT, program_category VARCHAR(255), funding_year INT, amount DECIMAL(10, 2)); | What is the percentage of funding by program category in 2022? | SELECT program_category, (amount / SUM(amount) OVER (PARTITION BY funding_year)) * 100 AS funding_percentage FROM program_categories WHERE funding_year = 2022 ORDER BY funding_percentage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE forestry.harvested_trees (id INT, species VARCHAR(50), volume FLOAT); | Find the top 3 species with the highest timber production in 'forestry' DB. | SELECT species, SUM(volume) AS total_volume FROM forestry.harvested_trees GROUP BY species ORDER BY total_volume DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, hashtags TEXT, post_date DATE); | What is the total number of posts containing the hashtag #music, by users from the United Kingdom, in the last week? | SELECT COUNT(*) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'United Kingdom' AND hashtags LIKE '%#music%' AND post_date >= DATE(NOW()) - INTERVAL 1 WEEK; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (region VARCHAR(20), project_cost INT); INSERT INTO Projects (region, project_cost) VALUES ('Northeast', 5000000), ('Southeast', 7000000), ('Midwest', 6000000), ('Southwest', 8000000), ('West', 9000000); | What is the maximum project cost in each region? | SELECT region, MAX(project_cost) FROM Projects GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, revenue) VALUES (1, 'Asian Fusion', 'New York', 50000.00), (2, 'Bella Italia', 'Los Angeles', 60000.00), (3, 'Sushi House', 'New York', 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 800... | Identify cities with only one restaurant. | SELECT city FROM Restaurants GROUP BY city HAVING COUNT(*) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (name TEXT, location TEXT, capacity_MW INTEGER); INSERT INTO solar_plants (name, location, capacity_MW) VALUES ('Plant A', 'Country W', 50), ('Plant B', 'Country V', 75), ('Plant C', 'Country W', 100); | Which solar plants are located in Country W? | SELECT * FROM solar_plants WHERE location = 'Country W'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing (id INT, garment_type VARCHAR(20), sustainable BOOLEAN, country VARCHAR(20), quantity INT, year INT); INSERT INTO Manufacturing (id, garment_type, sustainable, country, quantity, year) VALUES (1, 'Dress', TRUE, 'Vietnam', 300, 2022), (2, 'Shirt', FALSE, 'Vietnam', 450, 2022), (3, 'Pant', TRUE... | Calculate the total quantity of eco-friendly garments produced in Vietnam in 2022. | SELECT SUM(quantity) as total_quantity FROM Manufacturing WHERE sustainable = TRUE AND country = 'Vietnam' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_sequestration (year INT, tree_type VARCHAR(255), region VARCHAR(255), sequestration_rate FLOAT); | update the carbon_sequestration table to reflect a carbon sequestration rate of 5 tons per hectare for pine in the year 2020 | UPDATE carbon_sequestration SET sequestration_rate = 5 WHERE tree_type = 'Pine' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands(brand_id INT, brand_name TEXT); INSERT INTO brands(brand_id, brand_name) VALUES (1, 'BrandA'), (2, 'BrandB'), (3, 'BrandC'); CREATE TABLE products(product_id INT, brand_id INT, material TEXT); INSERT INTO products(product_id, brand_id, material) VALUES (1, 1, 'organic cotton'), (2, 1, 'polyester'), ... | What is the percentage of 'organic cotton' products out of the total products for each brand? | SELECT brand_id, brand_name, (COUNT(CASE WHEN material = 'organic cotton' THEN 1 END) * 100.0 / COUNT(*)) as percentage FROM brands b JOIN products p ON b.brand_id = p.brand_id GROUP BY brand_id, brand_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment(plant_id INT, city VARCHAR(50), country VARCHAR(50), year INT, treated_water_volume FLOAT, total_water_volume FLOAT); INSERT INTO wastewater_treatment(plant_id, city, country, year, treated_water_volume, total_water_volume) VALUES (1, 'Toronto', 'Canada', 2019, 5000000, 8000000), (2, '... | What is the percentage of wastewater treated by plants in Toronto, Canada for 2019? | SELECT city, (SUM(treated_water_volume) / SUM(total_water_volume)) * 100 FROM wastewater_treatment WHERE city = 'Toronto' AND country = 'Canada' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_status (name VARCHAR(50), status VARCHAR(50)); INSERT INTO conservation_status (name, status) VALUES ('Blue Whale', 'Endangered'), ('Hawksbill Turtle', 'Critically Endangered'), ('Fin Whale', 'Endangered'), ('Leatherback Turtle', 'Vulnerable'), ('Humpback Whale', 'Least Concern'); | Which marine species are threatened or endangered? | SELECT name FROM conservation_status WHERE status = 'Endangered' OR status = 'Critically Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (facility_id INT, condition VARCHAR(50)); | Count total mental health conditions treated across all facilities. | SELECT COUNT(DISTINCT condition) as total_conditions FROM facilities; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_prices (id INT, region VARCHAR(50), price FLOAT, date DATE); INSERT INTO energy_prices (id, region, price, date) VALUES (1, 'North', 55.7, '2022-03-01'); | What is the average energy price for the 'North' region in March 2022? | SELECT region, AVG(price) AS avg_price FROM energy_prices WHERE date BETWEEN '2022-03-01' AND '2022-03-31' AND region = 'North' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE adaptation_projects (country VARCHAR(50), year INT, co2_reduction FLOAT); INSERT INTO adaptation_projects (country, year, co2_reduction) VALUES ('China', 2019, 1200000), ('India', 2019, 1500000); | What is the total CO2 emissions reduction from climate adaptation projects in Asia in 2019? | SELECT SUM(co2_reduction) FROM adaptation_projects WHERE country IN ('China', 'India') AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_providers (id INT, name VARCHAR(50), location VARCHAR(50), cultural_competency_score INT); INSERT INTO mental_health_providers (id, name, location, cultural_competency_score) VALUES (1, 'Dr. Jane Doe', 'Urban', 85), (2, 'Dr. John Smith', 'Suburban', 70), (3, 'Dr. Maria Garcia', 'Urban', 90), ... | What is the average cultural competency score for mental health providers who work in urban areas, and how many of them have a score above 80? | SELECT AVG(cultural_competency_score), COUNT(*) FROM mental_health_providers WHERE location = 'Urban' AND cultural_competency_score > 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_data (id INT, country TEXT, visit_date DATE); INSERT INTO tourism_data (id, country, visit_date) VALUES (1, 'New Zealand', '2022-01-01'), (2, 'New Zealand', '2022-02-15'), (3, 'Australia', '2022-03-01'); | How many tourists visited New Zealand in each month of 2022? | SELECT visit_date, COUNT(*) AS num_visitors FROM tourism_data WHERE country = 'New Zealand' AND visit_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY visit_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_projects (id INT PRIMARY KEY, city VARCHAR(255), state VARCHAR(255), total_cost FLOAT); | What was the total cost of the construction projects in the city of Seattle in 2020? | SELECT SUM(total_cost) FROM construction_projects WHERE city = 'Seattle' AND YEAR(project_start_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE reader_demographics (id INT, age INT, country VARCHAR(50), topic VARCHAR(50)); INSERT INTO reader_demographics (id, age, country, topic) VALUES (1, 35, 'Brazil', 'Technology'); INSERT INTO reader_demographics (id, age, country, topic) VALUES (2, 42, 'Canada', 'Politics'); | What is the average age of readers who prefer technology news in Brazil? | SELECT AVG(age) FROM reader_demographics WHERE country = 'Brazil' AND topic = 'Technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment_sales (country TEXT, sale_date DATE); INSERT INTO military_equipment_sales (country, sale_date) VALUES ('Canada', '2021-07-15'), ('Australia', '2022-02-03'), ('Germany', '2021-12-21'), ('Japan', '2022-03-09'), ('Mexico', '2022-06-17'), ('Brazil', '2022-02-28'), ('South Korea', '2022-04-0... | Identify the total number of countries with military equipment purchases from the US in the last 18 months | SELECT COUNT(DISTINCT country) as unique_countries FROM military_equipment_sales WHERE sale_date >= (SELECT CURRENT_DATE - INTERVAL '18 months'); | gretelai_synthetic_text_to_sql |
CREATE TABLE expedition (org VARCHAR(20), species VARCHAR(50)); INSERT INTO expedition VALUES ('Ocean Explorer', 'Dolphin'), ('Ocean Explorer', 'Tuna'), ('Sea Discoverers', 'Shark'), ('Sea Discoverers', 'Whale'), ('Marine Investigators', 'Starfish'), ('Marine Investigators', 'Jellyfish'), ('Marine Investigators', 'Cora... | What is the total number of unique marine species observed by expeditions for the 'Marine Investigators' organization? | SELECT COUNT(DISTINCT species) FROM expedition WHERE org = 'Marine Investigators'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory(id INT, material VARCHAR(255), quantity INT); CREATE TABLE products(id INT, material VARCHAR(255), quantity INT); INSERT INTO inventory(id, material, quantity) VALUES (1, 'organic cotton', 75), (2, 'conventional cotton', 100), (3, 'organic cotton', 30), (4, 'hemp', 60); INSERT INTO products(id, m... | Which materials in the 'inventory' table have a quantity of at least 100 and are used in the production of at least one product in the 'products' table? | SELECT i.material FROM inventory i INNER JOIN products p ON i.material = p.material WHERE i.quantity >= 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), country VARCHAR(255), ethical_certification VARCHAR(255)); | Update the country of a supplier in the "suppliers" table | UPDATE suppliers SET country = 'Colombia' WHERE supplier_id = 2001; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (id INT, policy_name TEXT, state TEXT); INSERT INTO CulturalCompetency (id, policy_name, state) VALUES (1, 'Diversity Act 2020', 'California'); INSERT INTO CulturalCompetency (id, policy_name, state) VALUES (2, 'Inclusion Act 2018', 'California'); | List all cultural competency policies in California. | SELECT * FROM CulturalCompetency WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation_sectors (project_id INT, sector TEXT, region TEXT, amount FLOAT); INSERT INTO climate_adaptation_sectors (project_id, sector, region, amount) VALUES (1, 'Coastal Protection', 'North America', 1000000); INSERT INTO climate_adaptation_sectors (project_id, sector, region, amount) VALUES (2,... | Which climate adaptation sectors received the least funding in North America? | SELECT sector, MIN(amount) FROM climate_adaptation_sectors WHERE region = 'North America' GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE Causes (Cause TEXT); CREATE TABLE Donations (DonationID INT, DonationAmount INT, Cause TEXT); INSERT INTO Causes (Cause) VALUES ('Environment'), ('Health'), ('Education'); INSERT INTO Donations (DonationID, DonationAmount, Cause) VALUES (1, 5000, 'Environment'), (2, 7000, 'Health'), (3, 3000, 'Environment'... | What is the total donation amount and average donation amount for each cause? | SELECT Cause, SUM(DonationAmount) AS TotalDonationAmount, AVG(DonationAmount) AS AverageDonationAmount FROM Donations GROUP BY Cause; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_manufacturing (model VARCHAR(50), quantity INT); INSERT INTO aircraft_manufacturing (model, quantity) VALUES ('F-35', 1200), ('F-16', 800), ('F-22', 400); CREATE TABLE material_costs (model VARCHAR(50), cost DECIMAL(10,2)); INSERT INTO material_costs (model, cost) VALUES ('F-35', 120000.00), ('F-1... | Calculate the total cost of materials for each aircraft model, including joined data from the 'aircraft_manufacturing' and 'material_costs' tables. | SELECT am.model, SUM(mc.cost * am.quantity) AS total_cost FROM aircraft_manufacturing am INNER JOIN material_costs mc ON am.model = mc.model GROUP BY am.model; | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_matches (match_id INT, season INT, tickets_sold INT); INSERT INTO soccer_matches (match_id, season, tickets_sold) VALUES (1, 2018, 25000), (2, 2018, 28000), (3, 2019, 32000); | What is the average number of tickets sold for soccer matches per season? | SELECT AVG(tickets_sold) FROM soccer_matches GROUP BY season; | gretelai_synthetic_text_to_sql |
CREATE TABLE ad_campaigns (id INT, title VARCHAR(50), objective VARCHAR(50), budget DECIMAL(10, 2), start_date DATE, end_date DATE); INSERT INTO ad_campaigns (id, title, objective, budget, start_date, end_date) VALUES (1, 'Sample Campaign', 'Awareness', 5000, '2021-07-01', '2021-07-31'), (2, 'Another Campaign', 'Consid... | What is the average daily budget for ad sets grouped by campaign title? | SELECT ad_campaigns.title, AVG(ad_sets.daily_budget) as avg_daily_budget FROM ad_campaigns JOIN ad_sets ON ad_campaigns.id = ad_sets.campaign_id GROUP BY ad_campaigns.title; | gretelai_synthetic_text_to_sql |
CREATE TABLE SeaIceExtent (id INT, month INT, extent DECIMAL(5,2), date DATE); INSERT INTO SeaIceExtent (id, month, extent, date) VALUES (1, 1, 14.5, '2021-01-01'); INSERT INTO SeaIceExtent (id, month, extent, date) VALUES (2, 12, 11.0, '2021-12-31'); | What is the minimum and maximum sea ice extent in the Arctic Ocean for each month in 2021? | SELECT month, MIN(extent) AS min_extent, MAX(extent) AS max_extent FROM SeaIceExtent WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(255), community_identifier VARCHAR(255)); CREATE TABLE ArtistPrograms (program_id INT, artist_id INT, participant_role VARCHAR(255)); | Delete records of artists who have not participated in any programs. | DELETE FROM Artists WHERE artist_id NOT IN (SELECT artist_id FROM ArtistPrograms); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_for_good (id INT, region VARCHAR(255), year INT, budget DECIMAL(10,2)); INSERT INTO ai_for_good (id, region, year, budget) VALUES (1, 'Asia', 2021, 400000.00); INSERT INTO ai_for_good (id, region, year, budget) VALUES (2, 'Europe', 2021, 500000.00); | What is the total budget for all AI for good projects in Asia in 2021? | SELECT SUM(budget) FROM ai_for_good WHERE region = 'Asia' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Branches (id INT, branch VARCHAR(50)); INSERT INTO Military_Branches (id, branch) VALUES (1, 'Army'); INSERT INTO Military_Branches (id, branch) VALUES (2, 'Navy'); | What are the names of the military branches in the 'Military_Branches' table? | SELECT DISTINCT branch FROM Military_Branches; | gretelai_synthetic_text_to_sql |
CREATE TABLE Species_Year (Species_Name TEXT, Year INT, Fish_Weight FLOAT); INSERT INTO Species_Year (Species_Name, Year, Fish_Weight) VALUES ('Salmon', 2019, 400000), ('Trout', 2019, 300000), ('Shrimp', 2019, 600000), ('Salmon', 2020, 500000), ('Trout', 2020, 350000), ('Shrimp', 2020, 700000); | What is the total fish weight for each species per year? | SELECT Species_Name, Year, SUM(Fish_Weight) OVER (PARTITION BY Species_Name) AS Total_Fish_Weight FROM Species_Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, factory_name TEXT, region TEXT); INSERT INTO factories (factory_id, factory_name, region) VALUES (1, 'Factory A', 'North'), (2, 'Factory B', 'South'), (3, 'Factory C', 'East'); CREATE TABLE products (product_id INT, factory_id INT, production_month DATE, quantity INT); INSERT INT... | What is the total quantity of products manufactured by each factory, grouped by region and month? | SELECT region, EXTRACT(MONTH FROM production_month) AS month, SUM(quantity) AS total_quantity FROM factories JOIN products ON factories.factory_id = products.factory_id GROUP BY region, EXTRACT(MONTH FROM production_month); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, menu_name TEXT, menu_type TEXT, price DECIMAL, daily_sales INT, cuisine TEXT); | What is the most expensive menu item in the Asian cuisine category? | SELECT menu_name, MAX(price) FROM menu WHERE cuisine = 'Asian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VisitorCounts (Country VARCHAR(20), Year INT, VisitorCount INT); INSERT INTO VisitorCounts (Country, Year, VisitorCount) VALUES ('Japan', 2020, 1000), ('Japan', 2021, 800), ('Canada', 2020, 1500), ('Canada', 2021, 1200); | List the countries that had a decrease in visitors between 2020 and 2021. | SELECT Country FROM VisitorCounts WHERE Year IN (2020, 2021) GROUP BY Country HAVING COUNT(*) = 2 AND MAX(VisitorCount) < MIN(VisitorCount); | gretelai_synthetic_text_to_sql |
CREATE TABLE route_planning (id INT, route VARCHAR(20), route_date DATE, num_riders INT); INSERT INTO route_planning (id, route, route_date, num_riders) VALUES (1, 'Route 1', '2021-06-21', 150), (2, 'Route 2', '2021-06-23', 200), (3, 'Route 3', '2021-06-25', 250); | How many riders used each route in the last week of June 2021? | SELECT route, SUM(num_riders) as total_riders FROM route_planning WHERE route_date BETWEEN '2021-06-21' AND '2021-06-27' GROUP BY route; | gretelai_synthetic_text_to_sql |
CREATE TABLE workout_equipment (equipment_id INT, equipment_name VARCHAR(50), quantity INT); | Add a new column 'manufacturer' to the 'workout_equipment' table | ALTER TABLE workout_equipment ADD manufacturer VARCHAR(50); | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (investment_id INT, technology VARCHAR(20), region VARCHAR(50), investment_amount INT); INSERT INTO network_investments (investment_id, technology, region, investment_amount) VALUES (1, '4G', 'North', 10000), (2, '5G', 'North', 20000), (3, '3G', 'South', 15000), (4, '5G', 'East', 25000)... | What is the total investment in network infrastructure for each technology in the Western region? | SELECT technology, SUM(investment_amount) AS total_investment FROM network_investments WHERE region = 'West' GROUP BY technology; | 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.