context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
---|---|---|---|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Ethnicity VARCHAR(20), LGBTQ VARCHAR(10)); INSERT INTO Employees (EmployeeID, Department, Ethnicity, LGBTQ) VALUES (1, 'Mining', 'Caucasian', 'Yes'); INSERT INTO Employees (EmployeeID, Department, Ethnicity, LGBTQ) VALUES (2, 'Mining', 'African-American', 'No'); INSERT INTO Employees (EmployeeID, Department, Ethnicity, LGBTQ) VALUES (3, 'Mining', 'Indigenous', 'Yes'); | What is the total number of workers in the Mining department who identify as LGBTQ+? | SELECT COUNT(*) FROM Employees WHERE Department = 'Mining' AND LGBTQ = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Route (route_id INT, shipment_id INT, distance FLOAT); INSERT INTO Route (route_id, shipment_id, distance) VALUES (1, 1, 100), (2, 2, 200), (3, 3, 150); | What are the route optimization details for the freight forwarding data? | SELECT r.route_id, f.item_name, r.distance FROM Route r JOIN FreightForwarding f ON r.shipment_id = f.shipment_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, city, response_time) VALUES (1, 'San Francisco', 120); | Find the average response time for emergency calls in 'San Francisco' | SELECT AVG(response_time) FROM emergency_calls WHERE city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CyberAttacks (id INT, country VARCHAR(255), date DATE); INSERT INTO CyberAttacks (id, country, date) VALUES (1, 'United States', '2022-01-01'), (2, 'China', '2022-02-01'), (3, 'Russia', '2022-03-01'); | What are the top 5 countries with the most cyber attacks in the last 12 months? | SELECT country, COUNT(*) AS attack_count FROM CyberAttacks WHERE date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) GROUP BY country ORDER BY attack_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE tunnel_info (tunnel_id INT, tunnel_name VARCHAR(50)); CREATE TABLE tunnel_lengths (tunnel_id INT, tunnel_length INT); INSERT INTO tunnel_info (tunnel_id, tunnel_name) VALUES (1, 'Channel Tunnel'), (2, 'Seikan Tunnel'), (3, 'Gotthard Base Tunnel'); INSERT INTO tunnel_lengths (tunnel_id, tunnel_length) VALUES (1, 50495), (2, 53880), (3, 57060); | List all the tunnels along with their lengths from the 'tunnel_info' and 'tunnel_lengths' tables. | SELECT tunnel_info.tunnel_name, tunnel_lengths.tunnel_length FROM tunnel_info INNER JOIN tunnel_lengths ON tunnel_info.tunnel_id = tunnel_lengths.tunnel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, country VARCHAR(50), post_count INT); INSERT INTO users (user_id, country, post_count) VALUES (1, 'Canada', 5), (2, 'USA', 10), (3, 'Canada', 8); | What is the average number of posts per user in Canada in 2021? | SELECT AVG(post_count) FROM users WHERE country = 'Canada' AND YEAR(post_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE HospitalBeds (Country VARCHAR(50), Continent VARCHAR(50), BedsPer1000 FLOAT, Year INT); INSERT INTO HospitalBeds (Country, Continent, BedsPer1000, Year) VALUES ('France', 'Europe', 6.0, 2020), ('Germany', 'Europe', 8.0, 2020), ('Italy', 'Europe', 3.5, 2020); | What is the number of hospital beds per 1000 people in European countries in 2020? | SELECT Country, Continent, BedsPer1000 FROM HospitalBeds WHERE Continent = 'Europe' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Autonomous_Vehicles (Company VARCHAR(50), Country VARCHAR(50), Year_Introduced INT); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('Waymo', 'USA', 2009); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('NuTonomy', 'Singapore', 2016); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('Baidu', 'China', 2015); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('Uber', 'USA', 2016); | Which city has the most autonomous vehicles introduced? | SELECT City, MAX(Year_Introduced) FROM (SELECT Company AS City, Year_Introduced FROM Autonomous_Vehicles WHERE Country = 'USA' GROUP BY Company) AS Autonomous_Vehicles_USA; | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_revenue (tour_id INT, operator_id INT, revenue INT, booking_date DATE); CREATE VIEW sustainable_tours AS SELECT * FROM tour_revenue JOIN tour_operators ON tour_revenue.operator_id = tour_operators.operator_id WHERE tour_operators.sustainable_practices = TRUE; | Show the total revenue generated from sustainable tours in the last 30 days. | SELECT SUM(revenue) FROM sustainable_tours WHERE booking_date >= CURDATE() - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor (donor_id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO donor (donor_id, name, region) VALUES (1, 'Sumit Gupta', 'region_AP'); INSERT INTO donor (donor_id, name, region) VALUES (2, 'Hana Lee', 'region_AP'); CREATE TABLE donation (donation_id INT, donor_id INT, nonprofit_id INT, amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donation (donation_id, donor_id, nonprofit_id, amount, donation_date) VALUES (1, 1, 1, 500, '2021-01-01'); INSERT INTO donation (donation_id, donor_id, nonprofit_id, amount, donation_date) VALUES (2, 2, 1, 400, '2021-02-15'); | Find the number of unique donors for each nonprofit in 'region_AP' who have made donations in the last month. | SELECT n.nonprofit_id, COUNT(DISTINCT d.donor_id) as unique_donors FROM donation d INNER JOIN donor don ON d.donor_id = don.donor_id INNER JOIN nonprofit n ON d.nonprofit_id = n.nonprofit_id WHERE don.region = 'region_AP' AND d.donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY n.nonprofit_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, policyholder_id INT, issue_date DATE); INSERT INTO policies (id, policyholder_id, issue_date) VALUES (1, 1, '2021-02-15'); CREATE TABLE policyholders (id INT, dob DATE); INSERT INTO policyholders (id, dob) VALUES (1, '1990-05-01'); | How many policies were issued in 'Q1 2021' for policyholders aged 30-40? | SELECT COUNT(policies.id) FROM policies JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE policyholders.dob BETWEEN '1981-01-01' AND '1991-01-01' AND policies.issue_date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Communities (community_id INT PRIMARY KEY, community_name VARCHAR(255), region VARCHAR(255), engagement_level INT); INSERT INTO Communities (community_id, community_name, region, engagement_level) VALUES (3, 'Kayan', 'Southeast Asia', 3); CREATE TABLE Arts (id INT PRIMARY KEY, art_form VARCHAR(255), year_emerged INT, location VARCHAR(255), community_engagement INT); INSERT INTO Arts (id, art_form, year_emerged, location, community_engagement) VALUES (3, 'Batik', 1800, 'Indonesia', 200000); | What is the total community engagement in traditional arts for each community in Southeast Asia? | SELECT c.community_name, c.region, SUM(a.community_engagement) AS total_engagement FROM Communities c INNER JOIN Arts a ON c.community_name = a.location GROUP BY c.community_name; | gretelai_synthetic_text_to_sql |
CREATE VIEW wastewater_treatment_plants AS SELECT w.plant_id, w.location, w.capacity, t.cost AS treatment_cost FROM wastewater_treatment w INNER JOIN treatment_costs t ON w.plant_id = t.plant_id; | Update the 'treatment_cost' column in the 'wastewater_treatment_plants' view where the plant_id is 7 | UPDATE wastewater_treatment_plants SET treatment_cost = treatment_cost * 1.1 WHERE plant_id = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, quantity INT); INSERT INTO production VALUES ('Terbium', 2019, 300); INSERT INTO production VALUES ('Terbium', 2020, 350); | Determine the percentage change in global production of Terbium between 2019 and 2020 | SELECT (SUM(CASE WHEN year = 2020 THEN quantity ELSE 0 END) - SUM(CASE WHEN year = 2019 THEN quantity ELSE 0 END)) * 100.0 / SUM(CASE WHEN year = 2019 THEN quantity ELSE 0 END) AS percentage_change FROM production WHERE element = 'Terbium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, hotel_type TEXT, revenue FLOAT); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, views INT); INSERT INTO hotels VALUES (1, 'Hotel D', 'UK', 'Luxury', 1000000); INSERT INTO virtual_tours VALUES (1, 1), (2, 1); | What is the total revenue for luxury hotels in the UK that offer virtual tours? | SELECT SUM(hotels.revenue) FROM hotels INNER JOIN virtual_tours ON hotels.hotel_id = virtual_tours.hotel_id WHERE hotels.country = 'UK' AND hotels.hotel_type = 'Luxury'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_records (vessel_id INT, inspection_date DATE, result VARCHAR(10)); | Show the number of successful inspections for vessels with IDs "MV-789" and "MV-345" from the "safety_records" table. | SELECT COUNT(*) FROM safety_records WHERE vessel_id IN (789, 345) AND result = 'PASS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, salesperson_id INT, garment_id INT, region TEXT, price INT); INSERT INTO sales (id, salesperson_id, garment_id, region, price) VALUES (1, 1, 1, 'Paris', 250), (2, 1, 2, 'London', 120), (3, 2, 3, 'Paris', 180), (4, 2, 4, 'London', 220), (5, 3, 5, 'Berlin', 200), (6, 3, 6, 'Berlin', 160); | What is the total revenue for each salesperson who sold garments with a price above '200'? | SELECT salesperson_id, SUM(price) AS total_revenue FROM sales WHERE price > 200 GROUP BY salesperson_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesign (GameName VARCHAR(100), Genre VARCHAR(50), Developer VARCHAR(100), VR BOOLEAN); INSERT INTO GameDesign VALUES ('Stellar Odyssey', 'Adventure', 'Intergalactic Studios', TRUE); | Insert a new virtual reality game 'Stellar Odyssey' into the GameDesign table. | INSERT INTO GameDesign (GameName, Genre, Developer, VR) VALUES ('Stellar Odyssey', 'Adventure', 'Intergalactic Studios', TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE RiskAssessment (ModelID INT, ModelName VARCHAR(50), PolicyholderID INT, Score INT); INSERT INTO RiskAssessment (ModelID, ModelName, PolicyholderID, Score) VALUES (1, 'Standard', 1, 80), (2, 'Comprehensive', 2, 85), (3, 'Standard', 3, 90), (4, 'Comprehensive', 4, 75), (5, 'Standard', 5, 95), (6, 'Comprehensive', 6, 80); | List all distinct risk assessment models and their average scores | SELECT ModelName, AVG(Score) FROM RiskAssessment GROUP BY ModelName; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_preferences (player_id INT, genre VARCHAR(50)); INSERT INTO player_preferences (player_id, genre) VALUES (1, 'FPS'), (2, 'RPG'), (3, 'FPS'), (4, 'Simulation'), (5, 'RPG'); | What is the total number of players who prefer the 'RPG' genre in the 'player_preferences' table? | SELECT COUNT(*) as rpg_player_count FROM player_preferences WHERE genre = 'RPG'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs_3 (project_id INT, state VARCHAR(20), carbon_offsets FLOAT); INSERT INTO carbon_offset_programs_3 (project_id, state, carbon_offsets) VALUES (1, 'Texas', 1200.5), (2, 'Texas', 1800.75), (3, 'Texas', 2500.33); | Find the total carbon offset by project in Texas | SELECT project_id, SUM(carbon_offsets) FROM carbon_offset_programs_3 WHERE state = 'Texas' GROUP BY project_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(50)); INSERT INTO players VALUES (1, 'John'); INSERT INTO players VALUES (2, 'Jane'); INSERT INTO players VALUES (3, 'Mark'); CREATE TABLE game_sessions (session_id INT, player_id INT, game VARCHAR(50), duration INT); INSERT INTO game_sessions VALUES (1, 1, 'Strategy', 12); INSERT INTO game_sessions VALUES (2, 1, 'Strategy', 15); INSERT INTO game_sessions VALUES (3, 2, 'Strategy', 8); INSERT INTO game_sessions VALUES (4, 2, 'Strategy', 9); INSERT INTO game_sessions VALUES (5, 3, 'RPG', 10); | Which players have played 'Strategy' games for more than 15 hours in total in the 'game_sessions' table? | SELECT p.name FROM players p JOIN game_sessions gs ON p.player_id = gs.player_id WHERE gs.game = 'Strategy' GROUP BY p.player_id HAVING SUM(gs.duration) > 15; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_name TEXT, launch_country TEXT, launch_year INT); INSERT INTO space_missions (mission_name, launch_country, launch_year) VALUES ('Explorer 1', 'United States', 1958); | What is the earliest launch year for a space mission in the space_missions table? | SELECT MIN(launch_year) FROM space_missions; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, region VARCHAR(255), volume FLOAT); INSERT INTO forests VALUES (1, 'Tropical', 123.45); | What is the total volume of timber harvested in tropical regions? | SELECT SUM(volume) FROM forests WHERE region = 'Tropical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tiger_conservation_projects (id INT, project_name VARCHAR(255), location VARCHAR(255)); CREATE TABLE tiger_habitats (id INT, project_id INT, habitat_type VARCHAR(255)); INSERT INTO tiger_conservation_projects (id, project_name, location) VALUES (1, 'Save The Tiger Fund', 'India'), (2, 'Sumatran Tiger Project', 'Indonesia'), (3, 'Bengal Tiger Conservation', 'Bangladesh'); INSERT INTO tiger_habitats (id, project_id, habitat_type) VALUES (1, 1, 'Forest'), (2, 1, 'Grasslands'), (3, 2, 'Rainforest'), (4, 3, 'Mangrove Forests'); | List all tiger conservation projects and their respective habitats | SELECT tiger_conservation_projects.project_name, tiger_habitats.habitat_type FROM tiger_conservation_projects INNER JOIN tiger_habitats ON tiger_conservation_projects.id = tiger_habitats.project_id; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA peace_operations;CREATE TABLE eu_operations (operation_name VARCHAR(50), year INT, organization VARCHAR(50));INSERT INTO peace_operations.eu_operations (operation_name, year, organization) VALUES ('France I', 2021, 'EU'), ('Germany II', 2021, 'EU'), ('Italy III', 2021, 'EU'), ('Spain IV', 2021, 'EU'), ('Poland V', 2021, 'EU'); | What is the count of peacekeeping operations conducted in the year 2021 by countries in the European Union? | SELECT COUNT(*) FROM peace_operations.eu_operations WHERE year = 2021 AND organization = 'EU'; | gretelai_synthetic_text_to_sql |
CREATE TABLE traditional_arts (id INT, art_name VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO traditional_arts (id, art_name, year, country) VALUES (1, 'Ukiyo-e', 1600, 'Japan'), (2, 'Taracea', 1700, 'Mexico'); | What is the average year when traditional arts were first practiced? | SELECT AVG(year) FROM traditional_arts; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mines (MineID INT, MineName VARCHAR(50), Location VARCHAR(50));CREATE TABLE EnvironmentalImpact (ImpactID INT, MineID INT, ImpactType VARCHAR(50), ImpactAmount DECIMAL(10,2), ImpactDate DATE);CREATE TABLE Mitigation (MitigationID INT, ImpactID INT, MitigationType VARCHAR(50), MitigationDate DATE, MitigationCost DECIMAL(10,2));CREATE VIEW MineImpact AS SELECT MineID, SUM(ImpactAmount) AS TotalImpact FROM EnvironmentalImpact GROUP BY MineID ORDER BY TotalImpact DESC FETCH FIRST 1 ROW ONLY;CREATE VIEW MitigationCosts AS SELECT MitigationID, ImpactID, MitigationType, MitigationDate, MitigationCost, (MitigationCost * 1.5) AS TotalCost FROM Mitigation; | What is the daily environmental impact of the mine with the highest total impact, and what is the cost of mitigating that impact? | SELECT M.MineName, EI.ImpactType, EI.ImpactAmount, MC.MitigationType, MC.TotalCost FROM MineImpact MI JOIN Mines M ON MI.MineID = M.MineID JOIN EnvironmentalImpact EI ON MI.MineID = EI.MineID JOIN MitigationCosts MC ON MI.ImpactID = MC.ImpactID FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (id INT PRIMARY KEY, type VARCHAR(255), recycled BOOLEAN); CREATE TABLE garments (id INT PRIMARY KEY, material_id INT, FOREIGN KEY (material_id) REFERENCES materials(id)); CREATE TABLE brands (id INT PRIMARY KEY, country VARCHAR(255), sustainable BOOLEAN); CREATE TABLE sales (id INT PRIMARY KEY, brand_id INT, date DATE, quantity INT, price DECIMAL(5,2)); ALTER TABLE sales ADD FOREIGN KEY (brand_id) REFERENCES brands(id); | Identify the top 3 countries with the highest revenue for garments made from recycled polyester, considering only those brands that have more than 500 sales. | SELECT brands.country, SUM(sales.quantity*sales.price) as total_revenue FROM sales INNER JOIN garments ON sales.garment_id = garments.id INNER JOIN materials ON garments.material_id = materials.id INNER JOIN brands ON sales.brand_id = brands.id WHERE materials.recycled = TRUE AND brands.sustainable = TRUE GROUP BY brands.country HAVING COUNT(DISTINCT sales.id) > 500 ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_timber (company VARCHAR(255), year INT, volume_m3 INT); INSERT INTO company_timber (company, year, volume_m3) VALUES ('Company1', 2010, 1000), ('Company1', 2011, 1200), ('Company1', 2012, 1500), ('Company2', 2010, 1100), ('Company2', 2011, 1300), ('Company2', 2012, 1600), ('Company3', 2010, 1400), ('Company3', 2011, 1700), ('Company3', 2012, 2000); | What is the total volume of timber produced by each company? | SELECT company, SUM(volume_m3) FROM company_timber GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE criminal_cases (case_id INT, court_type VARCHAR(20), year INT); | What is the total number of criminal cases heard in all courts in New York in 2020? | SELECT COUNT(*) FROM criminal_cases WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_wellbeing (athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (2, 'Jane Smith', 28, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (3, 'Jim Brown', 30, 'Football'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (4, 'Lucy Davis', 22, 'Football'); | How many athletes are in the 'athlete_wellbeing' table that play 'Football'? | SELECT COUNT(*) FROM athlete_wellbeing WHERE sport = 'Football'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name TEXT, supplier TEXT); CREATE TABLE shipment_details (id INT, shipment_id INT, product_id INT, units INT); | List all the products that were shipped to a specific city, along with their respective suppliers and the number of units shipped. | SELECT p.name, p.supplier, sd.units FROM products p JOIN shipment_details sd ON p.id = sd.product_id JOIN shipments s ON sd.shipment_id = s.id WHERE s.destination_city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse_Inventory (warehouse_id INT, pallets INT, inventory_date DATE); INSERT INTO Warehouse_Inventory (warehouse_id, pallets, inventory_date) VALUES (1, 200, '2022-01-01'); INSERT INTO Warehouse_Inventory (warehouse_id, pallets, inventory_date) VALUES (1, 300, '2022-02-01'); INSERT INTO Warehouse_Inventory (warehouse_id, pallets, inventory_date) VALUES (2, 400, '2022-01-01'); | How many pallets were stored in each warehouse in France in the month of January 2022? | SELECT warehouse_id, SUM(pallets) FROM Warehouse_Inventory WHERE inventory_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY warehouse_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Road (road_id INT, region VARCHAR(20), resilience_score DECIMAL(3,2)); INSERT INTO Road (road_id, region, resilience_score) VALUES (1, 'South', 60.00), (2, 'North', 70.00); | What is the minimum resilience score for a road in the South? | SELECT MIN(resilience_score) FROM Road WHERE region = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO excavation_sites (site_id, site_name, country) VALUES (1, 'Pompeii', 'Italy'), (2, 'Machu Picchu', 'Peru'), (3, 'Petra', 'Jordan'); CREATE TABLE artifact_inventory (site_id INT, artifact_type VARCHAR(50), quantity INT, height DECIMAL(5,2), width DECIMAL(5,2)); INSERT INTO artifact_inventory (site_id, artifact_type, quantity, height, width) VALUES (1, 'Pottery', 1000, 15.5, 9.2), (1, 'Jewelry', 250, 0.5, 0.5), (1, 'Frescoes', 150, 3.2, 2.1), (2, 'Pottery', 500, 12.8, 8.1), (2, 'Textiles', 200, 0.3, 0.3), (3, 'Sculptures', 75, 50.0, 25.0), (3, 'Pottery', 300, 18.9, 11.3); | What are the average dimensions of pottery artifacts from the excavation sites? | SELECT AVG(a.height) as avg_height, AVG(a.width) as avg_width FROM artifact_inventory a WHERE a.artifact_type = 'Pottery'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft_Launches (id INT, company VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft_Launches (id, company, launch_date) VALUES (1, 'SpaceX', '2015-01-01'), (2, 'United Launch Alliance', '2015-02-11'), (3, 'SpaceX', '2016-03-08'), (4, 'Arianespace', '2016-04-25'); | Which companies have launched the most spacecraft in the Spacecraft_Launches table? | SELECT company, COUNT(*) as total_launches FROM Spacecraft_Launches GROUP BY company ORDER BY total_launches DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Adoption_Statistics (Id INT, Region VARCHAR(255), Year INT, Adoption_Rate FLOAT); INSERT INTO Adoption_Statistics (Id, Region, Year, Adoption_Rate) VALUES (1, 'North America', 2018, 1.5); INSERT INTO Adoption_Statistics (Id, Region, Year, Adoption_Rate) VALUES (2, 'Europe', 2019, 2.1); INSERT INTO Adoption_Statistics (Id, Region, Year, Adoption_Rate) VALUES (3, 'Asia', 2020, 3.2); | How many electric vehicle adoption statistics are available for each region? | SELECT Region, COUNT(*) AS Total_Statistics FROM Adoption_Statistics GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), program_id INT, donation_date DATE); INSERT INTO donations (donation_id, donation_amount, program_id, donation_date) VALUES (4, 25.00, 3, '2022-01-01'), (5, 150.00, 2, '2022-02-01'), (6, 100.00, 1, '2022-03-01'); | What is the total number of donations and total donation amount for each program in 2022? | SELECT program_id, COUNT(donation_id) as total_donations, SUM(donation_amount) as total_donation_amount FROM donations WHERE YEAR(donation_date) = 2022 GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_name TEXT, curator TEXT); | List all artworks and their respective curators. | SELECT artwork_name, curator FROM Artworks; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, sector VARCHAR(20)); INSERT INTO companies (id, sector) VALUES (1, 'technology'), (2, 'finance'), (3, 'technology'), (4, 'healthcare'), (5, 'finance'), (6, 'renewable_energy'); | Which sectors have more than 3 companies? | SELECT sector, COUNT(*) FROM companies GROUP BY sector HAVING COUNT(*) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ratings (country VARCHAR(50), stars FLOAT); INSERT INTO hotel_ratings (country, stars) VALUES ('Japan', 4.2), ('Malaysia', 3.8), ('Thailand', 4.0); | What is the average hotel star rating for hotels in Japan, Malaysia, and Thailand? | SELECT AVG(stars) FROM hotel_ratings WHERE country IN ('Japan', 'Malaysia', 'Thailand'); | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (author_id INT, native_language VARCHAR(50), country VARCHAR(50)); CREATE TABLE articles (article_id INT, author_id INT, content_type VARCHAR(20)); INSERT INTO authors VALUES (1, 'Cree', 'Canada'); INSERT INTO articles VALUES (1, 1, 'culture'); | What is the number of articles written by native speakers of indigenous languages in North America? | SELECT COUNT(*) FROM authors INNER JOIN articles ON authors.author_id = articles.author_id WHERE authors.native_language IN ('Cree', 'Navajo', 'Inuit') AND country IN ('Canada', 'United States'); | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_id INT, state_name VARCHAR(255)); CREATE TABLE police_services (service_id INT, service_name VARCHAR(255), state_id INT, budget INT); CREATE TABLE fire_services (service_id INT, service_name VARCHAR(255), state_id INT, budget INT); | Calculate the percentage of total budget allocated to police and fire services, per state. | SELECT s.state_name, ROUND(100 * SUM(ps.budget) / (SELECT SUM(ps2.budget) FROM police_services ps2 WHERE ps2.state_id = s.state_id) , 2) as police_budget_percentage, ROUND(100 * SUM(fs.budget) / (SELECT SUM(fs2.budget) FROM fire_services fs2 WHERE fs2.state_id = s.state_id) , 2) as fire_budget_percentage FROM states s LEFT JOIN police_services ps ON s.state_id = ps.state_id LEFT JOIN fire_services fs ON s.state_id = fs.state_id GROUP BY s.state_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (program_id INT, program_type VARCHAR(50), start_date DATE); INSERT INTO Programs (program_id, program_type, start_date) VALUES (1, 'Workshop', '2018-01-01'), (2, 'Lecture', '2017-06-15'), (3, 'Performance', '2016-09-30'); CREATE TABLE Attendance (attendance_id INT, program_id INT, attendee_count INT, attend_date DATE); INSERT INTO Attendance (attendance_id, program_id, attendee_count, attend_date) VALUES (1, 1, 50, '2022-02-03'), (2, 1, 75, '2022-06-12'), (3, 2, 100, '2022-12-25'), (4, 3, 150, '2022-05-05'); | What is the total number of attendees at each program type, with data from the past year? | SELECT p.program_type, SUM(a.attendee_count) AS total_attendees FROM Programs p JOIN Attendance a ON p.program_id = a.program_id WHERE a.attend_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY p.program_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Race varchar(50), Ethnicity varchar(50)); | What is the racial and ethnic diversity of employees in each department, as a percentage of the total number of employees? | SELECT d.Department, 100.0 * COUNT(DISTINCT e.EmployeeID) / (SELECT COUNT(DISTINCT EmployeeID) FROM Employees) as Percentage FROM Employees e JOIN (VALUES ('IT'), ('HR'), ('Finance')) as d(Department) ON e.Department = d.Department GROUP BY d.Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (customer_id INT, transaction_amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions (customer_id, transaction_amount, transaction_date) VALUES (1, 150.00, '2021-01-01'), (1, 200.00, '2021-01-10'), (2, 50.00, '2021-01-05'), (2, 75.00, '2021-02-01'), (3, 300.00, '2021-03-01'); | What is the average transaction amount for customers who have made at least 5 transactions in the past year, sorted in descending order? | SELECT AVG(transaction_amount) FROM transactions WHERE customer_id IN (SELECT customer_id FROM transactions GROUP BY customer_id HAVING COUNT(*) >= 5) ORDER BY AVG(transaction_amount) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, name VARCHAR(255), start_date DATE, end_date DATE, primary_country VARCHAR(255), PRIMARY KEY(id)); INSERT INTO space_missions (id, name, start_date, end_date, primary_country) VALUES (1, 'Apollo 11', '1969-07-16', '1969-07-24', 'USA'), (2, 'Soyuz T-15', '1986-03-13', '1986-05-26', 'USSR'); CREATE TABLE mission_partners (id INT, mission_id INT, partner_country VARCHAR(255), PRIMARY KEY(id), FOREIGN KEY (mission_id) REFERENCES space_missions(id)); INSERT INTO mission_partners (id, mission_id, partner_country) VALUES (1, 1, 'Canada'), (2, 2, 'France'); | List all space missions that include international partners, along with the mission start and end dates. | SELECT space_missions.name, space_missions.start_date, space_missions.end_date FROM space_missions INNER JOIN mission_partners ON space_missions.id = mission_partners.mission_id WHERE mission_partners.partner_country IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees(id INT, name VARCHAR(50), department VARCHAR(50), position VARCHAR(50), salary FLOAT, full_time BOOLEAN, gender VARCHAR(50), start_date DATE); | How many employees have been working in the Mining department for more than 5 years? | SELECT COUNT(*) FROM Employees WHERE department = 'Mining' AND start_date <= DATEADD(year, -5, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE CosmeticsSales (productID INT, productName VARCHAR(50), category VARCHAR(50), country VARCHAR(50), isHalal BOOLEAN, price DECIMAL(5,2), quantity INT); INSERT INTO CosmeticsSales (productID, productName, category, country, isHalal, price, quantity) VALUES (1, 'Lipstick', 'Cosmetics', 'UAE', TRUE, 15.99, 50); | What is the total revenue of halal cosmetics sold in the UAE in 2021? | SELECT SUM(price * quantity) FROM CosmeticsSales WHERE country = 'UAE' AND isHalal = TRUE AND YEAR(saleDate) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE flights (flight_id INT, airline VARCHAR(255), flight_date DATE, safety_score INT); INSERT INTO flights (flight_id, airline, flight_date, safety_score) VALUES (1, 'SpaceAirlines', '2020-02-03', 95), (2, 'SpaceAirlines', '2020-06-15', 92), (3, 'SpaceAirlines', '2019-11-18', 97), (4, 'SpaceAirlines', '2021-03-25', 93), (5, 'SpaceAirlines', '2018-09-01', 96); | What is the safety score trend for flights operated by SpaceAirlines in the last 2 years? | SELECT flight_date, safety_score, ROW_NUMBER() OVER (ORDER BY flight_date) as rank FROM flights WHERE airline = 'SpaceAirlines' AND flight_date >= DATEADD(year, -2, CURRENT_DATE) ORDER BY flight_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists policyholders (policyholder_id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(10), policy_type VARCHAR(50), premium DECIMAL(10,2)); | Drop the 'high_risk_policyholders' view | DROP VIEW IF EXISTS high_risk_policyholders; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_types (vehicle_type_id INT, vehicle_type TEXT);CREATE TABLE fares (fare_id INT, vehicle_type_id INT, fare_amount DECIMAL, fare_collection_date DATE); INSERT INTO vehicle_types (vehicle_type_id, vehicle_type) VALUES (1001, 'Bus'), (1002, 'Tram'), (2001, 'Subway'); INSERT INTO fares (fare_id, vehicle_type_id, fare_amount, fare_collection_date) VALUES (1, 1001, 5.00, '2022-07-20'), (2, 1001, 5.00, '2022-07-20'), (3, 1002, 3.50, '2022-07-20'), (4, 1002, 3.50, '2022-07-20'), (5, 2001, 7.00, '2022-07-20'); | What is the total fare collected for each vehicle type on July 20, 2022? | SELECT vt.vehicle_type, SUM(f.fare_amount) as total_fare FROM vehicle_types vt JOIN fares f ON vt.vehicle_type_id = f.vehicle_type_id WHERE f.fare_collection_date = '2022-07-20' GROUP BY vt.vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (tx_id INT, contract_name VARCHAR(255), asset_name VARCHAR(255), tx_value DECIMAL(10,2)); INSERT INTO Transactions (tx_id, contract_name, asset_name, tx_value) VALUES (1, 'SmartContract1', 'ETH', 100.50); INSERT INTO Transactions (tx_id, contract_name, asset_name, tx_value) VALUES (2, 'SmartContract1', 'BTC', 200.75); | What was the total value of transactions for 'SmartContract1' that involved the 'ETH' digital asset? | SELECT SUM(tx_value) FROM Transactions WHERE contract_name = 'SmartContract1' AND asset_name = 'ETH'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_agencies (name VARCHAR(50), country VARCHAR(50), launches INTEGER); INSERT INTO space_agencies (name, country, launches) VALUES ('NASA', 'USA', 228), ('ESA', 'Europe', 105); | What is the total number of spacecrafts launched by NASA and ESA? | SELECT SUM(launches) FROM space_agencies WHERE name IN ('NASA', 'ESA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (id INT, name TEXT, speed DECIMAL(5,2), arrived_date DATE, country TEXT); INSERT INTO vessel_performance (id, name, speed, arrived_date, country) VALUES (1, 'Vessel A', 9.5, '2022-02-05', 'Japan'), (2, 'Vessel B', 12.8, '2022-02-10', 'Japan'), (3, 'Vessel C', 11.6, '2022-02-18', 'Japan'); | How many vessels arrived in Japan in February 2022 with a speed less than or equal to 10 knots? | SELECT COUNT(*) FROM vessel_performance WHERE arrived_date BETWEEN '2022-02-01' AND '2022-02-28' AND country = 'Japan' AND speed <= 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_data (habitat_id INT, habitat_type VARCHAR(255), region VARCHAR(255), protection_level VARCHAR(255)); INSERT INTO habitat_data (habitat_id, habitat_type, region, protection_level) VALUES (1, 'Forest', 'North', 'Full'), (2, 'Forest', 'North', 'Partial'), (3, 'Savannah', 'South', 'Full'), (4, 'Savannah', 'South', 'Partial'), (5, 'Wetlands', 'East', 'Full'), (6, 'Wetlands', 'East', 'Full'), (7, 'Mountains', 'West', 'Partial'), (8, 'Mountains', 'West', 'Partial'); | What is the percentage of habitats that are fully protected, by region? | SELECT region, (COUNT(CASE WHEN protection_level = 'Full' THEN 1 END)::float/COUNT(habitat_id))*100 AS protection_percentage FROM habitat_data GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE tunnels (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE tunnel_construction_costs (tunnel_id INT, cost DECIMAL(10, 2)); | Which tunnels are located in 'Texas' and their respective construction costs from the 'tunnels' and 'tunnel_construction_costs' tables? | SELECT t.name, tcc.cost as construction_cost FROM tunnels t INNER JOIN tunnel_construction_costs tcc ON t.id = tcc.tunnel_id WHERE t.location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(255), city VARCHAR(255), capacity INT, certified BOOLEAN); INSERT INTO hotels (hotel_id, name, city, capacity, certified) VALUES (1, 'EcoHotel NY', 'New York', 150, TRUE), (2, 'GreenHotel NY', 'New York', 200, FALSE); | List the names and capacities of hotels with sustainability certifications in New York. | SELECT name, capacity FROM hotels WHERE city = 'New York' AND certified = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (site_id INT, site_name TEXT); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type TEXT); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'), (4, 'Site D'), (5, 'Site E'); INSERT INTO artifacts (artifact_id, site_id, artifact_type) VALUES (1, 1, 'wooden'), (2, 1, 'stone'), (3, 2, 'metal'), (4, 3, 'wooden'), (5, 3, 'pottery'), (6, 4, 'stone'), (7, 5, 'stone'), (8, 5, 'ceramic'), (9, 5, 'metal'), (10, 5, 'metal'), (11, 6, 'metal'), (12, 6, 'metal'), (13, 6, 'metal'), (14, 7, 'stone'), (15, 7, 'pottery'); | Find sites with more than 3 types of metal artifacts. | SELECT e.site_name FROM excavation_sites e JOIN artifacts a ON e.site_id = a.site_id WHERE a.artifact_type LIKE '%metal' GROUP BY e.site_id HAVING COUNT(DISTINCT a.artifact_type) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_projects (project_id INT, country VARCHAR(50), capacity_mw FLOAT); INSERT INTO wind_projects (project_id, country, capacity_mw) VALUES (1, 'Germany', 50.5), (2, 'France', 67.3), (3, 'Spain', 45.8), (4, 'Germany', 72.1), (5, 'France', 84.6), (6, 'Spain', 90.2), (7, 'Germany', 36.9), (8, 'France', 42.3), (9, 'Spain', 30.6); | What is the total installed capacity (in MW) of wind power projects in Germany, France, and Spain? | SELECT SUM(capacity_mw) FROM wind_projects WHERE country IN ('Germany', 'France', 'Spain'); | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_data (id INT, sample_id VARCHAR(20), gene_sequence TEXT); CREATE TABLE bioprocess_data (id INT, sample_id VARCHAR(20), pressure FLOAT); INSERT INTO genetic_data (id, sample_id, gene_sequence) VALUES (1, 'GD001', 'ATGCGA...'), (2, 'GD002', 'ATGCGC...'); INSERT INTO bioprocess_data (id, sample_id, pressure) VALUES (1, 'GD001', 1.5), (2, 'GD002', 2.3); | Update gene sequences if the related bioprocess engineering data has a pressure value above 2. | UPDATE genetic_data gd SET gd.gene_sequence = 'ATGCGT...' WHERE EXISTS (SELECT 1 FROM bioprocess_data bd WHERE bd.sample_id = gd.sample_id AND bd.pressure > 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_teams (team_id INT PRIMARY KEY, team_name VARCHAR(255), conference VARCHAR(50), three_point_fg_made INT, three_point_fg_attempted INT); | What is the average number of three-point field goals made per game by each team in the basketball_teams table, grouped by their conference, and only for teams who have made more than 500 three-point field goals in total? | SELECT conference, AVG(three_point_fg_made * 1.0 / three_point_fg_attempted) as avg_three_point_fg_percentage FROM basketball_teams GROUP BY conference HAVING SUM(three_point_fg_made) > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE neodymium_prices (year INT, country TEXT, price DECIMAL(10, 2)); INSERT INTO neodymium_prices (year, country, price) VALUES (2018, 'China', 85.2), (2019, 'China', 86.4), (2020, 'China', 87.8), (2021, 'China', 89.2); | Find the minimum market price of neodymium in China since 2018. | SELECT MIN(price) FROM neodymium_prices WHERE country = 'China' AND year >= 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE educators(id INT, age INT, domain VARCHAR(255)); INSERT INTO educators VALUES (1, 45, 'education'), (2, 30, 'education'), (3, 50, 'technology'), (4, 42, 'education'), (5, 48, 'education'); | What is the average age of educators in the education domain? | SELECT AVG(age) FROM educators WHERE domain = 'education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name TEXT, is_organic BOOLEAN, price DECIMAL, source_country TEXT); INSERT INTO products (product_id, name, is_organic, price, source_country) VALUES (1, 'Lipstick', TRUE, 29.99, 'South Korea'); INSERT INTO products (product_id, name, is_organic, price, source_country) VALUES (2, 'Eye Shadow', TRUE, 26.49, 'South Korea'); | What is the sum of the prices of all organic cosmetics sourced from South Korea? | SELECT SUM(price) FROM products WHERE is_organic = TRUE AND source_country = 'South Korea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name TEXT, habitat TEXT); INSERT INTO marine_species (id, name, habitat) VALUES (1, 'Queen Angelfish', 'Caribbean Sea'), (2, 'Green Sea Turtle', 'Caribbean Sea'); | How many marine species are found in the Caribbean Sea? | SELECT COUNT(*) FROM marine_species WHERE habitat = 'Caribbean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_compounds (id INT, compound VARCHAR(50), environmental_impact_score FLOAT); INSERT INTO chemical_compounds (id, compound, environmental_impact_score) VALUES (1, 'CompoundX', 78.2), (2, 'CompoundY', 65.4), (3, 'CompoundZ', 89.1); | List all unique chemical compounds and their corresponding environmental impact scores, sorted by scores in descending order. | SELECT compound, environmental_impact_score FROM chemical_compounds ORDER BY environmental_impact_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (id INT, vessel_id INT, cargo_weight INT, trip_date DATE); INSERT INTO trips VALUES (1, 1, 500, '2021-06-01'), (2, 1, 550, '2021-06-10'), (3, 2, 600, '2021-05-15'); | What is the total cargo weight for each vessel on its last trip? | SELECT vessel_id, MAX(cargo_weight) AS last_trip_cargo_weight FROM trips GROUP BY vessel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, transaction_date DATE, country VARCHAR(255), amount DECIMAL(10,2)); INSERT INTO transactions (id, transaction_date, country, amount) VALUES (1, '2022-01-01', 'USA', 100.00), (2, '2022-01-02', 'Canada', 200.00), (3, '2022-01-03', 'USA', 300.00), (4, '2022-01-04', 'Mexico', 400.00); | What are the names and transaction dates of all transactions that occurred in the United States or Mexico, in January 2022? | SELECT country, transaction_date FROM transactions WHERE (country = 'USA' OR country = 'Mexico') AND transaction_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255), City varchar(255)); CREATE TABLE Inspections (InspectionID int, RestaurantID int, ViolationCount int, InspectionScore int, InspectionDate date); | How many food safety inspections were conducted in each city during 2022, and what was the average inspection score? | SELECT R.City, YEAR(I.InspectionDate) as Year, COUNT(*) as TotalInspections, AVG(I.InspectionScore) as AverageInspectionScore FROM Restaurants R INNER JOIN Inspections I ON R.RestaurantID = I.RestaurantID WHERE YEAR(I.InspectionDate) = 2022 GROUP BY R.City; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_apps_transactions (app_name VARCHAR(20), id INT); INSERT INTO creative_apps_transactions (app_name, id) VALUES ('ArtBot', 1); INSERT INTO creative_apps_transactions (app_name, id) VALUES ('MusicGen', 2); INSERT INTO creative_apps_transactions (app_name, id) VALUES ('StoryGen', 3); | List the AI creative applications with transaction counts greater than or equal to the average number of transactions for all AI creative applications. | SELECT app_name FROM creative_apps_transactions WHERE id >= (SELECT AVG(id) FROM creative_apps_transactions); | gretelai_synthetic_text_to_sql |
CREATE TABLE avg_square (unit_id INT, area VARCHAR(20), studio BOOLEAN, square_footage FLOAT); INSERT INTO avg_square (unit_id, area, studio, square_footage) VALUES (1, 'all', TRUE, 400); | What is the average square footage of studio units across all areas? | SELECT AVG(square_footage) FROM avg_square WHERE studio = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, age INT, country VARCHAR(20)); INSERT INTO players (id, age, country) VALUES (1, 22, 'JP'), (2, 25, 'KR'), (3, 30, 'US'), (4, 19, 'JP'); | What is the distribution of player ages playing esports games in Japan and South Korea? | SELECT country, AVG(age) AS avg_age FROM players WHERE country IN ('JP', 'KR') AND EXISTS (SELECT 1 FROM esports_games WHERE players.id = esports_games.player_id) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (id INT, name VARCHAR(50), professional_development_hours INT, years_of_experience INT); INSERT INTO teachers (id, name, professional_development_hours, years_of_experience) VALUES (1, 'Jane Doe', 12, 5); | Teachers with professional development hours between 10 and 15 | SELECT name FROM teachers WHERE professional_development_hours BETWEEN 10 AND 15; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT, continent TEXT, coastline_km FLOAT); INSERT INTO countries (id, name, continent, coastline_km) VALUES (1, 'Canada', 'North America', 202089), (2, 'Norway', 'Europe', 25322), (3, 'South Africa', 'Africa', 2798), (4, 'Australia', 'Australia', 25760), (5, 'Chile', 'South America', 6435); | Which countries have the longest coastlines in their respective continents? | SELECT name, continent FROM countries WHERE coastline_km = (SELECT MAX(coastline_km) FROM countries WHERE countries.continent = countries.continent); | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Customers VALUES (1, 'John Smith', 'USA'), (2, 'Jane Doe', 'Canada'); CREATE TABLE Orders (OrderID INT, CustomerID INT, OrderValue DECIMAL(10,2)); INSERT INTO Orders VALUES (1, 1, 50.00), (2, 1, 75.00), (3, 2, 100.00); | What is the average order value per customer by country? | SELECT Country, AVG(OrderValue) as AvgOrderValue FROM Orders o JOIN Customers c ON o.CustomerID = c.CustomerID GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT, year INT, budget INT); | Find the total budget spent on defense diplomacy in the last 5 years. | SELECT SUM(budget) FROM defense_diplomacy WHERE year BETWEEN (SELECT EXTRACT(YEAR FROM NOW()) - 5) AND EXTRACT(YEAR FROM NOW()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Sites (SiteID int, SiteName text, Location text); CREATE TABLE Artifacts (ArtifactID int, ArtifactName text, SiteID int, Material text); | Which excavation sites have produced artifacts made of more than one material? | SELECT DISTINCT SiteName FROM Sites INNER JOIN Artifacts ON Sites.SiteID = Artifacts.SiteID GROUP BY SiteName, Material HAVING COUNT(DISTINCT Material) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_memberships (union_id INT, worker_id INT, union_name VARCHAR(50), join_date DATE); INSERT INTO union_memberships (union_id, worker_id, union_name, join_date) VALUES (1, 1, 'United Steelworkers', '2021-01-10'), (1, 2, 'United Steelworkers', '2022-01-05'), (2, 3, 'Teamsters', '2021-08-10'), (2, 4, 'Teamsters', '2022-02-15'), (3, 5, 'Service Employees International Union', '2021-04-01'), (3, 6, 'Service Employees International Union', '2022-04-12'), (4, 7, 'United Auto Workers', '2021-09-15'), (4, 8, 'United Auto Workers', '2022-09-10'), (1, 9, 'United Steelworkers', '2022-09-20'); | Delete all records with union_name as 'United Steelworkers' from the 'union_memberships' table | DELETE FROM union_memberships WHERE union_name = 'United Steelworkers'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); CREATE TABLE DonationEvents (EventID INT PRIMARY KEY, EventName VARCHAR(100), EventType VARCHAR(100), DonationID INT, EventLocation VARCHAR(100), EventDate DATE, FOREIGN KEY (DonationID) REFERENCES Donors(DonorID)); | How many 'Education' events were held in 'Toronto' and 'Vancouver' between 2020-01-01 and 2020-12-31? | SELECT COUNT(*) as NumberOfEvents FROM DonationEvents e WHERE e.EventType = 'Education' AND e.EventLocation IN ('Toronto', 'Vancouver') AND e.EventDate BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patents (country VARCHAR(30), patent_count INT); INSERT INTO patents (country, patent_count) VALUES ('European Union', 1200), ('European Union', 1300), ('UK', 800), ('UK', 850); | How many renewable energy patents were granted in the European Union and the UK? | SELECT SUM(patent_count) FROM patents WHERE country IN ('European Union', 'UK'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rehabilitation_center (animal_id INT, admission_date DATE); INSERT INTO rehabilitation_center (animal_id, admission_date) VALUES (1, '2021-01-05'), (2, '2021-01-12'), (3, '2021-02-18'), (4, '2021-03-05'), (5, '2021-03-25'); | What is the number of animals admitted to the rehabilitation center per month? | SELECT EXTRACT(MONTH FROM admission_date) AS month, COUNT(*) FROM rehabilitation_center GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE); INSERT INTO project (id, name, location, start_date) VALUES (1, 'Green Build', 'NYC', '2020-01-01'), (2, 'Solar Tower', 'LA', '2019-12-15'), (3, 'Eco House', 'Austin', '2020-03-01'); CREATE TABLE permit (id INT, project_id INT, type VARCHAR(50), issued_date DATE); INSERT INTO permit (id, project_id, type, issued_date) VALUES (1, 1, 'Building', '2019-12-01'), (2, 1, 'Electrical', '2020-01-05'), (3, 2, 'Building', '2019-11-30'), (4, 2, 'Plumbing', '2019-12-10'), (5, 3, 'Building', '2020-02-15'), (6, 4, 'Building', '2021-01-10'), (7, 4, 'Electrical', '2021-01-15'); CREATE TABLE sustainable (project_id INT, solar_panels BOOLEAN, wind_turbines BOOLEAN, green_roof BOOLEAN); INSERT INTO sustainable (project_id, solar_panels, wind_turbines, green_roof) VALUES (1, TRUE, TRUE, TRUE), (2, TRUE, TRUE, FALSE), (3, FALSE, FALSE, TRUE), (4, FALSE, TRUE, FALSE); | What is the latest permit issued date for projects in 'NYC' with wind turbines? | SELECT MAX(p.issued_date) FROM permit p JOIN project pr ON p.project_id = pr.id JOIN sustainable s ON pr.id = s.project_id WHERE pr.location = 'NYC' AND s.wind_turbines = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50), Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Department, Position, Salary) VALUES (1, 'John Doe', 'IT', 'Developer', 75000.00), (2, 'Jane Smith', 'IT', 'Developer', 80000.00), (3, 'Alice Johnson', 'Marketing', 'Marketing Specialist', 60000.00), (4, 'Bob Brown', 'HR', 'HR Specialist', 65000.00); | How many employees are there in each department? | SELECT Department, COUNT(*) FROM Employees GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, name VARCHAR(255), address VARCHAR(255), city VARCHAR(255), sustainable_urbanism_certified BOOLEAN, sold_date DATE); CREATE TABLE co_owners (property_id INT, owner_name VARCHAR(255)); INSERT INTO properties (property_id, name, address, city, sustainable_urbanism_certified, sold_date) VALUES (1, 'Green Living', '123 Main St', 'New York', true, '2022-03-15'), (2, 'Eco Haven', '456 Oak St', 'New York', false, '2022-01-01'), (3, 'Sustainable Suites', '789 Pine St', 'New York', true, NULL); INSERT INTO co_owners (property_id, owner_name) VALUES (1, 'Alice'), (1, 'Bob'), (2, 'Charlie'), (3, 'Dave'); | Identify co-owned properties in New York City with sustainable urbanism certifications that were sold in the past six months, and list their names, addresses, and the names of their co-owners. | SELECT p.name, p.address, co.owner_name FROM properties p JOIN co_owners co ON p.property_id = co.property_id WHERE p.city = 'New York' AND p.sustainable_urbanism_certified = true AND p.sold_date >= DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (id INT, business_type VARCHAR(20), country VARCHAR(50), price DECIMAL(5,2)); INSERT INTO sustainable_materials (id, business_type, country, price) VALUES (1, 'women-owned', 'United States', 15.99), (2, 'cooperative', 'Brazil', 12.50); | What is the average price of sustainable materials sourced from women-owned businesses in the United States? | SELECT AVG(price) FROM sustainable_materials WHERE business_type = 'women-owned' AND country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE BridgesCanada (BridgeID INT, Name VARCHAR(255), Province VARCHAR(255), MaintenanceSchedule VARCHAR(255), MaintenanceCost FLOAT, Type VARCHAR(255)); INSERT INTO BridgesCanada VALUES (1, 'Bridge A', 'Quebec', 'Quarterly', 5000, 'Suspension'); INSERT INTO BridgesCanada VALUES (2, 'Bridge B', 'Ontario', 'Semi-Annually', 7500, 'Beam'); INSERT INTO BridgesCanada VALUES (3, 'Bridge C', 'British Columbia', 'Annually', 3000, 'Arch'); | Identify the number of bridges, their respective maintenance schedules, and the total maintenance cost in each province of Canada, along with their respective bridge types (e.g., suspension, beam, arch). | SELECT Province, Type, COUNT(*) as BridgeCount, MaintenanceSchedule, SUM(MaintenanceCost) as TotalCost FROM BridgesCanada GROUP BY Province, Type, MaintenanceSchedule; | gretelai_synthetic_text_to_sql |
CREATE TABLE neighborhoods (nid INT, name TEXT);CREATE TABLE crimes (cid INT, nid INT, type TEXT, date TEXT); | How many crimes were committed by each type in each neighborhood last year? | SELECT neighborhoods.name, crimes.type, COUNT(crimes.cid) FROM neighborhoods INNER JOIN crimes ON neighborhoods.nid = crimes.nid WHERE crimes.date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY neighborhoods.name, crimes.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_count (id INT, country VARCHAR(255), program VARCHAR(255)); INSERT INTO restorative_justice_count (id, country, program) VALUES (1, 'US', 'Victim Offender Mediation'), (2, 'Canada', 'Restorative Circles'); | Find the total number of restorative justice programs in the US and Canada, grouped by their respective countries. | SELECT country, COUNT(*) AS program_count FROM restorative_justice_count GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE citizen_feedback (id INT, feedback VARCHAR(255), delete_date DATE); INSERT INTO citizen_feedback (id, feedback, delete_date) VALUES (1, 'Feedback 1', '2022-05-01'), (2, 'Feedback 2', '2022-05-05'), (3, 'Feedback 3', '2022-05-07'); | Find the number of citizen feedback records deleted in the last month, grouped by the day they were deleted. | SELECT DATE(delete_date) as delete_day, COUNT(*) as records_deleted FROM citizen_feedback WHERE delete_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY delete_day | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_projects (id INT, name VARCHAR(50), region VARCHAR(50), funding FLOAT); INSERT INTO autonomous_projects VALUES (1, 'Project Alpha', 'North America', 5000000); INSERT INTO autonomous_projects VALUES (2, 'Project Beta', 'Europe', 7000000); | List all the autonomous driving research projects | SELECT * FROM autonomous_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtAuctionSales (SaleID INT PRIMARY KEY, PaintingID INT, SalePrice DECIMAL(10, 2), SaleYear INT, FOREIGN KEY (PaintingID) REFERENCES Paintings(PaintingID)); INSERT INTO ArtAuctionSales (SaleID, PaintingID, SalePrice, SaleYear) VALUES (1, 1, 100000.00, 2022), (2, 2, 200000.00, 2022); | What is the name of the painting sold for the highest price? | SELECT PaintingName FROM Paintings p JOIN ArtAuctionSales a ON p.PaintingID = a.PaintingID WHERE a.SalePrice = (SELECT MAX(SalePrice) FROM ArtAuctionSales); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists mining_schema;CREATE TABLE mining_schema.mining_company (id INT PRIMARY KEY, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), salary FLOAT);INSERT INTO mining_schema.mining_company (id, name, position, department, salary) VALUES (1, 'John Doe', 'Engineer', 'Mining', 75000.0), (2, 'Jane Smith', 'Geologist', 'Survey', 65000.0); | What is the total number of employees in the 'mining_company'? | SELECT COUNT(*) FROM mining_schema.mining_company; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(50), region VARCHAR(50), common_disease VARCHAR(50)); INSERT INTO marine_species (id, name, region, common_disease) VALUES (1, 'Clownfish', 'Pacific Ocean', 'Skin Disease'); CREATE TABLE diseases (id INT, name VARCHAR(50)); | What are the common diseases among different marine species in the Pacific Ocean? | SELECT marine_species.name, marine_species.common_disease FROM marine_species INNER JOIN diseases ON marine_species.common_disease = diseases.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity(city VARCHAR(20), capacity INT, year INT); INSERT INTO landfill_capacity VALUES('Mumbai', 5000000, 2021), ('Delhi', 6000000, 2021), ('Mumbai', 4500000, 2020); | What is the landfill capacity in Mumbai as of 2021? | SELECT capacity FROM landfill_capacity WHERE city = 'Mumbai' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE household_water_consumption (id INT, state VARCHAR(20), water_consumption FLOAT); INSERT INTO household_water_consumption (id, state, water_consumption) VALUES (1, 'California', 1200), (2, 'Texas', 1500), (3, 'California', 1100), (4, 'Texas', 1400); | What is the difference in the average water consumption per household between the states of California and Texas? | SELECT AVG(CASE WHEN state = 'California' THEN water_consumption END) - AVG(CASE WHEN state = 'Texas' THEN water_consumption END) FROM household_water_consumption | gretelai_synthetic_text_to_sql |
CREATE TABLE product_innovation (innovation_id int,innovation_date date,innovation_description varchar(255),impact_level varchar(50)); | Delete records in the "product_innovation" table where the "innovation_date" is after December 31, 2022. | DELETE FROM product_innovation WHERE innovation_date > '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); | Show the names and locations of restorative justice programs that have not ended yet | SELECT name, location FROM programs WHERE type = 'Restorative Justice' AND end_date > CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_category VARCHAR(255), sale_date DATE, revenue NUMERIC(10, 2)); INSERT INTO sales (product_category, sale_date, revenue) VALUES ('Skincare', '2022-01-01', 500), ('Makeup', '2022-01-03', 300), ('Skincare', '2022-01-05', 700), ('Haircare', '2022-01-07', 600), ('Makeup', '2022-02-01', 400); | What is the total sales revenue for each product category in Q1 2022? | SELECT product_category, SUM(revenue) as total_revenue FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY product_category; | 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.