context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE restaurant_revenue(location VARCHAR(255), revenue INT); INSERT INTO restaurant_revenue(location, revenue) VALUES ('Location1', 5000), ('Location2', 7000), ('Location3', 3000), ('Restaurant4', 6000), ('Restaurant5', 4000), ('Restaurant9', 9000), ('Restaurant10', 8000); | What is the total revenue for restaurants that serve sustainable menu items? | SELECT SUM(revenue) FROM restaurant_revenue INNER JOIN sustainable_sourcing ON restaurant_revenue.location = sustainable_sourcing.menu_item WHERE sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (Id INT, Age INT, Gender VARCHAR(10)); CREATE TABLE Workouts (Id INT, MemberId INT, Duration INT, Date DATE); INSERT INTO Members (Id, Age, Gender) VALUES (1, 25, 'Female'), (2, 32, 'Male'), (3, 45, 'Female'), (4, 28, 'Non-binary'); INSERT INTO Workouts (Id, MemberId, Duration, Date) VALUES (1, 1, ... | Increase the duration of all workouts in August by 15% for members aged 30 or older. | UPDATE Workouts SET Duration = Duration * 1.15 WHERE DATE_FORMAT(Date, '%Y-%m') = '2022-08' AND MemberId IN (SELECT Id FROM Members WHERE Age >= 30); | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID INT, OriginWarehouse INT, DestinationWarehouse INT, Distance FLOAT); INSERT INTO Routes (RouteID, OriginWarehouse, DestinationWarehouse, Distance) VALUES (1, 10, 20, 150.3), (2, 11, 21, 180.5), (3, 12, 22, 120.7); CREATE TABLE Warehouses (WarehouseID INT, State VARCHAR(2)); INSERT INTO Ware... | What is the average distance for routes starting from a warehouse in CA? | SELECT AVG(Distance) FROM Routes r JOIN Warehouses w ON r.OriginWarehouse = w.WarehouseID WHERE w.State = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance (product_id INT, product_name VARCHAR(50), region VARCHAR(50)); INSERT INTO shariah_compliant_finance (product_id, product_name, region) VALUES (1, 'Murabaha', 'Asia'), (2, 'Ijara', 'Europe'), (3, 'Musharakah', 'Asia'); | List all the Shariah-compliant financial products offered in the Asia region. | SELECT product_name FROM shariah_compliant_finance WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (Employee_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Division VARCHAR(50), Hire_Date DATE); CREATE TABLE Department_Organization (Department_ID INT, Department VARCHAR(50), Division VARCHAR(50)); | Identify the number of employees hired in each quarter for the Engineering division. | SELECT DATEPART(QUARTER, Hire_Date) AS Quarter, Department, Division, COUNT(*) AS Employees_Hired FROM Employee WHERE Division = 'Engineering' GROUP BY DATEPART(QUARTER, Hire_Date), Department, Division; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_volume (volume_id INT, well_id INT, production_year INT, production_volume FLOAT, region VARCHAR(50)); INSERT INTO production_volume (volume_id, well_id, production_year, production_volume, region) VALUES (11, 7, 2022, 300.0, 'South America'); INSERT INTO production_volume (volume_id, well_id, p... | What is the total production volume for each region, and what is the percentage of the total production volume accounted for by the top 2 regions? | SELECT region, SUM(production_volume) as total_volume, PERCENTAGE_RANK() OVER (ORDER BY SUM(production_volume) DESC) as percentage_of_total FROM production_volume GROUP BY region ORDER BY percentage_of_total DESC FETCH FIRST 2 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE cost (mine_id INT, year INT, cost INT); | What is the total resource depletion cost for each mine by year? | SELECT mine.name, cost.year, SUM(cost.cost) FROM cost JOIN mine ON cost.mine_id = mine.id GROUP BY mine.name, cost.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment (garment_id INT, type VARCHAR(50), co2_emission INT); | Which garment has the highest CO2 emission and how much is it? | SELECT type AS highest_emission_garment, MAX(co2_emission) AS co2_emission FROM garment; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, dispensary_id INT, strain VARCHAR(255), quantity INT);CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), state VARCHAR(255)); | Which strains have been sold in more than 5 dispensaries in Oregon? | SELECT strain FROM sales JOIN dispensaries ON sales.dispensary_id = dispensaries.dispensary_id WHERE state = 'Oregon' GROUP BY strain HAVING COUNT(DISTINCT dispensary_id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (UserID INT, UserName VARCHAR(50), Country VARCHAR(50), HeartRate INT, WorkoutDate DATE); | What is the maximum heart rate recorded during any workout for users in Australia in the last year? | SELECT MAX(HeartRate) FROM Users WHERE Country = 'Australia' AND WorkoutDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_data (id INT, city VARCHAR(50), data_usage FLOAT); INSERT INTO mobile_data (id, city, data_usage) VALUES (1, 'San Francisco', 4.5), (2, 'San Francisco', 6.7), (3, 'New York', 3.4), (4, 'San Francisco', 8.9); | What is the maximum monthly data usage for mobile customers in the city of San Francisco? | SELECT MAX(data_usage) FROM mobile_data WHERE city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, organic_supplier BOOLEAN); CREATE TABLE ingredients (ingredient_id INT, supplier_id INT, is_organic BOOLEAN); INSERT INTO suppliers VALUES (1, true); INSERT INTO suppliers VALUES (2, false); INSERT INTO ingredients VALUES (1, 1, true); INSERT INTO ingredients VALUES (2, 1, false... | List all suppliers that have provided both organic and non-organic ingredients to restaurants, along with the total number of ingredients supplied by each. | SELECT s.supplier_id, COUNT(i.ingredient_id) as total_ingredients FROM suppliers s INNER JOIN ingredients i ON s.supplier_id = i.supplier_id WHERE s.organic_supplier = true OR i.is_organic = false GROUP BY s.supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name TEXT); INSERT INTO department (id, name) VALUES (1, 'textile'), (2, 'metalworking'), (3, 'electronics'); CREATE TABLE worker (id INT, salary REAL, department_id INT, country TEXT); INSERT INTO worker (id, salary, department_id, country) VALUES (1, 3000, 1, 'France'), (2, 3500, 1, '... | What is the minimum salary of workers in the 'electronics' department, grouped by country? | SELECT country, MIN(worker.salary) FROM worker INNER JOIN department ON worker.department_id = department.id WHERE department.name = 'electronics' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_item (item_id INT, item_name VARCHAR(50), category VARCHAR(20), price DECIMAL(5, 2)); | Update the menu_item table to change the price of item_id 203 to 12.99 | UPDATE menu_item SET price = 12.99 WHERE item_id = 203; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT, community_health_worker_id INT, violation_count INT, state VARCHAR(50)); INSERT INTO mental_health_parity (id, community_health_worker_id, violation_count, state) VALUES (1, 101, 3, 'California'), (2, 101, 2, 'California'), (3, 102, 5, 'California'); | What is the average number of mental health parity violations for each community health worker in California? | SELECT state, AVG(violation_count) OVER (PARTITION BY community_health_worker_id) as avg_violations FROM mental_health_parity WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emission_reductions (project VARCHAR(255), region VARCHAR(255), reduction FLOAT); | What is the average CO2 emission reduction achieved by renewable energy projects in Africa? | SELECT AVG(reduction) FROM emission_reductions WHERE project = 'renewable energy' AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (ProgramID int, ParticipantCount int); INSERT INTO LanguagePreservation (ProgramID, ParticipantCount) VALUES (101, 45), (102, 62), (103, 38), (104, 71), (105, 54); | What is the total number of participants in all language preservation programs? | SELECT SUM(ParticipantCount) FROM LanguagePreservation; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (id INT PRIMARY KEY, name VARCHAR(100), category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu (id, name, category, price) VALUES (1, 'Margherita Pizza', 'Pizza', 9.99), (2, 'Spaghetti Bolognese', 'Pasta', 8.99), (3, 'Caesar Salad', 'Salad', 7.99), (4, 'Vegetable Lasagna', 'Pasta', 11.99); | What is the most expensive vegetarian menu item? | SELECT name, price FROM menu WHERE category = 'Salad' OR category = 'Pasta' AND price = (SELECT MAX(price) FROM menu WHERE category = 'Salad' OR category = 'Pasta'); | gretelai_synthetic_text_to_sql |
CREATE TABLE disinformation (id INT, case_name VARCHAR(50), date DATE, location VARCHAR(50)); INSERT INTO disinformation (id, case_name, date, location) VALUES (1, 'Case1', '2018-01-01', 'South America'), (2, 'Case2', '2019-03-15', 'North America'), (3, 'Case3', '2020-12-31', 'Europe'); | What is the average number of disinformation cases detected per month in South America since 2018? | SELECT AVG(COUNT(*)) FROM disinformation WHERE location LIKE '%South America%' AND date BETWEEN '2018-01-01' AND '2022-12-31' GROUP BY MONTH(date); | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSite (SiteID INT PRIMARY KEY, SiteName VARCHAR(100), Location VARCHAR(100), StartDate DATE, EndDate DATE);CREATE TABLE Artifact (ArtifactID INT PRIMARY KEY, SiteID INT, ArtifactName VARCHAR(100), Description TEXT, FOREIGN KEY (SiteID) REFERENCES ExcavationSite(SiteID));CREATE TABLE ArtifactType (... | Update the 'Ancient Coin' artifact description to 'An extremely rare coin from the EuropeExcavation site.'. | UPDATE Artifact SET Description = 'An extremely rare coin from the EuropeExcavation site.' WHERE ArtifactName = 'Ancient Coin'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists arts_culture; CREATE TABLE if not exists arts_culture.events(event_id INT, event_name VARCHAR(50), event_date DATE, category VARCHAR(20)); CREATE TABLE if not exists arts_culture.attendance(attendance_id INT, event_id INT, demographic VARCHAR(10), attendee_count INT); | Which events had the highest attendance from the 'Latinx' demographic in the 'Theatre' category? | SELECT events.event_name, MAX(attendance.attendee_count) FROM arts_culture.events JOIN arts_culture.attendance ON events.event_id = attendance.event_id WHERE attendance.demographic = 'Latinx' AND events.category = 'Theatre' GROUP BY events.event_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_taxis (taxi_id INT, ride_id INT, start_time TIMESTAMP, end_time TIMESTAMP, city VARCHAR(255)); | Which city has the highest number of electric taxi rides in a month? | SELECT city, COUNT(*) as num_rides FROM electric_taxis WHERE ride_id BETWEEN 1 AND 100000 GROUP BY city ORDER BY num_rides DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (region VARCHAR(50), advisory_count INT); INSERT INTO travel_advisories (region, advisory_count) VALUES ('Asia Pacific', 120), ('Europe', 80), ('Americas', 150); | What is the total number of travel advisories issued for 'asia_pacific' region? | SELECT SUM(advisory_count) FROM travel_advisories WHERE region = 'Asia Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, name, sector, ESG_rating) VALUES (1, 'Apple', 'Technology', 8.2), (2, 'Microsoft', 'Technology', 8.5), (3, 'Tesla', 'Automative', 7.8); | What is the average ESG rating for companies in the technology sector? | SELECT AVG(ESG_rating) FROM companies WHERE sector = 'Technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_tech_events (event_location VARCHAR(255), event_date DATE); INSERT INTO accessible_tech_events (event_location, event_date) VALUES ('Kenya', '2021-10-01'), ('Egypt', '2022-02-01'), ('Nigeria', '2021-06-01'); | How many accessible technology events were held in Africa in the past year? | SELECT COUNT(*) OVER (PARTITION BY CASE WHEN event_date >= '2021-01-01' AND event_date < '2022-01-01' THEN 1 ELSE 0 END) as african_events FROM accessible_tech_events WHERE event_location LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DepartmentMilitaryInnovation (id INT, department VARCHAR(50), budget INT); | What is the maximum budget spent on military innovation by each department? | SELECT department, MAX(budget) FROM DepartmentMilitaryInnovation GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceania (country VARCHAR(50), obesity_rate DECIMAL(3,1)); INSERT INTO oceania (country, obesity_rate) VALUES ('Australia', 27.9), ('New Zealand', 30.8); | What is the obesity rate in Oceania by country? | SELECT country, AVG(obesity_rate) as avg_obesity_rate FROM oceania GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name VARCHAR(50), location VARCHAR(50), date DATE, attendance INT); INSERT INTO Events (id, name, location, date, attendance) VALUES (1, 'Art Show', 'Texas', '2020-01-01', 50); | What is the average attendance for events in Texas in the 'Events' table? | SELECT AVG(attendance) FROM Events WHERE location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities (id INT, name VARCHAR(50), location VARCHAR(50), carbon_offset INT); | Calculate the total carbon offset for each smart city in the 'smart_cities' table | SELECT name, (SELECT SUM(carbon_offset) FROM smart_cities WHERE smart_cities.name = cities.name) AS total_carbon_offset FROM smart_cities AS cities; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing (client_id INT, financial_wellbeing_score INT); INSERT INTO financial_wellbeing (client_id, financial_wellbeing_score) VALUES (1, 7), (2, 3), (3, 6), (4, 5); | Delete all records of clients who have a financial wellbeing score below 5, regardless of their country. | DELETE FROM financial_wellbeing WHERE financial_wellbeing_score < 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50)); CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Region VARCHAR(20)); CREATE TABLE PlayerEvent (PlayerID INT, EventID INT); CREATE TABLE Games (GameID INT, GameName VARCHAR(50), Genre VARCHAR(20)); CREATE TABLE GameEvent (GameID INT, Event... | Count the number of unique esports events where at least one player from Asia participated, and the number of unique FPS games played in these events. | SELECT COUNT(DISTINCT EsportsEvents.EventID), COUNT(DISTINCT Games.GameID) FROM EsportsEvents INNER JOIN PlayerEvent ON EsportsEvents.EventID = PlayerEvent.EventID INNER JOIN Players ON PlayerEvent.PlayerID = Players.PlayerID INNER JOIN Games ON GameEvent.GameID = Games.GameID INNER JOIN GameEvent ON EsportsEvents.Even... | gretelai_synthetic_text_to_sql |
CREATE TABLE Peacekeeping_Operations (id INT, operation_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE, status VARCHAR(255)); | Delete peacekeeping operations that were terminated before 2010. | DELETE FROM Peacekeeping_Operations WHERE status = 'Terminated' AND start_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_personnel (id INT, department TEXT, position TEXT, country TEXT); INSERT INTO intelligence_personnel (id, department, position, country) VALUES (1, 'CIA', 'Analyst', 'USA'), (2, 'FBI', 'Agent', 'USA'), (3, 'NSA', 'Engineer', 'USA'); | What is the number of intelligence personnel in each department in the US government? | SELECT i.department, COUNT(i.id) as total_personnel FROM intelligence_personnel i WHERE i.country = 'USA' GROUP BY i.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (iid INT, incident_time TIMESTAMP, incident_type VARCHAR(255)); | How many crime incidents were reported in the last month, categorized by day of the week and hour? | SELECT DATE_FORMAT(i.incident_time, '%W') AS day_of_week, HOUR(i.incident_time) AS hour, COUNT(i.iid) FROM incidents i WHERE i.incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY day_of_week, hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_investments (id INT, value DECIMAL(10,2), location VARCHAR(50)); INSERT INTO sustainable_investments (id, value, location) VALUES (1, 5000, 'United States'), (2, 3000, 'Canada'), (3, 7000, 'United States'); | What is the average transaction value for sustainable investments in the United States? | SELECT AVG(value) FROM sustainable_investments WHERE location = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sm_platform (country VARCHAR(50), activity INT); INSERT INTO sm_platform (country, activity) VALUES ('USA', 15000), ('Canada', 10000), ('Mexico', 12000), ('Brazil', 18000), ('Argentina', 14000); | What are the top 3 countries with the most user activity on social media platform sm_platform in the year 2022, and what is the total activity for each? | SELECT s.country, SUM(s.activity) as total_activity FROM sm_platform s WHERE s.activity >= 10000 AND YEAR(s.activity_date) = 2022 GROUP BY s.country ORDER BY total_activity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE job_applications (id INT, applicant_name VARCHAR(50), department VARCHAR(50), application_source VARCHAR(50), application_date DATE); INSERT INTO job_applications (id, applicant_name, department, application_source, application_date) VALUES (1, 'Jane Doe', 'IT', 'LinkedIn', '2021-02-12'); INSERT INTO job_a... | What is the total number of job applicants per source, by department, for the year 2021? | SELECT department, application_source, COUNT(*) as total_applicants FROM job_applications WHERE YEAR(application_date) = 2021 GROUP BY department, application_source; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, tour_name VARCHAR(255), city VARCHAR(255), engagement_duration INT); INSERT INTO virtual_tours (tour_id, tour_name, city, engagement_duration) VALUES (1, 'Tour A', 'New York', 60), (2, 'Tour B', 'New York', 90), (3, 'Tour C', 'Los Angeles', 45); | What is the average virtual tour engagement duration in New York City? | SELECT AVG(engagement_duration) FROM virtual_tours WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_identity TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_identity) VALUES (1, 'SoftwareSolutions', 'Software', 2016, 'LGBTQ+'); INSERT INTO companies (id, name, industry, founding_year, founder_identity) VALUES... | What is the average number of patents for companies founded by LGBTQ+ individuals in the software industry? | SELECT AVG(num_patents) FROM company_details INNER JOIN companies ON company_details.company_id = companies.id WHERE companies.founder_identity = 'LGBTQ+' AND companies.industry = 'Software'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EventPlayerCounts (event VARCHAR(100), category VARCHAR(50), players INT); | What is the minimum number of players for eSports events in the 'Sports' category? | SELECT MIN(players) FROM EventPlayerCounts WHERE category = 'Sports'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (id INT, name TEXT, location TEXT);CREATE TABLE Materials (id INT, supplier_id INT, factory_id INT, material TEXT, quantity INT, date DATE);INSERT INTO Suppliers VALUES (1, 'SupplierA', 'CityA'), (2, 'SupplierB', 'CityB'), (3, 'SupplierC', 'CityC');INSERT INTO Materials VALUES (1, 1, 5, 'Material... | What are the total quantities of materials delivered by suppliers located in CityB in the last month? | SELECT SUM(m.quantity) FROM Suppliers s INNER JOIN Materials m ON s.id = m.supplier_id WHERE s.location = 'CityB' AND m.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists investments (investment_id INT, region VARCHAR(50), sector VARCHAR(50), amount DECIMAL(10,2), investment_year INT); INSERT INTO investments (investment_id, region, sector, amount, investment_year) VALUES (1, 'Southeast Asia', 'Social Impact Bonds', 700000, 2019); | What is the total investment in social impact bonds in Southeast Asia in 2019? | SELECT SUM(amount) FROM investments WHERE region = 'Southeast Asia' AND sector = 'Social Impact Bonds' AND investment_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (id INT, city VARCHAR(20), operator VARCHAR(20), num_chargers INT, open_date DATE); | Delete all records from the 'charging_stations' table where the 'city' is 'Seattle' | DELETE FROM charging_stations WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityPolicing (id INT, quarter INT, year INT, numOfficers INT); | Find the number of police officers hired per quarter, for the last 2 years, from 'CommunityPolicing' table. | SELECT year, quarter, SUM(numOfficers) FROM CommunityPolicing WHERE year BETWEEN (YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE) GROUP BY year, quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature (year INT, month INT, avg_temp FLOAT); INSERT INTO temperature (year, month, avg_temp) VALUES (2022, 1, -20.5), (2022, 2, -25.0); | Find the average temperature for each month in 2022 in the 'temperature' table. | SELECT month, AVG(avg_temp) as avg_temp FROM temperature WHERE year = 2022 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, artist VARCHAR(50), genre VARCHAR(50), tickets_sold INT, revenue DECIMAL(10,2), country VARCHAR(50)); INSERT INTO concerts (id, artist, genre, tickets_sold, revenue, country) VALUES (1, 'Louis Armstrong', 'Jazz', 10000, 1500000, 'USA'); INSERT INTO concerts (id, artist, genre, tickets_sol... | What is the total revenue for Jazz concerts in the United States? | SELECT SUM(revenue) FROM concerts WHERE genre = 'Jazz' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions (customer_id INT, transaction_city VARCHAR(20)); INSERT INTO customer_transactions (customer_id, transaction_city) VALUES (1, 'Tokyo'), (2, 'Sydney'), (3, 'Tokyo'), (4, 'Paris'), (5, 'Sydney'); | Identify customers who made transactions in both Tokyo and Sydney. | SELECT customer_id FROM customer_transactions WHERE transaction_city IN ('Tokyo', 'Sydney') GROUP BY customer_id HAVING COUNT(DISTINCT transaction_city) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(255), Country VARCHAR(255)); INSERT INTO Suppliers (SupplierID, SupplierName, Country) VALUES (6, 'Supplier3', 'USA'); INSERT INTO Suppliers (SupplierID, SupplierName, Country) VALUES (7, 'Supplier4', 'Mexico'); | Which menu items are offered by suppliers from the USA? | SELECT MenuItems.MenuItemName, Suppliers.SupplierName FROM MenuItems JOIN Suppliers ON MenuItems.SupplierID = Suppliers.SupplierID WHERE Suppliers.Country = 'USA' | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts (id INT, name VARCHAR(255), country VARCHAR(255), age INT); INSERT INTO Astronauts (id, name, country, age) VALUES (1, 'Rakesh Sharma', 'India', 67); INSERT INTO Astronauts (id, name, country, age) VALUES (2, 'Kalpana Chawla', 'India', N/A); INSERT INTO Astronauts (id, name, country, age) VALUES... | What is the average age of astronauts from India? | SELECT AVG(age) FROM Astronauts WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, country TEXT); INSERT INTO startups(id, name, country) VALUES (1, 'StartupA', 'USA'), (2, 'StartupB', 'Canada'), (3, 'StartupC', 'USA'), (4, 'StartupD', 'Mexico'), (5, 'StartupE', 'Brazil'); | How many startups were founded in each country? | SELECT country, COUNT(*) as num_startups FROM startups GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE allergens (product_id INT, allergen_id INT, allergen_name TEXT); CREATE TABLE sales_regions_with_allergens AS SELECT sales_regions.*, allergens.allergen_id, allergens.allergen_name FROM sales_regions JOIN allergens ON sales_regions.product_id = allergens.product_id; INSERT INTO allergens VALUES (1, 1, 'A... | Which regions have sales of products that contain allergens? | SELECT regions.region_name FROM sales_regions_with_allergens JOIN regions ON sales_regions_with_allergens.region_id = regions.region_id GROUP BY regions.region_name HAVING COUNT(DISTINCT allergens.allergen_id) > 1 | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(100), department VARCHAR(50), gender VARCHAR(50), neurodivergent VARCHAR(50)); INSERT INTO faculty VALUES (1, 'Quinn Smith', 'Psychology', 'Non-binary', 'Yes'); CREATE TABLE grants (id INT, faculty_id INT, amount DECIMAL(10,2)); INSERT INTO grants VALUES (1, 1, 60000); | What percentage of research grants are awarded to faculty members who identify as neurodivergent? | SELECT 100.0 * SUM(CASE WHEN faculty.neurodivergent = 'Yes' THEN grants.amount ELSE 0 END) / SUM(grants.amount) AS percentage FROM grants JOIN faculty ON grants.faculty_id = faculty.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_plans (plan_id INT, plan_name VARCHAR(255), download_speed INT, upload_speed INT, price DECIMAL(5,2)); | Update the download speed for an existing broadband plan in the 'broadband_plans' table | UPDATE broadband_plans SET download_speed = 1500 WHERE plan_id = 3001; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, city VARCHAR(255)); INSERT INTO districts (id, city) VALUES (1, 'Los Angeles'); CREATE TABLE water_quality_violations (id INT, district_id INT, violation_date DATE); INSERT INTO water_quality_violations (id, district_id) VALUES (1, 1); | Identify the number of water quality violations in each district of Los Angeles in the last year | SELECT water_quality_violations.district_id, COUNT(*) as number_of_violations FROM water_quality_violations WHERE water_quality_violations.violation_date >= (CURRENT_DATE - INTERVAL '1 year')::date AND water_quality_violations.district_id IN (SELECT id FROM districts WHERE city = 'Los Angeles') GROUP BY water_quality_v... | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtTypes (ArtTypeID INT, ArtType VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT, ArtTypeID INT, ArtistID INT, Year INT); INSERT INTO ArtTypes VALUES (1, 'Painting'), (2, 'Sculpture'), (3, 'Textile'), (4, 'Pottery'); INSERT INTO ArtPieces VALUES (1, 1, 1, 2010), (2, 1, 2, 2015), (3, 2, 3, 2005), (4, 2... | Which traditional art types have the most pieces in the database? | SELECT ArtTypes.ArtType, COUNT(ArtPieces.ArtPieceID) AS ArtPieceCount FROM ArtTypes INNER JOIN ArtPieces ON ArtTypes.ArtTypeID = ArtPieces.ArtTypeID GROUP BY ArtTypes.ArtType ORDER BY ArtPieceCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE org_mitigation_projects (org_name VARCHAR(50), year INT, status VARCHAR(50)); INSERT INTO org_mitigation_projects (org_name, year, status) VALUES ('UNFCCC', 2019, 'Completed'), ('Greenpeace', 2019, 'Completed'), ('WWF', 2019, 'Completed'), ('UN', 2019, 'In-progress'); | What is the number of climate mitigation projects completed by each organization in 2019? | SELECT org_name, SUM(CASE WHEN status = 'Completed' THEN 1 ELSE 0 END) as completed_projects FROM org_mitigation_projects WHERE year = 2019 GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipment_deliveries(id INT, shipment_id INT, delivery_time INT); CREATE TABLE shipments(id INT, source VARCHAR(255), destination VARCHAR(255), shipment_date DATE); INSERT INTO shipment_deliveries(id, shipment_id, delivery_time) VALUES (1, 1, 7), (2, 2, 10), (3, 3, 8); INSERT INTO shipments(id, source... | What is the average delivery time for shipments to India from the United States? | SELECT AVG(delivery_time) FROM shipment_deliveries JOIN shipments ON shipment_deliveries.shipment_id = shipments.id WHERE shipments.source = 'United States' AND shipments.destination = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE, delivery_time INT); INSERT INTO orders VALUES (1, 1, '2022-01-01', 3), (2, 1, '2022-01-05', 5), (3, 2, '2022-02-01', 2), (4, 2, '2022-02-03', 4), (5, 3, '2022-03-01', 6); | Find the number of orders placed by each customer and the average delivery time for each customer. | SELECT customer_id, COUNT(*) as num_orders, AVG(delivery_time) as avg_delivery_time FROM orders GROUP BY customer_id ORDER BY num_orders DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency (country VARCHAR(20), renewable_energy_production INT, energy_storage_capacity INT, carbon_price DECIMAL(5,2)); INSERT INTO energy_efficiency (country, renewable_energy_production, energy_storage_capacity, carbon_price) VALUES ('Sweden', 650000, 12000, 120.00), ('Norway', 800000, 15000, 1... | Identify the top 3 energy-efficient countries in the energy market domain, considering renewable energy production, energy storage capacity, and carbon pricing. | SELECT country, (renewable_energy_production + energy_storage_capacity + carbon_price) AS total_energy_efficiency FROM energy_efficiency GROUP BY country ORDER BY total_energy_efficiency DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (show_id INT, title VARCHAR(100), release_year INT, rating FLOAT); INSERT INTO tv_shows (show_id, title, release_year, rating) VALUES (1, 'Game of Thrones', 2011, 4.1), (2, 'Stranger Things', 2016, 4.6), (3, 'Breaking Bad', 2008, 4.8); | Update the rating of 'Breaking Bad' to 4.9. | UPDATE tv_shows SET rating = 4.9 WHERE title = 'Breaking Bad'; | gretelai_synthetic_text_to_sql |
CREATE TABLE lines (id INT, movie_id INT, actor_id INT, lines INT); CREATE TABLE movies (id INT, title VARCHAR(255)); | Who are the top 5 actors by lines in a movie? | SELECT m.title, a.name, SUM(l.lines) as total_lines FROM lines l | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEvents (id INT, district_id INT, event_date DATE, region_id INT); CREATE TABLE Districts (id INT, region_id INT, district_name VARCHAR(255)); INSERT INTO Districts (id, region_id, district_name) VALUES (1, 1, 'Downtown'), (2, 1, 'Uptown'), (3, 2, 'Harbor'), (4, 2, 'International'), (5, 3, 'Central... | Identify the top 3 districts with the highest number of community policing events, in the central region, for the past year. | SELECT district_id, district_name, COUNT(*) as num_events FROM CommunityEvents JOIN Districts ON Districts.id = CommunityEvents.district_id WHERE event_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE AND region_id = 3 GROUP BY district_id, district_name ORDER BY num_events DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regional_Bookings (region VARCHAR(50), bookings INT); INSERT INTO Regional_Bookings (region, bookings) VALUES ('North America', 10000), ('South America', 5000), ('Europe', 15000); | What is the total number of bookings for each region in the 'Regional_Bookings' table? | SELECT region, SUM(bookings) FROM Regional_Bookings GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_festivals (artist_id INT, artist_name TEXT, artist_age INT); | What is the average age of artists in the 'music_festivals' table? | SELECT AVG(artist_age) FROM music_festivals; | gretelai_synthetic_text_to_sql |
CREATE TABLE coral_reefs (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255)); | Add a record to the table "coral_reefs" | INSERT INTO coral_reefs (id, name, location, status) VALUES (1, 'Great Barrier Reef', 'Australia', 'Vulnerable'); | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_aid_services (service_id INT, service_name VARCHAR(25), location VARCHAR(30), access_date DATE); | What is the most common service accessed in the 'legal_aid_services' table? | SELECT service_name, COUNT(*) AS count FROM legal_aid_services GROUP BY service_name ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), City varchar(50));CREATE TABLE FoodInspections (InspectionID int, RestaurantID int, InspectionDate date, Score int); | What is the average food safety score for restaurants in the city of Los Angeles for the month of May 2022? | SELECT AVG(FI.Score) as AverageScore, R.City FROM FoodInspections FI INNER JOIN Restaurants R ON FI.RestaurantID = R.RestaurantID WHERE R.City = 'Los Angeles' AND MONTH(FI.InspectionDate) = 5 AND YEAR(FI.InspectionDate) = 2022 GROUP BY R.City; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (id INT, age INT, gender VARCHAR(10), city VARCHAR(20)); INSERT INTO offenders (id, age, gender, city) VALUES (1, 34, 'Female', 'Oakland'), (2, 42, 'Male', 'San_Francisco'); CREATE TABLE crimes (id INT, type VARCHAR(20), location VARCHAR(20)); INSERT INTO crimes (id, type, location) VALUES (1, 'P... | What is the average age of female offenders who committed property crimes in Oakland? | SELECT AVG(age) FROM offenders JOIN crimes ON offenders.id = crimes.id WHERE gender = 'Female' AND type = 'Property_Crime' AND city = 'Oakland'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workforce (ID INT, Department VARCHAR(255), Gender VARCHAR(255), HireDate DATE); INSERT INTO Workforce (ID, Department, Gender, HireDate) VALUES (1, 'Mining', 'Male', '2021-12-01'), (2, 'Mining', 'Male', '2021-11-01'), (3, 'Mining', 'Female', '2021-10-01'), (4, 'Maintenance', 'Male', '2021-12-01'), (5, 'Ma... | Show the number of workers in each department by gender for the past month. | SELECT Department, Gender, COUNT(*) as Number_of_Workers FROM Workforce WHERE HireDate >= DATEADD(MONTH, -1, GETDATE()) GROUP BY Department, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE GenderCounts (id INT, company_id INT, gender VARCHAR(10)); INSERT INTO GenderCounts (id, company_id, gender) VALUES (1, 1, 'Female'), (2, 1, 'Male'), (3, 2, 'Male'), (4, 2, 'Non-binary'); | What is the number of female, male, and non-binary founders for each company? | SELECT company_id, gender, COUNT(*) as num_founders FROM GenderCounts GROUP BY company_id, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, well_name VARCHAR(50), location VARCHAR(50), company VARCHAR(50), num_drills INT, drill_date DATE); INSERT INTO wells VALUES (1, 'Well A', 'North Sea', 'ABC Oil', 3, '2020-01-02'); INSERT INTO wells VALUES (2, 'Well B', 'North Sea', 'XYZ Oil', 5, '2020-03-15'); INSERT INTO wells VALUES (3, '... | Find the total number of wells drilled in the North Sea by oil companies in 2020 | SELECT SUM(num_drills) FROM wells WHERE location = 'North Sea' AND company LIKE '%Oil%' AND drill_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge (id INT, name TEXT, location TEXT, type TEXT); INSERT INTO Bridge (id, name, location, type) VALUES (1, 'Brooklyn Bridge', 'NYC, NY', 'Pedestrian'), (2, 'Manhattan Bridge', 'NYC, NY', 'Pedestrian'); | How many pedestrian bridges are there in New York City? | SELECT COUNT(*) FROM Bridge WHERE location = 'NYC, NY' AND type = 'Pedestrian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_games (id INT, home_team VARCHAR(50), away_team VARCHAR(50), date DATE, fouls_home INT, fouls_away INT); INSERT INTO basketball_games (id, home_team, away_team, date, fouls_home, fouls_away) VALUES (1, 'Chicago Bulls', 'Milwaukee Bucks', '2023-01-01', 14, 16); INSERT INTO basketball_games (id, h... | What is the average number of fouls committed by a team in basketball games played after 2021 in the 'basketball_games' table? | SELECT AVG(fouls_home + fouls_away) FROM basketball_games WHERE date > '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (id INT, trip_id INT, trip_type VARCHAR(255), city_id INT, trip_cost DECIMAL(10,2));CREATE TABLE public_transportation (id INT, trip_id INT, transportation_type VARCHAR(255)); | Show the number of public transportation trips and the total cost for each trip in the city of Chicago. | SELECT t.trip_type, COUNT(t.id) as num_trips, SUM(t.trip_cost) as total_cost FROM trips t INNER JOIN public_transportation pt ON t.id = pt.trip_id WHERE t.city_id = (SELECT id FROM cities WHERE city_name = 'Chicago') GROUP BY t.trip_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_unemployment(id INT, state VARCHAR(255), quarter INT, year INT, rate DECIMAL(5,2)); CREATE TABLE military_spending(id INT, state VARCHAR(255), quarter INT, year INT, spending INT); | List all veteran unemployment rates by state in the last quarter of 2021, along with their respective military spending. | SELECT v.state, v.rate, m.spending FROM veteran_unemployment v INNER JOIN military_spending m ON v.state = m.state WHERE v.quarter = 4 AND v.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Deliveries (id INT, weight FLOAT, destination VARCHAR(20), ship_date DATE); INSERT INTO Deliveries (id, weight, destination, ship_date) VALUES (1, 30.5, 'Canada', '2021-01-11'), (2, 40.2, 'Mexico', '2021-01-12'); | What is the minimum shipment weight for deliveries to Canada after January 10, 2021? | SELECT MIN(weight) FROM Deliveries WHERE destination = 'Canada' AND ship_date > '2021-01-10'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EthicalFashion.SustainableMaterials (material_id INT, material_type VARCHAR(20), quantity INT); INSERT INTO EthicalFashion.SustainableMaterials (material_id, material_type, quantity) VALUES (1, 'Organic Cotton', 3000), (2, 'Recycled Polyester', 4500), (3, 'Tencel', 2000); | Find the total quantity of sustainable materials used, partitioned by material type, and ordered by total quantity in descending order? | SELECT material_type, SUM(quantity) AS total_quantity FROM EthicalFashion.SustainableMaterials GROUP BY material_type ORDER BY total_quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE makeup_ingredients (ingredient_id INT, product_id INT, is_vegan BOOLEAN, is_animal_tested BOOLEAN, region VARCHAR(255)); | What is the average rating of makeup products that are not tested on animals and contain at least one vegan ingredient in the EU? | SELECT AVG(rating) FROM makeup_ingredients WHERE is_vegan = TRUE AND is_animal_tested = FALSE AND region = 'EU'; | 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 D', 2019), ('Recipient E', 2019), ('Recipient D', 2020); CREATE TABLE climate_finance_2022 (recipient_name TEXT, funding_year INTEGER); INSERT INTO climate_fi... | Display the names of all climate finance recipients who received funding in either 2019 or 2022. | SELECT recipient_name FROM climate_finance_2019 WHERE funding_year = 2019 UNION SELECT recipient_name FROM climate_finance_2022 WHERE funding_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_preferences (consumer_id INT, country VARCHAR(100), preference VARCHAR(100), preference_score INT); INSERT INTO consumer_preferences (consumer_id, country, preference, preference_score) VALUES (1, 'France', 'Natural', 4000), (2, 'France', 'Organic', 3000), (3, 'USA', 'Natural', 5000), (4, 'USA', '... | What percentage of consumers prefer Natural over Organic in France? | SELECT 100.0 * SUM(CASE WHEN preference = 'Natural' THEN preference_score ELSE 0 END) / SUM(preference_score) AS natural_percentage | gretelai_synthetic_text_to_sql |
CREATE TABLE football_tournaments (name VARCHAR(255), year INT, prize_money INT); INSERT INTO football_tournaments (name, year, prize_money) VALUES ('UEFA Champions League', 2016, 139000000); | What was the total prize money of the 2016 UEFA Champions League? | SELECT prize_money FROM football_tournaments WHERE name = 'UEFA Champions League' AND year = 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE emissions (id INT, mine_type VARCHAR(50), country VARCHAR(50), year INT, co2_emission INT); INSERT INTO emissions (id, mine_type, country, year, co2_emission) VALUES (789, 'coal', 'South Africa', 2020, 1000); | Update the "co2_emission" of the record in the "emissions" table with ID 789 to 1200 tons for a coal mine in "South Africa" in 2020 | UPDATE emissions SET co2_emission = 1200 WHERE id = 789; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (city VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('Toronto', 2020, 0.35); | What is the recycling rate in the city of Toronto for the year 2020?' | SELECT recycling_rate FROM recycling_rates WHERE city = 'Toronto' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), area_size FLOAT, avg_depth FLOAT, conservation_status VARCHAR(100)); INSERT INTO marine_protected_areas (id, name, area_size, avg_depth, conservation_status) VALUES (1, 'Coral Triangle', 518000, -200, 'Least Concern'), (2, 'Great Barrier Reef', 344400, -50... | What is the minimum depth of all marine protected areas with a conservation status of 'Endangered'? | SELECT MIN(avg_depth) FROM marine_protected_areas WHERE conservation_status = 'Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE areas_canada (id INT, name VARCHAR(255), rural_designation VARCHAR(50)); INSERT INTO areas_canada (id, name, rural_designation) VALUES (1, 'Area X', 'Rural'); CREATE TABLE obesity_rates (id INT, area_id INT, obesity_rate FLOAT); INSERT INTO obesity_rates (id, area_id, obesity_rate) VALUES (1, 1, 30.5); | What are the three rural areas with the highest obesity rate in Canada? | SELECT a.name, ob.obesity_rate FROM areas_canada a JOIN obesity_rates ob ON a.id = ob.area_id WHERE a.rural_designation = 'Rural' ORDER BY ob.obesity_rate DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE TV_shows (id INT, title VARCHAR(255), release_year INT, runtime INT, imdb_rating DECIMAL(2,1)); | Insert a new record into the TV_shows table for a show with ID 3, 'New Show', released in 2022, with a runtime of 30 minutes, and an IMDb rating of 8.5. | INSERT INTO TV_shows (id, title, release_year, runtime, imdb_rating) VALUES (3, 'New Show', 2022, 30, 8.5); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, Name varchar(100), Program varchar(50), Hours int, VolunteerDate date); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours, VolunteerDate) VALUES (1, 'Charlotte Lee', 'Food Bank', 50); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours, VolunteerDate) VALUES (2, '... | Who are the volunteers with the most volunteer hours for the Food Bank program? | SELECT Name, SUM(Hours) as TotalHours FROM Volunteers WHERE Program = 'Food Bank' GROUP BY Name ORDER BY TotalHours DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (country VARCHAR(50), incident_count INT, incident_date DATE); INSERT INTO security_incidents (country, incident_count, incident_date) VALUES ('Country A', 120, '2022-01-01'), ('Country B', 140, '2022-01-02'), ('Country C', 160, '2022-01-03'), ('Country D', 130, '2022-01-04'), ('Country ... | Identify the top 3 countries with the highest number of security incidents in the last year. | SELECT country, SUM(incident_count) as total_incidents FROM security_incidents WHERE incident_date >= DATEADD(year, -1, GETDATE()) GROUP BY country ORDER BY total_incidents DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (port_id INT, port_name TEXT, country TEXT); INSERT INTO Port (port_id, port_name, country) VALUES (1, 'Port of Dar es Salaam', 'Tanzania'); CREATE TABLE Shipment (shipment_id INT, container_id INT, port_id INT, shipping_date DATE); CREATE TABLE Container (container_id INT, weight FLOAT); | What is the total weight of containers shipped from the Port of Dar es Salaam to Tanzania in the last 6 months? | SELECT SUM(c.weight) as total_weight FROM Container c JOIN Shipment s ON c.container_id = s.container_id JOIN Port p ON s.port_id = p.port_id WHERE p.country = 'Tanzania' AND s.shipping_date >= NOW() - INTERVAL '6 months' AND p.port_name = 'Port of Dar es Salaam'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Equipment (EquipmentID INT, EquipmentName VARCHAR(50), LastMaintenanceDate DATE); INSERT INTO Equipment (EquipmentID, EquipmentName, LastMaintenanceDate) VALUES (1, 'M1 Abrams', '2022-01-01'), (2, 'F-15 Eagle', '2021-12-15'), (3, 'M2 Bradley', '2020-05-23'); | Delete records of military equipment that have not been maintained in the past year? | DELETE FROM Equipment WHERE LastMaintenanceDate < DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_asset_categories (id INT, name VARCHAR(255)); CREATE TABLE digital_assets (id INT, category_id INT, name VARCHAR(255), daily_trading_volume DECIMAL(10,2)); INSERT INTO digital_asset_categories (id, name) VALUES (1, 'CategoryA'), (2, 'CategoryB'), (3, 'CategoryC'); INSERT INTO digital_assets (id, ca... | What is the highest daily trading volume for each digital asset category? | SELECT category_id, MAX(daily_trading_volume) AS Highest_Daily_Trading_Volume FROM digital_assets GROUP BY category_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Product_Ingredients (id INT, product VARCHAR(255), ingredient VARCHAR(255), cruelty_free BOOLEAN); INSERT INTO Product_Ingredients (id, product, ingredient, cruelty_free) VALUES (1, 'Lush Soak Stimulant Bath Bomb', 'Sodium Bicarbonate', true), (2, 'The Body Shop Born Lippy Strawberry Lip Balm', 'Caprylic/C... | What is the average number of ingredients per cruelty-free product in the database? | SELECT AVG(COUNT(*)) as avg_ingredients FROM Product_Ingredients GROUP BY cruelty_free; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (trip_id INT, trip_start_time DATETIME, trip_end_time DATETIME, system_name VARCHAR(20)); | How many rides started between 7-8 AM for the tram system in October 2022? | SELECT system_name, COUNT(*) FROM trips WHERE trip_start_time BETWEEN '2022-10-01 07:00:00' AND '2022-10-31 08:00:00' AND system_name = 'Tram' GROUP BY system_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding (FundingID INT, Source TEXT, Year INT, Amount INT); INSERT INTO Funding (FundingID, Source, Year, Amount) VALUES (1, 'Private Donation', 2022, 75000), (2, 'Government Grant', 2021, 100000), (3, 'Corporate Sponsorship', 2022, 50000); | Determine the percentage of funding received from private sources in the year 2022. | SELECT (SUM(CASE WHEN Year = 2022 AND Source = 'Private Donation' THEN Amount ELSE 0 END) / SUM(CASE WHEN Year = 2022 THEN Amount ELSE 0 END)) * 100 AS 'Percentage of Funding from Private Sources in 2022' FROM Funding; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryBases (BaseID INT, BaseName TEXT, Country TEXT, Personnel INT); INSERT INTO MilitaryBases (BaseID, BaseName, Country, Personnel) VALUES (1, 'Fort Bragg', 'USA', 53104); INSERT INTO MilitaryBases (BaseID, BaseName, Country, Personnel) VALUES (2, 'CFB Petawawa', 'Canada', 7685); | What is the total number of military bases located in the United States and Canada, and how many personnel are stationed at these bases? | SELECT SUM(Personnel) as TotalPersonnel, COUNT(*) as BaseCount FROM MilitaryBases WHERE Country IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(id INT, product_category VARCHAR(255), revenue DECIMAL(10, 2), sale_date DATE); INSERT INTO sales(id, product_category, revenue, sale_date) VALUES (1, 'Electronics', 1000.00, '2022-01-01'), (2, 'Furniture', 1500.00, '2022-01-05'), (3, 'Electronics', 1200.00, '2022-04-10'); INSERT INTO sales(id, p... | What is the total revenue generated from each product category in the last quarter? | SELECT product_category, SUM(revenue) FROM sales WHERE sale_date >= CURDATE() - INTERVAL 90 DAY GROUP BY product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name VARCHAR(255), region VARCHAR(255), endangerment_status VARCHAR(255)); INSERT INTO marine_species (species_name, region, endangerment_status) VALUES ('Polar Bear', 'Arctic', 'Vulnerable'), ('Narwhal', 'Arctic', 'Near Threatened'); | List all marine species observed in the Arctic region with their endangerment status. | SELECT species_name, endangerment_status FROM marine_species WHERE region = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT PRIMARY KEY, name VARCHAR(255), beds INT, location VARCHAR(255)); INSERT INTO hospitals (id, name, beds, location) VALUES (1, 'Johns Hopkins Hospital', 1138, 'Baltimore, MD'); INSERT INTO hospitals (id, name, beds, location) VALUES (2, 'Massachusetts General Hospital', 999, 'Boston, MA');... | What is the average number of hospital beds per location, for locations with more than 1000 beds? | SELECT location, AVG(beds) FROM hospitals GROUP BY location HAVING SUM(beds) > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name TEXT); INSERT INTO ports (id, name) VALUES (1, 'Port of Los Angeles'); CREATE TABLE vessels (id INT, name TEXT, port_id INT, speed FLOAT); INSERT INTO vessels (id, name, port_id, speed) VALUES (1, 'Vessel A', 1, 15.5), (2, 'Vessel B', 1, 14.3), (3, 'Vessel C', 1, 16.8); | What is the average speed of vessels that arrived in the Port of Los Angeles in January 2022? | SELECT AVG(speed) FROM vessels WHERE port_id = 1 AND arrival_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Revenue (revenue_id INT, sale_type TEXT, state TEXT, revenue DECIMAL(10,2)); INSERT INTO Revenue (revenue_id, sale_type, state, revenue) VALUES (1, 'medical', 'Oregon', 5000.00), (2, 'recreational', 'Oregon', 7000.00), (3, 'medical', 'California', 8000.00), (4, 'recreational', 'California', 10000.00); | What is the total revenue generated from medical marijuana sales in Oregon? | SELECT SUM(revenue) as total_revenue FROM Revenue WHERE state = 'Oregon' AND sale_type = 'medical'; | 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.