context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE threats (id INT, category VARCHAR(50), ip_address VARCHAR(50), threat_date DATE); INSERT INTO threats (id, category, ip_address, threat_date) VALUES (1, 'Malware', '192.168.1.1', '2022-01-01'), (2, 'Phishing', '192.168.1.2', '2022-01-02'); | How many unique IP addresses are associated with each threat category in the last week? | SELECT category, COUNT(DISTINCT ip_address) as unique_ips FROM threats WHERE threat_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, state VARCHAR(5)); INSERT INTO wells VALUES (1, 'Well A', 1000, 'TX'); INSERT INTO wells VALUES (2, 'Well B', 1500, 'AK'); INSERT INTO wells VALUES (3, 'Well C', 1200, 'TX'); INSERT INTO wells VALUES (4, 'Well D', 800, 'LA'); INSERT INTO w... | List the wells with the highest production volume in each state | SELECT state, MAX(production_volume) FROM wells GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, category TEXT, word_count INT); INSERT INTO articles (id, title, category, word_count) VALUES (1, 'Article1', 'Politics', 800), (2, 'Article2', 'Sports', 500); | What's the average word count of articles in the 'Politics' category? | SELECT AVG(word_count) FROM articles WHERE category = 'Politics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE holmium_usage (industry VARCHAR(50), usage FLOAT); | Calculate the percentage of Holmium used in various industries. | SELECT industry, usage * 100.0 / SUM(usage) OVER (PARTITION BY NULL) AS percentage FROM holmium_usage; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_production (id INT, plant_location VARCHAR(50), production_date DATE, amount_wasted FLOAT); | What is the average amount of waste produced daily by the chemical manufacturing plant located in New York in the past year? | SELECT AVG(amount_wasted) FROM waste_production WHERE plant_location = 'New York' AND production_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_maintenance (vehicle_type VARCHAR(50), last_maintenance DATE); INSERT INTO subway_maintenance (vehicle_type, last_maintenance) VALUES ('Yellow Line', '2021-07-01'), ('Yellow Line', '2021-09-15'), ('Green Line', '2021-08-20'); | List all vehicle maintenance records for the 'Yellow Line' subway fleet | SELECT * FROM subway_maintenance WHERE vehicle_type = 'Yellow Line'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), sport VARCHAR(50), team VARCHAR(50)); | Insert a new record for a basketball player named "Sue Bird" into the "players" table | INSERT INTO players (player_id, first_name, last_name, sport, team) VALUES (6, 'Sue', 'Bird', 'Basketball', 'Storm'); | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO workers (id, name, department) VALUES (1, 'John Doe', 'Machining'), (2, 'Jane Smith', 'Assembly'); CREATE TABLE parts (id INT, worker_id INT, quantity INT, date DATE); INSERT INTO parts (id, worker_id, quantity, date) VALUES (1, 1, 150... | What was the total quantity of parts produced by each worker in the 'machining' department for January 2021? | SELECT w.name, SUM(p.quantity) as total_quantity FROM workers w JOIN parts p ON w.id = p.worker_id WHERE w.department = 'Machining' AND p.date BETWEEN '2021-01-01' AND '2021-01-31' GROUP BY w.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_student_publications (id INT, student_id INT, community VARCHAR(255), num_publications INT); INSERT INTO graduate_student_publications (id, student_id, community, num_publications) VALUES (1, 1, 'African American', 2), (2, 2, 'Latinx', 1), (3, 3, 'Native American', 3), (4, 4, 'Asian American', 1),... | What is the total number of publications by graduate students from historically underrepresented communities? | SELECT community, SUM(num_publications) as total_publications FROM graduate_student_publications WHERE community IN ('African American', 'Latinx', 'Native American') GROUP BY community; | gretelai_synthetic_text_to_sql |
CREATE TABLE european_investment_bank (fund_id INT, project_name VARCHAR(100), country VARCHAR(50), sector VARCHAR(50), amount FLOAT, climate_adaptation_flag BOOLEAN); INSERT INTO european_investment_bank (fund_id, project_name, country, sector, amount, climate_adaptation_flag) VALUES (1, 'Sea Level Rise Protection', '... | What is the total amount of climate finance provided to projects in the Pacific region for climate adaptation by the European Investment Bank? | SELECT SUM(amount) FROM european_investment_bank WHERE country LIKE '%%pacific%%' AND climate_adaptation_flag = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT, equipment_type VARCHAR(255), country VARCHAR(255), year INT, total_sales DECIMAL(10,2)); INSERT INTO military_sales (id, equipment_type, country, year, total_sales) VALUES (1, 'Aircraft', 'India', 2019, 5000000.00), (2, 'Ground Vehicle', 'India', 2020, 3000000.00); | What is the total number of aircraft sales to India in the last 3 years? | SELECT SUM(total_sales) FROM military_sales WHERE equipment_type = 'Aircraft' AND country = 'India' AND year BETWEEN (SELECT YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(100), Country VARCHAR(50)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Country) VALUES (1, 'Tesla', 'USA'), (2, 'Nissan', 'Japan'), (3, 'BMW', 'Germany'); CREATE TABLE ElectricVehicles (EVID INT, ManufacturerID INT, Model VARCHAR... | What is the total number of electric vehicles by manufacturer, grouped by country, with a count greater than 500? | SELECT Country, ManufacturerName, COUNT(*) as Total FROM ElectricVehicles EV JOIN Manufacturers M ON EV.ManufacturerID = M.ManufacturerID GROUP BY Country, ManufacturerName HAVING COUNT(*) > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research (id INT PRIMARY KEY, country VARCHAR(255), genetic_mutation VARCHAR(255), data_size INT, research_date DATE); | What is the distribution of genetic research data by the type of genetic mutation, for the top 3 countries with the most data, and for each month in the year 2022? | SELECT EXTRACT(MONTH FROM research_date) AS month, genetic_mutation, SUM(data_size) FROM genetic_research WHERE country IN (SELECT country FROM genetic_research GROUP BY country ORDER BY SUM(data_size) DESC LIMIT 3) AND research_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month, genetic_mutation; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, quantity INT, price DECIMAL(5,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(100), category VARCHAR(50), country VARCHAR(50)); | What is the total revenue of skincare products sold in the US in the last month? | SELECT SUM(sales.quantity * sales.price) FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.category = 'Skincare' AND products.country = 'US' AND sales.sale_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE garments (item VARCHAR(20), material VARCHAR(20), sustainability VARCHAR(10), price DECIMAL(5,2)); INSERT INTO garments (item, material, sustainability, price) VALUES ('T-Shirt', 'Organic Cotton', 'Yes', 25.00), ('Pants', 'Organic Cotton', 'Yes', 30.00); CREATE TABLE sales_volume (item VARCHAR(20), quantit... | What is the total revenue from sales of sustainable organic cotton garments? | SELECT SUM(garments.price * sales_volume.quantity) FROM garments INNER JOIN sales_volume ON garments.item = sales_volume.item WHERE garments.material = 'Organic Cotton' AND sustainability = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (debris_id INT, name VARCHAR(255), country VARCHAR(255), debris_type VARCHAR(255)); | What is the distribution of space debris by debris type? | SELECT debris_type, COUNT(*) as total_debris FROM space_debris GROUP BY debris_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT, is_organic BOOLEAN, name VARCHAR(255)); INSERT INTO Products (id, is_organic, name) VALUES (1, true, 'Broccoli'), (2, true, 'Carrots'), (3, false, 'Potatoes'), (4, true, 'Cauliflower'), (5, false, 'Onions'), (6, true, 'Garlic'); CREATE TABLE MarketProducts (market_id INT, product_id INT);... | What is the percentage of organic produce in 'HealthyHarvest'? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM MarketProducts WHERE market_id = 1)) AS percentage FROM Products WHERE is_organic = true AND id IN (SELECT product_id FROM MarketProducts WHERE market_id = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_users (user_id INT, age INT, data_usage FLOAT, country VARCHAR(20)); INSERT INTO mobile_users (user_id, age, data_usage, country) VALUES (1, 23, 2.5, 'Philippines'); INSERT INTO mobile_users (user_id, age, data_usage, country) VALUES (2, 31, 3.2, 'Philippines'); | What is the average data usage per mobile user in the Philippines, partitioned by age group? | SELECT age_group, AVG(data_usage) FROM (SELECT age, data_usage, FLOOR(age/10)*10 AS age_group FROM mobile_users WHERE country = 'Philippines') subquery GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development_2 (id INT, initiative_name VARCHAR(50), budget DECIMAL(10, 2)); INSERT INTO community_development_2 (id, initiative_name, budget) VALUES (1, 'Clean Water Initiative', 50000.00), (2, 'Renewable Energy', 75000.00), (3, 'Waste Management', 45000.00), (4, 'Affordable Housing', 110000.00); | Which community development initiatives have budget allocations between 75000 and 125000 in the 'community_development_2' table? | SELECT initiative_name, budget FROM community_development_2 WHERE budget BETWEEN 75000 AND 125000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID int, PolicyType varchar(20), SaleRegion varchar(20)); INSERT INTO Policies (PolicyID, PolicyType, SaleRegion) VALUES (1, 'Auto', 'West'), (2, 'Home', 'East'), (3, 'Auto', 'West'), (4, 'Life', 'Midwest'); | What is the distribution of policy types across different regions? | SELECT PolicyType, SaleRegion, COUNT(*) OVER (PARTITION BY PolicyType, SaleRegion) as PolicyCount FROM Policies; | gretelai_synthetic_text_to_sql |
CREATE TABLE modes (mode_id INT, mode_name VARCHAR(255)); CREATE TABLE fares (fare_id INT, mode_id INT, fare_amount DECIMAL(5,2)); INSERT INTO modes VALUES (1, 'Bus'); INSERT INTO modes VALUES (2, 'Train'); INSERT INTO fares VALUES (1, 1, 2.50); INSERT INTO fares VALUES (2, 1, 3.00); INSERT INTO fares VALUES (3, 2, 1.7... | What is the minimum fare for each mode of transportation? | SELECT mode_name, MIN(fare_amount) as min_fare FROM modes m JOIN fares f ON m.mode_id = f.mode_id GROUP BY m.mode_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies(id INT, name VARCHAR(50), founding_year INT, industry VARCHAR(20), funding FLOAT); INSERT INTO companies(id, name, founding_year, industry, funding) VALUES (1, 'CompanyA', 2010, 'Tech', 750000); INSERT INTO companies(id, name, founding_year, industry, funding) VALUES (2, 'CompanyB', 2015, 'Health... | Identify companies that received funding in the range of $500,000 to $1,000,000, ordered by founding year. | SELECT name, founding_year FROM companies WHERE funding BETWEEN 500000 AND 1000000 ORDER BY founding_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE Sales (dispid INT, date DATE, product_category TEXT, revenue DECIMAL(10,2)); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Oregon'); INSERT INTO Dispensaries (id, name, state) VALUES (2, 'Dispensary B', 'Oregon'); INSERT IN... | What is the total revenue for each product category sold at every dispensary in Oregon in 2021? | SELECT d.name, s.product_category, SUM(s.revenue) as total_revenue FROM Dispensaries d JOIN Sales s ON d.id = s.dispid WHERE d.state = 'Oregon' AND YEAR(s.date) = 2021 GROUP BY d.name, s.product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, usage FLOAT, purpose VARCHAR(20), date DATE); INSERT INTO water_usage (id, usage, purpose, date) VALUES (1, 150, 'residential', '2021-07-01'); INSERT INTO water_usage (id, usage, purpose, date) VALUES (2, 120, 'industrial', '2021-07-01'); | Find the total water usage for residential purposes in 'July 2021' from the 'water_usage' table | SELECT SUM(usage) FROM water_usage WHERE purpose = 'residential' AND date = '2021-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fine_dining.restaurants (restaurant_id INT, name TEXT, health_score INT); INSERT INTO fine_dining.restaurants (restaurant_id, name, health_score) VALUES (1, 'The Classy Spoon', 95), (2, 'Gourmet Delights', 88); | Which restaurants in the 'fine_dining' schema have a health score above 90? | SELECT * FROM fine_dining.restaurants WHERE health_score > 90; | gretelai_synthetic_text_to_sql |
CREATE TABLE ev_sales (id INT PRIMARY KEY, model VARCHAR(100), manufacturer VARCHAR(100), year INT, total_sales INT); | Create a table for storing electric vehicle (EV) data | CREATE TABLE ev_data (id INT PRIMARY KEY, model VARCHAR(100), manufacturer VARCHAR(100), year INT, total_sales INT); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (id INT, name VARCHAR(100), country VARCHAR(50), revenue FLOAT); | What's the total revenue for music artists from the USA? | SELECT SUM(revenue) FROM Artists WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_asia_regions (id INT, name VARCHAR(255)); CREATE TABLE life_expectancy (id INT, region_id INT, expectancy DECIMAL(5,2)); INSERT INTO south_asia_regions (id, name) VALUES (1, 'South Asia West'), (2, 'South Asia Central'), (3, 'South Asia East'), (4, 'South Asia South'); | What is the average life expectancy in each region of South Asia? | SELECT r.name, AVG(le.expectancy) FROM life_expectancy le JOIN south_asia_regions r ON le.region_id = r.id GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE least_progress (country TEXT, year INT, progress FLOAT); INSERT INTO least_progress (country, year, progress) VALUES ('Argentina', 2017, 0.2); | Which countries have made the least progress in climate adaptation in the last 5 years? | SELECT country, MIN(progress) FROM least_progress WHERE year BETWEEN 2016 AND 2021 GROUP BY country ORDER BY progress ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name VARCHAR(50), location VARCHAR(50), area FLOAT, sustainability_rating INT); | Identify buildings with the lowest sustainability ratings | SELECT name FROM green_buildings WHERE sustainability_rating = (SELECT MIN(sustainability_rating) FROM green_buildings); | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_ops (id INT, year INT, location VARCHAR(255), type VARCHAR(255), result VARCHAR(255)); | Add new records of intelligence operations in a specific year to the "intelligence_ops" table | INSERT INTO intelligence_ops (id, year, location, type, result) VALUES (1, 2015, 'Russia', 'Surveillance', 'Success'), (2, 2015, 'Germany', 'Infiltration', 'Failure'); | gretelai_synthetic_text_to_sql |
CREATE TABLE art_collection (artwork_id INT, name VARCHAR(50), artist VARCHAR(50), year INT, medium VARCHAR(50)); | List the artworks in the 'art_collection' table, ordered by the artist's name. | SELECT * FROM art_collection ORDER BY artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE SuburbBLifelong (studentID INT, suburb VARCHAR(50), program VARCHAR(50)); INSERT INTO SuburbBLifelong (studentID, suburb, program) VALUES (1, 'Suburb B', 'lifelong learning'), (2, 'City C', 'lifelong learning'); CREATE TABLE CityCLifelong (studentID INT, city VARCHAR(50), program VARCHAR(50)); INSERT INTO ... | What is the total number of students who participated in lifelong learning programs in 'Suburb B' and 'City C'? | SELECT COUNT(DISTINCT studentID) FROM SuburbBLifelong WHERE suburb IN ('Suburb B', 'City C') AND program = 'lifelong learning' UNION ALL SELECT COUNT(DISTINCT studentID) FROM CityCLifelong WHERE city IN ('Suburb B', 'City C') AND program = 'lifelong learning'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA RuralHealth; USE RuralHealth; CREATE TABLE CensusTracts (TractID INT, TractPopulation INT, TractArea FLOAT, StateAbbreviation VARCHAR(10)); INSERT INTO CensusTracts (TractID, TractPopulation, TractArea, StateAbbreviation) VALUES (1, 500, 10.5, 'AL'), (2, 1500, 34.2, 'AK'); | What is the average population density in census tracts for each state, ordered from highest to lowest? | SELECT StateAbbreviation, AVG(TractPopulation / TractArea) as AvgPopulationDensity FROM CensusTracts GROUP BY StateAbbreviation ORDER BY AvgPopulationDensity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfills (country VARCHAR(50), capacity INT, year INT); INSERT INTO landfills (country, capacity, year) VALUES ('China', 25000, 2020), ('India', 18000, 2020), ('Indonesia', 12000, 2020), ('Japan', 15000, 2020), ('Pakistan', 10000, 2020); | What is the average landfill capacity in Asia in 2020?' | SELECT AVG(capacity) as avg_capacity FROM landfills WHERE year = 2020 AND country IN ('China', 'India', 'Indonesia', 'Japan', 'Pakistan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Spending (Country VARCHAR(50), Service VARCHAR(50), Year INT, Amount DECIMAL(10,2)); INSERT INTO Spending (Country, Service, Year, Amount) VALUES ('Mexico', 'Education', 2021, 5000.00), ('Mexico', 'Healthcare', 2021, 8000.00), ('Brazil', 'Education', 2021, 7000.00), ('Brazil', 'Healthcare', 2021, 10000.00)... | What is the total spending on education and healthcare services for indigenous communities in Mexico, Brazil, and Canada in 2021? | SELECT Country, SUM(Amount) as TotalSpending FROM Spending WHERE Service IN ('Education', 'Healthcare') AND Year = 2021 AND Country IN ('Mexico', 'Brazil', 'Canada') GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (event_id INT, event_name VARCHAR(50), location VARCHAR(50), date DATE, ticket_price DECIMAL(5,2), num_tickets INT, city VARCHAR(50)); CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), age INT, city VARCHAR(50), state VARCHAR(50), country VARCHAR(50)); | What is the total revenue for each event by state in the 'concerts' and 'fans' tables? | SELECT event_name, state, SUM(ticket_price * num_tickets) as total_revenue FROM concerts c JOIN fans f ON c.city = f.city GROUP BY event_name, state; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (Id INT, Name VARCHAR(50), Population INT, AnnualRainfall DECIMAL(5,2)); INSERT INTO City (Id, Name, Population, AnnualRainfall) VALUES (1, 'Tokyo', 9000000, 60.5), (2, 'Delhi', 3000000, 55.3), (3, 'Shanghai', 25000000, 62.4), (4, 'Sao Paulo', 12000000, 120.0); | What is the ranking of each city based on its total population, and what is the annual rainfall for each city? | SELECT Name, Population, AnnualRainfall, ROW_NUMBER() OVER (ORDER BY Population DESC) AS CityRank FROM City; | gretelai_synthetic_text_to_sql |
CREATE TABLE Building_Permits (state TEXT, permits_issued INTEGER); INSERT INTO Building_Permits (state, permits_issued) VALUES ('New York', 1500), ('Texas', 2000), ('California', 1200); | What is the total number of building permits issued in the state of New York and Texas combined? | SELECT SUM(permits_issued) FROM Building_Permits WHERE state IN ('New York', 'Texas'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_id INT, title VARCHAR(50), year_made INT, artist_id INT, price FLOAT); INSERT INTO Artworks (artwork_id, title, year_made, artist_id, price) VALUES (1, 'The Card Players', 1892, 1, 3000.0); CREATE TABLE Exhibitions (exhibition_id INT, exhibition_name VARCHAR(50), start_date DATE, end_date... | How many artworks were exhibited in Spain between 1850 and 1900? | SELECT COUNT(*) FROM Exhibitions WHERE Exhibitions.start_date BETWEEN '1850-01-01' AND '1900-12-31' AND Exhibitions.country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor_Statistics (id INT, employee_count INT, year INT, state VARCHAR(20)); INSERT INTO Labor_Statistics (id, employee_count, year, state) VALUES (1, 10000, 2020, 'New York'); | How many construction laborers were employed in the state of New York in 2020? | SELECT SUM(employee_count) FROM Labor_Statistics WHERE year = 2020 AND state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE taxi_trips (ride_id INT, ride_start_time TIMESTAMP, ride_end_time TIMESTAMP, ride_distance FLOAT, fare FLOAT, vehicle_type VARCHAR(10)); | Find the top 3 most expensive electric taxi rides by ride_distance. | SELECT ride_id, ride_distance, fare FROM (SELECT ride_id, ride_distance, fare, ROW_NUMBER() OVER (PARTITION BY vehicle_type ORDER BY ride_distance DESC, fare DESC) AS rank FROM taxi_trips WHERE vehicle_type = 'Electric Taxi') AS subquery WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Designers (DesignerID INT, DesignerName VARCHAR(50)); INSERT INTO Designers VALUES (1, 'DesignerA'), (2, 'DesignerB'), (3, 'DesignerC'); CREATE TABLE Transactions (TransactionID INT, DesignerID INT, Quantity INT, Sales DECIMAL(10,2)); INSERT INTO Transactions VALUES (1, 1, 50, 1000), (2, 1, 75, 1500), (3, ... | Identify the total number of transactions and total sales for each designer, in descending order by total sales. | SELECT DesignerName, SUM(Quantity) AS Total_Quantity, SUM(Sales) AS Total_Sales, ROW_NUMBER() OVER (ORDER BY SUM(Sales) DESC) AS Rank FROM Designers JOIN Transactions ON Designers.DesignerID = Transactions.DesignerID GROUP BY DesignerName ORDER BY Rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (artist_id INT, name TEXT); INSERT INTO Artists (artist_id, name) VALUES (1, 'Edvard Munch'), (2, 'Vincent Van Gogh'); CREATE TABLE Artworks (artwork_id INT, title TEXT, creation_year INT, art_movement TEXT, artist_id INT); INSERT INTO Artworks (artwork_id, title, creation_year, art_movement, artis... | What are the names of all artists who have created artworks in the 'expressionism' movement? | SELECT Artists.name FROM Artists INNER JOIN Artworks ON Artists.artist_id = Artworks.artist_id WHERE Artworks.art_movement = 'Expressionism' GROUP BY Artists.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_membership (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO union_membership (id, name, country) VALUES (1, 'Union A', 'USA'), (2, 'Union B', 'Canada'), (3, 'Union C', 'USA'), (4, 'Union D', 'Canada'); | What is the total number of members in unions based in the US and Canada, excluding any duplicate entries? | SELECT COUNT(DISTINCT name) FROM union_membership WHERE country IN ('USA', 'Canada') | gretelai_synthetic_text_to_sql |
CREATE TABLE precedents (precedent_id INT PRIMARY KEY, precedent_name VARCHAR(50), year DECIMAL(4,0), court VARCHAR(50)); INSERT INTO precedents (precedent_id, precedent_name, year, court) VALUES (1, 'Brown v. Board of Education', 1954, 'District Court'), (2, 'Miranda v. Arizona', 1966, 'Supreme Court'); | Update the court for precedent 'Brown v. Board of Education' to 'Supreme Court' in the 'precedents' table | UPDATE precedents SET court = 'Supreme Court' WHERE precedent_name = 'Brown v. Board of Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_cages (id INT, farm_id INT, cage_number INT, fish_count INT); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES (1, 4, 1, 1500); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES (2, 4, 2, 2500); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES... | How many fish are there in each cage at the Indian fish farm 'Farm D'? | SELECT cage_number, fish_count FROM fish_cages WHERE farm_id = (SELECT id FROM salmon_farms WHERE name = 'Farm D' AND country = 'India' LIMIT 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE weather_global (country VARCHAR(20), year INT, temperature DECIMAL(5,2)); INSERT INTO weather_global VALUES ('AF', 2010, 10.5), ('AF', 2011, 11.2), ('AF', 2012, 12.1), ('AU', 2010, 8.7), ('AU', 2011, 8.9), ('AU', 2012, 9.3); | What is the maximum temperature change in Africa and minimum temperature change in Australia over the last 10 years? | SELECT MAX(CASE WHEN country = 'AF' THEN temperature END) AS max_temp_change_AF, MIN(CASE WHEN country = 'AU' THEN temperature END) AS min_temp_change_AU FROM (SELECT ROW_NUMBER() OVER (PARTITION BY country ORDER BY year DESC) rn, country, temperature FROM weather_global WHERE year >= 2010) t WHERE rn <= 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Fossil_Fuel_Vehicles_Brazil (Id INT, Vehicle VARCHAR(50), CO2_Emission DECIMAL(5,2)); INSERT INTO Fossil_Fuel_Vehicles_Brazil (Id, Vehicle, CO2_Emission) VALUES (1, 'Chevrolet Onix', 135.0), (2, 'Ford Ka', 140.0), (3, 'Volkswagen Gol', 145.0); | What is the maximum CO2 emission of fossil fuel vehicles in Brazil? | SELECT MAX(CO2_Emission) FROM Fossil_Fuel_Vehicles_Brazil; | gretelai_synthetic_text_to_sql |
CREATE TABLE LegalPatents (Id INT, Country VARCHAR(50), FilingDate DATE); INSERT INTO LegalPatents (Id, Country, FilingDate) VALUES (1, 'USA', '2020-01-01'), (2, 'Canada', '2021-05-15'), (3, 'Mexico', '2019-12-31'); | List all legal technology patents that were filed in the US, Canada, or Mexico in the last 5 years. | SELECT Country FROM LegalPatents WHERE FilingDate >= DATEADD(year, -5, GETDATE()) AND Country IN ('USA', 'Canada', 'Mexico') ORDER BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (id INT, permit_number TEXT, location TEXT, cost INT, issue_date DATE); INSERT INTO building_permits (id, permit_number, location, cost, issue_date) VALUES (1, 'NY-1234', 'New York', 500000, '2019-03-01'); INSERT INTO building_permits (id, permit_number, location, cost, issue_date) VALUES ... | What is the maximum cost of building permits issued in 'New York' in 2019? | SELECT MAX(cost) FROM building_permits WHERE location = 'New York' AND YEAR(issue_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders(id INT, name VARCHAR(50), gender VARCHAR(10), industry VARCHAR(20)); INSERT INTO founders VALUES (1, 'Alice', 'Female', 'Tech'); INSERT INTO founders VALUES (2, 'Bob', 'Male', 'Finance'); CREATE TABLE funding(id INT, founder_id INT, amount INT); INSERT INTO funding VALUES (1, 1, 500000); INSERT IN... | What is the total funding received by female founders in the tech industry? | SELECT SUM(funding.amount) FROM founders INNER JOIN funding ON founders.id = funding.founder_id WHERE founders.gender = 'Female' AND founders.industry = 'Tech'; | gretelai_synthetic_text_to_sql |
CREATE TABLE justice_schemas.restorative_programs (id INT PRIMARY KEY, program_name TEXT, program_type TEXT); | What is the total number of restorative justice programs in the justice_schemas.restorative_programs table, categorized by the type of program? | SELECT program_type, COUNT(*) FROM justice_schemas.restorative_programs GROUP BY program_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE EnergyConsumption (Machine VARCHAR(50), Energy INT, Timestamp DATETIME); INSERT INTO EnergyConsumption (Machine, Energy, Timestamp) VALUES ('MachineA', 1000, '2022-02-01 00:00:00'), ('MachineB', 1200, '2022-02-01 00:00:00'); | What is the average energy consumption per machine, per day, for the past week? | SELECT Machine, AVG(Energy) OVER (PARTITION BY Machine ORDER BY Timestamp ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) FROM EnergyConsumption WHERE Timestamp >= DATEADD(day, -7, CURRENT_TIMESTAMP) | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_fashion_metrics ( id INT PRIMARY KEY, metric VARCHAR(255), value INT, category VARCHAR(255), metric_date DATE ); | What are the quartiles for sustainable fashion metrics values across all categories? | SELECT metric, value, NTILE(4) OVER (ORDER BY value DESC) as quartile FROM sustainable_fashion_metrics; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists funding; USE funding; CREATE TABLE if not exists research_funding (id INT, project_id INT, country VARCHAR(255), funding DECIMAL(10, 2)); INSERT INTO research_funding (id, project_id, country, funding) VALUES (1, 1, 'Australia', 7000000.00), (2, 2, 'Canada', 6000000.00), (3, 3, 'Australia', ... | What is the total funding for genetic research projects in Australia? | SELECT SUM(funding) FROM funding.research_funding WHERE country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Nail_Polish (ProductID int, ProductName varchar(100), Price decimal(5,2), CrueltyFree bit); INSERT INTO Nail_Polish (ProductID, ProductName, Price, CrueltyFree) VALUES (1, 'Cruelty-free Red Nail Polish', 9.99, 1); INSERT INTO Nail_Polish (ProductID, ProductName, Price, CrueltyFree) VALUES (2, 'Classic Nail... | What is the maximum retail price of cruelty-free nail polishes? | SELECT MAX(Price) FROM Nail_Polish WHERE CrueltyFree = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, species VARCHAR(20), population INT); INSERT INTO animal_population (id, species, population) VALUES (1, 'tiger', 500), (2, 'elephant', 300); CREATE TABLE habitat_preservation (id INT, species VARCHAR(20), efforts INT); INSERT INTO habitat_preservation (id, species, efforts) VALU... | Find the species with the least number of animals in the 'animal_population' table and the corresponding number of preservation efforts for the same species in the 'habitat_preservation' table. | SELECT species, population, efforts FROM animal_population INNER JOIN habitat_preservation ON animal_population.species = habitat_preservation.species WHERE population = (SELECT MIN(population) FROM animal_population); | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(100), age INT, sport VARCHAR(50), olympics BOOLEAN); INSERT INTO athletes (id, name, age, sport, olympics) VALUES (1, 'John Doe', 30, 'Athletics', true), (2, 'Jane Smith', 25, 'Gymnastics', true); | What is the average age of athletes who participated in the 2020 Olympics? | SELECT AVG(age) FROM athletes WHERE olympics = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, author VARCHAR(50), year INT, journal VARCHAR(50)); INSERT INTO publications (id, author, year, journal) VALUES (1, 'Alice', 2019, 'Journal of Computer Science'), (2, 'Bob', 2018, 'Journal of Physics'), (3, 'Eve', 2019, 'Journal of Mathematics'); | What is the total number of publications by graduate students in the year 2019? | SELECT COUNT(*) FROM publications WHERE year = 2019 AND author IN (SELECT name FROM students WHERE graduate_student = 'Yes'); | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (id INT, project_name VARCHAR(100), region VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO DefenseProjects (id, project_name, region, start_date, end_date) VALUES (1, 'Project A', 'Asia-Pacific', '2019-01-01', '2020-12-31'); INSERT INTO DefenseProjects (id, project_name, region, s... | How many defense projects were delayed in the Asia-Pacific region in 2020? | SELECT COUNT(*) FROM DefenseProjects WHERE region = 'Asia-Pacific' AND end_date > start_date + INTERVAL 1 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), hire_date DATE, gender VARCHAR(50), country VARCHAR(50)); INSERT INTO employees (id, first_name, last_name, hire_date, gender, country) VALUES (7, 'Aarav', 'Singh', '2022-02-15', 'Male', 'India'); | What is the total number of employees hired in the South Asia region in 2022, grouped by gender? | SELECT e.gender, COUNT(e.id) as total_hired FROM employees e WHERE e.hire_date >= '2022-01-01' AND e.hire_date < '2023-01-01' AND e.country IN (SELECT region FROM regions WHERE region_name = 'South Asia') GROUP BY e.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_water_usage(country VARCHAR(50), year INT, day INT, volume FLOAT); INSERT INTO daily_water_usage(country, year, day, volume) VALUES ('Brazil', 2019, 1, 4.58), ('Brazil', 2019, 2, 4.61), ('Brazil', 2019, 3, 4.64); | What is the minimum water usage in a single day in Brazil in 2019? | SELECT MIN(volume) FROM daily_water_usage WHERE country = 'Brazil' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE Water_Usage (Year INT, Sector VARCHAR(20), Volume INT); INSERT INTO Water_Usage (Year, Sector, Volume) VALUES (2019, 'Domestic', 12300000), (2018, 'Domestic', 12000000), (2020, 'Domestic', 12500000); | What is the total volume of water consumed by the domestic sector in the state of New York in 2019? | SELECT SUM(Volume) FROM Water_Usage WHERE Year = 2019 AND Sector = 'Domestic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Position, Department, Salary) VALUES (1, 'John', 'Doe', 'Manager', 'Manufacturing', 75000.00); INSERT INTO Emp... | Show the names and positions of employees in the Engineering department who earn a salary above the average salary for the department. | SELECT FirstName, LastName, Position FROM Employees WHERE Department = 'Engineering' AND Salary > (SELECT AVG(Salary) FROM Employees WHERE Department = 'Engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Centers (cc_name TEXT, families_assisted INTEGER, assist_date DATE); INSERT INTO Community_Centers (cc_name, families_assisted, assist_date) VALUES ('Center A', 10, '2021-07-04'); INSERT INTO Community_Centers (cc_name, families_assisted, assist_date) VALUES ('Center B', 15, '2021-08-18'); | What is the average number of families assisted per day by each community center in Q3 of 2021? | SELECT cc_name, AVG(families_assisted/DATEDIFF('2021-10-01', assist_date)) FROM Community_Centers WHERE assist_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY cc_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data_4 (sale_id INT, product_category VARCHAR(255), region VARCHAR(255), sale_quantity INT, sale_revenue DECIMAL(10,2), sale_year INT); | What is the total sales revenue of each product category in the top 3 African regions for 2022? | SELECT a.product_category, a.region, SUM(a.sale_revenue) AS total_sales_revenue FROM sales_data_4 a JOIN (SELECT region, SUM(sale_revenue) AS total_sale_revenue FROM sales_data_4 WHERE sale_year = 2022 GROUP BY region ORDER BY total_sale_revenue DESC LIMIT 3) b ON a.region = b.region WHERE a.sale_year = 2022 GROUP BY a... | gretelai_synthetic_text_to_sql |
CREATE TABLE nhl_season (player_id INT, player_name VARCHAR(50), team_id INT, team_name VARCHAR(50), position VARCHAR(50), games_played INT, time_on_ice INT); INSERT INTO nhl_season (player_id, player_name, team_id, team_name, position, games_played, time_on_ice) VALUES (1, 'Victor Hedman', 1, 'Tampa Bay Lightning', 'D... | What is the average time spent on ice by each defenseman in the 2021-2022 NHL season? | SELECT player_name, AVG(time_on_ice) as avg_time FROM nhl_season WHERE position = 'D' GROUP BY player_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(255), circular_supply_chain BOOLEAN); INSERT INTO products (product_id, name, circular_supply_chain) VALUES (1, 'Refurbished Phone', TRUE), (2, 'Vintage Dress', FALSE); CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE); INSERT INTO sales (sale_id, produ... | How many circular supply chain products were sold last month? | SELECT COUNT(*) FROM products JOIN sales ON products.product_id = sales.product_id WHERE circular_supply_chain = TRUE AND sale_date BETWEEN '2022-02-01' AND '2022-02-28'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_neodymium (year INT, quantity INT); INSERT INTO production_neodymium (year, quantity) VALUES (2015, 1200), (2016, 1400), (2017, 1800), (2018, 2000), (2019, 2200), (2020, 2500), (2021, 2800); | Calculate the average production of Neodymium in 2020 | SELECT AVG(quantity) FROM production_neodymium WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Carbon_Pricing (Country VARCHAR(20), Currency VARCHAR(20), Price DECIMAL(10,2)); INSERT INTO Carbon_Pricing VALUES ('Japan', 'JPY', 3000), ('Canada', 'CAD', 20), ('Sweden', 'SEK', 40); | What is the carbon price in Japanese Yen for each country that has a carbon pricing mechanism? | SELECT Country, Price * (SELECT AVG(Exchange_Rate) FROM Exchange_Rates WHERE Currency_Code = Carbon_Pricing.Currency) AS Price_In_JPY FROM Carbon_Pricing; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_revenue (id INT, supplier TEXT, revenue FLOAT, date DATE); | What is the total revenue for each textile supplier this year? | SELECT supplier, SUM(revenue) FROM supplier_revenue WHERE YEAR(date) = YEAR(CURDATE()) GROUP BY supplier; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT, animal_name VARCHAR(255), habitat_type VARCHAR(255), weight DECIMAL(5,2)); INSERT INTO animals (id, animal_name, habitat_type, weight) VALUES (1, 'Lion', 'Savannah', 190.0), (2, 'Elephant', 'Forest', 6000.0), (3, 'Hippo', 'Wetlands', 3300.0), (4, 'Giraffe', 'Savannah', 1600.0), (5, 'Duck',... | Update the weight of the 'Elephant' in the 'Forest' habitat to 5500.0. | UPDATE animals SET weight = 5500.0 WHERE animal_name = 'Elephant' AND habitat_type = 'Forest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(255), network VARCHAR(255)); INSERT INTO digital_assets (asset_id, asset_name, network) VALUES (1, 'ETH', 'ethereum'), (2, 'USDC', 'ethereum'), (3, 'UNI', 'ethereum'); CREATE TABLE transactions (transaction_id INT, asset_id INT, value DECIMAL(10,2)); INSERT ... | What is the total number of transactions and their average value for each digital asset in the 'ethereum' network? | SELECT d.asset_name, COUNT(t.transaction_id) as total_transactions, AVG(t.value) as average_value FROM digital_assets d JOIN transactions t ON d.asset_id = t.asset_id WHERE d.network = 'ethereum' GROUP BY d.asset_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, country VARCHAR(50)); INSERT INTO patients (patient_id, country) VALUES (1, 'Nigeria'), (2, 'Nigeria'), (3, 'USA'), (4, 'Nigeria'); CREATE TABLE therapy_sessions (patient_id INT, session_count INT, improvement BOOLEAN); INSERT INTO therapy_sessions (patient_id, session_count, impr... | What is the percentage of patients who improved after therapy sessions in Nigeria? | SELECT AVG(CASE WHEN therapy_sessions.improvement = TRUE THEN 1.0 ELSE 0.0 END) * 100.0 / COUNT(DISTINCT patients.patient_id) AS percentage FROM patients INNER JOIN therapy_sessions ON patients.patient_id = therapy_sessions.patient_id WHERE patients.country = 'Nigeria'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists defense; CREATE TABLE if not exists au_peacekeeping_operations (id INT PRIMARY KEY, year INT, operation_count INT); INSERT INTO au_peacekeeping_operations (id, year, operation_count) VALUES (1, 2018, 5), (2, 2019, 7), (3, 2020, 10), (4, 2021, 12); | What is the maximum number of peacekeeping operations conducted by the African Union in a single year? | SELECT MAX(operation_count) FROM defense.au_peacekeeping_operations; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplace_safety (facility_id INT, total_incidents INT); INSERT INTO workplace_safety (facility_id, total_incidents) VALUES (42, 5); INSERT INTO workplace_safety (facility_id, total_incidents) VALUES (43, 3); | Update records in the "workplace_safety" table by increasing the "total_incidents" column by 1 for the row where the "facility_id" is 42 | UPDATE workplace_safety SET total_incidents = total_incidents + 1 WHERE facility_id = 42; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_violations (id INT, factory VARCHAR(100), country VARCHAR(50), violations INT); INSERT INTO labor_violations (id, factory, country, violations) VALUES (1, 'Blue Factory', 'Indonesia', 15), (2, 'Green Factory', 'Cambodia', 20), (3, 'Red Factory', 'Vietnam', 25); | Identify the factory with the highest number of labor rights violations in Asia. | SELECT factory, SUM(violations) as total_violations FROM labor_violations WHERE country = 'Asia' GROUP BY factory ORDER BY total_violations DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'Software Engineer', 150000.00), (2, 'Jane Smith', 'Data Analyst', 120000.00), (3, 'Bob Brown', 'Data Analyst', 130000.00); | What is the maximum salary in the "tech_company" database for data analysts? | SELECT MAX(salary) FROM employees WHERE department = 'Data Analyst'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (id INT, artist_name VARCHAR(255), gender VARCHAR(10), ethnicity VARCHAR(255)); CREATE TABLE Artworks (id INT, artist_id INT, artwork_name VARCHAR(255), year_created INT); INSERT INTO Artists (id, artist_name, gender, ethnicity) VALUES (1, 'José Clemente Orozco', 'Male', 'Hispanic'); INSERT INTO Ar... | Delete all artworks created by 'Male Hispanic' artists | DELETE A FROM Artworks A INNER JOIN Artists B ON A.artist_id = B.id WHERE B.gender = 'Male' AND B.ethnicity = 'Hispanic'; DELETE FROM Artists WHERE gender = 'Male' AND ethnicity = 'Hispanic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, sector VARCHAR(50), generation_kg INT, date DATE); INSERT INTO waste_generation (id, sector, generation_kg, date) VALUES (1, 'Industrial', 2500, '2021-01-01'), (2, 'Commercial', 1800, '2021-01-01'), (3, 'Residential', 1200, '2021-01-01'), (4, 'Industrial', 2300, '2021-02-01'), (5,... | What is the total waste generation for each sector in Q1 2021? | SELECT sector, SUM(generation_kg) FROM waste_generation WHERE date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE media (id INT, title VARCHAR(50), runtime INT, type VARCHAR(10), country VARCHAR(50)); | Find the titles and runtimes of all movies and tv shows in the media table that have a runtime over 120 minutes and were produced in the US or Canada. | SELECT title, runtime FROM media WHERE type IN ('movie', 'tv_show') AND runtime > 120 AND country IN ('US', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (id INT, name TEXT, location TEXT, cost_per_sqm FLOAT); INSERT INTO Buildings (id, name, location, cost_per_sqm) VALUES (1, 'BuildingA', 'East Asia', 8000.00), (2, 'BuildingB', 'East Asia', 9000.50), (3, 'BuildingC', 'East Asia', 7500.25); | What is the maximum construction cost per square meter for buildings in 'East Asia'? | SELECT MAX(cost_per_sqm) FROM Buildings WHERE location = 'East Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255), hours_per_week FLOAT); | Insert a new record into the 'volunteers' table | INSERT INTO volunteers (id, name, email, hours_per_week) VALUES (1, 'John Doe', '[john.doe@gmail.com](mailto:john.doe@gmail.com)', 10.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity (id INT, state VARCHAR(20), diversity_index FLOAT); INSERT INTO diversity (id, state, diversity_index) VALUES (1, 'Queensland', 0.65), (2, 'NewSouthWales', 0.72), (3, 'Victoria', 0.70); | Which state has the lowest workforce diversity index? | SELECT state, MIN(diversity_index) as min_index FROM diversity GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, title TEXT, category TEXT, publish_date DATE); INSERT INTO articles VALUES (1, 'Article 1', 'Politics', '2022-01-01'); INSERT INTO articles VALUES (2, 'Article 2', 'Sports', '2022-01-02'); | Find the number of articles published in each news category in 'categoryanalysis' database for the last year. | SELECT category, COUNT(*) FROM articles WHERE publish_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY category | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name VARCHAR(255), last_co2_report_date DATE, co2_emission INT); INSERT INTO mines (id, name, last_co2_report_date, co2_emission) VALUES (1, 'Mine A', '2022-01-15', 5000), (2, 'Mine B', '2022-02-20', 7000), (3, 'Mine C', '2022-03-10', 6000), (4, 'Mine D', '2022-04-01', 8000); | What is the total CO2 emission by mine for the last 6 months? | SELECT m.name, SUM(m.co2_emission) as total_co2_emission FROM mines m WHERE m.last_co2_report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY m.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Digital_Assets (id INT PRIMARY KEY, name VARCHAR(50), smart_contract_id INT, FOREIGN KEY (smart_contract_id) REFERENCES Smart_Contracts(id)); INSERT INTO Digital_Assets (id, name, smart_contract_id) VALUES (1, 'Asset1', 1); INSERT INTO Digital_Assets (id, name, smart_contract_id) VALUES (2, 'Asset2', 2); | List all digital assets and their regulatory laws in North America. | SELECT da.name, r.law FROM Digital_Assets da INNER JOIN Smart_Contracts sc ON da.smart_contract_id = sc.id INNER JOIN Regulations r ON sc.country = r.country WHERE r.region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Catfish_Production (Production_ID INT, Farm_ID INT, Location TEXT, Production_Volume INT); INSERT INTO Catfish_Production (Production_ID, Farm_ID, Location, Production_Volume) VALUES (1, 1, 'Mississippi', 1500), (2, 2, 'Alabama', 2000), (3, 3, 'Mississippi', 1700); | What is the total production volume for each location in the Catfish_Production table? | SELECT Location, SUM(Production_Volume) FROM Catfish_Production GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Meals (meal_id INT, meal_name VARCHAR(255), is_vegetarian BOOLEAN, restaurant_country VARCHAR(255)); INSERT INTO Meals (meal_id, meal_name, is_vegetarian, restaurant_country) VALUES (1, 'Spaghetti Bolognese', FALSE, 'Italy'), (2, 'Vegetable Lasagna', TRUE, 'Italy'), (3, 'Coq au Vin', FALSE, 'France'), (4, ... | What is the daily caloric intake for vegetarian meals in a French restaurant? | SELECT d.date, SUM(n.calories) as daily_caloric_intake FROM Days d JOIN Meals m ON d.day_id = m.meal_id JOIN Nutrition n ON m.meal_id = n.meal_id WHERE m.is_vegetarian = TRUE AND m.restaurant_country = 'France' GROUP BY d.date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2), organic BOOLEAN); INSERT INTO Products (id, name, category, price, organic) VALUES (1, 'Nourishing Lipstick', 'Makeup', 14.99, true), (2, 'Luxury Foundation', 'Makeup', 45.50, false), (3, 'Tinted Mascara', 'Makeup', 8.99, true); | What is the total price of organic cosmetic products? | SELECT SUM(p.price) as total_price FROM Products p WHERE p.organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE police_stations_2 (id INT, city VARCHAR(50), station_count INT); INSERT INTO police_stations_2 (id, city, station_count) VALUES (1, 'CityM', 5), (2, 'CityN', 10), (3, 'CityO', 8); | What is the total number of police stations in CityM? | SELECT station_count FROM police_stations_2 WHERE city = 'CityM'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, city VARCHAR(20), initiative VARCHAR(50)); INSERT INTO community_policing (id, city, initiative) VALUES (1, 'Vancouver', 'Neighborhood Watch'), (2, 'Montreal', 'Coffee with a Cop'), (3, 'Vancouver', 'Citizens Police Academy'); | What is the total number of community policing initiatives in the city of Vancouver? | SELECT COUNT(*) FROM community_policing WHERE city = 'Vancouver'; | gretelai_synthetic_text_to_sql |
CREATE TABLE desserts (id INT, name TEXT, type TEXT, sugar_grams INT); INSERT INTO desserts (id, name, type, sugar_grams) VALUES (1, 'Chocolate Mousse', 'vegan', 25), (2, 'Blueberry Cheesecake', 'non_vegan', 35); | What is the average sugar content in vegan desserts? | SELECT AVG(sugar_grams) FROM desserts WHERE type = 'vegan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_facilities (facility_id INT, name VARCHAR(255), county VARCHAR(255), has_telemedicine BOOLEAN); INSERT INTO healthcare_facilities (facility_id, name, county, has_telemedicine) VALUES (1, 'Pineville General', 'Pineville', true), (2, 'Pineville Clinic', 'Pineville', false), (3, 'Pineville Specialt... | What percentage of healthcare facilities in the rural county of 'Pineville' have telemedicine capabilities? | SELECT 100.0 * COUNT(*) FILTER (WHERE has_telemedicine = true) / COUNT(*) FROM healthcare_facilities WHERE county = 'Pineville'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaitingTimes (WaitingTimeID INT, ClinicID INT, DoctorID INT, Date DATE, WaitingTime INT); INSERT INTO WaitingTimes (WaitingTimeID, ClinicID, DoctorID, Date, WaitingTime) VALUES (1, 1, 1, '2021-10-01', 30); | What is the average waiting time for patients to see a doctor, grouped by the day of the week and the location of the clinic? | SELECT DATEPART(dw, Date) AS DayOfWeek, Location, AVG(WaitingTime) FROM WaitingTimes wt JOIN Clinics cl ON wt.ClinicID = cl.ClinicID GROUP BY DATEPART(dw, Date), Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name TEXT); INSERT INTO factories (id, name) VALUES (1, 'Factory A'), (2, 'Factory B'); CREATE TABLE chemical_produced (factory_id INT, chemical_name TEXT); INSERT INTO chemical_produced (factory_id, chemical_name) VALUES (1, 'Chemical X'), (1, 'Chemical X'), (2, 'Chemical Y'), (2, 'Chem... | Find the number of unique chemicals produced by each factory. | SELECT factory_id, COUNT(DISTINCT chemical_name) AS unique_chemicals_produced FROM chemical_produced GROUP BY factory_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, date DATE, water_usage INT); INSERT INTO water_usage (id, date, water_usage) VALUES (1, '2022-01-01', 5000), (2, '2022-01-02', 5500), (3, '2022-01-03', 4500); | What is the maximum water usage for a single day in the 'water_usage' table? | SELECT MAX(water_usage) FROM water_usage; | gretelai_synthetic_text_to_sql |
CREATE TABLE stations (station_id INT, station_name TEXT); INSERT INTO stations (station_id, station_name) VALUES (1, 'New York'), (2, 'Boston'); CREATE TABLE train_routes (route_id INT, start_station INT, end_station INT, distance INT, fare DECIMAL); | Insert a new train route from 'New York' to 'Boston' with a distance of 400 km and a fare of $150. | INSERT INTO train_routes (route_id, start_station, end_station, distance, fare) VALUES (1, (SELECT station_id FROM stations WHERE station_name = 'New York'), (SELECT station_id FROM stations WHERE station_name = 'Boston'), 400, 150); | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_institutions (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE shariah_compliant_finance (id INT, financial_institution_id INT, branches INT); | List all financial institutions offering Shariah-compliant finance in Southeast Asia, sorted by the number of branches in descending order. | SELECT financial_institutions.name FROM financial_institutions INNER JOIN shariah_compliant_finance ON financial_institutions.id = shariah_compliant_finance.financial_institution_id WHERE region = 'Southeast Asia' ORDER BY branches DESC; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.