context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE accidents (id INT PRIMARY KEY, vehicle_make VARCHAR(255), accident_count INT); | Delete all records in the 'accidents' table where the 'vehicle_make' is 'Tesla' | DELETE FROM accidents WHERE vehicle_make = 'Tesla'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturerCount (Manufacturer VARCHAR(50), TotalSpacecrafts INT); INSERT INTO SpacecraftManufacturerCount (Manufacturer, TotalSpacecrafts) VALUES ('Galactic Spacecraft Inc.', 100), ('Nebula Spacecrafts', 500), ('Cosmic Engineering', 350); | What is the number of spacecrafts manufactured by each manufacturer? | SELECT Manufacturer, COUNT(*) FROM SpacecraftManufacturerCount GROUP BY Manufacturer | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_suppliers (id INT PRIMARY KEY, chemical_id INT, supplier_name VARCHAR(255), last_purchase_date DATE); CREATE TABLE chemicals (id INT PRIMARY KEY, hazard_level INT); | What are the names of suppliers who have provided chemicals with a hazard level greater than 7 in the last 6 months? | SELECT DISTINCT cs.supplier_name FROM chemical_suppliers cs JOIN chemicals c ON cs.chemical_id = c.id WHERE c.hazard_level > 7 AND cs.last_purchase_date > (CURRENT_DATE - INTERVAL '6 months'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Indian_Ocean_Pollution (pollutant TEXT, location TEXT, affected_species TEXT); INSERT INTO Indian_Ocean_Pollution (pollutant, location, affected_species) VALUES ('Microplastics', 'Arabian Sea', 'Omani Sardine, Whale Shark'), ('Plastic Waste', 'Bay of Bengal', 'Indian Oil Sardine, Bottlenose Dolphin'); | Which marine species are affected by plastic pollution in the Indian Ocean? | SELECT affected_species FROM Indian_Ocean_Pollution WHERE pollutant = 'Microplastics' OR pollutant = 'Plastic Waste'; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumptions (id INT, product VARCHAR(50), is_organic BOOLEAN, quantity INT); INSERT INTO consumptions (id, product, is_organic, quantity) VALUES (1, 'Beef', true, 1000), (2, 'Chicken', true, 800); | What is the maximum quantity of organic meat consumed in Australia? | SELECT MAX(quantity) FROM consumptions WHERE is_organic = true AND product LIKE '%Meat%' AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (PlayerID INT, GameGenre VARCHAR(255), SessionDuration FLOAT, SessionDate DATE); INSERT INTO GameSessions (PlayerID, GameGenre, SessionDuration, SessionDate) VALUES (1, 'RPG', 50.5, '2021-05-01'), (2, 'FPS', 130.3, '2021-07-10'); | Show the number of players who played more than 100 hours of a specific game genre in the last year. | SELECT GameGenre, COUNT(PlayerID) as PlayersCount FROM GameSessions WHERE SessionDate BETWEEN DATEADD(year, -1, CURRENT_DATE) AND CURRENT_DATE AND SessionDuration > 100 GROUP BY GameGenre; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, budget INT, program_type VARCHAR(20)); INSERT INTO programs (id, budget, program_type) VALUES (1, 120000, 'Education'), (2, 50000, 'Health'), (3, 80000, 'Arts'); | Delete any program records with a budget over $100,000 and a program type of 'Education'. | DELETE FROM programs WHERE budget > 100000 AND program_type = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE feedback (id INT, area TEXT, category TEXT, sentiment TEXT); INSERT INTO feedback (id, area, category, sentiment) VALUES (1, 'State A', 'road maintenance', 'positive'), (2, 'City B', 'road maintenance', 'negative'), (3, 'State A', 'road maintenance', 'positive'); | What is the percentage of positive citizen feedback on road maintenance? | SELECT (COUNT(*) FILTER (WHERE sentiment = 'positive')) * 100.0 / COUNT(*) AS percentage FROM feedback WHERE category = 'road maintenance'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists funding; USE funding; CREATE TABLE if not exists startup_funding (id INT, name VARCHAR(255), region VARCHAR(255), funding DECIMAL(10, 2)); INSERT INTO startup_funding (id, name, region, funding) VALUES (1, 'Startup A', 'Asia', 18000000.00), (2, 'Startup B', 'USA', 25000000.00), (3, 'Startup ... | What is the total funding for biotech startups in Asia? | SELECT SUM(funding) FROM funding.startup_funding WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT, violation_date DATE, location TEXT); INSERT INTO mental_health_parity (id, violation_date, location) VALUES (1, '2021-01-01', 'Japan'); INSERT INTO mental_health_parity (id, violation_date, location) VALUES (2, '2021-02-01', 'South Korea'); INSERT INTO mental_health_parity (id... | What is the total number of mental health parity violations reported in Japan in 2021? | SELECT COUNT(*) FROM mental_health_parity WHERE violation_date >= '2021-01-01' AND violation_date < '2022-01-01' AND location = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (id INT, name VARCHAR(100), state VARCHAR(50), seismic_retrofit BOOLEAN); INSERT INTO Buildings (id, name, state, seismic_retrofit) VALUES (1, 'City Hall', 'California', TRUE), (2, 'Library', 'California', FALSE), (3, 'Police Station', 'California', TRUE); | What is the total number of seismic retrofits performed on buildings in California? | SELECT COUNT(*) FROM Buildings WHERE state = 'California' AND seismic_retrofit = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN); CREATE TABLE safety_records (record_id INT, product_id INT, violation_date DATE); | Delete records of products that have never received a safety violation but are not cruelty-free certified. | DELETE FROM products USING safety_records WHERE products.product_id = safety_records.product_id AND products.is_cruelty_free = FALSE AND safety_records.record_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sustainable_Tourism (Destination VARCHAR(50), CO2_Emissions INT, Water_Usage INT); INSERT INTO Sustainable_Tourism (Destination, CO2_Emissions, Water_Usage) VALUES ('Bali', 120, 3500), ('Kyoto', 80, 2000), ('Rio de Janeiro', 150, 4000); | Find all destinations with CO2 emissions below the average in the Sustainable_Tourism table. | SELECT Destination FROM Sustainable_Tourism WHERE CO2_Emissions < (SELECT AVG(CO2_Emissions) FROM Sustainable_Tourism); | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_loans (id INT, amount DECIMAL, date DATE); INSERT INTO shariah_loans (id, amount, date) VALUES (1, 5000, '2021-06-05'), (2, 7000, '2021-06-07'); CREATE TABLE socially_responsible_loans (id INT, amount DECIMAL, date DATE); INSERT INTO socially_responsible_loans (id, amount, date) VALUES (1, 3000, '2... | What is the sum of all Shariah-compliant and socially responsible loans issued in the month of June 2021? | SELECT SUM(amount) FROM shariah_loans WHERE EXTRACT(MONTH FROM date) = 6 UNION ALL SELECT SUM(amount) FROM socially_responsible_loans WHERE EXTRACT(MONTH FROM date) = 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, Name TEXT, DonationAmount DECIMAL); | Who is the top donor in terms of total donation amount? | SELECT Name, SUM(DonationAmount) AS TotalDonation FROM Donors GROUP BY Name ORDER BY TotalDonation DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_agencies (agency_id INT PRIMARY KEY, agency_name VARCHAR(255), director_name VARCHAR(255), director_start_date DATE, director_end_date DATE); INSERT INTO intelligence_agencies (agency_id, agency_name, director_name, director_start_date, director_end_date) VALUES (1, 'CIA', 'William Burns', '20... | Who are the top 3 intelligence agency directors by tenure? | SELECT director_name, DATEDIFF(day, director_start_date, director_end_date) AS tenure FROM intelligence_agencies ORDER BY tenure DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, restaurant_id INT, food_category TEXT, price DECIMAL(5,2), sustainability_score INT); CREATE TABLE restaurant (restaurant_id INT, name TEXT); INSERT INTO restaurant (restaurant_id, name) VALUES (1, 'Restaurant B'), (2, 'Restaurant C'); INSERT INTO menu (menu_id, restaurant_id, food_categ... | List the top 3 sustainable menu items based on their sales and sustainability scores for a particular restaurant in Q2 2021. | SELECT m.food_category, m.price, m.sustainability_score, SUM(m.price) AS total_sales FROM menu m JOIN restaurant r ON m.restaurant_id = r.restaurant_id WHERE r.name = 'Restaurant B' AND m.price > 0 AND EXTRACT(MONTH FROM m.order_date) BETWEEN 4 AND 6 AND EXTRACT(YEAR FROM m.order_date) = 2021 GROUP BY m.menu_id, m.food... | gretelai_synthetic_text_to_sql |
CREATE TABLE student_demographics (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), ethnicity VARCHAR(50)); CREATE TABLE disability_accommodations (id INT PRIMARY KEY, student_id INT, faculty_id INT, accommodation_type VARCHAR(50), start_date DATE, end_date DATE); | Retrieve the name, age, and ethnicity of all students with disability accommodations | SELECT student_demographics.name, student_demographics.age, student_demographics.ethnicity FROM student_demographics INNER JOIN disability_accommodations ON student_demographics.id = disability_accommodations.student_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, DonorID int, DonationDate date, AmountDonated float); INSERT INTO Donations (DonationID, DonorID, DonationDate, AmountDonated) VALUES (1, 1, '2022-01-01', 5000.00), (2, 2, '2022-02-01', 7000.00), (3, 1, '2022-03-01', 8000.00), (4, 1, '2022-03-05', 3000.00); | List the donors who have donated more than once in a single month, and the dates of their donations. | SELECT DonorID, DonationDate FROM Donations D1 WHERE DonorID IN (SELECT DonorID FROM Donations D2 WHERE D1.DonorID = D2.DonorID AND MONTH(D1.DonationDate) = MONTH(D2.DonationDate) AND YEAR(D1.DonationDate) = YEAR(D2.DonationDate) AND D1.DonationID <> D2.DonationID); | gretelai_synthetic_text_to_sql |
CREATE TABLE BlueOrigin (ID INT, Mission VARCHAR(50), LaunchDate DATE); INSERT INTO BlueOrigin (ID, Mission, LaunchDate) VALUES (1, 'New Shepard', '2022-08-01'), (2, 'New Glenn', '2023-02-15'), (3, 'Blue Moon', '2024-01-01'); | What is the next scheduled launch date for Blue Origin missions? | SELECT Mission, LEAD(LaunchDate) OVER (ORDER BY LaunchDate) as NextLaunchDate FROM BlueOrigin; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_projects (project_id INT PRIMARY KEY, project_name VARCHAR(50), project_type VARCHAR(50)); | Delete all records from the 'research_projects' table where the 'project_type' is 'genomics' | DELETE FROM research_projects WHERE project_type = 'genomics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE return_data (return_id INT, item_id INT, return_date DATE); INSERT INTO return_data (return_id, item_id, return_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-02-01'), (3, 3, '2022-03-01'), (4, 4, '2022-04-01'), (5, 5, '2022-05-01'); CREATE TABLE restock_data (restock_id INT, item_id INT, restock_date DAT... | How many days on average does it take for a returned item to be restocked in the Tokyo warehouse? | SELECT AVG(DATEDIFF(day, return_date, restock_date)) FROM return_data JOIN restock_data ON return_data.item_id = restock_data.item_id WHERE restock_data.restock_location = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_usage (usage_id INT, customer_id INT, usage_date DATE, data_usage DECIMAL(5,2)); | Insert a new record in the customer_usage table for a customer with id 1001, who used 500 MB of data on 2023-03-01 | INSERT INTO customer_usage (usage_id, customer_id, usage_date, data_usage) VALUES ((SELECT MAX(usage_id) FROM customer_usage) + 1, 1001, '2023-03-01', 500.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_farms (id INT, city VARCHAR(20), acreage DECIMAL(5,2)); INSERT INTO urban_farms (id, city, acreage) VALUES (1, 'NY', 1.25), (2, 'LA', 2.50), (3, 'NY', 1.75), (4, 'LA', 3.00); | What is the average acreage of urban farms in New York and Los Angeles? | SELECT AVG(acreage) FROM urban_farms WHERE city IN ('NY', 'LA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_projects_region (organization_name TEXT, region TEXT); INSERT INTO ai_projects_region (organization_name, region) VALUES ('TechCorp', 'Asia-Pacific'), ('InnoTech', 'North America'), ('GreenAI', 'Europe'), ('AIforGood', 'Africa'), ('Tech4Good', 'North America'); CREATE TABLE ai_projects_budget (organizat... | What is the total budget spent on AI projects by organizations in the top 3 regions with the most organizations working on AI projects? | SELECT SUM(budget) FROM ai_projects_budget INNER JOIN ai_projects_region ON ai_projects_budget.organization_name = ai_projects_region.organization_name WHERE region IN (SELECT region FROM (SELECT region, COUNT(*) as organization_count FROM ai_projects_region GROUP BY region ORDER BY organization_count DESC LIMIT 3) sub... | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_demographics (patient_id INT, age INT, gender VARCHAR(255), condition VARCHAR(255)); | What is the average age of patients who have received treatment for depression or anxiety in the patient_demographics table, grouped by their gender? | SELECT gender, AVG(age) FROM patient_demographics WHERE condition IN ('depression', 'anxiety') GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (id INT PRIMARY KEY, project_id INT, year INT, region VARCHAR(255), sector VARCHAR(255), amount DECIMAL(10,2)); | What is the total amount of climate finance invested in renewable energy projects in Africa since 2010? | SELECT SUM(amount) FROM climate_finance WHERE sector = 'Renewable Energy' AND year >= 2010 AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Daily_Response(Day DATE, Response_Time INT); INSERT INTO Daily_Response VALUES ('2022-01-01', 2), ('2022-01-01', 5), ('2022-01-02', 3), ('2022-01-03', 4), ('2022-01-03', 6); | What is the average response time to citizen complaints per day, with the fastest response time first? | SELECT Day, AVG(Response_Time) as Avg_Response_Time FROM Daily_Response GROUP BY Day ORDER BY Avg_Response_Time ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), energy_type VARCHAR(50), capacity_mw FLOAT, PRIMARY KEY (id)); | What is the total installed capacity and number of renewable energy projects for each energy type in a specific city and state, ordered by the total capacity in descending order? | SELECT city, state, energy_type, SUM(capacity_mw) as total_capacity, COUNT(*) as project_count, ROW_NUMBER() OVER (ORDER BY SUM(capacity_mw) DESC) as ranking FROM renewable_energy_projects WHERE city = 'CityName' AND state = 'StateName' GROUP BY energy_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingFacilities (RFID INT, Location VARCHAR(50), Type VARCHAR(50), Capacity INT); INSERT INTO RecyclingFacilities (RFID, Location, Type, Capacity) VALUES (9, 'Jakarta', 'E-waste', 6000); INSERT INTO RecyclingFacilities (RFID, Location, Type, Capacity) VALUES (10, 'Jakarta', 'Glass', 7000); INSERT INTO ... | Which recycling facilities can handle e-waste and glass in Jakarta and Nairobi? | SELECT R.Location, R.Type FROM RecyclingFacilities R WHERE R.Location IN ('Jakarta', 'Nairobi') AND R.Type IN ('E-waste', 'Glass') GROUP BY R.Location, R.Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE BusRoutes (RouteID INT, District VARCHAR(20), Fare DECIMAL(5,2)); INSERT INTO BusRoutes (RouteID, District, Fare) VALUES (1, 'North', 1.50), (2, 'South', 2.00), (3, 'East', 1.25), (4, 'North', 2.50), (5, 'West', 1.75); | Find the maximum fare for bus routes serving the 'North' district. | SELECT MAX(Fare) FROM BusRoutes WHERE District = 'North'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50));CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), ProductType VARCHAR(50), QuantitySold INT); INSERT INTO Countries VALUES (1, 'USA'), (2, 'Canada'); INSERT INTO Products VALUES (1, 'Chicken', 'Meat', 100), (2, 'Beef', 'Meat', 150), (3, 'Fish'... | What is the maximum quantity of each type of meat product sold in each country? | SELECT c.CountryName, p.ProductType, MAX(p.QuantitySold) as MaxQuantitySold FROM Countries c JOIN Products p ON c.CountryID = 1 GROUP BY c.CountryName, p.ProductType; | gretelai_synthetic_text_to_sql |
CREATE TABLE location (id INT, name TEXT, country TEXT); INSERT INTO location (id, name, country) VALUES (1, 'Operation A', 'Country G'); INSERT INTO location (id, name, country) VALUES (2, 'Operation B', 'Country H'); | How many mining operations are located in Country G? | SELECT COUNT(*) FROM location WHERE country = 'Country G'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_count (id INT, name VARCHAR(255)); INSERT INTO rural_infrastructure_count (id, name) VALUES (1, 'Water Supply System'), (2, 'Solar Farm'), (3, 'School'); CREATE TABLE community_initiatives_count (id INT, name VARCHAR(255)); INSERT INTO community_initiatives_count (id, name) VALUES (1, ... | Find the total number of rural infrastructure projects and community development initiatives in 'RuralDev' database. | SELECT COUNT(*) FROM rural_infrastructure_count; SELECT COUNT(*) FROM community_initiatives_count; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE membership (member_id INT, demographic_segment VARCHAR(20)); CREATE TABLE revenue (member_id INT, revenue DECIMAL(10,2), transaction_date DATE); INSERT INTO membership (member_id, demographic_segment) VALUES (1, 'Young Adults'), (2, 'Seniors'); INSERT INTO revenue (member_id, revenue... | What is the total revenue generated from members in the "Young Adults" demographic segment for the year 2020? | SELECT SUM(revenue) FROM revenue INNER JOIN membership ON revenue.member_id = membership.member_id WHERE membership.demographic_segment = 'Young Adults' AND YEAR(transaction_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE asia_pacific_archaeology (site_id INT, radiocarbon_dating BOOLEAN); | Count of sites in 'asia_pacific_archaeology' with 'radiocarbon_dating'? | SELECT COUNT(*) FROM asia_pacific_archaeology WHERE radiocarbon_dating = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_workers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO healthcare_workers (id, name, age, gender, location) VALUES (1, 'John Doe', 35, 'Male', 'New York'); INSERT INTO healthcare_workers (id, name, age, gender, location) VALUES (2, 'Jane Smith', 32, 'F... | List the names and locations of all female healthcare workers. | SELECT name, location FROM healthcare_workers WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ethical_AI_Region (region VARCHAR(255), initiative VARCHAR(255), budget INT); INSERT INTO Ethical_AI_Region (region, initiative, budget) VALUES ('Asia', 'Transparency', 500000), ('Africa', 'Accountability', 300000), ('South America', 'Fairness', 200000), ('Europe', 'Explainability', 400000), ('North Americ... | What is the distribution of ethical AI initiatives by region and budget? | SELECT region, initiative, AVG(budget) as avg_budget FROM Ethical_AI_Region GROUP BY region, initiative; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_projects (id INT, project_name VARCHAR(100), region VARCHAR(50), carbon_offset FLOAT); | Calculate the average carbon offset per project in the 'Europe' region | SELECT AVG(carbon_offset) FROM carbon_offset_projects WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, mine_id INT, year INT, product TEXT, production_volume INT); INSERT INTO production (id, mine_id, year, product, production_volume) VALUES (1, 1, 2020, 'Rare Earth Elements', 5000); | What is the total production volume of rare earth elements in China for the year 2020? | SELECT SUM(production_volume) FROM production WHERE year = 2020 AND product = 'Rare Earth Elements' AND mine_id IN (SELECT id FROM mines WHERE location = 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, name VARCHAR(255), major VARCHAR(255), gpa DECIMAL(3,2)); | Add a new student named "Jamie" with a major in "Computer Science" and a GPA of 3.8 to the "students" table. | INSERT INTO students (name, major, gpa) VALUES ('Jamie', 'Computer Science', 3.8); | gretelai_synthetic_text_to_sql |
CREATE TABLE orders_summary (menu_id INT, quantity INT); INSERT INTO orders_summary (menu_id, quantity) VALUES (1, 100), (2, 90), (3, 80), (4, 70), (5, 60); | Identify menu items ordered less frequently than 10% of the most ordered item. | SELECT m.menu_name FROM menus m JOIN orders_summary os ON m.menu_id = os.menu_id WHERE os.quantity < (SELECT 0.1 * quantity FROM orders_summary WHERE quantity = (SELECT MAX(quantity) FROM orders_summary)); | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParity (ID INT, Violation VARCHAR(255), State VARCHAR(255), Date DATE); INSERT INTO MentalHealthParity VALUES (1, 'Non-compliance with mental health coverage', 'California', '2022-01-15'); INSERT INTO MentalHealthParity VALUES (2, 'Lack of mental health coverage parity', 'California', '2022-02-... | List all mental health parity violations in California in the past month. | SELECT * FROM MentalHealthParity WHERE State = 'California' AND Date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (id INT, country VARCHAR(50), patent VARCHAR(50), date DATE); INSERT INTO military_innovation (id, country, patent, date) VALUES (1, 'USA', 'Stealth Technology', '2015-01-01'); INSERT INTO military_innovation (id, country, patent, date) VALUES (2, 'China', 'Drone Technology', '2018-05-2... | What are the top 5 countries with the highest number of military innovation patents since 2010? | SELECT country, COUNT(*) as patents_since_2010 FROM military_innovation WHERE date >= '2010-01-01' GROUP BY country ORDER BY patents_since_2010 DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel (id INT, type VARCHAR(50), name VARCHAR(50));CREATE TABLE incident (id INT, vessel_id INT, incident_date DATE, incident_type VARCHAR(50)); | Which container vessels have had the most collisions in the past 3 years? | SELECT v.name, COUNT(i.id) as collision_count FROM vessel v INNER JOIN incident i ON v.id = i.vessel_id WHERE v.type = 'container' AND i.incident_type = 'collision' AND i.incident_date >= DATE(NOW(), INTERVAL -3 YEAR) GROUP BY v.name ORDER BY collision_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (government VARCHAR(50), half INT, expenditure FLOAT); INSERT INTO community_development (government, half, expenditure) VALUES ('US Federal Government', 1, 2000000), ('US State Government', 1, 1500000), ('US Local Government', 1, 1000000), ('German Federal Government', 1, 1200000), (... | What was the total community development expenditure by the US government in H1 2016? | SELECT SUM(expenditure) as total_expenditure FROM community_development WHERE government = 'US Federal Government' AND half = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (id INT, age INT, cultural_competency VARCHAR(20)); INSERT INTO community_health_workers (id, age, cultural_competency) VALUES (1, 35, 'High'), (2, 40, 'Medium'), (3, 30, 'Low'), (4, 45, 'High'), (5, 50, 'High'); | What is the average age of community health workers with high cultural competency? | SELECT AVG(age) FROM community_health_workers WHERE cultural_competency = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (id INT, warehouse_id INT, pallets INT); INSERT INTO Inventory (id, warehouse_id, pallets) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 150); CREATE TABLE Warehouses (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50)); INSERT INTO Warehouses (id, name, city, country) VALUES (1, 'Warehous... | How many pallets are stored in the warehouse with the most pallets? | SELECT SUM(i.pallets) FROM Inventory i JOIN (SELECT MAX(total_pallets) AS max_pallets FROM (SELECT w.id, SUM(i.pallets) AS total_pallets FROM Inventory i JOIN Warehouses w ON i.warehouse_id = w.id GROUP BY w.id) subquery) subquery2 ON i.pallets = subquery2.max_pallets; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation(year INT, state VARCHAR(20), material VARCHAR(20), amount INT); INSERT INTO waste_generation VALUES (2018, 'California', 'Plastic', 5000), (2018, 'California', 'Paper', 8000), (2019, 'California', 'Plastic', 5500), (2019, 'California', 'Paper', 8500), (2020, 'California', 'Plastic', 6000),... | What is the total waste generation by material type in 2020 for California? | SELECT SUM(amount) as total_waste, material FROM waste_generation WHERE year = 2020 AND state = 'California' GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_virtual_tours (hotel_id INT, city VARCHAR(50), rating FLOAT); INSERT INTO hotel_virtual_tours (hotel_id, city, rating) VALUES (1, 'Paris', 4.6), (2, 'Paris', 4.5), (3, 'Rome', 4.4), (4, 'Rome', 4.3); | What is the difference in average rating between hotel virtual tours in Paris and Rome? | SELECT city, AVG(rating) as avg_rating FROM hotel_virtual_tours GROUP BY city; SELECT (PARIS_AVG_RATING - ROME_AVG_RATING) as rating_difference; | gretelai_synthetic_text_to_sql |
CREATE TABLE indian_ocean_research_stations (id INT, country TEXT, num_stations INT); INSERT INTO indian_ocean_research_stations (id, country, num_stations) VALUES (1, 'India', 15), (2, 'Indonesia', 20); | What is the maximum number of marine research stations in the Indian Ocean? | SELECT MAX(num_stations) FROM indian_ocean_research_stations; | gretelai_synthetic_text_to_sql |
SELECT * FROM NewHiresByQuarter; | Query the NewHiresByQuarter view | SELECT * FROM NewHiresByQuarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE content_categories (id INT, content_category VARCHAR(255)); CREATE TABLE posts_extended (id INT, content_category_id INT, content TEXT); INSERT INTO content_categories (id, content_category) VALUES (1, 'AI'), (2, 'Data Science'), (3, 'Machine Learning'); INSERT INTO posts_extended (id, content_category_id,... | What is the total number of posts in each content category? | SELECT content_categories.content_category, COUNT(posts_extended.id) FROM content_categories JOIN posts_extended ON posts_extended.content_category_id = content_categories.id GROUP BY content_categories.content_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); INSERT INTO teams (team_id, team_name) VALUES (1, 'TeamA'), (2, 'TeamB'); CREATE TABLE ticket_sales (team_id INT, ticket_type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO ticket_sales (team_id, ticket_type, price) VALUES (1, 'VIP', 100.00), (1, 'Regular', 60.00)... | What is the average ticket price by team and ticket type? | SELECT t.team_name, ticket_type, AVG(ticket_sales.price) as avg_price FROM ticket_sales JOIN teams ON ticket_sales.team_id = teams.team_id GROUP BY t.team_name, ticket_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name VARCHAR(50), budget INT, completion_date DATE, planned_completion_date DATE); | What is the success rate of rural infrastructure projects, defined as the percentage of projects that were completed on time and within budget, in the last 3 years? | SELECT 100.0 * AVG(CASE WHEN budget = actual_spent AND completion_date <= planned_completion_date THEN 1 ELSE 0 END) as success_rate FROM (SELECT id, budget, completion_date, planned_completion_date, SUM(cost) as actual_spent FROM projects WHERE date(completion_date) >= date('now','-3 years') GROUP BY id) subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_productivity (mine_name TEXT, extraction_tons INTEGER, workforce_size INTEGER, productivity_tons_per_worker FLOAT, location TEXT); INSERT INTO mine_productivity (mine_name, extraction_tons, workforce_size, productivity_tons_per_worker, location) VALUES ('Golden Ridge Mine', 3500, 200, 17.5, 'North Ame... | What is the maximum productivity for mines located in 'Africa'? | SELECT MAX(productivity_tons_per_worker) as max_productivity FROM mine_productivity WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce (id INT PRIMARY KEY, name VARCHAR(50), gender VARCHAR(50), role VARCHAR(50)); INSERT INTO workforce (id, name, gender, role) VALUES (1, 'John Doe', 'Male', 'Miner'), (2, 'Jane Smith', 'Female', 'Engineer'), (3, 'Alberto Garcia', 'Male', 'Manager'), (4, 'Sandra Rodriguez', 'Female', 'Miner'), (5, ... | What's the total number of workers in the mining industry, categorized by their gender? | SELECT gender, COUNT(*) as total_workers FROM workforce GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventID INT, City VARCHAR(50), Country VARCHAR(50), Year INT); INSERT INTO EsportsEvents (EventID, City, Country, Year) VALUES (1, 'Los Angeles', 'USA', 2019), (2, 'Paris', 'France', 2019), (3, 'Tokyo', 'Japan', 2020), (4, 'Seoul', 'South Korea', 2018); | How many esports events were held in Tokyo, Japan in 2020? | SELECT COUNT(*) FROM EsportsEvents WHERE City = 'Tokyo' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE cuisine (id INT, name VARCHAR(255)); INSERT INTO cuisine (id, name) VALUES (1, 'Asian'), (2, 'Italian'), (3, 'Mexican'); CREATE TABLE dishes (id INT, name VARCHAR(255), cuisine_id INT, calories INT); INSERT INTO dishes (id, name, cuisine_id, calories) VALUES (1, 'Pad Thai', 1, 600), (2, 'Fried Rice', 1, 70... | What is the average calorie count for dishes in the Asian cuisine category? | SELECT AVG(calories) FROM dishes WHERE cuisine_id = (SELECT id FROM cuisine WHERE name = 'Asian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE employee (id INT, name VARCHAR(50), department VARCHAR(20), hire_date DATE);CREATE VIEW experienced_employees_by_dept AS SELECT department, id, name, DATEDIFF(CURDATE(), hire_date) as work_experience FROM employee WHERE department IN ('Manufacturing', 'Design'); | Identify the most experienced employees in each department. | SELECT department, id, name, work_experience, RANK() OVER (PARTITION BY department ORDER BY work_experience DESC) as experience_rank FROM experienced_employees_by_dept WHERE experience_rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), organic BOOLEAN, weight FLOAT, supplier_id INT); | Find the total weight of organic products supplied by the top 2 suppliers. | SELECT s.name, SUM(p.weight) FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id WHERE p.organic = 't' GROUP BY s.name ORDER BY SUM(p.weight) DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE water (country VARCHAR(255), region VARCHAR(255), access INT); INSERT INTO water (country, region, access) VALUES ('Country A', 'Latin America', 500000), ('Country B', 'Latin America', 600000); | How many people have access to clean water in Latin America? | SELECT SUM(access) FROM water WHERE region = 'Latin America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO wind_farms (id, name, region, capacity_mw) VALUES (1, 'Windfarm A', 'west', 150.5); INSERT INTO wind_farms (id, name, region, capacity_mw) VALUES (2, 'Windfarm B', 'east', 120.2); CREATE TABLE solar_power_plants (id INT, name TEXT,... | Which renewable energy projects have a capacity greater than 150 MW? | SELECT name, capacity_mw FROM wind_farms WHERE capacity_mw > 150 UNION ALL SELECT name, capacity_mw FROM solar_power_plants WHERE capacity_mw > 150; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams (dam_name TEXT, dam_year INT, dam_state TEXT); INSERT INTO dams (dam_name, dam_year, dam_state) VALUES ('D1', 2015, 'Texas'), ('D2', 2018, 'Texas'), ('D3', 2008, 'Texas'), ('D4', 2012, 'Texas'), ('D5', 2020, 'Texas'); | How many dams were built in Texas between 2010 and 2020? | SELECT COUNT(*) FROM dams WHERE dam_year BETWEEN 2010 AND 2020 AND dam_state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(255), severity FLOAT); INSERT INTO vulnerabilities (id, sector, severity) VALUES (1, 'healthcare', 7.5), (2, 'finance', 5.2), (3, 'healthcare', 8.1); | What is the average severity score of vulnerabilities detected in the healthcare sector? | SELECT AVG(severity) FROM vulnerabilities WHERE sector = 'healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); | Insert a new restorative justice program into the 'programs' table | INSERT INTO programs (id, name, location, type, start_date, end_date) VALUES (103, 'Victim-Offender Mediation', 'San Francisco, CA', 'Restorative Justice', '2023-01-01', '2023-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtSales (SaleID INT, SaleDate DATE, Revenue INT); INSERT INTO ArtSales (SaleID, SaleDate, Revenue) VALUES (1, '2022-01-01', 1000), (2, '2022-02-01', 2000), (3, '2022-03-01', 3000), (4, '2022-04-01', 1500), (5, '2022-05-01', 2500), (6, '2022-06-01', 3500), (7, '2022-07-01', 1700), (8, '2022-08-01', 2700), ... | What is the total revenue generated from art sales in each quarter? | SELECT QUARTER(SaleDate) as Quarter, SUM(Revenue) as TotalRevenue FROM ArtSales GROUP BY Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup_founders (id INT PRIMARY KEY, name VARCHAR(255), sexual_orientation VARCHAR(50), industry VARCHAR(255), total_funding FLOAT); | What is the total funding for startups founded by a person from the LGBTQ+ community? | SELECT SUM(total_funding) FROM startup_founders WHERE sexual_orientation = 'LGBTQ+'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nyc_real_estate(id INT, borough VARCHAR(50), green_roof BOOLEAN); INSERT INTO nyc_real_estate VALUES (1, 'Manhattan', true); | How many properties are there in each borough of NYC that have green roofs? | SELECT borough, COUNT(*) FROM nyc_real_estate WHERE green_roof = true GROUP BY borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, time_spent_reading INT); CREATE TABLE user_activity (user_id INT, article_id INT, start_time DATETIME, end_time DATETIME); CREATE TABLE articles (id INT, title TEXT, category TEXT); | Who are the top 5 users who spent the most time reading articles about 'politics'? | SELECT name FROM (SELECT user_id, SUM(TIMESTAMPDIFF(MINUTE, start_time, end_time)) AS time_spent_reading FROM user_activity JOIN articles ON user_activity.article_id = articles.id WHERE articles.category = 'politics' GROUP BY user_id ORDER BY time_spent_reading DESC LIMIT 5) AS subquery JOIN users ON subquery.user_id =... | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_ops (id INT, country VARCHAR(50), region VARCHAR(50)); INSERT INTO peacekeeping_ops (id, country, region) VALUES (1, 'Nigeria', 'Africa'), (2, 'Ukraine', 'Europe'), (3, 'Iraq', 'Middle East'); | Display the "country" and "region" columns from the "peacekeeping_ops" table, showing only records where the "region" column is 'Europe' | SELECT country, region FROM peacekeeping_ops WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE VIEW green_certified_properties AS SELECT * FROM properties WHERE has_green_certification = TRUE; | What is the total number of properties with a green certification in the green_certified_properties view? | SELECT COUNT(*) FROM green_certified_properties; | gretelai_synthetic_text_to_sql |
CREATE TABLE Clients (ClientID int, Age int, Gender varchar(10), Region varchar(50)); INSERT INTO Clients (ClientID, Age, Gender, Region) VALUES (11, 35, 'Female', 'Asia'); CREATE TABLE Cases (CaseID int, ClientID int, Category varchar(50)); INSERT INTO Cases (CaseID, ClientID, Category) VALUES (1101, 11, 'Civil Law'); | What is the total number of clients from 'Asia' who have had 'civil law' cases? | SELECT COUNT(DISTINCT C.ClientID) as TotalClients FROM Clients C INNER JOIN Cases CA ON C.ClientID = CA.ClientID WHERE C.Region = 'Asia' AND CA.Category = 'Civil Law'; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_emissions (emission_id INT, product_id INT, co2_emissions FLOAT, emission_date DATE); | What is the total CO2 emissions from manufacturing cosmetics in the last 12 months? | SELECT SUM(co2_emissions) FROM manufacturing_emissions WHERE emission_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_2019 (recipient_name TEXT, funding_year INTEGER); INSERT INTO climate_finance_2019 (recipient_name, funding_year) VALUES ('Recipient A', 2019), ('Recipient B', 2019), ('Recipient A', 2020); CREATE TABLE climate_finance_2020 (recipient_name TEXT, funding_year INTEGER); INSERT INTO climate_fi... | Display the names of all climate finance recipients who received funding in both 2019 and 2020. | SELECT recipient_name FROM climate_finance_2019 WHERE funding_year = 2019 INTERSECT SELECT recipient_name FROM climate_finance_2020 WHERE funding_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (artwork_id INT, artwork_name TEXT, artist_name TEXT, country TEXT); CREATE TABLE country_continent (country TEXT, continent TEXT); | What is the number of artworks in the artworks table, grouped by country, excluding those from the United States? | SELECT country, COUNT(artwork_id) FROM artworks JOIN country_continent ON artworks.country = country_continent.country WHERE country != 'United States' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO clients VALUES (1, 'John Doe', 'Latin America'), (2, 'Jane Smith', 'North America'), (3, 'Alice Johnson', 'Latin America'); CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE, transaction_amount DECI... | What is the average transaction amount by client in the Latin America region in Q2 2022? | SELECT c.region, AVG(t.transaction_amount) FROM clients c JOIN transactions t ON c.client_id = t.client_id WHERE c.region = 'Latin America' AND t.transaction_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY c.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE tokyo_art(id INT, museum VARCHAR(30), section VARCHAR(30), value INT); INSERT INTO tokyo_art VALUES (1, 'Tokyo National Museum', 'Modern Art', 1000000); INSERT INTO tokyo_art VALUES (2, 'Mori Art Museum', 'Modern Art', 2000000); | What is the total value of artworks in the modern art section of the museums in Tokyo? | SELECT SUM(value) FROM tokyo_art WHERE museum IN (SELECT museum FROM tokyo_art WHERE section = 'Modern Art') AND section = 'Modern Art'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_trips (trip_id INT, trip_date DATE, station_id INT); CREATE TABLE subway_stations (station_id INT, station_name VARCHAR(255), city VARCHAR(255)); | How many subway trips were taken in Berlin in the last week? | SELECT COUNT(*) FROM subway_trips JOIN subway_stations ON subway_trips.station_id = subway_stations.station_id WHERE subway_stations.city = 'Berlin' AND subway_trips.trip_date >= DATEADD(WEEK, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_facilities (facility_id INT, country VARCHAR(20), num_beds INT); INSERT INTO healthcare_facilities (facility_id, country, num_beds) VALUES (1, 'Brazil', 50), (2, 'Mexico', 75); | Calculate the average number of hospital beds per rural healthcare facility in Brazil and Mexico. | SELECT AVG(num_beds) FROM healthcare_facilities WHERE country IN ('Brazil', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics (fan_id INT, gender VARCHAR(255), team_id INT); INSERT INTO fan_demographics (fan_id, gender, team_id) VALUES (1, 'Male', 1), (2, 'Female', 2), (3, 'Male', 1), (4, 'Male', 3), (5, 'Female', 2); CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name)... | What is the distribution of fans by gender for each team? | SELECT t.team_name, f.gender, COUNT(f.fan_id) fan_count FROM fan_demographics f JOIN teams t ON f.team_id = t.team_id GROUP BY t.team_name, f.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_projects (id INT, project_name TEXT, state TEXT, completion_year INT, is_sustainable BOOLEAN); INSERT INTO sustainable_projects (id, project_name, state, completion_year, is_sustainable) VALUES (1, 'Solar Park', 'New York', 2021, true), (2, 'Wind Farm', 'California', 2020, true), (3, 'Green Apa... | How many sustainable building projects were completed in New York in 2021? | SELECT COUNT(*) FROM sustainable_projects WHERE state = 'New York' AND completion_year = 2021 AND is_sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (name VARCHAR(255)); CREATE TABLE employee (id INT, name VARCHAR(255), gender VARCHAR(50), ethnicity VARCHAR(50), department_id INT); | Find the number of employees of different genders and ethnicities in each department of the company. | SELECT department.name AS department, gender, ethnicity, COUNT(*) AS employee_count FROM department INNER JOIN employee ON department.id = employee.department_id GROUP BY department.name, gender, ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_timber_2 (species_id INT, species_name VARCHAR(50), year INT, volume INT); INSERT INTO species_timber_2 (species_id, species_name, year, volume) VALUES (1, 'Oak', 2018, 1000), (2, 'Pine', 2018, 2000), (3, 'Maple', 2018, 3000), (4, 'Birch', 2018, 4000), (1, 'Oak', 2019, 900), (2, 'Pine', 2019, 2200)... | Identify the species with a decrease in timber production between 2018 and 2019, and order them by the largest decrease first. | SELECT species_name, (LAG(volume, 1) OVER (PARTITION BY species_name ORDER BY year)) - volume AS volume_decrease FROM species_timber_2 WHERE year = 2019 GROUP BY species_name, volume ORDER BY volume_decrease DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_activity (user_id INT, activity_type VARCHAR(50), hobby VARCHAR(50)); INSERT INTO user_activity (user_id, activity_type, hobby) VALUES (1, 'followed_account', 'yoga'), (2, 'engaged_post', 'cooking'), (3, 'followed_account', 'hiking'), (4, 'engaged_post', 'painting'), (5, 'followed_account', 'meditatio... | What are the unique hobbies of users who have followed accounts about mental health advocacy but have not engaged with posts about mindfulness. | SELECT hobby FROM user_activity WHERE activity_type = 'followed_account' AND user_id NOT IN (SELECT user_id FROM user_activity WHERE activity_type = 'engaged_post' AND post_topic = 'mindfulness'); | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT PRIMARY KEY, title VARCHAR(100), release_year INT, genre VARCHAR(50), production_budget INT); | Update the production budget of all movies released in 2010 by 15% | UPDATE movies SET production_budget = production_budget * 1.15 WHERE release_year = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenses (id INT, victim_id INT, offense_type VARCHAR(50), date_of_offense DATE); | Add a new offense record into the "offenses" table | INSERT INTO offenses (id, victim_id, offense_type, date_of_offense) VALUES (2003, 1002, 'Assault', '2021-09-25'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (CompanyID INT, CompanyName VARCHAR(50), LaborProductivity DECIMAL(5,2)); INSERT INTO Companies (CompanyID, CompanyName, LaborProductivity) VALUES (1, 'ABC Mining', 15.5), (2, 'XYZ Excavations', 12.3), (3, 'MNO Drilling', 18.7), (4, 'PQR Quarrying', 10.1); | What are the names of mining companies with the highest and lowest labor productivity? | SELECT CompanyName FROM Companies WHERE LaborProductivity = (SELECT MAX(LaborProductivity) FROM Companies) OR LaborProductivity = (SELECT MIN(LaborProductivity) FROM Companies); | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_inspections (restaurant_name VARCHAR(255), location VARCHAR(255), score INTEGER, inspection_date DATE); INSERT INTO restaurant_inspections (restaurant_name, location, score, inspection_date) VALUES ('Restaurant A', 'New York', 90, '2021-01-01'), ('Restaurant B', 'New York', 85, '2021-02-01'); | What was the average food safety score for restaurants in New York in 2021? | SELECT AVG(score) FROM restaurant_inspections WHERE location = 'New York' AND YEAR(inspection_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, location VARCHAR(50), posts INT); CREATE TABLE posts (id INT, user_id INT, content TEXT, timestamp TIMESTAMP); | What is the average number of posts per day for users over 40 years old in the 'social_media' database? | SELECT AVG(COUNT(posts.id)/86400) AS avg_posts_per_day FROM posts JOIN users ON posts.user_id = users.id WHERE users.age > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE well_production (well_name VARCHAR(20), production_qty FLOAT, production_date DATE); INSERT INTO well_production (well_name, production_qty, production_date) VALUES ('Well A', 1000, '2020-01-01'); INSERT INTO well_production (well_name, production_qty, production_date) VALUES ('Well B', 1500, '2020-01-01')... | List the top 3 producing wells in the North Sea, partitioned by year. | SELECT well_name, production_qty, production_date, RANK() OVER (PARTITION BY EXTRACT(YEAR FROM production_date) ORDER BY production_qty DESC) as rank FROM well_production WHERE well_name LIKE 'Well%' AND production_date BETWEEN '2020-01-01' AND '2021-12-31' AND location = 'North Sea' ORDER BY production_date, rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_genres (genre_id INT, genre VARCHAR(255)); CREATE TABLE platforms (platform_id INT, platform_name VARCHAR(255)); CREATE TABLE revenue (genre_id INT, platform_id INT, revenue INT, year INT); INSERT INTO music_genres (genre_id, genre) VALUES (1, 'Latin'); INSERT INTO platforms (platform_id, platform_na... | What is the total revenue for Latin music on streaming platforms since 2015? | SELECT SUM(revenue) FROM revenue JOIN music_genres ON revenue.genre_id = music_genres.genre_id JOIN platforms ON revenue.platform_id = platforms.platform_id WHERE music_genres.genre = 'Latin' AND revenue.year >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (ID INT, Type VARCHAR(50), Cost FLOAT, Disability VARCHAR(50), Region VARCHAR(50)); INSERT INTO Accommodations (ID, Type, Cost, Disability, Region) VALUES (1, 'Wheelchair Accessibility', 2000.0, 'Physical Disability', 'Southwest'), (2, 'Adaptive Equipment', 2500.0, 'Physical Disability', 'So... | What is the maximum budget for accommodations for students with physical disabilities in the Southwest? | SELECT MAX(Cost) FROM Accommodations WHERE Disability = 'Physical Disability' AND Region = 'Southwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_types (vehicle_type_id INT, vehicle_type VARCHAR(255)); CREATE TABLE maintenance_requests (request_id INT, vehicle_type_id INT, request_date DATE); | How many maintenance requests have been submitted for each vehicle type? | SELECT vt.vehicle_type, COUNT(mr.request_id) as num_requests FROM vehicle_types vt INNER JOIN maintenance_requests mr ON vt.vehicle_type_id = mr.vehicle_type_id GROUP BY vt.vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName) VALUES (1, 'Alice'), (2, 'Bob'); CREATE TABLE Assignments (AssignmentID INT, VolunteerID INT, ProjectID INT, ProjectCountry TEXT); INSERT INTO Assignments (AssignmentID, VolunteerID, ProjectID, ProjectCoun... | List all volunteers who have not been assigned to a project in Asia. | SELECT Volunteers.VolunteerName FROM Volunteers LEFT JOIN Assignments ON Volunteers.VolunteerID = Assignments.VolunteerID WHERE Assignments.ProjectCountry IS NULL OR Assignments.ProjectCountry != 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, conservation_status) VALUES (1, 'Whale Shark', 'Endangered'); CREATE TABLE oceanography (id INT PRIMARY KEY, species_id INT, sea_surface_temperature INT); INSERT INTO oceanography... | Update the conservation status of the species with the highest sea surface temperature to 'Critically Endangered'. | UPDATE marine_species m SET m.conservation_status = 'Critically Endangered' FROM oceanography o WHERE m.id = o.species_id AND o.sea_surface_temperature = (SELECT MAX(sea_surface_temperature) FROM oceanography); | gretelai_synthetic_text_to_sql |
CREATE TABLE prescriptions (id INT PRIMARY KEY, patient_id INT, drug VARCHAR(50), country VARCHAR(50), prescription_date DATE); | Which antidepressants are most commonly prescribed in Australia? | SELECT drug FROM prescriptions WHERE country = 'Australia' AND drug LIKE '%antidepressant%' GROUP BY drug ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Student (StudentID INT, Name VARCHAR(20), District VARCHAR(20)); | Insert a new student 'Pascale' from 'RainbowSchool' district into the 'Student' table. | INSERT INTO Student (StudentID, Name, District) VALUES (3, 'Pascale', 'RainbowSchool'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_bookings (booking_id INT, ota_name TEXT, region TEXT, booking_amount DECIMAL(10,2)); INSERT INTO ota_bookings (booking_id, ota_name, region, booking_amount) VALUES (1, 'Booking.com', 'APAC', 200.50), (2, 'Expedia', 'NA', 150.25), (3, 'Agoda', 'APAC', 300.00); | What is the total revenue of OTA bookings from APAC region in 2021? | SELECT SUM(booking_amount) FROM ota_bookings WHERE region = 'APAC' AND YEAR(booking_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE News (news_id INT, title TEXT, category TEXT); INSERT INTO News (news_id, title, category) VALUES (1, 'Article1', 'Politics'), (2, 'Article2', 'Sports'), (3, 'Article3', 'Politics'); CREATE TABLE Categories (category_id INT, category_name TEXT); INSERT INTO Categories (category_id, category_name) VALUES (1... | How many news articles are there in each news category? | SELECT c.category_name, COUNT(n.news_id) as num_articles FROM News n INNER JOIN Categories c ON n.category = c.category_name GROUP BY c.category_name; | 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.