context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE public.water_usage ( id SERIAL PRIMARY KEY, location VARCHAR(255), date DATE, usage FLOAT); | Create a table named 'water_usage' | CREATE TABLE public.water_usage ( id SERIAL PRIMARY KEY, location VARCHAR(255), date DATE, usage FLOAT); | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, studio_country VARCHAR(50), rating DECIMAL(3,2)); | What is the average rating of movies produced by studios located in Africa? | SELECT AVG(rating) FROM movies WHERE studio_country IN ('Nigeria', 'South Africa', 'Egypt'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinics (id INT, name VARCHAR(50), location VARCHAR(50), num_workers INT, avg_age INT); | What is the number of healthcare workers in each location in the "rural_clinics" table? | SELECT location, COUNT(num_workers) FROM rural_clinics GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (SessionID INT, PlayerID INT, Game TEXT, Duration INT, SessionDate DATE); INSERT INTO GameSessions (SessionID, PlayerID, Game, Duration, SessionDate) VALUES (1, 1, 'Cosmic Crusaders', 60, '2022-01-01'), (2, 2, 'Cosmic Crusaders', 45, '2022-01-05'), (3, 3, 'Cosmic Crusaders', 70, '2022-01-10'); | Count the number of players who have played more than 50 hours in the game "Cosmic Crusaders" in the month of January 2022. | SELECT COUNT(*) FROM GameSessions WHERE Game = 'Cosmic Crusaders' AND Duration > 50 AND EXTRACT(MONTH FROM SessionDate) = 1 AND EXTRACT(YEAR FROM SessionDate) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Space_Missions (MissionId INT, Name VARCHAR, Launch_Date DATE, Status VARCHAR, Objective TEXT); | Insert new space missions into the Space_Missions table. | WITH new_missions AS (VALUES (1, 'Artemis I', '2022-08-29', 'Planned', 'Uncrewed lunar flyby'), (2, 'Artemis II', '2023-11-01', 'Planned', 'Crewed lunar flyby')) INSERT INTO Space_Missions (MissionId, Name, Launch_Date, Status, Objective) SELECT * FROM new_missions; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (province text, type text, year integer, stations integer); | How many electric vehicle charging stations were installed in each province in Canada, by type, from 2016 to 2021? | SELECT province, type, SUM(stations) as total_stations FROM charging_stations WHERE year BETWEEN 2016 AND 2021 AND province = 'Canada' GROUP BY province, type; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (incident_id INT, incident_date DATE, country TEXT, incident_type TEXT); INSERT INTO safety_incidents (incident_id, incident_date, country, incident_type) VALUES (1, '2021-01-15', 'USA', 'Chemical Spill'), (2, '2021-02-20', 'Canada', 'Fire'), (3, '2021-03-05', 'Mexico', 'Equipment Failure'... | Find the top 2 countries with the highest safety incident rate in the past year, partitioned by month. | SELECT country, COUNT(*) AS incidents, EXTRACT(MONTH FROM incident_date) AS month FROM safety_incidents WHERE incident_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY country, month ORDER BY incidents DESC FETCH FIRST 2 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE civil_cases (case_id INT, case_county VARCHAR(20)); CREATE TABLE dispute_resolution (case_id INT, resolution_type VARCHAR(20)); | How many alternative dispute resolution methods were used for civil cases in each county? | SELECT cc.case_county, COUNT(dr.resolution_type) FROM civil_cases cc INNER JOIN dispute_resolution dr ON cc.case_id = dr.case_id GROUP BY cc.case_county; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_ethics_complaints (organization VARCHAR(255), region VARCHAR(255), year INT, num_complaints INT); INSERT INTO ai_ethics_complaints (organization, region, year, num_complaints) VALUES ('Organization A', 'Saudi Arabia', 2018, 20), ('Organization B', 'United Arab Emirates', 2019, 25), ('Organization C', 'E... | What is the maximum number of AI ethics complaints received by organizations in the Middle East and North Africa region, and which organization received it? | SELECT MAX(num_complaints) as max_complaints, organization FROM ai_ethics_complaints WHERE region = 'Middle East and North Africa' GROUP BY organization HAVING max_complaints = (SELECT MAX(num_complaints) FROM ai_ethics_complaints WHERE region = 'Middle East and North Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Cybersecurity (Strategy_Name VARCHAR(255), Budget INT, Fiscal_Year INT); INSERT INTO Cybersecurity (Strategy_Name, Budget, Fiscal_Year) VALUES ('Endpoint Protection', 5000000, 2022); INSERT INTO Cybersecurity (Strategy_Name, Budget, Fiscal_Year) VALUES ('Network Security', 7000000, 2022); | List all cybersecurity strategies and their respective budgets from the 'Cybersecurity' table | SELECT * FROM Cybersecurity; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), founding_year INT); INSERT INTO companies (id, name, sector, founding_year) VALUES (1, 'Johnson & Johnson', 'Healthcare', 1886), (2, 'Pfizer', 'Healthcare', 1849), (3, 'Tesla', 'Automotive', 2003); | How many companies were founded before 2010 in the healthcare sector? | SELECT COUNT(*) FROM companies WHERE sector = 'Healthcare' AND founding_year < 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_gardens (id INT, region VARCHAR(10), crop VARCHAR(20), yield INT); | List all the crops and their yields from 'urban_gardens' table for region '02' | SELECT crop, yield FROM urban_gardens WHERE region = '02'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Contracts (ContractID INT, ContractType VARCHAR(50), ContractAmount DECIMAL(10,2), MilitaryBranch VARCHAR(50), PRIMARY KEY (ContractID)); CREATE TABLE Vendors (VendorID INT, VendorName VARCHAR(50), VendorLocation VARCHAR(50), ContactPerson VARCHAR(50)); CREATE TABLE Employees (EmployeeID INT, EmployeeName ... | Who are the vendors and their corresponding employee names who have been involved in the awarding of cybersecurity contracts? | SELECT Vendors.VendorName, Employees.EmployeeName FROM Contracts INNER JOIN Vendors ON Contracts.MilitaryBranch = Vendors.VendorLocation INNER JOIN Employees ON Vendors.VendorID = Employees.VendorID WHERE ContractType = 'Cybersecurity Contract'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(100), launch_date DATE, type VARCHAR(50)); | List all the debris types in the space_debris table | SELECT DISTINCT type FROM space_debris; | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (DepartmentID INT PRIMARY KEY, DepartmentName VARCHAR(50)); CREATE TABLE Universities (UniversityID INT PRIMARY KEY, UniversityName VARCHAR(50)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMARY KEY, UniversityID INT, DepartmentID INT, BudgetForDisabilityAccommodations DEC... | What is the maximum budget allocated for disability accommodations in each department? | SELECT d.DepartmentName, MAX(ud.BudgetForDisabilityAccommodations) as MaxBudget FROM Departments d JOIN UniversityDepartments ud ON d.DepartmentID = ud.DepartmentID GROUP BY d.DepartmentName; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), age INT); INSERT INTO employees (id, name, department, age) VALUES (1, 'John Doe', 'Marketing', 35), (2, 'Jane Smith', 'Marketing', 28); | What is the average age of employees in the marketing department? | SELECT AVG(age) FROM employees WHERE department = 'Marketing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_gender (student_id INT, gender TEXT, total_open_pedagogy_hours INT); INSERT INTO open_pedagogy_gender (student_id, gender, total_open_pedagogy_hours) VALUES (1, 'Female', 30), (2, 'Male', 45), (3, 'Female', 60); | What is the total number of hours spent on open pedagogy projects by students in each gender group? | SELECT gender, SUM(total_open_pedagogy_hours) FROM open_pedagogy_gender GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (year INT, category VARCHAR(255), amount INT); INSERT INTO budget (year, category, amount) VALUES (2018, 'Education', 50000), (2018, 'Transport', 70000), (2019, 'Education', 55000), (2019, 'Transport', 80000), (2020, 'Education', 60000), (2020, 'Transport', 90000), (2021, 'Education', 65000), (2021,... | Find the total amount of money spent on public transportation in 2020 and 2021? | SELECT SUM(amount) FROM budget WHERE category = 'Transport' AND year IN (2020, 2021) | gretelai_synthetic_text_to_sql |
CREATE TABLE shipment_deliveries(id INT, shipment_id INT, delivery_time INT); INSERT INTO shipment_deliveries(id, shipment_id, delivery_time) VALUES (1, 1, 7), (2, 2, 10), (3, 3, 8); | What is the earliest delivery time for shipments to Australia? | SELECT MIN(delivery_time) FROM shipment_deliveries JOIN shipments ON shipment_deliveries.shipment_id = shipments.id WHERE shipments.destination = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE program (id INT, name VARCHAR(50)); INSERT INTO program (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Arts & Culture'); CREATE TABLE donation (id INT, amount DECIMAL(10,2), program_id INT, donation_date DATE); | What is the total donation amount and average donation amount for the 'Arts & Culture' program in 2022? | SELECT d.program_id, SUM(d.amount) as total_donations, AVG(d.amount) as avg_donation_amount FROM donation d WHERE d.program_id = 3 AND YEAR(d.donation_date) = 2022 GROUP BY d.program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (StudentID INT, AccommodationType VARCHAR(50), AccommodationDate DATE); INSERT INTO Accommodations (StudentID, AccommodationType, AccommodationDate) VALUES (1, 'Sign Language Interpreter', '2021-01-01'); CREATE TABLE Students (StudentID INT, StudentName VARCHAR(50), GraduationYear INT); INSE... | What is the total number of students who received accommodations by accommodation type in 2021? | SELECT AccommodationType, COUNT(*) as Total FROM Accommodations WHERE YEAR(AccommodationDate) = 2021 GROUP BY AccommodationType; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, founder TEXT, community TEXT, funding FLOAT); INSERT INTO startups (id, name, founder, community, funding) VALUES (1, 'Acme', 'John Doe', 'Majority', 500000.00); INSERT INTO startups (id, name, founder, community, funding) VALUES (2, 'Beta Corp', 'Jane Smith', 'Underrepresented... | What is the average funding for startups founded by individuals from underrepresented communities? | SELECT AVG(funding) FROM startups WHERE community = 'Underrepresented'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bus_fares (fare_id INT, region_id INT, fare DECIMAL(5,2)); INSERT INTO bus_fares (fare_id, region_id, fare) VALUES (1, 1, 1.50), (2, 2, 2.25), (3, 3, 1.75), (4, 2, 2.25); | What is the maximum fare for buses in the 'south' region? | SELECT MAX(bf.fare) FROM bus_fares bf INNER JOIN regions r ON bf.region_id = r.region_id WHERE r.region_name = 'south'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FeedSupply (ID INT PRIMARY KEY, Supplier VARCHAR, SpeciesID INT, Quantity INT, DeliveryDate DATE, Cost FLOAT, FOREIGN KEY (SpeciesID) REFERENCES Species(ID)); INSERT INTO FeedSupply (ID, Supplier, SpeciesID, Quantity, DeliveryDate, Cost) VALUES (3, 'SustainableFeeds Inc.', 3, 700, '2022-04-01', 1200.00); | What is the average quantity and average cost of feed supplied to each species, grouped by species and month? | SELECT f.Name AS SpeciesName, f.Origin, fs.Supplier, AVG(fs.Quantity) AS AvgQuantity, AVG(fs.Cost) AS AvgCost, DATE_FORMAT(fs.DeliveryDate, '%%Y-%%m') AS Month FROM FeedSupply fs JOIN Species f ON fs.SpeciesID = f.ID GROUP BY f.Name, f.Origin, MONTH(fs.DeliveryDate), fs.Supplier; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (id INT, country TEXT, year INT, month INT, advisory_level INT); INSERT INTO travel_advisories (id, country, year, month, advisory_level) VALUES (1, 'Canada', 2022, 1, 2), (2, 'Canada', 2022, 2, 2), (3, 'Mexico', 2022, 3, 3); | How many travel advisories were issued for Canada in 2022? | SELECT COUNT(*) FROM travel_advisories WHERE country = 'Canada' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Clients (ClientID int, Name varchar(50), Division varchar(50)); INSERT INTO Clients (ClientID, Name, Division) VALUES (10, 'Alex Thompson', 'High Net Worth'), (11, 'Bella Chen', 'Retail'), (12, 'Charlie Lee', 'High Net Worth'); CREATE TABLE Transactions (TransactionID int, ClientID int, Amount decimal(10,2... | Who are the top 3 clients with the highest total transaction amounts in the 'Retail' division? | SELECT c.Name, SUM(t.Amount) as TotalTransactionAmount FROM Clients c INNER JOIN Transactions t ON c.ClientID = t.ClientID WHERE c.Division = 'Retail' GROUP BY c.Name ORDER BY TotalTransactionAmount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums (MuseumID int, MuseumName varchar(50), Country varchar(50), Website varchar(100)); INSERT INTO Museums (MuseumID, MuseumName, Country, Website) VALUES (1, 'Louvre Museum', 'France', 'https://www.louvre.fr'); INSERT INTO Museums (MuseumID, MuseumName, Country, Website) VALUES (2, 'British Museum', '... | List all museums in Europe with their respective websites. | SELECT MuseumName, Website FROM Museums WHERE Country = 'Europe' | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name TEXT, location TEXT, category TEXT); INSERT INTO heritage_sites (id, name, location, category) VALUES (1, 'Angkor Wat', 'Cambodia', 'Cultural'), (2, 'Borobudur', 'Indonesia', 'Cultural'), (3, 'Prambanan', 'Indonesia', 'Cultural'), (4, 'Temple of Preah Vihear', 'Cambodia', 'Cult... | Which countries in Southeast Asia have the most UNESCO heritage sites? | SELECT location, COUNT(*) FROM heritage_sites WHERE category = 'Cultural' GROUP BY location ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending (loan_id INT, issue_date DATE); INSERT INTO socially_responsible_lending (loan_id, issue_date) VALUES (1, '2021-02-01'), (2, '2021-05-15'), (3, '2022-03-09'); | How many socially responsible loans have been issued in the last 12 months? | SELECT COUNT(loan_id) FROM socially_responsible_lending WHERE issue_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE vessels (id INT, country_id INT, name TEXT, num_employees INT); INSERT INTO countries VALUES (1, 'Brazil'), (2, 'Argentina'), (3, 'Colombia'); INSERT INTO vessels VALUES (1, 1, 'Brazilian Vessel 1', 30), (2, 1, 'Brazilian Vessel 2', 40), (3, 2, 'Argentine Vessel ... | What is the average number of employees on vessels from each country? | SELECT c.name, AVG(v.num_employees) as avg_num_employees FROM countries c INNER JOIN vessels v ON c.id = v.country_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_name VARCHAR, donation_amount DECIMAL, donation_date DATE, program VARCHAR); INSERT INTO donations (id, donor_name, donation_amount, donation_date, program) VALUES (1, 'John Doe', 100, '2021-01-01', 'Education'); | What is the average donation amount per program? | SELECT program, AVG(donation_amount) FROM donations GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE MenuItems (MenuID INT, RestaurantID INT, MenuItem VARCHAR(255), Category VARCHAR(255), AveragePrice DECIMAL(5,2), Popularity INT); | Identify menu items with a high price difference between the average price and the next most popular item in the same category, for restaurants in Illinois. | SELECT MenuID, MenuItem, Category, AveragePrice, Popularity, LEAD(AveragePrice) OVER (PARTITION BY Category ORDER BY Popularity DESC) as NextItemPrice, (AveragePrice - LEAD(AveragePrice) OVER (PARTITION BY Category ORDER BY Popularity DESC)) as PriceDifference FROM MenuItems WHERE RestaurantID IN (SELECT RestaurantID F... | gretelai_synthetic_text_to_sql |
CREATE TABLE music_revenue (song VARCHAR(255), genre VARCHAR(255), revenue INT, revenue_date DATE); INSERT INTO music_revenue (song, genre, revenue, revenue_date) VALUES ('Song1', 'Genre1', 5000000, '2022-02-01'), ('Song2', 'Genre2', 7000000, '2022-02-02'), ('Song3', 'Genre1', 6000000, '2022-02-03'), ('Song4', 'Genre2'... | Find the total revenue for each music genre in the current month. | SELECT genre, SUM(revenue) as total_revenue FROM music_revenue GROUP BY genre ORDER BY total_revenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE oil_production (production_id INT PRIMARY KEY, company_name VARCHAR(255), year INT, yearly_production BIGINT); | Update the 'oil_production' table to set the 'yearly_production' to 0 for all records where the 'company_name' is 'Global Energy Inc.' | UPDATE oil_production SET yearly_production = 0 WHERE company_name = 'Global Energy Inc.'; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (department_id INT, department_name TEXT); CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, department_id INT, hours_spent_on_mental_health_sessions INT); INSERT INTO departments VALUES (1, 'Mathematics'), (2, 'Science'), (3, 'English'); INSERT INTO teachers VALUES (1, 'Mr. Patel', 1, ... | What is the maximum number of hours spent on mental health support sessions by teachers in each department? | SELECT d.department_name, MAX(t.hours_spent_on_mental_health_sessions) FROM departments d INNER JOIN teachers t ON d.department_id = t.department_id GROUP BY d.department_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide (country VARCHAR(20), population INT, affected INT); INSERT INTO digital_divide (country, population, affected) VALUES ('United States', 331002651, 42000000), ('Canada', 37410003, 500000); | What is the total number of people affected by the digital divide in North America? | SELECT SUM(affected) FROM digital_divide WHERE country = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (type VARCHAR(10), city VARCHAR(20), year INT); INSERT INTO schools (type, city, year) VALUES ('public', 'Chicago', 2019); INSERT INTO schools (type, city, year) VALUES ('private', 'Chicago', 2019); | How many public schools were there in the city of Chicago in the year 2019? | SELECT COUNT(*) FROM schools WHERE type = 'public' AND city = 'Chicago' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment (plant_name VARCHAR(50), country VARCHAR(20), capacity_m3 INT); INSERT INTO wastewater_treatment (plant_name, country, capacity_m3) VALUES ('Vancouver WWTP', 'Canada', 1500000); | List all the wastewater treatment plants in Canada and their capacities. | SELECT plant_name, country, capacity_m3 FROM wastewater_treatment WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE session_duration (session_id INT, duration INT, treatment VARCHAR(255), country VARCHAR(255)); INSERT INTO session_duration (session_id, duration, treatment, country) VALUES (1, 60, 'Group', 'United Kingdom'); INSERT INTO session_duration (session_id, duration, treatment, country) VALUES (2, 90, 'Individua... | What is the average duration of group therapy sessions in the United Kingdom? | SELECT AVG(duration) FROM session_duration WHERE treatment = 'Group' AND country = 'United Kingdom'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CanadianMiningExtraction (year INT, company TEXT, country TEXT, mineral TEXT, quantity INT); INSERT INTO CanadianMiningExtraction (year, company, country, mineral, quantity) VALUES (2017, 'Northstar Mining', 'Canada', 'Copper', 5000), (2018, 'Northstar Mining', 'Canada', 'Copper', 5500), (2019, 'Northstar ... | What is the total quantity of copper and gold extracted by each company in Canada for the last 5 years? | SELECT context.company, SUM(CASE WHEN context.mineral = 'Copper' THEN context.quantity ELSE 0 END) as total_copper, SUM(CASE WHEN context.mineral = 'Gold' THEN context.quantity ELSE 0 END) as total_gold FROM CanadianMiningExtraction context WHERE context.country = 'Canada' AND context.year BETWEEN 2017 AND 2021 GROUP B... | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence_sources (source_id INT, source_name VARCHAR(255), sector VARCHAR(255), last_updated TIMESTAMP); | List all the unique sources of threat intelligence for the financial sector from the last year. | SELECT DISTINCT source_name FROM threat_intelligence_sources WHERE sector = 'Financial' AND last_updated >= NOW() - INTERVAL '1 year'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title varchar(255), release_year int, LGBTQ_representation boolean); INSERT INTO movies (title, release_year, LGBTQ_representation) VALUES ('Moonlight', 2016, true); INSERT INTO movies (title, release_year, LGBTQ_representation) VALUES ('Call Me By Your Name', 2017, true); INSERT INTO movies (title... | How many films featuring LGBTQ+ representation were released in the US between 2015 and 2020? | SELECT COUNT(*) FROM movies WHERE LGBTQ_representation = true AND release_year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Construction_Projects (project_id INT, project_name VARCHAR(50), state VARCHAR(2), timeline INT); INSERT INTO Construction_Projects VALUES (1, 'Chicago Loop Tower', 'IL', 48); | What is the maximum timeline for a construction project in Illinois? | SELECT MAX(timeline) FROM Construction_Projects WHERE state = 'IL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, has_sustainable_practices BOOLEAN, factory_name TEXT); INSERT INTO factories VALUES (1, TRUE, 'Green Factory'); INSERT INTO factories VALUES (2, FALSE, 'Eco-friendly Solutions'); CREATE TABLE workers (worker_id INT, factory_id INT); INSERT INTO workers VALUES (1, 1); INSERT INTO ... | List the factories that have sustainable practices and the number of workers in those factories in the factories and workers tables. | SELECT factories.factory_name, COUNT(workers.worker_id) FROM factories INNER JOIN workers ON factories.factory_id = workers.factory_id WHERE has_sustainable_practices = TRUE GROUP BY factories.factory_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE DrugSales (SalesRepID int, DrugName varchar(50), SalesDate date, TotalSalesRev decimal(18,2)); INSERT INTO DrugSales (SalesRepID, DrugName, SalesDate, TotalSalesRev) VALUES (5, 'DrugV', '2021-03-15', 65000.00), (6, 'DrugW', '2021-02-01', 90000.00), (7, 'DrugX', '2021-01-25', 78000.00), (8, 'DrugY', '2021-0... | What is the total sales revenue per sales representative, ranked by sales revenue? | SELECT SalesRepID, SUM(TotalSalesRev) as TotalSales, ROW_NUMBER() OVER (ORDER BY SUM(TotalSalesRev) DESC) as SalesRank FROM DrugSales GROUP BY SalesRepID; | gretelai_synthetic_text_to_sql |
CREATE TABLE EnergyEfficiency (Country TEXT, Year INT, Score NUMBER); INSERT INTO EnergyEfficiency (Country, Year, Score) VALUES ('Japan', 2022, 80), ('South Korea', 2022, 75), ('China', 2022, 70), ('India', 2022, 65); CREATE TABLE GHGEmissions (Country TEXT, Year INT, Emissions NUMBER); INSERT INTO GHGEmissions (Count... | What are the top 3 energy efficient countries in Asia in 2022? | SELECT EnergyEfficiency.Country, AVG(EnergyEfficiency.Score) AS Average_Score FROM EnergyEfficiency WHERE EnergyEfficiency.Country IN ('Japan', 'South Korea', 'China', 'India') AND EnergyEfficiency.Year = 2022 GROUP BY EnergyEfficiency.Country ORDER BY Average_Score DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Event_Data (EventID INT, Event_Type VARCHAR(50), Budget DECIMAL(10, 2)); | Find the total budget and total number of events for each event type, from the 'Event_Data' table, grouped by Event_Type. | SELECT Event_Type, SUM(Budget) AS Total_Budget, COUNT(*) AS Total_Events FROM Event_Data GROUP BY Event_Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle (id INT, name TEXT, is_electric BOOLEAN, city_traffic_speed FLOAT); CREATE TABLE SafetyTesting (id INT, vehicle_id INT); INSERT INTO Vehicle (id, name, is_electric, city_traffic_speed) VALUES (1, 'Model S', true, 15.3), (2, 'Camry', false, 18.9), (3, 'Bolt', true, 13.2); INSERT INTO SafetyTesting (... | What is the average city traffic speed of the electric vehicles that participated in safety testing? | SELECT AVG(city_traffic_speed) FROM Vehicle INNER JOIN SafetyTesting ON Vehicle.id = SafetyTesting.vehicle_id WHERE is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE forest_types (id INT, type VARCHAR(20)); INSERT INTO forest_types (id, type) VALUES (3, 'coniferous'); | Find the total volume of timber harvested in 'Africa' from 'coniferous' type | SELECT SUM(volume) FROM timber_harvest t JOIN forest_types ft ON t.forest_type_id = ft.id WHERE t.harvest_location = 'Africa' AND ft.type = 'coniferous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE video_views (id INT, user_id INT, video_id INT, watch_time INT, video_type TEXT, view_date DATE, disinformation_score INT); INSERT INTO video_views (id, user_id, video_id, watch_time, video_type, view_date, disinformation_score) VALUES (1, 1, 1, 60, 'news', '2022-03-01', 3); INSERT INTO video_views (id, us... | What is the total watch time for news videos in Asia with a disinformation score below 4 in the last month? | SELECT SUM(watch_time) FROM video_views WHERE video_type = 'news' AND view_date >= DATEADD(month, -1, GETDATE()) AND country = 'Asia' AND disinformation_score < 4; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.cargo (id INT, cargo_type VARCHAR(255), arrived_at DATE); | Add new cargo record for 'copper ore' with id 100, arrived at port on Feb 10, 2022 | INSERT INTO ocean_shipping.cargo (id, cargo_type, arrived_at) VALUES (100, 'copper ore', '2022-02-10'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Sharks (Species VARCHAR(255), Ocean VARCHAR(255), Population INT); INSERT INTO Sharks (Species, Ocean, Population) VALUES ('Great White Shark', 'Pacific Ocean', 32000); | Update the Sharks table to increase the population of the Great White Shark in the Pacific Ocean by 5000. | UPDATE Sharks SET Population = Population + 5000 WHERE Species = 'Great White Shark' AND Ocean = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccinations (id INT, patient_id INT, vaccine_type VARCHAR(50), date DATE, hospital_id INT); INSERT INTO vaccinations (id, patient_id, vaccine_type, date, hospital_id) VALUES (1, 2, 'COVID-19', '2022-04-10', 102), (2, 3, 'Flu', '2022-03-15', 101), (3, 4, 'COVID-19', '2022-05-05', 102); CREATE TABLE hospita... | What is the name and location of hospitals that have administered the COVID-19 vaccine? | SELECT hospitals.name, hospitals.location FROM vaccinations INNER JOIN hospitals ON vaccinations.hospital_id = hospitals.id WHERE vaccine_type = 'COVID-19'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (dept VARCHAR(50), program VARCHAR(50), amount INT); INSERT INTO budget (dept, program, amount) VALUES ('Disability Services', 'Accessible Technology', 50000), ('Disability Services', 'Sign Language Interpretation', 75000), ('Human Resources', 'Diversity Training', 30000); | Update the budget for the 'Sign Language Interpretation' program to $80,000 in the 'Disability Services' department. | UPDATE budget SET amount = 80000 WHERE dept = 'Disability Services' AND program = 'Sign Language Interpretation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (fare_id INT, route_id INT, fare DECIMAL(5,2), fare_type VARCHAR(20)); INSERT INTO fares (fare_id, route_id, fare, fare_type) VALUES (1, 1, 8.00, 'Commuter Rail'), (2, 2, 6.50, 'Subway'), (3, 3, 9.00, 'Commuter Rail'); | What is the minimum fare for the commuter rail in Boston? | SELECT MIN(fare) FROM fares WHERE fare_type = 'Commuter Rail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE case_outcomes (case_id INT, case_type_id INT, case_status VARCHAR(20)); CREATE TABLE case_types (case_type_id INT, case_type VARCHAR(20)); | What is the total number of cases for each case type ('case_types' table) in the 'case_outcomes' table? | SELECT ct.case_type, COUNT(co.case_id) as num_cases FROM case_outcomes co JOIN case_types ct ON co.case_type_id = ct.case_type_id GROUP BY ct.case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (satellite_id INT, manufacturer VARCHAR(255), delivery_date DATE); INSERT INTO Satellites (satellite_id, manufacturer, delivery_date) VALUES (1, 'SpaceTech Inc.', '2020-01-01'), (2, 'Galactic Enterprises', '2019-05-15'); | What is the average delivery time for satellites by SpaceTech Inc.? | SELECT AVG(DATEDIFF('2022-08-01', delivery_date)) FROM Satellites WHERE manufacturer = 'SpaceTech Inc.'; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (id INT, name VARCHAR(50), state VARCHAR(50), rating FLOAT, upgrade_year INT); | What is the average energy efficiency rating of buildings in Texas that have received energy efficiency upgrades since 2010? | SELECT AVG(rating) FROM buildings WHERE state = 'Texas' AND upgrade_year >= 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge_Design (project_name VARCHAR(100), span_length FLOAT); INSERT INTO Bridge_Design (project_name, span_length) VALUES ('Bicycle Bridge', 50.00), ('Pedestrian Bridge', 30.00), ('Train Bridge', 100.00); | What is the maximum span length for bridges in the 'Bridge_Design' table? | SELECT MAX(span_length) FROM Bridge_Design; | gretelai_synthetic_text_to_sql |
CREATE TABLE TextileSuppliers (SupplierID INT, SupplierName TEXT, Country TEXT, OrganicCottonQty INT); INSERT INTO TextileSuppliers (SupplierID, SupplierName, Country, OrganicCottonQty) VALUES (1, 'EcoFabrics', 'India', 3000), (2, 'GreenWeaves', 'Pakistan', 4000), (3, 'SustainableTextiles', 'Italy', 6000); | What is the total quantity of organic cotton used by textile suppliers in India and Pakistan? | SELECT Country, SUM(OrganicCottonQty) FROM TextileSuppliers WHERE Country IN ('India', 'Pakistan') GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_training(id INT, personnel_id INT, trained_by VARCHAR(255), trained_in VARCHAR(255), training_year INT); INSERT INTO peacekeeping_training(id, personnel_id, trained_by, trained_in, training_year) VALUES (1, 111, 'AU', 'Cybersecurity', 2016), (2, 222, 'EU', 'Mediation', 2017), (3, 333, 'AU', 'C... | What is the minimum number of peacekeeping personnel trained by the African Union in cybersecurity between 2016 and 2020, inclusive? | SELECT MIN(personnel_id) FROM peacekeeping_training WHERE trained_by = 'AU' AND trained_in = 'Cybersecurity' AND training_year BETWEEN 2016 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), launch_date DATE, organization VARCHAR(255), PRIMARY KEY(id)); INSERT INTO satellites (id, name, launch_date, organization) VALUES (1, 'Satellite1', '2010-05-12', 'Organization1'), (2, 'Satellite2', '2015-09-18', 'Organization2'), (3, 'Satellite3', '2020-01-03', 'Orga... | Which organizations have successfully launched satellites and when were they launched? | SELECT satellites.organization, satellites.launch_date FROM satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products(id INT, name TEXT, material TEXT, is_sustainable BOOLEAN); INSERT INTO Products(id, name, material, is_sustainable) VALUES (1, 'Shirt', 'Polyester', false), (2, 'Pants', 'Hemp', true); | Delete the records where 'Polyester' is mislabeled as sustainable? | DELETE FROM Products WHERE material = 'Polyester' AND is_sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, FirstName VARCHAR(50), LastName VARCHAR(50)); INSERT INTO Members (MemberID, FirstName, LastName) VALUES (1, 'John', 'Doe'); INSERT INTO Members (MemberID, FirstName, LastName) VALUES (2, 'Jane', 'Doe'); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT IN... | Add a new workout session for member with ID 3 on February 5, 2022. | INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (3, 3, '2022-02-05'); | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, location VARCHAR(50), generation_date DATE, waste_amount INT); | Insert records for waste_generation table, with data for 'London', 'Sydney', 'Rio de Janeiro' and generation_date values '2020-01-01', '2019-07-01', '2018-05-01' respectively | INSERT INTO waste_generation (id, location, generation_date, waste_amount) VALUES (3, 'London', '2020-01-01', 1200), (4, 'Sydney', '2019-07-01', 1800), (5, 'Rio de Janeiro', '2018-05-01', 2500); | gretelai_synthetic_text_to_sql |
CREATE TABLE Founders (id INT, name TEXT, gender TEXT, industry TEXT); INSERT INTO Founders VALUES (1, 'Alice', 'Female', 'Healthcare'); | What is the average funding amount received by female founders in the Healthcare industry? | SELECT AVG(InvestmentRounds.funding_amount) FROM Founders JOIN InvestmentRounds ON Founders.id = InvestmentRounds.founder_id WHERE Founders.gender = 'Female' AND Founders.industry = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (ArtworkID INT, ExhibitionID INT, VisitorID INT); | What's the total number of artworks in the 'Contemporary Art' exhibition? | SELECT SUM(a.TotalArtworks) FROM (SELECT e.ExhibitionID, COUNT(a.ArtworkID) TotalArtworks FROM Artworks a JOIN Exhibitions e ON a.ExhibitionID = e.ExhibitionID WHERE e.ExhibitionName = 'Contemporary Art' GROUP BY e.ExhibitionID) a; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_missions (spacecraft_name TEXT, mission_date DATE); | Find the number of spacecraft missions per week, and rank them in descending order? | SELECT DATE_TRUNC('week', mission_date) as mission_week, COUNT(*) as mission_count, RANK() OVER (ORDER BY COUNT(*) DESC) as mission_rank FROM spacecraft_missions GROUP BY mission_week ORDER BY mission_rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_year INT, gender VARCHAR(255)); INSERT INTO donors (donor_id, donation_amount, donation_year, gender) VALUES (1, 5000.00, 2020, 'female'), (2, 3000.00, 2019, 'male'), (3, 7000.00, 2020, 'non-binary'), (4, 9000.00, 2021, 'non-binary'), (5, 8000.0... | Delete all records for donors who identify as 'prefer not to say'. | DELETE FROM donors WHERE gender = 'prefer not to say'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TemperatureData (date DATE, temperature FLOAT, sensor_id INT, FOREIGN KEY (sensor_id) REFERENCES SensorData(sensor_id)); | Insert new temperature data for sensor 008 on 2023-03-03 with a value of 25°C | INSERT INTO TemperatureData (date, temperature, sensor_id) VALUES ('2023-03-03', 25, 8); | gretelai_synthetic_text_to_sql |
CREATE TABLE developers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO developers (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'China'); CREATE TABLE smart_contracts (id INT, name VARCHAR(50), developer_id INT); INSERT INTO smart_contracts (id, name, developer_id) VALUES (1, 'SC1', 1), (2, '... | What is the total number of smart contracts developed by developers from the US and China? | SELECT COUNT(*) FROM smart_contracts sc INNER JOIN developers d ON sc.developer_id = d.id WHERE d.country IN ('USA', 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces_spain (id INT, name TEXT, province TEXT, total_employees INT); INSERT INTO workplaces_spain (id, name, province, total_employees) VALUES (1, 'ABC Company', 'Madrid', 500); INSERT INTO workplaces_spain (id, name, province, total_employees) VALUES (2, 'XYZ Corporation', 'Barcelona', 300); | What is the number of workplaces with successful collective bargaining agreements in Spain, grouped by province? | SELECT province, COUNT(*) as total_workplaces FROM workplaces_spain WHERE total_employees > 0 GROUP BY province; | gretelai_synthetic_text_to_sql |
CREATE TABLE agriculture_innovation (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO agriculture_innovation (id, name, age, gender, location) VALUES (1, 'Jane', 45, 'Female', 'Rural Texas'); INSERT INTO agriculture_innovation (id, name, age, gender, location) VALUES (2, 'Alice'... | What is the average age of female farmers in the 'agriculture_innovation' table? | SELECT AVG(age) FROM agriculture_innovation WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ytterbium_Production (Year INT, Quarter INT, Quantity INT); INSERT INTO Ytterbium_Production (Year, Quarter, Quantity) VALUES (2017, 1, 125), (2017, 2, 140), (2017, 3, 155), (2017, 4, 170), (2018, 1, 185), (2018, 2, 210), (2018, 3, 235), (2018, 4, 260); | List the total production quantity of Ytterbium for each quarter it was produced. | SELECT Year, Quarter, SUM(Quantity) FROM Ytterbium_Production GROUP BY Year, Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (ID INT, Name VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50)); INSERT INTO Employee (ID, Name, Position, Department) VALUES (1, 'Alice', 'Cybersecurity Strategist', 'Intelligence Agency A'), (2, 'Bob', 'Cybersecurity Analyst', 'Intelligence Agency B'), (3, 'Charlie', 'Cybersecurity Stra... | Who are the top 5 cybersecurity strategists in the intelligence community? | SELECT E.Name, E.Position, E.Department FROM Employee E INNER JOIN (SELECT Department, MAX(ID) AS MaxID FROM Employee WHERE Position = 'Cybersecurity Strategist' GROUP BY Department) MaxID ON E.Department = MaxID.Department AND E.ID = MaxID.MaxID; | gretelai_synthetic_text_to_sql |
CREATE TABLE industrial_water_usage (state VARCHAR(20), year INT, sector VARCHAR(30), usage FLOAT); INSERT INTO industrial_water_usage (state, year, sector, usage) VALUES ('California', 2020, 'Agriculture', 12345.6), ('California', 2020, 'Manufacturing', 23456.7), ('California', 2020, 'Mining', 34567.8); | What is the total water usage by each industrial sector in California in 2020?' | SELECT sector, SUM(usage) FROM industrial_water_usage WHERE state = 'California' AND year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, name VARCHAR(100), code VARCHAR(1000), creation_date DATE); INSERT INTO smart_contracts (id, name, code, creation_date) VALUES (1, 'legacySC123', '0x123...', '2017-01-01'); INSERT INTO smart_contracts (id, name, code, creation_date) VALUES (2, 'otherSC', '0x456...', '2018-05-05'); | Update the name of all smart contracts created before 2019-01-01 with the word 'legacy' in it to 'LegacySC' in the smart_contracts table. | UPDATE smart_contracts SET name = 'LegacySC' WHERE name LIKE '%legacy%' AND creation_date < '2019-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (stream_id INT, genre VARCHAR(255), user_id INT, streams_amount INT); | What is the average number of streams per user for each genre of music? | SELECT genre, AVG(streams_amount) FROM streams GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, region VARCHAR(10), billing_amount INT); INSERT INTO cases (id, region, billing_amount) VALUES (1, 'Eastern', 5000), (2, 'Western', 7000), (3, 'Eastern', 6000); | Find the average billing amount for cases in the 'Eastern' region. | SELECT AVG(billing_amount) FROM cases WHERE region = 'Eastern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_taxis (taxi_id INT, taxi_type VARCHAR(50), taxi_registration_date DATE); INSERT INTO autonomous_taxis (taxi_id, taxi_type, taxi_registration_date) VALUES (1, 'Tesla Model 3', '2022-02-01'), (2, 'Nissan Leaf', '2022-02-02'), (3, 'Honda Civic', '2022-02-03'); | How many electric vehicles are there in the autonomous taxi fleet in Tokyo? | SELECT COUNT(*) FROM autonomous_taxis WHERE taxi_type LIKE '%electric%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT PRIMARY KEY, name TEXT, location TEXT, is_fair_trade BOOLEAN); | How many fair trade suppliers are there? | SELECT COUNT(*) FROM suppliers WHERE is_fair_trade = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_data (hotel_id INT, hotel_name TEXT, city TEXT, country TEXT, stars INT, ai_chatbot BOOLEAN); INSERT INTO hotel_data (hotel_id, hotel_name, city, country, stars, ai_chatbot) VALUES (1, 'Park Hotel', 'Zurich', 'Switzerland', 5, true), (2, 'Four Seasons', 'Montreal', 'Canada', 5, false), (3, 'The Plaza... | What are the top 3 cities with the highest number of hotels that have adopted AI-powered chatbots for customer service? | SELECT city, COUNT(DISTINCT hotel_id) as hotel_count FROM hotel_data WHERE ai_chatbot = true GROUP BY city ORDER BY hotel_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO renewable_energy (id, project_name, location, investment) VALUES (1, 'Solar Farm', 'Arizona', 12000000), (2, 'Wind Turbines', 'Texas', 8000000); | What is the minimum investment in renewable energy projects in the 'renewable_energy' schema? | SELECT MIN(investment) FROM renewable_energy; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(100), field_of_study VARCHAR(50), state VARCHAR(50)); INSERT INTO students VALUES (1, 'Jamie Johnson', 'Sociology', 'California'); | How many graduate students are enrolled in Social Sciences programs per state? | SELECT state, COUNT(*) FROM students WHERE field_of_study IN ('Sociology', 'Political Science', 'Anthropology') GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs_approval_all_years (drug_name TEXT, approval_year INTEGER, region TEXT); INSERT INTO drugs_approval_all_years (drug_name, approval_year, region) VALUES ('DrugX', 2018, 'North'), ('DrugY', 2019, 'South'), ('DrugZ', 2020, 'East'), ('DrugA', 2018, 'West'), ('DrugB', 2020, 'North'), ('DrugC', 2019, 'Nort... | What is the total number of drugs approved in a given year, across all regions, including drugs approved for other years? | SELECT COUNT(DISTINCT drug_name) FROM drugs_approval_all_years WHERE approval_year = 2020 UNION SELECT COUNT(DISTINCT drug_name) FROM drugs_approval_all_years WHERE approval_year != 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name TEXT, race TEXT, industry TEXT, funds_raised FLOAT); INSERT INTO founders (id, name, race, industry, funds_raised) VALUES (1, 'Alice', 'Asian', 'Technology', 5000000), (2, 'Bob', 'Black', 'Finance', 2000000), (3, 'Charlie', 'Latinx', 'Technology', 3000000), (4, 'Diana', 'White', 'E-c... | Identify underrepresented founders who have raised funding in the e-commerce sector. | SELECT DISTINCT name FROM founders WHERE industry = 'E-commerce' AND race NOT IN ('White'); | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (assistance_id INT, assistance_name VARCHAR(50), year INT, location VARCHAR(50), description TEXT); | Insert a new record in the humanitarian_assistance table for an operation named 'Medical Aid in Africa' in 2022 | INSERT INTO humanitarian_assistance (assistance_id, assistance_name, year, location, description) VALUES (1, 'Medical Aid in Africa', 2022, 'Africa', 'Description of the medical aid operation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_type TEXT, donor_name TEXT, cause_id INT, donation_amount DECIMAL(10, 2), donation_date DATE); CREATE TABLE Causes (id INT, cause_name TEXT); CREATE TABLE Organizations (id INT, organization_name TEXT, country TEXT); CREATE TABLE Individual_Donors (id INT, donor_name TEXT, country ... | Show causes that received donations from both organizations and individual donors in Brazil in 2020. | SELECT c.cause_name FROM Donations d JOIN Causes c ON d.cause_id = c.id WHERE d.donation_date BETWEEN '2020-01-01' AND '2020-12-31' AND (d.donor_type = 'Organization' AND d.donor_name IN (SELECT organization_name FROM Organizations WHERE country = 'Brazil')) OR (d.donor_type = 'Individual' AND d.donor_name IN (SELECT d... | gretelai_synthetic_text_to_sql |
CREATE TABLE models (id INT, name TEXT, country TEXT); INSERT INTO models (id, name, country) VALUES (1, 'ModelA', 'US'), (2, 'ModelB', 'Canada'), (3, 'ModelC', 'Brazil'); | Delete models developed in South America. | DELETE FROM models WHERE country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(100), Gender VARCHAR(10)); INSERT INTO Artists (ArtistID, Name, Gender) VALUES (1, 'Clara Peeters', 'Female'); INSERT INTO Artists (ArtistID, Name, Gender) VALUES (2, 'Francisco Goya', 'Male'); CREATE TABLE ArtWorks (ArtWorkID INT PRIMARY KEY, Title VARCHAR(1... | Identify artworks by female artists that have not been exhibited since 2015. | SELECT ArtWorks.Title FROM ArtWorks INNER JOIN Artists ON ArtWorks.ArtistID = Artists.ArtistID WHERE Artists.Gender = 'Female' AND ArtWorks.LastExhibitionDate < '2016-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_ingredients (product_id INT, ingredient VARCHAR(255), percentage FLOAT, PRIMARY KEY (product_id, ingredient)); | Create a view that shows the top 3 products with the least natural ingredients | CREATE VIEW least_3_natural_ingredients AS SELECT product_id, SUM(percentage) as total_natural_ingredients FROM product_ingredients WHERE ingredient LIKE 'natural%' GROUP BY product_id ORDER BY total_natural_ingredients ASC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech_genetics; CREATE TABLE if not exists biotech_genetics.startups (id INT, name VARCHAR(100), location VARCHAR(50), funding DECIMAL(10,2)); INSERT INTO biotech_genetics.startups (id, name, location, funding) VALUES (1, 'Genetech', 'San Francisco', 2500000.00), (2, 'IncellDX', 'New York'... | Show the total funding for biotech startups in the Bay Area, and the number of genetic research studies in the country with the most studies. | SELECT SUM(startups.funding) as total_funding, (SELECT COUNT(*) FROM biotech_genetics.studies WHERE country = (SELECT country FROM biotech_genetics.studies GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1)) as study_count FROM biotech_genetics.startups WHERE location = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE oil_reservoirs (reservoir_id INT, reservoir_name VARCHAR(100), location VARCHAR(100), oil_capacity FLOAT); INSERT INTO oil_reservoirs (reservoir_id, reservoir_name, location, oil_capacity) VALUES (1, 'Girassol', 'Angola', 800), (2, 'Jazireh-e-Jafar', 'Iran', 1500); CREATE TABLE production_data (reservoir_i... | Create a view with reservoirs and their production | CREATE VIEW reservoir_production AS SELECT r.reservoir_id, r.reservoir_name, SUM(p.production) FROM oil_reservoirs r JOIN production_data p ON r.reservoir_id = p.reservoir_id GROUP BY r.reservoir_id, r.reservoir_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_cars (car_id INT, city VARCHAR(20), in_operation BOOLEAN); INSERT INTO autonomous_cars (car_id, city, in_operation) VALUES (1, 'San Francisco', TRUE), (2, 'San Francisco', FALSE), (3, 'Los Angeles', TRUE), (4, 'Los Angeles', TRUE), (5, 'Miami', FALSE), (6, 'Miami', TRUE); | What is the total number of autonomous cars in operation in San Francisco, Los Angeles, and Miami? | SELECT city, COUNT(*) FROM autonomous_cars WHERE in_operation = TRUE GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'John Smith', 'CA'), (2, 'Jane Doe', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES ... | What is the average claim amount for policyholders living in 'CA'? | SELECT AVG(Claims.ClaimAmount) FROM Claims INNER JOIN Policyholders ON Claims.PolicyID = Policyholders.PolicyID WHERE Policyholders.State = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE trends_by_region (id INT PRIMARY KEY, region VARCHAR(255), trend_name VARCHAR(255), popularity_score INT); | Display all trends from 'trends_by_region' table for region 'Asia' | SELECT * FROM trends_by_region WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleet (id INT, name VARCHAR(50), capacity INT); INSERT INTO fleet VALUES (1, 'ShipA', 10000), (2, 'ShipB', 12000), (3, 'ShipC', 8000); | What is the total capacity of all container ships in the fleet? | SELECT SUM(capacity) FROM fleet WHERE type = 'Container'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, country TEXT); CREATE TABLE donations (donation_id INT, donor_id INT, cause_id INT, donation_amount DECIMAL); INSERT INTO donors (donor_id, donor_name, country) VALUES (1, 'Aisha Patel', 'India'), (2, 'Hiroshi Tanaka', 'Japan'), (3, 'Clara Rodriguez', 'Brazil'); INSER... | Which causes have received donations from donors in India? | SELECT causes.cause_name FROM causes INNER JOIN donations ON causes.cause_id = donations.cause_id INNER JOIN donors ON donations.donor_id = donors.donor_id WHERE donors.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), country VARCHAR(50)); INSERT INTO wells (well_id, well_name, country) VALUES (1, 'WellA', 'Venezuela'), (2, 'WellB', 'Venezuela'), (3, 'WellC', 'Brazil'); | What are the names of all wells in 'Venezuela'? | SELECT well_name FROM wells WHERE country = 'Venezuela'; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (employment_id INT, industry VARCHAR(50), veteran_status VARCHAR(50), employment_date DATE); | Show veteran employment statistics for the defense industry in the last quarter | SELECT industry, veteran_status, COUNT(*) AS num_employed FROM veteran_employment WHERE employment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND industry = 'Defense' GROUP BY industry, veteran_status; | 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.