context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Veterans_Employment (ID INT, Industry TEXT, State TEXT, Num_Employees INT); INSERT INTO Veterans_Employment (ID, Industry, State, Num_Employees) VALUES (1, 'Defense', 'California', 5000); INSERT INTO Veterans_Employment (ID, Industry, State, Num_Employees) VALUES (2, 'Defense', 'Texas', 6000); INSERT INTO Veterans_Employment (ID, Industry, State, Num_Employees) VALUES (3, 'Defense', 'New York', 4000); | What is the average number of veterans employed in the defense industry per state? | SELECT AVG(Num_Employees) FROM Veterans_Employment WHERE Industry = 'Defense' GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, capacity INT, location TEXT); INSERT INTO projects (id, name, capacity, location) VALUES (1, 'Solar Farm 1.0', 1000, 'California'); INSERT INTO projects (id, name, capacity, location) VALUES (2, 'Wind Farm 1.0', 2000, 'Texas'); INSERT INTO projects (id, name, capacity, location) VALUES (3, 'Hydro Plant 1.0', 1500, 'Oregon'); | Add a new row to the projects table for a project with id 4, name 'Energy Storage 1.0', capacity 500, and location 'Arizona' | INSERT INTO projects (id, name, capacity, location) VALUES (4, 'Energy Storage 1.0', 500, 'Arizona'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ResilienceProjects (id INT, region VARCHAR(20), cost FLOAT); INSERT INTO ResilienceProjects (id, region, cost) VALUES (1, 'Northwest', 500000.0), (2, 'Southeast', 750000.0), (3, 'Northwest', 300000.0); | What is the total cost of all resilience projects in the Northwest region? | SELECT SUM(cost) FROM ResilienceProjects WHERE region = 'Northwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workers (Id INT, Name VARCHAR(50), Job VARCHAR(50), Salary FLOAT, Industry VARCHAR(50)); INSERT INTO Workers (Id, Name, Job, Salary, Industry) VALUES (1, 'John Doe', 'Engineer', 80000.00, 'oil'); INSERT INTO Workers (Id, Name, Job, Salary, Industry) VALUES (2, 'Jane Smith', 'Technician', 60000.00, 'oil'); INSERT INTO Workers (Id, Name, Job, Salary, Industry) VALUES (3, 'Mike Johnson', 'Manager', 95000.00, 'oil'); | Delete all records of workers with a salary greater than 90000 and update the remaining salaries to increase by 5% if they work in the 'oil' industry. | WITH cte AS (DELETE FROM Workers WHERE Salary > 90000 AND Industry = 'oil' RETURNING *) UPDATE Workers SET Salary = Salary * 1.05 WHERE Industry = 'oil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, Premium DECIMAL(10, 2), PolicyholderState VARCHAR(10)); INSERT INTO Policies (PolicyID, Premium, PolicyholderState) VALUES (1, 2500, 'California'), (2, 1500, 'New York'), (3, 1000, 'California'); | List all policies with a premium greater than $2000 for policyholders living in 'California' or 'New York'. | SELECT * FROM Policies WHERE PolicyholderState IN ('California', 'New York') AND Premium > 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (id INT, chemical_code VARCHAR(10), incident_type VARCHAR(50)); INSERT INTO safety_incidents (id, chemical_code, incident_type) VALUES (1, 'ABC123', 'Leak'), (2, 'ABC123', 'Explosion'), (3, 'DEF456', 'Fire'), (4, 'DEF456', 'Leak'), (5, 'GHI789', 'Explosion'), (6, 'JKL012', 'Fire'); CREATE TABLE chemicals (id INT, code VARCHAR(10), type VARCHAR(50)); INSERT INTO chemicals (id, code, type) VALUES (1, 'ABC123', 'Solid'), (2, 'DEF456', 'Liquid'), (3, 'GHI789', 'Gas'), (4, 'JKL012', 'Solid'); | What is the total number of safety incidents for each product type in the chemicals domain? | SELECT c.type, COUNT(si.id) as total_incidents FROM safety_incidents si JOIN chemicals c ON si.chemical_code = c.code GROUP BY c.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE FarmH (country VARCHAR(20), species VARCHAR(20), biomass FLOAT); INSERT INTO FarmH (country, species, biomass) VALUES ('Norway', 'Salmon', 450000); INSERT INTO FarmH (country, species, biomass) VALUES ('Norway', 'Trout', 120000); INSERT INTO FarmH (country, species, biomass) VALUES ('Scotland', 'Salmon', 320000); INSERT INTO FarmH (country, species, biomass) VALUES ('Scotland', 'Trout', 160000); INSERT INTO FarmH (country, species, biomass) VALUES ('Canada', 'Salmon', 200000); INSERT INTO FarmH (country, species, biomass) VALUES ('Canada', 'Trout', 260000); | What is the total biomass of salmon farmed in all countries? | SELECT SUM(biomass) FROM FarmH WHERE species='Salmon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, department_id INT, mental_health_score INT); INSERT INTO students (student_id, department_id, mental_health_score) VALUES (1, 101, 80), (2, 101, 85), (3, 102, 75), (4, 102, 90); CREATE TABLE departments (department_id INT, department_name VARCHAR(50)); INSERT INTO departments (department_id, department_name) VALUES (101, 'Social Sciences'), (102, 'Humanities'); | What is the average mental health score of students in each department? | SELECT departments.department_name, AVG(students.mental_health_score) as avg_mental_health FROM students JOIN departments ON students.department_id = departments.department_id GROUP BY departments.department_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_representatives (id INT, name TEXT, region TEXT, sales FLOAT); INSERT INTO sales_representatives (id, name, region, sales) VALUES (1, 'John Doe', 'North', 5000), (2, 'Jane Smith', 'South', 6000), (3, 'Alice Johnson', 'East', 7000), (4, 'Bob Williams', 'West', 8000), (5, 'Charlie Brown', 'North', 9000), (6, 'David Lee', 'North', 10000); | What are the top 3 sales representatives with the highest total sales in the North region? | SELECT name, SUM(sales) as total_sales FROM sales_representatives WHERE region = 'North' GROUP BY name ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, city VARCHAR(20), date DATE, crime VARCHAR(20)); INSERT INTO crimes (id, city, date, crime) VALUES (1, 'Seattle', '2021-01-01', 'Theft'), (2, 'Seattle', '2021-02-01', 'Burglary'), (3, 'Seattle', '2021-03-01', 'Assault'), (4, 'Seattle', '2021-04-01', 'Murder'); | What is the maximum number of reported crimes in the city of Seattle? | SELECT MAX(id) FROM crimes WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (id INT, operation_name VARCHAR(255), country VARCHAR(255), year INT); | Add a new humanitarian_assistance record for 'Operation Rainbow' in 'Country X' in 2020 | INSERT INTO humanitarian_assistance (id, operation_name, country, year) VALUES (1, 'Operation Rainbow', 'Country X', 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE OceanFloorMapping (id INT, location VARCHAR(50), depth INT); INSERT INTO OceanFloorMapping (id, location, depth) VALUES (1, 'Mariana Trench', 10000), (2, 'Sunda Trench', 8000), (3, 'Philippine Trench', 6500), (4, 'Kermadec Trench', 10000), (5, 'Tonga Trench', 10800); | Update the 'OceanFloorMapping' table to correct the depth for the 'Tonga Trench' to 10820 meters | UPDATE OceanFloorMapping SET depth = 10820 WHERE location = 'Tonga Trench'; | gretelai_synthetic_text_to_sql |
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), creation_date DATE); | Find the number of open pedagogy courses created in the past two years from the 'courses' table. | SELECT COUNT(*) FROM courses WHERE course_name LIKE '%open pedagogy%' AND creation_date >= DATE(NOW()) - INTERVAL 2 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (country, year, visitors) VALUES ('France', 2020, 15000), ('Germany', 2020, 12000), ('Spain', 2020, 18000), ('Italy', 2020, 10000); | How many tourists visited each European country in the year 2020? | SELECT country, visitors FROM tourism_stats WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE MonthlyCityEnergyEfficiency (City VARCHAR(50), Month INT, EnergyEfficiencyScore FLOAT); | Find the difference in energy efficiency scores between consecutive months for each city in the "MonthlyCityEnergyEfficiency" table. | SELECT City, EnergyEfficiencyScore, LAG(EnergyEfficiencyScore) OVER (PARTITION BY City ORDER BY Month) AS PreviousEnergyEfficiencyScore, EnergyEfficiencyScore - LAG(EnergyEfficiencyScore) OVER (PARTITION BY City ORDER BY Month) AS Difference FROM MonthlyCityEnergyEfficiency; | gretelai_synthetic_text_to_sql |
CREATE TABLE maritime_safety_incidents (year INT, incidents INT); INSERT INTO maritime_safety_incidents (year, incidents) VALUES (2010, 150), (2011, 145), (2012, 160), (2013, 175), (2014, 180), (2015, 190), (2016, 200), (2017, 210), (2018, 220), (2019, 230); | What is the trend of maritime safety incidents over time? | SELECT year, incidents, (SELECT COUNT(*) FROM maritime_safety_incidents AS sub WHERE sub.year <= main.year) AS cumulative_incidents FROM maritime_safety_incidents AS main ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organizations (OrganizationID int, OrganizationName varchar(50), AmountDonated numeric(10,2)); INSERT INTO Organizations (OrganizationID, OrganizationName, AmountDonated) VALUES (1, 'ACME Inc.', 2000.00), (2, 'Beta Corp.', 3000.00); | What was the total amount donated by each organization in Q3 2020? | SELECT OrganizationName, SUM(AmountDonated) as TotalDonated FROM Organizations WHERE AmountDonated >= 0 AND AmountDonated < 9999.99 GROUP BY OrganizationName; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarSales (Id INT, Vehicle VARCHAR(50), Year INT, QuantitySold INT); CREATE TABLE ElectricVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Horsepower INT); | How many electric vehicles were sold in the 'CarSales' database in 2021? | SELECT COUNT(*) FROM CarSales WHERE Vehicle IN (SELECT Model FROM ElectricVehicles WHERE Year = 2021); | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (id INT, item_name VARCHAR(20), price DECIMAL(5,2), is_sustainable BOOLEAN); INSERT INTO inventory (id, item_name, price, is_sustainable) VALUES (1, 't-shirt', 20.99, false), (2, 'blouse', 45.50, true), (3, 'jeans', 39.99, true); | List all items with a price above the median for sustainable items | SELECT * FROM inventory WHERE is_sustainable = true AND price > (SELECT AVG(price) FROM inventory WHERE is_sustainable = true); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name TEXT, gender TEXT, country TEXT); INSERT INTO customers (customer_id, customer_name, gender, country) VALUES (1, 'Ana', 'Female', 'Mexico'), (2, 'Pedro', 'Male', 'Brazil'); CREATE TABLE loans (loan_id INT, customer_id INT, maturity INT); INSERT INTO loans (loan_id, customer_id, maturity) VALUES (1, 1, 8), (2, 2, 9); | How many customers have taken out loans with a maturity of more than 7 years, in Mexico and Brazil, broken down by gender? | SELECT gender, COUNT(*) FROM customers JOIN loans ON customers.customer_id = loans.customer_id WHERE country IN ('Mexico', 'Brazil') AND maturity > 7 GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, years_of_experience INT); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount DECIMAL, domain TEXT); | What is the total billing amount for cases in the legal services domain that were handled by attorneys with less than 5 years of experience? | SELECT SUM(cases.billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE cases.domain = 'legal services' AND attorneys.years_of_experience < 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, YearsOfExperience INT, Specialization VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization) VALUES (1, 12, 'Civil Law'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization) VALUES (2, 15, 'Criminal Law'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Specialization) VALUES (3, 5, 'Family Law'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (1, 1, 2000.00); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (2, 2, 3000.00); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (3, 3, 1500.00); | What is the average billing amount for cases handled by attorneys with more than 10 years of experience? | SELECT AVG(BillingAmount) FROM Cases INNER JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE YearsOfExperience > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_info (restaurant_id INT, name VARCHAR(50), address VARCHAR(100), city VARCHAR(50), state VARCHAR(2), has_vegan_options BOOLEAN); | Delete records in the restaurant_info table with a restaurant ID of 99 | DELETE FROM restaurant_info WHERE restaurant_id = 99; | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthEquityMetrics (ID INT PRIMARY KEY, CommunityID INT, Metric VARCHAR(20), Value FLOAT); | What is the minimum value for each health equity metric? | SELECT Metric, MIN(Value) as MinValue FROM HealthEquityMetrics GROUP BY Metric; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales(sale_id INT, equipment_name VARCHAR(50), sale_country VARCHAR(50)); INSERT INTO military_sales VALUES (1, 'Tank', 'Canada'), (2, 'Helicopter', 'Canada'), (3, 'Airplane', 'Mexico'); | How many military equipment sales were made to Canada? | SELECT COUNT(*) FROM military_sales WHERE sale_country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (Country VARCHAR(50), Year INT, Operations INT); INSERT INTO PeacekeepingOperations (Country, Year, Operations) VALUES ('France', 2016, 6), ('USA', 2016, 8), ('UK', 2016, 7), ('France', 2017, 7), ('USA', 2017, 9), ('UK', 2017, 8), ('France', 2018, 8), ('USA', 2018, 10), ('UK', 2018, 9); | List the top 2 countries with the most peacekeeping operations since 2016? | SELECT Country, SUM(Operations) AS TotalOperations FROM PeacekeepingOperations GROUP BY Country ORDER BY TotalOperations DESC FETCH FIRST 2 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, building_name VARCHAR(50), location VARCHAR(50), square_footage INT, certification VARCHAR(10)); INSERT INTO green_buildings (id, building_name, location, square_footage, certification) VALUES (1, 'EcoTower', 'Seattle', 500000, 'LEED Platinum'); INSERT INTO green_buildings (id, building_name, location, square_footage, certification) VALUES (2, 'GreenHaven', 'Austin', 350000, 'LEED Gold'); INSERT INTO green_buildings (id, building_name, location, square_footage, certification) VALUES (6, 'GreenSkyRise', 'Vancouver', 600000, 'LEED Platinum'); | What is the total square footage of all green buildings certified as LEED Platinum? | SELECT SUM(square_footage) FROM green_buildings WHERE certification = 'LEED Platinum'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT PRIMARY KEY, investor_id INT, nonprofit_id INT, amount DECIMAL(10,2), investment_date DATE); INSERT INTO investments (id, investor_id, nonprofit_id, amount, investment_date) VALUES (1, 1, 3, 1500.00, '2021-03-01'), (2, 2, 4, 2000.00, '2021-05-01'), (3, 3, 5, 1000.00, '2021-09-01'), (4, 4, 3, 2500.00, '2021-12-01'); CREATE TABLE nonprofits (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sector VARCHAR(255)); INSERT INTO nonprofits (id, name, location, sector) VALUES (3, 'Greenpeace', 'Germany', 'Renewable Energy'), (4, 'SolarAid', 'UK', 'Renewable Energy'), (5, 'WindAid', 'Peru', 'Renewable Energy'); | What is the total investment in renewable energy sector for the year 2021? | SELECT SUM(amount) FROM investments i JOIN nonprofits n ON i.nonprofit_id = n.id WHERE n.sector = 'Renewable Energy' AND DATE_PART('year', investment_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (DispensaryID INT, DispensaryName TEXT, State TEXT); INSERT INTO Dispensaries (DispensaryID, DispensaryName, State) VALUES (1, 'Green Earth', 'Colorado'); CREATE TABLE Inventory (InventoryID INT, DispensaryID INT, Strain TEXT); INSERT INTO Inventory (InventoryID, DispensaryID, Strain) VALUES (1, 1, 'Blue Dream'); | Show the number of unique strains available in each dispensary in Colorado. | SELECT d.DispensaryName, COUNT(DISTINCT i.Strain) as UniqueStrains FROM Dispensaries d INNER JOIN Inventory i ON d.DispensaryID = i.DispensaryID WHERE d.State = 'Colorado' GROUP BY d.DispensaryName; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapy_sessions (session_id INT, patient_id INT, country VARCHAR(50), session_count INT); INSERT INTO therapy_sessions (session_id, patient_id, country, session_count) VALUES (1, 1, 'USA', 5), (2, 2, 'Canada', 3), (3, 3, 'Japan', 4); | List of countries with at least 5 therapy sessions. | SELECT country FROM therapy_sessions GROUP BY country HAVING SUM(session_count) >= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_energy_usage (hotel_name VARCHAR(50), energy_type VARCHAR(50), consumption INT, month INT, year INT); INSERT INTO hotel_energy_usage (hotel_name, energy_type, consumption, month, year) VALUES ('Hotel Paris', 'Electricity', 80000, 1, 2022), ('Hotel Paris', 'Gas', 25000, 1, 2022), ('Hotel Tokyo', 'Electricity', 90000, 1, 2022), ('Hotel Tokyo', 'Gas', 30000, 1, 2022); | Create a table for hotel energy usage and insert sample data. | SELECT hotel_name, SUM(consumption) as total_consumption FROM hotel_energy_usage WHERE energy_type = 'Electricity' AND year = 2022 GROUP BY hotel_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_performances (performance_id INT, name VARCHAR(50), location VARCHAR(50), date DATE, type VARCHAR(50)); | What is the earliest and latest date for traditional art performances in each country? | SELECT location, MIN(date) AS earliest_date, MAX(date) AS latest_date FROM art_performances GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE organization (organization_id INT, name VARCHAR(50)); INSERT INTO organization (organization_id, name) VALUES (1, 'Organization X'), (2, 'Organization Y'); CREATE TABLE year (year_id INT, year INT); INSERT INTO year (year_id, year) VALUES (1, 2021), (2, 2020); CREATE TABLE donations (donation_id INT, amount INT, organization_id INT, year_id INT); INSERT INTO donations (donation_id, amount, organization_id, year_id) VALUES (1, 500, 1, 1), (2, 700, 1, 1), (3, 300, 2, 1); | What is the total amount of donations received by 'organization X' in the year 2021? | SELECT SUM(amount) FROM donations WHERE organization_id = 1 AND year_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE co_ownership(id INT, city TEXT, cost FLOAT); INSERT INTO co_ownership(id, city, cost) VALUES (1, 'Chicago', 300000.00), (2, 'Chicago', 400000.00); | What is the median co-ownership cost in Chicago? | SELECT MEDIAN(cost) FROM co_ownership WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_innovation (id INT PRIMARY KEY, country VARCHAR(50), year INT, innovation_category VARCHAR(50), expenditure FLOAT); | Delete all records from the 'defense_innovation' table where 'innovation_category' is 'Artificial Intelligence' | WITH cte AS (DELETE FROM defense_innovation WHERE innovation_category = 'Artificial Intelligence' RETURNING *) INSERT INTO defense_innovation SELECT * FROM cte; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_pricing (country VARCHAR(20), date DATETIME, daily_price FLOAT); INSERT INTO carbon_pricing (country, date, daily_price) VALUES ('Germany', '2021-01-01', 30.5), ('Germany', '2021-01-02', 31.2), ('France', '2021-01-01', 25.3), ('France', '2021-01-02', 26.1), ('Italy', '2021-01-01', 28.8), ('Italy', '2021-01-02', 29.6); | What is the average, minimum, and maximum daily carbon pricing in Germany, France, and Italy for January 2021? | SELECT country, AVG(daily_price) as avg_price, MIN(daily_price) as min_price, MAX(daily_price) as max_price FROM carbon_pricing WHERE country IN ('Germany', 'France', 'Italy') AND date >= '2021-01-01' AND date < '2021-02-01' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Faculty (FacultyID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10), Salary INT); INSERT INTO Faculty (FacultyID, Name, Department, Gender, Salary) VALUES (1, 'Alice', 'Engineering', 'Female', 80000); INSERT INTO Faculty (FacultyID, Name, Department, Gender, Salary) VALUES (2, 'Bob', 'Engineering', 'Male', 85000); | What is the average salary of male faculty members in the Engineering department? | SELECT AVG(Salary) FROM Faculty WHERE Department = 'Engineering' AND Gender = 'Male'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, district TEXT);CREATE TABLE lifelong_learning_programs (id INT, start_date DATE, end_date DATE);CREATE TABLE program_enrollment (student_id INT, program_id INT, enrollment_date DATE, end_date DATE); | What is the total number of hours spent by students in lifelong learning programs in each district? | SELECT students.district, SUM(DATEDIFF('day', program_enrollment.enrollment_date, program_enrollment.end_date)) as total_hours FROM students INNER JOIN program_enrollment ON students.id = program_enrollment.student_id INNER JOIN lifelong_learning_programs ON program_enrollment.program_id = lifelong_learning_programs.id GROUP BY students.district; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genetech', 'California', 50000000.00); | What is the average funding amount for biotech startups located in California? | SELECT AVG(funding) FROM startups WHERE location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (building_id INT, country VARCHAR(50), is_leed_certified BOOLEAN); INSERT INTO green_buildings (building_id, country, is_leed_certified) VALUES (1, 'USA', true), (2, 'Canada', false), (3, 'Mexico', true), (4, 'USA', true); | Find the percentage of green buildings in each country that are certified as LEED. | SELECT country, (COUNT(*) FILTER (WHERE is_leed_certified)) * 100.0 / COUNT(*) AS leed_certified_percentage FROM green_buildings GROUP BY country | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10)); INSERT INTO faculty (id, name, department, gender) VALUES (1, 'Alice', 'Computer Science', 'Female'); | What is the total amount of research grants awarded to female faculty in the Computer Science department? | SELECT SUM(amount) FROM research_grants WHERE faculty_id IN (SELECT id FROM faculty WHERE department = 'Computer Science' AND gender = 'Female'); | gretelai_synthetic_text_to_sql |
CREATE TABLE age_group (age_group_id INT, age_group TEXT); CREATE TABLE individual (individual_id INT, name TEXT, age INT, access_level TEXT, age_group_id INT); INSERT INTO age_group (age_group_id, age_group) VALUES (1, '0-17'), (2, '18-34'), (3, '35-54'), (4, '55+'); INSERT INTO individual (individual_id, name, age, access_level, age_group_id) VALUES (1, 'John Doe', 45, 'Limited', 3), (2, 'Jane Smith', 22, 'Full', 2); INSERT INTO individual (individual_id, name, age, access_level, age_group_id) VALUES (3, 'James Johnson', 19, 'Full', 2); | Identify the number of individuals in each age group that have limited access to digital tools in Sub-Saharan Africa. | SELECT age_group, COUNT(*) FROM individual INNER JOIN age_group ON individual.age_group_id = age_group.age_group_id WHERE access_level = 'Limited' AND region = 'Sub-Saharan Africa' GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), size FLOAT); | Add a new record to the 'habitats' table | INSERT INTO habitats (id, name, location, size) VALUES (1, 'Siberian Tiger Habitat', 'Russia', 15000.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (project_id INT, state TEXT, completion_date DATE); INSERT INTO green_buildings (project_id, state, completion_date) VALUES (1, 'Texas', '2022-01-01'), (2, 'Texas', '2021-12-31'), (3, 'New York', '2022-03-15'), (4, 'New York', '2021-06-28'); | How many more green building projects have been completed in Texas compared to New York? | SELECT COUNT(*) FILTER (WHERE state = 'Texas') - COUNT(*) FILTER (WHERE state = 'New York') FROM green_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE Albums (AlbumID INT PRIMARY KEY AUTO_INCREMENT, Title VARCHAR(100));CREATE TABLE Songs (SongID INT PRIMARY KEY AUTO_INCREMENT, Title VARCHAR(100), Duration INT, AlbumID INT, FOREIGN KEY (AlbumID) REFERENCES Albums(AlbumID)); | Add a new song to album with ID 1 named 'Rise' with a duration of 205 seconds | INSERT INTO Songs (Title, Duration, AlbumID) VALUES ('Rise', 205, 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_positions (id INT, name VARCHAR(50), salary DECIMAL(10, 2)); CREATE TABLE employees (id INT, name VARCHAR(50), dept_id INT, position_id INT); | How many employees are there in each position without a salary greater than $100000? | SELECT e.position, COUNT(*) as num_employees FROM employee_positions e JOIN employees em ON em.id = e.id HAVING SUM(em.salary) <= 100000 GROUP BY e.position; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name VARCHAR(255), category VARCHAR(255), carbon_offsets FLOAT); INSERT INTO green_buildings (id, name, category, carbon_offsets) VALUES (1, 'Solar Tower 1', 'solar', 500.0); INSERT INTO green_buildings (id, name, category, carbon_offsets) VALUES (2, 'Solar Tower 2', 'solar', 800.0); INSERT INTO green_buildings (id, name, category, carbon_offsets) VALUES (3, 'Solar Tower 3', 'solar', 1000.0); | What is the total carbon offset of green building projects in the 'solar' category, partitioned by the name of the projects? | SELECT name, SUM(carbon_offsets) OVER (PARTITION BY name) AS total_carbon_offsets FROM green_buildings WHERE category = 'solar'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_info (id INT, name VARCHAR(50), category VARCHAR(50), cost INT); INSERT INTO project_info (id, name, category, cost) VALUES (1, 'Test1', 'Environment', 800000); | List all projects with costs higher than the avg cost of 'Environment' projects. | SELECT * FROM project_info WHERE cost > (SELECT AVG(cost) FROM project_info WHERE category = 'Environment'); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, LGBTQ VARCHAR(5), CulturalCompetencyScore INT); INSERT INTO CommunityHealthWorkers (WorkerID, LGBTQ, CulturalCompetencyScore) VALUES (1, 'Yes', 80), (2, 'No', 85), (3, 'Yes', 70), (4, 'No', 90); | Identify the number of community health workers who identify as LGBTQ+, by cultural competency score quartile. | SELECT CulturalCompetencyScoreQuartile, COUNT(*) as Count FROM (SELECT CulturalCompetencyScore, NTILE(4) OVER (ORDER BY CulturalCompetencyScore) as CulturalCompetencyScoreQuartile, LGBTQ FROM CommunityHealthWorkers) as Data WHERE LGBTQ = 'Yes' GROUP BY CulturalCompetencyScoreQuartile; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tours (id INT, operator_id INT, date DATE, revenue DECIMAL(10, 2), cultural_heritage BOOLEAN); | What is the maximum revenue generated by a single cultural heritage tour in Africa, in the year 2022? | SELECT MAX(revenue) FROM Tours WHERE cultural_heritage = TRUE AND YEAR(date) = 2022 AND country IN ('Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousVehicles (Make VARCHAR(50), Model VARCHAR(50), Year INT, Area VARCHAR(50), Distance DECIMAL(5,2), Sales INT); | What is the average distance traveled by autonomous vehicles in urban areas? | SELECT AVG(Distance) AS AvgDistance FROM AutonomousVehicles WHERE Area = 'Urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_development (id INT, name VARCHAR(50), age INT, subject VARCHAR(50)); | Who is the oldest teacher in the teacher_development table? | SELECT name, age FROM teacher_development ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (player_id INT, name VARCHAR(255), age INT, game_genre VARCHAR(255), country VARCHAR(255)); INSERT INTO Players (player_id, name, age, game_genre, country) VALUES (1, 'John', 27, 'FPS', 'USA'), (2, 'Sarah', 30, 'RPG', 'Canada'), (3, 'Alex', 22, 'FPS', 'USA'), (4, 'Max', 25, 'FPS', 'Canada'), (5, 'Zoe', 28, 'FPS', 'Mexico'), (6, 'Ella', 24, 'MOBA', 'Brazil'); | What are the game genres and countries of players who are 25 or older? | SELECT game_genre, country FROM Players WHERE age >= 25; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT, name VARCHAR(255), habitat_depth FLOAT, biomass FLOAT); INSERT INTO species (id, name, habitat_depth, biomass) VALUES (1, 'Clownfish', 2.0, 0.001), (2, 'Blue Whale', 1000.0, 150000.0), (3, 'Jellyfish', 50.0, 0.01); CREATE TABLE habitats (id INT, depth FLOAT, location VARCHAR(255)); INSERT INTO habitats (id, depth, location) VALUES (1, 100.0, 'Pacific Ocean'), (2, 3000.0, 'Atlantic Ocean'); CREATE VIEW species_habitats AS SELECT species.name, species.biomass, habitats.depth FROM species INNER JOIN habitats ON species.habitat_depth = habitats.depth; | What is the total biomass of all marine species in a given habitat? | SELECT SUM(biomass) FROM species_habitats; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, office VARCHAR(50)); INSERT INTO attorneys VALUES (1, 'Dallas'); CREATE TABLE cases (case_id INT, attorney_id INT, case_outcome VARCHAR(10)); | Who is the attorney with the most cases won in the 'Dallas' office? | SELECT attorneys.name, COUNT(*) AS cases_won FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.office = 'Dallas' AND case_outcome = 'won' GROUP BY attorneys.name ORDER BY cases_won DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE baseball_hits (player VARCHAR(50), team VARCHAR(50), homeruns INT); INSERT INTO baseball_hits (player, team, homeruns) VALUES ('Aaron Judge', 'New York Yankees', 30), ('Mike Trout', 'Los Angeles Angels', 25), ('Juan Soto', 'Washington Nationals', 20); | Who has the highest number of home runs in the 'baseball_hits' table? | SELECT player, MAX(homeruns) FROM baseball_hits; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (site_id INT, name VARCHAR(255), city VARCHAR(255), type VARCHAR(255)); INSERT INTO cultural_sites (site_id, name, city, type) VALUES (1, 'Notre-Dame', 'Paris', 'historical'), (2, 'Louvre Museum', 'Paris', 'art'), (3, 'Colosseum', 'Rome', 'historical'); | List the number of cultural heritage sites in Paris and Rome. | SELECT city, COUNT(*) FROM cultural_sites WHERE city IN ('Paris', 'Rome') AND type = 'historical' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (date DATE, temperature FLOAT); INSERT INTO arctic_weather (date, temperature) VALUES ('2020-07-01', 15.0), ('2020-07-02', 10.0), ('2020-07-03', 12.0); | What is the minimum temperature recorded in the 'arctic_weather' table for the month of July? | SELECT MIN(temperature) FROM arctic_weather WHERE EXTRACT(MONTH FROM date) = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location_id INT, location VARCHAR(100), level FLOAT); INSERT INTO ocean_acidification (location_id, location, level) VALUES (1, 'Pacific Ocean', 8.2); INSERT INTO ocean_acidification (location_id, location, level) VALUES (2, 'Atlantic Ocean', 7.9); | What is the maximum ocean acidification level recorded? | SELECT MAX(level) FROM ocean_acidification; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (site_id INT, name VARCHAR(255), continent VARCHAR(255)); CREATE VIEW site_summary AS SELECT continent, COUNT(site_id) as site_count FROM heritage_sites GROUP BY continent; | Show the number of cultural heritage sites in each continent. | SELECT continent, site_count FROM site_summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE asteroids (id INT, discovery_date DATE, discoverer_country VARCHAR(255)); | How many asteroids have been discovered by observatories in the USA and Europe? | SELECT COUNT(*) FROM asteroids WHERE discoverer_country IN ('USA', 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservationByRegion (id INT, region VARCHAR(255), method VARCHAR(255)); INSERT INTO LanguagePreservationByRegion (id, region, method) VALUES (1, 'Africa', 'Translation'), (2, 'Asia', 'Documentation'), (3, 'Europe', 'Education'), (4, 'Oceania', 'Revitalization'), (5, 'Africa', 'Media'), (6, 'Asia', 'Translation'), (7, 'Europe', 'Legislation'); | What is the most common language preservation method in Oceania? | SELECT region, method FROM (SELECT region, method, RANK() OVER(PARTITION BY region ORDER BY COUNT(*) DESC) as rank FROM LanguagePreservationByRegion GROUP BY region, method) as ranked WHERE rank = 1 AND region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), CuisineType varchar(50), Location varchar(50), TotalRevenue numeric(12, 2)); INSERT INTO Restaurants (RestaurantID, Name, CuisineType, Location, TotalRevenue) VALUES (1, 'Asian Fusion', 'Asian', 'New York', 500000), (2, 'Bella Italia', 'Italian', 'Los Angeles', 750000), (3, 'Sushi House', 'Japanese', 'San Francisco', 600000); | What is the total revenue generated by each cuisine type, ordered by the total revenue in descending order? | SELECT CuisineType, SUM(TotalRevenue) as TotalRevenue FROM Restaurants GROUP BY CuisineType ORDER BY TotalRevenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholder (ID INT, Name VARCHAR(50), Insurance_Type VARCHAR(20)); INSERT INTO Policyholder (ID, Name, Insurance_Type) VALUES (1, 'John Doe', 'Auto'), (2, 'Jane Smith', 'Home'), (3, 'Mike Johnson', 'Auto'), (4, 'Sara Williams', 'Home'), (5, 'David Brown', 'Auto'), (6, 'Michelle Garcia', 'Auto, Home'); | List all policyholders who have both auto and home insurance policies. | SELECT DISTINCT Name FROM Policyholder WHERE Insurance_Type = 'Auto' INTERSECT SELECT DISTINCT Name FROM Policyholder WHERE Insurance_Type = 'Home'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameName VARCHAR(50), Playtime INT); CREATE TABLE Games (GameID INT, GameName VARCHAR(50)); INSERT INTO Games VALUES (1, 'League of Legends'); | List all players who have played 'League of Legends' and their total playtime | SELECT p.PlayerID, SUM(p.Playtime) as TotalPlaytime FROM PlayerGames p INNER JOIN Games g ON p.GameID = g.GameID WHERE g.GameName = 'League of Legends' GROUP BY p.PlayerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, mine_id INT, year INT, element TEXT, production_quantity INT); INSERT INTO production (id, mine_id, year, element, production_quantity) VALUES (1, 1, 2017, 'Holmium', 100), (2, 2, 2017, 'Holmium', 150), (3, 3, 2017, 'Holmium', 200), (4, 1, 2017, 'Dysprosium', 200), (5, 2, 2017, 'Dysprosium', 250), (6, 3, 2017, 'Dysprosium', 300); | What is the total production quantity (in metric tons) of Holmium from the mine with the ID 1 for the year 2017? | SELECT SUM(production_quantity) FROM production WHERE mine_id = 1 AND year = 2017 AND element = 'Holmium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEngagement (id INT, group_id INT, location VARCHAR(50), type VARCHAR(50));CREATE TABLE LanguagePreservationGroups (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO CommunityEngagement (id, group_id, location, type) VALUES (1, 101, 'France', 'Workshop'), (2, 101, 'Italy', 'Festival'), (3, 102, 'France', 'Festival'), (4, 102, 'Italy', 'Workshop'), (5, 103, 'Spain', 'Conference'); INSERT INTO LanguagePreservationGroups (id, name, location) VALUES (101, 'Breton Language Group', 'France'), (102, 'Sicilian Language Group', 'Italy'), (103, 'Catalan Language Group', 'Spain'); | Find the number of unique community engagement events and their corresponding types at each language preservation group location. | SELECT lpg.location, COUNT(DISTINCT ce.type) as num_events, ce.type FROM CommunityEngagement ce INNER JOIN LanguagePreservationGroups lpg ON ce.group_id = lpg.id GROUP BY lpg.location, ce.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE marinefinfish (country VARCHAR(20), temperature DECIMAL(5,2)); INSERT INTO marinefinfish (country, temperature) VALUES ('Norway', 12.5), ('Norway', 13.0), ('Norway', 11.8); | What is the average water temperature for marine finfish farms in Norway? | SELECT AVG(temperature) FROM marinefinfish WHERE country = 'Norway'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_revenue (ota_id INT, city TEXT, daily_revenue FLOAT, year INT); INSERT INTO ota_revenue (ota_id, city, daily_revenue, year) VALUES (1, 'New York', 2000, 2023), (2, 'New York', 2500, 2023), (3, 'Los Angeles', 1800, 2023); | What is the average daily revenue for OTAs in 'New York' in 2023? | SELECT AVG(daily_revenue) FROM ota_revenue WHERE city = 'New York' AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT);CREATE TABLE shipments (shipment_id INT, shipment_weight INT, ship_date DATE, port_id INT); INSERT INTO ports VALUES (1, 'Port of Oakland', 'USA'), (2, 'Port of Vancouver', 'Canada'); INSERT INTO shipments VALUES (1, 2000, '2022-01-01', 1), (2, 1500, '2022-02-15', 2); | What is the total weight of containers shipped from the Port of Oakland to Canada in Q1 of 2022? | SELECT SUM(shipment_weight) FROM shipments JOIN ports ON shipments.port_id = ports.port_id WHERE ports.country = 'Canada' AND ports.port_name = 'Port of Vancouver' AND ship_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, event_name TEXT, event_category TEXT, funding_source TEXT); INSERT INTO events (id, event_name, event_category, funding_source) VALUES (1, 'Symphony Concert', 'music', 'Foundation X'), (2, 'Ballet Performance', 'dance', 'Foundation Y'); | How many unique funding sources support events in the 'music' and 'dance' categories? | SELECT COUNT(DISTINCT funding_source) FROM events WHERE event_category IN ('music', 'dance'); | gretelai_synthetic_text_to_sql |
CREATE TABLE donor (id INT, name VARCHAR(255)); INSERT INTO donor (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Bob Johnson'); CREATE TABLE donation (id INT, donor_id INT, program_id INT); INSERT INTO donation (id, donor_id, program_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 2), (4, 3, 1), (5, 3, 3); | List all unique donors who have donated to at least two different programs. | SELECT d.name FROM donor d INNER JOIN (SELECT donor_id FROM donation GROUP BY donor_id HAVING COUNT(DISTINCT program_id) >= 2) dd ON d.id = dd.donor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE gym_memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5,2), state VARCHAR(50)); | How many new members joined in each state for the year 2021? | SELECT state, COUNT(DISTINCT member_name) AS new_members FROM gym_memberships WHERE YEAR(start_date) = 2021 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE dives (dive_id INT, diver_name TEXT, depth FLOAT, temperature FLOAT, date DATE); | Update the 'dives' table to set the temperature to '15' degrees Celsius for the dive with dive_id '3'. | UPDATE dives SET temperature = 15 WHERE dive_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_features (id INT, hotel_name TEXT, location TEXT, ai_features INT, revenue FLOAT); INSERT INTO hotel_features (id, hotel_name, location, ai_features, revenue) VALUES (1, 'Hotel A', 'APAC', 5, 1200000), (2, 'Hotel B', 'Europe', 7, 900000), (3, 'Hotel C', 'Americas', 3, 800000), (4, 'Hotel D', 'APAC', 6, 1500000), (5, 'Hotel E', 'Africa', 4, 700000); | What is the total revenue generated by hotels in the APAC region with AI-powered features? | SELECT SUM(revenue) FROM hotel_features WHERE location = 'APAC' AND ai_features > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE audience (id INT, gender VARCHAR(10), age INT, location VARCHAR(50), interests VARCHAR(100)); INSERT INTO audience (id, gender, age, location, interests) VALUES (1, 'Male', 25, 'New York', 'Sports'); INSERT INTO audience (id, gender, age, location, interests) VALUES (2, 'Female', 35, 'California', 'Entertainment'); INSERT INTO audience (id, gender, age, location, interests) VALUES (3, 'Male', 45, 'Texas', 'Politics'); INSERT INTO audience (id, gender, age, location, interests) VALUES (4, 'Female', 50, 'Chicago', 'Science'); | How many unique locations are represented in the 'audience' table? | SELECT COUNT(DISTINCT location) FROM audience; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers', 12.99); INSERT INTO menus VALUES (2, 'Beef Burger', 'Entrees', 15.99); INSERT INTO menus VALUES (3, 'Chocolate Cake', 'Desserts', 8.99); CREATE TABLE sales (sale_id INT, menu_id INT, quantity INT, country VARCHAR(255)); | What are the most popular menu items in each country? | SELECT m.item, s.country, SUM(s.quantity) as total_sold FROM menus m INNER JOIN sales s ON m.menu_id = s.menu_id GROUP BY m.item, s.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY, Title VARCHAR(100), City VARCHAR(100), StartDate DATE, EndDate DATE, ArtWorkID INT, FOREIGN KEY (ArtWorkID) REFERENCES ArtWorks(ArtWorkID)); INSERT INTO Exhibitions (ExhibitionID, Title, City, StartDate, EndDate, ArtWorkID) VALUES (1, 'Artistic Revolutions', 'Paris', '2020-01-01', '2020-03-31', 1); INSERT INTO Exhibitions (ExhibitionID, Title, City, StartDate, EndDate, ArtWorkID) VALUES (2, 'Artistic Revolutions', 'Berlin', '2020-04-01', '2020-06-30', 1); CREATE TABLE ArtWorks (ArtWorkID INT PRIMARY KEY, Title VARCHAR(100)); INSERT INTO ArtWorks (ArtWorkID, Title) VALUES (1, 'The Scream'); | Identify artworks that have been exhibited in both Paris and Berlin. | SELECT ArtWorks.Title FROM ArtWorks INNER JOIN Exhibitions ON ArtWorks.ArtWorkID = Exhibitions.ArtWorkID WHERE Exhibitions.City IN ('Paris', 'Berlin') GROUP BY ArtWorks.Title HAVING COUNT(DISTINCT Exhibitions.City) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (country VARCHAR(255), investment_amount INT); INSERT INTO climate_finance (country, investment_amount) VALUES ('Canada', 1200000), ('Mexico', 800000), ('Brazil', 1500000); | What is the total amount of climate finance invested by country? | SELECT country, SUM(investment_amount) as total_investment FROM climate_finance GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (project_name VARCHAR(255), start_date DATE, end_date DATE); CREATE TABLE construction_projects (project_name VARCHAR(255), contractor_name VARCHAR(255)); | What is the average project duration in months for each contractor in the 'project_timeline' and 'construction_projects' tables? | select cp.contractor_name, avg(months_between(pt.start_date, pt.end_date)) as avg_duration from project_timeline pt inner join construction_projects cp on pt.project_name = cp.project_name group by cp.contractor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255)); INSERT INTO restaurants (id, name) VALUES (1, 'Restaurant A'), (2, 'Restaurant B'); CREATE TABLE dishes (id INT, name VARCHAR(255), type VARCHAR(255), revenue INT, restaurant_id INT); INSERT INTO dishes (id, name, type, revenue, restaurant_id) VALUES (1, 'Quinoa Salad', 'vegetarian', 500, 1), (2, 'Chickpea Curry', 'vegetarian', 800, 1), (3, 'Cheeseburger', 'non-vegetarian', 1200, 1), (4, 'Pizza Margherita', 'vegetarian', 700, 2), (5, 'Fish and Chips', 'non-vegetarian', 1500, 2); | Find the total revenue for vegetarian dishes across all restaurants. | SELECT SUM(revenue) FROM dishes WHERE type = 'vegetarian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name TEXT, conservation_status TEXT); CREATE TABLE ocean_acidification_impact (id INT, species_id INT, PRIMARY KEY (id, species_id), FOREIGN KEY (species_id) REFERENCES marine_species(id)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1, 'Coral', 'Vulnerable'), (2, 'Salmon', 'Least Concern'), (3, 'Sea Turtle', 'Endangered'); INSERT INTO ocean_acidification_impact (id, species_id) VALUES (1, 1), (2, 3); | Identify all marine species that have been impacted by ocean acidification and their conservation status. | SELECT marine_species.species_name, marine_species.conservation_status FROM marine_species INNER JOIN ocean_acidification_impact ON marine_species.id = ocean_acidification_impact.species_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, policy_name VARCHAR(255), last_updated TIMESTAMP); INSERT INTO policies (id, policy_name, last_updated) VALUES (1, 'Incident Response Policy', '2021-01-01 00:00:00'), (2, 'Access Control Policy', '2022-02-15 12:34:56'), (3, 'Password Policy', '2022-02-22 10:00:00'); | List all policies that have been updated in the last week. | SELECT * FROM policies WHERE last_updated >= NOW() - INTERVAL 1 WEEK; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streams (location TEXT, genre TEXT, num_streams INTEGER, num_concerts INTEGER); INSERT INTO Streams (location, genre, num_streams, num_concerts) VALUES ('New York', 'Pop', 500000, 100), ('New York', 'Rock', 600000, 150), ('Los Angeles', 'Jazz', 400000, 75), ('Los Angeles', 'Pop', 700000, 200); | Identify the top 3 genres with the highest average number of streams per concert in New York and Los Angeles. | SELECT genre, AVG(num_streams/num_concerts) as avg_streams_per_concert FROM Streams WHERE location IN ('New York', 'Los Angeles') GROUP BY genre ORDER BY AVG(num_streams/num_concerts) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, player_id INT, game_date DATE, wins INT); CREATE TABLE players (player_id INT, player_country VARCHAR(255)); | What is the maximum number of wins for a player from Brazil, for games that started in the last 30 days? | SELECT MAX(wins) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'Brazil' AND games.game_date >= (CURRENT_DATE - INTERVAL '30' DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE Ingredients (IngredientID int, IngredientName varchar(50), Sustainable bit); INSERT INTO Ingredients (IngredientID, IngredientName, Sustainable) VALUES (1, 'Quinoa', 1); INSERT INTO Ingredients (IngredientID, IngredientName, Sustainable) VALUES (2, 'Falafel', 0); INSERT INTO Ingredients (IngredientID, IngredientName, Sustainable) VALUES (3, 'Tofu', 1); CREATE TABLE Dishes (DishID int, DishName varchar(50), IngredientID int); INSERT INTO Dishes (DishID, DishName, IngredientID) VALUES (1, 'Quinoa Salad', 1); INSERT INTO Dishes (DishID, DishName, IngredientID) VALUES (2, 'Falafel Wrap', 2); INSERT INTO Dishes (DishID, DishName, IngredientID) VALUES (3, 'Tofu Stir Fry', 3); CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(50), City varchar(50), Sustainable bit); INSERT INTO Restaurants (RestaurantID, RestaurantName, City, Sustainable) VALUES (1, 'The Green Garden', 'New York', 1); INSERT INTO Restaurants (RestaurantID, RestaurantName, City, Sustainable) VALUES (2, 'Healthy Bites', 'Los Angeles', 0); | List all sustainable ingredients and their associated dishes, considering only dishes served at restaurants in New York with sustainable sourcing practices. | SELECT D.DishName, I.IngredientName, I.Sustainable FROM Dishes D JOIN Ingredients I ON D.IngredientID = I.IngredientID JOIN Restaurants R ON D.RestaurantID = R.RestaurantID WHERE R.City = 'New York' AND R.Sustainable = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE paris_impact (site_id INT, name VARCHAR(255), type VARCHAR(255), local_impact DECIMAL(10,2)); INSERT INTO paris_impact (site_id, name, type, local_impact) VALUES (1, 'Notre-Dame', 'historical', 5000.00), (2, 'Louvre Museum', 'art', 7000.00); | What is the average local economic impact of sustainable tourism in Paris? | SELECT AVG(local_impact) FROM paris_impact WHERE type = 'historical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT); INSERT INTO patients (id, name, age, treatment) VALUES (1, 'Alice', 35, 'CBT'), (2, 'Bob', 42, 'DBT'), (3, 'John', 50, 'Mindfulness'); | Update the treatment for patient 'Alice' to 'DBT' in the 'patients' table. | UPDATE patients SET treatment = 'DBT' WHERE name = 'Alice'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_projects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), offset_tons_co2 INT, start_date DATE, end_date DATE); | Delete carbon offset project 'y' | DELETE FROM carbon_offset_projects WHERE project_name = 'y'; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name VARCHAR(50), gender VARCHAR(10)); CREATE TABLE companies (id INT, founder_id INT, name VARCHAR(50)); INSERT INTO founders VALUES (1, 'Alice', 'Female'); INSERT INTO founders VALUES (2, 'Bob', 'Male'); INSERT INTO companies VALUES (1, 1, 'Ada Tech'); INSERT INTO companies VALUES (2, 1, 'Eve Inc'); INSERT INTO companies VALUES (3, 2, 'Beta Corp'); | List female founders and the number of companies they've established | SELECT founders.name, COUNT(companies.id) FROM founders INNER JOIN companies ON founders.id = companies.founder_id WHERE founders.gender = 'Female' GROUP BY founders.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocation (service VARCHAR(20), city VARCHAR(20), budget INT); INSERT INTO BudgetAllocation (service, city, budget) VALUES ('Education', 'Oakland', 30000000), ('Healthcare', 'Oakland', 40000000); | What is the total budget allocated for education and healthcare services in the City of Oakland? | SELECT SUM(budget) FROM BudgetAllocation WHERE city = 'Oakland' AND service IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE EV_Adoption (id INT, country VARCHAR(50), adoption_rate FLOAT); | What is the adoption rate of electric vehicles in China compared to the US? | SELECT country, adoption_rate FROM EV_Adoption WHERE country IN ('China', 'US') ORDER BY adoption_rate DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, product TEXT, quantity INT, date DATE); INSERT INTO sales (id, product, quantity, date) VALUES (1, 'eggs', 12, '2021-01-01'), (2, 'milk', 24, '2021-01-05'), (3, 'eggs', 18, '2021-01-07'), (4, 'flour', 36, '2021-01-10'); | What is the total weight of all eggs sold last month? | SELECT SUM(quantity) FROM sales WHERE product = 'eggs' AND date BETWEEN '2021-01-01' AND '2021-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vendor_materials (id INT PRIMARY KEY, brand VARCHAR(255), vendor VARCHAR(255), material_type VARCHAR(255), quantity INT); INSERT INTO vendor_materials (id, brand, vendor, material_type, quantity) VALUES (1, 'EcoFriendlyFashions', 'Vendor1', 'Organic Cotton', 2000), (2, 'EcoFriendlyFashions', 'Vendor2', 'Recycled Polyester', 1500), (3, 'GreenFashions', 'Vendor3', 'Organic Cotton', 1000), (4, 'GreenFashions', 'Vendor4', 'Tencel', 2000); | List all vendors that the ethical fashion brand 'EcoFriendlyFashions' sources sustainable materials from, along with the total quantity of materials sourced from each vendor. | SELECT vm.vendor, SUM(vm.quantity) as total_quantity FROM vendor_materials vm WHERE vm.brand = 'EcoFriendlyFashions' GROUP BY vm.vendor; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), PlayVR INT, TotalRevenue INT); INSERT INTO Players (PlayerID, Age, Gender, PlayVR, TotalRevenue) VALUES (1, 30, 'Female', 1, 5000); INSERT INTO Players (PlayerID, Age, Gender, PlayVR, TotalRevenue) VALUES (2, 25, 'Male', 0, 4000); INSERT INTO Players (PlayerID, Age, Gender, PlayVR, TotalRevenue) VALUES (3, 35, 'Non-binary', 1, 6000); INSERT INTO Players (PlayerID, Age, Gender, PlayVR, TotalRevenue) VALUES (4, 28, 'Male', 1, 7000); INSERT INTO Players (PlayerID, Age, Gender, PlayVR, TotalRevenue) VALUES (5, 40, 'Female', 0, 8000); | What is the average age of players who play VR games and their total revenue? | SELECT AVG(Players.Age), SUM(Players.TotalRevenue) FROM Players WHERE Players.PlayVR = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableBuildings (id INT, project_value INT, state VARCHAR(20)); INSERT INTO SustainableBuildings (id, project_value, state) VALUES (1, 500000, 'Illinois'), (2, 300000, 'California'); | What is the total value of sustainable building projects in Illinois? | SELECT SUM(project_value) FROM SustainableBuildings WHERE state = 'Illinois'; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_code CHAR(2), region_name VARCHAR(50)); INSERT INTO region VALUES ('NA', 'North America'), ('EU', 'Europe'); CREATE TABLE visit_summary (region_code CHAR(2), year INT, visitor_count INT); INSERT INTO visit_summary VALUES ('NA', 2020, 1000), ('NA', 2019, 1200), ('EU', 2020, 2000), ('EU', 2019, 2500); | How many tourists visited each region in 2020? | SELECT region_code, SUM(visitor_count) OVER (PARTITION BY region_code) FROM visit_summary WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), level INT); | Delete records from the 'players' table where the 'country' is 'Canada' | DELETE FROM players WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergencies (id INT, city VARCHAR(20), type VARCHAR(20), date DATE); INSERT INTO emergencies (id, city, type, date) VALUES (1, 'Los Angeles', 'emergency', '2021-01-01'); INSERT INTO emergencies (id, city, type, date) VALUES (2, 'Los Angeles', 'fire', '2021-01-02'); | What is the total number of emergency calls and fire incidents in the city of Los Angeles? | SELECT SUM(calls) FROM (SELECT COUNT(*) AS calls FROM emergencies WHERE city = 'Los Angeles' AND type = 'emergency' UNION ALL SELECT COUNT(*) AS calls FROM emergencies WHERE city = 'Los Angeles' AND type = 'fire') AS total | gretelai_synthetic_text_to_sql |
CREATE TABLE route (id INT, name TEXT, type TEXT, length FLOAT, fare FLOAT); INSERT INTO route (id, name, type, length, fare) VALUES (1, 'Central Line', 'Underground', 25.3, 3.5), (2, 'Circle Line', 'Underground', 22.8, 4.2), (3, 'Jubilee Line', 'Underground', 36.2, 5.0), (4, 'Bus Route 123', 'Bus', 12.5, 2.5), (5, 'Bus Route 456', 'Bus', 20.0, 3.0); | What is the average fare for each route in the 'route' table, grouped by route type? | SELECT type, AVG(fare) as avg_fare FROM route GROUP BY type; | 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.