context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(50)); CREATE TABLE grants (grant_id INT, faculty_id INT, grant_amount DECIMAL(10,2)); INSERT INTO faculty (faculty_id, faculty_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO grants (grant_id, faculty_id, grant_amount) VALUES (100, 1, 50000), (101,... | How many research grants were awarded to each faculty member? | SELECT f.faculty_name, COUNT(g.grant_id) AS num_grants FROM faculty f INNER JOIN grants g ON f.faculty_id = g.faculty_id GROUP BY f.faculty_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Feedback (Library VARCHAR(255), Region VARCHAR(255), Score INT); INSERT INTO Feedback (Library, Region, Score) VALUES ('Northeast Central Library', 'Northeast', 9), ('Southeast Central Library', 'Southeast', 8), ('Southwest Central Library', 'Southwest', 7), ('Northwest Central Library', 'Northwest', 10); | What is the maximum citizen feedback score for public libraries in the Northeast region? | SELECT MAX(Score) FROM Feedback WHERE Region = 'Northeast' AND Library LIKE '%Public Library%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE army_recruits (recruit_id INT, name VARCHAR(50), rank VARCHAR(50), join_date DATE); | Insert records of new recruits who joined the army in 2023 into the army_recruits table | INSERT INTO army_recruits (recruit_id, name, rank, join_date) VALUES (1, 'Minh Nguyen', 'Private', '2023-04-01'), (2, 'Aisha Said', 'Private', '2023-07-15'), (3, 'Konstantinos Papadopoulos', 'Private', '2023-11-27'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crew_members (id INT, name VARCHAR(50), nationality VARCHAR(20), position VARCHAR(20), hire_date DATE); INSERT INTO crew_members (id, name, nationality, position, hire_date) VALUES (1, 'John Doe', 'Canadian', 'Captain', '2000-01-01'); INSERT INTO crew_members (id, name, nationality, position, hire_date) VA... | Update the 'position' column to 'Senior Officer' in the 'crew_members' table for the crew member with id = 1 | UPDATE crew_members SET position = 'Senior Officer' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name TEXT, region TEXT, total_revenue DECIMAL(10,2)); INSERT INTO attorneys (id, name, region, total_revenue) VALUES (1, 'Smith', 'boston', 50000.00), (2, 'Johnson', 'nyc', 75000.00), (3, 'Williams', 'boston', 60000.00); | What is the total revenue and count of cases for attorneys in the 'boston' region? | SELECT SUM(total_revenue) as total_revenue, COUNT(*) as case_count FROM attorneys WHERE region = 'boston'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, name VARCHAR(255)); INSERT INTO regions (region_id, name) VALUES (1, 'West Coast'), (2, 'Midwest'), (3, 'Southeast'); CREATE TABLE natural_disasters (disaster_id INT, region_id INT, date DATE); INSERT INTO natural_disasters (disaster_id, region_id, date) VALUES (1, 1, '2022-01-01'),... | How many natural disasters were recorded in each region in the last 6 months? | SELECT region_id, name, COUNT(*) as total_disasters FROM natural_disasters nd JOIN regions r ON nd.region_id = r.region_id WHERE date >= CURDATE() - INTERVAL 6 MONTH GROUP BY region_id, name; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_rosters (roster_id INT, member_id INT, industry VARCHAR(15)); INSERT INTO union_rosters (roster_id, member_id, industry) VALUES (1, 1, 'Manufacturing'), (2, 2, 'Construction'), (3, 3, 'Retail'); | How many union members work in each industry? | SELECT industry, COUNT(*) as num_members FROM union_rosters GROUP BY industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, company_name TEXT, sector TEXT); CREATE TABLE esg_scores (company_id INT, esg_score INT); | What is the average ESG score for companies in the renewable energy sector? | SELECT AVG(esg_score) FROM companies c JOIN esg_scores s ON c.company_id = s.company_id WHERE c.sector = 'renewable energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600); | What is the average number of beds in hospitals and total number of beds by city? | SELECT city, AVG(beds) as avg_beds, SUM(beds) as total_beds FROM hospitals GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name TEXT, city TEXT); CREATE TABLE transactions (client_id INT, amount DECIMAL(10,2), transaction_time TIMESTAMP); INSERT INTO clients (id, name, city) VALUES (1, 'Zara', 'New York'); | Insert a new transaction with amount 800 for client 'Zara' living in 'New York' on '2022-04-01'. | INSERT INTO transactions (client_id, amount, transaction_time) VALUES (1, 800, '2022-04-01 12:00:00'); | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities.buildings (id INT, city VARCHAR(255), co2_emissions INT); CREATE VIEW smart_cities.buildings_view AS SELECT id, city, co2_emissions FROM smart_cities.buildings; | Get the city name and the difference between the maximum and minimum CO2 emissions of its buildings for each city in the 'smart_cities' schema. | SELECT city, MAX(co2_emissions) - MIN(co2_emissions) FROM smart_cities.buildings_view GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255)); INSERT INTO brands VALUES (1, 'BrandA'), (2, 'BrandB'); CREATE TABLE products (product_id INT, brand_id INT, sustainable_material_qty INT); | What is the average quantity of sustainable material used per product by each brand? | SELECT brand_id, AVG(sustainable_material_qty) as avg_qty FROM products GROUP BY brand_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (Product VARCHAR(50), Microplastics_Weight DECIMAL(10,2)); INSERT INTO Products (Product, Microplastics_Weight) VALUES ('Cleanser', 0.25), ('Moisturizer', 0.15), ('Toner', 0.1); | What is the total weight of microplastics in all products? | SELECT SUM(Microplastics_Weight) FROM Products; | gretelai_synthetic_text_to_sql |
CREATE TABLE login_attempts_2 (id INT, ip_address VARCHAR(15), login_status VARCHAR(10)); INSERT INTO login_attempts_2 (id, ip_address, login_status) VALUES (1, '192.168.1.100', 'successful'), (2, '192.168.1.101', 'suspicious'), (3, '192.168.1.102', 'successful'), (4, '192.168.1.103', 'unsuccessful'), (5, '192.168.1.10... | What are the unique IP addresses associated with successful login attempts, ordered by the count of successful login attempts? | SELECT ip_address, COUNT(*) as count FROM login_attempts_2 WHERE login_status = 'successful' GROUP BY ip_address ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups( startup_id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), funding DECIMAL(10,2)); CREATE TABLE if not exists biotech.funding_rounds( funding_round_id INT PRIMARY KEY, startup_id INT, amount DECIMAL(10,2), FOREIGN KEY (startup_i... | What is the total funding received by startups in the UK? | SELECT SUM(fr.amount) AS total_funding FROM biotech.startups s JOIN biotech.funding_rounds fr ON s.startup_id = fr.startup_id WHERE s.location = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Courts (Location VARCHAR(255), JudgeID INT); CREATE TABLE Cases (CaseID INT, JudgeID INT); | What is the maximum number of cases handled by a single judge in a single court location? | SELECT MAX(Cases.CaseID) OVER(PARTITION BY Courts.Location) FROM Courts JOIN Cases ON Courts.JudgeID = Cases.JudgeID; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farm (id INT, country VARCHAR(20), name VARCHAR(50), capacity FLOAT); INSERT INTO wind_farm (id, country, name, capacity) VALUES (1, 'Canada', 'Windfarm 1', 120.5), (2, 'Brazil', 'Windfarm 2', 180.6), (3, 'Canada', 'Windfarm 3', 200.7); | What is the minimum installed capacity for wind farms in Canada and Brazil? | SELECT MIN(capacity) FROM wind_farm WHERE country IN ('Canada', 'Brazil'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteOrbits (SatelliteID INT, OrbitType VARCHAR(50), OrbitHeight INT); INSERT INTO SatelliteOrbits (SatelliteID, OrbitType, OrbitHeight) VALUES (101, 'LEO', 500), (201, 'MEO', 8000), (301, 'GEO', 36000), (401, 'LEO', 600), (501, 'MEO', 10000), (601, 'LEO', 450), (701, 'LEO', 550); CREATE TABLE SpaceLau... | Identify the countries with the most satellites in low Earth orbit (LEO) based on the SatelliteOrbits and SpaceLaunches tables? | SELECT s.Country, COUNT(so.SatelliteID) AS TotalSatellitesInLEO FROM SatelliteOrbits so JOIN SpaceLaunches s ON so.SatelliteID = s.SatelliteID WHERE OrbitType = 'LEO' GROUP BY s.Country ORDER BY TotalSatellitesInLEO DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (ID INT, Region VARCHAR(20), Circular_Economy BOOLEAN, Waste_Generated INT); INSERT INTO Factories (ID, Region, Circular_Economy, Waste_Generated) VALUES (1, 'Region X', TRUE, 500); INSERT INTO Factories (ID, Region, Circular_Economy, Waste_Generated) VALUES (2, 'Region X', FALSE, 700); INSERT IN... | What is the total waste generated by factories in 'Region X' using circular economy practices, and the percentage of waste reduction compared to factories not using circular economy practices? | SELECT (SUM(CASE WHEN Circular_Economy = TRUE THEN Waste_Generated ELSE 0 END) / SUM(Waste_Generated)) * 100 AS 'Percentage of Waste Reduction' FROM Factories WHERE Region = 'Region X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element TEXT, volume INT); INSERT INTO production (year, element, volume) VALUES (2020, 'gadolinium', 5000), (2020, 'holmium', 3000), (2020, 'erbium', 4000); | What is the average production volume of gadolinium, holmium, and erbium in 2020? | SELECT AVG(volume) FROM production WHERE element IN ('gadolinium', 'holmium', 'erbium') AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo (container_type VARCHAR(50), cargo_weight INT); INSERT INTO cargo VALUES ('ContainerA', 1000), ('ContainerA', 1200), ('ContainerB', 1500), ('ContainerB', 1800), ('ContainerC', 2000); | What is the average weight of cargo for each type of container? | SELECT container_type, AVG(cargo_weight) FROM cargo GROUP BY container_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicConsultations (ConsultationID INT, ConsultationName TEXT, ConsultationRegion TEXT, ConsultationCountry TEXT); INSERT INTO PublicConsultations (ConsultationID, ConsultationName, ConsultationRegion, ConsultationCountry) VALUES (1, 'Environment Policy Consultation', 'Scotland', 'UK'), (2, 'Education Ref... | List the number of public consultations held in each region and country? | SELECT ConsultationCountry, ConsultationRegion, COUNT(*) FROM PublicConsultations GROUP BY ConsultationCountry, ConsultationRegion; | gretelai_synthetic_text_to_sql |
CREATE TABLE salesperson (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO salesperson (id, name, region) VALUES (1, 'John Doe', 'East'), (2, 'Jane Smith', 'West'); CREATE TABLE sales (id INT, salesperson_id INT, amount DECIMAL(10, 2)); INSERT INTO sales (id, salesperson_id, amount) VALUES (1, 1, 500.00), (2,... | Calculate total sales for each salesperson | SELECT s.name, SUM(sales.amount) as total_sales FROM salesperson s JOIN sales ON s.id = sales.salesperson_id GROUP BY s.id, s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accidents (aircraft VARCHAR(50), accident_date DATE, description TEXT); INSERT INTO Accidents (aircraft, accident_date, description) VALUES ('Boeing 737', '2019-03-10', 'Engine failure'), ('Airbus A320', '2020-05-05', 'Landing gear failure'); | Which accidents involved Boeing 737 aircraft? | SELECT aircraft, description FROM Accidents WHERE aircraft = 'Boeing 737'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), size FLOAT); INSERT INTO marine_protected_areas (id, name, location, size) VALUES (1, 'Arctic National Wildlife Refuge', 'Arctic Ocean', 30600000); INSERT INTO marine_protected_areas (id, name, location, size) VALUES (2, 'Svalbard Na... | What is the average size of marine protected areas in the Arctic, Atlantic, and Antarctic Oceans? | SELECT AVG(size) FROM marine_protected_areas WHERE location IN ('Arctic Ocean', 'Atlantic Ocean', 'Antarctic Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (station_id INT, station_city VARCHAR(50), station_type VARCHAR(50)); INSERT INTO charging_stations (station_id, station_city, station_type) VALUES (1, 'Los Angeles', 'Level 2'), (2, 'Los Angeles', 'DC Fast Charging'), (3, 'San Diego', 'Level 2'); | How many electric vehicle charging stations are there in each city? | SELECT station_city, COUNT(DISTINCT station_id) FROM charging_stations GROUP BY station_city; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_data (country VARCHAR(50), capacity FLOAT); INSERT INTO landfill_data (country, capacity) VALUES ('Saudi Arabia', 1500000), ('Iran', 1200000), ('Turkey', 900000); | What is the average landfill capacity (in cubic meters) for countries in the Middle East? | SELECT AVG(capacity) FROM landfill_data WHERE country IN ('Saudi Arabia', 'Iran', 'Turkey'); | gretelai_synthetic_text_to_sql |
CREATE TABLE automotive_workers (id INT, name VARCHAR(50), salary FLOAT, industry40 VARCHAR(50), training_type VARCHAR(50)); INSERT INTO automotive_workers (id, name, salary, industry40, training_type) VALUES (1, 'Charlie Davis', 50000.0, 'Automation', 'Online Course'); INSERT INTO automotive_workers (id, name, salary,... | What is the total salary cost of workers in the automotive industry who are part of industry 4.0 training programs, grouped by type of training? | SELECT SUM(salary), training_type FROM automotive_workers WHERE industry = 'Automotive' AND industry40 IS NOT NULL GROUP BY training_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrganicGreens (menu_item VARCHAR(50), quantity_sold INT); INSERT INTO OrganicGreens (menu_item, quantity_sold) VALUES ('Quinoa Salad', 150), ('Tofu Stir Fry', 200), ('Veggie Burger', 250); | What are the top 3 most sold dishes at 'Organic Greens'? | SELECT menu_item, SUM(quantity_sold) as total_sold FROM OrganicGreens GROUP BY menu_item ORDER BY total_sold DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (1, 25, 'Female', 'France'); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (2, 30, 'Male', 'Germany'); CREATE TABLE Games (GameID INT, GameName VARCHAR(20),... | What's the gender ratio of players who play VR games in Europe? | SELECT (COUNT(CASE WHEN Gender = 'Male' THEN 1 END) * 1.0 / COUNT(*)) AS Male_ratio, (COUNT(CASE WHEN Gender = 'Female' THEN 1 END) * 1.0 / COUNT(*)) AS Female_ratio FROM Players INNER JOIN Games ON Players.Location = Games.GameName WHERE Games.VR = true AND Players.Location = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE USBudget (state VARCHAR(30), service VARCHAR(30), budget INT); INSERT INTO USBudget (state, service, budget) VALUES ('California', 'Education', 5000000), ('Texas', 'Education', 7000000), ('Florida', 'Education', 4000000), ('New York', 'Education', 6000000); | What is the percentage of the total budget allocated to education in each state in the US? | SELECT state, (budget * 100.0 / (SELECT SUM(budget) FROM USBudget WHERE service = 'Education')) AS percentage FROM USBudget WHERE service = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (id INT, name VARCHAR(50), province VARCHAR(50), capacity FLOAT); INSERT INTO facilities (id, name, province, capacity) VALUES (1, 'Prince George Mill', 'British Columbia', 500000); | List all timber production facilities in British Columbia and their respective production capacities in cubic meters. | SELECT f.name, f.capacity FROM facilities f WHERE f.province = 'British Columbia'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (name VARCHAR(255), location VARCHAR(255)); CREATE TABLE if not exists biotech.funding (startup_name VARCHAR(255), vc_name VARCHAR(255)); INSERT INTO biotech.startups (name, location) VALUES ('Startup1', 'City1'), ('Startup2', 'City2'); IN... | What are the names of biotech startups that received funding from both VC1 and VC2? | SELECT s.name FROM biotech.startups s JOIN biotech.funding f1 ON s.name = f1.startup_name JOIN biotech.funding f2 ON s.name = f2.startup_name WHERE f1.vc_name = 'VC1' AND f2.vc_name = 'VC2'; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy (country TEXT, waste_generation FLOAT); INSERT INTO circular_economy (country, waste_generation) VALUES ('Country A', 1200), ('Country B', 1500), ('Country C', 1000); | What is the total waste generation in each country for the circular economy initiative? | SELECT country, SUM(waste_generation) FROM circular_economy GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_investment (city VARCHAR(20), year INT, investment_amount FLOAT); INSERT INTO circular_economy_investment (city, year, investment_amount) VALUES ('Boston', 2020, 1000000), ('New York', 2020, 1100000), ('Chicago', 2020, 1300000); | Which city had the highest investment in circular economy initiatives in the year 2020? | SELECT city, MAX(investment_amount) FROM circular_economy_investment GROUP BY year HAVING year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, name VARCHAR(255), year INT, artist_name VARCHAR(255), artist_gender VARCHAR(10)); INSERT INTO artworks (id, name, year, artist_name, artist_gender) VALUES (1, 'Painting1', 1850, 'Anna', 'female'), (2, 'Sculpture1', 1880, 'Bella', 'female'), (3, 'Painting2', 1820, 'Clara', 'female'); | How many artworks were created by female artists in the 19th century? | SELECT COUNT(*) FROM artworks WHERE artist_gender = 'female' AND year BETWEEN 1800 AND 1899; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, dispensary_id INT, name VARCHAR(255)); INSERT INTO initiatives (id, dispensary_id, name) VALUES (1, 1, 'Veteran-owned'), (2, 2, 'Minority-owned'); | List all social equity initiatives and corresponding dispensaries in Massachusetts. | SELECT d.name, i.name as initiative_name FROM dispensaries d INNER JOIN initiatives i ON d.id = i.dispensary_id WHERE d.state = 'MA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'Mohammed Ahmed', 'IL'), (2, 'Sarah Johnson', 'IN'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount... | What is the average claim amount for policyholders in 'IL' or 'IN'? | SELECT AVG(Claims.ClaimAmount) AS AvgClaimAmount FROM Policyholders INNER JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Policyholders.State IN ('IL', 'IN'); | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_revenue (tour_id INT, operator_id INT, revenue INT, tour_type VARCHAR); CREATE VIEW virtual_tour_revenue AS SELECT * FROM tour_revenue WHERE tour_type = 'Virtual'; CREATE TABLE japan_tourism (tourist_id INT, country VARCHAR); CREATE VIEW japan_virtual_tours AS SELECT * FROM virtual_tour_revenue JOIN j... | What is the total revenue generated from virtual tour experiences in Japan? | SELECT SUM(revenue) FROM japan_virtual_tours; | gretelai_synthetic_text_to_sql |
CREATE TABLE courts (id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(2)); CREATE TABLE court_cases (id INT PRIMARY KEY, case_number VARCHAR(50), court_id INT, FOREIGN KEY (court_id) REFERENCES courts(id)); | Update the name of the court with id 1 | UPDATE courts SET name = 'Cook County Court' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (year INT, species VARCHAR(255), volume FLOAT); INSERT INTO timber_production VALUES (2018, 'Oak', 1200); | What's the total volume of timber produced in 2020, grouped by species? | SELECT species, SUM(volume) FROM timber_production WHERE year = 2020 GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (id INT, center_name VARCHAR(50), location VARCHAR(50), num_participants INT); | Delete all records from the 'community_education' table where the center_name is 'Tiger Conservation Society' | DELETE FROM community_education WHERE center_name = 'Tiger Conservation Society'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (GameID INT, SessionDuration TIME); | Show the total number of game sessions for each game in the 'GameSessions' table | SELECT GameID, COUNT(*) as TotalGameSessions FROM GameSessions GROUP BY GameID; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, title VARCHAR(100), year INT, citations INT); INSERT INTO publications (id, title, year, citations) VALUES (1, 'Publication 1', 2018, 5), (2, 'Publication 2', 2020, 15), (3, 'Publication 3', 2019, 8); | List the publications that have been cited more than 10 times in the past 2 years. | SELECT title FROM publications WHERE citations > 10 AND year >= YEAR(CURRENT_DATE()) - 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (customer_id INT, customer_name VARCHAR(50), customer_country VARCHAR(50)); CREATE TABLE Purchases (purchase_id INT, purchase_date DATE, customer_id INT, clothing_id INT); INSERT INTO Customers (customer_id, customer_name, customer_country) VALUES (1, 'David Lee', 'Australia'), (2, 'Emily Wong', ... | How many customers in Oceania have made purchases of sustainable clothing? | SELECT COUNT(*) FROM Customers c INNER JOIN Purchases p ON c.customer_id = p.customer_id WHERE c.customer_country = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerability_resolutions (resolution_time INT, vulnerability_severity VARCHAR(255)); INSERT INTO vulnerability_resolutions (resolution_time, vulnerability_severity) VALUES (7, 'Critical'), (12, 'High'), (23, 'Medium'), (34, 'Low'), (45, 'Critical'), (56, 'High'), (67, 'Medium'); | What is the average time to resolve critical vulnerabilities in the last 3 months? | SELECT AVG(resolution_time) as avg_resolution_time FROM vulnerability_resolutions WHERE vulnerability_severity = 'Critical' AND resolution_time > 0 AND resolution_time IS NOT NULL AND resolution_time < 1000 AND resolution_time >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts (name VARCHAR(30), age INT, walked_on_moon BOOLEAN); INSERT INTO Astronauts (name, age, walked_on_moon) VALUES ('Neil Armstrong', 38, TRUE), ('Buzz Aldrin', 39, TRUE); | What is the average age of astronauts who have walked on the Moon? | SELECT AVG(age) FROM Astronauts WHERE walked_on_moon = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, user_id INT, game_name VARCHAR(255), location VARCHAR(255)); INSERT INTO games (id, user_id, game_name, location) VALUES | How many users have played the game 'Overwatch' from South Korea? | SELECT COUNT(DISTINCT user_id) FROM games WHERE game_name = 'Overwatch' AND location = 'South Korea' | gretelai_synthetic_text_to_sql |
CREATE TABLE quality_control (batch_id INT, product_id INT, quality_score INT); | Insert a new record into the 'quality_control' table: 'batch_id' = 9012, 'product_id' = 34, 'quality_score' = 95 | INSERT INTO quality_control (batch_id, product_id, quality_score) VALUES (9012, 34, 95); | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (id INT, name VARCHAR(100), attended_workshop BOOLEAN); INSERT INTO Visitors (id, name, attended_workshop) VALUES (1, 'Alice', FALSE); INSERT INTO Visitors (id, name, attended_workshop) VALUES (2, 'Bob', TRUE); | Find the number of visitors who have not attended any workshops | SELECT COUNT(*) FROM Visitors WHERE attended_workshop = FALSE; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA manufacturing;CREATE TABLE workforce_development (id INT PRIMARY KEY, name TEXT, field TEXT);INSERT INTO workforce_development (id, name, field) VALUES (1, 'Workforce Development A', 'AI'); INSERT INTO workforce_development (id, name, field) VALUES (2, 'Workforce Development B', 'ML'); INSERT INTO workfor... | Add a new workforce development record with ID 5, name 'Workforce Development E', field 'Automation' | INSERT INTO workforce_development (id, name, field) VALUES (5, 'Workforce Development E', 'Automation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, GameName VARCHAR(50), ReleaseYear INT, Genre VARCHAR(50), Price DECIMAL(5, 2), Country VARCHAR(50)); INSERT INTO Games (GameID, GameName, ReleaseYear, Genre, Price, Country) VALUES (1, 'GameA', 2020, 'Action', 60.00, 'USA'), (2, 'GameB', 2019, 'Adventure', 50.00, 'Canada'), (3, 'GameC', ... | How many games were sold in each country, and what was the total revenue? | SELECT Country, COUNT(GameID) AS GamesSold, SUM(Price) AS TotalRevenue FROM Games GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streams (StreamID INT, UserID INT, SongID INT, StreamDate TIMESTAMP); CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), ArtistID INT, Genre VARCHAR(50)); INSERT INTO Streams VALUES (1, 1, 1, '2023-01-01 10:00:00'), (2, 1, 2, '2023-01-01 11:00:00'), (3, 2, 1, '2023-01-02 12:00:00'); INSERT INTO Songs V... | What is the most popular genre of music in Europe? | SELECT Genre, COUNT(*) AS NumStreams FROM Streams JOIN Songs ON Streams.SongID = Songs.SongID WHERE Songs.Genre IS NOT NULL GROUP BY Genre HAVING NumStreams = (SELECT MAX(NumStreams) FROM (SELECT Genre, COUNT(*) AS NumStreams FROM Streams JOIN Songs ON Streams.SongID = Songs.SongID WHERE Songs.Genre IS NOT NULL GROUP B... | gretelai_synthetic_text_to_sql |
CREATE TABLE underrepresented_countries (company_name VARCHAR(100), founder_country VARCHAR(50), founding_year INT); | Find the total number of startups founded by individuals from underrepresented countries | SELECT COUNT(*) FROM underrepresented_countries; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name TEXT, country TEXT, launch_date DATE); INSERT INTO satellites (id, name, country, launch_date) VALUES (1, 'Express-AM5', 'Russia', '2013-12-22'); INSERT INTO satellites (id, name, country, launch_date) VALUES (2, 'Yamal-300K', 'Russia', '2012-05-15'); INSERT INTO satellites (id, na... | Show the total number of satellites launched by Russia | SELECT COUNT(*) FROM satellites WHERE country = 'Russia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (id INT, name VARCHAR(50), location VARCHAR(50), energy_consumption FLOAT); | What is the maximum and minimum energy consumption of buildings in 'RegionB' in the 'GreenBuildings' table? | SELECT MAX(energy_consumption) AS max_consumption, MIN(energy_consumption) AS min_consumption FROM GreenBuildings WHERE location = 'RegionB'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (Date date, Location text, Material text, Quantity integer);CREATE TABLE RecyclingRates (Date date, Location text, Material text, Quantity real); | What is the percentage of waste generated that was recycled, for each location and material, for the third quarter of 2023? | SELECT wg.Location, wg.Material, 100.0 * AVG(rr.Quantity / wg.Quantity) as PercentageRecycled FROM WasteGeneration wg JOIN RecyclingRates rr ON wg.Location = rr.Location AND wg.Material = rr.Material WHERE wg.Date >= '2023-07-01' AND wg.Date < '2023-10-01' GROUP BY wg.Location, wg.Material; | gretelai_synthetic_text_to_sql |
CREATE TABLE Categories (id INT, product VARCHAR(255)); INSERT INTO Categories (id, product) VALUES (1, 'Tops'), (2, 'Bottoms'), (3, 'Dresses'), (4, 'Outerwear'); CREATE TABLE Sales_By_Category (id INT, category_id INT, quarter INT, year INT, amount INT); INSERT INTO Sales_By_Category (id, category_id, quarter, year, a... | What was the total sales amount for each product category in Q3 of 2021? | SELECT c.product, SUM(s.amount) FROM Sales_By_Category s JOIN Categories c ON s.category_id = c.id WHERE s.quarter = 3 AND s.year = 2021 GROUP BY c.product; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_programs (id INT PRIMARY KEY, program_name VARCHAR(50), start_date DATE, end_date DATE, location VARCHAR(50)); | Insert a new training program record into the 'training_programs' table | INSERT INTO training_programs (id, program_name, start_date, end_date, location) VALUES (1001, 'SQL Fundamentals', '2022-06-01', '2022-06-03', 'New York'); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), common_name VARCHAR(50), region VARCHAR(20), conservation_status VARCHAR(20));INSERT INTO marine_species (id, species_name, common_name, region, conservation_status) VALUES (1, 'Orcinus_orca', 'Killer Whale', 'Arctic', 'Least Concern');INSERT INTO marine_sp... | How many marine species are there in each conservation status, for species found in the Indian Ocean? | SELECT conservation_status, COUNT(*) FROM marine_species WHERE region = 'Indian' GROUP BY conservation_status; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (id INT, country VARCHAR(50), operation_count INT, year INT); INSERT INTO PeacekeepingOperations (id, country, operation_count, year) VALUES (1, 'Australia', 2, 2016), (2, 'New Zealand', 1, 2016), (3, 'Australia', 3, 2017), (4, 'New Zealand', 2, 2017), (5, 'Australia', 4, 2018), (6, ... | What is the average number of peacekeeping operations led by countries in Oceania since 2016? | SELECT AVG(operation_count) FROM PeacekeepingOperations WHERE country IN ('Australia', 'New Zealand') AND year >= 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClothingItems (ItemID INT, ItemName VARCHAR(255), AvailableSizes VARCHAR(255)); INSERT INTO ClothingItems (ItemID, ItemName, AvailableSizes) VALUES (101, 'Maxi Dress', 'XS,S,M,L,XL'), (102, 'Blazer', 'S,M,L'), (103, 'Jeans', '28,30,32,34,36'), (104, 'T-Shirt', 'XS,S,M,L,XL,XXL'), (105, 'Jumpsuit', 'M,L,XL'... | List the names and sizes of all men's clothing items. | SELECT ItemName, AvailableSizes FROM ClothingItems WHERE ItemName LIKE '%Men%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists africa; USE africa; CREATE TABLE if not exists military_bases (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO military_bases (id, name, type, location) VALUES (1, 'Camp Lemonnier', 'Naval Expeditionary Base', 'Djibouti'), (2, 'Air Base 201', 'Air Force Base... | What is the total number of military bases located in 'africa' schema? | SELECT COUNT(*) FROM africa.military_bases; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, region VARCHAR(10), contract_date DATE); INSERT INTO defense_contracts VALUES (1, 'Pacific', '2021-04-15'), (2, 'Atlantic', '2021-05-01'), (3, 'Pacific', '2021-06-15'); | How many defense contracts were signed in each region in the last quarter? | SELECT region, COUNT(*) FROM defense_contracts WHERE contract_date >= (CURRENT_DATE - INTERVAL '3 months') GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE russian_oil_fields (field_id INT, name VARCHAR(50), location VARCHAR(50), discovery_year INT); | List all oil fields in Russia that were discovered before 1980. | SELECT name FROM russian_oil_fields WHERE location = 'Russia' AND discovery_year < 1980; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, country VARCHAR(30), ESG_score FLOAT); INSERT INTO companies (id, country, ESG_score) VALUES (1, 'USA', 75.2), (2, 'Canada', 78.5), (3, 'USA', 72.1), (4, 'Mexico', 69.9); | Find the top 3 countries with the highest average ESG score? | SELECT country, AVG(ESG_score) as avg_esg_score FROM companies GROUP BY country ORDER BY avg_esg_score DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT, dish_type VARCHAR(255));CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT); | What is the total quantity of vegetarian dishes sold in each branch last week? | SELECT branch_name, SUM(quantity) as total_veg_sales FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE dish_type = 'vegetarian' AND sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE GROUP BY branch_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_us_counties (name TEXT, state TEXT, num_clinics INTEGER); INSERT INTO rural_us_counties (name, state, num_clinics) VALUES ('County A', 'Texas', 5), ('County B', 'California', 7), ('County C', 'Montana', 3), ('County D', 'New York', 6); | What is the average number of clinics per rural county in the United States? | SELECT state, AVG(num_clinics) FROM rural_us_counties GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE district (id INT, name VARCHAR(20)); INSERT INTO district (id, name) VALUES (1, 'West'), (2, 'East'), (3, 'North'), (4, 'South'); CREATE TABLE calls (id INT, district_id INT, call_type VARCHAR(20), call_time TIMESTAMP, response_time INT); INSERT INTO calls (id, district_id, call_type, call_time, response_t... | What is the average response time for medical emergencies in the North district? | SELECT AVG(response_time) FROM calls WHERE district_id = (SELECT id FROM district WHERE name = 'North') AND call_type = 'Medical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholder (PolicyholderID INT, PolicyholderAge INT, PolicyholderGender VARCHAR(10)); CREATE TABLE Claim (ClaimID INT, PolicyholderID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Policyholder VALUES (1, 45, 'Female'), (2, 55, 'Male'), (3, 30, 'Female'); INSERT INTO Claim VALUES (1, 1, 5000), (2, 1, 3000)... | What is the average claim amount for policyholders over the age of 40? | SELECT AVG(ClaimAmount) as AverageClaimAmount FROM Claim JOIN Policyholder ON Claim.PolicyholderID = Policyholder.PolicyholderID WHERE Policyholder.PolicyholderAge > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE EngineeringStudents(StudentID INT, NumPapers INT); INSERT INTO EngineeringStudents(StudentID, NumPapers) VALUES (1, 3), (2, 0), (3, NULL); | How many graduate students in the Engineering department have not published any papers? | SELECT COUNT(StudentID) FROM EngineeringStudents WHERE NumPapers = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE BuildingPermits (PermitID INT, PermitDate DATE, State TEXT); INSERT INTO BuildingPermits VALUES (1, '2022-01-01', 'California'), (2, '2022-01-15', 'Texas'), (3, '2022-02-05', 'Florida'); | Which building permits were issued in the last 60 days, excluding California? | SELECT PermitID, PermitDate FROM BuildingPermits WHERE State != 'California' AND PermitDate >= DATE(NOW()) - INTERVAL 60 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE AstronautMission (id INT, astronaut_id INT, mission_name VARCHAR(30), body VARCHAR(30)); | How many astronauts have flown on missions involving extraterrestrial bodies? | SELECT COUNT(DISTINCT astronaut_id) FROM AstronautMission WHERE body IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE ResourceDepletion (Operation VARCHAR(50), Resource VARCHAR(50), DepletionQuantity FLOAT); INSERT INTO ResourceDepletion(Operation, Resource, DepletionQuantity) VALUES ('Operation A', 'Coal', 12000), ('Operation A', 'Iron', 15000), ('Operation B', 'Coal', 10000), ('Operation B', 'Iron', 18000), ('Operation ... | Calculate the total coal and iron depleted by each mining operation in the last quarter, excluding 'Operation F'. | SELECT Operation, SUM(DepletionQuantity) FROM ResourceDepletion WHERE Operation NOT IN ('Operation F') AND Resource IN ('Coal', 'Iron') AND DepletionQuantity >= 0 GROUP BY Operation; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO marine_life (id, name, location, depth) VALUES (1, 'Station A', 'Pacific', 4000.5); INSERT INTO marine_life (id, name, location, depth) VALUES (2, 'Station B', 'Atlantic', 3000.2); | What are the names and locations of all marine life research stations deeper than 3000 meters? | SELECT name, location FROM marine_life WHERE depth > 3000; | gretelai_synthetic_text_to_sql |
CREATE TABLE model_scores (model_id INT, explainability_score FLOAT, ai_application_area VARCHAR(50), report_year INT); | What is the average explainability score for models in the 'AI in healthcare' application area, for the year 2022? | SELECT AVG(ms.explainability_score) FROM model_scores ms WHERE ms.ai_application_area = 'AI in healthcare' AND ms.report_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (volunteer_id INT, hours DECIMAL(10,2), cause VARCHAR(20), region VARCHAR(20), volunteer_date DATE); INSERT INTO volunteer_hours (volunteer_id, hours, cause, region, volunteer_date) VALUES (1, 3.00, 'environment', 'eastregion', '2021-01-01'), (2, 4.00, 'health', 'westregion', '2021-04-01'),... | What is the minimum number of hours volunteered in the 'eastregion' for the 'environment' cause in the year 2021? | SELECT MIN(hours) FROM volunteer_hours WHERE region = 'eastregion' AND cause = 'environment' AND YEAR(volunteer_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Clippers'); CREATE TABLE games (game_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT, home_team_assists INT, away_team_assists INT); INSERT INTO games (game_id, home_team_id, ... | What is the average number of assists per game for the Clippers? | SELECT AVG(home_team_assists + away_team_assists) as avg_assists FROM games WHERE home_team_id = (SELECT team_id FROM teams WHERE team_name = 'Clippers') OR away_team_id = (SELECT team_id FROM teams WHERE team_name = 'Clippers'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ManufacturingOrders (OrderID INT, OrderDate DATE, AircraftType VARCHAR(50), Manufacturer VARCHAR(50), Cost INT); INSERT INTO ManufacturingOrders (OrderID, OrderDate, AircraftType, Manufacturer, Cost) VALUES (1, '2021-09-01', 'Aircraft1', 'Manufacturer1', 1000000); | What is the total cost of manufacturing for each aircraft type, including only completed manufacturing orders? | SELECT AircraftType, SUM(Cost) AS TotalCost FROM ManufacturingOrders WHERE OrderDate < GETDATE() GROUP BY AircraftType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (id INT, customer_id INT, region VARCHAR(10), amount DECIMAL(10, 2)); INSERT INTO Transactions (id, customer_id, region, amount) VALUES (1, 10, 'Americas', 100), (2, 10, 'Americas', 200), (3, 11, 'Asia', 300), (4, 12, 'Europe', 400); | Find the average transaction amount and total transaction count for each customer in the 'Americas' region. | SELECT customer_id, AVG(amount) as avg_amount, COUNT(*) as total_transactions FROM Transactions WHERE region = 'Americas' GROUP BY customer_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Innovation (id INT, project VARCHAR(255), region VARCHAR(255), year INT); INSERT INTO Innovation (id, project, region, year) VALUES (1, 'Precision Farming', 'Rural North', 2013), (2, 'Drip Irrigation', 'Urban East', 2017), (3, 'Soil Sensor', 'Rural South', 2015), (4, 'Vertical Farming', 'Urban West', 2016)... | What is the total number of agricultural innovation projects in the 'Innovation' table, grouped by region, that were implemented before 2015? | SELECT region, COUNT(*) as total_projects FROM Innovation WHERE year < 2015 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE tours (id INT, name VARCHAR(255), description TEXT, revenue FLOAT); INSERT INTO tours (id, name, description, revenue) VALUES (1, 'Historic Landmarks Tour', 'Discover cultural heritage sites in Paris.', 9000.00), (2, 'Traditional Villages Tour', 'Explore authentic Italian villages and their culture.', 8000... | What is the total revenue of tours that promote cultural heritage preservation? | SELECT SUM(revenue) FROM tours WHERE description LIKE '%cultural heritage%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_manufacturing (id INT PRIMARY KEY, company VARCHAR(50), location VARCHAR(50), ethical_rating FLOAT); INSERT INTO ethical_manufacturing (id, company, location, ethical_rating) VALUES (1, 'GreenTech', 'USA', 4.2), (2, 'EcoInnovations', 'Canada', 4.6), (3, 'SustainableSolutions', 'Mexico', 4.8); | Create a view named 'top_ethical_ratings' showing the top 3 companies by ethical rating | CREATE VIEW top_ethical_ratings AS SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY ethical_rating DESC) rn FROM ethical_manufacturing) x WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE TherapyApproaches (TherapyID INT, TherapyName VARCHAR(50)); CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10), Region VARCHAR(50)); CREATE TABLE TherapySessions (SessionID INT, PatientID INT, TherapyID INT); | How many patients were treated with a specific therapy approach in each region? | SELECT TherapyApproaches.TherapyName, Patients.Region, COUNT(TherapySessions.SessionID) FROM TherapyApproaches INNER JOIN TherapySessions ON TherapyApproaches.TherapyID = TherapySessions.TherapyID INNER JOIN Patients ON TherapySessions.PatientID = Patients.PatientID GROUP BY TherapyApproaches.TherapyName, Patients.Regi... | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name TEXT, cuisine_type TEXT, nutrition_values INT); INSERT INTO dishes (id, name, cuisine_type, nutrition_values) VALUES (1, 'Pasta Primavera', 'Italian', 4), (2, 'Margherita Pizza', 'Italian', 2); | What is the minimum nutrition value (fiber) for dishes in the 'Italian' cuisine type? | SELECT MIN(nutrition_values) FROM dishes WHERE cuisine_type = 'Italian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Gender VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT, Medium VARCHAR(255), SalePrice DECIMAL(10,2)); | What is the average sale price of sculptures by female artists from Spain? | SELECT AVG(Artworks.SalePrice) AS AvgSalePrice FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID WHERE Artists.Gender = 'Female' AND Artists.Nationality = 'Spanish' AND Artworks.Medium = 'Sculpture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, category VARCHAR(20), cost FLOAT); INSERT INTO Infrastructure (id, category, cost) VALUES (1, 'Transportation', 5000000), (2, 'WaterSupply', 3000000), (3, 'Transportation', 7000000), (4, 'WaterSupply', 1000000), (5, 'SewerSystems', 6000000); | What is the minimum and maximum cost of projects in 'WaterSupply' and 'SewerSystems' categories? | SELECT category, MIN(cost) AS min_cost, MAX(cost) AS max_cost FROM Infrastructure WHERE category IN ('WaterSupply', 'SewerSystems') GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE support_org (id INT, organization_name VARCHAR(50), sector VARCHAR(20)); INSERT INTO support_org (id, organization_name, sector) VALUES (1, 'Doctors Without Borders', 'healthcare'), (2, 'Oxfam', 'sanitation'), (3, 'Red Cross', 'healthcare'), (4, 'UNICEF', 'sanitation'); | How many unique organizations provided support in healthcare and sanitation? | SELECT DISTINCT organization_name FROM support_org WHERE sector IN ('healthcare', 'sanitation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousDriving (Id INT, Company VARCHAR(50), Model VARCHAR(50), TestMiles FLOAT); | What is the total number of autonomous vehicle test miles driven by 'Waymo' in the 'AutonomousDriving' database? | SELECT SUM(TestMiles) FROM AutonomousDriving WHERE Company = 'Waymo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, post_topic VARCHAR(50), post_date DATE); INSERT INTO posts (post_id, post_topic, post_date) VALUES (1, 'Environment', '2022-02-10'); CREATE TABLE user_post_interactions (user_id INT, post_id INT, interaction_type VARCHAR(50)); INSERT INTO user_post_interactions (user_id, post_id, intera... | What is the percentage of users from India who liked or shared posts about environmental issues in the last month? | SELECT 100.0 * COUNT(DISTINCT CASE WHEN interaction_type IN ('Like', 'Share') THEN user_id END) / COUNT(DISTINCT user_id) as percentage FROM user_post_interactions JOIN posts ON user_post_interactions.post_id = posts.post_id WHERE post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND posts.post_topic = 'Environment... | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donor_age INT, donation_amount DECIMAL(10,2)); INSERT INTO donations (donor_id, donor_age, donation_amount) VALUES (1, 25, 50.00), (2, 35, 100.00), (3, 22, 75.00), (4, 30, 60.00), (5, 28, 80.00); CREATE TABLE young_donors (donor_id INT); INSERT INTO young_donors (donor_id) VALUES (... | What was the total amount donated by the 'young_donors' in the 'donations' table? | SELECT SUM(donation_amount) FROM donations WHERE donor_id IN (SELECT donor_id FROM young_donors); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, region VARCHAR(50), volunteer_type VARCHAR(50), registration_date DATE); INSERT INTO volunteers (id, region, volunteer_type, registration_date) VALUES (1, 'North', 'Disaster Response', '2020-12-20'), (2, 'South', 'Disaster Response', '2020-11-15'), (3, 'East', 'Disaster Response', '2021... | How many disaster response volunteers were there in total as of January 1, 2021? | SELECT COUNT(*) as total_volunteers FROM volunteers WHERE volunteer_type = 'Disaster Response' AND registration_date <= '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists bioprocess; USE bioprocess; CREATE TABLE if not exists engineering_projects (id INT PRIMARY KEY, project_name VARCHAR(255), region VARCHAR(255), budget FLOAT); INSERT INTO engineering_projects (id, project_name, region, budget) VALUES (1, 'Bio-Manufacturing Plant', 'Asia', 15000000.00), (2, ... | What is the total bioprocess engineering budget for projects in Asia? | SELECT SUM(budget) FROM bioprocess.engineering_projects WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE UserStreams (StreamID INT, UserID INT, SongID INT, StreamDate DATE); | How many unique users listened to Latin music in Q1 2022? | SELECT COUNT(DISTINCT UserID) FROM UserStreams WHERE SongID IN (SELECT SongID FROM Songs WHERE Genre = 'Latin') AND QUARTER(StreamDate) = 1 AND YEAR(StreamDate) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParity (PatientID int, MentalHealthVisits int); INSERT INTO MentalHealthParity (PatientID, MentalHealthVisits) VALUES (1, 5), (2, 3), (3, 6), (4, 4), (5, 8), (6, 7), (7, 6); | Calculate the number of mental health visits per patient, ordered by the number of visits in descending order. | SELECT PatientID, MentalHealthVisits, ROW_NUMBER() OVER (ORDER BY MentalHealthVisits DESC) AS VisitRank FROM MentalHealthParity; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (id INT, policyholder_id INT, date DATE, amount FLOAT); INSERT INTO claims (id, policyholder_id, date, amount) VALUES (1, 1, '2021-07-01', 700), (2, 2, '2021-08-01', 400), (3, 3, '2021-09-01', 600), (4, 4, '2021-10-01', 550); | List policyholders with claims over $500 in the last 6 months | SELECT policyholder_id FROM claims WHERE date > DATEADD(month, -6, CURRENT_DATE) AND amount > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_type VARCHAR(10), transaction_date DATE); INSERT INTO transactions (transaction_id, customer_id, transaction_value, transaction_type, transaction_date) VALUES (1, 1, 12000, 'deposit', '2021-07-01'), (2, 2, -500... | Find the daily net transaction amount (total transaction value - total withdrawal value) for the past week, grouped by day and ordered by day in ascending order? | SELECT transaction_date, SUM(CASE WHEN transaction_type = 'deposit' THEN transaction_value ELSE -transaction_value END) as daily_net_transaction_amount FROM transactions WHERE transaction_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE GROUP BY transaction_date ORDER BY transaction_date ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Name VARCHAR(50), Specialty VARCHAR(50)); | Insert new records for community health workers with their respective specialties. | INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (5, 'Rajesh Patel', 'Mental Health'); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (6, 'María Rodríguez', 'Physical Health'); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (7, 'Nguyen Tran', 'Community... | gretelai_synthetic_text_to_sql |
CREATE TABLE wins (win_id INT, player_id INT, match_id INT, team_id INT, wins INT); INSERT INTO wins (win_id, player_id, match_id, team_id, wins) VALUES (1, 13, 14, 715, 10); | Which tennis player won the most matches in the 'wins' table? | SELECT player_id, MAX(wins) FROM wins; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT, order_date DATE, customer_id INT, item_id INT); CREATE TABLE items (id INT, name TEXT, size TEXT); | How many items in a specific size category have been sold in a given time period? | SELECT COUNT(*) FROM orders o JOIN items i ON o.item_id = i.id WHERE i.size = 'XL' AND o.order_date BETWEEN '2022-01-01' AND '2022-12-31'; | 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.