context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE clinical_trials (trial_id INT, drug_name VARCHAR(255)); INSERT INTO clinical_trials (trial_id, drug_name) VALUES (1, 'DrugA'), (2, 'DrugB'), (3, 'DrugB'), (4, 'DrugC'), (5, 'DrugC'), (6, 'DrugC'); | What is the maximum number of clinical trials conducted for a single drug? | SELECT drug_name, MAX(cnt) FROM (SELECT drug_name, COUNT(*) AS cnt FROM clinical_trials GROUP BY drug_name) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE WeatherData (City VARCHAR(50), Humidity INT, Timestamp DATETIME); INSERT INTO WeatherData (City, Humidity, Timestamp) VALUES ('CityA', 60, '2022-01-01 00:00:00'), ('CityB', 70, '2022-01-01 00:00:00'); | What is the average humidity per day for each city in the past week? | SELECT City, AVG(Humidity) OVER (PARTITION BY City ORDER BY Timestamp ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) FROM WeatherData | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT PRIMARY KEY, product_name TEXT, product_type TEXT, brand_id INT, is_vegan BOOLEAN, price DECIMAL); INSERT INTO products (product_id, product_name, product_type, brand_id, is_vegan, price) VALUES (1, 'Lipstick', 'Makeup', 1, false, 25.99), (2, 'Mascara', 'Makeup', 2, false, 20.99), ... | What is the minimum price of all non-vegan makeup products? | SELECT MIN(price) FROM products WHERE product_type = 'Makeup' AND is_vegan = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), age INT, region VARCHAR(20), strategy_name VARCHAR(50)); INSERT INTO customers (customer_id, name, age, region, strategy_name) VALUES (1, 'John Doe', 35, 'Southeast', 'Equity'), (2, 'Jane Smith', 45, 'Northeast', 'Bond'), (3, 'Mike Johnson', 50, 'Southeast', 'E... | How many customers are there in each investment strategy? | SELECT strategy_name, COUNT(*) FROM customers GROUP BY strategy_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralDistrictZPD (programID INT, district VARCHAR(50), programDate DATE); INSERT INTO RuralDistrictZPD (programID, district, programDate) VALUES (1, 'Rural District Z', '2021-02-01'), (2, 'Rural District Z', '2021-06-15'); CREATE TABLE UrbanDistrictWPD (programID INT, district VARCHAR(50), programDate DATE... | What is the total number of professional development programs conducted in 'Rural District Z' and 'Urban District W' last year? | SELECT COUNT(DISTINCT programID) FROM RuralDistrictZPD WHERE district IN ('Rural District Z', 'Urban District W') AND YEAR(programDate) = 2021 UNION ALL SELECT COUNT(DISTINCT programID) FROM UrbanDistrictWPD WHERE district IN ('Rural District Z', 'Urban District W') AND YEAR(programDate) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name TEXT, sustainable BOOLEAN, sales INT); | Which menu items have been sold more than 300 times and are not sourced sustainably? | SELECT menu_items.name FROM menu_items WHERE menu_items.sales > 300 AND menu_items.sustainable = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT PRIMARY KEY, name TEXT, city_id INT, FOREIGN KEY (city_id) REFERENCES city(id)); CREATE TABLE meeting (id INT PRIMARY KEY, date DATE, department_id INT, FOREIGN KEY (department_id) REFERENCES department(id)); | What is the average number of public meetings held per department in the state of New York? | SELECT AVG(meetings_per_dept) FROM (SELECT COUNT(*) as meetings_per_dept FROM meeting JOIN department ON meeting.department_id = department.id WHERE department.city_id IN (SELECT id FROM city WHERE state = 'NY') GROUP BY department.id) as subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name TEXT, location TEXT); INSERT INTO marine_protected_areas (name, location) VALUES ('Galapagos Marine Reserve', 'Pacific'), ('Great Barrier Reef', 'Pacific'), ('Channel Islands National Marine Sanctuary', 'Pacific'), ('Monterey Bay National Marine Sanctuary', 'Pacific'), ('Cordel... | Find the number of marine protected areas in the Pacific Ocean. | SELECT COUNT(*) FROM marine_protected_areas WHERE location = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE freight_forwarder (id INT, name VARCHAR(255), revenue FLOAT); INSERT INTO freight_forwarder (id, name, revenue) VALUES (1, 'ABC Logistics', 500000), (2, 'XYZ Freight', 600000), (3, 'MNO Logistics', 400000); | What is the total revenue of freight forwarder 'MNO Logistics'? | SELECT revenue FROM freight_forwarder WHERE name = 'MNO Logistics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (id INT, name VARCHAR(255), is_cruelty_free BOOLEAN); INSERT INTO cosmetics (id, name, is_cruelty_free) VALUES (1, 'Lipstick', true), (2, 'Mascara', false); CREATE TABLE ingredients (cosmetic_id INT, ingredient VARCHAR(255)); INSERT INTO ingredients (cosmetic_id, ingredient) VALUES (1, 'Ricinus C... | What are the cosmetic products and their ingredients that are not cruelty-free? | SELECT c.name, i.ingredient FROM cosmetics c INNER JOIN ingredients i ON c.id = i.cosmetic_id WHERE c.is_cruelty_free = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, title VARCHAR(255), content TEXT, hashtags VARCHAR(255), created_at TIMESTAMP); | Find the top 5 users who have posted the most about "climate change" in the past month, in Canada, based on the number of posts. | SELECT u.username, COUNT(p.id) as post_count FROM users u JOIN posts p ON u.id = p.user_id WHERE u.country = 'Canada' AND p.hashtags LIKE '%#climatechange%' GROUP BY u.username ORDER BY post_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessel (VesselID INT, Name VARCHAR(255), CarrierID INT, GrossTonnage INT, YearBuilt INT); INSERT INTO Vessel (VesselID, Name, CarrierID, GrossTonnage, YearBuilt) VALUES (3, 'PIL Container', 3, 45000, 2010); | What is the GrossTonnage of all vessels owned by the carrier registered in Singapore? | SELECT Vessel.GrossTonnage FROM Vessel INNER JOIN Carrier ON Vessel.CarrierID = Carrier.CarrierID WHERE Carrier.FlagState = 'Singapore'; | gretelai_synthetic_text_to_sql |
CREATE TABLE canadian_provinces (province VARCHAR(255), water_usage INT); | Create a table for water usage in Canadian provinces and insert data. | INSERT INTO canadian_provinces (province, water_usage) VALUES ('Ontario', 5000000), ('Quebec', 4000000), ('British Columbia', 3000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorker (WorkerID INT, State CHAR(2), CulturalCompetencyScore INT); INSERT INTO CommunityHealthWorker (WorkerID, State, CulturalCompetencyScore) VALUES (1, 'CA', 85), (2, 'TX', 80), (3, 'CA', 90), (4, 'TX', 82); | Rank community health workers by cultural competency score in descending order within each state. | SELECT WorkerID, State, CulturalCompetencyScore, RANK() OVER (PARTITION BY State ORDER BY CulturalCompetencyScore DESC) AS Rank FROM CommunityHealthWorker; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (id INT PRIMARY KEY, name VARCHAR(255), cost DECIMAL(10, 2)); CREATE TABLE inventory (id INT PRIMARY KEY, ingredient_id INT, quantity INT, use_date DATE); INSERT INTO ingredients (id, name, cost) VALUES (1, 'Tomato', 0.50), (2, 'Pasta', 1.00), (3, 'Chicken', 2.50); INSERT INTO inventory (id, in... | Display the total quantity of each ingredient used in the last 7 days | SELECT ingredients.name, SUM(inventory.quantity) AS total_quantity FROM ingredients JOIN inventory ON ingredients.id = inventory.ingredient_id WHERE inventory.use_date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) GROUP BY ingredients.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, name VARCHAR(50), cost INT); INSERT INTO space_missions (id, name, cost) VALUES (1, 'Mars Rover', 2500000), (2, 'ISS', 150000000), (3, 'Hubble Space Telescope', 1000000000); | What is the total cost of each space mission? | SELECT name, SUM(cost) OVER (PARTITION BY 1) as total_cost FROM space_missions; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, timestamp TIMESTAMP, country VARCHAR(255), incident_type VARCHAR(255)); | What are the top 3 countries with the most security incidents, in the last year? | SELECT country, COUNT(*) as incident_count FROM security_incidents WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 YEAR) GROUP BY country ORDER BY incident_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, region VARCHAR(50), incident_date DATE); | Count the number of security incidents in the APAC region in the last month. | SELECT COUNT(*) FROM security_incidents WHERE region = 'APAC' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (org_id INT, org_name TEXT, num_volunteers INT); | What is the total number of volunteers for each organization in the 'organizations' table? | SELECT org_name, SUM(num_volunteers) FROM organizations GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplace_safety (id INT, location VARCHAR(50), risk_level VARCHAR(10), safety_score INT); INSERT INTO workplace_safety (id, location, risk_level, safety_score) VALUES (1, 'Office', 'Low', 90), (2, 'Factory', 'High', 60), (3, 'Construction Site', 'Very High', 50), (4, 'Warehouse', 'Medium', 70); | Insert a new record with the following details into the 'workplace_safety' table: (5, 'Warehouse', 'Medium', 80) | INSERT INTO workplace_safety (id, location, risk_level, safety_score) VALUES (5, 'Warehouse', 'Medium', 80); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers(id INT, name VARCHAR(50), technology VARCHAR(50)); CREATE TABLE broadband_subscribers(id INT, name VARCHAR(50), technology VARCHAR(50)); | What is the percentage of mobile and broadband subscribers that are using a 4G network technology? | SELECT 'mobile' as type, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM mobile_subscribers WHERE technology = '4G') as pct_4g_mobile FROM mobile_subscribers WHERE technology = '4G' UNION ALL SELECT 'broadband' as type, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM broadband_subscribers WHERE technology = '4G') as pct_4g_broadband... | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm(id INT, location VARCHAR(50), temperature FLOAT); INSERT INTO Farm(id, location, temperature) VALUES (1, 'Mediterranean Sea', 22.5), (2, 'Aegean Sea', 21.3); | What is the average water temperature in fish farms located in the Mediterranean and Aegean seas? | SELECT AVG(temperature) FROM Farm WHERE location LIKE '%Mediterranean Sea%' OR location LIKE '%Aegean Sea%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE song_releases (song_id INT, artist_name VARCHAR(50), genre VARCHAR(20)); | Find the total number of songs released by each artist. | SELECT artist_name, COUNT(*) FROM song_releases GROUP BY artist_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE coral_reefs (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255)); | Create a table named "coral_reefs" | CREATE TABLE coral_reefs (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255)); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_stations (station_id INT, station_name TEXT, region TEXT); INSERT INTO marine_life_research_stations (station_id, station_name, region) VALUES (1, 'Station A', 'Pacific'), (2, 'Station B', 'Atlantic'); | Delete the marine life research station with station ID 2 from the database. | DELETE FROM marine_life_research_stations WHERE station_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), post_country VARCHAR(50)); INSERT INTO users (id, name, post_country) VALUES (1, 'Hiroshi', 'Japan'); INSERT INTO users (id, name, post_country) VALUES (2, 'Ichigo', 'Japan'); INSERT INTO users (id, name, post_country) VALUES (3, 'Carla', 'USA'); CREATE TABLE user_posts (us... | Who are the top 3 users with the most posts containing the hashtag '#food' in 'Japan'? | SELECT name FROM (SELECT name, ROW_NUMBER() OVER (PARTITION BY post_country ORDER BY COUNT(*) DESC) as rank FROM users JOIN user_posts ON users.id = user_posts.user_id WHERE post_country = 'Japan' AND post_hashtags LIKE '%#food%' GROUP BY name, post_country) AS user_ranks WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_number INT, policyholder_name TEXT, issue_date DATE, state TEXT); INSERT INTO policies (policy_number, policyholder_name, issue_date, state) VALUES (12345, 'John Doe', '2021-06-01', 'California'); INSERT INTO policies (policy_number, policyholder_name, issue_date, state) VALUES (67890, 'Ja... | Delete policies that were issued in Texas. | DELETE FROM policies WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (port_name VARCHAR(50), dock_count INT); INSERT INTO Port VALUES ('Port of Oakland', 12), ('Port of Los Angeles', 15), ('Port of Seattle', 10), ('Port of Tacoma', 13), ('Port of Vancouver', 14); CREATE TABLE Cargo (cargo_id INT, cargo_weight FLOAT, vessel_name VARCHAR(50), dock_date DATE); INSERT INTO... | What is the total cargo weight (in metric tons) handled by each port in the last month, including the port name and the total cargo weight? | SELECT P.port_name, SUM(C.cargo_weight) as total_cargo_weight FROM Port P INNER JOIN Cargo C ON 1=1 WHERE C.dock_date >= DATEADD(MONTH, -1, GETDATE()) GROUP BY P.port_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalHeritage (site_id INT, site_name VARCHAR(50), country VARCHAR(50), has_virtual_tour BOOLEAN); INSERT INTO CulturalHeritage (site_id, site_name, country, has_virtual_tour) VALUES (1, 'Temple of Izumo', 'Japan', true); | Identify the number of cultural heritage sites in Japan with virtual tours. | SELECT COUNT(*) FROM CulturalHeritage WHERE country = 'Japan' AND has_virtual_tour = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name VARCHAR(50), avg_depth FLOAT); INSERT INTO marine_species (species_name, avg_depth) VALUES ('Clownfish', 5.0), ('Blue Whale', 200.0); | What is the average depth of marine species habitats? | SELECT AVG(avg_depth) FROM marine_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE grants (id INT, faculty_id INT, title VARCHAR(100), amount DECIMAL(10, 2)); INSERT INTO grants (id, faculty_id, title, amount) VALUES (1, 1, 'Research Grant 1', 50000), (2, 2, 'Research Grant 2', 75000), (3, 3, 'Research Grant 3', 80000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(5... | Identify faculty members in the Humanities department who have not received any research grants. | SELECT f.name FROM faculty f LEFT JOIN grants g ON f.id = g.faculty_id WHERE f.department = 'Humanities' AND g.id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics_by_game (id INT, game_id INT, gender VARCHAR(50), count INT); INSERT INTO fan_demographics_by_game (id, game_id, gender, count) VALUES (1, 1, 'Male', 2000), (2, 1, 'Female', 3000), (3, 2, 'Male', 1500), (4, 2, 'Female', 4000); | What is the percentage of male and female fans in the stadium? | SELECT game_id, gender, 100.0*SUM(count) / (SELECT SUM(count) FROM fan_demographics_by_game WHERE game_id = f.game_id) as percentage FROM fan_demographics_by_game f GROUP BY game_id, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name TEXT, hours DECIMAL, program_date DATE); | Which programs had the most volunteer hours in Q2 2022? | SELECT name, SUM(hours) as total_hours FROM programs WHERE program_date >= '2022-04-01' AND program_date < '2022-07-01' GROUP BY name ORDER BY total_hours DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT, name TEXT, region TEXT, budget FLOAT); INSERT INTO Programs (id, name, region, budget) VALUES (1, 'Education', 'Africa', 1000.0), (2, 'Healthcare', 'Asia', 2000.0); | What is the total budget for programs in Africa and Asia? | SELECT SUM(budget) FROM Programs WHERE region IN ('Africa', 'Asia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation (initiative VARCHAR(50), region VARCHAR(50), start_year INT, investment FLOAT); INSERT INTO climate_mitigation (initiative, region, start_year, investment) VALUES ('Energy Efficiency', 'Caribbean', 2018, 500000), ('Green Buildings', 'Caribbean', 2019, 700000); | Which climate mitigation initiatives in the Caribbean were initiated after 2017, and what is their total investment? | SELECT initiative, region, SUM(investment) as total_investment FROM climate_mitigation WHERE region = 'Caribbean' AND start_year > 2017 GROUP BY initiative; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (well_id INT, date DATE, quantity FLOAT); INSERT INTO production (well_id, date, quantity) VALUES (1, '2021-01-01', 100.0), (1, '2021-01-02', 120.0), (2, '2021-01-01', 150.0); | Identify the well with the lowest daily production in the past month | SELECT well_id, MIN(quantity) FROM production WHERE date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY well_id ORDER BY MIN(quantity) LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(50), production_year INT, country VARCHAR(50)); INSERT INTO movies (id, title, genre, production_year, country) VALUES (1, 'Movie1', 'Action', 2015, 'UK'), (2, 'Movie2', 'Drama', 2018, 'USA'), (3, 'Movie3', 'Comedy', 2012, 'UK'); | What is the distribution of genres in movies produced in the UK? | SELECT genre, COUNT(*) as count FROM movies WHERE country = 'UK' GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_actions (user_id INT, game_id INT, action_date DATE); | Delete users who have not played any game in the last month. | DELETE u FROM users u LEFT JOIN user_actions a ON u.id = a.user_id WHERE a.user_id IS NULL AND u.last_login_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE astrobiology_funding (year INT, amount FLOAT); INSERT INTO astrobiology_funding (year, amount) VALUES (2017, 1200000), (2018, 1500000), (2019, 1800000), (2020, 2000000), (2021, 2500000); | What is the total funding for astrobiology projects in the last 5 years? | SELECT SUM(amount) FROM astrobiology_funding WHERE year BETWEEN 2017 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm (id INT, name VARCHAR(255), type VARCHAR(255), sustainability VARCHAR(255)); INSERT INTO farm (id, name, type, sustainability) VALUES (1, 'Smith Farm', 'organic', 'sustainable'), (2, 'Johnson Farm', 'conventional', 'non-sustainable'), (3, 'Brown Farm', 'organic', 'sustainable'), (4, 'Davis Farm', 'con... | List the names and types of all farms in the 'farming' database that use sustainable practices. | SELECT name, type FROM farm WHERE sustainability = 'sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), JobTitle VARCHAR(50), LastActivity DATETIME); | Delete all employees who have 'Senior' in their job title from the Employee table | DELETE FROM Employee WHERE JobTitle LIKE '%Senior%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists sales (id INT PRIMARY KEY, product_id INT, purchase_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, product_id, purchase_date, quantity, price) VALUES (3, 1, '2022-02-01', 2, 12.99); CREATE TABLE if not exists product (id INT PRIMARY KEY, name TEXT, brand_id INT, price DE... | What are the sales for a specific product in a specific month? | SELECT SUM(quantity * price) FROM sales WHERE product_id = 1 AND EXTRACT(MONTH FROM purchase_date) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmergencyCalls (id INT, region VARCHAR(20), response_time INT); | What is the average response time for emergency calls in the "downtown" region? | SELECT AVG(response_time) FROM EmergencyCalls WHERE region = 'downtown'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (InventoryID INT, WarehouseID INT, ProductID INT, Quantity INT); INSERT INTO Inventory (InventoryID, WarehouseID, ProductID, Quantity) VALUES (3, 3, 3, 50); INSERT INTO Inventory (InventoryID, WarehouseID, ProductID, Quantity) VALUES (4, 3, 4, 30); | What are the products with a quantity below 25 at the Hong Kong warehouse? | SELECT p.ProductName, i.Quantity FROM Inventory i JOIN Products p ON i.ProductID = p.ProductID WHERE i.WarehouseID = 3 AND i.Quantity < 25; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (product_id INT, ingredient_name VARCHAR(50), is_sustainable BOOLEAN, supplier_country VARCHAR(50)); INSERT INTO ingredients (product_id, ingredient_name, is_sustainable, supplier_country) VALUES (101, 'Jojoba Oil', true, 'USA'), (102, 'Shea Butter', true, 'Ghana'), (103, 'Rosehip Oil', false, ... | List the top 5 ingredients sourced from sustainable suppliers for skincare products in the USA. | SELECT ingredient_name, supplier_country FROM ingredients WHERE is_sustainable = true AND supplier_country = 'USA' LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT, customer_id INT, order_date DATE, product_type VARCHAR(255), weight INT); INSERT INTO orders (id, customer_id, order_date, product_type, weight) VALUES (1, 1001, '2022-01-01', 'Meat', 1000), (2, 1001, '2022-01-01', 'Dairy', 500), (3, 1001, '2022-01-02', 'Meat', 1500); | What is the total weight of meat and dairy products ordered by a specific customer? | SELECT SUM(weight) FROM orders WHERE customer_id = 1001 AND (product_type = 'Meat' OR product_type = 'Dairy'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hockey_athletes (athlete_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50), participated_in_olympics INT); | Delete records of athletes from the 'hockey_athletes' table who have not participated in the Olympics? | DELETE FROM hockey_athletes WHERE participated_in_olympics = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Technologies (Name VARCHAR(255), Max_Personnel INT); INSERT INTO Military_Technologies (Name, Max_Personnel) VALUES ('M1 Abrams', 4), ('AH-64 Apache', 2), ('M2 Bradley', 3); | What is the maximum number of personnel that can be deployed by each military technology? | SELECT Name, Max_Personnel FROM Military_Technologies ORDER BY Max_Personnel DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name) VALUES (1, 'Picasso'), (2, 'Warhol'), (3, 'Matisse'), (4, 'Banksy'); CREATE TABLE Exhibitions (exhibit_id INT, artist_name VARCHAR(50), city VARCHAR(20)); INSERT INTO Exhibitions (exhibit_id, artist_name, city) V... | Identify artists who have had their works exhibited in more than one country but have never had their works sold at auctions. | SELECT artist_name FROM Artists WHERE artist_name NOT IN (SELECT artist_name FROM Auctions) INTERSECT SELECT artist_name FROM Exhibitions GROUP BY artist_name HAVING COUNT(DISTINCT city) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cities (id INT, region VARCHAR(20), adoption_rate FLOAT); INSERT INTO Cities (id, region, adoption_rate) VALUES (1, 'CityA', 0.65), (2, 'CityB', 0.78), (3, 'CityC', 0.92); | What is the average smart city technology adoption rate in Asia? | SELECT AVG(adoption_rate) FROM Cities WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO Brands (BrandID, BrandName) VALUES (1, 'BrandX'), (2, 'BrandY'), (3, 'BrandZ'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), BrandID INT, OrganicCotton INT); INSERT INTO Products (ProductID, ProductName, BrandID, OrganicCotton) VALU... | How many products are made from organic cotton by each brand? | SELECT BrandName, SUM(OrganicCotton) as TotalOrganicCotton FROM Brands b JOIN Products p ON b.BrandID = p.BrandID GROUP BY BrandName; | gretelai_synthetic_text_to_sql |
CREATE TABLE polar_bear_sightings (id INT, date DATE, region VARCHAR(255)); | What is the total number of polar bear sightings in each region? | SELECT region, COUNT(*) FROM polar_bear_sightings GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Biomass (species VARCHAR(50), habitat VARCHAR(50), biomass FLOAT); INSERT INTO Biomass (species, habitat, biomass) VALUES ('Arctic Fox', 'Tundra', 1.5); INSERT INTO Biomass (species, habitat, biomass) VALUES ('Reindeer', 'Tundra', 120); INSERT INTO Biomass (species, habitat, biomass) VALUES ('Polar Bear', ... | What is the total biomass of all mammal species in the Arctic tundra? | SELECT SUM(biomass) FROM Biomass WHERE habitat = 'Tundra'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, vendor VARCHAR(50), contract_amount DECIMAL(10,2), contract_date DATE);INSERT INTO defense_contracts (contract_id, vendor, contract_amount, contract_date) VALUES (1, 'XYZ Defense Inc.', 7000000.00, '2021-04-01'); | What is the total contract amount for each vendor in 2021? | SELECT vendor, SUM(contract_amount) FROM defense_contracts WHERE contract_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY vendor; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(255), capacity_kW INT, country VARCHAR(255)); INSERT INTO renewable_projects (project_id, project_name, capacity_kW, country) VALUES (1, 'Solar Farm 1', 1000, 'USA'); INSERT INTO renewable_projects (project_id, project_name, capacity_kW, country) VAL... | What is the total number of renewable energy projects in each country and their total installed capacity (in kW)? | SELECT country, COUNT(*), SUM(capacity_kW) as total_capacity_kW FROM renewable_projects GROUP BY country; | 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 (1001, 3, 'California'), (1002, 4, 'California'), (1003, 5, 'Florid... | List policy numbers and claim amounts for policyholders living in 'California' or 'Florida' who have filed a claim. | SELECT Policies.PolicyNumber, Claims.ClaimAmount FROM Policies JOIN Claims ON Policies.PolicyholderID = Claims.PolicyholderID WHERE Policies.PolicyState IN ('California', 'Florida'); | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_plants(state VARCHAR(20), year INT, num_plants INT); INSERT INTO wastewater_plants VALUES ('California', 2005, 10), ('California', 2006, 12), ('California', 2007, 14), ('New York', 2005, 5), ('New York', 2006, 6), ('New York', 2007, 7), ('Texas', 2005, 15), ('Texas', 2006, 17), ('Texas', 2007, 1... | Identify the states with the highest wastewater treatment plant construction rates between 2005 and 2015, excluding California. | SELECT state, AVG(num_plants) AS avg_construction_rate FROM wastewater_plants WHERE state != 'California' AND year BETWEEN 2005 AND 2007 GROUP BY state ORDER BY avg_construction_rate DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_asset (id INT, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE market_capitalization (id INT, asset_id INT, value INT); INSERT INTO digital_asset (id, name, category) VALUES (1, 'Asset1', 'Crypto'), (2, 'Asset2', 'Crypto'), (3, 'Asset3', 'Security'), (4, 'Asset4', 'Security'), (5, 'Asset5',... | Update the market capitalization of 'Asset3' to 9000000. | UPDATE market_capitalization SET value = 9000000 WHERE asset_id = (SELECT id FROM digital_asset WHERE name = 'Asset3'); | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_assessments (assessment_id INT, year INT, co2_emissions INT); INSERT INTO environmental_assessments (assessment_id, year, co2_emissions) VALUES (1, 2018, 5000), (2, 2019, 6000), (3, 2020, 7000); | List all environmental impact assessments by year and their total CO2 emissions. | SELECT year, SUM(co2_emissions) FROM environmental_assessments GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Investments (InvestmentID INT, Sector VARCHAR(50), ImpactRating INT, Amount FLOAT); INSERT INTO Investments (InvestmentID, Sector, ImpactRating, Amount) VALUES (1, 'Renewable Energy', 3, 10000), (2, 'Renewable Energy', 2, 15000), (3, 'Technology', 4, 20000); | What is the total number of high-impact investments in the renewable energy sector? | SELECT SUM(Amount) FROM Investments WHERE Sector = 'Renewable Energy' AND ImpactRating = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_consumption (id INT, platform VARCHAR(50), listens INT, artist_id INT); | Add a new music consumption record 'Spotify' with 100 listens and artist_id 3 in the music_consumption table | INSERT INTO music_consumption (platform, listens, artist_id) VALUES ('Spotify', 100, 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessel_Stats (vessel_name TEXT, location TEXT, handling_date DATE, containers_handled INTEGER); INSERT INTO Vessel_Stats (vessel_name, location, handling_date, containers_handled) VALUES ('VesselA', 'South China Sea', '2020-04-01', 50), ('VesselB', 'South China Sea', '2020-04-02', 75), ('VesselC', 'South C... | What is the average number of containers handled per day by vessels in the South China Sea in Q2 2020? | SELECT AVG(containers_handled/30.0) FROM Vessel_Stats WHERE location = 'South China Sea' AND handling_date >= '2020-04-01' AND handling_date <= '2020-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(255), NumberOfArtworks INT); INSERT INTO Artists (ArtistID, ArtistName, NumberOfArtworks) VALUES (1, 'Vincent van Gogh', 2100), (2, 'Pablo Picasso', 1347), (3, 'Claude Monet', 1643), (4, 'Jackson Pollock', 287); | Find the maximum number of artworks created by an individual artist | SELECT MAX(NumberOfArtworks) AS MaxArtworks FROM Artists; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'Canada', 8000000), (2, 'StartupB', 'Canada', 6000000), (3, 'StartupC', 'USA',... | Who are the top three funded biotech startups in Canada? | SELECT name, funding FROM biotech.startups WHERE location = 'Canada' ORDER BY funding DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerPreferences (PlayerID INT, VRPreference INT); INSERT INTO PlayerPreferences (PlayerID, VRPreference) VALUES (1, 1), (2, 0), (3, 1), (4, 0); | What is the total number of players who prefer VR technology? | SELECT COUNT(*) FROM PlayerPreferences WHERE VRPreference = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE modern_art_movements (name TEXT, year INTEGER); INSERT INTO modern_art_movements (name, year) VALUES ('Cubism', 1907), ('Fauvism', 1904), ('Expressionism', 1905); | What are the names and years of all modern art movements? | SELECT name, year FROM modern_art_movements; | gretelai_synthetic_text_to_sql |
CREATE TABLE Defense_Projects (project_id INT, start_year INT, budget FLOAT); INSERT INTO Defense_Projects (project_id, start_year, budget) VALUES (1, 2021, 6000000), (2, 2022, 7000000); | Which defense projects have a start date after 2020-01-01 and a budget over 5 million? | SELECT project_id, start_year, budget FROM Defense_Projects WHERE start_year > 2020 AND budget > 5000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_energy (project_id INT, project_name VARCHAR(255), state VARCHAR(255), project_type VARCHAR(255), installed_capacity FLOAT); | What is the total installed capacity of wind energy projects in the state of Texas, grouped by project type? | SELECT project_type, SUM(installed_capacity) FROM wind_energy WHERE state = 'Texas' GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces (id INT, name TEXT, safety_violation BOOLEAN, union_affiliation TEXT); INSERT INTO workplaces (id, name, safety_violation, union_affiliation) VALUES (1, 'ABC Company', TRUE, 'Union A'), (2, 'XYZ Corporation', FALSE, 'Union B'), (3, 'LMN Industries', TRUE, 'Union A'); | Update the union affiliation for a specific workplace. | UPDATE workplaces SET union_affiliation = 'Union C' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_strategies (strategy_id INT, strategy_description TEXT); INSERT INTO investment_strategies (strategy_id, strategy_description) VALUES (1, 'Impact first investing'), (2, 'Financial first investing'), (3, 'Diversified investing'); | List all the unique investment strategies and their descriptions. | SELECT DISTINCT strategy_id, strategy_description FROM investment_strategies; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name TEXT, country TEXT); INSERT INTO ports (id, name, country) VALUES (1, 'New York', 'USA'), (2, 'Baltimore', 'USA'); CREATE TABLE vessels (id INT, name TEXT, model TEXT, port_id INT); INSERT INTO vessels (id, name, model, port_id) VALUES (1, 'TestVessel1', 'ModelA', 1), (2, 'TestVessel2',... | What is the average speed of vessels that arrived in the US east coast ports in January 2020? | SELECT AVG(vp.speed) FROM vessel_positions vp JOIN vessels v ON vp.vessel_id = v.id JOIN ports p ON v.port_id = p.id WHERE p.country = 'USA' AND EXTRACT(MONTH FROM vp.timestamp) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (category VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO sales (category, revenue) VALUES ('Appetizers', 1784.1), ('Entrees', 4318.8), ('Desserts', 3381.7); | Find the top 3 categories with the highest revenue | SELECT category, revenue FROM sales ORDER BY revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT); CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY, Name VARCHAR(255), StartDate DATE, EndDate DATE, MuseumID INT); CREATE TABL... | Which artworks by artists from India were exhibited in museums in London? | SELECT Artworks.Title FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID INNER JOIN ExhibitionArtworks ON Artworks.ArtworkID = ExhibitionArtworks.ArtworkID INNER JOIN Exhibitions ON ExhibitionArtworks.ExhibitionID = Exhibitions.ExhibitionID INNER JOIN Museums ON Exhibitions.MuseumID = Museums.Muse... | gretelai_synthetic_text_to_sql |
CREATE TABLE courses (course_id INT, course_name TEXT, course_type TEXT); CREATE TABLE professional_development (pd_id INT, course_id INT, student_id INT, pass_fail TEXT); | What is the number of students who have completed each course in the professional_development table, and what is the overall pass rate for all courses? | SELECT c.course_name, COUNT(p.student_id) as num_students, (SELECT COUNT(*) FROM professional_development p WHERE p.pass_fail = 'PASS' AND p.course_id = c.course_id) as num_passed FROM courses c JOIN professional_development p ON c.course_id = p.course_id GROUP BY c.course_name; SELECT (SELECT COUNT(*) FROM professiona... | gretelai_synthetic_text_to_sql |
CREATE TABLE spills (id INT, date DATE, location TEXT, chemical TEXT); INSERT INTO spills (id, date, location, chemical) VALUES (1, '2022-01-01', 'Oregon', 'Acetone'), (2, '2022-02-15', 'Washington', 'Ammonia'), (3, '2022-07-05', 'Idaho', 'Benzene'); | How many chemical spills occurred in the northwest region in the past year, excluding spills from the month of July? | SELECT COUNT(*) AS num_spills FROM spills WHERE location LIKE 'Northwest%' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND EXTRACT(MONTH FROM date) != 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), JoinDate DATETIME, MembershipEndDate DATETIME); | Update the 'Members' table to add a new column 'MembershipEndDate' and set the value as NULL | ALTER TABLE Members ADD MembershipEndDate DATETIME; UPDATE Members SET MembershipEndDate = NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (menu_id INT, item_name TEXT, price DECIMAL, vegetarian BOOLEAN); INSERT INTO Menu (menu_id, item_name, price, vegetarian) VALUES (1, 'Hamburger', 5.99, false), (2, 'Cheeseburger', 6.49, false), (3, 'Fries', 2.49, null), (4, 'Salad', 4.99, true), (5, 'Pizza', 7.99, false); | What are the total revenues for vegetarian and non-vegetarian menu items? | SELECT SUM(price) as total_revenue FROM Menu WHERE vegetarian = true; SELECT SUM(price) as total_revenue FROM Menu WHERE vegetarian = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE Population (country VARCHAR(255), population INT); INSERT INTO Population (country, population) VALUES ('Australia', 25499703), ('Canada', 37410003); CREATE TABLE WasteGeneration (country VARCHAR(255), generation_rate FLOAT); INSERT INTO WasteGeneration (country, generation_rate) VALUES ('Australia', 21.3)... | What is the average waste generation rate per capita in Australia and Canada? | SELECT AVG(generation_rate/population*1000000) FROM Population, WasteGeneration WHERE Population.country IN ('Australia', 'Canada') AND WasteGeneration.country = Population.country | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_costs (project_id INT, location VARCHAR(100), labor_cost FLOAT, year INT); INSERT INTO labor_costs (project_id, location, labor_cost, year) VALUES (1, 'California', 20000, 2022), (2, 'New York', 25000, 2022), (3, 'Texas', 18000, 2022); | List the average labor costs for construction projects in California in 2022. | SELECT AVG(labor_cost) FROM labor_costs WHERE location = 'California' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE RegulatoryFrameworksByRegion (FrameworkRegion VARCHAR(50), FrameworkCount INT); INSERT INTO RegulatoryFrameworksByRegion (FrameworkRegion, FrameworkCount) VALUES ('APAC', 2), ('Europe', 1), ('North America', 3); ALTER TABLE RegulatoryFrameworksByRegion ADD COLUMN FrameworkRegion VARCHAR(50); | What is the total number of regulatory frameworks in place, and for which regions are they applicable? | SELECT FrameworkRegion, FrameworkCount FROM RegulatoryFrameworksByRegion; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(255)); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'); CREATE TABLE organic_farming (country_id INT, year INT, area_ha INT); INSERT INTO organic_farming (country_id, year, area_ha) VALUES (1, 2020, 1000), (1, 2019, 800), (2, 2020, 1500), (2, 2019, 1200); | Find the total area (in hectares) of organic farming for each country in 2020. | SELECT c.name, SUM(of.area_ha) as total_area_2020 FROM countries c JOIN organic_farming of ON c.id = of.country_id WHERE of.year = 2020 GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ambulances (id INT, type VARCHAR(15), location VARCHAR(10)); INSERT INTO ambulances VALUES (1, 'ground', 'rural'); INSERT INTO ambulances VALUES (2, 'helicopter', 'rural') | Determine the total number of ambulances and medical helicopters in rural areas | SELECT COUNT(*) FROM ambulances WHERE location = 'rural' AND type IN ('ground', 'helicopter') | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, location TEXT, score INT); INSERT INTO mental_health_facilities (facility_id, location, score) VALUES (1, 'Urban', 80), (2, 'Rural', 75), (3, 'Indigenous', 90); | What is the average cultural competency score for mental health facilities in Indigenous areas? | SELECT AVG(score) FROM mental_health_facilities WHERE location = 'Indigenous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_waste (site_name VARCHAR(50), waste_amount FLOAT, region VARCHAR(50)); INSERT INTO chemical_waste (site_name, waste_amount, region) VALUES ('Site A', 150.5, 'South America'), ('Site B', 125.7, 'South America'), ('Site C', 200.3, 'South America'), ('Site D', 75.9, 'South America'), ('Site E', 175.4... | Find the three sites with the highest chemical waste production and their corresponding ranks, in South America. | SELECT site_name, waste_amount, RANK() OVER (PARTITION BY region ORDER BY waste_amount DESC) as waste_rank FROM chemical_waste WHERE region = 'South America' AND waste_rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, Category VARCHAR(50), LoadingCapacity FLOAT); INSERT INTO Vessels (VesselID, Category, LoadingCapacity) VALUES (1, 'Cargo', 80000), (2, 'Passenger', 65000), (3, 'Cargo', 55000), (4, 'Passenger', 48000), (5, 'Passenger', 72000), (6, 'Cargo', 30000); | Count the number of vessels in the 'Passenger' category with a loading capacity greater than 50000 tons | SELECT COUNT(*) FROM Vessels WHERE Category = 'Passenger' AND LoadingCapacity > 50000; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (id INT, contract_date DATE, contract_value FLOAT, business_id INT, business_owner_gender VARCHAR(255), business_location VARCHAR(255)); INSERT INTO defense_contracts (id, contract_date, contract_value, business_id, business_owner_gender, business_location) VALUES (1, '2022-01-01', 10000,... | Which countries have had the most defense contracts awarded to women-owned businesses in the past 6 months? | SELECT business_location, COUNT(*) as num_contracts FROM defense_contracts WHERE business_owner_gender = 'Female' AND contract_date >= DATEADD(month, -6, GETDATE()) GROUP BY business_location ORDER BY num_contracts DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (country VARCHAR(255), year INT, energy_source VARCHAR(255), consumption DECIMAL(10,2)); | What is the total energy consumption (in GWh) by country, for the years 2017 to 2020, broken down by energy source? | SELECT energy_source, SUM(consumption) FROM energy_consumption WHERE year IN (2017, 2018, 2019, 2020) GROUP BY energy_source; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_quality_violations(violation_id INT, violation_date DATE, state TEXT); INSERT INTO water_quality_violations(violation_id, violation_date, state) VALUES (1, '2021-01-01', 'California'), (2, '2021-02-01', 'Texas'), (3, '2021-03-01', 'Florida'), (4, '2021-04-01', 'California'), (5, '2021-05-01', 'Texas'... | How many water quality violations were there in each state in the year 2021? | SELECT state, COUNT(*) FROM water_quality_violations WHERE YEAR(violation_date) = 2021 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption_data (id INT, year INT, renewable_energy_consumption DECIMAL); INSERT INTO energy_consumption_data (id, year, renewable_energy_consumption) VALUES (1, 2019, 4567.8); INSERT INTO energy_consumption_data (id, year, renewable_energy_consumption) VALUES (2, 2020, 5678.9); | What is the total renewable energy consumption for the year 2019? | SELECT SUM(renewable_energy_consumption) FROM energy_consumption_data WHERE year = 2019; | 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 (2001, 9, 'Ontario'), (2002, 10, 'Ontario'); INSERT INTO Claims (Po... | List policy numbers and claim amounts for policyholders living in 'Ontario' who have filed a claim. | SELECT Policies.PolicyNumber, Claims.ClaimAmount FROM Policies JOIN Claims ON Policies.PolicyholderID = Claims.PolicyholderID WHERE Policies.PolicyState = 'Ontario'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists 'rural_clinics' (id INT, name TEXT, address TEXT, PRIMARY KEY(id)); | Update address in 'rural_clinics' where id=1 | UPDATE 'rural_clinics' SET address = 'New Address' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sourcing (id INT, fabric_type VARCHAR(20), quantity INT, country VARCHAR(20)); INSERT INTO sourcing (id, fabric_type, quantity, country) VALUES (1, 'organic_cotton', 500, 'USA'); INSERT INTO sourcing (id, fabric_type, quantity, country) VALUES (2, 'recycled_polyester', 300, 'China'); | What is the average quantity of sustainable fabric sourced from the USA? | SELECT AVG(quantity) FROM sourcing WHERE fabric_type = 'organic_cotton' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE virtual_tours (virtual_tour_id INT, name VARCHAR(255), location VARCHAR(255), city_id INT); INSERT INTO cities (city_id, name, country) VALUES (1, 'Rome', 'Italy'), (2, 'Athens', 'Greece'); INSERT INTO virtual_tours (virtual_tour_i... | How many virtual tours are available for each city? | SELECT c.name, COUNT(v.virtual_tour_id) AS num_tours FROM cities c LEFT JOIN virtual_tours v ON c.city_id = v.city_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_sales (id INT, price DECIMAL); | Delete all concert records with a price greater than 500. | DELETE FROM concert_sales WHERE price > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Gender varchar(50), ComplianceTraining bit); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, ComplianceTraining) VALUES (1, 'John', 'Doe', 'IT', 'Male', 1), (2, 'Jane', 'Doe', 'IT', '... | What is the percentage of employees who have completed compliance training, by department and gender? | SELECT Employees.Department, Employees.Gender, COUNT(CASE WHEN Employees.ComplianceTraining = 1 THEN 1 ELSE NULL END) as Completed_Training, COUNT(Employees.EmployeeID) as Total_Employees, COUNT(CASE WHEN Employees.ComplianceTraining = 1 THEN 1 ELSE NULL END) * 100.0 / COUNT(Employees.EmployeeID) as Percentage_Complete... | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, subject_area TEXT, courses_completed INT); INSERT INTO teachers (teacher_id, teacher_name, subject_area, courses_completed) VALUES (1, 'Sonia', 'Math', 5), (2, 'Tariq', 'Science', 3), (3, 'Ella', 'English', 7), (4, 'Victor', 'Math', 2), (5, 'Kiara', 'Science', 4... | What is the total number of professional development courses completed by teachers in each subject area, and what is the maximum mental health score for students in each district? | SELECT teachers.subject_area, COUNT(teachers.courses_completed) AS total_courses, MAX(students.mental_health_score) AS max_mental_health_score FROM teachers JOIN students ON teachers.subject_area = students.subject_area GROUP BY teachers.subject_area; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT);CREATE TABLE crimes (crime_id INT, district_id INT, crime_date DATE); | Insert a new crime record for the 'Southside' district with a date of '2022-01-01'. | INSERT INTO crimes (crime_id, district_id, crime_date) SELECT NULL, (SELECT district_id FROM districts WHERE district_name = 'Southside'), '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_waste (site_name VARCHAR(50), waste_amount FLOAT); INSERT INTO chemical_waste (site_name, waste_amount) VALUES ('Site A', 150.5), ('Site B', 125.7), ('Site C', 200.3), ('Site D', 75.9), ('Site E', 175.4); | Find the three sites with the highest chemical waste production and their corresponding ranks. | SELECT site_name, waste_amount, RANK() OVER (ORDER BY waste_amount DESC) as waste_rank FROM chemical_waste WHERE waste_rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE FabricData (FabricID INT, SupplierID INT, FabricType TEXT, Quantity FLOAT, Sustainable BOOLEAN); INSERT INTO FabricData (FabricID, SupplierID, FabricType, Quantity, Sustainable) VALUES (1001, 1, 'Cotton', 500, true), (1002, 1, 'Polyester', 700, false), (1003, 2, 'Hemp', 800, true); | What is the total quantity of fabric used by each textile supplier in the last 6 months? | SELECT SupplierID, SUM(Quantity) FROM FabricData WHERE FabricDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY SupplierID; | gretelai_synthetic_text_to_sql |
CREATE TABLE eSports_games_2 (id INT, team1 TEXT, team2 TEXT, winner TEXT); INSERT INTO eSports_games_2 (id, team1, team2, winner) VALUES (1, 'Black', 'White', 'Black'), (2, 'Gray', 'Black', 'Gray'), (3, 'Black', 'Red', 'Red'); | What is the percentage of games won by team 'Black' in the eSports tournament? | SELECT (COUNT(*) FILTER (WHERE winner = 'Black')) * 100.0 / COUNT(*) FROM eSports_games_2 WHERE team1 = 'Black' OR team2 = 'Black'; | 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.