context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Members (MemberID INT, Age INT, MembershipType VARCHAR(10)); INSERT INTO Members (MemberID, Age, MembershipType) VALUES (1, 35, 'Premium'), (2, 28, 'Basic'), (3, 42, 'Premium'), (4, 22, 'Basic'), (5, 55, 'Premium'); | What is the total number of members who have a 'Basic' or 'Premium' membership? | SELECT COUNT(*) FROM Members WHERE MembershipType IN ('Basic', 'Premium'); | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_time TIMESTAMP); | What is the trend of security incidents over the past year? | SELECT DATE_TRUNC('month', incident_time) as incident_month, COUNT(*) as incident_count FROM security_incidents WHERE incident_time >= NOW() - INTERVAL '1 year' GROUP BY incident_month ORDER BY incident_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (customer_id INT, first_name VARCHAR(15), last_name VARCHAR(15), food_allergy VARCHAR(15)); INSERT INTO Customers (customer_id, first_name, last_name, food_allergy) VALUES (1, 'John', 'Doe', 'Peanuts'), (2, 'Jane', 'Doe', 'Nuts'), (3, 'Bob', 'Smith', NULL); | List all the customers who have a food allergy to peanuts. | SELECT first_name, last_name FROM Customers WHERE food_allergy = 'Peanuts'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, vuln_id INT, vuln_description VARCHAR(50), vuln_date DATE); INSERT INTO vulnerabilities (id, vuln_id, vuln_description, vuln_date) VALUES (1, 1, 'SQL Injection', '2022-01-01'), (2, 2, 'Cross-Site Scripting', '2022-01-05'), (3, 3, 'Remote Code Execution', '2022-01-10'); | What are the top 5 most common vulnerabilities found in the last month? | SELECT vuln_description, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE vuln_date >= DATEADD(day, -30, GETDATE()) GROUP BY vuln_description ORDER BY vulnerability_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE microfinance_institutions (institution_name TEXT, loans_outstanding NUMERIC, socially_responsible BOOLEAN, country TEXT); INSERT INTO microfinance_institutions (institution_name, loans_outstanding, socially_responsible, country) VALUES ('Pro Mujer', 123456, TRUE, 'Bolivia'); INSERT INTO microfinance_institutions (institution_name, loans_outstanding, socially_responsible, country) VALUES ('Fondo Esperanza', 234567, TRUE, 'Chile'); | What is the total outstanding socially responsible loans for microfinance institutions in South America? | SELECT SUM(loans_outstanding) FROM microfinance_institutions WHERE socially_responsible = TRUE AND country = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Language (LanguageID INT, LanguageName VARCHAR(50), Family VARCHAR(50), Population INT); INSERT INTO Language (LanguageID, LanguageName, Family, Population) VALUES (1, 'Quechua', 'Andean', 8000000), (2, 'Aymara', 'Andean', 3000000), (3, 'Mapudungun', 'Mapuche', 500000), (4, 'Guarani', 'Tupi-Guarani', 6000000); | What is the ratio of preserved languages per capita in each language family? | SELECT r.Family, AVG(l.Population) as AvgPopulation, COUNT(l.LanguageName) as LanguageCount, COUNT(l.LanguageName)/AVG(l.Population) as LangPerCapita FROM Language l JOIN (SELECT DISTINCT Family FROM Language) r ON 1=1 GROUP BY r.Family; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, region VARCHAR(50), data_usage INT, usage_date DATE); | What is the total data usage for broadband subscribers in a specific region for the last month? | SELECT region, SUM(data_usage) FROM broadband_subscribers WHERE region = 'RegionName' AND usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing (id INT PRIMARY KEY, item_type VARCHAR(20), country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Manufacturing (id, item_type, country, price) VALUES (1, 'Men_Shirt', 'Italy', 60.00), (2, 'Men_Pants', 'Italy', 80.00); | What is the average retail price of men's clothing items produced in Italy? | SELECT AVG(price) FROM Manufacturing WHERE item_type LIKE 'Men%' AND country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, investment_strategy VARCHAR(20), investment_return DECIMAL(10,2)); INSERT INTO investments (investment_id, investment_strategy, investment_return) VALUES (1, 'Stock Growth', 0.12), (2, 'Bond Income', 0.04), (3, 'Real Estate', 0.06), (4, 'Crypto', 0.25), (5, 'Stock Growth', 0.15), (6, 'Bond Income', 0.03); | Calculate the average investment return for each investment strategy in Q2 2021, excluding strategies with less than 5 investments. | SELECT AVG(investment_return) as avg_investment_return, investment_strategy FROM investments WHERE investment_date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY investment_strategy HAVING COUNT(investment_id) >= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE MineLocations (MineID int, Location varchar(50)); INSERT INTO MineLocations VALUES (1, 'Arctic Region'), (2, 'Andes Mountains'), (3, 'Sahara Desert'); CREATE TABLE AccidentData (MineID int, AccidentDate date); INSERT INTO AccidentData VALUES (1, '2022-01-15'), (1, '2022-02-18'), (3, '2022-03-04'), (2, '2022-01-12'), (1, '2022-02-29'); | How many labor accidents occurred in mines located in the Arctic region in Q1 2022? | SELECT COUNT(*) as LaborAccidents FROM AccidentData ad JOIN MineLocations ml ON ad.MineID = ml.MineID WHERE ml.Location = 'Arctic Region' AND ad.AccidentDate BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FashionTrends (TrendID INT, TrendName TEXT, Popularity INT, ProductionVolume INT, CO2Emission INT); INSERT INTO FashionTrends (TrendID, TrendName, Popularity, ProductionVolume, CO2Emission) VALUES (1, 'Athleisure', 8000, 7000, 300), (2, 'Denim', 9000, 4000, 250), (3, 'Boho-Chic', 7000, 5000, 200), (4, 'Minimalism', 6000, 3000, 150); CREATE TABLE ProductionVolume (TrendID INT, ProductionVolume INT); INSERT INTO ProductionVolume (TrendID, ProductionVolume) VALUES (1, 7000), (2, 4000), (3, 5000), (4, 3000); | What is the total CO2 emission for each fashion trend that is popular in Germany and has a production volume greater than 5000? | SELECT FT.TrendName, SUM(FT.CO2Emission) FROM FashionTrends FT INNER JOIN ProductionVolume PV ON FT.TrendID = PV.TrendID WHERE FT.Popularity > 8000 AND PV.ProductionVolume > 5000 GROUP BY FT.TrendName; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (id INT, name VARCHAR(50), data_usage FLOAT, city VARCHAR(50)); INSERT INTO mobile_customers (id, name, data_usage, city) VALUES (1, 'John Doe', 3.5, 'Chicago'), (2, 'Jane Smith', 4.2, 'New York'), (3, 'Mike Johnson', 5.6, 'Chicago'), (4, 'Sara Davis', 6.7, 'Chicago'); | Who are the top 3 mobile customers by data usage in the city of Chicago? | SELECT name, data_usage FROM mobile_customers WHERE city = 'Chicago' ORDER BY data_usage DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_lessons (lesson_id INT, participant_name VARCHAR(50), instrument VARCHAR(50)); INSERT INTO music_lessons (lesson_id, participant_name, instrument) VALUES (1, 'Oliver', 'Piano'), (2, 'Patricia', 'Guitar'), (3, 'John', 'Drums'); | Delete the record of the participant 'Oliver' from the 'Music Lessons' table, if they exist. | DELETE FROM music_lessons WHERE participant_name = 'Oliver'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name VARCHAR(50), location VARCHAR(50), carbon_emissions INT); INSERT INTO mining_operations (id, name, location, carbon_emissions) VALUES (1, 'Operation A', 'USA', 5000), (2, 'Operation B', 'Canada', 4000), (3, 'Operation C', 'Mexico', 6000); | What is the average carbon emission per mining operation? | SELECT AVG(carbon_emissions) as avg_emissions FROM mining_operations; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data(product_id INT, product_type VARCHAR(20), sale_date DATE, revenue DECIMAL(10,2), cruelty_free BOOLEAN); INSERT INTO sales_data(product_id, product_type, sale_date, revenue, cruelty_free) VALUES(1, 'Lipstick', '2021-01-01', 50.00, TRUE), (2, 'Mascara', '2021-01-15', 75.00, FALSE); | Find the total revenue of cruelty-free makeup products sold in 2021 | SELECT SUM(revenue) FROM sales_data WHERE product_type LIKE 'Makeup%' AND cruelty_free = TRUE AND YEAR(sale_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (vulnerability_id INT, vulnerability_severity VARCHAR(255), vulnerability_date DATE); INSERT INTO vulnerabilities (vulnerability_id, vulnerability_severity, vulnerability_date) VALUES (1, 'Critical', '2021-06-01'), (2, 'High', '2021-06-05'), (3, 'Medium', '2021-06-10'), (4, 'Low', '2021-06-15'), (5, 'Critical', '2021-06-20'), (6, 'High', '2021-06-25'), (7, 'Medium', '2021-06-30'); | What is the distribution of vulnerabilities by severity level for the last month? | SELECT vulnerability_severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE vulnerability_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY vulnerability_severity; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility_initiatives (initiative_year INT, num_initiatives INT); INSERT INTO accessibility_initiatives (initiative_year, num_initiatives) VALUES (2013, 125), (2014, 150), (2015, 175), (2016, 200), (2017, 225), (2018, 250), (2019, 275), (2020, 300); | How many accessibility initiatives were launched per year in the last 10 years? | SELECT initiative_year, num_initiatives, COUNT(*) OVER (PARTITION BY initiative_year) AS initiatives_per_year FROM accessibility_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); CREATE TABLE games (game_id INT, team_id INT, game_date DATE); CREATE TABLE games_stats (game_id INT, team_id INT, points INT); | What is the average points scored per game, grouped by team and year, from the teams, games, and games_stats tables? | SELECT t.team_name, EXTRACT(YEAR FROM g.game_date) AS year, AVG(gs.points) AS avg_points FROM teams t JOIN games g ON t.team_id = g.team_id JOIN games_stats gs ON g.game_id = gs.game_id GROUP BY t.team_name, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_ai_count (country VARCHAR(2), project_count INT); INSERT INTO ethical_ai_count (country, project_count) VALUES ('US', 10), ('CA', 5), ('MX', 8), ('BR', 6), ('AR', 7); | What is the average number of ethical AI projects per country? | SELECT AVG(project_count) FROM ethical_ai_count; | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_transactions (transaction_id INT, revenue DECIMAL(10, 2)); | What is the average online travel agency revenue per transaction? | SELECT AVG(revenue) FROM ota_transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_areas (name TEXT, population INT, area FLOAT, waste_generation FLOAT); INSERT INTO urban_areas (name, population, area, waste_generation) VALUES ('City A', 1200000, 200, 150000), ('City B', 1500000, 250, 180000), ('City C', 1000000, 180, 120000); | What is the average waste generation per person in urban areas with a population greater than 1,000,000? | SELECT AVG(waste_generation/population) FROM urban_areas WHERE population > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_sales (manufacturer VARCHAR(50), autonomous BOOLEAN, sales INT); INSERT INTO vehicle_sales (manufacturer, autonomous, sales) VALUES ('Tesla', TRUE, 50000), ('Nissan', FALSE, 30000), ('Chevrolet', TRUE, 40000), ('Ford', FALSE, 60000); | Display the percentage of autonomous vehicles among total vehicles for each manufacturer | SELECT manufacturer, (SUM(CASE WHEN autonomous THEN sales ELSE 0 END) / SUM(sales)) * 100 as percentage FROM vehicle_sales GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (name TEXT, min_depth FLOAT, ocean TEXT); CREATE TABLE ocean_regions (name TEXT, area FLOAT); | What is the minimum depth recorded for any marine species in the Pacific Ocean? | SELECT MIN(min_depth) FROM marine_species WHERE ocean = (SELECT name FROM ocean_regions WHERE area = 'Pacific Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, state TEXT, outcome TEXT); | What is the average success rate of cases in each state? | SELECT state, AVG(CASE WHEN outcome = 'Success' THEN 1.0 ELSE 0.0 END) AS success_rate FROM cases GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (team VARCHAR(50), opponent VARCHAR(50), points_team INTEGER, points_opponent INTEGER, season VARCHAR(10)); INSERT INTO matches (team, opponent, points_team, points_opponent, season) VALUES ('Los Angeles Lakers', 'Golden State Warriors', 100, 115, '2020-2021'), ('Los Angeles Lakers', 'Los Angeles Clippers', 98, 105, '2020-2021'); | What is the minimum number of points scored by the Los Angeles Lakers in a single game during the 2020-2021 NBA season? | SELECT MIN(points_team) FROM matches WHERE team = 'Los Angeles Lakers' AND season = '2020-2021'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents(StudentID INT, Name VARCHAR(50), Department VARCHAR(50)); INSERT INTO GraduateStudents VALUES (1, 'Robert Brown', 'Social Sciences'); INSERT INTO GraduateStudents VALUES (2, 'Emily Davis', 'Social Sciences'); CREATE TABLE ResearchGrants(GrantsID INT, StudentID INT, Year INT, Amount INT); INSERT INTO ResearchGrants VALUES (1, 1, 2019, 50000); INSERT INTO ResearchGrants VALUES (2, 2, 2021, 75000); INSERT INTO ResearchGrants VALUES (3, 1, 2021, 60000); | What is the total research grant amount awarded to graduate students in the Social Sciences department per year? | SELECT RG.Year, SUM(RG.Amount) FROM ResearchGrants RG JOIN GraduateStudents GS ON RG.StudentID = GS.StudentID WHERE GS.Department = 'Social Sciences' GROUP BY RG.Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (member_id INT, union_name VARCHAR(30), sector VARCHAR(20), num_offices INT); INSERT INTO union_members (member_id, union_name, sector, num_offices) VALUES (1, 'UnionA', 'Construction', 8), (2, 'UnionB', 'Construction', 5), (3, 'UnionC', 'Education', 4); | Determine the total number of members in unions with 'Construction' as their sector and having more than 6 offices. | SELECT COUNT(*) FROM union_members WHERE sector = 'Construction' AND num_offices > 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (id INT, name VARCHAR(50), cost DECIMAL(10,2), type VARCHAR(20)); INSERT INTO infrastructure_projects (id, name, cost, type) VALUES (1, 'Rural Road', 12000.00, 'Transportation'); INSERT INTO infrastructure_projects (id, name, cost, type) VALUES (2, 'Irrigation System', 35000.00, 'Water Management'); INSERT INTO infrastructure_projects (id, name, cost, type) VALUES (3, 'Rural Electrification', 28000.00, 'Energy'); | Show the total cost of rural infrastructure projects per type in the 'rural_development' database | SELECT type, SUM(cost) FROM infrastructure_projects GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_aid (provider_id INT, provider VARCHAR(255), location VARCHAR(255)); CREATE TABLE restorative_practices (offense_id INT, practice VARCHAR(255), provider_id INT); | Which legal aid providers in the 'legal_aid' table also offer restorative justice services in the 'restorative_practices' table? | SELECT provider FROM legal_aid WHERE provider_id IN (SELECT provider_id FROM restorative_practices); | gretelai_synthetic_text_to_sql |
CREATE TABLE biotech_startups (id INT, name TEXT, location TEXT, budget FLOAT); INSERT INTO biotech_startups (id, name, location, budget) VALUES (1, 'StartupLab', 'New York', 10000000.0); INSERT INTO biotech_startups (id, name, location, budget) VALUES (2, 'TechBio', 'New York', 14000000.0); | What is the average budget for biotech startups in New York? | SELECT AVG(budget) FROM biotech_startups WHERE location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO players (id, name, age, country) VALUES (1, 'John Doe', 25, 'USA'); INSERT INTO players (id, name, age, country) VALUES (2, 'Jane Smith', 30, 'Canada'); | Update the age of all Canadian players to 27 | UPDATE players SET age = 27 WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PuzzleScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int); INSERT INTO PuzzleScores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player1', 'Game6', 1000), (2, 'Player2', 'Game6', 1200), (3, 'Player3', 'Game6', 800), (4, 'Player4', 'Game6', 1400); | Update the score of the player with the lowest score in the 'Puzzle' game category to be the average score for that category. | UPDATE PuzzleScores SET Score = (SELECT AVG(Score) FROM PuzzleScores WHERE Game = 'Game6') WHERE PlayerID = (SELECT PlayerID FROM PuzzleScores WHERE Game = 'Game6' ORDER BY Score LIMIT 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), price INT); INSERT INTO properties (id, address, city, state, price) VALUES (4, '101 EcoLn', 'SustainableCity', 'WA', 450000); CREATE TABLE green_certifications (property_id INT, certification_type VARCHAR(255)); INSERT INTO green_certifications (property_id, certification_type) VALUES (5, 'GreenGlobe'); | What is the address, city, and state of properties in 'SustainableCity' with no green certifications? | SELECT properties.address, properties.city, properties.state FROM properties LEFT JOIN green_certifications ON properties.id = green_certifications.property_id WHERE properties.city = 'SustainableCity' AND green_certifications.property_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonationDate DATE, Amount DECIMAL(10,2), State TEXT); INSERT INTO Donors (DonorID, DonationDate, Amount, State) VALUES (1, '2021-01-15', 50.00, 'California'), (2, '2021-02-01', 100.00, 'Texas'), (3, '2021-06-10', 25.00, 'Florida'), (4, '2021-04-20', 75.00, 'California'); | What was the percentage of donations received from each state in H1 2021? | SELECT State, SUM(Amount) as 'Total Donations', (SUM(Amount) / (SELECT SUM(Amount) FROM Donors WHERE DonationDate BETWEEN '2021-01-01' AND '2021-06-30') * 100) as 'Percentage of Donations' FROM Donors WHERE DonationDate BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (id INT, name TEXT, build_year INT, location TEXT); INSERT INTO bridges (id, name, build_year, location) VALUES (1, 'Bridge A', 1975, 'California'), (2, 'Bridge B', 1982, 'Texas'); | Find the number of bridges built before 1980 in California | SELECT COUNT(*) FROM bridges WHERE build_year < 1980 AND location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (id INT, cause VARCHAR(255), cost INT, sector VARCHAR(255), date DATE); INSERT INTO incidents (id, cause, cost, sector, date) VALUES (1, 'third-party vendor', 5000, 'financial', '2021-01-01'); INSERT INTO incidents (id, cause, cost, sector, date) VALUES (2, 'insider threat', 10000, 'retail', '2021-01-02'); | What is the average cost of security incidents caused by third-party vendors in the financial sector in 2021? | SELECT AVG(cost) FROM incidents WHERE cause = 'third-party vendor' AND sector = 'financial' AND YEAR(date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (PropertyID INT, Price DECIMAL(10,2), District VARCHAR(255)); INSERT INTO Properties (PropertyID, Price, District) VALUES (1, 900000, 'Sustainable Urbanism'), (2, 800000, 'Sustainable Urbanism'), (3, 700000, 'Traditional Urbanism'); | What is the total property value in the sustainable urbanism district of Vancouver? | SELECT SUM(Price) FROM Properties WHERE District = 'Sustainable Urbanism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_by_day (menu_item VARCHAR(255), sales DECIMAL(10,2), day_of_week VARCHAR(10)); INSERT INTO sales_by_day (menu_item, sales, day_of_week) VALUES ('Bruschetta', 100.00, 'Monday'), ('Spaghetti Bolognese', 200.00, 'Monday'), ('Cheesecake', 150.00, 'Monday'), ('Bruschetta', 150.00, 'Tuesday'), ('Spaghetti Bolognese', 250.00, 'Tuesday'), ('Cheesecake', 180.00, 'Tuesday'); | What is the total sales for each menu item by day of the week? | SELECT menu_item, day_of_week, SUM(sales) FROM sales_by_day GROUP BY menu_item, day_of_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE Disability_Complaints (id INT, complaint_id INT, complaint_type VARCHAR(50), resolution_status VARCHAR(50)); INSERT INTO Disability_Complaints (id, complaint_id, complaint_type, resolution_status) VALUES (1, 3001, 'Accessibility', 'Resolved'), (2, 3002, 'Discrimination', 'Unresolved'); | What is the total number of disability complaints by type and resolution status? | SELECT Disability_Complaints.complaint_type, Disability_Complaints.resolution_status, COUNT(*) as total FROM Disability_Complaints GROUP BY Disability_Complaints.complaint_type, Disability_Complaints.resolution_status; | gretelai_synthetic_text_to_sql |
CREATE TABLE museum_operations (exhibit_id INT, exhibit_name TEXT, start_date DATE, end_date DATE, daily_visitors INT); | What is the maximum number of daily visitors for exhibits in the museum_operations table, excluding temporary exhibits? | SELECT MAX(daily_visitors) FROM museum_operations WHERE DATEDIFF(end_date, start_date) > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE exploration (well_id INT, well_name TEXT, production_rate FLOAT, region TEXT); INSERT INTO exploration (well_id, well_name, production_rate, region) VALUES (1, 'Well D', 500.5, 'North Sea'); INSERT INTO exploration (well_id, well_name, production_rate, region) VALUES (2, 'Well E', 600.3, 'Gulf of Mexico'); INSERT INTO exploration (well_id, well_name, production_rate, region) VALUES (3, 'Well F', 450.2, 'North Sea'); | What is the maximum production rate for wells in the North Sea? | SELECT MAX(production_rate) FROM exploration WHERE region = 'North Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT PRIMARY KEY, project_name VARCHAR(255), project_location VARCHAR(255), project_type VARCHAR(255), capacity_mw FLOAT); | Determine the sum of installed capacity for renewable energy projects in Japan. | SELECT SUM(capacity_mw) FROM renewable_projects WHERE project_location = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name TEXT, state TEXT); CREATE TABLE revenue (restaurant_id INT, location_id INT, amount INT); | What is the total revenue for each restaurant location, grouped by state, excluding states with no revenue? | SELECT restaurants.state, SUM(revenue.amount) FROM revenue JOIN restaurants ON revenue.restaurant_id = restaurants.id WHERE revenue.amount > 0 GROUP BY restaurants.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, VRPreference INT, GameType VARCHAR(10)); INSERT INTO Players (PlayerID, VRPreference, GameType) VALUES (1, 1, 'FPS'), (2, 0, 'RPG'), (3, 1, 'FPS'), (4, 0, 'Simulation'); | How many players prefer VR technology for FPS games? | SELECT COUNT(*) FROM Players WHERE VRPreference = 1 AND GameType = 'FPS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE epl_stats (player TEXT, team TEXT, goals INT); INSERT INTO epl_stats (player, team, goals) VALUES ('Harry Kane', 'Tottenham', 21), ('Mohamed Salah', 'Liverpool', 20), ('Son Heung-min', 'Tottenham', 19); | Who is the leading goal scorer in the 2022-2023 English Premier League? | SELECT player, SUM(goals) as total_goals FROM epl_stats GROUP BY player ORDER BY total_goals DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (country VARCHAR(50), agreement_type VARCHAR(50), year INT); INSERT INTO defense_diplomacy (country, agreement_type, year) VALUES (1, 'USA', 2015), (2, 'Russia', 2018), (3, 'China', 2017); | Add a new record to the "defense_diplomacy" table with the following information: ('India', 'military exercise', 2022) | INSERT INTO defense_diplomacy (country, agreement_type, year) VALUES ('India', 'military exercise', 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE car_insurance (policyholder_name TEXT, policy_number INTEGER); CREATE TABLE health_insurance (policyholder_name TEXT, policy_number INTEGER); INSERT INTO car_insurance VALUES ('Alice', 123), ('Bob', 456), ('Charlie', 789), ('Dave', 111); INSERT INTO health_insurance VALUES ('Bob', 999), ('Eve', 888), ('Alice', 222), ('Dave', 333); | Which policyholders have policies in both the car and health insurance categories, and what are their policy numbers? | SELECT policyholder_name, policy_number FROM car_insurance WHERE policyholder_name IN (SELECT policyholder_name FROM health_insurance); | gretelai_synthetic_text_to_sql |
CREATE TABLE reviews (id INT PRIMARY KEY, user_id INT, attraction_id INT, rating INT, review TEXT, timestamp TIMESTAMP); | Insert new records into the reviews table for a review of an attraction in Paris, France | INSERT INTO reviews (user_id, attraction_id, rating, review, timestamp) VALUES (123, 7, 5, 'This attraction is a must-see in Paris!', '2022-11-30 10:30:00'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); CREATE TABLE Donations (DonationID INT, ProgramID INT, DonorID INT, DonationDate DATE); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Dance'), (2, 'Photography'), (3, 'Sculpture'); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'Jane Smith'), (2, 'Robert Johnson'), (3, 'Clara Garcia'); INSERT INTO Donations (DonationID, ProgramID, DonorID, DonationDate) VALUES (1, 1, 1, '2023-01-05'), (2, 1, 3, '2023-02-10'), (3, 2, 2, '2023-03-20'), (4, 3, 1, '2023-03-25'); | Which programs received funding from new donors in Q1 2023? | SELECT p.ProgramName FROM Programs p INNER JOIN Donations d ON p.ProgramID = d.ProgramID INNER JOIN Donors don ON d.DonorID = don.DonorID WHERE QUARTER(d.DonationDate) = 1 AND don.DonorID NOT IN (SELECT DonorID FROM Donations WHERE DonationDate < '2023-01-01') GROUP BY p.ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response_efforts (id INT, effort_name VARCHAR(255), effort_type VARCHAR(255)); INSERT INTO disaster_response_efforts (id, effort_name, effort_type) VALUES (1, 'Effort A', 'Search and Rescue'), (2, 'Effort B', 'Medical Assistance'), (3, 'Effort C', 'Search and Rescue'); | How many unique types of disaster response efforts are there in 'disaster_response_efforts' table? | SELECT COUNT(DISTINCT effort_type) as num_unique_types FROM disaster_response_efforts; | gretelai_synthetic_text_to_sql |
CREATE TABLE training (id INT PRIMARY KEY, employee_id INT, training_type VARCHAR(50), duration INT); INSERT INTO training (id, employee_id, training_type, duration) VALUES (1, 1, 'SQL', 2), (2, 2, 'Python', 4); | Update the duration of the training with id 1 in the "training" table to 3 | UPDATE training SET duration = 3 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_centers (id INT, open_date DATE); INSERT INTO healthcare_centers (id, open_date) VALUES (1, '2017-01-01'), (2, '2018-05-15'), (3, '2019-09-23'), (4, '2020-07-02'), (5, '2021-02-14'); CREATE TABLE regions (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO regions (id, name, type) VALUES (1, 'RegionA', 'Rural'), (2, 'RegionB', 'Urban'); | How many rural healthcare centers were opened in the last 5 years? | SELECT COUNT(*) FROM healthcare_centers WHERE open_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND (SELECT type FROM regions WHERE id = (SELECT region_id FROM healthcare_centers WHERE healthcare_centers.id = id)) = 'Rural'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Rural_Patients (Patient_ID INT, Age INT, Gender VARCHAR(10), Diagnosis VARCHAR(20)); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (1, 35, 'Male', NULL); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (2, 42, 'Female', 'Asthma'); | What is the number of male patients who have not been diagnosed with any disease? | SELECT COUNT(Rural_Patients.Patient_ID) FROM Rural_Patients WHERE Rural_Patients.Gender = 'Male' AND Rural_Patients.Diagnosis IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE ElectricVehicleAdoption (Vehicle VARCHAR(255), MPG INT); INSERT INTO ElectricVehicleAdoption (Vehicle, MPG) VALUES ('TeslaModel3', 120), ('TeslaModelS', 105), ('NissanLeaf', 115), ('ChevroletBolt', 128); | Calculate the average miles per gallon for electric vehicles in the 'ElectricVehicleAdoption' table. | SELECT AVG(MPG) as AverageMPG FROM ElectricVehicleAdoption WHERE Vehicle LIKE '%Tesla%' OR Vehicle LIKE '%Nissan%' OR Vehicle LIKE '%Chevrolet%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives_national (region VARCHAR(20), initiative VARCHAR(50), usage FLOAT, timestamp TIMESTAMP); INSERT INTO conservation_initiatives_national (region, initiative, usage, timestamp) VALUES ('Sydney', 'Rainwater harvesting', 1000, '2022-01-01 10:00:00'), ('Australia', 'Greywater reuse', 1200, '2022-02-01 10:00:00'); | What is the percentage of water conservation initiatives in the Sydney region compared to the national average? | SELECT 100.0 * SUM(CASE WHEN region = 'Sydney' THEN usage ELSE 0 END) / SUM(CASE WHEN region = 'Australia' THEN usage ELSE 0 END) AS percentage FROM conservation_initiatives_national WHERE initiative IN ('Rainwater harvesting', 'Greywater reuse'); | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_hotels (hotel_id INT, hotel_name VARCHAR(50), rating DECIMAL(2,1), country VARCHAR(50)); INSERT INTO eco_hotels VALUES (1, 'Eco-Retreat', 4.7, 'Spain'), (2, 'Green Vacations', 4.3, 'Spain'), (3, 'Eco-Lodge', 4.5, 'France'), (4, 'Green Hotel', 4.6, 'Germany'); | List the names and ratings of eco-friendly hotels in Germany. | SELECT hotel_name, rating FROM eco_hotels WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, region TEXT, volunteer_date DATE); | Insert a new record into the 'volunteers' table for 'Pablo Rodriguez' from the 'Southeast' region who volunteered on '2022-02-14' | INSERT INTO volunteers (id, name, region, volunteer_date) VALUES (1, 'Pablo Rodriguez', 'Southeast', '2022-02-14'); | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farms (id INT, name TEXT, location TEXT, area_ha FLOAT); | Insert a new organic farm 'Farm C' located in 'Oakland' with an area of 2 hectares into the 'organic_farms' table. | INSERT INTO organic_farms (id, name, location, area_ha) VALUES (3, 'Farm C', 'Oakland', 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_games(fan_id INT, game_id INT);CREATE TABLE games(game_id INT, game_name VARCHAR(50), tickets_sold INT); | Show the number of unique fans who have purchased tickets for each game. | SELECT g.game_name, COUNT(DISTINCT f.fan_id) FROM fan_games f JOIN games g ON f.game_id = g.game_id GROUP BY g.game_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, VRAdoption BOOLEAN); INSERT INTO Players (PlayerID, VRAdoption) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, FALSE); | What is the total number of players who have adopted virtual reality technology? | SELECT COUNT(*) FROM Players WHERE VRAdoption = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE ev_adoption_statistics (id INT, country_name VARCHAR(50), adoption_rate INT); | Add a new row to the 'ev_adoption_statistics' table with id 100, country_name 'Germany', and adoption_rate 25 | INSERT INTO ev_adoption_statistics (id, country_name, adoption_rate) VALUES (100, 'Germany', 25); | gretelai_synthetic_text_to_sql |
CREATE TABLE date (date DATE); CREATE TABLE investment (transaction_id INT, date DATE, value DECIMAL(10,2), type VARCHAR(10)); | What is the total transaction value for each day in the "investment" table, for transactions that occurred in the month of March 2022 and are of type "sell"? | SELECT d.date, SUM(i.value) as total_value FROM date d JOIN investment i ON d.date = i.date WHERE i.type = 'sell' AND MONTH(d.date) = 3 AND YEAR(d.date) = 2022 GROUP BY d.date; | gretelai_synthetic_text_to_sql |
CREATE TABLE site (site_id INT, site_name VARCHAR(50), num_employees INT); | What is the average number of employees per site? | SELECT AVG(num_employees) FROM site; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT PRIMARY KEY, name VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); CREATE TABLE concerts (id INT PRIMARY KEY, artist_id INT, venue VARCHAR(255), city VARCHAR(255), country VARCHAR(255), tickets_sold INT, revenue DECIMAL(10, 2)); CREATE TABLE users (id INT PRIMARY KEY, gender VARCHAR(50), age INT); | Identify the total revenue from concert ticket sales for artists from Asia. | SELECT SUM(revenue) AS total_revenue FROM concerts WHERE country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (id INT, student_id INT, type TEXT, cost INT, date DATE); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (1, 1, 'wheelchair', 500, '2022-01-01'); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (2, 2, 'note taker', 500, '2022-02-01'); | What is the minimum cost of accommodations provided to students with mobility impairments in the past year? | SELECT MIN(cost) FROM accommodations WHERE type = 'wheelchair' AND date >= DATE_SUB(NOW(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE tech_companies (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), mission VARCHAR(255)); | Delete all records in the "tech_companies" table where the "location" is 'San Francisco' | WITH deleted_data AS (DELETE FROM tech_companies WHERE location = 'San Francisco' RETURNING *) SELECT * FROM deleted_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), is_cruelty_free BOOLEAN, sales FLOAT); INSERT INTO products VALUES (1, 'Lipstick', true, 500.50), (2, 'Mascara', false, 300.00), (3, 'Foundation', true, 700.00); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions VALUES (1, 'Canada'), (2, 'USA'); CREATE TABLE time (time_id INT, year INT); INSERT INTO time VALUES (1, 2022); | What are the top 3 cruelty-free cosmetic products by sales in the Canadian region for 2022? | SELECT p.product_name, p.sales FROM products p INNER JOIN regions r ON p.product_id = r.region_id INNER JOIN time t ON p.product_id = t.time_id WHERE p.is_cruelty_free = true GROUP BY p.product_name, p.sales, r.region_name, t.year ORDER BY p.sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE, location VARCHAR(100)); INSERT INTO donations (id, donor_id, amount, donation_date, location) VALUES (1, 101, 500.00, '2022-01-01', 'New York'), (2, 102, 300.00, '2022-02-15', 'Los Angeles'), (3, 101, 600.00, '2022-04-01', 'New York'); | Which donors have made a donation in every quarter of the current year, broken down by their location? | SELECT donor_id, YEAR(donation_date) AS year, QUARTER(donation_date) AS quarter, location FROM donations WHERE donation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE() GROUP BY donor_id, year, quarter, location HAVING COUNT(DISTINCT quarter) = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), role VARCHAR(50)); CREATE TABLE trainings (id INT, employee_id INT, training VARCHAR(50)); INSERT INTO employees (id, name, department, role) VALUES (1, 'John Doe', 'hr', 'employee'), (2, 'Jane Smith', 'hr', 'manager'), (3, 'Bob Johnson', 'operations', 'employee'), (4, 'Alice', 'it', 'employee'), (5, 'Eli', 'research', 'employee'); INSERT INTO trainings (id, employee_id, training) VALUES (1, 1, 'SQL Fundamentals'), (2, 1, 'Data Analysis'), (3, 2, 'Data Analysis'), (4, 3, 'SQL Fundamentals'), (5, 4, 'Machine Learning'), (6, 5, 'SQL Fundamentals'), (7, 5, 'Data Analysis'); | Find the number of employees who have completed training programs 'SQL Fundamentals', 'Data Analysis', and 'Machine Learning' separately for each department. | SELECT department, training, COUNT(*) FROM trainings JOIN employees ON trainings.employee_id = employees.id GROUP BY department, training; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), population INT, habitat VARCHAR(255)); | Insert a new record into the species table for a marine reptile found in the Southern Ocean | INSERT INTO species (id, name, type, population, habitat) VALUES (24, 'Leatherback Sea Turtle', 'Reptile', 3500, 'Southern Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (drug varchar(20), quarter varchar(10), revenue int); INSERT INTO sales (drug, quarter, revenue) VALUES ('DrugA', 'Q1 2020', 1500000); | What was the total revenue for 'DrugA' in Q1 2020?' | SELECT revenue FROM sales WHERE drug = 'DrugA' AND quarter = 'Q1 2020'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sea_level (id INT, month INT, level FLOAT); INSERT INTO sea_level (id, month, level) VALUES (1, 1, 20); INSERT INTO sea_level (id, month, level) VALUES (2, 2, 19); INSERT INTO sea_level (id, month, level) VALUES (3, 3, 18); | What is the minimum sea level, grouped by month? | SELECT month, MIN(level) FROM sea_level GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (id INT, name VARCHAR(50), date DATE); INSERT INTO esports_events (id, name, date) VALUES (201, 'DreamHack', '2022-06-11'), (202, 'ESL One', '2022-07-16'); | Delete the esports event with ID 201 | DELETE FROM esports_events WHERE id = 201; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ingredient (id INT PRIMARY KEY, name VARCHAR(255), origin VARCHAR(255), supplier_id INT); CREATE TABLE Supplier (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); | Who is the supplier of the quinoa ingredient in Berlin? | SELECT s.name FROM Ingredient i INNER JOIN Supplier s ON i.supplier_id = s.id WHERE i.name = 'Quinoa' AND s.location = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (MissionID INT PRIMARY KEY, AstronautID INT, HoursFlown INT); INSERT INTO SpaceMissions (MissionID, AstronautID, HoursFlown) VALUES (1, 1, 150); INSERT INTO SpaceMissions (MissionID, AstronautID, HoursFlown) VALUES (2, 2, 120); | What is the total number of space missions flown by astronauts who have completed more than 100 hours of flight time? | SELECT COUNT(*) FROM SpaceMissions SM INNER JOIN Astronauts A ON SM.AstronautID = A.AstronautID WHERE A.HoursFlown > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicTransportation (TripID INT, Mode VARCHAR(50), Distance DECIMAL(5,2)); CREATE TABLE MultimodalTransportation (TripID INT, Mode VARCHAR(50), Distance DECIMAL(5,2)); | What is the percentage of public transportation trips that are multimodal? | SELECT 100.0 * COUNT(DISTINCT pt.TripID) / COUNT(DISTINCT mt.TripID) AS Percentage FROM PublicTransportation pt JOIN MultimodalTransportation mt ON pt.TripID = mt.TripID; | gretelai_synthetic_text_to_sql |
CREATE TABLE CitizenFeedback (state VARCHAR(20), year INT, service VARCHAR(30), rating INT); INSERT INTO CitizenFeedback (state, year, service, rating) VALUES ('New York', 2021, 'Education', 5), ('New York', 2021, 'Education', 4), ('New York', 2021, 'Education', 5), ('New York', 2021, 'Education', 3), ('New York', 2021, 'Education', 5), ('New York', 2021, 'Education', 2); | Determine the number of citizen feedback records with a rating of 5 for education services in New York state in 2021. | SELECT COUNT(*) FROM CitizenFeedback WHERE state = 'New York' AND year = 2021 AND service = 'Education' AND rating = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), policyholder_state VARCHAR(20)); INSERT INTO claims (policyholder_id, claim_amount, policyholder_state) VALUES (1, 500.00, 'Nevada'), (2, 600.00, 'Nevada'), (3, 700.00, 'Nevada'), (4, 800.00, 'New Mexico'); | What is the average claim amount paid to policyholders in 'Nevada' and 'New Mexico'? | SELECT AVG(claim_amount) FROM claims WHERE policyholder_state IN ('Nevada', 'New Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities_or (id INT, name VARCHAR(50), state VARCHAR(50), capacity FLOAT); INSERT INTO facilities_or (id, name, state, capacity) VALUES (1, 'Port Blakely', 'Oregon', 1000000); | List all timber production facilities in the state of Oregon and their respective production capacities in cubic meters. | SELECT f.name, f.capacity FROM facilities_or f WHERE f.state = 'Oregon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program_id INT, signup_date DATE); CREATE TABLE programs (program_id INT, program_name TEXT); INSERT INTO programs VALUES (1, 'Health Awareness'); INSERT INTO programs VALUES (2, 'Environment Protection'); | What was the total number of volunteers for each program in H1 2022? | SELECT program_id, program_name, COUNT(volunteer_id) as total_volunteers FROM volunteers JOIN programs ON volunteers.program_id = programs.program_id WHERE QUARTER(signup_date) IN (1,2) AND YEAR(signup_date) = 2022 GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists cities (city_id INT, city VARCHAR(255)); INSERT INTO cities (city_id, city) VALUES (1, 'Los Angeles'), (2, 'New York'), (3, 'Chicago'); CREATE TABLE if not exists matches (match_id INT, city_id INT, sport VARCHAR(255), date DATE); INSERT INTO matches (match_id, city_id, sport, date) VALUES (1, 1, 'Basketball', '2022-05-01'), (2, 2, 'Baseball', '2022-05-05'), (3, 3, 'Soccer', '2022-05-03'), (4, 1, 'Basketball', '2022-05-15'), (5, 1, 'Basketball', '2022-05-25'); | How many basketball matches took place in Los Angeles in the last month? | SELECT COUNT(match_id) FROM matches WHERE city_id = 1 AND sport = 'Basketball' AND date >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Events (id INT, location VARCHAR(20), event_date DATE); INSERT INTO Community_Events (id, location, event_date) VALUES (1, 'New York', '2020-09-01'), (2, 'Los Angeles', '2021-02-15'); | How many community events were held in New York between 2020 and 2021? | SELECT COUNT(*) FROM Community_Events WHERE location = 'New York' AND event_date BETWEEN '2020-01-01' AND '2021-12-31' | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, incident_date DATE, incident_description TEXT, location TEXT, resolved BOOLEAN); CREATE VIEW states AS SELECT SUBSTRING(location, 1, INSTR(location, ' ') - 1) AS state FROM mental_health_parity GROUP BY state; | What is the total number of mental health parity violation incidents that have been reported in each state in the last year? | SELECT state, COUNT(*) FROM mental_health_parity WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response.sectors_donations (sector_id INT, sector_name VARCHAR(255), total_donations DECIMAL); INSERT INTO disaster_response.sectors_donations (sector_id, sector_name, total_donations) VALUES (1, 'Education', 15000.00), (2, 'Health', 20000.00), (3, 'Water', 10000.00), (4, 'Shelter', 12000.00); | Which sectors received the highest and lowest total donations in the 'disaster_response' schema? | SELECT sector_name, total_donations FROM (SELECT sector_name, total_donations, DENSE_RANK() OVER (ORDER BY total_donations DESC) as donation_rank FROM disaster_response.sectors_donations) ranked_donations WHERE donation_rank = 1 OR donation_rank = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainability_scores (id INT PRIMARY KEY, algorithm_name VARCHAR(50), explanation_score INT, evaluation_date DATE); | Delete all records from the 'explainability_scores' table where the 'algorithm_name' is 'RL Algo 1' | DELETE FROM explainability_scores WHERE algorithm_name = 'RL Algo 1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_agriculture (id INT, initiative TEXT, location TEXT); INSERT INTO urban_agriculture (id, initiative, location) VALUES (1, 'Initiative 1', 'Asia'), (2, 'Initiative 2', 'Africa'); | Determine the total number of urban agriculture initiatives in 'Asia'. | SELECT COUNT(*) FROM urban_agriculture WHERE location = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Designers (DesignerID INT, DesignerName VARCHAR(50), IsSustainableFabric BOOLEAN); INSERT INTO Designers (DesignerID, DesignerName, IsSustainableFabric) VALUES (1, 'DesignerA', FALSE), (2, 'DesignerB', TRUE), (3, 'DesignerC', FALSE); CREATE TABLE FabricUsage (DesignerID INT, Fabric VARCHAR(50), Quantity INT); INSERT INTO FabricUsage (DesignerID, Fabric, Quantity) VALUES (1, 'Conventional Cotton', 600), (1, 'Viscose', 500), (2, 'Organic Cotton', 400), (2, 'Recycled Polyester', 300), (3, 'Conventional Cotton', 700), (3, 'Viscose', 600); | What is the total quantity of non-sustainable fabrics used by each designer? | SELECT d.DesignerName, SUM(fu.Quantity) as TotalNonSustainableQuantity FROM Designers d JOIN FabricUsage fu ON d.DesignerID = fu.DesignerID WHERE d.IsSustainableFabric = FALSE GROUP BY d.DesignerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT); INSERT INTO players (id, name, age) VALUES (1, 'John Doe', 25), (2, 'Jane Smith', 30); CREATE TABLE games_played (player_id INT, game_name VARCHAR(50), FOREIGN KEY (player_id) REFERENCES players(id)); INSERT INTO games_played (player_id, game_name) VALUES (1, 'Game A'), (1, 'Game B'); | Delete player records who have not played any games | DELETE FROM players WHERE id NOT IN (SELECT player_id FROM games_played); | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (hospital_name VARCHAR(255), borough VARCHAR(255)); INSERT INTO hospitals VALUES ('Mount Sinai Hospital', 'Manhattan'); INSERT INTO hospitals VALUES ('New York-Presbyterian Hospital', 'Manhattan'); INSERT INTO hospitals VALUES ('Montefiore Medical Center', 'Bronx'); | How many hospitals are there in each borough of New York City? | SELECT borough, COUNT(*) FROM hospitals GROUP BY borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE Multimodal_Data (Id INT, City VARCHAR(50), Mode VARCHAR(50), Month VARCHAR(10)); INSERT INTO Multimodal_Data (Id, City, Mode, Month) VALUES (1, 'Chicago', 'Bus', 'June'); INSERT INTO Multimodal_Data (Id, City, Mode, Month) VALUES (2, 'Chicago', 'Train', 'June'); | What is the percentage of multimodal trips in the city of Chicago in the month of June? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Multimodal_Data WHERE City = 'Chicago' AND Month = 'June')) FROM Multimodal_Data WHERE City = 'Chicago' AND Month = 'June' AND Mode IN ('Bus', 'Train'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Genres (genre_id INT, genre_name TEXT); INSERT INTO Genres (genre_id, genre_name) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'); CREATE TABLE Sales (sale_id INT, genre_id INT, revenue INT); | What is the total revenue for each genre? | SELECT genre_name, SUM(revenue) as total_revenue FROM Genres JOIN Sales ON Genres.genre_id = Sales.genre_id GROUP BY genre_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_disability BOOLEAN, user_country VARCHAR(50)); INSERT INTO users (user_id, user_disability, user_country) VALUES (1, true, 'Canada'); | Find the top 3 countries with the highest number of users with disabilities in Q4 2020, and display the total number of users for each. | SELECT user_country, COUNT(*) as user_count FROM users WHERE EXTRACT(MONTH FROM user_last_login) BETWEEN 10 AND 12 AND user_disability = true GROUP BY user_country ORDER BY user_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, product_id INT); CREATE TABLE sales (sale_id INT, product_id INT, sale_country TEXT); INSERT INTO ingredients VALUES (1, 'Water', 1), (2, 'Aloe Vera', 1), (3, 'Fragrance', 2), (4, 'Water', 3), (5, 'Glycerin', 3); INSERT INTO sales VALUES (1, 1, 'France'), (2, 2, 'Germany'), (3, 3, 'Italy'); | What are the most popular ingredients in cosmetics sold in Europe? | SELECT ingredient_name, COUNT(*) as count FROM ingredients i JOIN sales s ON i.product_id = s.product_id WHERE s.sale_country IN ('France', 'Germany', 'Italy') GROUP BY ingredient_name ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE machine (id INT, machine_name VARCHAR(50), waste_generated INT); INSERT INTO machine (id, machine_name, waste_generated) VALUES (1, 'Machine 1', 500), (2, 'Machine 2', 700), (3, 'Machine 3', 800), (4, 'Machine 4', 900); | Find the total waste generated by each machine, ranked by the highest total waste. | SELECT machine_name, SUM(waste_generated) as total_waste FROM machine GROUP BY machine_name ORDER BY total_waste DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE global_artists (id INT, name VARCHAR(255), country VARCHAR(50)); INSERT INTO global_artists (id, name, country) VALUES (1, 'Artist1', 'USA'), (2, 'Artist2', 'Canada'), (3, 'Artist3', 'Mexico'); | How many unique countries are represented in the 'global_artists' table? | SELECT COUNT(DISTINCT country) FROM global_artists; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (id INT, name TEXT, country TEXT, visitors INT); | Insert a new cultural heritage site in India with 10000 visitors. | INSERT INTO sites (name, country, visitors) VALUES ('Cultural Site India', 'India', 10000); | gretelai_synthetic_text_to_sql |
CREATE TABLE prices (year INT, element VARCHAR(10), country VARCHAR(10), price DECIMAL(5,2)); INSERT INTO prices (year, element, country, price) VALUES (2017, 'Gadolinium', 'Japan', 25.5), (2018, 'Gadolinium', 'Japan', 26.2), (2019, 'Gadolinium', 'Japan', 28.1), (2020, 'Gadolinium', 'Japan', 30.5), (2021, 'Gadolinium', 'Japan', 32.8); | What is the maximum price of Gadolinium in Japan over the past 3 years? | SELECT MAX(price) FROM prices WHERE element = 'Gadolinium' AND country = 'Japan' AND year BETWEEN (SELECT YEAR(CURDATE()) - 3) AND YEAR(CURDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, region VARCHAR(20), num_investments INT); INSERT INTO customers (id, region, num_investments) VALUES (1, 'Middle East', 3), (2, 'North America', 2), (3, 'Europe', 1), (4, 'Middle East', 4); | What is the average number of investments per customer in the Middle East region? | SELECT AVG(num_investments) FROM customers WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name VARCHAR(50), community VARCHAR(30));CREATE TABLE posts (id INT, title VARCHAR(50), author_id INT, post_type VARCHAR(10), genre VARCHAR(20)); | What is the total number of articles and blogs published by authors from underrepresented communities in the 'Arts and Entertainment' genre? | SELECT COUNT(*) FROM posts p JOIN authors a ON p.author_id = a.id WHERE a.community IN ('LGBTQ+', 'Minority Races', 'Indigenous') AND p.genre = 'Arts and Entertainment'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_text TEXT); CREATE TABLE users (id INT, privacy_setting VARCHAR(20)); CREATE TABLE post_likes (id INT, post_id INT, likes INT); INSERT INTO users (id, privacy_setting) VALUES (1, 'medium'), (2, 'high'), (3, 'low'); INSERT INTO posts (id, user_id, post_text) VALUES (1, 1, 'Hello World!'), (2, 2, 'Goodbye World!'), (3, 3, 'This is a private post.'); INSERT INTO post_likes (id, post_id, likes) VALUES (1, 1, 10), (2, 2, 5), (3, 3, 15); | Add a column to the posts table for the number of views | ALTER TABLE posts ADD COLUMN views INT; | 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.