context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE courses (id INT PRIMARY KEY, name VARCHAR(50), instructor VARCHAR(50), department VARCHAR(50)); | Insert a new record into the "courses" table for "Ethical AI" taught by "Dr. John" in the "Engineering" department | INSERT INTO courses (id, name, instructor, department) VALUES (1, 'Ethical AI', 'Dr. John', 'Engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE contractors (id INT, name TEXT, state TEXT); CREATE TABLE project_contractors (id INT, project_id INT, contractor_id INT); INSERT INTO contractors (id, name, state) VALUES (1, 'ABC Construction', 'Arizona'); INSERT INTO contractors (id, name, state) VALUES (2, 'XYZ Construction', 'California'); INSERT INTO project_contractors (id, project_id, contractor_id) VALUES (1, 1, 1); INSERT INTO project_contractors (id, project_id, contractor_id) VALUES (2, 2, 2); INSERT INTO project_contractors (id, project_id, contractor_id) VALUES (3, 3, 1); INSERT INTO project_contractors (id, project_id, contractor_id) VALUES (4, 4, 2); INSERT INTO project_contractors (id, project_id, contractor_id) VALUES (5, 5, 3); | Who are the top 5 contractors by project count in Arizona? | SELECT contractors.name, COUNT(project_contractors.id) as project_count FROM contractors JOIN project_contractors ON contractors.id = project_contractors.contractor_id WHERE contractors.state = 'Arizona' GROUP BY contractors.name ORDER BY project_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_name VARCHAR(50), donation_amount DECIMAL(10,2)); | Find the number of unique donors who made a donation of more than 500 in the 'donors' table. | SELECT COUNT(DISTINCT donor_name) FROM donors WHERE donation_amount > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, player_name TEXT, country TEXT); INSERT INTO players VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Bob Johnson', 'Mexico'); CREATE TABLE games (game_id INT, game_name TEXT, genre TEXT, country TEXT); INSERT INTO games VALUES (1, 'Game 1', 'Racing', 'USA'), (2, 'Game 2', 'Action', 'Canada'); CREATE TABLE player_games (player_id INT, game_id INT, playtime INT); INSERT INTO player_games VALUES (1, 1, 10), (1, 2, 5), (2, 1, 8), (3, 1, 12); | What is the total playtime for players who have played games in the Racing genre and are from the USA? | SELECT SUM(player_games.playtime) FROM player_games JOIN players ON player_games.player_id = players.player_id JOIN games ON player_games.game_id = games.game_id WHERE players.country = 'USA' AND games.genre = 'Racing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_representatives (id INT, name TEXT, union_name TEXT); INSERT INTO union_representatives (id, name, union_name) VALUES (1, 'John Smith', 'Union A'), (2, 'Jane Doe', 'Union B'), (3, 'Mike Lee', 'Union A'); | Delete all records of union representatives from a specific union. | DELETE FROM union_representatives WHERE union_name = 'Union A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholder (PolicyholderID INT, Age INT, Gender VARCHAR(10), CarMake VARCHAR(20), State VARCHAR(20)); INSERT INTO Policyholder (PolicyholderID, Age, Gender, CarMake, State) VALUES (1, 35, 'Female', 'Toyota', 'CA'); INSERT INTO Policyholder (PolicyholderID, Age, Gender, CarMake, State) VALUES (2, 42, 'Male', 'Honda', 'CA'); | List policyholders who have the same car make as the policyholder with ID '2'. | SELECT CarMake FROM Policyholder WHERE PolicyholderID IN (SELECT PolicyholderID FROM Policy WHERE PolicyholderID = 2) GROUP BY CarMake; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), area_size FLOAT, avg_depth FLOAT, region VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, area_size, avg_depth, region) VALUES (1, 'Great Barrier Reef', 344400, 1200, 'Indian'); | What is the total area covered by marine protected areas in the Indian Ocean that are deeper than 3000 meters? | SELECT SUM(area_size) FROM marine_protected_areas WHERE region = 'Indian' AND avg_depth > 3000; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (id INT, state VARCHAR(2), policy_type VARCHAR(20), claim_amount DECIMAL(10,2), claim_date DATE); INSERT INTO claims (id, state, policy_type, claim_amount, claim_date) VALUES (1, 'TX', 'Auto', 2500, '2022-01-12'), (2, 'TX', 'Auto', 3500, '2022-04-23'), (3, 'TX', 'Renters', 1200, '2022-02-14'); | What is the sum of claim amounts for auto insurance in Texas in the last quarter? | SELECT SUM(claim_amount) FROM claims WHERE state = 'TX' AND policy_type = 'Auto' AND QUARTER(claim_date) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_info (customer_id INT, region VARCHAR(20), investment_portfolio DECIMAL(10, 2), portfolio_date DATE); INSERT INTO customer_info (customer_id, region, investment_portfolio, portfolio_date) VALUES (1, 'Asia-Pacific', 20000, '2021-09-01'), (2, 'North America', 30000, '2021-09-01'), (3, 'Asia-Pacific', 25000, '2021-08-01'); | What is the average monthly investment portfolio value for customers in the Asia-Pacific region over the last 12 months, ordered by the most recent month? | SELECT region, AVG(investment_portfolio) as avg_portfolio, EXTRACT(MONTH FROM portfolio_date) as month FROM customer_info WHERE portfolio_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND CURRENT_DATE AND region = 'Asia-Pacific' GROUP BY region, month ORDER BY month DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_sales (sale_id INT, genre VARCHAR(10), year INT, revenue FLOAT); INSERT INTO music_sales (sale_id, genre, year, revenue) VALUES (1, 'Pop', 2021, 50000.00), (2, 'Rock', 2021, 45000.00), (3, 'Pop', 2020, 40000.00), (4, 'Jazz', 2020, 30000.00), (5, 'Hip-Hop', 2019, 25000.00), (6, 'Latin', 2020, 35000.00), (7, 'K-Pop', 2019, 20000.00), (8, 'Afrobeats', 2021, 60000.00); CREATE VIEW genre_sales AS SELECT genre, SUM(revenue) as total_revenue FROM music_sales GROUP BY genre; | What was the total revenue for the Afrobeats genre in 2021? | SELECT total_revenue FROM genre_sales WHERE genre = 'Afrobeats' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name VARCHAR(255)); INSERT INTO department (id, name) VALUES (1, 'Parks'); INSERT INTO department (id, name) VALUES (2, 'Transportation'); CREATE TABLE initiative (id INT, name VARCHAR(255), department_id INT, status VARCHAR(255)); INSERT INTO initiative (id, name, department_id, status) VALUES (1, 'Bike Share', 2, 'open'); INSERT INTO initiative (id, name, department_id, status) VALUES (2, 'Traffic Counts', 2, 'open'); | Delete all open data initiatives in the 'Transportation' department | DELETE FROM initiative WHERE department_id = (SELECT id FROM department WHERE name = 'Transportation') AND status = 'open'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(255)); CREATE TABLE cargo (id INT, port_id INT, cargo_type VARCHAR(255), timestamp TIMESTAMP, weight INT); INSERT INTO ports VALUES (1, 'Port A'), (2, 'Port B'), (3, 'Port C'); INSERT INTO cargo VALUES (1, 1, 'container', '2022-01-01 10:00:00', 20), (2, 2, 'container', '2022-01-05 12:00:00', 30), (3, 1, 'container', '2022-01-07 14:00:00', 40); | What is the total cargo handled by each port in the last month? | SELECT p.name, SUM(c.weight) as total_cargo FROM ports p JOIN cargo c ON p.id = c.port_id WHERE c.timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle (id INT, name VARCHAR(50), type VARCHAR(20), safety_rating INT, manufacturer_id INT); INSERT INTO Vehicle (id, name, type, safety_rating, manufacturer_id) VALUES (1, 'Tesla Model 3', 'Electric', 5, 1), (2, 'Chevrolet Bolt', 'Electric', 4, 2), (3, 'Nissan Leaf', 'Electric', 4, 3); CREATE TABLE Manufacturer (id INT, name VARCHAR(50), country VARCHAR(10), electric_powertrain BOOLEAN); INSERT INTO Manufacturer (id, name, country, electric_powertrain) VALUES (1, 'Tesla', 'USA', true), (2, 'Chevrolet', 'USA', true), (3, 'Nissan', 'Japan', true); CREATE TABLE Sales (id INT, manufacturer_id INT, year INT, units_sold INT); INSERT INTO Sales (id, manufacturer_id, year, units_sold) VALUES (1, 1, 2021, 5000), (2, 2, 2021, 3000), (3, 3, 2021, 2000), (4, 1, 2022, 6000), (5, 3, 2022, 4000); | What is the average safety rating of electric vehicles manufactured in Japan and sold between 2020 and 2022? | SELECT AVG(Vehicle.safety_rating) FROM Vehicle INNER JOIN Manufacturer ON Vehicle.manufacturer_id = Manufacturer.id INNER JOIN Sales ON Manufacturer.id = Sales.manufacturer_id WHERE Manufacturer.country = 'Japan' AND Sales.year BETWEEN 2020 AND 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE zipcodes (zip INTEGER, city TEXT, average_income INTEGER); INSERT INTO zipcodes (zip, city, average_income) VALUES (12345, 'City 1', 60000), (67890, 'City 2', 45000), (11121, 'City 3', 70000), (22233, 'City 4', 55000); | List all the zip codes and corresponding cities in the state of Florida where the average income is above 50000. | SELECT zip, city FROM zipcodes WHERE average_income > 50000 AND state = 'FL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safe_algorithm (id INT PRIMARY KEY, sector TEXT, version TEXT); INSERT INTO safe_algorithm (id, sector, version) VALUES (1, 'high_risk', 'v1.2'), (2, 'low_risk', 'v1.0'), (3, 'high_risk', 'v1.1'); | What is the 'safe_algorithm' version used in 'low_risk' sector? | SELECT version FROM safe_algorithm WHERE sector = 'low_risk'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Aircraft (id INT, model VARCHAR(255), manufacturer VARCHAR(255), year_manufactured INT, total_flight_hours INT); INSERT INTO Aircraft (id, model, manufacturer, year_manufactured, total_flight_hours) VALUES (1, 'B747', 'Boeing', 1990, 50000); INSERT INTO Aircraft (id, model, manufacturer, year_manufactured, total_flight_hours) VALUES (2, 'A320', 'Airbus', 2005, 30000); | What is the total flight hours for each aircraft model? | SELECT model, SUM(total_flight_hours) FROM Aircraft GROUP BY model; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_plants (id INT, country VARCHAR(255), name VARCHAR(255), capacity FLOAT); INSERT INTO hydro_plants (id, country, name, capacity) VALUES (1, 'Brazil', 'Hydro Plant A', 3000), (2, 'Colombia', 'Hydro Plant B', 2500), (3, 'Argentina', 'Hydro Plant C', 2000), (4, 'Peru', 'Hydro Plant D', 1500), (5, 'Venezuela', 'Hydro Plant E', 1000); | What is the total installed capacity of hydroelectric power plants in South America? | SELECT SUM(capacity) FROM hydro_plants WHERE country IN ('Brazil', 'Colombia', 'Argentina', 'Peru', 'Venezuela'); | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transit_trips (id INT, age_group TEXT, trip_count INT, city TEXT); INSERT INTO public_transit_trips (id, age_group, trip_count, city) VALUES (1, 'senior', 3000, 'NYC'), (2, 'adult', 5000, 'NYC'), (3, 'youth', 2000, 'NYC'); | What is the total number of public transportation trips taken by senior citizens in New York City? | SELECT SUM(trip_count) FROM public_transit_trips WHERE age_group = 'senior' AND city = 'NYC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE contracts (contract_id INT, vendor_id INT, contract_value FLOAT); INSERT INTO contracts (contract_id, vendor_id, contract_value) VALUES (1, 1001, 500000), (2, 1002, 300000), (3, 1001, 800000); | What is the average contract value for each vendor? | SELECT vendor_id, AVG(contract_value) AS avg_contract_value FROM contracts GROUP BY vendor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Player_Demographics (id INT PRIMARY KEY, player_id INT, age INT, gender VARCHAR(255), country VARCHAR(255), disability_status VARCHAR(255)); INSERT INTO Player_Demographics (id, player_id, age, gender, country) VALUES (1, 201, 25, 'Female', 'Canada'); | Update the 'disability_status' for player 201 to 'No' | UPDATE Player_Demographics SET disability_status = 'No' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_interests (user_id INT, interest VARCHAR(50), clicked_ads VARCHAR(50)); INSERT INTO user_interests (user_id, interest, clicked_ads) VALUES (1, 'cooking', 'plant-based diet'), (2, 'travel', 'budget travel'), (3, 'gardening', 'plant-based diet'), (4, 'fitness', 'gym membership'), (5, 'movies', 'streaming service'), (6, 'technology', 'smartphone'); | What are the unique interests of users who have clicked on ads about plant-based diets but have not posted about veganism or vegetarianism? | SELECT interest FROM user_interests WHERE clicked_ads = 'plant-based diet' AND interest NOT IN ('veganism', 'vegetarianism'); | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier (id INT, supplier VARCHAR(255), product_count INT); INSERT INTO supplier (id, supplier, product_count) VALUES (1, 'Supplier A', 200), (2, 'Supplier B', 150), (3, 'Supplier C', 300), (4, 'Supplier D', 250); | How many products are there in each supplier's inventory? | SELECT supplier, SUM(product_count) FROM supplier GROUP BY supplier; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(id INT, equipment_name VARCHAR(50), sale_date DATE, country VARCHAR(50), government_agency VARCHAR(50)); INSERT INTO sales VALUES (1, 'Submarine', '2019-01-01', 'Brazil', 'Ministry of Defense'); | Which military equipment sales contracts involved the Brazilian government and were finalized in 2019? | SELECT sales.equipment_name, sales.sale_date, sales.country, sales.government_agency FROM sales WHERE sales.country = 'Brazil' AND YEAR(sale_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (program_id INT, state VARCHAR(2), victims_served INT); INSERT INTO restorative_justice_programs (program_id, state, victims_served) VALUES (1, 'CA', 300), (2, 'NY', 400), (3, 'TX', 550), (4, 'FL', 600); | List the states with no restorative justice programs | SELECT state FROM restorative_justice_programs GROUP BY state HAVING COUNT(*) = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospital_visits (patient_id INT, visit_date DATE, state VARCHAR(2), diagnosis VARCHAR(10)); INSERT INTO hospital_visits (patient_id, visit_date, state, diagnosis) VALUES (1, '2019-01-01', 'FL', 'diabetes'); | What is the total number of hospital visits in Florida for patients with diabetes in the year 2019? | SELECT COUNT(*) FROM hospital_visits WHERE state = 'FL' AND diagnosis = 'diabetes' AND YEAR(visit_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE MuseumData (id INT, museum_name VARCHAR(50), num_employees INT, state VARCHAR(50)); INSERT INTO MuseumData (id, museum_name, num_employees, state) VALUES (1, 'Getty', 500, 'California'), (2, 'LACMA', 400, 'California'), (3, 'Met', 800, 'New York'), (4, 'MoMA', 700, 'New York'), (5, 'SFMOMA', 350, 'California'); | What is the average number of employees in museums located in California? | SELECT AVG(num_employees) FROM MuseumData WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinics (id INT, name TEXT, city TEXT, state TEXT, num_doctors INT, last_review_date DATE); INSERT INTO clinics (id, name, city, state, num_doctors, last_review_date) VALUES (1, 'Planned Parenthood', 'Los Angeles', 'CA', 15, '2020-01-10'); INSERT INTO clinics (id, name, city, state, num_doctors, last_review_date) VALUES (2, 'LA Free Clinic', 'Los Angeles', 'CA', 8, '2020-02-15'); | What is the average number of doctors in clinics in Los Angeles, CA? | SELECT city, AVG(num_doctors) FROM clinics WHERE state = 'CA' GROUP BY city HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_populations (subscriber_id INT, city VARCHAR(50), population INT); INSERT INTO city_populations (subscriber_id, city, population) VALUES (1, 'New York', 8600000), (2, 'Los Angeles', 4000000); | How many mobile customers are there in each city with a population over 1 million? | SELECT city, COUNT(*) FROM city_populations WHERE population > 1000000 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE traditional_crafts (id INT, name VARCHAR(50), age INT); INSERT INTO traditional_crafts (id, name, age) VALUES (1, 'Basket weaving', 5000), (2, 'Pottery', 10000), (3, 'Blacksmithing', 7000), (4, 'Wood carving', 8000), (5, 'Weaving', 6000); | What is the oldest record in the traditional_crafts table? | SELECT name, age FROM traditional_crafts ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Project_Timelines (id INT, project_name VARCHAR(255), timeline INT, is_sustainable BOOLEAN); INSERT INTO Project_Timelines (id, project_name, timeline, is_sustainable) VALUES (1, 'Green Building', 180, TRUE), (2, 'Solar Panel Installation', 120, TRUE), (3, 'Traditional Construction', 240, FALSE); | What is the maximum project timeline for a sustainable building project? | SELECT MAX(timeline) FROM Project_Timelines WHERE is_sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE worker (id INT PRIMARY KEY, industry VARCHAR(50), salary INT, salary_date DATE); | Insert a new record of a worker in the automotive industry with a salary of $70,000, employed on 2023-01-01. | INSERT INTO worker (industry, salary, salary_date) VALUES ('Automotive', 70000, '2023-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name VARCHAR(50)); INSERT INTO attorneys (id, name) VALUES (1, 'John Smith'); CREATE TABLE cases (id INT, attorney_id INT, billing_amount DECIMAL(10,2)); | What is the total billing amount for cases handled by attorney John Smith? | SELECT SUM(billing_amount) FROM cases WHERE attorney_id = (SELECT id FROM attorneys WHERE name = 'John Smith'); | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide (region VARCHAR(255), internet_speed INT); INSERT INTO digital_divide (region, internet_speed) VALUES ('Rural_America', 5), ('Urban_India', 50), ('Urban_Brazil', 20), ('Rural_Indonesia', 3); | Delete records in 'digital_divide' table if the 'internet_speed' is less than 10 Mbps | DELETE FROM digital_divide WHERE internet_speed < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE maritime_laws (law_id INT, law_name VARCHAR(50), region VARCHAR(50), penalty_amount INT); | What is the minimum maritime law penalty in the Mediterranean region in USD? | SELECT MIN(penalty_amount) FROM maritime_laws WHERE region = 'Mediterranean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicles (country VARCHAR(50), num_vehicles INT); INSERT INTO electric_vehicles (country, num_vehicles) VALUES ('China', 1140000), ('Japan', 850000), ('South Korea', 425000); | How many electric vehicles are there in China, Japan, and South Korea? | SELECT SUM(num_vehicles) FROM electric_vehicles WHERE country IN ('China', 'Japan', 'South Korea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artifacts (ArtifactID INT, SiteID INT, ArtifactType TEXT, DateFound DATE); INSERT INTO Artifacts (ArtifactID, SiteID, ArtifactType, DateFound) VALUES (1, 1, 'Pottery', '2010-06-01'); INSERT INTO Artifacts (ArtifactID, SiteID, ArtifactType, DateFound) VALUES (2, 1, 'Bone', '2010-06-03'); INSERT INTO Artifacts (ArtifactID, SiteID, ArtifactType, DateFound) VALUES (3, 2, 'Tool', '2008-08-28'); | How many artifacts were found at each site? | SELECT SiteID, COUNT(*) OVER (PARTITION BY SiteID) AS ArtifactCount FROM Artifacts; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name TEXT, region TEXT, average_depth FLOAT); | What is the average depth of all marine protected areas in the Pacific region, excluding areas with an average depth of over 4000 meters? | SELECT AVG(average_depth) FROM marine_protected_areas WHERE region = 'Pacific' AND average_depth < 4000; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO restaurants (restaurant_id, name, location) VALUES (1, 'ABC Cafe', 'New York'), (2, 'XYZ Diner', 'Los Angeles'); CREATE TABLE sales (sale_id INT, restaurant_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO sales (sale_id, restaurant_id, sale_date, revenue) VALUES (1, 1, '2021-01-01', 1000), (2, 1, '2021-01-03', 2000), (3, 2, '2021-01-02', 1500), (4, 2, '2021-01-04', 2500); | What is the total revenue for each restaurant, including the name and location, for the month of January 2021? | SELECT r.name, r.location, SUM(s.revenue) as total_revenue FROM restaurants r INNER JOIN sales s ON r.restaurant_id = s.restaurant_id WHERE s.sale_date BETWEEN '2021-01-01' AND '2021-01-31' GROUP BY r.restaurant_id, r.name, r.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO menus (id, name, category, price) VALUES (1, 'Veggie Burger', 'Vegan Dishes', 8.99), (2, 'Chickpea Curry', 'Vegan Dishes', 10.99), (3, 'Tofu Stir Fry', 'Vegan Dishes', 12.49); | What is the average price of 'Vegan Dishes'? | SELECT AVG(price) FROM menus WHERE category = 'Vegan Dishes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (Sale_ID INT, Strain TEXT, Retail_Price DECIMAL); INSERT INTO Sales (Sale_ID, Strain, Retail_Price) VALUES (1, 'Sour Diesel', 12.00); | Rank the strains of cannabis flower by their average retail price per gram, in descending order. | SELECT Strain, AVG(Retail_Price) as Avg_Price, RANK() OVER (ORDER BY AVG(Retail_Price) DESC) as Rank FROM Sales GROUP BY Strain; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_fleet (id INT, country VARCHAR(255), manufacturer VARCHAR(255), weight_class VARCHAR(255), fleet_size INT); | What is the distribution of satellite weight classes in the global satellite fleet? | SELECT weight_class, SUM(fleet_size) as total_fleet_size FROM satellite_fleet GROUP BY 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR, email VARCHAR, phone VARCHAR); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL, payment_method VARCHAR); | List the top 5 donors by total donation amount, including their names and contact information | SELECT d.name, d.email, d.phone, SUM(donations.amount) as total_donations FROM donors d JOIN donations ON d.id = donations.donor_id GROUP BY d.id ORDER BY total_donations DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerCount (GameID int, GameName varchar(100), Genre varchar(50), PlayerCount int); INSERT INTO PlayerCount VALUES (10, 'GameJ', 'FPS', 150000), (11, 'GameK', 'Action', 120000), (12, 'GameL', 'FPS', 180000); | Find the total number of players for FPS games. | SELECT SUM(PlayerCount) as TotalPlayers FROM PlayerCount WHERE Genre = 'FPS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantInspections (inspection_id INT, restaurant_id INT, food_safety_score INT); INSERT INTO RestaurantInspections (inspection_id, restaurant_id, food_safety_score) VALUES (1, 1, 80), (2, 2, 95), (3, 3, 70), (4, 4, 92), (5, 5, 85); | List restaurants with unsatisfactory food safety scores | SELECT r.restaurant_id, r.restaurant_name FROM Restaurants r INNER JOIN RestaurantInspections ri ON r.restaurant_id = ri.restaurant_id WHERE ri.food_safety_score < 85; | gretelai_synthetic_text_to_sql |
CREATE TABLE contracts (id INT, name VARCHAR(50), value INT); | Update the contract value of defense contract with ID 2 to 5000000 | UPDATE contracts SET value = 5000000 WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, category VARCHAR(20), amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, category, amount, donation_date) VALUES (1, 'Education', 500.00, '2021-01-05'), (2, 'Arts & Culture', 750.00, '2021-01-10'), (3, 'Health', 600.00, '2021-02-15'), (4, 'Arts & Culture', 300.00, '2021-03-01'); | What was the total donation amount for the 'Arts & Culture' category in Q1 2021? | SELECT SUM(amount) FROM donations WHERE category = 'Arts & Culture' AND donation_date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, treatment_type VARCHAR(10)); INSERT INTO patients (patient_id, age, treatment_type) VALUES (1, 30, 'therapy'), (2, 45, 'medication'), (3, 50, 'therapy'), (4, 25, 'therapy'); | What is the minimum age of patients who received therapy-based treatment? | SELECT MIN(age) FROM patients WHERE treatment_type = 'therapy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, temperature FLOAT, location VARCHAR(20)); INSERT INTO Warehouse (id, temperature, location) VALUES (1, 15, 'Warehouse A'), (2, 22, 'Warehouse B'); | What is the total number of pallets stored in Warehouse A with a temperature below 20 degrees Celsius? | SELECT COUNT(*) FROM Warehouse WHERE location = 'Warehouse A' AND temperature < 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(100), launch_date DATE, type VARCHAR(50)); | What is the latest launch date in the space_debris table? | SELECT MAX(launch_date) FROM space_debris; | gretelai_synthetic_text_to_sql |
CREATE TABLE college (college_name TEXT); INSERT INTO college (college_name) VALUES ('College of Engineering'), ('College of Arts'), ('College of Business'); CREATE TABLE faculty (faculty_id INTEGER, college_name TEXT, num_publications INTEGER); INSERT INTO faculty (faculty_id, college_name, num_publications) VALUES (1, 'College of Engineering', 5), (2, 'College of Engineering', 3), (3, 'College of Arts', 2), (4, 'College of Business', 4); | What is the average number of publications per faculty member in the 'College of Engineering'? | SELECT AVG(num_publications) FROM faculty WHERE college_name = 'College of Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteManufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50));CREATE TABLE SatelliteDeployment (DeploymentID INT, ManufacturerID INT, DeliveryTime DATE); | What is the average delivery time for satellites grouped by manufacturer? | SELECT AVG(DeliveryTime) AS AvgDeliveryTime, ManufacturerName FROM SatelliteDeployment SD INNER JOIN SatelliteManufacturers SM ON SD.ManufacturerID = SM.ManufacturerID GROUP BY ManufacturerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment_model VARCHAR(255), quantity INT, sale_date DATE, region VARCHAR(255)); | What is the total number of military equipment sold by 'Gamma Corp' to 'Middle East' for all models? | SELECT SUM(quantity) FROM MilitaryEquipmentSales WHERE seller = 'Gamma Corp' AND buyer = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (country VARCHAR(20), capacity INT); INSERT INTO energy_storage (country, capacity) VALUES ('Japan', 120000), ('US', 150000), ('Germany', 100000); | What is the total installed capacity of energy storage in Japan, the US, and Germany, and which one has the highest capacity? | SELECT e1.country, SUM(e1.capacity) as total_capacity FROM energy_storage e1 WHERE e1.country IN ('Japan', 'US', 'Germany') GROUP BY e1.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies(id INT, name TEXT, founding_year INT, funding_amount INT, racial_ethnicity TEXT); INSERT INTO Companies VALUES (1, 'TechCo', 2018, 5000000, 'African American'), (2, 'GreenTech', 2016, 7000000, 'Hispanic'), (3, 'AIStudio', 2020, 3000000, 'Asian'), (4, 'RenewableEnergy', 2019, 8000000, 'Native American'), (5, 'CloudServices', 2021, 6000000, 'Pacific Islander'); | What is the total funding amount for companies founded by underrepresented racial or ethnic groups in the last 5 years? | SELECT SUM(funding_amount) FROM Companies WHERE racial_ethnicity IN ('African American', 'Hispanic', 'Asian', 'Native American', 'Pacific Islander') AND founding_year >= YEAR(CURRENT_DATE) - 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE technologies (name TEXT, description TEXT, weight INT); INSERT INTO technologies (name, description, weight) VALUES ('Drones', 'Unmanned aerial vehicles.', 50), ('Stealth Technology', 'Invisible to radar.', 10000), ('Smart Bombs', 'Precision-guided munitions.', 500); | What are the names and descriptions of all military technologies in the technologies table that have a weight less than 1000 pounds? | SELECT name, description FROM technologies WHERE weight < 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_crops (id INT, name VARCHAR(50), location VARCHAR(50), year INT, production INT); INSERT INTO organic_crops (id, name, location, year, production) VALUES (1, 'Rice', 'India', 2020, 1000), (2, 'Wheat', 'Pakistan', 2020, 800), (3, 'Corn', 'Mexico', 2020, 1200), (4, 'Quinoa', 'Bolivia', 2020, 500), (5, 'Rice', 'India', 2019, 900), (6, 'Wheat', 'Pakistan', 2019, 700), (7, 'Corn', 'Mexico', 2019, 1100), (8, 'Quinoa', 'Bolivia', 2019, 450); | What is the total production of organic crops? | SELECT name, SUM(production) as total_production FROM organic_crops WHERE year = 2020 GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Authors (id INT, name TEXT, region TEXT); INSERT INTO Authors (id, name, region) VALUES (1, 'Author 1', 'North America'), (2, 'Author 2', 'Europe'), (3, 'Author 3', 'Asia'); | Which regions have the most diverse set of authors? | SELECT region, COUNT(DISTINCT name) as unique_authors FROM Authors GROUP BY region ORDER BY unique_authors DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountyF_Budget (Year INT, Service VARCHAR(20), Budget FLOAT); INSERT INTO CountyF_Budget (Year, Service, Budget) VALUES (2018, 'Parks', 3000000), (2019, 'Recreation', 4000000), (2020, 'Parks', 3500000), (2021, 'Recreation', 4500000), (2022, 'Parks', 4000000); | What is the sum of the budget allocated to parks and recreation services in 'CountyF' for even-numbered years between 2018 and 2022? | SELECT SUM(Budget) FROM CountyF_Budget WHERE Year BETWEEN 2018 AND 2022 AND Year % 2 = 0 AND Service = 'Parks'; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT);CREATE TABLE community_policing (community_policing_id INT, district_id INT, metric DECIMAL(3,2)); | Update the community policing metric for the 'Northeast' district to 85%. | UPDATE community_policing SET metric = 85 WHERE district_id = (SELECT district_id FROM districts WHERE district_name = 'Northeast'); | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_farms (id INT, name VARCHAR(100), country VARCHAR(50), capacity FLOAT, completion_date DATE); INSERT INTO solar_farms (id, name, country, capacity, completion_date) VALUES (1, 'Solarfarm A', 'China', 100, '2010-01-01'); INSERT INTO solar_farms (id, name, country, capacity, completion_date) VALUES (2, 'Solarfarm B', 'USA', 120, '2011-01-01'); | What is the maximum installed capacity of solar farms in each of the top 5 countries with the most solar farms? | SELECT country, MAX(capacity) AS max_capacity FROM solar_farms GROUP BY country ORDER BY max_capacity DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_initiatives (id INT, initiative_name VARCHAR(255), launch_date DATE); | How many pollution control initiatives were launched in the last 5 years? | SELECT count(*) FROM pollution_initiatives WHERE launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255)); INSERT INTO farmers (farmer_id, name, age, location) VALUES (1, 'John Doe', 35, 'Springfield'); | How many farmers are from Springfield? | SELECT COUNT(*) FROM farmers WHERE location = 'Springfield'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (id INT, title VARCHAR(50), runtime INT, genre VARCHAR(50)); | Delete all records from the tv_shows table where the runtime is less than 30 minutes. | DELETE FROM tv_shows WHERE runtime < 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(255), manufacturer_country VARCHAR(50)); INSERT INTO products (product_id, name, manufacturer_country) VALUES (1, 'T-Shirt', 'USA'), (2, 'Jeans', 'India'); CREATE TABLE product_reviews (review_id INT, product_id INT, rating INT); INSERT INTO product_reviews (review_id, product_id, rating) VALUES (1, 1, 5), (2, 2, 4); | What is the average rating of products from each country? | SELECT manufacturer_country, AVG(rating) FROM products JOIN product_reviews ON products.product_id = product_reviews.product_id GROUP BY manufacturer_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE rescue_centers (center_id INT, center_name VARCHAR(50), region VARCHAR(50));CREATE TABLE animal_rescues (rescue_id INT, animal_id INT, center_id INT, rescue_date DATE); INSERT INTO rescue_centers (center_id, center_name, region) VALUES (1, 'Rescue Center A', 'North'), (2, 'Rescue Center B', 'South'), (3, 'Rescue Center C', 'East'); INSERT INTO animal_rescues (rescue_id, animal_id, center_id, rescue_date) VALUES (1001, 101, 1, '2021-01-01'), (1002, 102, 2, '2021-03-01'), (1003, 103, 3, '2021-05-01'); | How many animals were rescued in each region? | SELECT rc.region, COUNT(ar.animal_id) AS total_rescued FROM animal_rescues ar JOIN rescue_centers rc ON ar.center_id = rc.center_id GROUP BY rc.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity_toronto (city VARCHAR(50), capacity INT); INSERT INTO landfill_capacity_toronto (city, capacity) VALUES ('Toronto', 4000), ('Seoul', 4500), ('Mumbai', 5000); | What is the maximum landfill capacity in Toronto? | SELECT MAX(capacity) FROM landfill_capacity_toronto WHERE city = 'Toronto'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, subcategory VARCHAR(255), price DECIMAL(5,2), is_refurbished BOOLEAN); INSERT INTO products (product_id, subcategory, price, is_refurbished) VALUES (1, 'Electronics', 100.99, true); | What is the minimum price of refurbished products, grouped by subcategory? | SELECT subcategory, MIN(price) AS min_price FROM products WHERE is_refurbished = true GROUP BY subcategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, policy_type VARCHAR(10), state VARCHAR(2)); INSERT INTO policies (id, policy_type, state) VALUES (1, 'car', 'NY'), (2, 'home', 'CA'), (3, 'car', 'FL'); | How many policies were sold in 'FL'? | SELECT COUNT(*) FROM policies WHERE state = 'FL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, volunteer_name TEXT, program TEXT, participation_date DATE, hours FLOAT); INSERT INTO Volunteers (id, volunteer_name, program, participation_date, hours) VALUES (1, 'Olivia', 'Tree Planting', '2022-02-01', 5), (2, 'Mateo', 'Beach Cleanup', '2022-03-05', 7.5); | What is the total number of volunteers and total volunteer hours for environmental programs? | SELECT program, COUNT(*), SUM(hours) FROM Volunteers WHERE program LIKE '%Environment%' GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, material VARCHAR(50), revenue INT); INSERT INTO sales (id, material, revenue) VALUES (1, 'cotton', 1000), (2, 'polyester', 2000), (3, 'recycled_polyester', 1500), (4, 'organic_cotton', 2500); | What percentage of sales comes from sustainable materials? | SELECT 100.0 * SUM(CASE WHEN material LIKE '%sustainable%' THEN revenue END) / SUM(revenue) as pct_sustainable_sales FROM sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE nhl_points (team_id INT, team_name TEXT, league TEXT, points INT, wins INT); INSERT INTO nhl_points (team_id, team_name, league, points, wins) VALUES (1, 'Colorado Avalanche', 'NHL', 119, 56), (2, 'Philadelphia Flyers', 'NHL', 61, 25); | What is the difference between the most and least points scored by each team in the 2021-2022 NHL season? | SELECT team_id, team_name, ABS(points - LEAD(points) OVER (PARTITION BY team_id ORDER BY team_id)) AS points_difference FROM nhl_points; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_suppliers (supplier_id INT PRIMARY KEY, name VARCHAR(255), rating INT); | Create a view for the top 3 food suppliers by rating | CREATE VIEW top_3_food_suppliers AS SELECT * FROM food_suppliers WHERE rating > 4 ORDER BY rating DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE baseball_homeruns (player_name VARCHAR(50), team VARCHAR(50), career_homeruns INT); INSERT INTO baseball_homeruns (player_name, team, career_homeruns) VALUES ('Sadaharu Oh', 'Yomiuri Giants', 868); | How many home runs did Sadaharu Oh hit in his professional baseball career? | SELECT career_homeruns FROM baseball_homeruns WHERE player_name = 'Sadaharu Oh'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, industry TEXT); INSERT INTO company (id, name, industry) VALUES (1, 'GreenTech', 'Sustainability'); CREATE TABLE investment_round (id INT, company_id INT); INSERT INTO investment_round (id, company_id) VALUES (1, 1); | Which startups in the sustainability sector have not yet received any funding? | SELECT c.name FROM company c LEFT JOIN investment_round ir ON c.id = ir.company_id WHERE ir.company_id IS NULL AND c.industry = 'Sustainability'; | gretelai_synthetic_text_to_sql |
CREATE TABLE academic_publications (id INT, student_name VARCHAR(50), student_major VARCHAR(50), publication_count INT); INSERT INTO academic_publications (id, student_name, student_major, publication_count) VALUES (1, 'Hannah Nguyen', 'Sociology', 15), (2, 'Ali Ahmed', 'Political Science', 20), (3, 'Sofia Rodriguez', 'Anthropology', 18), (4, 'Taro Tanaka', 'Economics', 12), (5, 'Xiao Wang', 'Psychology', 14), (6, 'Minh Lee', 'Social Work', 17); | Who are the top 5 graduate students with the highest number of academic publications in the College of Social Sciences? | SELECT student_name, publication_count FROM academic_publications WHERE student_major LIKE '%Social Sciences%' ORDER BY publication_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE donation_by_category (category VARCHAR(20), donation_amount INT); INSERT INTO donation_by_category (category, donation_amount) VALUES ('Education', 800); INSERT INTO donation_by_category (category, donation_amount) VALUES ('Healthcare', 1000); | What was the total amount donated to 'Education' and 'Healthcare' categories in 'donation_by_category' table? | SELECT SUM(donation_amount) FROM donation_by_category WHERE category IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature (year INT, continent TEXT, temperature FLOAT); INSERT INTO temperature (year, continent, temperature) VALUES (1950, 'Africa', 22.3), (1950, 'Asia', 23.1), (1950, 'Europe', 10.3), (1950, 'North America', 8.9), (1950, 'South America', 21.4), (1950, 'Oceania', 18.2), (2000, 'Africa', 22.7), (2000, 'Asia', 24.0), (2000, 'Europe', 10.8), (2000, 'North America', 9.5), (2000, 'South America', 21.8), (2000, 'Oceania', 18.8); | What is the average temperature change in each continent from 1950 to 2000? | SELECT continent, AVG(temperature) FROM temperature WHERE year BETWEEN 1950 AND 2000 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name VARCHAR(50), gender VARCHAR(10), company_id INT, founding_year INT); CREATE TABLE funding (id INT, company_id INT, amount INT); | What is the maximum funding received by a company founded by a woman in 2016? | SELECT MAX(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id WHERE founders.gender = 'female' AND founders.founding_year = 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE Greenhouse2 (date DATE, temperature FLOAT, humidity FLOAT); | Insert a new record of temperature 25 and humidity 60 in 'Greenhouse2' on 2023-01-01. | INSERT INTO Greenhouse2 (date, temperature, humidity) VALUES ('2023-01-01', 25, 60); | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (id INT, title VARCHAR(100), content TEXT, publication_date DATE); INSERT INTO news_articles (id, title, content, publication_date) VALUES (1, 'News Article 1', 'Content of News Article 1', '2021-01-01'); INSERT INTO news_articles (id, title, content, publication_date) VALUES (2, 'News Article 2', 'Content of News Article 2', '2021-02-01'); INSERT INTO news_articles (id, title, content, publication_date) VALUES (3, 'News Article 3', 'Content of News Article 3', '2022-01-01'); | How many news articles were published in 2021? | SELECT COUNT(*) FROM news_articles WHERE YEAR(publication_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, name VARCHAR(255), artist_id INT); CREATE TABLE exhibitions (id INT, name VARCHAR(255)); CREATE TABLE exhibition_artworks (exhibition_id INT, artwork_id INT); INSERT INTO artworks (id, name, artist_id) VALUES (1, 'The Persistence of Memory', 1); INSERT INTO exhibitions (id, name) VALUES (1, 'Contemporary Art'); INSERT INTO exhibition_artworks (exhibition_id, artwork_id) VALUES (1, 1); | Update artist_id for artworks in the 'Contemporary Art' exhibition | WITH updated_artworks AS (UPDATE artworks SET artist_id = 2 WHERE id IN (SELECT artwork_id FROM exhibition_artworks WHERE exhibition_id = 1)) SELECT * FROM updated_artworks; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_safety (vessel_name VARCHAR(255), category VARCHAR(255)); INSERT INTO vessel_safety (vessel_name, category) VALUES ('Titanic', 'High Risk'), ('Queen Mary 2', 'Medium Risk'), ('Andrea Gail', 'Low Risk'); | Identify the number of vessels in each maritime safety category and their corresponding categories. | SELECT category, COUNT(*) FROM vessel_safety GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO warehouses (id, name, location) VALUES (1, 'Warehouse A', 'City A'), (2, 'Warehouse B', 'City B'); CREATE TABLE inventory (id INT, warehouse_id INT, item_type VARCHAR(50), quantity INT); INSERT INTO inventory (id, warehouse_id, item_type, quantity) VALUES (1, 1, 'Item1', 100), (2, 1, 'Item2', 200), (3, 2, 'Item1', 150), (4, 2, 'Item3', 50); | What are the total quantities of items stored in each warehouse, grouped by item type? | SELECT item_type, SUM(quantity) as total_quantity FROM inventory JOIN warehouses ON inventory.warehouse_id = warehouses.id GROUP BY item_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, contract_value FLOAT, state TEXT); INSERT INTO defense_contracts (contract_id, contract_value, state) VALUES (6, 4000000, 'Virginia'), (7, 6000000, 'Virginia'); | What is the average defense contract value in Virginia? | SELECT AVG(contract_value) FROM defense_contracts WHERE state = 'Virginia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_name TEXT, in_circulation INTEGER, circulation_date DATE); INSERT INTO digital_assets (asset_name, in_circulation, circulation_date) VALUES ('Bitcoin', 18750000, '2022-03-01'), ('Ethereum', 115500000, '2022-03-01'); | What is the total number of digital assets in circulation in Canada as of 2022-03-01? | SELECT SUM(in_circulation) FROM digital_assets WHERE circulation_date = '2022-03-01' AND asset_name IN ('Bitcoin', 'Ethereum'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ContractorProjects (contractor VARCHAR(255), project_id INT, sustainability VARCHAR(255)); INSERT INTO ContractorProjects (contractor, project_id, sustainability) VALUES ('ABC Construction', 1, 'sustainable'), ('XYZ Builders', 2, 'sustainable'), ('GreenTech', 3, 'sustainable'), ('EcoBuilders', 4, 'sustainable'), ('SolarForce', 5, 'not sustainable'); | Who are the top 3 contractors with the most sustainable construction projects? | SELECT contractor, COUNT(*) AS num_sustainable_projects FROM ContractorProjects WHERE sustainability = 'sustainable' GROUP BY contractor ORDER BY num_sustainable_projects DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_id INT, debris_name VARCHAR(255), launch_date DATE, location VARCHAR(255), type VARCHAR(255)); | List all unique debris types in the 'space_debris' table | SELECT DISTINCT type FROM space_debris; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, player_name VARCHAR(50)); | Update player names to uppercase in the 'players' table | UPDATE players SET player_name = UPPER(player_name); | gretelai_synthetic_text_to_sql |
CREATE TABLE equity (id INT PRIMARY KEY, dispensary_id INT, program VARCHAR(255), approved_date DATE); INSERT INTO equity (id, dispensary_id, program, approved_date) VALUES (1, 2, 'Minority-owned', '2020-04-05'); | What dispensaries are part of the social equity program 'Minority-owned' that was approved in 2020? | SELECT d.name, e.program FROM dispensary d INNER JOIN equity e ON d.id = e.dispensary_id WHERE e.program = 'Minority-owned' AND e.approved_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE actor_ip (id INT, threat_actor VARCHAR(255), ip_address VARCHAR(255)); INSERT INTO actor_ip (id, threat_actor, ip_address) VALUES (1, 'APT28', '172.16.0.1'), (2, 'APT33', '10.0.0.1'), (3, 'APT34', '172.16.0.2'), (4, 'APT29', '10.0.0.2'), (5, 'APT35', '10.0.0.3'), (6, 'APT34', '10.0.0.4'); | What are the unique IP addresses that have been associated with 'APT34' threat actor? | SELECT DISTINCT ip_address FROM actor_ip WHERE threat_actor = 'APT34'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseContracts (id INT, vendor VARCHAR(50), contract_type VARCHAR(30), contract_value DECIMAL(15,2), contract_date DATE); INSERT INTO DefenseContracts (id, vendor, contract_type, contract_value, contract_date) VALUES (1, 'Lockheed Martin', 'Research', 5000000, '2022-05-10'); INSERT INTO DefenseContracts (id, vendor, contract_type, contract_value, contract_date) VALUES (2, 'Lockheed Martin', 'Manufacturing', 12000000, '2022-06-22'); | What is the total value of defense contracts with vendor 'Lockheed Martin' in Q2 2022, grouped by contract type? | SELECT contract_type, SUM(contract_value) as total_contract_value FROM DefenseContracts WHERE vendor = 'Lockheed Martin' AND contract_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY contract_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm_temps (id INT, farm_id INT, date DATE, water_temperature DECIMAL(5,2)); INSERT INTO farm_temps (id, farm_id, date, water_temperature) VALUES (1, 1, '2021-01-01', 12.5), (2, 1, '2021-02-01', 12.0), (3, 2, '2021-01-01', 13.2), (4, 2, '2021-02-01', 13.5), (5, 3, '2021-01-01', 16.0), (6, 3, '2021-02-01', 15.5); CREATE TABLE pacific_farms (id INT, farm_name TEXT, region TEXT); INSERT INTO pacific_farms (id, farm_name, region) VALUES (1, 'FarmA', 'Pacific'), (2, 'FarmB', 'Pacific'), (3, 'FarmC', 'Atlantic'); | Identify the number of farms in the Pacific region that have experienced a drop in water temperature. | SELECT COUNT(*) FROM (SELECT farm_id FROM farm_temps JOIN pacific_farms ON farm_temps.farm_id = pacific_farms.id WHERE pacific_farms.region = 'Pacific' AND water_temperature IN (SELECT water_temperature FROM farm_temps WHERE date > '2021-01-01' AND farm_id = farm_temps.farm_id) GROUP BY farm_id HAVING COUNT(DISTINCT date) > 1) AS temp_counts; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, category VARCHAR(50), fair_trade BOOLEAN); INSERT INTO products (product_id, category, fair_trade) VALUES (101, 'Electronics', FALSE), (102, 'Clothing', TRUE), (103, 'Food', TRUE), (104, 'Clothing', FALSE), (105, 'Electronics', TRUE); CREATE TABLE prices (price_id INT, product_id INT, price DECIMAL(10,2)); INSERT INTO prices (price_id, product_id, price) VALUES (1, 101, 500), (2, 102, 30), (3, 103, 2.5), (4, 104, 45), (5, 105, 800); | What is the average price of fair trade certified products for each product category? | SELECT category, AVG(price) AS avg_price FROM prices JOIN products ON prices.product_id = products.product_id WHERE products.fair_trade = TRUE GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE sales (dispensary_id INT, strain_id INT, quantity INT, price DECIMAL(10,2), sale_date DATE); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Arizona'); INSERT INTO sales (dispensary_id, strain_id, quantity, price, sale_date) VALUES (1, 1, 10, 50, '2022-04-01'); INSERT INTO sales (dispensary_id, strain_id, quantity, price, sale_date) VALUES (1, 2, 15, 60, '2022-04-15'); | Update the price of cannabis for strain_id 3 sold by Dispensary A in Arizona to $70 | UPDATE sales SET price = 70 WHERE dispensary_id = 1 AND strain_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (Id INT, Name VARCHAR(50), Age INT, Nationality VARCHAR(50)); INSERT INTO Members (Id, Name, Age, Nationality) VALUES (6, 'Sophia Rodriguez', 32, 'Mexico'), (7, 'Hiroshi Tanaka', 45, 'Japan'); CREATE TABLE Workouts (Id INT, MemberId INT, WorkoutType VARCHAR(50), Duration INT, Date DATE); INSERT INTO Workouts (Id, MemberId, WorkoutType, Duration, Date) VALUES (7, 6, 'Pilates', 45, '2022-01-07'), (8, 7, 'Barre', 60, '2022-01-08'); | Find the average age of members who have done 'Pilates' or 'Barre'? | SELECT AVG(m.Age) as AverageAge FROM Members m JOIN Workouts w ON m.Id = w.MemberId WHERE w.WorkoutType = 'Pilates' OR w.WorkoutType = 'Barre'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_ethics (tool_name VARCHAR(255), country VARCHAR(255), date DATE, impact_score INT); INSERT INTO ai_ethics (tool_name, country, date, impact_score) VALUES ('DeepRed', 'USA', '2022-01-01', 7), ('GreenAI', 'Canada', '2022-02-01', 8), ('FairAI', 'Mexico', '2022-03-01', 9); | Update the "impact_score" to 10 for the record in the "ai_ethics" table where the "tool_name" is 'GreenAI' and the "country" is 'Canada' | UPDATE ai_ethics SET impact_score = 10 WHERE tool_name = 'GreenAI' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (event_id INT PRIMARY KEY, name VARCHAR(50), date DATE, game VARCHAR(50), location VARCHAR(50)); | Add a new column to the esports_events table | ALTER TABLE esports_events ADD COLUMN prize_pool DECIMAL(10,2); | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, department VARCHAR(20));CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2), department VARCHAR(20)); INSERT INTO factories (factory_id, department) VALUES (1, 'textile'), (2, 'metal'), (3, 'electronics'); INSERT INTO workers (worker_id, factory_id, salary, department) VALUES (1, 1, 35000, 'textile'), (2, 1, 36000, 'textile'), (3, 2, 45000, 'metal'), (4, 2, 46000, 'metal'), (5, 3, 55000, 'electronics'); | What is the average salary of workers in the 'textile' department across all factories? | SELECT AVG(w.salary) FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'textile'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainabilityRatings (product_id INT, carbon_footprint DECIMAL(5,2), water_usage DECIMAL(5,2), country VARCHAR(50)); INSERT INTO SustainabilityRatings (product_id, carbon_footprint, water_usage, country) VALUES (4, 1.8, 10.0, 'Australia'); | What is the average water usage for products with a carbon footprint less than 2.0 in Australia? | SELECT AVG(water_usage) as avg_water_usage FROM SustainabilityRatings WHERE carbon_footprint < 2.0 AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE users (id INT, user_name VARCHAR(50), region VARCHAR(50), registration_method VARCHAR(50), join_date DATE); INSERT INTO users (id, user_name, region, registration_method, join_date) VALUES (1, 'Sophia Lee', 'Asia', 'Online', '2022-03-15'); INSERT INTO users (id, user_name, region, registration_method, join_date) VALUES (2, 'Minho Park', 'Asia', 'In-person', '2022-07-23'); | What is the total number of users who joined from 'Asia' using the 'Online' registration method? | SELECT COUNT(*) FROM fitness.users WHERE region = 'Asia' AND registration_method = 'Online'; | 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.