context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE crime_victims (id INT, gender TEXT, age INT, crime_type TEXT); | How many victims of crime are recorded in the 'crime_victims' table by gender? | SELECT gender, COUNT(*) FROM crime_victims GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE BrandSkincareSales (sale_id INT, product_name TEXT, brand TEXT, sale_amount FLOAT, sale_date DATE); INSERT INTO BrandSkincareSales (sale_id, product_name, brand, sale_amount, sale_date) VALUES (1, 'Cleanser', 'Brand A', 50.00, '2021-01-01'); INSERT INTO BrandSkincareSales (sale_id, product_name, brand, sal... | find the total sales of skincare products in the first quarter of 2021 for each brand | SELECT brand, SUM(sale_amount) AS total_sales FROM BrandSkincareSales WHERE sale_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE blockchains (id INT, name VARCHAR(255), num_assets INT); INSERT INTO blockchains (id, name, num_assets) VALUES (1, 'Bitcoin', 1000), (2, 'Ethereum', 5000), (3, 'Ripple', 2000), (4, 'Binance Smart Chain', 3000), (5, 'Cardano', 4000); | What are the top 3 blockchains with the most digital assets? | SELECT name, num_assets FROM blockchains ORDER BY num_assets DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, program VARCHAR(50), country VARCHAR(50)); CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(50), program VARCHAR(50), country VARCHAR(50)); INSERT INTO Donations (id, donation_amount, donation_date, program, country) VALUES (1, 10... | What is the total number of volunteers and total donation amount for each program in Philippines? | SELECT p.program, COUNT(DISTINCT v.volunteer_name) as num_volunteers, SUM(d.donation_amount) as total_donations FROM Donations d INNER JOIN Volunteers v ON d.program = v.program INNER JOIN Programs p ON d.program = p.program WHERE d.country = 'Philippines' GROUP BY p.program; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_farms (id INT, name VARCHAR(30), num_employees INT, certification_level VARCHAR(10)); | What is the total number of farmers in the 'agricultural_farms' table per certification level? | SELECT certification_level, COUNT(*) FROM agricultural_farms GROUP BY certification_level; | gretelai_synthetic_text_to_sql |
CREATE TABLE sourcing (year INT, country VARCHAR(20), fabric_type VARCHAR(20), quantity INT); INSERT INTO sourcing (year, country, fabric_type, quantity) VALUES (2022, 'India', 'sustainable', 3000), (2022, 'India', 'regular', 5000); | What is the total quantity of sustainable fabric sourced from India in 2022? | SELECT SUM(quantity) FROM sourcing WHERE year = 2022 AND country = 'India' AND fabric_type = 'sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO factories (id, name, country) VALUES (1, 'Eco-friendly Goods Inc', 'Canada'); CREATE TABLE products (id INT, name VARCHAR(255), quantity INT); INSERT INTO products (id, name, quantity) VALUES (1, 'Eco-friendly Tote Bag', 2000); CREATE... | What is the total quantity of product 'Eco-friendly Tote Bag' manufactured by factories in Canada? | SELECT SUM(products.quantity) as total_quantity FROM products INNER JOIN manufacturing ON products.id = manufacturing.product_id INNER JOIN factories ON manufacturing.factory_id = factories.id WHERE factories.country = 'Canada' AND products.name = 'Eco-friendly Tote Bag'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (country VARCHAR(255), element VARCHAR(255), quantity INT); INSERT INTO inventory (country, element, quantity) VALUES ('Malaysia', 'Samarium', 1000), ('Malaysia', 'Gadolinium', 1500), ('Malaysia', 'Ytterbium', 2000); | How many Rare Earth Elements does Malaysia have in their inventory? | SELECT SUM(quantity) as total_quantity FROM inventory WHERE country = 'Malaysia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (id INT, year INT, program VARCHAR(30), amount INT); INSERT INTO budget (id, year, program, amount) VALUES (1, 2017, 'rural health', 5000000); | What is the total budget allocated for rural health programs in the last 5 years? | SELECT SUM(amount) FROM budget WHERE program = 'rural health' AND year BETWEEN 2017 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_workforce_history (mine_id INT, change_date DATE, num_employees INT); INSERT INTO mine_workforce_history (mine_id, change_date, num_employees) VALUES (1, '2021-01-01', 500), (1, '2021-04-01', 450), (2, '2021-01-01', 450), (2, '2021-04-01', 450), (3, '2021-01-01', 400), (3, '2021-04-01', 350); | Identify mines that have reduced their workforce in the last quarter. | SELECT mine_id, change_date, num_employees, LAG(num_employees) OVER (PARTITION BY mine_id ORDER BY change_date) as prev_quarter_employees, num_employees - LAG(num_employees) OVER (PARTITION BY mine_id ORDER BY change_date) as employess_change FROM mine_workforce_history WHERE num_employees < LAG(num_employees) OVER (PA... | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists work_hours (id INT PRIMARY KEY, worker_id INT, sector VARCHAR(255), hours_per_week INT); INSERT INTO work_hours (id, worker_id, sector, hours_per_week) VALUES (1, 101, 'retail', 40), (2, 102, 'retail', 45), (3, 103, 'manufacturing', 50); | What is the maximum number of hours worked per week by workers in the 'retail' sector, including overtime? | SELECT MAX(hours_per_week) FROM work_hours WHERE sector = 'retail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safe_ai_algorithms (algorithm_id INT, algorithm_name TEXT, is_safe BOOLEAN, developer_gender TEXT); INSERT INTO safe_ai_algorithms (algorithm_id, algorithm_name, is_safe, developer_gender) VALUES (1, 'Safe AI', true, 'Female'), (2, 'Unsafe AI', false, 'Non-binary'), (3, 'Safe AI', true, 'Non-binary'); | What is the ratio of safe AI algorithms to unsafe AI algorithms developed by women and non-binary individuals? | SELECT developer_gender, SUM(is_safe) as num_safe, COUNT(*) as num_total, 1.0 * SUM(is_safe) / COUNT(*) as ratio FROM safe_ai_algorithms GROUP BY developer_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sustainable_Practices (project_id INT, practice VARCHAR(255), region VARCHAR(255), completion_date DATE); INSERT INTO Sustainable_Practices (project_id, practice, region, completion_date) VALUES (1, 'Solar Panels', 'West Coast', '2019-04-15'); INSERT INTO Sustainable_Practices (project_id, practice, region... | Which sustainable building practices were implemented in projects located in 'West Coast' region between 2018 and 2020? | SELECT practice FROM Sustainable_Practices WHERE region = 'West Coast' AND completion_date BETWEEN '2018-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicWorksProjects (ProjectID INT, Name VARCHAR(255), Location VARCHAR(255), Status VARCHAR(255)); INSERT INTO PublicWorksProjects VALUES (1, 'Water Treatment Plant', 'Colorado', 'Completed'); INSERT INTO PublicWorksProjects VALUES (2, 'Sewer System Upgrade', 'California', 'In Progress'); INSERT INTO Publ... | How many public works projects have been completed in each country, and which ones are they? | SELECT Location, COUNT(*) as NumberOfProjects, STRING_AGG(Name, ', ') as CompletedProjects FROM PublicWorksProjects WHERE Status = 'Completed' GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_categories (category_id INT, category VARCHAR(50), description TEXT); INSERT INTO fairness_categories (category_id, category, description) VALUES (1, 'Racial', 'Fairness related to race and ethnicity'), (2, 'Gender', 'Fairness related to gender and gender identity'), (3, 'Age', 'Fairness related t... | List the unique algorithmic fairness categories and corresponding descriptions, ordered by category in ascending order. | SELECT DISTINCT category, description FROM fairness_categories ORDER BY category ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_consumption (region VARCHAR(50), water_consumption INT); INSERT INTO water_consumption (region, water_consumption) VALUES ('North America', 2000), ('South America', 2500), ('Southeast Asia', 1700), ('Europe', 1800), ('Africa', 2200); | What is the average water consumption for organic cotton production in Southeast Asia? | SELECT region, AVG(water_consumption) FROM water_consumption WHERE region = 'Southeast Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE endangered_species (name VARCHAR(255), status VARCHAR(50)); | Identify the number of species in the 'endangered_species' table. | SELECT COUNT(*) FROM endangered_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE TransitUsersNew (id INT, city VARCHAR(50), usage INT); INSERT INTO TransitUsersNew (id, city, usage) VALUES (1, 'New York', 5000); INSERT INTO TransitUsersNew (id, city, usage) VALUES (2, 'Boston', 3000); | What is the total number of public transportation users in the cities of New York and Boston? | SELECT SUM(usage) FROM TransitUsersNew WHERE city IN ('New York', 'Boston'); | gretelai_synthetic_text_to_sql |
CREATE TABLE field_sensors (field_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); | Insert a new record with sensor type 'moisture' and a value of 45.3 in field 5 at 2023-02-18 10:00:00. | INSERT INTO field_sensors (field_id, sensor_type, value, timestamp) VALUES (5, 'moisture', 45.3, '2023-02-18 10:00:00'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rocket_engines (engine_name VARCHAR(20), manufacturer VARCHAR(20), thrust INT, fuel_type VARCHAR(10)); INSERT INTO rocket_engines (engine_name, manufacturer, thrust, fuel_type) VALUES ('RS-25', 'Pratt & Whitney', 1890000, 'Liquid'), ('Merlin', 'SpaceX', 845000, 'Liquid'), ('RD-180', 'NPO Energomash', 18880... | Show the number of engines produced by each manufacturer | SELECT manufacturer, COUNT(*) FROM rocket_engines GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, industry TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, funding) VALUES (1, 'Genetech', 'Pharmaceuticals', 50000000); INSERT INTO startups (id, name, industry, funding) VALUES (2, 'BioSteward', 'Bioinformatics', 75000000); | What is the total funding received by biotech startups, grouped by the industry sector they operate in. | SELECT industry, SUM(funding) FROM startups GROUP BY industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(50), location VARCHAR(50), un_code VARCHAR(10)); CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(50), year_built INT, port_id INT); CREATE TABLE captains (id INT, name VARCHAR(50), age INT, license_number VARCHAR(20), vessel_id INT); CREATE TABLE cargo (id INT, desc... | Identify the vessels that have visited the port of 'Tianjin' but have not carried any cargo. | SELECT DISTINCT vessels.name FROM vessels LEFT JOIN cargo ON vessels.id = cargo.vessel_id WHERE cargo.vessel_id IS NULL AND vessels.port_id IN (SELECT id FROM ports WHERE name = 'Tianjin'); | gretelai_synthetic_text_to_sql |
CREATE TABLE power_sector (country VARCHAR(50), region VARCHAR(50), year INT, carbon_intensity FLOAT); INSERT INTO power_sector (country, region, year, carbon_intensity) VALUES ('India', 'South Asia', 2018, 0.75); INSERT INTO power_sector (country, region, year, carbon_intensity) VALUES ('India', 'South Asia', 2019, 0.... | What is the average carbon intensity of the power sector in the South Asian region for the years 2018 to 2020? | SELECT region, AVG(carbon_intensity) FROM power_sector WHERE region = 'South Asia' AND year BETWEEN 2018 AND 2020 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT, name VARCHAR(50), status VARCHAR(20)); INSERT INTO animals (id, name, status) VALUES (1, 'Tiger', 'Endangered'); INSERT INTO animals (id, name, status) VALUES (2, 'Elephant', 'Vulnerable'); INSERT INTO animals (id, name, status) VALUES (3, 'Rhino', 'Critically Endangered'); INSERT INTO ani... | Find the number of animals in each status category, ordered by the number of animals in each category in descending order | SELECT status, COUNT(*) FROM animals GROUP BY status ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, state VARCHAR(2), policy_type VARCHAR(20), age INT); INSERT INTO policyholders (id, state, policy_type, age) VALUES (1, 'TX', 'Auto', 30), (2, 'TX', 'Health', 40), (3, 'TX', 'Auto', 50); | What is the average age of policyholders with auto insurance policies in Texas? | SELECT AVG(age) FROM policyholders WHERE state = 'TX' AND policy_type = 'Auto'; | gretelai_synthetic_text_to_sql |
CREATE TABLE locations (location_id INT, location TEXT); INSERT INTO locations (location_id, location) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Toronto'), (4, 'Mumbai'), (5, 'London'); | What are the top 10 most common donor locations, along with the number of donors from each? | SELECT l.location, COUNT(dn.donor_id) as donor_count FROM donors dn JOIN locations l ON SUBSTRING_INDEX(dn.address, ' ', 1) = l.location GROUP BY l.location ORDER BY donor_count DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment_incidents (incident_date DATE, incident_type VARCHAR(255)); INSERT INTO military_equipment_incidents (incident_date, incident_type) VALUES ('2021-01-01', 'Malfunction'), ('2021-01-15', 'Collision'), ('2021-03-20', 'Theft'), ('2021-04-01', 'Malfunction'), ('2021-05-01', 'Collision'), ('20... | How many military equipment incidents occurred in each month in 2021? | SELECT DATE_TRUNC('month', incident_date) AS month, COUNT(*) as num_incidents FROM military_equipment_incidents WHERE incident_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT); CREATE TABLE bills (bill_id INT, client_id INT, amount DECIMAL(10, 2), paid BOOLEAN); | List all clients who have not paid their bills in full. | SELECT c.client_id, c.name FROM clients c JOIN bills b ON c.client_id = b.client_id WHERE b.paid = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_engineering (item_name VARCHAR(50), sales_volume INT); | Delete records in the menu_engineering table where the sales_volume is greater than 100 | DELETE FROM menu_engineering WHERE sales_volume > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableCapacity (Continent TEXT, Year INT, Capacity NUMBER); INSERT INTO RenewableCapacity (Continent, Year, Capacity) VALUES ('Africa', 2020, 120000), ('South America', 2020, 180000); CREATE TABLE FossilFuelCapacity (Continent TEXT, Year INT, Capacity NUMBER); INSERT INTO FossilFuelCapacity (Continent, ... | What is the total installed renewable energy capacity in Africa and South America as of 2020? | SELECT RenewableCapacity.Continent, SUM(RenewableCapacity.Capacity) AS Total_Renewable_Capacity FROM RenewableCapacity WHERE RenewableCapacity.Continent IN ('Africa', 'South America') AND RenewableCapacity.Year = 2020 GROUP BY RenewableCapacity.Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workplace_Safety_Incidents (id INT, union VARCHAR(255), incident_type VARCHAR(255), reported_date DATE); INSERT INTO Workplace_Safety_Incidents (id, union, incident_type, reported_date) VALUES (1, 'Union A', 'Chemical Spill', '2020-01-05'); | What is the total number of workplace safety incidents reported in the year 2020? | SELECT COUNT(*) FROM Workplace_Safety_Incidents WHERE YEAR(reported_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE holdings (holding_id INT, customer_id INT, ticker VARCHAR(10), shares INT); INSERT INTO holdings (holding_id, customer_id, ticker, shares) VALUES (1, 1, 'AAPL', 100), (2, 1, 'MSFT', 75), (3, 2, 'AAPL', 150), (4, 3, 'JPM', 200), (5, 4, 'AAPL', 250), (6, 5, 'TSLA', 50); | What is the maximum number of shares held by a single customer for the 'AAPL' stock? | SELECT MAX(shares) FROM holdings WHERE ticker = 'AAPL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE railroad_sections (id INT, section_name VARCHAR(50), location VARCHAR(50)); INSERT INTO railroad_sections (id, section_name, location) VALUES (1, 'Section 1', 'Urban'), (2, 'Section 2', 'Suburban'), (3, 'Section 3', 'Rural'); | How many 'railroad_sections' are there in 'Suburban' locations? | SELECT COUNT(*) FROM railroad_sections WHERE location = 'Suburban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(50), industry VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, industry, funding) VALUES (1, 'StartupA', 'AU', 'Biotech', 1000000.0); INSERT INTO startups (id, name, location, industry, funding) VALUES (2, 'StartupB', 'CA', 'Softwa... | Which biotech startups have received funding in Australia? | SELECT name FROM startups WHERE location = 'AU' AND industry = 'Biotech'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, country VARCHAR(50), data_usage INT); INSERT INTO mobile_subscribers (subscriber_id, country, data_usage) VALUES (1, 'China', 100), (2, 'Brazil', 150), (3, 'Indonesia', 200), (4, 'Russia', 250), (5, 'China', 50), (6, 'Brazil', 75), (7, 'Indonesia', 125), (8, 'Russia',... | What is the average data usage for mobile subscribers in each country? | SELECT country, AVG(data_usage) AS avg_data_usage FROM mobile_subscribers GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sentiments (id INT PRIMARY KEY, sentiment FLOAT); INSERT INTO Sentiments (id, sentiment) VALUES (1, 0.5), (2, 0.7), (3, 0.6); CREATE TABLE Articles (id INT PRIMARY KEY, title TEXT, language_id INT, sentiment_id INT, FOREIGN KEY (language_id) REFERENCES Languages(id), FOREIGN KEY (sentiment_id) REFERENCES S... | What is the average sentiment score for articles published in a specific language, grouped by day? | SELECT l.language, DATE_FORMAT(a.date, '%Y-%m-%d') as date, AVG(s.sentiment) as avg_sentiment FROM Articles a JOIN Languages l ON a.language_id = l.id JOIN Sentiments s ON a.sentiment_id = s.id GROUP BY l.language, date; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (shipment_id INT, item_code VARCHAR(5), warehouse_id VARCHAR(5), quantity INT); CREATE TABLE warehouses (warehouse_id VARCHAR(5), city VARCHAR(5), state VARCHAR(3)); INSERT INTO shipments VALUES (1, 'AAA', 'LAX', 200), (2, 'BBB', 'NYC', 300), (3, 'AAA', 'LAX', 100), (4, 'CCC', 'NYC', 50), (5, 'BB... | What is the total quantity of all items shipped from warehouse 'LAX' and 'NYC'? | SELECT SUM(quantity) FROM shipments JOIN warehouses ON shipments.warehouse_id = warehouses.warehouse_id WHERE warehouses.city IN ('LAX', 'NYC'); | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyTypes (PolicyTypeID int, PolicyType varchar(20)); CREATE TABLE Claims (ClaimID int, PolicyTypeID int, ClaimAmount decimal); INSERT INTO PolicyTypes (PolicyTypeID, PolicyType) VALUES (1, 'Home'); INSERT INTO PolicyTypes (PolicyTypeID, PolicyType) VALUES (2, 'Auto'); INSERT INTO Claims (ClaimID, Policy... | List policy types and their respective average claim amounts. | SELECT PolicyTypes.PolicyType, AVG(Claims.ClaimAmount) FROM PolicyTypes INNER JOIN Claims ON PolicyTypes.PolicyTypeID = Claims.PolicyTypeID GROUP BY PolicyTypes.PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_applications (app_id INT, name TEXT, country TEXT, category TEXT); INSERT INTO ai_applications (app_id, name, country, category) VALUES (1, 'ArtBot', 'Nigeria', 'Creative'), (2, 'MusicGen', 'South Africa', 'Creative'), (3, 'DataViz', 'US', 'Analytical'), (4, 'ChatAssist', 'Canada', 'Assistive'); | How many creative AI applications have been developed in Africa? | SELECT COUNT(*) FROM ai_applications WHERE country IN (SELECT country FROM ai_applications WHERE category = 'Creative') AND category = 'Creative'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovations (innovation_id INT, innovation_name VARCHAR(50), innovation_year INT, innovation_description TEXT); | Delete all records in the military_innovations table where the innovation_name contains 'cyber' | DELETE FROM military_innovations WHERE innovation_name LIKE '%cyber%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, sale_date DATE); INSERT INTO sales (sale_id, product_id, quantity, sale_date) VALUES (1, 1, 3, '2022-01-05'), (2, 2, 1, '2022-01-07'); CREATE TABLE product (product_id INT, product_name TEXT, region_id INT); INSERT INTO product (product_id, product_name, re... | How many items were sold in each region in the last month? | SELECT r.region_name, SUM(s.quantity) as total_sold FROM sales s JOIN product p ON s.product_id = p.product_id JOIN region r ON p.region_id = r.region_id WHERE s.sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(255), coastline VARCHAR(50), policies VARCHAR(255)); INSERT INTO countries (id, name, coastline, policies) VALUES (1, 'India', 'Indian Ocean', 'Yes'), (2, 'China', 'Pacific Ocean', 'No'); | Which countries have a coastline along the Indian Ocean and have enacted policies for marine conservation? | SELECT name FROM countries WHERE coastline = 'Indian Ocean' AND policies = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_violations (violation_id INT, country VARCHAR(20), fine DECIMAL(10,2)); | Find the number of labor violations in each country and the total fine amount. | SELECT country, COUNT(*), SUM(fine) FROM labor_violations GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE LocalFarm (FarmID INT, IsLocal BOOLEAN); INSERT INTO LocalFarm (FarmID, IsLocal) VALUES (1, TRUE), (2, FALSE), (3, TRUE); | Total quantity of food items from local farms | SELECT SUM(i.Quantity) FROM FoodItem f INNER JOIN LocalFarm l ON f.FarmID = l.FarmID INNER JOIN Inventory i ON f.ItemID = i.ItemID WHERE l.IsLocal = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE government_meetings (meeting_id INT, duration INT); | What is the total duration of public meetings in 'government_meetings' table, excluding meetings with a duration less than 1 hour? | SELECT SUM(duration) FROM government_meetings WHERE duration >= 60; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists mining;CREATE TABLE mining.extraction (id INT, company STRING, mineral STRING, tons INT);INSERT INTO mining.extraction (id, company, mineral, tons) VALUES (1, 'company C', 'mineral X', 900), (2, 'company C', 'mineral Y', 1100); | List all unique minerals extracted by 'company C'. | SELECT DISTINCT mineral FROM mining.extraction WHERE company = 'company C'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(2), followers INT); INSERT INTO users (id, name, country, followers) VALUES (1, 'Alice', 'US', 1000), (2, 'Bob', 'JP', 500), (3, 'Charlie', 'CA', 1500), (4, 'David', 'MX', 200), (5, 'Eve', 'DE', 800); CREATE TABLE posts (id INT, user_id INT, timestamp DATETI... | Find users who have not received any likes on their posts and are from a country other than the US. | SELECT users.name FROM users LEFT JOIN posts ON users.id = posts.user_id WHERE users.country != 'US' AND posts.likes = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations(student_id INT, accommodation_id INT, cost DECIMAL(5,2)); | What is the average cost of accommodations per student? | SELECT AVG(cost) FROM Accommodations; | gretelai_synthetic_text_to_sql |
CREATE TABLE Forests (Fid INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Area FLOAT); CREATE TABLE Carbon (Cid INT PRIMARY KEY, Fid INT, Year INT, Sequestration FLOAT, FOREIGN KEY (Fid) REFERENCES Forests(Fid)); CREATE TABLE Harvest (Hid INT PRIMARY KEY, Fid INT, Year INT, Volume INT, FOREIGN KEY (Fid) REFEREN... | What are the names of forests in India and their respective annual harvest volumes, if any, and the carbon sequestration amounts for each year? | SELECT Forests.Name, Carbon.Year, SUM(Carbon.Sequestration), Harvest.Volume FROM Forests FULL OUTER JOIN Carbon ON Forests.Fid = Carbon.Fid LEFT JOIN Harvest ON Forests.Fid = Harvest.Fid WHERE Forests.Country = 'India' GROUP BY Carbon.Year, Harvest.Volume, Forests.Name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA FoodService;CREATE TABLE MenuItems (menu_item_id INT, restaurant_id INT, name VARCHAR(50), cost FLOAT); INSERT INTO MenuItems (menu_item_id, restaurant_id, name, cost) VALUES (1, 1, 'Seafood Risotto', 20.00), (2, 1, 'Caesar Salad', 12.00), (3, 2, 'Chicken Shawarma', 15.00), (4, 2, 'Falafel Plate', 10.00); | Which menu items have the highest cost for each restaurant category? | SELECT restaurant_id, name, MAX(cost) as highest_cost FROM MenuItems GROUP BY restaurant_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, department VARCHAR(20), enrollment_status VARCHAR(10)); INSERT INTO graduate_students (id, department, enrollment_status) VALUES (1, 'Computer Science', 'Enrolled'), (2, 'Physics', 'Enrolled'), (3, 'Mathematics', 'Not Enrolled'); | Find the number of graduate students enrolled in each department, excluding those enrolled in the 'Computer Science' department. | SELECT department, COUNT(*) as enrollment_count FROM graduate_students WHERE department != 'Computer Science' GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (id INT, city VARCHAR(50), type VARCHAR(50), passengers INT); | Insert new data into the 'public_transportation' table | INSERT INTO public_transportation (id, city, type, passengers) VALUES (1, 'New York', 'Subway', 5000); | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT PRIMARY KEY, animal_id INT, location_id INT, incident_date DATE, incident_type VARCHAR(50)); | Insert a new record into the 'incidents' table with the following details: 'incident_id' as 6, 'animal_id' as 4, 'location_id' as 3, 'incident_date' as '2022-02-22', 'incident_type' as 'Injury' | INSERT INTO incidents (incident_id, animal_id, location_id, incident_date, incident_type) VALUES (6, 4, 3, '2022-02-22', 'Injury'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vegan_dishes (dish_id INT, name VARCHAR(50), calorie_count INT, total_fat DECIMAL(3,2)); INSERT INTO vegan_dishes VALUES (1, 'Vegan Lasagna', 450, 15.5); INSERT INTO vegan_dishes VALUES (2, 'Quinoa Stir Fry', 350, 10.5); CREATE TABLE served_here (dish_id INT, location VARCHAR(50)); INSERT INTO served_here ... | Find the average calorie count and total fat for vegan dishes served at 'Fresh Harvest'. | SELECT AVG(vd.calorie_count), AVG(vd.total_fat) FROM vegan_dishes vd JOIN served_here sh ON vd.dish_id = sh.dish_id WHERE sh.location = 'Fresh Harvest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threats (name TEXT, description TEXT, severity TEXT); INSERT INTO threats (name, description, severity) VALUES ('Cyber Terrorism', 'Attacks on critical infrastructure.', 'High'), ('Nuclear Proliferation', 'Spread of nuclear weapons.', 'Medium'), ('Climate Change', 'Environmental degradation and instability... | List all national security threats in the threats table that have a severity level of "High". | SELECT name FROM threats WHERE severity = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vaccinations (VaccinationID INT, Date DATE, VaccinesAdministered INT); INSERT INTO Vaccinations (VaccinationID, Date, VaccinesAdministered) VALUES (1, '2021-08-01', 5000); INSERT INTO Vaccinations (VaccinationID, Date, VaccinesAdministered) VALUES (2, '2021-08-02', 5500); | What is the maximum number of vaccines administered in a day in New York? | SELECT MAX(VaccinesAdministered) FROM Vaccinations WHERE Date BETWEEN '2021-08-01' AND '2021-08-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE medical_equipment (country VARCHAR(20), center_name VARCHAR(50), purchase_date DATE); INSERT INTO medical_equipment (country, center_name, purchase_date) VALUES ('Mexico', 'Center Z', '2018-01-01'), ('Mexico', 'Center AA', '2019-01-01'), ('Colombia', 'Center BB', '2020-01-01'), ('Colombia', 'Center CC', '2... | What is the total number of medical equipment items in rural health centers in Mexico and Colombia that were purchased in the last 5 years? | SELECT country, COUNT(*) FROM medical_equipment WHERE purchase_date >= DATEADD(year, -5, CURRENT_DATE) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (debris_id INT, name VARCHAR(255), type VARCHAR(255), mass FLOAT); INSERT INTO space_debris (debris_id, name, type, mass) VALUES (1, 'Defunct Satellite', 'Satellite', 1500.0); | What is the total mass of space debris by type? | SELECT type, SUM(mass) as total_mass FROM space_debris GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE cyber_incidents (id INT, incident_date DATE, incident_type VARCHAR(255)); | Which cybersecurity incidents were reported in the last 6 months from the 'cyber_incidents' table? | SELECT * FROM cyber_incidents WHERE incident_date >= DATE(NOW()) - INTERVAL 6 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, game_name TEXT, game_category TEXT, game_purchase_price FLOAT, release_year INT); INSERT INTO games (game_id, game_name, game_category, game_purchase_price, release_year) VALUES (1, 'Game A', 'Role-playing', 49.99, 2018), (2, 'Game B', 'Action', 59.99, 2019), (3, 'Game C', 'Role-playing... | What is the average game purchase price for games released in 2018? | SELECT AVG(game_purchase_price) as avg_price FROM games WHERE release_year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE harvest (harvest_id INT, country VARCHAR(20), year INT, species VARCHAR(20), quantity INT); INSERT INTO harvest VALUES (1, 'Norway', 2022, 'Salmon', 10000), (2, 'Chile', 2022, 'Tilapia', 8000), (3, 'Norway', 2021, 'Salmon', 12000), (4, 'China', 2022, 'Carp', 15000); | What is the total number of fish harvested from each country in the year 2022? | SELECT country, COUNT(*) AS 'Total Harvested' FROM harvest WHERE year = 2022 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, location VARCHAR(50), completion_date DATE); INSERT INTO projects (id, location, completion_date) VALUES (1, 'Kenya', '2015-05-01'), (2, 'Nigeria', '2017-12-31'), (3, 'Ghana', '2016-08-15'), (4, 'Uganda', '2018-09-05'), (5, 'Tanzania', '2014-11-23'); | How many community development projects were completed in Africa between 2015 and 2018? | SELECT COUNT(*) FROM projects WHERE location LIKE 'Africa%' AND completion_date BETWEEN '2015-01-01' AND '2018-12-31'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS logistics;CREATE TABLE IF NOT EXISTS customers (customer_id INT,customer_name VARCHAR(50));CREATE TABLE IF NOT EXISTS shipments (shipment_id INT,customer_id INT,shipment_date DATE,shipment_type VARCHAR(20),revenue DECIMAL(10,2));INSERT INTO customers (customer_id, customer_name) VALUES (1, '... | List the top 3 customers with the highest total spend on international shipments in the last quarter of 2020, along with the total spent by each customer. | SELECT customer_name, SUM(revenue) AS total_spent FROM logistics.customers c JOIN logistics.shipments s ON c.customer_id = s.customer_id WHERE shipment_type = 'international' AND QUARTER(shipment_date) = 4 GROUP BY customer_name ORDER BY total_spent DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_tech (id INT, name VARCHAR(255), country VARCHAR(255), status VARCHAR(255));INSERT INTO military_tech (id, name, country, status) VALUES (1, 'F-35', 'USA', 'active'), (2, 'Abrams M1', 'USA', 'inactive'), (3, 'Javelin', 'USA', 'active'); | Delete all records from the military_tech table that are no longer active. | DELETE FROM military_tech WHERE status != 'active'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies_esg_2 (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies_esg_2 (id, sector, ESG_score) VALUES (1, 'technology', 72.5), (2, 'finance', 80.2), (3, 'technology', 76.1); | What's the average ESG score for companies in the 'finance' and 'technology' sectors? | SELECT sector, AVG(ESG_score) FROM companies_esg_2 WHERE sector IN ('finance', 'technology') GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists decommissioned_well (well_id INT, well_name TEXT, decommission_year INT); INSERT INTO decommissioned_well (well_id, well_name, decommission_year) VALUES (1, 'Well A', 2021), (2, 'Well D', 2020), (3, 'Well E', 2021); | Identify the wells that were decommissioned in 2021 | SELECT well_name FROM decommissioned_well WHERE decommission_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Festivals (region VARCHAR(20), year INT, revenue DECIMAL(5,2)); INSERT INTO Festivals (region, year, revenue) VALUES ('Europe', 2022, 500000.00), ('Europe', 2022, 750000.00), ('US', 2022, 800000.00); | What is the total revenue for music festivals in Europe in 2022? | SELECT SUM(revenue) FROM Festivals WHERE region = 'Europe' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE gold_production (id INT, name TEXT, location TEXT, timestamp TIMESTAMP, gold_produced FLOAT); INSERT INTO gold_production (id, name, location, timestamp, gold_produced) VALUES (1, 'Golden Eagle Mine', 'Nevada', '2021-01-01 12:00:00', 1200); | What is the total amount of gold produced by the mining operations in the state of Nevada last year? | SELECT SUM(gold_produced) FROM gold_production WHERE location = 'Nevada' AND EXTRACT(YEAR FROM timestamp) = EXTRACT(YEAR FROM CURRENT_DATE) - 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_health_indicators (indicator_id INT PRIMARY KEY, indicator_name VARCHAR(255)); | Create a table named 'ocean_health_metrics' | CREATE TABLE ocean_health_metrics (metric_id INT PRIMARY KEY, location_id INT, indicator_id INT, year INT, value FLOAT, FOREIGN KEY (location_id) REFERENCES farm_locations(location_id), FOREIGN KEY (indicator_id) REFERENCES ocean_health_indicators(indicator_id)); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, volunteer_name TEXT, program TEXT, participation_date DATE); INSERT INTO Volunteers (id, volunteer_name, program, participation_date) VALUES (1, 'Alice', 'Feed the Hungry', '2022-01-01'), (2, 'Bob', 'Tutor Kids', '2022-01-02'); | How many volunteers engaged in each program, having more than 20 participants? | SELECT program, COUNT(*) FROM Volunteers GROUP BY program HAVING COUNT(*) > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (id INT, date DATE, industry VARCHAR(255), member_count INT); INSERT INTO union_members (id, date, industry, member_count) VALUES (1, '2022-01-01', 'education', 500), (2, '2022-02-01', 'education', 550), (3, '2022-03-01', 'education', 600); | What is the average number of union members per month in the 'education' schema for the year '2022'? | SELECT AVG(member_count) FROM union_members WHERE industry = 'education' AND date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AccessToJustice (case_id INT, case_type VARCHAR(10)); INSERT INTO AccessToJustice (case_id, case_type) VALUES (1, 'civil'), (2, 'criminal'), (3, 'constitutional'); | List the 'case_id' and 'case_type' for cases in the 'AccessToJustice' table where the 'case_type' starts with 'c' | SELECT case_id, case_type FROM AccessToJustice WHERE case_type LIKE 'c%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_projects (id INT, investor_type VARCHAR(50), year INT, project_count INT); INSERT INTO climate_finance_projects (id, investor_type, year, project_count) VALUES (1, 'Private Investor', 2020, 10); INSERT INTO climate_finance_projects (id, investor_type, year, project_count) VALUES (2, 'Public... | How many climate finance projects were initiated by public investors in 2019? | SELECT project_count FROM climate_finance_projects WHERE investor_type = 'Public Investor' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists workers (id INT PRIMARY KEY, sector VARCHAR(255), monthly_salary DECIMAL(10, 2)); INSERT INTO workers (id, sector, monthly_salary) VALUES (1, 'manufacturing', 2500.00), (2, 'manufacturing', 3000.50), (3, 'manufacturing', 1800.00); | What is the average monthly salary of workers in the 'manufacturing' sector, excluding those earning below the minimum wage? | SELECT AVG(monthly_salary) FROM workers WHERE monthly_salary > (SELECT MIN(monthly_salary) FROM workers WHERE sector = 'manufacturing') AND sector = 'manufacturing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (Id INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Age INT, Gender VARCHAR(10)); CREATE TABLE Policies (Id INT PRIMARY KEY, PolicyholderId INT, PolicyType VARCHAR(50), CoverageAmount DECIMAL(10,2), FOREIGN KEY (PolicyholderId) REFERENCES Policyholders(Id)); CREATE TABLE Claims ... | What is the average claim amount and number of claims for policyholders who are female and have a policy type of 'Homeowners'? | SELECT P.Gender, PL.PolicyType, AVG(C.ClaimAmount) as AverageClaimAmount, COUNT(C.Id) as NumberOfClaims FROM Policyholders P JOIN Policies PL ON P.Id = PL.PolicyholderId JOIN Claims C ON PL.Id = C.PolicyId WHERE P.Gender = 'Female' AND PL.PolicyType = 'Homeowners' GROUP BY P.Gender, PL.PolicyType ORDER BY AverageClaimA... | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_species (year INT, species_count INT); INSERT INTO deep_sea_species (year, species_count) VALUES (2010, 1200), (2011, 1215), (2012, 1250), (2013, 1275), (2014, 1300), (2015, 1320); | Find the change in deep-sea species count per year. | SELECT year, species_count, LAG(species_count) OVER(ORDER BY year) as previous_year_count, species_count - LAG(species_count) OVER(ORDER BY year) as change FROM deep_sea_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (id INT, name VARCHAR(255), capacity INT, last_port VARCHAR(255), last_visited DATETIME); INSERT INTO Vessels (id, name, capacity, last_port, last_visited) VALUES (1, 'Sea Titan', 15000, 'Hong Kong', '2019-03-05 14:30:00'), (2, 'Ocean Wave', 12000, 'Tokyo', '2019-11-12 09:00:00'); CREATE VIEW Ports... | List the names of vessels and their maximum cargo capacity that have visited ports in Asia in 2019. | SELECT name, capacity FROM Vessels V JOIN Ports P ON V.last_port = P.port WHERE YEAR(last_visited) = 2019 AND FIND_IN_SET(last_port, (SELECT GROUP_CONCAT(port) FROM Ports WHERE port LIKE '%Asia%')) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (id INT, region VARCHAR(255), labor_hours INT); INSERT INTO Projects (id, region, labor_hours) VALUES (1, 'Midwest', 1200), (2, 'Northeast', 1500), (3, 'Midwest', 1300); | Count the number of construction projects in the Midwest that used over 1000 hours of labor? | SELECT COUNT(*) FROM Projects WHERE region = 'Midwest' AND labor_hours > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, Duration INT, MembershipType VARCHAR(20)); | Delete records of workouts with a duration less than 10 minutes for all members from the 'Workouts' table | DELETE FROM Workouts WHERE Duration < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Region VARCHAR(2)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Region) VALUES (1, 35, 'NY'), (2, 40, 'CA'), (3, 45, 'NY'), (4, 50, 'CA'); | What is the average age of community health workers in the 'NY' and 'CA' regions? | SELECT AVG(Age) FROM CommunityHealthWorkers WHERE Region IN ('NY', 'CA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities (id INT, country VARCHAR(255), city VARCHAR(255), technology VARCHAR(255)); INSERT INTO smart_cities (id, country, city, technology) VALUES (1, 'India', 'Bangalore', 'smart grids'), (2, 'India', 'Mumbai', 'smart transportation'), (3, 'USA', 'New York', 'smart buildings'); | Identify cities with smart city technology adoption in India. | SELECT DISTINCT city FROM smart_cities WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Publications (ID INT, Journal VARCHAR(50), Year INT, CitationCount INT); INSERT INTO Publications (ID, Journal, Year, CitationCount) VALUES (1, 'Journal of Data Science', 2020, 50), (2, 'Journal of Machine Learning', 2019, 40); | What is the average number of citations per publication in the 'Journal of Data Science'? | SELECT AVG(CitationCount) FROM Publications WHERE Journal = 'Journal of Data Science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_yield (id INT PRIMARY KEY, farm_id INT, crop VARCHAR(50), yield INT, year INT); INSERT INTO crop_yield (id, farm_id, crop, yield, year) VALUES (2, 2, 'Soybeans', 150, 2021); | Update crop yield for a specific farm | UPDATE crop_yield SET yield = 160 WHERE farm_id = 2 AND crop = 'Soybeans'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SAFETY_RECORDS (id INT, vessel_name VARCHAR(50), crew_size INT, accidents INT); | Compare safety records of vessels with 100+ crew members and those with < 50 | SELECT '100+ crew members' AS category, AVG(accidents) FROM SAFETY_RECORDS WHERE crew_size >= 100 UNION ALL SELECT 'Less than 50 crew members', AVG(accidents) FROM SAFETY_RECORDS WHERE crew_size < 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE microfinance_clients (id INT, name VARCHAR(50), gender VARCHAR(10), income FLOAT); INSERT INTO microfinance_clients (id, name, gender, income) VALUES (1, 'John Doe', 'Male', 5000.00), (2, 'Jane Doe', 'Female', 6000.00); | What is the total income by gender for microfinance clients in Kenya? | SELECT gender, SUM(income) as total_income FROM microfinance_clients WHERE country = 'Kenya' GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE seafood_exports (id INT, export_date DATE, export_country VARCHAR(50), import_country VARCHAR(50), quantity INT, unit_type VARCHAR(10)); INSERT INTO seafood_exports (id, export_date, export_country, import_country, quantity, unit_type) VALUES (1, '2019-01-01', 'Japan', 'Australia', 500, 'ton'), (2, '2019-0... | How many tons of seafood were imported by Japan from Australia in 2019? | SELECT SUM(quantity) FROM seafood_exports WHERE export_country = 'Australia' AND import_country = 'Japan' AND EXTRACT(YEAR FROM export_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT, age INT, gender TEXT, country TEXT); | Insert new records for visitors from India, Pakistan, and Bangladesh into the visitors table | INSERT INTO visitors (id, age, gender, country) VALUES (6001, 30, 'Male', 'India'), (6002, 22, 'Female', 'Pakistan'), (6003, 40, 'Male', 'Bangladesh'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Ingredient (id INT, product VARCHAR(255), ingredient VARCHAR(255), sourcing_country VARCHAR(255)); INSERT INTO Ingredient (id, product, ingredient, sourcing_country) VALUES (1, 'Lush Soak Stimulant Bath Bomb', 'Sodium Bicarbonate', 'England'), (2, 'The Body Shop Born Lippy Strawberry Lip Balm', 'Caprylic/C... | Which countries source the most ingredients for cosmetics in the database? | SELECT sourcing_country, COUNT(DISTINCT product) as product_count FROM Ingredient GROUP BY sourcing_country ORDER BY product_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE trip (trip_id INT, trip_time TIMESTAMP); | Show the number of public transportation trips by hour for a specific date | SELECT HOUR(trip_time) AS hour, COUNT(*) AS trips FROM trip WHERE trip_time BETWEEN '2022-06-01 00:00:00' AND '2022-06-02 00:00:00' GROUP BY hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteer_Age (VolunteerID INT, Age INT, Age_Group VARCHAR(50)); | Determine the total number of volunteers and total hours spent per age group, from the 'Volunteer_Age' table, grouped by Age_Group. | SELECT Age_Group, COUNT(*) AS Number_Of_Volunteers, SUM(Hours) AS Total_Hours_Spent FROM Volunteer_Age JOIN (SELECT VolunteerID, YEAR(CURDATE()) - YEAR(Birth_Date) AS Age FROM Volunteers) AS Age_Table ON Volunteer_Age.VolunteerID = Age_Table.VolunteerID GROUP BY Age_Group; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_name VARCHAR(50), menu_category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu_items (item_name, menu_category, price) VALUES ('Garden Salad', 'Appetizers', 7.50), ('Margherita Pizza', 'Entrees', 12.00), ('Cheeseburger', 'Entrees', 10.00), ('Chocolate Cake', 'Desserts', 8.00); | What is the average price of items in each menu category? | SELECT menu_category, AVG(price) FROM menu_items GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE unique_donors (donor_id INT, cause_area VARCHAR(20), donation_date DATE); INSERT INTO unique_donors (donor_id, cause_area, donation_date) VALUES (1, 'Arts', '2020-01-01'), (2, 'Education', '2020-02-01'), (3, 'Arts', '2020-03-01'), (4, 'Health', '2019-01-01'), (5, 'Health', '2020-01-01'); | How many unique donors have there been in each cause area? | SELECT cause_area, COUNT(DISTINCT donor_id) AS unique_donors FROM unique_donors GROUP BY cause_area; | gretelai_synthetic_text_to_sql |
CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type TEXT, age INT); INSERT INTO artifacts (artifact_id, site_id, artifact_type, age) VALUES (1, 5, 'ceramic', 80), (2, 1, 'wooden', 30), (3, 2, 'metal', 50), (4, 3, 'ceramic', 90), (5, 3, 'pottery', 60), (6, 4, 'stone', 70), (7, 5, 'stone', 85), (8, 5, 'ce... | What is the average age of ceramic artifacts from 'Site E'? | SELECT AVG(age) as avg_age FROM artifacts WHERE site_id = 5 AND artifact_type = 'ceramic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT PRIMARY KEY, location VARCHAR(50), size_acres FLOAT, preservation_status VARCHAR(50), protected_species VARCHAR(50)); | Insert a new record into the 'habitat_preservation' table | INSERT INTO habitat_preservation (id, location, size_acres, preservation_status, protected_species) VALUES (1, 'Amazon Rainforest', 21000000.0, 'Vulnerable', 'Jaguar'); | gretelai_synthetic_text_to_sql |
CREATE TABLE coral_reefs (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255)); INSERT INTO coral_reefs (id, name, location, status) VALUES (1, 'Great Barrier Reef', 'Australia', 'Vulnerable'); | List all records from the table "coral_reefs" | SELECT * FROM coral_reefs; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (chw_id INT, state VARCHAR(2), name VARCHAR(50), certification_date DATE); | Add new community health worker record for Georgia | INSERT INTO community_health_workers (chw_id, state, name, certification_date) VALUES (987, 'GA', 'Nia White', '2022-06-10'); | gretelai_synthetic_text_to_sql |
CREATE TABLE dam (id INT, name TEXT, province TEXT, construction_year INT, height FLOAT); INSERT INTO dam (id, name, province, construction_year, height) VALUES (1, 'Dam A', 'Quebec', 2005, 50.3); INSERT INTO dam (id, name, province, construction_year, height) VALUES (2, 'Dam B', 'Quebec', 1995, 60.2); | What is the maximum height of all dams in the province of Quebec that were constructed after the year 2000? | SELECT MAX(height) FROM dam WHERE province = 'Quebec' AND construction_year > 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_category VARCHAR(255), transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_date, transaction_category, transaction_value) VALUES (1, '2022-01-02', 'Food', 75.00), (2, '2022-02-05', 'Electronics', 350.00... | What is the total transaction value for each month of the year 2022? | SELECT YEAR(transaction_date) as year, MONTH(transaction_date) as month, SUM(transaction_value) as total_value FROM transactions WHERE transaction_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY year, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tours (package_id INT, package_name VARCHAR(255), country VARCHAR(255), available INT); INSERT INTO sustainable_tours (package_id, package_name, country, available) VALUES (1, 'Sustainable Tour Vancouver', 'Canada', 20); INSERT INTO sustainable_tours (package_id, package_name, country, availabl... | How many sustainable tourism packages are available in Canada and Mexico? | SELECT country, SUM(available) FROM sustainable_tours GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT PRIMARY KEY, ingredient_name VARCHAR(50)); CREATE TABLE product_ingredients (product_id INT, ingredient_id INT, PRIMARY KEY (product_id, ingredient_id), FOREIGN KEY (product_id) REFERENCES products(product_id), FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id)... | Which ingredients are used in more than 50% of the products? | SELECT ingredient_name, COUNT(*) as product_count FROM product_ingredients GROUP BY ingredient_id HAVING product_count > (SELECT COUNT(*) * 0.5 FROM products); | 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.