context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE SCHEMA if not exists rural; CREATE TABLE if not exists rural.disaster_stats (id INT, disaster_type VARCHAR(255), disaster_count INT); INSERT INTO rural.disaster_stats (id, disaster_type, disaster_count) VALUES (1, 'Tornado', 25), (2, 'Flood', 45), (3, 'Earthquake', 32); | What is the total number of natural disasters recorded in the 'rural' schema? | SELECT SUM(disaster_count) FROM rural.disaster_stats; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT); INSERT INTO volunteers (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mike Johnson'); CREATE TABLE donations (id INT, volunteer_id INT, amount INT); INSERT INTO donations (id, volunteer_id, amount) VALUES (1, 1, 100), (2, 2, 200), (3, 4, 300); | Determine the number of volunteers who have not made any donations. | SELECT COUNT(*) FROM volunteers LEFT JOIN donations ON volunteers.id = donations.volunteer_id WHERE donations.volunteer_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name VARCHAR(255)); CREATE TABLE teachers (teacher_id INT, district_id INT, years_of_experience INT); CREATE TABLE workshops (workshop_id INT, district_id INT, workshop_topic VARCHAR(255), teacher_id INT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'); INSERT INTO teachers (teacher_id, district_id, years_of_experience) VALUES (1, 1, 5), (2, 1, 10), (3, 2, 3), (4, 2, 8); INSERT INTO workshops (workshop_id, district_id, workshop_topic, teacher_id) VALUES (1, 1, 'Data Science', 1), (2, 1, 'Data Science', 2), (3, 2, 'Data Science', 3), (4, 2, 'Data Science', 4); | What is the number of teachers who have completed professional development in data science, by school district? | SELECT sd.district_name, COUNT(w.teacher_id) as num_teachers FROM districts sd JOIN workshops w ON sd.district_id = w.district_id WHERE w.workshop_topic = 'Data Science' GROUP BY sd.district_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE FinancialInstitutions (InstitutionID int, Name varchar(50), ShariahCompliant bit, SociallyResponsible bit); INSERT INTO FinancialInstitutions (InstitutionID, Name, ShariahCompliant, SociallyResponsible) VALUES (1, 'Institution A', 1, 1); CREATE TABLE Assets (AssetID int, InstitutionID int, Amount decimal(10,2)); INSERT INTO Assets (AssetID, InstitutionID, Amount) VALUES (1, 1, 5000000.00); | Display the total assets of all financial institutions in the database that are Shariah-compliant and offer socially responsible lending. | SELECT SUM(A.Amount) FROM Assets A INNER JOIN FinancialInstitutions FI ON A.InstitutionID = FI.InstitutionID WHERE FI.ShariahCompliant = 1 AND FI.SociallyResponsible = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_demographics (member_id INT, age INT, gender VARCHAR(10)); INSERT INTO member_demographics (member_id, age, gender) VALUES (1, 27, 'Female'), (2, 32, 'Male'), (3, 26, 'Female'); CREATE TABLE wearable_data (member_id INT, heart_rate INT, timestamp TIMESTAMP, membership_type VARCHAR(20)); INSERT INTO wearable_data (member_id, heart_rate, timestamp, membership_type) VALUES (1, 120, '2022-01-01 10:00:00', 'Platinum'), (1, 150, '2022-01-01 11:00:00', 'Platinum'), (2, 130, '2022-01-01 10:00:00', 'Gold'), (2, 140, '2022-01-01 11:00:00', 'Gold'), (3, 105, '2022-01-01 10:00:00', 'Platinum'), (3, 110, '2022-01-01 11:00:00', 'Platinum'); | What is the maximum heart rate for each member, sorted by membership type? | SELECT member_id, membership_type, MAX(heart_rate) as max_heart_rate FROM wearable_data w JOIN member_demographics m ON w.member_id = m.member_id GROUP BY member_id, membership_type ORDER BY membership_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT, certification VARCHAR(20), region VARCHAR(20)); INSERT INTO manufacturers (id, certification, region) VALUES (1, 'Fair Trade', 'Asia'), (2, 'GOTS', 'Europe'), (3, 'Fair Trade', 'Asia'); | Count the number of fair trade certified manufacturers in Asia. | SELECT COUNT(*) FROM manufacturers WHERE certification = 'Fair Trade' AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RegionID INT, Region VARCHAR(255)); INSERT INTO Regions (RegionID, Region) VALUES (1, 'North America'); INSERT INTO Regions (RegionID, Region) VALUES (2, 'South America'); INSERT INTO Players (PlayerID, PlayerStatus, GameName, RegionID) VALUES (1, 'Ultra', 'Cosmic Racers', 1); INSERT INTO Players (PlayerID, PlayerStatus, GameName, RegionID) VALUES (2, 'Beginner', 'Cosmic Racers', 2); | How many players have reached 'Ultra' status in 'Cosmic Racers' per region? | SELECT Region, COUNT(*) as PlayerCount FROM Players JOIN Regions ON Players.RegionID = Regions.RegionID WHERE PlayerStatus = 'Ultra' AND GameName = 'Cosmic Racers' GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transport (vehicle_id INT, vehicle_type VARCHAR(20), district INT, city VARCHAR(20)); INSERT INTO public_transport (vehicle_id, vehicle_type, district, city) VALUES (101, 'autonomous bus', 5, 'CityB'), (102, 'manual bus', 5, 'CityB'), (103, 'tram', 4, 'CityB'); | How many autonomous buses are there in District 5 of CityB? | SELECT COUNT(*) FROM public_transport WHERE vehicle_type = 'autonomous bus' AND district = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_sensors (id INT, location VARCHAR(50), temperature DECIMAL(5,2)); INSERT INTO environmental_sensors (id, location, temperature) VALUES (1, 'Chicago', 32.5), (2, 'Detroit', 25.3), (3, 'Cleveland', 30.1), (4, 'Buffalo', 28.6), (5, 'Atlanta', 35.2); | What is the maximum temperature recorded for each location in the environmental_sensors table? | SELECT location, MAX(temperature) as max_temperature FROM environmental_sensors GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Causes (id INT, cause_name TEXT, total_funding DECIMAL(10, 2), cause_category TEXT); CREATE TABLE Foundation_Donations (foundation_id INT, cause_id INT, donation_amount DECIMAL(10, 2), donation_date DATE); CREATE TABLE Foundations (id INT, foundation_name TEXT, country TEXT); | Find the top 3 causes that received the most funding from foundations in Canada in 2020? | SELECT c.cause_name, SUM(fd.donation_amount) AS total_funding FROM Causes c JOIN Foundation_Donations fd ON c.id = fd.cause_id JOIN Foundations f ON fd.foundation_id = f.id WHERE f.country = 'Canada' GROUP BY c.cause_name ORDER BY total_funding DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE HalfYearSatisfaction2 (Half TEXT, Year INTEGER, Service TEXT, Score INTEGER); INSERT INTO HalfYearSatisfaction2 (Half, Year, Service, Score) VALUES ('H1 2022', 2022, 'Education', 90), ('H1 2022', 2022, 'Healthcare', 85), ('H1 2022', 2022, 'Transportation', 92), ('H2 2022', 2022, 'Education', 93), ('H2 2022', 2022, 'Healthcare', 88), ('H2 2022', 2022, 'Transportation', 95); | Which public service had the highest citizen satisfaction score in H1 2022 and H2 2022? | SELECT Service, MAX(Score) FROM HalfYearSatisfaction2 WHERE Year = 2022 GROUP BY Service; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, country TEXT, founding_date DATE, founder_disability TEXT); INSERT INTO company (id, name, country, founding_date, founder_disability) VALUES (1, 'Theta Corp', 'Germany', '2017-01-01', 'Yes'); INSERT INTO company (id, name, country, founding_date, founder_disability) VALUES (2, 'Iota Inc', 'Germany', '2016-01-01', 'No'); | What was the total funding amount for startups founded by individuals with disabilities in Germany? | SELECT SUM(funding_amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.country = 'Germany' AND company.founder_disability = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE reservoirs (id INT, reservoir_name VARCHAR(50), country VARCHAR(50), water_level_meters INT, last_measurement_date DATE); INSERT INTO reservoirs (id, reservoir_name, country, water_level_meters, last_measurement_date) VALUES (1, 'Lake Superior', 'Canada', 405.5, '2021-12-01'); INSERT INTO reservoirs (id, reservoir_name, country, water_level_meters, last_measurement_date) VALUES (2, 'Lake Victoria', 'Tanzania', 11.2, '2021-12-15'); | What is the change in water levels for each reservoir over the past year, and which have experienced the greatest increase and decrease? | SELECT id, reservoir_name, country, DATEDIFF(day, last_measurement_date, CURRENT_DATE) as days_since_last_measurement, water_level_meters, (water_level_meters - LAG(water_level_meters) OVER (PARTITION BY reservoir_name ORDER BY last_measurement_date)) as change FROM reservoirs WHERE DATEDIFF(day, last_measurement_date, CURRENT_DATE) <= 365; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id VARCHAR(5), name VARCHAR(10)); INSERT INTO warehouses (id, name) VALUES ('W01', 'Warehouse One'), ('W02', 'Warehouse Two'), ('W03', 'Warehouse Three'), ('W04', 'Warehouse Four'); CREATE TABLE inventory (item_code VARCHAR(5), warehouse_id VARCHAR(5), quantity INT); INSERT INTO inventory (item_code, warehouse_id, quantity) VALUES ('A101', 'W01', 300), ('A202', 'W02', 200), ('A303', 'W03', 450), ('B404', 'W04', 500); | What is the total quantity of items starting with 'A' in warehouse 'W03'? | SELECT SUM(quantity) FROM inventory WHERE item_code LIKE 'A%' AND warehouse_id = 'W03'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_reviews (hotel_id INT, review_date DATE, review_score INT); | What is the average review score for hotel_id 123? | SELECT AVG(review_score) FROM hotel_reviews WHERE hotel_id = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (student_id INT, name VARCHAR(50), publication VARCHAR(50), publication_year INT); INSERT INTO graduate_students VALUES (1, 'Fatima Patel', 'ACM Transactions on Graphics', 2020), (2, 'Gabriel Brown', 'IEEE Transactions on Visualization and Computer Graphics', 2019), (3, 'Hana Davis', 'ACM Transactions on Graphics', 2021), (4, 'Iman Green', 'IEEE Transactions on Visualization and Computer Graphics', 2020); | List the names and publication years of graduate students who have published in both ACM Transactions on Graphics and IEEE Transactions on Visualization and Computer Graphics. | SELECT DISTINCT gs1.name, gs1.publication_year FROM graduate_students gs1 JOIN graduate_students gs2 ON gs1.name = gs2.name WHERE gs1.publication = 'ACM Transactions on Graphics' AND gs2.publication = 'IEEE Transactions on Visualization and Computer Graphics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE influencers (influencer_id INT, influencer_name TEXT);CREATE TABLE posts (post_id INT, post_text TEXT, influencer_id INT, post_date DATE);CREATE TABLE brands (brand_id INT, brand_name TEXT);CREATE TABLE mentions (mention_id INT, post_id INT, brand_id INT); | What are the top 5 most mentioned brands in influencer posts, in the last month? | SELECT b.brand_name, COUNT(m.mention_id) as mention_count FROM mentions m JOIN posts p ON m.post_id = p.post_id JOIN brands b ON m.brand_id = b.brand_id JOIN influencers i ON p.influencer_id = i.influencer_id WHERE p.post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY b.brand_name ORDER BY mention_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name TEXT, state TEXT, passed_bar_exam_tx BOOLEAN); INSERT INTO attorneys (attorney_id, name, state, passed_bar_exam_tx) VALUES (1, 'Jane Doe', 'Texas', TRUE), (2, 'John Smith', 'California', FALSE), (3, 'Sara Connor', 'Texas', TRUE), (4, 'Tom Williams', 'New York', FALSE); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount INT, state TEXT); INSERT INTO cases (case_id, attorney_id, billing_amount, state) VALUES (1, 1, 10000, 'Texas'), (2, 2, 8000, 'California'), (3, 3, 15000, 'Texas'), (4, 4, 6000, 'New York'); | What is the total billing amount for cases in Texas handled by attorneys who have passed the bar exam in that state? | SELECT SUM(cases.billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.passed_bar_exam_tx = TRUE AND cases.state = attorneys.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (id INT, name TEXT, company TEXT); INSERT INTO digital_assets (id, name, company) VALUES (1, 'Coin1', 'ABC'), (2, 'Coin2', 'DEF'); | What is the total number of digital assets launched by company 'ABC'? | SELECT COUNT(*) FROM digital_assets WHERE company = 'ABC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name VARCHAR(255), date DATE); CREATE TABLE Attendees (id INT, event_id INT, age INT, gender VARCHAR(255), race VARCHAR(255)); | How many events were attended by each demographic group last year? | SELECT a.age, a.gender, a.race, COUNT(*) FROM Attendees a JOIN Events e ON a.event_id = e.id WHERE e.date >= '2021-01-01' AND e.date < '2022-01-01' GROUP BY a.age, a.gender, a.race; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (id INT, name VARCHAR(255)); INSERT INTO ExcavationSites (id, name) VALUES (1, 'Burial Grounds'); CREATE TABLE Artifacts (id INT, excavationSiteId INT, name VARCHAR(255)); INSERT INTO Artifacts (id, excavationSiteId) VALUES (1, 1), (2, 1), (3, 1); | How many artifacts were found in the 'Burial Grounds' excavation site? | SELECT COUNT(*) FROM Artifacts WHERE excavationSiteId = (SELECT id FROM ExcavationSites WHERE name = 'Burial Grounds'); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, gender TEXT, industry TEXT); INSERT INTO companies (id, name, gender, industry) VALUES (1, 'Charlie Inc', 'Female', 'Consumer Electronics'); INSERT INTO companies (id, name, gender, industry) VALUES (2, 'David Corp', 'Male', 'Software'); INSERT INTO companies (id, name, gender, industry) VALUES (3, 'Eva LLP', 'Female', 'Finance'); | List all female founders in the Consumer Electronics industry. | SELECT companies.name FROM companies WHERE companies.gender = 'Female' AND companies.industry = 'Consumer Electronics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE funding_rounds (id INT PRIMARY KEY, company_id INT, round_type VARCHAR(255), raised_amount DECIMAL(10,2)); | Insert funding records for company_id 104 | INSERT INTO funding_rounds (id, company_id, round_type, raised_amount) VALUES (4, 104, 'Seed', 500000), (5, 104, 'Series A', 2000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (expedition_name TEXT, location TEXT, max_depth REAL); INSERT INTO deep_sea_expeditions (expedition_name, location, max_depth) VALUES ('Indian Ocean Expedition', 'Indian Ocean', 8000.0); | What is the maximum depth reached during deep-sea expeditions in the Indian Ocean? | SELECT max_depth FROM deep_sea_expeditions WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, victim_involved VARCHAR(5)); INSERT INTO cases (id, victim_involved) VALUES (1, 'Yes'), (2, 'No'), (3, 'Yes'); | What is the total number of cases in the justice system that involved a victim? | SELECT COUNT(*) FROM cases WHERE victim_involved = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE removed_space_debris (id INT, debris_id VARCHAR(50), mass FLOAT, size FLOAT, removal_year INT); | What is the total mass (in kg) of all space debris larger than 10 cm in size, removed from orbit since 2000? | SELECT SUM(mass) FROM removed_space_debris WHERE size > 10 AND removal_year >= 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArt (name VARCHAR(255), artists_count INT); INSERT INTO TraditionalArt (name, artists_count) VALUES ('Dance of the Maasai', 120), ('Papel Talo', 150), ('Batik', 135); | What traditional arts have more than 100 artists participating? | SELECT name FROM TraditionalArt WHERE artists_count > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE world_oil_reserves (country VARCHAR(255), oil_reserves DECIMAL(10,2), year INT); | What are the total oil reserves for the world, broken down by country, as of 2020? | SELECT wor.country, SUM(wor.oil_reserves) FROM world_oil_reserves wor WHERE wor.year = 2020 GROUP BY wor.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_trips (trip_id INT, day_of_week VARCHAR(10), city VARCHAR(50), is_holiday BOOLEAN); INSERT INTO subway_trips (trip_id, day_of_week, city, is_holiday) VALUES (1, 'Monday', 'Sydney', false), (2, 'Tuesday', 'Sydney', false), (3, 'Friday', 'Sydney', true); | What is the total number of subway trips in Sydney on a public holiday? | SELECT COUNT(*) FROM subway_trips WHERE is_holiday = true AND city = 'Sydney'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, volunteer_country TEXT, volunteer_name TEXT, volunteer_date DATE); INSERT INTO volunteers (id, volunteer_country, volunteer_name, volunteer_date) VALUES (1, 'USA', 'Alice Johnson', '2022-01-01'), (2, 'Canada', 'Bob Brown', '2022-03-05'); | Identify the top 5 countries with the most unique volunteers in the last 6 months. | SELECT volunteer_country, COUNT(DISTINCT volunteer_name) as unique_volunteers FROM volunteers WHERE volunteer_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY volunteer_country ORDER BY unique_volunteers DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (id INT PRIMARY KEY, equipment_name VARCHAR(50), country VARCHAR(50), quantity INT); | Insert new records of military equipment for a specific country in the military_equipment table. | INSERT INTO military_equipment (id, equipment_name, country, quantity) VALUES (3, 'Helicopter', 'Germany', 300), (4, 'Submarine', 'Germany', 200); | gretelai_synthetic_text_to_sql |
CREATE TABLE production_figures (well_id INT, year INT, oil_production INT, gas_production INT); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (1, 2019, 120000, 50000); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (2, 2018, 130000, 60000); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (3, 2019, 110000, 45000); | What is the total oil production in the Gulf of Mexico in 2019? | SELECT SUM(oil_production) FROM production_figures WHERE year = 2019 AND region = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (id INT, name VARCHAR(255), type VARCHAR(255), visits INT); INSERT INTO exhibitions (id, name, type, visits) VALUES (1, 'Cubism', 'Modern', 3000), (2, 'Abstract', 'Modern', 4500), (3, 'Impressionism', 'Classic', 5000), (4, 'Surrealism', 'Modern', 2500), (5, 'Renaissance', 'Classic', 6000); | What was the total number of visitors to the 'Classic' exhibitions? | SELECT SUM(visits) FROM exhibitions WHERE type = 'Classic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Product (product_id INT PRIMARY KEY, product_name VARCHAR(50), price DECIMAL(5,2), material_recycled BOOLEAN); | Show the total revenue generated by products that are made of recycled materials in the 'Product' table | SELECT SUM(price) FROM Product WHERE material_recycled = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE contracts (contract_id INT, contract_value FLOAT, vendor VARCHAR(255), region VARCHAR(255)); INSERT INTO contracts (contract_id, contract_value, vendor, region) VALUES (1, 500000, 'ABC Company', 'Northeast'); INSERT INTO contracts (contract_id, contract_value, vendor, region) VALUES (2, 750000, 'Logistics Company', 'South'); | What is the total contract value awarded to the 'Logistics Company' in the South region in the past year? | SELECT vendor, SUM(contract_value) as total_contract_value FROM contracts WHERE vendor = 'Logistics Company' AND region = 'South' AND contract_date >= DATEADD(year, -1, GETDATE()) GROUP BY vendor; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, EventName TEXT, EventDate DATE); INSERT INTO Events (EventID, EventName, EventDate) VALUES (1001, 'Community Pottery Workshop', '2022-01-01'), (1002, 'Weaving Techniques Demonstration', '2022-02-15'), (1003, 'Traditional Dance Festival', '2022-03-31'); | Calculate the number of community engagement events in the last 6 months, grouped by the day of the week and ordered by the day of the week in ascending order. | SELECT DATENAME(dw, EventDate) AS Day_Of_Week, COUNT(EventID) AS Number_Of_Events FROM Events WHERE EventDate >= DATEADD(month, -6, GETDATE()) GROUP BY DATENAME(dw, EventDate) ORDER BY DATENAME(dw, EventDate) ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID VARCHAR(20), Name VARCHAR(20), Type VARCHAR(20), AverageSpeed FLOAT); INSERT INTO Vessels VALUES ('V002', 'Vessel B', 'Tanker', 12.3), ('V003', 'Vessel C', 'Tanker', 14.8); | Which vessels have a type of 'Tanker'? | SELECT Name FROM Vessels WHERE Type = 'Tanker'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Salary DECIMAL(10, 2), Location VARCHAR(50)); INSERT INTO Employees (EmployeeID, Salary, Location) VALUES (1, 50000, 'NYC'), (2, 55000, 'LA'), (3, 60000, 'NYC'), (4, 45000, 'LA'); | Show the average salary of employees in each location, ordered by location. | SELECT Location, AVG(Salary) FROM Employees GROUP BY Location ORDER BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT PRIMARY KEY, seller VARCHAR(255), buyer VARCHAR(255), equipment_type VARCHAR(255), quantity INT); | What is the total number of military equipment sold to each country and the total quantity sold, ordered by the total quantity sold in descending order? | SELECT buyer, SUM(quantity) FROM military_sales GROUP BY buyer ORDER BY SUM(quantity) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Gender varchar(50), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (1, 'John', 'Doe', 'IT', 'Male', 75000); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (2, 'Jane', 'Doe', 'HR', 'Female', 80000); | What is the average salary by gender? | SELECT Gender, AVG(Salary) as AvgSalary FROM Employees GROUP BY Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorAge INT, TotalDonation FLOAT); | What is the average donation amount for each age group in 2021? | SELECT AVG(TotalDonation) as 'Average Donation Amount' FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY FLOOR(DonorAge / 10) * 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255), type VARCHAR(255), revenue FLOAT); INSERT INTO restaurants (id, name, type, revenue) VALUES (1, 'Restaurant A', 'Vegan', 5000.00), (2, 'Restaurant B', 'Asian Vegan', 6000.00), (3, 'Restaurant C', 'Italian Vegan', 7000.00); | What is the maximum revenue for a restaurant in the 'Vegan' category? | SELECT MAX(revenue) FROM restaurants WHERE type LIKE '%Vegan%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR, platform VARCHAR); INSERT INTO songs (id, title, platform) VALUES (1, 'Song1', 'Spotify'), (2, 'Song2', 'Apple Music'), (3, 'Song3', 'YouTube'), (4, 'Song4', 'Spotify'), (5, 'Song5', 'Apple Music'), (6, 'Song6', 'YouTube'), (7, 'Song7', 'Pandora'), (8, 'Song8', 'Spotify'), (9, 'Song9', 'Tidal'), (10, 'Song10', 'Apple Music'); | How many unique streaming platforms have songs been played on? | SELECT DISTINCT platform FROM songs; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.research (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255)); INSERT INTO biotech.research (id, name, country, type) VALUES (1, 'ProjectA', 'India', 'Genetics'), (2, 'ProjectB', 'China', 'Bioprocess'), (3, 'ProjectC', 'India', 'Genetics'); | Delete a specific genetic research project | DELETE FROM biotech.research WHERE name = 'ProjectA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft_Manufacturing (id INT, manufacturer VARCHAR(20), cost INT, manufacturing_date DATE); INSERT INTO Spacecraft_Manufacturing (id, manufacturer, cost, manufacturing_date) VALUES (1, 'NASA', 6000000, '2021-10-01'); | What are the names of the spacecraft manufactured by NASA and their manufacturing dates? | SELECT manufacturer, manufacturing_date FROM Spacecraft_Manufacturing WHERE manufacturer = 'NASA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, revenue FLOAT, cloud_pms BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, revenue, cloud_pms) VALUES (1, 'Hotel A', 'France', 1000000, true), (2, 'Hotel B', 'Germany', 800000, false), (3, 'Hotel C', 'France', 1200000, true); INSERT INTO hotels (hotel_id, hotel_name, country, revenue, cloud_pms) VALUES (4, 'Hotel D', 'UK', 900000, true), (5, 'Hotel E', 'Spain', 700000, false); | What is the average revenue per hotel for hotels in Europe that have adopted cloud PMS? | SELECT AVG(revenue) FROM hotels WHERE cloud_pms = true AND country LIKE 'Europe%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (id INT, name VARCHAR(100), span FLOAT); INSERT INTO Bridges (id, name, span) VALUES (1, 'Golden Gate Bridge', 4200), (2, 'Bay Bridge', 2300), (3, 'Chesapeake Bay Bridge', 4800); | How many bridges in the database have a span greater than 1000 feet? | SELECT COUNT(*) FROM Bridges WHERE span > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(255), country VARCHAR(255), email VARCHAR(255)); INSERT INTO players (id, name, country, email) VALUES (1, 'John Doe', 'UK', 'johndoe@example.com'), (2, 'Jane Doe', 'USA', 'janedoe@example.com'); | Update the email addresses of players living in the UK. | UPDATE players SET email = CONCAT(SUBSTRING_INDEX(email, '@', 1), '_uk', '@example.com') WHERE country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, item_name VARCHAR(50), quantity INT, ship_date DATE, origin_country VARCHAR(50), destination_country VARCHAR(50)); INSERT INTO shipments (id, item_name, quantity, ship_date, origin_country, destination_country) VALUES (1, 'Apples', 100, '2021-01-02', 'USA', 'Canada'); INSERT INTO shipments (id, item_name, quantity, ship_date, origin_country, destination_country) VALUES (2, 'Bananas', 200, '2021-01-05', 'USA', 'Canada'); | What is the total quantity of items shipped from the USA to Canada between January 1, 2021 and January 15, 2021? | SELECT SUM(quantity) FROM shipments WHERE origin_country = 'USA' AND destination_country = 'Canada' AND ship_date BETWEEN '2021-01-01' AND '2021-01-15'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organisations (OrganisationID INT, Organisation VARCHAR(50), Type VARCHAR(20), Location VARCHAR(50));CREATE TABLE CircularEconomyInitiatives (InitiativeID INT, Organisation VARCHAR(50), InitiativeType VARCHAR(20), StartDate DATE, EndDate DATE);CREATE VIEW OngoingInitiatives AS SELECT Organisation, InitiativeType FROM CircularEconomyInitiatives CI WHERE CI.EndDate IS NULL; | Show non-profit organizations with ongoing circular economy initiatives in Africa. | SELECT Organisation FROM OngoingInitiatives OI INNER JOIN Organisations O ON OI.Organisation = O.Organisation WHERE O.Type = 'Non-Profit' AND O.Location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2)); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (1, 'John Doe', 'HR', 60000.00), (2, 'Jane Smith', 'IT', 70000.00), (3, 'Mike Johnson', 'HR', 80000.00), (4, 'Emma White', 'Finance', 90000.00); CREATE TABLE Departments (Department VARCHAR(50), Manager VARCHAR(50)); INSERT INTO Departments (Department, Manager) VALUES ('HR', 'Peter'), ('IT', 'Sarah'), ('Finance', 'David'); | Who are the top 3 highest paid employees by department? | SELECT e.Department, e.Name, e.Salary FROM Employees e JOIN (SELECT Department, MAX(Salary) as MaxSalary FROM Employees GROUP BY Department) m ON e.Department = m.Department AND e.Salary = m.MaxSalary ORDER BY e.Salary DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE av_sales (id INT, make VARCHAR, model VARCHAR, year INT, region VARCHAR, sold INT); | How many autonomous vehicles were sold by region in the year 2020? | SELECT region, SUM(sold) as total_sold FROM av_sales WHERE year = 2020 AND model LIKE '%autonomous%' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE OperationsData (id INT, operation VARCHAR(255), year INT, cost INT); INSERT INTO OperationsData (id, operation, year, cost) VALUES (1, 'drilling', 2021, 1000), (2, 'mining', 2021, 2000), (3, 'excavation', 2022, 1500); | What was the total 'cost' of 'mining_operations' in the 'OperationsData' table for '2021'? | SELECT SUM(cost) FROM OperationsData WHERE operation = 'mining_operations' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); | Show the number of restorative justice programs by location and year | SELECT location, YEAR(start_date) AS Year, COUNT(*) AS Programs FROM programs WHERE type = 'Restorative Justice' GROUP BY location, YEAR(start_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (ID INT, RiskAssessmentModel VARCHAR(50), ClaimAmount DECIMAL(10, 2)); INSERT INTO Policies (ID, RiskAssessmentModel, ClaimAmount) VALUES (1, 'Standard', 1000.00), (2, 'Premium', 500.00), (3, 'Standard', 1500.00), (4, 'Basic', 2000.00); CREATE TABLE RiskAssessmentModels (ID INT, ModelName VARCHAR(50)); INSERT INTO RiskAssessmentModels (ID, ModelName) VALUES (1, 'Standard'), (2, 'Premium'), (3, 'Basic'); | What is the total claim amount for each risk assessment model? | SELECT RiskAssessmentModel, SUM(ClaimAmount) FROM Policies GROUP BY RiskAssessmentModel; | gretelai_synthetic_text_to_sql |
CREATE TABLE readers (id INT, age INT, gender VARCHAR(10), article_id INT, author_id INT);CREATE TABLE articles (id INT, title VARCHAR(100), date DATE, topic VARCHAR(50), political_ideology VARCHAR(50)); INSERT INTO readers VALUES (1, 45, 'Female', 1, 1); INSERT INTO articles VALUES (1, 'Politics', '2022-01-01', 'Politics', 'Liberal'); | What is the distribution of readers by age and gender for articles about politics, categorized by the political ideology of the author? | SELECT articles.political_ideology, readers.gender, readers.age, COUNT(readers.id) FROM readers INNER JOIN articles ON readers.article_id = articles.id GROUP BY articles.political_ideology, readers.gender, readers.age; | gretelai_synthetic_text_to_sql |
CREATE TABLE railway_projects (project_id INT, project_name VARCHAR(100), state CHAR(2), start_date DATE, cost FLOAT); INSERT INTO railway_projects VALUES (1, 'Northeast Corridor Upgrade', 'NY', '2021-01-01', 500000000), (2, 'Keystone Corridor Improvement', 'PA', '2020-06-15', 250000000), (3, 'Ethan Allen Express Extension', 'VT', '2022-01-01', 300000000); | What are the total costs of all railway projects in the northeast that started after 2020? | SELECT SUM(cost) FROM railway_projects WHERE state IN ('CT', 'ME', 'MD', 'MA', 'MI', 'NH', 'NJ', 'NY', 'OH', 'PA', 'RI', 'VT', 'VA', 'WI') AND start_date > '2020-01-01'; | gretelai_synthetic_text_to_sql |
SAME AS ABOVE | Delete all records of employees who identify as non-binary and work in the finance department. | DELETE FROM Employees WHERE Gender = 'Non-binary' AND Department = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (id INT, name VARCHAR(50), region VARCHAR(50), built_year INT, efficiency FLOAT); INSERT INTO wind_farms (id, name, region, built_year, efficiency) VALUES (1, 'WindFarm1', 'Europe', 2016, 0.45), (2, 'WindFarm2', 'Europe', 2017, 0.50); | What is the maximum energy efficiency (in %) of wind farms in 'Europe' that were built after '2015'? | SELECT MAX(efficiency) FROM wind_farms WHERE region = 'Europe' AND built_year > 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE areas (id INT, name VARCHAR(20)); INSERT INTO areas (id, name) VALUES (1, 'Urban'), (2, 'Rural'); CREATE TABLE budget (item VARCHAR(20), area_id INT, amount INT); INSERT INTO budget (item, area_id, amount) VALUES ('Utilities', 1, 6000000), ('Utilities', 2, 3500000); | What is the maximum budget allocated for utilities in urban areas? | SELECT MAX(amount) FROM budget WHERE item = 'Utilities' AND area_id = (SELECT id FROM areas WHERE name = 'Urban'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'IT', 70000.00), (2, 'Female', 'IT', 68000.00); | What is the average salary of male employees in the IT department? | SELECT AVG(Salary) FROM Employees WHERE Gender = 'Male' AND Department = 'IT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Households (HouseholdID INTEGER, HouseholdMembers INTEGER, HouseholdIncome INTEGER, HouseholdState TEXT); | What is the average income of households with 3 members in the state of Texas? | SELECT AVG(HouseholdIncome) FROM Households H WHERE H.HouseholdMembers = 3 AND H.HouseholdState = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50), production_rate FLOAT); INSERT INTO wells (well_id, well_name, region, production_rate) VALUES (5, 'Well E', 'South China Sea', 4000), (6, 'Well F', 'South China Sea', 9000); | What is the total production of wells in the 'South China Sea'? | SELECT SUM(production_rate) FROM wells WHERE region = 'South China Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255), genre VARCHAR(255), home_country VARCHAR(255)); CREATE TABLE artist_concerts (artist_id INT, country VARCHAR(255), city VARCHAR(255)); INSERT INTO artists (id, name, genre, home_country) VALUES (1, 'Taylor Swift', 'Country Pop', 'United States'); INSERT INTO artist_concerts (artist_id, country, city) VALUES (1, 'Canada', 'Toronto'); | Show the names and genres of all artists who have never performed in the United States. | SELECT a.name, a.genre FROM artists a WHERE a.id NOT IN (SELECT ac.artist_id FROM artist_concerts ac WHERE ac.country = 'United States'); | gretelai_synthetic_text_to_sql |
CREATE TABLE justice_data.court_hearings (id INT, case_number INT, hearing_date DATE, defendant_race VARCHAR(50)); CREATE TABLE justice_data.sentencing (id INT, case_number INT, offender_id INT, sentence_length INT, conviction VARCHAR(50)); | What is the total number of cases heard in the justice_data schema's court_hearings table where the defendant is of Indigenous origin, and the average sentence length for those cases? | SELECT CH.defendant_race, COUNT(*), AVG(S.sentence_length) FROM justice_data.court_hearings CH JOIN justice_data.sentencing S ON CH.case_number = S.case_number WHERE CH.defendant_race LIKE '%Indigenous%' GROUP BY CH.defendant_race; | gretelai_synthetic_text_to_sql |
CREATE TABLE Languages (Language VARCHAR(50), Status VARCHAR(50)); INSERT INTO Languages (Language, Status) VALUES ('Tigrinya', 'Vulnerable'), ('Amharic', 'Vulnerable'); | Delete the records of the languages 'Tigrinya' and 'Amharic' from the Languages table. | DELETE FROM Languages WHERE Language IN ('Tigrinya', 'Amharic'); | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (investment_id INT, investment FLOAT, region VARCHAR(50), year INT); INSERT INTO network_investments (investment_id, investment, region, year) VALUES (1, 1000000, 'North America', 2020), (2, 2000000, 'South America', 2019), (3, 1500000, 'Europe', 2020); | What is the total number of network infrastructure investments in each region, grouped by year? | SELECT year, region, SUM(investment) AS total_investment FROM network_investments GROUP BY year, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO forests (id, name, hectares, country) VALUES (1, 'Sundarbans', 133000.0, 'India'), (2, 'Great Himalayan National Park', 90500.0, 'India'), (3, 'Xishuangbanna', 242000.0, 'China'), (4, 'Wuyishan', 56000.0, 'China'); | Identify forests with the largest wildlife habitat in India and China? | SELECT forests.name FROM forests WHERE forests.country IN ('India', 'China') AND forests.hectares = (SELECT MAX(hectares) FROM forests WHERE forests.country IN ('India', 'China')); | gretelai_synthetic_text_to_sql |
CREATE TABLE mumbai.lines (id INT, line_name VARCHAR); CREATE TABLE mumbai.revenue (id INT, line_id INT, daily_revenue DECIMAL); | What is the maximum daily revenue for each line in the 'mumbai' schema? | SELECT mumbai.lines.line_name, MAX(mumbai.revenue.daily_revenue) FROM mumbai.lines INNER JOIN mumbai.revenue ON mumbai.lines.id = mumbai.revenue.line_id GROUP BY mumbai.lines.line_name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name VARCHAR(50), country VARCHAR(50), funding DECIMAL(10,2));INSERT INTO biotech.startups(id, name, country, funding) VALUES (1, 'StartupA', 'US', 1500000.00), (2, 'StartupB', 'Canada', 2000000.00), (3, 'StartupC', 'Mexico', 500000.00), (4, 'StartupD', 'US', 1000000.00), (5, 'StartupE', 'Brazil', 750000.00); | List the names of all biotech startups that have received more funding than the average funding amount per country. | SELECT name FROM biotech.startups s1 WHERE s1.funding > (SELECT AVG(funding) FROM biotech.startups s2 WHERE s2.country = s1.country); | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (menu_id INT PRIMARY KEY, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); | What are the names and prices of all items in the "Desserts" category? | SELECT item_name, price FROM Menu WHERE category = 'Desserts'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.trips_by_week (id SERIAL PRIMARY KEY, vehicle_type TEXT, city TEXT, week_start DATE, week_trips INTEGER); INSERT INTO public.trips_by_week (vehicle_type, city, week_start, week_trips) VALUES ('autonomous_taxi', 'San Francisco', '2022-01-01', 7000), ('autonomous_taxi', 'San Francisco', '2022-01-08', 6500), ('autonomous_taxi', 'San Francisco', '2022-01-15', 6000); | What is the minimum number of trips taken by autonomous taxis in San Francisco in a week? | SELECT MIN(week_trips) FROM public.trips_by_week WHERE vehicle_type = 'autonomous_taxi' AND city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_metrics (id INT, farm_id INT, country VARCHAR(50), health_score INT); INSERT INTO health_metrics | Compare fish health metrics across multiple countries | SELECT health_score FROM health_metrics WHERE country IN ('Norway', 'Chile', 'Scotland') GROUP BY country ORDER BY health_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), Country TEXT); | What is the maximum donation amount from Australia? | SELECT MAX(DonationAmount) FROM Donors WHERE Country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, program TEXT, amount INT, donation_date DATE); INSERT INTO donors (id, name, program, amount, donation_date) VALUES (1, 'John Doe', 'Arts', 500, '2022-04-15'), (2, 'Jane Smith', 'Education', 1000, '2022-02-28'), (3, 'Alice Johnson', 'Arts', 750, '2021-12-31'), (4, 'Grace Wilson', 'Arts', 1000, '2022-05-12'), (5, 'Harry Moore', 'Education', 250, '2022-03-14'); | What is the total amount donated by new donors in Q2 2022? | SELECT SUM(amount) FROM (SELECT amount FROM donors WHERE donation_date >= '2022-04-01' AND donation_date < '2022-07-01' GROUP BY id HAVING COUNT(*) = 1) AS new_donors; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_incident_costs (incident_id INTEGER, incident_cost FLOAT, region TEXT); INSERT INTO ai_safety_incident_costs (incident_id, incident_cost, region) VALUES (8, 5000, 'Oceania'), (9, 7000, 'Oceania'), (10, 6000, 'Africa'); | Calculate the average AI safety incident cost in Oceania. | SELECT region, AVG(incident_cost) FROM ai_safety_incident_costs WHERE region = 'Oceania' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(50), revenue INT); INSERT INTO Events (event_id, event_name, revenue) VALUES (6, 'Theater Performance', 15000); | What was the total revenue from the 'Theater Performance' event? | SELECT revenue FROM Events WHERE event_name = 'Theater Performance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE criminal_cases (case_id INT, court_type VARCHAR(20), year INT); | What is the total number of criminal cases heard in district courts in New York in 2019? | SELECT COUNT(*) FROM criminal_cases WHERE court_type = 'district' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO companies (id, name, type, location, investment) VALUES (3, 'GenoSolutions', 'Genetic Research', 'New York', 8000000); INSERT INTO companies (id, name, type, location, investment) VALUES (4, 'BioNexus', 'Bioprocess', 'New York', 6000000); | What is the total investment for genetic research companies in New York? | SELECT SUM(investment) FROM companies WHERE type = 'Genetic Research' AND location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (item VARCHAR(255), daily_waste NUMERIC, customer_group VARCHAR(50), date DATE); INSERT INTO inventory (item, daily_waste, customer_group, date) VALUES ('Chicken Burger', 20, 'Millennials', '2021-10-01'), ('Fish and Chips', 15, 'Gen X', '2021-10-01'), ('BBQ Ribs', 10, 'Baby Boomers', '2021-10-01'); | Which customer demographic groups have the highest total waste? | SELECT customer_group, SUM(daily_waste) FROM inventory WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY) GROUP BY customer_group ORDER BY SUM(daily_waste) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, country TEXT, donation_amount FLOAT); INSERT INTO donors (donor_id, donor_name, country, donation_amount) VALUES (1, 'John Doe', 'USA', 200.00), (2, 'Jane Smith', 'Canada', 300.00); | What is the total donation amount given by individual donors from the USA in the year 2021? | SELECT SUM(donation_amount) FROM donors WHERE country = 'USA' AND YEAR(donation_date) = 2021 AND donor_type = 'individual'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production (region VARCHAR(20), chemical VARCHAR(30), quantity INT); INSERT INTO chemical_production (region, chemical, quantity) VALUES ('South America', 'Isobutanol', 4000), ('South America', 'Methanol', 7000); CREATE TABLE environmental_impact (chemical VARCHAR(30), impact_score INT); INSERT INTO environmental_impact (chemical, impact_score) VALUES ('Isobutanol', 70), ('Methanol', 60), ('Ethylene', 67); | Find the names and quantities of chemical substances that are both produced in the South America region and have an impact score greater than 65. | SELECT cp.chemical, cp.quantity FROM chemical_production cp JOIN environmental_impact ei ON cp.chemical = ei.chemical WHERE cp.region = 'South America' AND ei.impact_score > 65; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndianSales (id INT, vehicle_type VARCHAR(50), quantity INT, country VARCHAR(50), quarter INT, year INT); INSERT INTO IndianSales (id, vehicle_type, quantity, country, quarter, year) VALUES (1, 'Sedan', 1000, 'India', 2, 2021), (2, 'Sedan', 1200, 'India', 3, 2021), (3, 'Hatchback', 1500, 'India', 2, 2021), (4, 'Hatchback', 1700, 'India', 3, 2021); | How many sedans were sold in India in Q2 2021? | SELECT SUM(quantity) FROM IndianSales WHERE vehicle_type = 'Sedan' AND country = 'India' AND quarter = 2 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50)); INSERT INTO MiningSites (SiteID, SiteName, Location) VALUES (1, 'Site A', 'New York'), (2, 'Site B', 'Ohio'), (3, 'Site C', 'Alberta'); CREATE TABLE WasteProduction (SiteID INT, ProductionDate DATE, WasteAmount INT); INSERT INTO WasteProduction (SiteID, ProductionDate, WasteAmount) VALUES (1, '2021-01-01', 1000), (1, '2021-02-01', 1200), (2, '2021-01-01', 1500), (2, '2021-02-01', 1800), (3, '2021-01-01', 2000), (3, '2021-02-01', 2200); | Show the monthly change in waste production for each mining site | SELECT s.SiteName, s.Location, DATE_FORMAT(w.ProductionDate, '%Y-%m') as Month, (SUM(w.WasteAmount) - LAG(SUM(w.WasteAmount)) OVER (PARTITION BY s.SiteID ORDER BY w.ProductionDate)) as MonthlyChangeInWasteProduction FROM WasteProduction w INNER JOIN MiningSites s ON w.SiteID = s.SiteID GROUP BY w.SiteID, Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, hospital_id INT, clinic_id INT, name TEXT, location TEXT); INSERT INTO patients (id, hospital_id, clinic_id, name, location) VALUES (1, 1, NULL, 'Patient A', 'suburban'); INSERT INTO patients (id, hospital_id, clinic_id, name, location) VALUES (2, 2, NULL, 'Patient B', 'suburban'); INSERT INTO patients (id, hospital_id, clinic_id, name, location) VALUES (3, NULL, 1, 'Patient C', 'suburban'); | Find the number of unique patients served by hospitals and clinics in 'suburban' areas. | SELECT COUNT(DISTINCT name) FROM patients WHERE location = 'suburban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (Id INT, Name VARCHAR(50), Type VARCHAR(50), Flag VARCHAR(50)); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (1, 'Aurelia', 'Tanker', 'Panama'); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (2, 'Barracuda', 'Bulk Carrier', 'Marshall Islands'); CREATE TABLE Cargo (Id INT, VesselId INT, CargoType VARCHAR(50), Quantity INT); INSERT INTO Cargo (Id, VesselId, CargoType, Quantity) VALUES (1, 1, 'Oil', 5000); INSERT INTO Cargo (Id, VesselId, CargoType, Quantity) VALUES (2, 2, 'Coal', 8000); | What is the total cargo quantity for each cargo type and vessel flag? | SELECT Vessels.Flag, Cargo.CargoType, SUM(Cargo.Quantity) as TotalQuantity FROM Cargo JOIN Vessels ON Cargo.VesselId = Vessels.Id GROUP BY Vessels.Flag, Cargo.CargoType; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (policyholder_id INT, state VARCHAR(2)); INSERT INTO policyholders (policyholder_id, state) VALUES (1, 'OH'), (2, 'OH'), (3, 'NY'); | Count the number of policyholders in Ohio | SELECT COUNT(*) FROM policyholders WHERE state = 'OH'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_by_month (product_id INT, sale_date DATE, sales INT, product_category VARCHAR(50)); INSERT INTO sales_by_month (product_id, sale_date, sales, product_category) VALUES (1, '2021-01-01', 500, 'Foundation'), (2, '2021-01-01', 800, 'Lipstick'); | Find the cosmetics with the highest sales in each category for the past 12 months. | SELECT product_category, product_id, MAX(sales) AS max_sales FROM sales_by_month WHERE sale_date >= DATEADD(month, -12, CURRENT_DATE) GROUP BY product_category, product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyNumber INT, PolicyholderID INT, PolicyState VARCHAR(20)); CREATE TABLE Claims (PolicyholderID INT, ClaimAmount DECIMAL(10,2), PolicyState VARCHAR(20)); INSERT INTO Policies (PolicyNumber, PolicyholderID, PolicyState) VALUES (3001, 13, 'Tokyo'), (3002, 14, 'Tokyo'), (3003, 15, 'Delhi'); INSERT INTO Claims (PolicyholderID, ClaimAmount, PolicyState) VALUES (13, 1200, 'Tokyo'), (14, 1300, 'Tokyo'), (15, 1400, 'Delhi'); | List policy numbers and claim amounts for policyholders living in 'Tokyo' or 'Delhi' who have filed a claim. | SELECT Policies.PolicyNumber, Claims.ClaimAmount FROM Policies JOIN Claims ON Policies.PolicyholderID = Claims.PolicyholderID WHERE Policies.PolicyState IN ('Tokyo', 'Delhi'); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Central'); CREATE TABLE calls (call_id INT, district_id INT, response_time INT); | What is the minimum response time for emergency calls in the 'Central' district? | SELECT MIN(c.response_time) FROM calls c WHERE c.district_id = (SELECT district_id FROM districts WHERE district_name = 'Central'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, Team VARCHAR(20), State VARCHAR(20)); INSERT INTO Policies VALUES (1, 'Diverse Team', 'New York'), (2, 'United Team', 'Illinois'), (3, 'Diverse Team', 'Texas'), (4, 'Global Team', 'New York'), (5, 'Diverse Team', 'Illinois'); | How many policies does the 'Diverse Team' have in 'New York' and 'Illinois'? | SELECT Team, COUNT(*) FROM Policies WHERE State IN ('New York', 'Illinois') AND Team = 'Diverse Team' GROUP BY Team; | gretelai_synthetic_text_to_sql |
CREATE TABLE highways (id INT, name TEXT, state TEXT, num_lanes INT); INSERT INTO highways (id, name, state, num_lanes) VALUES (1, 'AZ-1 Interstate', 'AZ', 8); | What is the maximum number of lanes for highways in Arizona? | SELECT MAX(num_lanes) FROM highways WHERE state = 'AZ'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo (id INT PRIMARY KEY, description VARCHAR(255)); | Delete the cargo record with ID 33344 from the "cargo" table | WITH deleted_cargo AS (DELETE FROM cargo WHERE id = 33344 RETURNING id, description) SELECT * FROM deleted_cargo; | gretelai_synthetic_text_to_sql |
CREATE TABLE hockey_matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), location VARCHAR(50), date DATE, goals_home INT, goals_away INT); INSERT INTO hockey_matches (id, home_team, away_team, location, date, goals_home, goals_away) VALUES (1, 'Toronto Maple Leafs', 'Montreal Canadiens', 'Toronto', '2022-03-10', 4, 2); INSERT INTO hockey_matches (id, home_team, away_team, location, date, goals_home, goals_away) VALUES (2, 'Boston Bruins', 'New York Rangers', 'Boston', '2022-03-15', 3, 5); | What is the maximum number of goals scored by a single player in a hockey match in the 'hockey_matches' table? | SELECT MAX(goals_home), MAX(goals_away) FROM hockey_matches; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_stats (country VARCHAR(255), year INT, energy_efficiency_index FLOAT); | Show the energy efficiency statistics of the top 5 countries in the world | SELECT country, energy_efficiency_index FROM energy_efficiency_stats WHERE country IN (SELECT country FROM (SELECT country, AVG(energy_efficiency_index) as avg_efficiency FROM energy_efficiency_stats GROUP BY country ORDER BY avg_efficiency DESC LIMIT 5) as temp) ORDER BY energy_efficiency_index DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE CollaborationData (CollaborationID INT, Artist1 VARCHAR(100), Artist2 VARCHAR(100), Genre VARCHAR(50)); INSERT INTO CollaborationData (CollaborationID, Artist1, Artist2, Genre) VALUES (1, 'Taylor Swift', 'Ed Sheeran', 'Pop'), (2, 'Ariana Grande', 'Justin Bieber', 'Pop'); | What is the ratio of male to female collaborations in the Pop genre? | SELECT (SELECT COUNT(*) FROM CollaborationData WHERE (Artist1 = 'Male' OR Artist2 = 'Male') AND Genre = 'Pop') / (SELECT COUNT(*) FROM CollaborationData WHERE (Artist1 = 'Female' OR Artist2 = 'Female') AND Genre = 'Pop') AS Ratio; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Male', 'IT'), (2, 'Female', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Male', 'HR'), (5, 'Non-binary', 'IT'); | What is the number of non-binary employees in each department? | SELECT Department, COUNT(*) FROM Employees WHERE Gender = 'Non-binary' GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE district (did INT, name VARCHAR(255)); INSERT INTO district VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE calls (call_id INT, district_id INT, response_time INT, year INT); | Determine the total response time for emergency calls in each district in 2021. | SELECT d.name, SUM(c.response_time) FROM district d JOIN calls c ON d.did = c.district_id WHERE c.year = 2021 AND c.response_time < 60 GROUP BY d.did; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (policyholder_id INT, first_name VARCHAR(50), last_name VARCHAR(50)); CREATE TABLE claims (claim_id INT, policyholder_id INT, claim_date DATE); | Find the number of policyholders who have had at least one claim in the past year. | SELECT COUNT(DISTINCT policyholders.policyholder_id) FROM policyholders INNER JOIN claims ON policyholders.policyholder_id = claims.policyholder_id WHERE claims.claim_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_unions.strikes (id INT, union TEXT, year INT, duration INT); | What is the total number of strikes in 'labor_unions'? | SELECT SUM(duration) FROM labor_unions.strikes; | 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.