context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE if not exists Intersections(location CHAR(10), ev_adoption FLOAT, transit_usage INT); INSERT INTO Intersections(location, ev_adoption, transit_usage) VALUES ('Chicago_1st', 0.25, 1200), ('Chicago_1st', 0.25, 1250), ('Chicago_2nd', 0.31, 1500), ('Chicago_2nd', 0.31, 1450), ('Seattle_1st', 0.28, 800), ('Seat... | Identify intersections with high rates of electric vehicle adoption and public transit usage in Chicago and Seattle. | SELECT location, ev_adoption, transit_usage FROM Intersections WHERE location IN ('Chicago_1st', 'Chicago_2nd', 'Seattle_1st', 'Seattle_2nd') AND ev_adoption > 0.25 AND transit_usage > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (country VARCHAR(20), consumption DECIMAL(10,2)); INSERT INTO renewable_energy (country, consumption) VALUES ('Australia', 120.50), ('Australia', 125.00), ('Japan', 170.00), ('Japan', 175.50); | Find the total renewable energy consumption in Australia and Japan? | SELECT SUM(consumption) FROM renewable_energy WHERE country IN ('Australia', 'Japan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_agency (id INT, name VARCHAR(255), director VARCHAR(255)); CREATE TABLE operation (id INT, agency_id INT, name VARCHAR(255), country VARCHAR(255), success_level INT); INSERT INTO intelligence_agency (id, name, director) VALUES (1, 'CIA', 'James Brown'); INSERT INTO operation (id, agency_id, na... | Who are the top three intelligence agency directors with the most successful operations, and what are the names of these operations, including the countries where they took place? | SELECT i.director, o.name, o.country FROM operation o JOIN intelligence_agency i ON o.agency_id = i.id ORDER BY o.success_level DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT); INSERT INTO donors (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'USA'), (4, 'David', 'UK'); | Find the difference in the number of donors between the US and Canada. | SELECT COUNT(*) FILTER (WHERE country = 'USA') - COUNT(*) FILTER (WHERE country = 'Canada') FROM donors; | gretelai_synthetic_text_to_sql |
CREATE TABLE IF NOT EXISTS smart_cities ( project_id INT, project_name VARCHAR(255), budget FLOAT, PRIMARY KEY (project_id)); INSERT INTO smart_cities (project_id, project_name, budget) VALUES (1, 'Intelligent Lighting', 500000), (2, 'Smart Waste Management', 750000), (3, 'E-Governance Services', 600000); | Which smart city projects have a budget greater than $600,000? | SELECT * FROM smart_cities WHERE budget > 600000; | gretelai_synthetic_text_to_sql |
CREATE TABLE offsets (id INT, region VARCHAR(20), project VARCHAR(20), offset INT); INSERT INTO offsets (id, region, project, offset) VALUES (1, 'Eastern', 'Wind Farm', 5000); INSERT INTO offsets (id, region, project, offset) VALUES (2, 'Western', 'Solar Farm', 7000); | What is the maximum carbon offset of renewable energy projects in the Eastern region? | SELECT MAX(offset) FROM offsets WHERE region = 'Eastern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Aircraft (aircraft_model VARCHAR(50), manufacturer VARCHAR(50), cost FLOAT); INSERT INTO Aircraft (aircraft_model, manufacturer, cost) VALUES ('ModelA', 'Manufacturer1', 1000), ('ModelB', 'Manufacturer1', 2000), ('ModelC', 'Manufacturer2', 1500); | What is the average cost of an aircraft manufactured by Manufacturer1? | SELECT AVG(cost) as avg_cost FROM Aircraft WHERE manufacturer = 'Manufacturer1' | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (equipment_name VARCHAR(255), origin_country VARCHAR(255)); | Delete the 'military_equipment' table | DROP TABLE military_equipment; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralInfrastructure (id INT PRIMARY KEY, type VARCHAR(255), construction_year INT); | Add a new record to the "RuralInfrastructure" table for a new 'Wind Turbine' with a construction year of 2020 | INSERT INTO RuralInfrastructure (type, construction_year) VALUES ('Wind Turbine', 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, region VARCHAR(255), name VARCHAR(255), patient_capacity INT); INSERT INTO hospitals (id, region, name, patient_capacity) VALUES (1, 'Northeast', 'Hospital A', 100), (2, 'West', 'Hospital B', 150), (3, 'South', 'Hospital C', 120); | What is the average patient capacity for hospitals in the South region? | SELECT AVG(patient_capacity) as avg_capacity FROM hospitals WHERE region = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE maintenance_requests (request_id INT, request_date DATE, request_type VARCHAR(255), unit VARCHAR(255), region VARCHAR(255)); INSERT INTO maintenance_requests (request_id, request_date, request_type, unit, region) VALUES (1, '2021-01-01', 'Equipment Maintenance', 'Unit A', 'Southeast'); INSERT INTO maintena... | What is the number of military equipment maintenance requests submitted by each unit in the Southeast region in the past month? | SELECT unit, COUNT(*) as total_requests FROM maintenance_requests WHERE request_type = 'Equipment Maintenance' AND region = 'Southeast' AND request_date >= DATEADD(month, -1, GETDATE()) GROUP BY unit; | gretelai_synthetic_text_to_sql |
CREATE TABLE TeacherProfessionalDevelopment (TeacherID INT, Date DATE, District VARCHAR(50), Hours INT); INSERT INTO TeacherProfessionalDevelopment (TeacherID, Date, District, Hours) VALUES (1, '2021-12-15', 'Suburban Education', 5); | What is the minimum number of hours of professional development completed by a teacher in the "Suburban Education" district in the last year? | SELECT MIN(Hours) FROM TeacherProfessionalDevelopment WHERE District = 'Suburban Education' AND Date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalEvents (id INT, city VARCHAR(50), attendance INT); INSERT INTO CulturalEvents (id, city, attendance) VALUES (1, 'Tokyo', 200), (2, 'Tokyo', 300), (3, 'Paris', 150), (4, 'Paris', 250), (5, 'London', 350); | What is the average attendance at cultural events in Tokyo and Paris? | SELECT AVG(attendance) FROM CulturalEvents WHERE city IN ('Tokyo', 'Paris'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (player_id VARCHAR(10), goals INT); INSERT INTO Players (player_id, goals) VALUES ('Player X', 25), ('Player X', 20), ('Player X', 30); | How many goals has Player X scored? | SELECT SUM(goals) FROM Players WHERE player_id = 'Player X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE individuals (individual_id INT, individual_name TEXT, income INT, financial_wellbeing_score INT, country TEXT); INSERT INTO individuals (individual_id, individual_name, income, financial_wellbeing_score, country) VALUES (1, 'John Doe', 6000000, 7, 'Indonesia'), (2, 'Jane Doe', 4000000, 8, 'Indonesia'), (3,... | What is the average financial wellbeing score of individuals in Indonesia with an income over 5,000,000 IDR? | SELECT AVG(financial_wellbeing_score) FROM individuals WHERE income > 5000000 AND country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IncidentByApp (id INT, app VARCHAR(255), region VARCHAR(255), incident_count INT); INSERT INTO IncidentByApp (id, app, region, incident_count) VALUES (1, 'AI Writer', 'North America', 12), (2, 'AI Artist', 'Europe', 15), (3, 'AI Composer', 'Asia', 8), (4, 'AI Writer', 'South America', 5), (5, 'AI Artist', ... | How many algorithmic fairness incidents were reported by each AI application? | SELECT app, SUM(incident_count) as total_incidents FROM IncidentByApp GROUP BY app; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_unemployment (unemployment_rate FLOAT, report_date DATE); INSERT INTO veteran_unemployment (unemployment_rate, report_date) VALUES (4.1, '2021-12-01'), (4.3, '2021-11-01'), (4.5, '2021-10-01'); | What is the maximum veteran unemployment rate for the last 6 months, and the date it was reported? | SELECT MAX(unemployment_rate), report_date FROM veteran_unemployment WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE traffic_court_records (id INT, violation_type TEXT, fine_amount DECIMAL(5,2), court_date DATE); | What is the minimum fine amount issued in traffic court in the past year, broken down by the type of violation? | SELECT violation_type, MIN(fine_amount) FROM traffic_court_records WHERE court_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY violation_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), price DECIMAL(5,2), is_organic BOOLEAN, country VARCHAR(255)); INSERT INTO products (product_id, product_name, price, is_organic, country) VALUES (1, 'Organic Facial Cleanser', 19.99, true, 'USA'); INSERT INTO products (product_id, product_name, price, i... | Find the average price of organic skincare products sold in the US. | SELECT AVG(price) FROM products WHERE is_organic = true AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE, Duration INT); | How many workouts were recorded in the first half of 2021? | SELECT COUNT(*) FROM Workouts WHERE MONTH(WorkoutDate) <= 6 AND YEAR(WorkoutDate) = 2021; | gretelai_synthetic_text_to_sql |
CREATE VIEW vessel_summary AS SELECT vessel_id, AVG(avg_speed) AS average_speed, SUM(fuel_efficiency) AS total_fuel_efficiency, COUNT(*) FILTER (WHERE result = 'PASS') AS successful_inspections FROM vessel_performance JOIN safety_records ON vessel_performance.vessel_id = safety_records.vessel_id GROUP BY vessel_id; | Create a new view named "vessel_summary" with columns "vessel_id", "average_speed", "total_fuel_efficiency", and "successful_inspections". | CREATE VIEW vessel_summary AS SELECT vessel_id, AVG(avg_speed) AS average_speed, SUM(fuel_efficiency) AS total_fuel_efficiency, COUNT(*) FILTER (WHERE result = 'PASS') AS successful_inspections FROM vessel_performance JOIN safety_records ON vessel_performance.vessel_id = safety_records.vessel_id GROUP BY vessel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production_3 (id INT, country VARCHAR(255), site_name VARCHAR(255), area FLOAT); INSERT INTO timber_production_3 (id, country, site_name, area) VALUES (1, 'Canada', 'Site A', 50000.0), (2, 'Canada', 'Site B', 60000.0), (3, 'Brazil', 'Site C', 70000.0), (4, 'Brazil', 'Site D', 80000.0), (5, 'Indonesi... | How many timber production sites are there in total, and what is their combined area in hectares, grouped by the sites' respective countries? | SELECT country, COUNT(*), SUM(area) FROM timber_production_3 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE tree_inventory (id INT, species VARCHAR(50), diameter FLOAT); INSERT INTO tree_inventory (id, species, diameter) VALUES (1, 'Oak', 45.8), (2, 'Cedar', 36.2), (3, 'Oak', 42.1), (4, 'Pine', 34.6), (5, 'Maple', 48.9); | Show the number of unique tree species in the tree_inventory table that have a diameter at breast height greater than or equal to 40 inches | SELECT COUNT(DISTINCT species) FROM tree_inventory WHERE diameter >= 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation (project_id INT, project_name VARCHAR(100), start_year INT, region VARCHAR(50), status VARCHAR(50)); | List all climate mitigation projects in the Middle East and North Africa that started after 2017. | SELECT project_id, project_name FROM climate_mitigation WHERE region = 'Middle East and North Africa' AND start_year > 2017 AND status = 'active'; | gretelai_synthetic_text_to_sql |
CREATE TABLE whale_sightings (id INTEGER, location TEXT, sighted INTEGER); | What is the total number of whale sightings in the 'Atlantic Ocean'? | SELECT SUM(sighted) FROM whale_sightings WHERE location = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Asia-Pacific'), (2, 'CompanyB', 'Europe'), (3, 'CompanyC', 'Asia-Pacific'); CREATE TABLE Materials (id INT, company_id INT, material VARCHAR(255), quantity INT); INSERT INTO Material... | Which companies use a specific sustainable material (e.g., organic cotton) and have fair labor practices? | SELECT Companies.name FROM Companies JOIN Materials ON Companies.id = Materials.company_id JOIN Labor ON Companies.id = Labor.company_id WHERE material = 'Organic cotton' AND fair = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtWorkSales (artworkID INT, saleDate DATE, artistID INT, revenue DECIMAL(10,2)); CREATE TABLE Artists (artistID INT, artistName VARCHAR(50), country VARCHAR(50)); | Who are the top 5 artists with the highest total revenue in Asia in the last 5 years? | SELECT a.artistName, SUM(aws.revenue) as total_revenue FROM ArtWorkSales aws JOIN Artists a ON aws.artistID = a.artistID WHERE a.country = 'Asia' AND saleDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE GROUP BY a.artistName ORDER BY total_revenue DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Country VARCHAR(50)); INSERT INTO Artists (ArtistID, ArtistName, Country) VALUES (1, 'A.R. Rahman', 'India'), (2, 'Green Day', 'USA'); CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), ArtistID INT, Length FLOAT); INSERT INTO Songs (SongID, SongName, Art... | What is the average length of songs released by artists from India? | SELECT AVG(Length) AS AvgLength FROM Songs WHERE ArtistID IN (SELECT ArtistID FROM Artists WHERE Country = 'India'); | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (region VARCHAR(50), year INT, capacity FLOAT); INSERT INTO landfill_capacity (region, year, capacity) VALUES ('Northern Africa', 2021, 1200000.0), ('Western Africa', 2021, 1500000.0), ('Eastern Africa', 2021, 2000000.0), ('Central Africa', 2021, 1800000.0), ('Southern Africa', 2021, 1300... | What is the total landfill capacity in cubic meters for each region in Africa in 2021? | SELECT region, SUM(capacity) FROM landfill_capacity WHERE year = 2021 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE MultiGenreUsers (UserID INT, Genre VARCHAR(20)); INSERT INTO MultiGenreUsers (UserID, Genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'), (4, 'Pop'), (4, 'Hip Hop'), (5, 'Pop'); | Identify the number of users who have streamed music from both the Pop and Hip Hop genres. | SELECT COUNT(DISTINCT UserID) FROM (SELECT UserID FROM MultiGenreUsers WHERE Genre = 'Pop' INTERSECT SELECT UserID FROM MultiGenreUsers WHERE Genre = 'Hip Hop') T; | gretelai_synthetic_text_to_sql |
CREATE TABLE Meals (MealID INT, MealName VARCHAR(50), Vendor VARCHAR(50), Calories INT); INSERT INTO Meals (MealID, MealName, Vendor, Calories) VALUES (1, 'Spaghetti Bolognese', 'Pasta Palace', 650), (2, 'Chicken Tikka Masala', 'Curry House', 850); | Which vendor has the highest total calorie count? | SELECT Vendor, SUM(Calories) as TotalCalories FROM Meals GROUP BY Vendor ORDER BY TotalCalories DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE maintenance_stats (vehicle_id INT, vehicle_type VARCHAR(10), maintenance_needed BOOLEAN); INSERT INTO maintenance_stats (vehicle_id, vehicle_type, maintenance_needed) VALUES (1, 'Bus', true), (2, 'Train', false), (3, 'Bus', false), (4, 'Tram', true); | Count the number of vehicles in need of maintenance for each type | SELECT vehicle_type, SUM(maintenance_needed) as number_of_vehicles_in_need_of_maintenance FROM maintenance_stats GROUP BY vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_open_pedagogy (teacher_id INT, project_id INT); INSERT INTO teacher_open_pedagogy (teacher_id, project_id) VALUES (1, 1001), (1, 1002), (2, 1003), (3, 1004), (3, 1005), (3, 1006), (4, 1007), (5, 1008); | Who are the top 5 teachers with the most open pedagogy projects, and how many projects have they completed? | SELECT teacher_id, COUNT(project_id) as num_projects FROM teacher_open_pedagogy GROUP BY teacher_id ORDER BY num_projects DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'Biology'), (2, 'Mathematics'), (3, 'Sociology'); CREATE TABLE research_grants (id INT, department_id INT, amount DECIMAL(10,2)); INSERT INTO research_grants (id, department_id, amount) VALUES (1, 1, 50000), (2, 1, 75000... | What is the average number of research grants per department? | SELECT d.name, AVG(rg.amount) FROM departments d JOIN research_grants rg ON d.id = rg.department_id GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_vulnerabilities (vulnerability_type VARCHAR(255), severity INT, discovery_month INT, region VARCHAR(255)); INSERT INTO cybersecurity_vulnerabilities (vulnerability_type, severity, discovery_month, region) VALUES ('Cross-Site Scripting', 4, 3, 'Europe'), ('SQL Injection', 7, 2, 'Europe'); | Display the number of cybersecurity vulnerabilities discovered per month and their severity in the European region | SELECT discovery_month, AVG(severity) FROM cybersecurity_vulnerabilities WHERE region = 'Europe' GROUP BY discovery_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cities (city_id INT, name TEXT, country TEXT); CREATE TABLE Virtual_Tours (tour_id INT, city_id INT, name TEXT, revenue FLOAT); INSERT INTO Cities (city_id, name, country) VALUES (1, 'New York', 'USA'), (2, 'Los Angeles', 'USA'); INSERT INTO Virtual_Tours (tour_id, city_id, name, revenue) VALUES (1, 1, 'Ce... | What is the revenue generated from virtual tours in New York and Los Angeles? | SELECT SUM(revenue) FROM Virtual_Tours WHERE city_id IN (1, 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_diversity (employee_id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10), age INT); INSERT INTO workforce_diversity (employee_id, name, department, gender, age) VALUES (1, 'John Doe', 'Engineering', 'Male', 35); INSERT INTO workforce_diversity (employee_id, name, department, gende... | What is the percentage of female employees in each department in the 'workforce_diversity' table? | SELECT department, ROUND(COUNT(*) FILTER (WHERE gender = 'Female') * 100.0 / COUNT(*), 2) AS percentage FROM workforce_diversity GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE seismic_retrofits (id INT, retrofit_number TEXT, location TEXT, cost INT, retrofit_date DATE); INSERT INTO seismic_retrofits (id, retrofit_number, location, cost, retrofit_date) VALUES (1, 'CA-1234', 'California', 300000, '2016-04-02'); INSERT INTO seismic_retrofits (id, retrofit_number, location, cost, re... | What is the minimum cost of seismic retrofits in 'California' since 2015? | SELECT MIN(cost) FROM seismic_retrofits WHERE location = 'California' AND YEAR(retrofit_date) >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinic_CA (patient_id INT, name VARCHAR(50)); INSERT INTO clinic_CA (patient_id, name) VALUES (1, 'James Johnson'), (2, 'Sophia Williams'), (3, 'Michael Brown'); | Delete the record of 'Michael Brown' from 'clinic_CA'. | DELETE FROM clinic_CA WHERE name = 'Michael Brown'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (id INT, name VARCHAR(50), location VARCHAR(50), expertise VARCHAR(50)); INSERT INTO Farmers (id, name, location, expertise) VALUES (1, 'Jane Doe', 'Canada', 'Urban Agriculture'); | What are the details of farmers specializing in urban agriculture? | SELECT * FROM Farmers WHERE expertise = 'Urban Agriculture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Equipment ( id INT, equipment_type VARCHAR(20), quantity INT ); INSERT INTO Military_Equipment (id, equipment_type, quantity) VALUES (1, 'Fighter Jet', 200), (2, 'Transport Plane', 150), (3, 'Helicopter', 300); | What is the total number of military aircrafts in the inventory? | SELECT SUM(quantity) FROM Military_Equipment WHERE equipment_type = 'Fighter Jet' OR equipment_type = 'Transport Plane'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryRenewableEnergy (country TEXT, capacity FLOAT); INSERT INTO CountryRenewableEnergy (country, capacity) VALUES ('Country1', 1200), ('Country2', 1500), ('Country3', 1800); | What is the average renewable energy capacity per country in the 'RenewableEnergy' table? | SELECT country, AVG(capacity) FROM CountryRenewableEnergy GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParityFines (FineID INT, Region VARCHAR(255), Fine INT); INSERT INTO MentalHealthParityFines (FineID, Region, Fine) VALUES (1, 'Northeast', 50000), (2, 'Southeast', 75000), (3, 'Midwest', 60000), (4, 'Southwest', 80000), (5, 'West', 100000); | What is the maximum mental health parity violation fine in each region? | SELECT Region, MAX(Fine) as MaxFine FROM MentalHealthParityFines GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, founder_gender TEXT, founding_year INT, funding_round_size INT); INSERT INTO startup (id, name, founder_gender, founding_year, funding_round_size) VALUES (1, 'WomenStart20', 'Female', 2020, 5000000); INSERT INTO startup (id, name, founder_gender, founding_year, funding_round_siz... | What is the total funding raised by startups founded by women in 2020? | SELECT SUM(funding_round_size) FROM startup WHERE founder_gender = 'Female' AND founding_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceDebris (id INT, diameter FLOAT, mass FLOAT); INSERT INTO SpaceDebris (id, diameter, mass) VALUES (1, 1.5, 2.3); | What is the total mass of all space debris larger than 1 cm in size? | SELECT SUM(mass) FROM SpaceDebris WHERE diameter > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_sales (id INT, vehicle_type VARCHAR(20), avg_speed FLOAT, sales INT); INSERT INTO vehicle_sales (id, vehicle_type, avg_speed, sales) VALUES (1, 'Tesla Model 3', 80.0, 50000), (2, 'Nissan Leaf', 70.0, 40000), (3, 'Chevrolet Bolt', 75.0, 30000); | What is the average speed of electric vehicles in 'vehicle_sales' table? | SELECT AVG(avg_speed) FROM vehicle_sales WHERE vehicle_type LIKE '%electric%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_data (id INT, name VARCHAR(20), state VARCHAR(2), score INT); INSERT INTO customer_data (id, name, state, score) VALUES (1, 'JohnDoe', 'CA', 75), (2, 'JaneDoe', 'NY', 80), (3, 'MikeSmith', 'CA', 65); | Delete records of customers with a financial wellbeing score less than 70 from the 'customer_data' table. | DELETE FROM customer_data WHERE score < 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_account (customer_id INT, account_number INT, balance DECIMAL(10, 2), closing_date DATE); INSERT INTO customer_account (customer_id, account_number, balance, closing_date) VALUES (1, 1001, 15000, '2021-08-31'), (1, 1002, 20000, '2021-08-31'), (2, 1003, 30000, '2021-08-31'); | What is the monthly average closing balance per customer for the last 6 months, ordered by the most recent month? | SELECT customer_id, AVG(balance) as avg_balance, EXTRACT(MONTH FROM closing_date) as month FROM customer_account WHERE closing_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY customer_id, month ORDER BY month DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (DepartmentID INT, Name VARCHAR(50)); INSERT INTO Departments VALUES (1, 'Computer Science'); CREATE TABLE ResearchGrants (GrantID INT, DepartmentID INT, Amount DECIMAL(10,2)); INSERT INTO ResearchGrants VALUES (1, 1, 5000); INSERT INTO ResearchGrants VALUES (2, 1, 7000); | What is the total amount of research funding received by each department in the past two years? | SELECT Departments.Name, SUM(ResearchGrants.Amount) FROM Departments INNER JOIN ResearchGrants ON Departments.DepartmentID = ResearchGrants.DepartmentID WHERE ResearchGrants.GrantID >= DATEADD(year, -2, GETDATE()) GROUP BY Departments.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, join_date DATE); INSERT INTO volunteers (id, name, country, join_date) VALUES (1, 'David Johnson', 'Australia', '2020-02-15'); INSERT INTO volunteers (id, name, country, join_date) VALUES (2, 'Emily Brown', 'Australia', '2020-05-28'); | How many volunteers have joined non-profit organizations in Australia between January 1, 2020, and June 30, 2020? | SELECT COUNT(*) FROM volunteers WHERE country = 'Australia' AND join_date BETWEEN '2020-01-01' AND '2020-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fortnite_scores (id INT, player TEXT, score INT, country TEXT); INSERT INTO fortnite_scores (id, player, score, country) VALUES (1, 'James', 85, 'UK'), (2, 'Peter', 75, 'UK'), (3, 'Olivia', 90, 'USA'), (4, 'Daniel', 95, 'USA'), (5, 'Sophia', 80, 'Canada'); | Which country has the highest average score in the game 'Fortnite'? | SELECT country, AVG(score) FROM fortnite_scores WHERE game = 'Fortnite' GROUP BY country ORDER BY AVG(score) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_holder (policy_holder_id INT, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(50), phone VARCHAR(15), address VARCHAR(100), city VARCHAR(50), state VARCHAR(2), zip VARCHAR(10)); INSERT INTO policy_holder (policy_holder_id, first_name, last_name, email, phone, address, city, state, zip) ... | Update the email to 'john.doe@example.com' for policy_holder_id 1 in the policy_holder table | UPDATE policy_holder SET email = 'john.doe@example.com' WHERE policy_holder_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableUrbanism (area TEXT, green_space_percentage FLOAT, public_transportation_score INT, walkability_score INT); INSERT INTO SustainableUrbanism (area, green_space_percentage, public_transportation_score, walkability_score) VALUES ('Eastside', 0.3, 8, 9), ('Westside', 0.5, 7, 8), ('GreenVille', 0.4, ... | Delete the record for the GreenVille area from the SustainableUrbanism table. | DELETE FROM SustainableUrbanism WHERE area = 'GreenVille'; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_advocacy_ga (id INT, union_name TEXT, state TEXT, members INT, involved_in_advocacy BOOLEAN); INSERT INTO union_advocacy_ga (id, union_name, state, members, involved_in_advocacy) VALUES (1, 'Union S', 'Georgia', 700, false), (2, 'Union T', 'Georgia', 600, true), (3, 'Union U', 'Georgia', 800, false); | What is the maximum number of members in unions that are not involved in labor rights advocacy in Georgia? | SELECT MAX(members) FROM union_advocacy_ga WHERE state = 'Georgia' AND involved_in_advocacy = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorker (WorkerID INT, ProviderID INT, WorkerIdentity VARCHAR(50), WorkerName VARCHAR(50)); INSERT INTO CommunityHealthWorker (WorkerID, ProviderID, WorkerIdentity, WorkerName) VALUES (1, 1, 'African American', 'John'), (2, 2, 'Hispanic', 'Jane'), (3, 3, 'Asian American', 'Jim'), (4, 4, 'Nati... | List the names of mental health providers who serve the most community health workers who identify as part of a historically underrepresented community. | SELECT ProviderID, WorkerName, COUNT(*) as NumWorkers FROM CommunityHealthWorker WHERE WorkerIdentity IN ('African American', 'Hispanic', 'Asian American', 'Native American') GROUP BY ProviderID, WorkerName ORDER BY NumWorkers DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (id INT, weight FLOAT, origin VARCHAR(50), destination VARCHAR(50), shipping_method VARCHAR(50)); INSERT INTO packages (id, weight, origin, destination, shipping_method) VALUES (1, 15.3, 'Canada', 'United States', 'expedited'), (2, 22.1, 'Mexico', 'Canada', 'standard'); | What is the total weight of packages shipped from Canada to the United States via expedited freight? | SELECT SUM(weight) FROM packages WHERE origin = 'Canada' AND destination = 'United States' AND shipping_method = 'expedited'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO hospitals (id, name, location, capacity) VALUES (1, 'Hospital A', 'Rural Washington', 50); INSERT INTO hospitals (id, name, location, capacity) VALUES (6, 'Hospital F', 'Rural Washington', 60); | What is the capacity of hospitals in Washington state? | SELECT capacity FROM hospitals WHERE location = 'Rural Washington'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (restaurant_name TEXT, cuisine TEXT, dish TEXT, carbohydrates INTEGER, dish_date DATE); INSERT INTO dishes (restaurant_name, cuisine, dish, carbohydrates, dish_date) VALUES ('Tokyo Sushi', 'Japanese', 'Sashimi', 5, '2022-04-01'); | Identify the top 3 dishes with the lowest carbohydrate content in Japanese cuisine restaurants in Tokyo, considering the month of April 2022. | SELECT dish, carbohydrates FROM (SELECT dish, carbohydrates, ROW_NUMBER() OVER (PARTITION BY dish_date ORDER BY carbohydrates ASC) as rn FROM dishes WHERE restaurant_name LIKE 'Tokyo%' AND cuisine = 'Japanese' AND dish_date >= '2022-04-01' AND dish_date < '2022-05-01') t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness (id INTEGER, algorithm TEXT, bias_level TEXT, risk_score INTEGER, last_updated TIMESTAMP); | Calculate the average risk_score for records in the algorithmic_fairness table where the bias_level is 'medium' | SELECT AVG(risk_score) FROM algorithmic_fairness WHERE bias_level = 'medium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (ID INT, Gender VARCHAR(10), Disease VARCHAR(20), Country VARCHAR(30), Diagnosis_Date DATE); INSERT INTO Patients (ID, Gender, Disease, Country, Diagnosis_Date) VALUES (1, 'Male', 'Tuberculosis', 'Argentina', '2020-01-01'); | How many patients in Argentina were diagnosed with Tuberculosis in 2020? | SELECT COUNT(*) FROM Patients WHERE Disease = 'Tuberculosis' AND Country = 'Argentina' AND YEAR(Diagnosis_Date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, last_interaction TIMESTAMP); INSERT INTO users (id, last_interaction) VALUES (1, '2021-01-01 10:00:00'), (2, '2021-06-15 14:30:00'), (3, '2020-12-25 09:15:00'), (4, '2019-08-05 16:20:00'); | Delete records of users who have not interacted with the creative AI application in the past year | DELETE FROM users WHERE last_interaction < NOW() - INTERVAL 1 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (TransactionID INT, TransactionDate DATE, Amount DECIMAL(18,2));INSERT INTO Transactions VALUES (1,'2022-01-01',1000.00),(2,'2022-01-15',2000.00),(3,'2022-02-01',3000.00),(4,'2022-03-01',1500.00),(5,'2022-03-15',2500.00); | What is the difference between the total transaction amount in the last 30 days and the total transaction amount in the 30 days prior to that? | SELECT (SUM(CASE WHEN TransactionDate >= DATEADD(day,-30,GETDATE()) THEN Amount ELSE 0 END) - SUM(CASE WHEN TransactionDate >= DATEADD(day,-60,GETDATE()) AND TransactionDate < DATEADD(day,-30,GETDATE()) THEN Amount ELSE 0 END)) AS TransactionAmountDifference FROM Transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE areas (id INT, name VARCHAR(20)); INSERT INTO areas (id, name) VALUES (1, 'Urban'), (2, 'Rural'); CREATE TABLE budget (item VARCHAR(20), area_id INT, amount INT); INSERT INTO budget (item, area_id, amount) VALUES ('Utilities', 1, 6000000), ('Utilities', 2, 3500000); | What is the average budget allocated for utilities in rural areas? | SELECT AVG(amount) FROM budget WHERE item = 'Utilities' AND area_id = (SELECT id FROM areas WHERE name = 'Rural'); | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, state VARCHAR(20), completion_year INT); INSERT INTO renewable_energy_projects (id, state, completion_year) VALUES (1, 'Texas', 2017), (2, 'Texas', 2020); | Identify the number of renewable energy projects in Texas with a completion year greater than 2018. | SELECT COUNT(*) FROM renewable_energy_projects WHERE state = 'Texas' AND completion_year > 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExtractionData (ExtractionDataID INT, MineID INT, Date DATE, Mineral TEXT, Quantity INT); | What is the total quantity of mineral extracted for each mine in a specific year? | SELECT MineID, SUM(Quantity) FROM ExtractionData WHERE YEAR(Date) = 2022 GROUP BY MineID; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, Program TEXT); | Which program has the least number of volunteers? | SELECT Program, COUNT(*) AS Count FROM Volunteers GROUP BY Program ORDER BY Count ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(255), country VARCHAR(255), funding_amount DECIMAL(10,2)); INSERT INTO biotech.startups (id, name, country, funding_amount) VALUES (1, 'Genetix', 'USA', 2000000.00), (2, 'BioSense', 'Canada', 1500000.00); | List biotech startups in descending order based on their funding amounts. | SELECT * FROM biotech.startups ORDER BY funding_amount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY, Sexuality VARCHAR(255), HourlyRate DECIMAL(5,2)); INSERT INTO Attorneys (AttorneyID, Sexuality, HourlyRate) VALUES (1, 'Heterosexual', 300.00), (2, 'Gay', 250.00), (3, 'Straight', 350.00); CREATE TABLE Cases (CaseID INT PRIMARY KEY, AttorneyID INT, HoursBilled DECIMAL... | What is the total billing amount for cases handled by attorneys who identify as male? | SELECT SUM(HoursBilled * Attorneys.HourlyRate) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.Sexuality IN ('Heterosexual', 'Straight'); | gretelai_synthetic_text_to_sql |
CREATE TABLE labor (id INT, project_id INT, worker_name VARCHAR(50), hours FLOAT); INSERT INTO labor (id, project_id, worker_name, hours) VALUES (6, 6, 'Jamila', 200); | What are the total labor hours for the Sustainable Housing project? | SELECT SUM(hours) FROM labor WHERE project_id = 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, region VARCHAR(50), name VARCHAR(50), budget INT); INSERT INTO projects (id, region, name, budget) VALUES (1, 'Africa', 'Solar Power', 80000), (2, 'Asia', 'Wind Energy', 100000); | What is the average budget for sustainable energy projects in Africa? | SELECT AVG(budget) FROM projects WHERE region = 'Africa' AND name LIKE '%sustainable energy%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_seafood_trends_2 (fishing_method VARCHAR(255), biomass FLOAT); INSERT INTO sustainable_seafood_trends_2 (fishing_method, biomass) VALUES ('Line Fishing', 550), ('Trawling', 750), ('Potting', 650); | Find the total biomass of fish in the sustainable_seafood_trends_2 table for each fishing_method. | SELECT fishing_method, SUM(biomass) FROM sustainable_seafood_trends_2 GROUP BY fishing_method; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes_2 (id INT, city VARCHAR(50), district VARCHAR(50), year INT, crime_count INT); INSERT INTO crimes_2 (id, city, district, year, crime_count) VALUES (1, 'CityJ', 'District2', 2018, 33), (2, 'CityJ', 'District2', 2017, 40), (3, 'CityK', 'District3', 2018, 47); | How many crimes were reported in District2 of CityJ in 2018? | SELECT SUM(crime_count) FROM crimes_2 WHERE city = 'CityJ' AND district = 'District2' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes_2 (name TEXT, sport TEXT); INSERT INTO athletes_2 (name, sport) VALUES ('John Doe', 'Baseball'), ('Jane Doe', 'Soccer'), ('Jim Smith', 'Baseball'), ('Jill Smith', 'Soccer'), ('James Johnson', 'Basketball'); | Find the names of athletes who have participated in baseball and soccer, but not basketball. | SELECT name FROM athletes_2 WHERE sport IN ('Baseball', 'Soccer') AND name NOT IN (SELECT name FROM athletes_2 WHERE sport = 'Basketball'); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Laptop 1', 'electronics'), (2, 'Phone 1', 'electronics'); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); INSERT INTO users (user_id, user_country)... | What was the total revenue from users in France and Germany for the 'electronics' product category in Q2 2022? | SELECT SUM(revenue) FROM orders o JOIN products p ON o.product_id = p.product_id JOIN users u ON o.user_id = u.user_id WHERE u.user_country IN ('France', 'Germany') AND p.category = 'electronics' AND o.order_date BETWEEN '2022-04-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, program_name VARCHAR(255), is_international BOOLEAN); INSERT INTO students (student_id, program_name, is_international) VALUES (1, 'Computer Science', TRUE), (2, 'Physics', FALSE), (3, 'English', TRUE); | Calculate the percentage of students who are international in the 'English' program. | SELECT program_name, AVG(is_international) * 100.0 AS pct_international FROM students GROUP BY program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE communication_budget (org_name VARCHAR(50), year INT, budget FLOAT); INSERT INTO communication_budget (org_name, year, budget) VALUES ('UNFCCC', 2019, 1000000), ('Greenpeace', 2019, 1200000), ('WWF', 2019, 1500000); | What is the total communication budget for each organization in 2019? | SELECT org_name, SUM(budget) as total_budget FROM communication_budget WHERE year = 2019 GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE QuarterlySales (sale_id INT, equipment_type VARCHAR(50), sale_value FLOAT, sale_date DATE); INSERT INTO QuarterlySales (sale_id, equipment_type, sale_value, sale_date) VALUES (5, 'Tanks', 18000000, '2021-02-15'), (6, 'Fighter Jets', 55000000, '2021-03-20'), (7, 'Armored Vehicles', 8000000, '2021-06-05'), (... | Find the number of military equipment sales by quarter in 2021 and display the result in a YYYY-Q format. | SELECT DATE_FORMAT(sale_date, '%Y-Q') AS Quarter, COUNT(*) AS SalesCount FROM QuarterlySales WHERE YEAR(sale_date) = 2021 GROUP BY Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE login_attempts (id INT, user_name VARCHAR(255), success BOOLEAN, login_time TIMESTAMP); INSERT INTO login_attempts (id, user_name, success, login_time) VALUES (1, 'user1', false, '2022-06-01 10:00:00'), (2, 'user2', true, '2022-06-02 11:00:00'); | How many times did each user attempt to log in, successfully and unsuccessfully, over the past week? | SELECT user_name, SUM(CASE WHEN success THEN 1 ELSE 0 END) as successful_logins, SUM(CASE WHEN NOT success THEN 1 ELSE 0 END) as unsuccessful_logins FROM login_attempts WHERE login_time >= DATE(NOW()) - INTERVAL '7 days' GROUP BY user_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinics (id INT, name TEXT, location TEXT); INSERT INTO clinics (id, name, location) VALUES (1, 'Clinic A', 'Urban Florida'); INSERT INTO clinics (id, name, location) VALUES (2, 'Clinic B', 'Rural Florida'); INSERT INTO clinics (id, name, location) VALUES (3, 'Clinic C', 'Urban Georgia'); INSERT INTO clini... | What is the number of clinics in urban and rural areas of Florida and Georgia? | SELECT COUNT(*) FROM clinics WHERE location IN ('Urban Florida', 'Rural Florida', 'Urban Georgia', 'Rural Georgia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Patents (id INT PRIMARY KEY, country VARCHAR(50), tech_name VARCHAR(50), filing_year INT); INSERT INTO Patents (id, country, tech_name, filing_year) VALUES (1, 'Singapore', 'AI-based surveillance', 2021), (2, 'Indonesia', 'Drone technology', 2021), (3, 'Thailand', 'Cybersecurity software', 2021); | Identify the military technology patents filed by ASEAN countries in 2021. | SELECT country, tech_name FROM Patents WHERE country IN ('Singapore', 'Indonesia', 'Thailand') AND filing_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (production_id INT, location VARCHAR(255), year INT, oil_production FLOAT); INSERT INTO production (production_id, location, year, oil_production) VALUES (1, 'Saudi Arabia', 2020, 5000000), (2, 'Iran', 2020, 3000000), (3, 'Iraq', 2019, 4000000); | What is the total oil production in the 'Middle East' for the year 2020? | SELECT SUM(oil_production) FROM production WHERE location LIKE '%Middle East%' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(50)); CREATE TABLE Attendees (attendee_id INT, event_id INT, age INT); INSERT INTO Events (event_id, event_name) VALUES (1, 'Jazz Night'); INSERT INTO Attendees (attendee_id, event_id, age) VALUES (1, 1, 25), (2, 1, 35), (3, 1, 45); | How many people attended the 'Jazz Night' event by age group? | SELECT e.event_name, a.age, COUNT(a.attendee_id) FROM Events e JOIN Attendees a ON e.event_id = a.event_id WHERE e.event_name = 'Jazz Night' GROUP BY e.event_name, a.age; | gretelai_synthetic_text_to_sql |
CREATE TABLE users(id INT, name VARCHAR(50), country VARCHAR(50), last_login DATETIME); CREATE TABLE game_sessions(id INT, user_id INT, game_name VARCHAR(50), start_time DATETIME); | Show the number of users who played a specific game in the last month, grouped by country. | SELECT game_name, country, COUNT(DISTINCT users.id) as num_users FROM game_sessions JOIN users ON game_sessions.user_id = users.id WHERE start_time >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY game_name, country; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, publish_date DATE); INSERT INTO articles VALUES (1, '2022-01-01'); INSERT INTO articles VALUES (2, '2022-01-02'); | Find the number of articles published per day for the last week in 'weeklyreview' database. | SELECT DATE(publish_date), COUNT(*) FROM articles WHERE publish_date >= CURDATE() - INTERVAL 7 DAY GROUP BY DATE(publish_date) | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), status VARCHAR(255)); INSERT INTO satellites (id, name, status) VALUES (1, 'Satellite 1', 'Operational'), (2, 'Satellite 2', 'Operational'), (3, 'Satellite 3', 'Inoperable'); | How many operational and inoperable satellites are in orbit? | SELECT SUM(CASE WHEN status = 'Operational' THEN 1 ELSE 0 END) AS operational, SUM(CASE WHEN status = 'Inoperable' THEN 1 ELSE 0 END) AS inoperable FROM satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE CaseResults (CaseID INT, Won BOOLEAN); INSERT INTO CaseResults (CaseID, Won) VALUES (1, TRUE), (2, FALSE); | What is the average income for clients who won their cases? | SELECT AVG(Clients.Income) FROM Clients INNER JOIN CaseResults ON Clients.CaseID = CaseResults.CaseID WHERE CaseResults.Won = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE dolphin_population (year INT, ocean VARCHAR(255), population INT); INSERT INTO dolphin_population (year, ocean, population) VALUES (2006, 'Indian Ocean', 950000), (2007, 'Indian Ocean', 930000), (2008, 'Indian Ocean', 920000), (2009, 'Indian Ocean', 910000), (2010, 'Indian Ocean', 900000), (2011, 'Indian O... | What is the change in population of dolphins in the Indian Ocean over the past 15 years? | SELECT year, population, LAG(population) OVER (ORDER BY year) as prev_population, population - LAG(population) OVER (ORDER BY year) as population_change FROM dolphin_population WHERE ocean = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (project_id INT, project_category VARCHAR(50), project_cost DECIMAL(10, 2)); INSERT INTO DefenseProjects (project_id, project_category, project_cost) VALUES (1, 'Research', 1000000.00); INSERT INTO DefenseProjects (project_id, project_category, project_cost) VALUES (2, 'Development', 200000... | What is the total number of defense projects and their total cost for each category? | SELECT project_category, COUNT(*) as total_projects, SUM(project_cost) as total_cost FROM DefenseProjects GROUP BY project_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists Cities (id int, name text); INSERT INTO Cities (id, name) VALUES (1, 'Los Angeles'), (2, 'New York'); CREATE TABLE if not exists Vehicles (id int, type text, capacity int, city_id int); INSERT INTO Vehicles (id, type, capacity, city_id) VALUES (1, 'Electric Bus', 50, 1), (2, 'Diesel Bus', 60,... | What is the average trip duration for electric buses in the city of 'Los Angeles'? | SELECT AVG(duration) FROM Trips JOIN Vehicles ON Trips.vehicle_id = Vehicles.id WHERE Vehicles.type = 'Electric Bus' AND Vehicles.city_id = (SELECT id FROM Cities WHERE name = 'Los Angeles'); | gretelai_synthetic_text_to_sql |
CREATE TABLE RefugeA(animal_id INT, species VARCHAR(20), refuge VARCHAR(10)); INSERT INTO RefugeA VALUES (1, 'Bear', 'RefugeA'), (2, 'Deer', 'RefugeA'), (3, 'Raccoon', 'RefugeA'); CREATE TABLE RefugeB(animal_id INT, species VARCHAR(20), refuge VARCHAR(10)); INSERT INTO RefugeB VALUES (4, 'Fox', 'RefugeB'), (5, 'Rabbit'... | What is the total number of animals in 'Refuge A' and 'Refuge B'? | SELECT SUM(qty) FROM (SELECT COUNT(*) as qty FROM RefugeA UNION ALL SELECT COUNT(*) as qty FROM RefugeB) as total; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operation (id INT, name VARCHAR(50), location VARCHAR(50), resource VARCHAR(50), quantity INT); INSERT INTO mining_operation (id, name, location, resource, quantity) VALUES (1, 'Operation A', 'Canada', 'Gold', 1000); INSERT INTO mining_operation (id, name, location, resource, quantity) VALUES (2, 'O... | What is the total quantity of gold mined by mining operations located in Canada? | SELECT SUM(quantity) FROM mining_operation WHERE location = 'Canada' AND resource = 'Gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE otas (ota_id INT, name TEXT, city TEXT, revenue FLOAT); | What is the total revenue for online travel agencies in 'Sydney'? | SELECT city, SUM(revenue) as total_revenue FROM otas WHERE city = 'Sydney' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE bay_area_properties_yearly (property_id INT, year INT, price DECIMAL(10,2), size INT, co_ownership BOOLEAN, property_type VARCHAR(20)); INSERT INTO bay_area_properties_yearly (property_id, year, price, size, co_ownership, property_type) VALUES (1, 2020, 1000000, 2000, TRUE, 'Condo'), (2, 2021, 1200000, 300... | Determine the annual change in average property price in the Bay Area, partitioned by property type and ordered by price in descending order. | SELECT property_type, EXTRACT(YEAR FROM date_trunc('year', time)) AS year, AVG(price) AS avg_price, LAG(AVG(price)) OVER (PARTITION BY property_type ORDER BY EXTRACT(YEAR FROM date_trunc('year', time))) - AVG(price) AS annual_change, ROW_NUMBER() OVER (PARTITION BY property_type ORDER BY EXTRACT(YEAR FROM date_trunc('y... | gretelai_synthetic_text_to_sql |
CREATE TABLE storage (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT, created_at TIMESTAMP); | How many energy storage projects have been implemented each year in the storage table? | SELECT EXTRACT(YEAR FROM created_at) as year, COUNT(*) as num_projects FROM storage GROUP BY year ORDER BY year ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (id INT, name VARCHAR(255), rainfall FLOAT); INSERT INTO region (id, name, rainfall) VALUES (1, 'US-MN', 12.5), (2, 'US-ND', 11.8), (3, 'CA-BC', 18.3); | What is the total rainfall in the last month for region 'CA-BC'? | SELECT SUM(rainfall) FROM region WHERE name = 'CA-BC' AND rainfall_timestamp >= DATEADD(month, -1, CURRENT_TIMESTAMP); | gretelai_synthetic_text_to_sql |
CREATE TABLE GroundForce.VehicleSales (id INT, manufacturer VARCHAR(255), model VARCHAR(255), quantity INT, price DECIMAL(10,2), buyer_country VARCHAR(255), sale_date DATE); | What is the maximum number of military vehicles sold by GroundForce to the Mexican government? | SELECT MAX(quantity) FROM GroundForce.VehicleSales WHERE buyer_country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, country TEXT); INSERT INTO suppliers (id, name, country) VALUES (1, 'Green Earth Farms', 'France'), (2, 'La Placita Market', 'Spain'), (3, 'Bella Verde Organics', 'Italy'); | Retrieve all records from the 'suppliers' table where the country is not 'Italy' | SELECT * FROM suppliers WHERE country != 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, monthly_bill FLOAT, state VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, monthly_bill, state) VALUES (1, 60.5, 'Texas'), (2, 70.3, 'Texas'), (3, 55.7, 'California'); | What is the maximum monthly bill for broadband subscribers in the state of Texas? | SELECT MAX(monthly_bill) FROM broadband_subscribers WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, app_name VARCHAR(255), severity INT, region VARCHAR(255), occurrence_date DATE); INSERT INTO vulnerabilities (id, app_name, severity, region, occurrence_date) VALUES (1, 'App1', 8, 'EMEA', '2021-02-03'); | Which were the top 3 most vulnerable software applications by severity in the EMEA region in H1 2021? | SELECT app_name, severity FROM vulnerabilities WHERE region = 'EMEA' AND occurrence_date >= '2021-01-01' AND occurrence_date < '2021-07-01' GROUP BY app_name HAVING COUNT(*) <= 3 ORDER BY severity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (id INT, name TEXT, location TEXT); INSERT INTO Accommodations (id, name, location) VALUES (1, 'Ramp', 'California'), (2, 'Elevator', 'New York'); | Which disability accommodations have been implemented in California? | SELECT name FROM Accommodations WHERE location = 'California'; | 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.