context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE inventory (item_id INT, quantity INT, unit_price DECIMAL(5,2)); INSERT INTO inventory (item_id, quantity, unit_price) VALUES (1, 10, 12.99), (2, 20, 7.50), (3, 30, 9.99), (4, 40, 15.49), (5, 50, 8.99); CREATE TABLE orders (order_id INT, item_id INT, order_date DATE, restaurant_id INT); INSERT INTO orders (order_id, item_id, order_date, restaurant_id) VALUES (1, 1, '2022-03-01', 2), (2, 3, '2022-03-02', 2), (3, 2, '2022-03-03', 1), (4, 4, '2022-03-04', 1), (5, 5, '2022-03-05', 2); CREATE TABLE menu_items (item_id INT, name TEXT, is_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO menu_items (item_id, name, is_vegan, price) VALUES (1, 'Quinoa Salad', true, 12.99), (2, 'Beef Burger', false, 7.50), (3, 'Chickpea Curry', true, 9.99), (4, 'Cheesecake', false, 15.49), (5, 'Veggie Pizza', true, 8.99); CREATE TABLE restaurants (restaurant_id INT, name TEXT, region TEXT); INSERT INTO restaurants (restaurant_id, name, region) VALUES (1, 'Big Burger', 'East'), (2, 'Veggies R Us', 'Midwest'), (3, 'Tasty Bites', 'West'); | Determine the revenue generated from the sale of dishes in a specific region in the last month. | SELECT SUM(i.quantity * m.price) as revenue FROM inventory i JOIN orders o ON i.item_id = o.item_id JOIN menu_items m ON i.item_id = m.item_id JOIN restaurants r ON o.restaurant_id = r.restaurant_id WHERE o.order_date BETWEEN '2022-02-01' AND '2022-02-28' AND r.region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (workout_id INT, member_id INT, gym_id INT, workout_date DATE, calories INT); INSERT INTO workouts (workout_id, member_id, gym_id, workout_date, calories) VALUES (1, 1, 1, '2022-01-01', 300), (2, 2, 1, '2022-01-02', 400), (3, 3, 2, '2022-01-03', 500); | Delete the workout with workout_id 1 | DELETE FROM workouts WHERE workout_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE bus_routes (route_id INT, vehicle_type VARCHAR(10), fare DECIMAL(5,2)); CREATE TABLE fares (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), fare_collection_date DATE); INSERT INTO bus_routes VALUES (1, 'Bus', 2.50), (2, 'Bus', 3.00); INSERT INTO fares VALUES (1, 1, 2.50, '2022-01-01'), (2, 1, 2.50, '2022-01-02'), (3, 2, 3.00, '2022-01-03'); | What is the average fare collected per trip for buses in the month of January 2022? | SELECT AVG(f.fare_amount) FROM fares f JOIN bus_routes br ON f.route_id = br.route_id WHERE f.fare_collection_date BETWEEN '2022-01-01' AND '2022-01-31' AND br.vehicle_type = 'Bus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (SiteID int, SiteName varchar(50), Location varchar(50)); CREATE TABLE PublicOutreach (EventID int, SiteID int, EventType varchar(20), Attendance int); | How many public outreach events have been held at each excavation site, and what was the average attendance? | SELECT ExcavationSites.SiteName, AVG(PublicOutreach.Attendance) AS AverageAttendance, COUNT(PublicOutreach.EventID) AS NumberOfEvents FROM ExcavationSites INNER JOIN PublicOutreach ON ExcavationSites.SiteID = PublicOutreach.SiteID GROUP BY ExcavationSites.SiteName; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide (region VARCHAR(255), year INT, gender VARCHAR(10), internet_accessibility FLOAT, mobile_accessibility FLOAT); INSERT INTO digital_divide (region, year, gender, internet_accessibility, mobile_accessibility) VALUES ('North America', 2015, 'Male', 0.85, 0.93), ('South America', 2016, 'Female', 0.68, 0.82), ('Asia', 2017, 'Male', 0.52, 0.81); | Show all records in digital_divide table with 'Female' gender | SELECT * FROM digital_divide WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CourtCases (CourtName text, CaseType text, CaseStatus text, Year int, NumCases int); INSERT INTO CourtCases VALUES ('Court1', 'Assault', 'Open', 2022, 30, '2022-01-01'), ('Court1', 'Theft', 'Closed', 2022, 25, '2022-01-01'), ('Court2', 'Assault', 'Open', 2022, 28, '2022-01-01'), ('Court2', 'Theft', 'Closed', 2022, 22, '2022-01-01'); | What is the number of cases in each court, broken down by case type, case status, and year? | SELECT CourtName, CaseType, CaseStatus, Year, SUM(NumCases) FROM CourtCases GROUP BY CourtName, CaseType, CaseStatus, Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (model_name TEXT, explainability_score INTEGER); INSERT INTO creative_ai (model_name, explainability_score) VALUES ('modelB', 72), ('modelD', 78); | Update the explainability score for 'modelB' to 75 in the 'creative_ai' table. | UPDATE creative_ai SET explainability_score = 75 WHERE model_name = 'modelB'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name TEXT); CREATE TABLE articles (id INT, title TEXT, content TEXT, region_id INT); INSERT INTO regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO articles (id, title, content, region_id) VALUES (1, 'Article 1', 'Content 1', 1), (2, 'Article 2', 'Content 2', 2), (3, 'Article 3', 'Content 3', 2), (4, 'Article 4', 'Content 4', 3), (5, 'Article 5', 'Content 5', 4); | Which regions have more than 5 articles published? | SELECT regions.name, COUNT(articles.id) FROM regions INNER JOIN articles ON regions.id = articles.region_id GROUP BY regions.name HAVING COUNT(articles.id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good (id INT, project_name TEXT, budget INT, region TEXT); INSERT INTO social_good (id, project_name, budget, region) VALUES (1, 'Tech4Good Initiative', 50000, 'Europe'), (2, 'SocialTech Program', 75000, 'North America'), (3, 'DigitalDivide Fund', 60000, 'Europe'); | What is the average budget for technology for social good projects in Europe? | SELECT AVG(budget) as avg_budget FROM social_good WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_ethics (article_id INT, author VARCHAR(50), title VARCHAR(100), published_date DATE, category VARCHAR(30), author_region VARCHAR(30)); INSERT INTO media_ethics (article_id, author, title, published_date, category, author_region) VALUES (1, 'John Doe', 'Article 5', '2021-01-05', 'Ethics', 'North America'), (2, 'Jane Smith', 'Article 6', '2021-01-06', 'Ethics', 'Europe'); | What is the total number of articles published by authors from different regions in the 'media_ethics' table? | SELECT author_region, COUNT(article_id) AS total_articles FROM media_ethics GROUP BY author_region; | gretelai_synthetic_text_to_sql |
CREATE TABLE MonthlyVisitors (visitor_id INT, destination VARCHAR(50), country VARCHAR(50), visit_month DATE); INSERT INTO MonthlyVisitors (visitor_id, destination, country, visit_month) VALUES (1, 'Eco Park', 'Brazil', '2022-02-01'); INSERT INTO MonthlyVisitors (visitor_id, destination, country, visit_month) VALUES (2, 'Green Beach', 'Argentina', '2022-03-01'); | What is the maximum number of visitors to any sustainable destination in South America in a month? | SELECT MAX(visitor_id) FROM MonthlyVisitors WHERE country IN ('South America') AND visit_month BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Innovation (Project_ID INT, Project_Name VARCHAR(50), Start_Date DATE); INSERT INTO Military_Innovation (Project_ID, Project_Name, Start_Date) VALUES (1, 'Stealth Fighter Project', '1980-01-01'); CREATE TABLE Humanitarian_Assistance (Mission_ID INT, Mission_Name VARCHAR(50), Location VARCHAR(50), Start_Date DATE, End_Date DATE); INSERT INTO Humanitarian_Assistance (Mission_ID, Mission_Name, Location, Start_Date, End_Date) VALUES (1, 'Operation Restore Hope', 'Somalia', '1992-01-01', '1993-12-31'); | What is the total number of military innovation projects and humanitarian assistance missions? | SELECT COUNT(*) as Total_Projects FROM Military_Innovation; SELECT COUNT(*) as Total_Missions FROM Humanitarian_Assistance; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovations (innovation_id INT, innovation_name VARCHAR(255), year INT); INSERT INTO military_innovations (innovation_id, innovation_name, year) VALUES (1, 'Stealth Drone', 2019), (2, 'Cyber Warfare Unit', 2018), (3, 'Laser Weapon System', 2020), (4, 'Artificial Intelligence in Battlefield', 2021), (5, 'Hypersonic Missile', 2019); | Which military innovations were introduced in the last 2 years? | SELECT innovation_name FROM military_innovations WHERE year BETWEEN (SELECT YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, title VARCHAR(50), release_date DATE, genre VARCHAR(20), vr_compatible VARCHAR(5)); | List the top 5 most popular game genres in the last month, along with the number of games released in each genre and the percentage of VR games. | SELECT g.genre, COUNT(g.id) AS games_released, SUM(CASE WHEN g.release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) THEN 1 ELSE 0 END) AS popular_in_last_month, 100.0 * SUM(CASE WHEN g.vr_compatible = 'Yes' THEN 1 ELSE 0 END) / COUNT(g.id) AS vr_percentage FROM games g GROUP BY g.genre ORDER BY games_released DESC, popular_in_last_month DESC, vr_percentage DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), position VARCHAR(50), team VARCHAR(50)); | Delete the 'player' record with ID '123' from the 'players' table | DELETE FROM players WHERE id = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE Equipment_Repairs (ID INT, Month VARCHAR(50), Year INT, Repairs INT); INSERT INTO Equipment_Repairs (ID, Month, Year, Repairs) VALUES (1, 'January', 2017, 150), (2, 'February', 2017, 120), (3, 'March', 2017, 180); | What is the average number of military equipment repairs per month? | SELECT Month, AVG(Repairs) FROM Equipment_Repairs GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (property_id INT, building_type TEXT, construction_year INT); INSERT INTO green_buildings VALUES (1, 'Apartment', 2010), (2, 'House', 2005), (3, 'Townhouse', 2015) | Count the number of properties in each 'building_type' in green_buildings. | SELECT building_type, COUNT(*) AS num_properties FROM green_buildings GROUP BY building_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE gas_prices (id INT PRIMARY KEY, tx_hash VARCHAR(255), gas_price DECIMAL(10, 2), chain VARCHAR(255)); INSERT INTO gas_prices (id, tx_hash, gas_price, chain) VALUES (1, 'tx1', 50, 'Binance Smart Chain'), (2, 'tx2', 75, 'Binance Smart Chain'); | What's the average gas price for transactions on the Binance Smart Chain? | SELECT AVG(gas_price) FROM gas_prices WHERE chain = 'Binance Smart Chain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryScores (id INT, country_id INT, year INT, score INT); INSERT INTO CountryScores (id, country_id, year, score) VALUES (1, 1, 2018, 70); INSERT INTO CountryScores (id, country_id, year, score) VALUES (2, 1, 2019, 75); INSERT INTO CountryScores (id, country_id, year, score) VALUES (3, 2, 2018, 80); INSERT INTO CountryScores (id, country_id, year, score) VALUES (4, 2, 2019, 85); INSERT INTO CountryScores (id, country_id, year, score) VALUES (5, 3, 2018, 60); INSERT INTO CountryScores (id, country_id, year, score) VALUES (6, 3, 2019, 65); INSERT INTO CountryScores (id, country_id, year, score) VALUES (7, 4, 2018, 90); INSERT INTO CountryScores (id, country_id, year, score) VALUES (8, 4, 2019, 95); | Identify countries with a significant increase in sustainable tourism scores between 2018 and 2019. | SELECT country_id, (score - LAG(score, 1) OVER (PARTITION BY country_id ORDER BY year)) as score_change FROM CountryScores WHERE score_change >= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (project_id INT, name VARCHAR(50), location VARCHAR(50), spending FLOAT); CREATE TABLE continent (continent_id INT, name VARCHAR(50), description TEXT); | List the names and total spending of all rural infrastructure projects in Africa? | SELECT p.name, SUM(p.spending) FROM project p JOIN continent c ON p.location = c.name WHERE c.name = 'Africa' GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, name VARCHAR(20), type VARCHAR(20), rating FLOAT); INSERT INTO games (id, name, type, rating) VALUES (1, 'GameA', 'VR', 8.7); INSERT INTO games (id, name, type, rating) VALUES (2, 'GameB', 'Non-VR', 9.1); | List all VR games with a rating above 8.5. | SELECT * FROM games WHERE type = 'VR' AND rating > 8.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval(drug_name TEXT, region TEXT, approval_quarter INT); INSERT INTO drug_approval (drug_name, region, approval_quarter) VALUES ('DrugA', 'RegionX', 1), ('DrugB', 'RegionY', 2), ('DrugD', 'RegionH', 1), ('DrugC', 'RegionZ', 4), ('DrugE', 'RegionH', 3), ('DrugF', 'RegionH', 2); | What is the number of drugs approved for use in 'RegionH' between Q1 and Q3 of 2020? | SELECT COUNT(*) FROM drug_approval WHERE region = 'RegionH' AND approval_quarter BETWEEN 1 AND 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway (id INT, name VARCHAR(255), location VARCHAR(255), length FLOAT); INSERT INTO subway (id, name, location, length) VALUES (1, 'Line 1', 'Seoul, South Korea', 19.6); | What is the average length of all subway lines in Seoul, South Korea? | SELECT AVG(length) FROM subway WHERE location = 'Seoul, South Korea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donor (id INT, name VARCHAR(255)); | What is the total number of donations made by each donor? | SELECT Donor.name, SUM(Donation.amount) as total_donations FROM Donor JOIN Donation ON Donor.id = Donation.donor_id GROUP BY Donor.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleet_data (id INT, vehicle_type VARCHAR(20), added_date DATE, city VARCHAR(20)); INSERT INTO fleet_data (id, vehicle_type, added_date, city) VALUES (1, 'Electric', '2022-04-15', 'New York'); INSERT INTO fleet_data (id, vehicle_type, added_date, city) VALUES (2, 'Electric', '2022-04-20', 'New York'); INSERT INTO fleet_data (id, vehicle_type, added_date, city) VALUES (3, 'Conventional', '2022-04-25', 'New York'); | How many electric vehicles were added to the fleet in New York in the past month? | SELECT COUNT(*) as num_electric_vehicles FROM fleet_data WHERE vehicle_type = 'Electric' AND city = 'New York' AND added_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (project_id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); | Show me the name and start date of all climate finance projects in 'Asia' that ended after 2010. | SELECT project_name, start_date FROM climate_finance WHERE location = 'Asia' AND end_date >= '2010-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_statistics (id INT, city VARCHAR(255), state VARCHAR(255), hourly_wage FLOAT); | List all construction labor statistics for the state of New York, broken down by city. | SELECT city, state, hourly_wage FROM labor_statistics WHERE state = 'New York' ORDER BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE OilWells (WellID INT, Location VARCHAR(20), ProductionYear INT, OilProduction INT); INSERT INTO OilWells (WellID, Location, ProductionYear, OilProduction) VALUES (1, 'Permian Basin', 2020, 900000), (2, 'Permian Basin', 2019, 800000), (3, 'North Sea', 2021, 700000); | What is the total oil production, in barrels, for all wells in the Permian Basin, for the year 2020? | SELECT SUM(OilProduction) FROM OilWells WHERE Location = 'Permian Basin' AND ProductionYear = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT PRIMARY KEY, vendor VARCHAR(50), quantity INT, species VARCHAR(50), price DECIMAL(5,2)); INSERT INTO sales (id, vendor, quantity, species, price) VALUES (1, 'Seafood Haven', 20, 'Salmon', 12.99), (2, 'Sea Bounty', 30, 'Tilapia', 9.49), (3, 'Sea Bounty', 15, 'Cod', 14.50); | Display the total revenue generated from each vendor in the 'sales' table. | SELECT vendor, SUM(quantity * price) FROM sales GROUP BY vendor; | gretelai_synthetic_text_to_sql |
CREATE TABLE trainings(id INT, date DATE, location TEXT, participants INT); INSERT INTO trainings(id, date, location, participants) VALUES (1, '2021-01-10', 'New York', 25); INSERT INTO trainings(id, date, location, participants) VALUES (2, '2021-03-15', 'San Francisco', 30); INSERT INTO trainings(id, date, location, participants) VALUES (3, '2022-06-30', 'London', 20); | What is the total number of ethical AI training sessions conducted in 2021? | SELECT SUM(participants) FROM trainings WHERE YEAR(date) = 2021 AND location LIKE '%AI%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_fabric (id INT, fabric_type VARCHAR(20), quantity INT, continent VARCHAR(20)); INSERT INTO sustainable_fabric (id, fabric_type, quantity, continent) VALUES (1, 'organic_cotton', 500, 'Australia'); INSERT INTO sustainable_fabric (id, fabric_type, quantity, continent) VALUES (2, 'recycled_polyester', 300, 'New Zealand'); | What is the average quantity of sustainable fabric sourced from Oceania? | SELECT AVG(quantity) FROM sustainable_fabric WHERE continent IN ('Australia', 'New Zealand'); | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthEquityMetrics (MetricID INT, Community VARCHAR(25), Age INT, MetricDate DATE, Value FLOAT); INSERT INTO HealthEquityMetrics (MetricID, Community, Age, MetricDate, Value) VALUES (1, 'South Bronx', 25, '2021-01-01', 78.5); INSERT INTO HealthEquityMetrics (MetricID, Community, Age, MetricDate, Value) VALUES (2, 'South Bronx', 30, '2021-02-15', 79.2); INSERT INTO HealthEquityMetrics (MetricID, Community, Age, MetricDate, Value) VALUES (3, 'South Bronx', 35, '2021-03-30', 80.1); INSERT INTO HealthEquityMetrics (MetricID, Community, Age, MetricDate, Value) VALUES (4, 'South Bronx', 40, '2021-04-15', 81.0); | What is the trend in health equity metrics for a specific community based on age? | SELECT Age, Value FROM HealthEquityMetrics WHERE Community = 'South Bronx' ORDER BY Age; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (TeamID INT, Game VARCHAR(50), Name VARCHAR(50), Wins INT, Losses INT); INSERT INTO Teams (TeamID, Game, Name, Wins, Losses) VALUES (1, 'GameA', 'TeamA', 10, 5); INSERT INTO Teams (TeamID, Game, Name, Wins, Losses) VALUES (2, 'GameB', 'TeamC', 15, 3); INSERT INTO Teams (TeamID, Game, Name, Wins, Losses) VALUES (3, 'GameB', 'TeamD', 5, 8); | Update the win rate of teams in game B by dividing the number of wins by the sum of wins and losses. | UPDATE Teams SET WinRate = (Wins / (Wins + Losses)) WHERE Game = 'GameB'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_donation (donor_id INT, org_id INT, donation_id INT); INSERT INTO donor_donation (donor_id, org_id, donation_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3), (4, 3, 4), (5, 4, 5); | How many unique donors have donated to each organization? | SELECT org_id, COUNT(DISTINCT donor_id) as unique_donors FROM donor_donation GROUP BY org_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory(item_id INT, item_name VARCHAR(50), is_kosher BOOLEAN, is_vegan BOOLEAN, weight DECIMAL(5,2)); INSERT INTO Inventory VALUES(1,'Tofu',TRUE,TRUE,0.5),(2,'Seitan',TRUE,TRUE,1.0),(3,'TV Dinner',FALSE,FALSE,0.3); | What is the total weight of items in the inventory that are both Kosher and vegan? | SELECT SUM(weight) FROM Inventory WHERE is_kosher = TRUE AND is_vegan = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Veteran_Employment (id INT, state VARCHAR(50), unemployment_rate FLOAT); INSERT INTO Veteran_Employment (id, state, unemployment_rate) VALUES (1, 'California', 3.5), (2, 'Texas', 4.0); | Show veteran unemployment rates by state? | SELECT Veteran_Employment.state, Veteran_Employment.unemployment_rate FROM Veteran_Employment ORDER BY Veteran_Employment.unemployment_rate; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(50), is_fair_trade BOOLEAN, revenue FLOAT); | What is the total revenue generated from cosmetic products that are fair trade certified? | SELECT SUM(revenue) FROM cosmetics WHERE is_fair_trade = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'); | Delete a marine species from the 'marine_species' table | DELETE FROM marine_species WHERE species_name = 'Oceanic Whitetip Shark'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), supplier_id INT); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50)); INSERT INTO products (product_id, product_name, supplier_id) VALUES (1, 'T-Shirt', 1), (2, 'Jeans', 2), (3, 'Shoes', 3), (4, 'Dress', 1), (5, 'Bag', 2); INSERT INTO suppliers (supplier_id, supplier_name) VALUES (1, 'GreenEarth'), (2, 'EcoBlue'), (3, 'CircularWear'); | How many products does each supplier supply? | SELECT suppliers.supplier_name, COUNT(products.product_id) FROM suppliers LEFT JOIN products ON suppliers.supplier_id = products.supplier_id GROUP BY suppliers.supplier_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, city VARCHAR(20), country VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id, city, country) VALUES (1, 'Mumbai', 'India'), (2, 'Delhi', 'India'), (3, 'Bangalore', 'India'); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO Visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 25), (2, 1, 28), (3, 2, 15), (4, 2, 18), (5, 3, 35), (6, 3, 40); | What is the average age of visitors who attended exhibitions in 'Mumbai'? | SELECT AVG(age) FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.city = 'Mumbai'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, JoinDate DATE, Region VARCHAR(50)); INSERT INTO Members (MemberID, JoinDate, Region) VALUES (1, '2022-04-01', 'Northeast'), (2, '2022-05-14', 'Southeast'), (3, '2022-06-03', 'Northeast'); CREATE TABLE Donations (DonationID INT, MemberID INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID, MemberID, DonationDate, Amount) VALUES (1, 1, '2022-04-05', 50.00), (2, 2, '2022-05-15', 100.00), (3, 3, '2022-06-07', 25.00); | What is the average donation amount by new members in Q2 2022? | SELECT AVG(Amount) FROM Donations INNER JOIN Members ON Donations.MemberID = Members.MemberID WHERE YEAR(DonationDate) = 2022 AND Members.MemberID NOT IN (SELECT Members.MemberID FROM Members GROUP BY Members.MemberID HAVING COUNT(Members.MemberID) < 2) AND QUARTER(DonationDate) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Country (ID INT, Name VARCHAR(50), Continent VARCHAR(50)); INSERT INTO Country (ID, Name, Continent) VALUES (1, 'Nigeria', 'Africa'), (2, 'Kenya', 'Africa'); CREATE TABLE CommunityInitiatives (ID INT, CountryID INT, Initiative VARCHAR(50)); INSERT INTO CommunityInitiatives (ID, CountryID, Initiative) VALUES (1, 1, 'Library'), (2, 1, 'Playground'), (3, 2, 'Health Center'); | What is the average number of community development initiatives in Africa, grouped by country? | SELECT c.Name, AVG(CI.Initiative) as AvgInitiativesPerCountry FROM Country c JOIN CommunityInitiatives CI ON c.ID = CI.CountryID WHERE c.Continent = 'Africa' GROUP BY c.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, name TEXT, type TEXT, country TEXT); INSERT INTO initiatives (id, name, type, country) VALUES (1, 'Sustainable Tourism in the Rockies', 'Sustainable Tourism', 'Canada'), (2, 'Eco-Friendly Whale Watching in British Columbia', 'Sustainable Tourism', 'Canada'), (3, 'Historic Sites of Quebec City', 'Cultural Heritage', 'Canada'); | How many sustainable tourism initiatives are in Canada? | SELECT COUNT(*) FROM initiatives WHERE type = 'Sustainable Tourism' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AI_Safety_Topics (id INT, topic TEXT, published_date DATE); INSERT INTO AI_Safety_Topics (id, topic, published_date) VALUES (1, 'Topic1', '2017-01-01'), (2, 'Topic2', '2018-05-15'), (3, 'Topic3', '2016-03-20'), (4, 'Topic4', '2018-12-31'); | List all unique AI safety research topics addressed before 2018. | SELECT DISTINCT topic FROM AI_Safety_Topics WHERE published_date < '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, country VARCHAR(50), sector VARCHAR(50), amount FLOAT); INSERT INTO investments (id, country, sector, amount) VALUES (1, 'Canada', 'Climate Change', 500000), (2, 'Mexico', 'Renewable Energy', 750000), (3, 'Canada', 'Climate Change', 600000); | What is the average investment in climate change mitigation projects in North America? | SELECT AVG(amount) as avg_investment FROM investments WHERE sector = 'Climate Change' AND country IN (SELECT country FROM (SELECT * FROM countries WHERE region = 'North America') as north_america); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_hospital (patient_id INT, age INT, gender VARCHAR(10)); INSERT INTO rural_hospital (patient_id, age, gender) VALUES (1, 35, 'Male'), (2, 50, 'Female'), (3, 42, 'Male'), (4, 60, 'Male'), (5, 30, 'Female'); | How many male patients are in the 'rural_hospital' table? | SELECT COUNT(*) FROM rural_hospital WHERE gender = 'Male'; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (strain_id INT, name VARCHAR(255), type VARCHAR(255), price FLOAT); INSERT INTO strains (strain_id, name, type, price) VALUES (10, 'Green Crack', 'Sativa', NULL); CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (2, 'Green Earth'); CREATE TABLE inventory (inventory_id INT, strain_id INT, dispensary_id INT, price FLOAT, quantity INT); | Insert new 'Sativa' strain 'Green Crack' with price $15 per gram into 'Green Earth' dispensary. | INSERT INTO inventory (inventory_id, strain_id, dispensary_id, price, quantity) SELECT NULL, (SELECT strain_id FROM strains WHERE name = 'Green Crack' AND type = 'Sativa'), (SELECT dispensary_id FROM dispensaries WHERE name = 'Green Earth'), 15, 25; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (tv_show_id INT, title VARCHAR(50), production_country VARCHAR(50), premiere_date DATE, production_budget INT); INSERT INTO tv_shows (tv_show_id, title, production_country, premiere_date, production_budget) VALUES (1, 'TV Show1', 'Mexico', '2020-01-01', 10000000), (2, 'TV Show2', 'Brazil', '2019-12-25', 12000000), (3, 'TV Show3', 'Mexico', '2018-05-15', 9000000); CREATE TABLE producers (producer_id INT, name VARCHAR(50), nationality VARCHAR(50)); INSERT INTO producers (producer_id, name, nationality) VALUES (1, 'Producer1', 'Mexico'), (2, 'Producer2', 'Brazil'), (3, 'Producer3', 'Mexico'); | List all TV shows produced in Mexico or created by Mexican producers, along with their production budget and premiere date. | SELECT tv_shows.title, tv_shows.production_country, tv_shows.premiere_date, tv_shows.production_budget FROM tv_shows INNER JOIN producers ON (tv_shows.production_country = 'Mexico' OR producers.nationality = 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenGrocers (supplier_id INT, supplier_name VARCHAR(50)); CREATE TABLE SupplierEcoLabels (supplier_id INT, eco_label VARCHAR(50)); INSERT INTO GreenGrocers (supplier_id, supplier_name) VALUES (1, 'EcoFarm'), (2, 'GreenFields'), (3, 'NatureVille'); INSERT INTO SupplierEcoLabels (supplier_id, eco_label) VALUES (1, 'Certified Organic'), (1, 'Non-GMO'), (2, 'Fair Trade'), (3, 'Regenerative Agriculture'); | List all suppliers and their associated eco-labels in 'GreenGrocers'? | SELECT g.supplier_name, e.eco_label FROM GreenGrocers g INNER JOIN SupplierEcoLabels e ON g.supplier_id = e.supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance (id INT, country VARCHAR(255), asset_value DECIMAL(10,2)); | What is the maximum Shariah-compliant finance asset value in the Gulf Cooperation Council (GCC) countries? | SELECT MAX(asset_value) FROM shariah_compliant_finance WHERE country IN (SELECT country FROM (SELECT DISTINCT country FROM shariah_compliant_finance WHERE region = 'Gulf Cooperation Council') t); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), join_date DATE, total_likes INT); CREATE TABLE privacy_settings (id INT, user_id INT, allow_notifications BOOLEAN, allow_messages BOOLEAN, allow_location BOOLEAN); | Insert new user with privacy settings | INSERT INTO users (id, name, join_date, total_likes) VALUES (3, 'Charlie', '2021-03-03', 200); INSERT INTO privacy_settings (id, user_id, allow_notifications, allow_messages, allow_location) VALUES (3, 3, false, true, false); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA Government;CREATE TABLE Government.Region (name VARCHAR(255), budget INT);CREATE TABLE Government.City (name VARCHAR(255), region VARCHAR(255), complaints INT); | What is the average number of citizens' complaints received by each city council in the 'Urban' region? | SELECT region, AVG(complaints) FROM Government.City WHERE region = 'Urban' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, case_type VARCHAR(20), billing_amount INT); INSERT INTO cases (id, case_type, billing_amount) VALUES (1, 'Civil', 5000), (2, 'Criminal', 7000), (3, 'Civil', 6000), (4, 'Civil', 15000), (5, 'Civil', 3000), (6, 'Criminal', 8000); | List the case types and the number of cases, excluding cases with a billing amount between $5000 and $10000. | SELECT case_type, COUNT(*) AS num_cases FROM cases WHERE billing_amount < 5000 OR billing_amount > 10000 GROUP BY case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.trips (trip_id SERIAL PRIMARY KEY, passenger_type VARCHAR(20), fare DECIMAL(5,2), route_type_id INTEGER, FOREIGN KEY (route_type_id) REFERENCES public.route_type(route_type_id)); INSERT INTO public.trips (passenger_type, fare, route_type_id) VALUES ('youth', 2.00, 5), ('adult', 3.00, 1), ('youth', 2.00, 2); | How many 'youth' passengers traveled on 'monorail' routes in August 2022? | SELECT COUNT(*) FROM public.trips WHERE passenger_type = 'youth' AND route_type_id = (SELECT route_type_id FROM public.route_type WHERE route_type = 'monorail') AND fare_date >= '2022-08-01' AND fare_date <= '2022-08-31' | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_number INT, coverage_amount INT); INSERT INTO policy VALUES (1, 50000); INSERT INTO policy VALUES (2, 75000); | Update the coverage amount to 100000 for policy number 1. | UPDATE policy SET coverage_amount = 100000 WHERE policy_number = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE maintenance_requests (request_id INT, equipment_type VARCHAR(255), date DATE); INSERT INTO maintenance_requests (request_id, equipment_type, date) VALUES (1, 'Tank', '2020-01-05'), (2, 'Helicopter', '2020-01-10'), (3, 'Tank', '2020-01-15'); | List the number of military equipment maintenance requests for each type of equipment in January 2020 | SELECT equipment_type, COUNT(*) FROM maintenance_requests WHERE date BETWEEN '2020-01-01' AND '2020-01-31' GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name TEXT, area FLOAT, region TEXT, timber_production FLOAT); INSERT INTO forests (id, name, area, region, timber_production) VALUES (1, 'Sundarbans', 10000.0, 'Asia-Pacific', 12345.6), (2, 'Great Barrier Reef', 34000.0, 'Asia-Pacific', 67890.1); | What is the total timber production of all forests in the 'Asia-Pacific' region? | SELECT SUM(timber_production) FROM forests WHERE region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Movies (movie_id INT, title TEXT, release_year INT, production_budget FLOAT); INSERT INTO Movies (movie_id, title, release_year, production_budget) VALUES (1, 'MovieA', 2005, 60.0), (2, 'MovieB', 2012, 40.0), (3, 'MovieC', 2018, 70.0), (4, 'MovieD', 2008, 55.0), (5, 'MovieE', 2010, 80.0), (6, 'MovieF', 2015, 45.0); | What is the total production budget for movies released in 2010? | SELECT SUM(production_budget) FROM Movies WHERE release_year = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, country VARCHAR(50)); CREATE TABLE workers (id INT, name VARCHAR(50), country VARCHAR(50), training VARCHAR(50)); INSERT INTO countries (id, country) VALUES (1, 'USA'), (2, 'China'), (3, 'Germany'), (4, 'Mexico'); INSERT INTO workers (id, name, country, training) VALUES (1, 'Tom', 'USA', 'Composting'), (2, 'Jin', 'China', 'Recycling'), (3, 'Heidi', 'Germany', 'Upcycling'), (4, 'Pedro', 'Mexico', 'Waste Reduction'), (5, 'Anna', 'USA', 'Recycling'), (6, 'Li', 'China', 'Composting'), (7, 'Karl', 'Germany', 'Waste Reduction'), (8, 'Carlos', 'Mexico', 'Upcycling'); | Display the number of workers in each country who have completed workforce development training in the circular economy, along with the names of those countries. | SELECT w.country, COUNT(*) as count FROM workers w INNER JOIN countries c ON w.country = c.country INNER JOIN circular_economy ce ON w.training = ce.training GROUP BY w.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Department (id INT, name VARCHAR(255), budget FLOAT); INSERT INTO Department (id, name, budget) VALUES (1, 'Education', 5000000), (2, 'Healthcare', 7000000), (3, 'Transportation', 8000000); | What is the total budget allocated for the 'Transportation' department in the year 2022? | SELECT SUM(budget) FROM Department WHERE name = 'Transportation' AND YEAR(datetime) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE diseases (name TEXT, location TEXT, prevalence INTEGER); INSERT INTO diseases (name, location, prevalence) VALUES ('Disease A', 'Rural India', 50), ('Disease B', 'Rural India', 40), ('Disease C', 'Rural India', 30), ('Disease D', 'Rural India', 20), ('Disease E', 'Rural India', 10), ('Disease A', 'Rural Pakistan', 40), ('Disease B', 'Rural Pakistan', 30), ('Disease C', 'Rural Pakistan', 20), ('Disease D', 'Rural Pakistan', 10); | List the top 5 diseases by prevalence in rural areas of India and Pakistan. | SELECT name, SUM(prevalence) AS total_prevalence FROM diseases WHERE location IN ('Rural India', 'Rural Pakistan') GROUP BY name ORDER BY total_prevalence DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (id INT, program VARCHAR(50), country VARCHAR(50), year INT, amount INT); INSERT INTO funding (id, program, country, year, amount) VALUES (1, 'Literary Arts Program 1', 'Canada', 2021, 15000), (2, 'Literary Arts Program 2', 'Canada', 2021, 20000); | What is the total amount of funding received by each literary arts program in Canada in 2021? | SELECT program, SUM(amount) AS total_amount FROM funding WHERE country = 'Canada' AND year = 2021 GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupportPrograms (ProgramID INT, ProgramName VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO SupportPrograms (ProgramID, ProgramName, Budget) VALUES (1, 'Art Therapy', 15000), (2, 'Braille Literacy', 18000), (3, 'Communication Assistance', 22000), (4, 'Dietary Accommodations', 14000), (5, 'Hearing Loops', 20000), (6, 'Inclusive Fitness', 25000), (7, 'Low Vision Services', 19000); | List all support programs with their respective budgets, in alphabetical order. | SELECT ProgramName, Budget FROM SupportPrograms ORDER BY ProgramName ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceX_Missions (Id INT, Name VARCHAR(50), FlightTime INT); INSERT INTO SpaceX_Missions (Id, Name, FlightTime) VALUES (1, 'Falcon1', 280), (2, 'Falcon9', 540), (3, 'FalconHeavy', 1000); | What is the maximum flight time of a SpaceX mission? | SELECT MAX(FlightTime) FROM SpaceX_Missions WHERE Name = 'Falcon9'; | gretelai_synthetic_text_to_sql |
CREATE TABLE power_plants (plant_id INT, state VARCHAR(255), power_source VARCHAR(255)); INSERT INTO power_plants (plant_id, state, power_source) VALUES (1, 'CA', 'Hydro'), (2, 'CA', 'Wind'), (3, 'CA', 'Solar'), (4, 'TX', 'Hydro'), (5, 'TX', 'Wind'), (6, 'TX', 'Solar'), (7, 'NY', 'Hydro'), (8, 'NY', 'Wind'), (9, 'NY', 'Solar'), (10, 'NY', 'Hydro'), (11, 'NY', 'Wind'), (12, 'NY', 'Solar'); | What is the number of solar power plants in the state of New York? | SELECT COUNT(*) FROM power_plants WHERE state = 'NY' AND power_source = 'Solar'; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (violation_id INT, violation_type VARCHAR(20), violation_date DATE); INSERT INTO violations (violation_id, violation_type, violation_date) VALUES (1, 'Speeding', '2022-01-15'), (2, 'Parking', '2022-01-17'), (3, 'Speeding', '2022-01-18'); | What is the most common type of violation, in the last month? | SELECT violation_type, COUNT(*) as num_occurrences FROM (SELECT violation_type, ROW_NUMBER() OVER (PARTITION BY violation_type ORDER BY violation_date DESC) as rn FROM violations WHERE violation_date >= DATEADD(month, -1, GETDATE())) x WHERE rn = 1 GROUP BY violation_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE archaeologists (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50)); | Update the age of archaeologist 'John Doe' in the 'archaeologists' table to 35. | UPDATE archaeologists SET age = 35 WHERE name = 'John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodSafetyRecords.HealthyMeals (mealName TEXT, calorieCount INTEGER); | Delete all records with a calorie count greater than 500 from the FoodSafetyRecords.HealthyMeals table. | DELETE FROM FoodSafetyRecords.HealthyMeals WHERE calorieCount > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments(id INT, mode VARCHAR(50), source VARCHAR(50), destination VARCHAR(50), shipping_cost FLOAT); INSERT INTO Shipments(id, mode, source, destination, shipping_cost) VALUES (1, 'rail', 'France', 'Germany', 500); | What is the average shipping cost for all shipments that were sent by rail from France to Germany? | SELECT AVG(Shipments.shipping_cost) FROM Shipments WHERE Shipments.mode = 'rail' AND Shipments.source = 'France' AND Shipments.destination = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DancePreservation (id INT, dance VARCHAR(50), continent VARCHAR(50), year INT); INSERT INTO DancePreservation (id, dance, continent, year) VALUES (1, 'Bharatanatyam', 'Asia', 2012), (2, 'Odissi', 'Asia', 2011), (3, 'Kathak', 'Asia', 2013), (4, 'Mohiniyattam', 'Asia', 2010), (5, 'Kuchipudi', 'Asia', 2011); | How many traditional dances from Asia have been documented and preserved since 2010? | SELECT COUNT(*) FROM DancePreservation WHERE continent = 'Asia' AND year >= 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO graduate_students (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Ravi Patel', 'India'), (4, 'Sana Khan', 'Pakistan'); CREATE TABLE research_grants (id INT, student_id INT, amount DECIMAL(10,2)); INSERT INTO research_grants (id, student_id, amount) VALUES (1, 1, 5000), (2, 3, 7000), (3, 2, 3000), (5, 3, 4000); | List all graduate students from India who have received research grants. | SELECT gs.* FROM graduate_students gs INNER JOIN research_grants rg ON gs.id = rg.student_id WHERE gs.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists energy_efficiency_programs (program_id integer, program_start_date date, program_location varchar(255)); INSERT INTO energy_efficiency_programs (program_id, program_start_date, program_location) VALUES (1, '2019-01-01', 'Brazil'), (2, '2019-06-01', 'Argentina'), (3, '2019-12-31', 'Colombia'); | How many energy efficiency programs were initiated in South America in 2019? | SELECT program_location, COUNT(*) as num_programs FROM energy_efficiency_programs WHERE program_start_date BETWEEN '2019-01-01' AND '2019-12-31' AND program_location LIKE 'South America%' GROUP BY program_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE young_trees (id INT, species VARCHAR(255), age INT); INSERT INTO young_trees (id, species, age) VALUES (1, 'Oak', 10), (2, 'Maple', 8), (3, 'Pine', 12); | What is the average age of all trees in the 'young_trees' table? | SELECT AVG(age) FROM young_trees; | gretelai_synthetic_text_to_sql |
CREATE TABLE cult_tours (tour_id INT, tour_name TEXT, country TEXT, added_date DATE); INSERT INTO cult_tours (tour_id, tour_name, country, added_date) VALUES (1, 'Eiffel Tower Tour', 'France', '2022-06-15'); INSERT INTO cult_tours (tour_id, tour_name, country, added_date) VALUES (2, 'Louvre Tour', 'France', '2022-07-20'); INSERT INTO cult_tours (tour_id, tour_name, country, added_date) VALUES (3, 'Mont Saint-Michel Tour', 'France', '2022-08-02'); | What is the total number of cultural heritage tours in France that were added to the database in the last month? | SELECT COUNT(*) FROM cult_tours WHERE country = 'France' AND added_date >= '2022-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT); CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, maintenance_date DATE, maintenance_type TEXT); | What is the total number of maintenance tasks performed on each vehicle, by vehicle type? | SELECT v.vehicle_type, v.vehicle_id, COUNT(m.maintenance_id) as total_maintenance_tasks FROM vehicles v INNER JOIN maintenance m ON v.vehicle_id = m.vehicle_id GROUP BY v.vehicle_type, v.vehicle_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE africa_renewable (id INT, source VARCHAR(50), capacity FLOAT); INSERT INTO africa_renewable (id, source, capacity) VALUES (1, 'Wind', 200.5), (2, 'Solar', 300.2), (3, 'Hydro', 150.1), (4, 'Geothermal', 100.3); | Which renewable energy sources have been installed in Africa with a capacity greater than 150 MW? | SELECT DISTINCT source FROM africa_renewable WHERE capacity > 150; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50)); CREATE TABLE Donations (DonationID int, Donation decimal(10,2)); CREATE TABLE ProgramDonations (ProgramID int, DonationID int, ProgramName varchar(50), Donation decimal(10,2)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); INSERT INTO Donations (DonationID, Donation) VALUES (1, 1000.00), (2, 1500.00), (3, 750.00); INSERT INTO ProgramDonations (ProgramID, DonationID, ProgramName, Donation) VALUES (1, 1, 'Education', 1000.00), (2, 2, 'Health', 1500.00), (3, 3, 'Environment', 750.00); | What is the total donation for each program in the 'ProgramDonations' table? | SELECT ProgramName, SUM(Donation) as TotalDonated FROM ProgramDonations GROUP BY ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (dish_name TEXT, category TEXT, price DECIMAL); INSERT INTO menu VALUES ('Cheese Quesadilla', 'Mexican', 6.99), ('Beef Burrito', 'Mexican', 8.99), ('Chicken Shawarma', 'Middle Eastern', 9.99); | Count the number of dishes in each category | SELECT category, COUNT(*) FROM menu GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Salary DECIMAL(10, 2), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Salary, Department) VALUES (1, 50000, 'HR'), (2, 55000, 'IT'), (3, 60000, 'IT'), (4, 45000, 'HR'), (5, 70000, 'HR'); | Get the total salary paid to employees in each department, ordered by the total salary. | SELECT Department, SUM(Salary) FROM Employees GROUP BY Department ORDER BY SUM(Salary) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE riders (rider_id INT, name VARCHAR(255)); INSERT INTO riders (rider_id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'), (3, 'Aaliyah Brown'); CREATE TABLE fares (fare_id INT, rider_id INT, fare_amount DECIMAL(5,2)); | Delete fare information for rider 'Aaliyah Brown' | DELETE FROM fares WHERE rider_id = (SELECT rider_id FROM riders WHERE name = 'Aaliyah Brown'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE DigitalAssets (id INT, company_id INT, value DECIMAL(10, 2), asset_date DATE); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Africa'), (2, 'CompanyB', 'Europe'), (3, 'CompanyC', 'Africa'); INSERT INTO DigitalAssets (id, company_id, value, asset_date) VALUES (1, 1, 100, '2022-01-01'), (2, 1, 200, '2022-01-02'), (3, 2, 50, '2022-01-01'), (4, 3, 250, '2022-01-01'); | What is the total number of digital assets owned by companies based in Africa as of 2022-01-01? | SELECT SUM(value) FROM DigitalAssets JOIN Companies ON DigitalAssets.company_id = Companies.id WHERE Companies.region = 'Africa' AND DigitalAssets.asset_date <= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(100), price DECIMAL(5,2), is_recycled BOOLEAN); INSERT INTO products (product_id, name, price, is_recycled) VALUES (1, 'Recycled Notebook', 9.99, true); INSERT INTO products (product_id, name, price, is_recycled) VALUES (2, 'Eco-Friendly Pen', 3.99, true); CREATE TABLE sales (sale_id INT, product_id INT, quantity INT); CREATE TABLE stores (store_id INT, location VARCHAR(50)); INSERT INTO stores (store_id, location) VALUES (1, 'Sydney Store'); INSERT INTO stores (store_id, location) VALUES (2, 'Melbourne Store'); CREATE TABLE store_sales (store_id INT, sale_id INT); | Show the total revenue generated from sales of recycled products in Australia. | SELECT SUM(p.price * s.quantity) FROM products p JOIN sales s ON p.product_id = s.product_id JOIN store_sales ss ON s.sale_id = ss.sale_id JOIN stores st ON ss.store_id = st.store_id WHERE p.is_recycled = true AND st.location = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE communities (community_id INT, country VARCHAR(255)); | How many indigenous communities are there in each country? | SELECT country, COUNT(*) FROM communities GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_reservations (reservation_id INT, hotel_id INT, guest_name TEXT, arrival_date DATE, departure_date DATE, num_guests INT, payment_amount FLOAT, is_cancelled BOOLEAN); | Add a new column 'payment_method' to table 'hotel_reservations' | ALTER TABLE hotel_reservations ADD COLUMN payment_method TEXT; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, investor_id INT, country TEXT, amount FLOAT); INSERT INTO investments (id, investor_id, country, amount) VALUES (1, 1, 'USA', 10000), (2, 1, 'Canada', 5000), (3, 2, 'Mexico', 8000), (4, 2, 'USA', 12000), (5, 3, 'Canada', 7000), (6, 3, 'USA', 15000); | Identify the top 3 countries with the highest total investment amounts. | SELECT country, SUM(amount) as total_investment FROM investments GROUP BY country ORDER BY total_investment DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT);CREATE TABLE ota_bookings (booking_id INT, hotel_id INT, ota_name TEXT, revenue FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country) VALUES (1, 'Hotel X', 'USA'); INSERT INTO ota_bookings (booking_id, hotel_id, ota_name, revenue) VALUES (1, 1, 'OTA1', 500), (2, 1, 'OTA2', 700), (3, 1, 'OTA3', 300); | What is the total revenue generated by each OTA (Online Travel Agency) for a given hotel? | SELECT ota.ota_name, SUM(ob.revenue) as total_revenue FROM hotels h INNER JOIN ota_bookings ob ON h.hotel_id = ob.hotel_id INNER JOIN (SELECT DISTINCT hotel_id, ota_name FROM ota_bookings) ota ON h.hotel_id = ota.hotel_id WHERE h.hotel_id = 1 GROUP BY ota.ota_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_ethics (tool VARCHAR(255), method VARCHAR(255), year INT, ethical_rating FLOAT); | Insert new record into ai_ethics table for 'Tegnbit' with 'Machine Learning' method in 2021 | INSERT INTO ai_ethics (tool, method, year, ethical_rating) VALUES ('Tegnbit', 'Machine Learning', 2021, NULL); | gretelai_synthetic_text_to_sql |
CREATE TABLE building_energy (country TEXT, building_type TEXT, energy_efficiency NUMERIC); INSERT INTO building_energy (country, building_type, energy_efficiency) VALUES ('France', 'Residential', 80), ('France', 'Commercial', 90), ('Germany', 'Residential', 85), ('Germany', 'Commercial', 95); | What are the energy efficiency stats for buildings in France and Germany? | SELECT country, building_type, energy_efficiency FROM building_energy WHERE country IN ('France', 'Germany'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, category VARCHAR(20), billing_amount DECIMAL(10, 2), opened_date DATE); | Find the total billing amount for cases in the labor law category that were opened after 2020-01-01. | SELECT SUM(billing_amount) FROM cases WHERE category = 'labor' AND opened_date >= '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT PRIMARY KEY, name VARCHAR(255), genre VARCHAR(255)); CREATE TABLE albums (id INT PRIMARY KEY, title VARCHAR(255), release_year INT, artist_id INT, FOREIGN KEY (artist_id) REFERENCES artists(id)); CREATE TABLE tracks (id INT PRIMARY KEY, title VARCHAR(255), duration FLOAT, album_id INT, FOREIGN KEY (album_id) REFERENCES albums(id)); | Insert new artist with multiple albums and tracks | INSERT INTO artists (id, name, genre) VALUES (1, 'Natasha Bedingfield', 'Pop'); INSERT INTO albums (id, title, release_year, artist_id) VALUES (1, 'Unwritten', 2004, 1), (2, 'Pocketful of Sunshine', 2008, 1); INSERT INTO tracks (id, title, duration, album_id) VALUES (1, 'These Words', 3.21, 1), (2, 'Unwritten', 4.18, 1), (3, 'Soulmate', 3.29, 2), (4, 'Pocketful of Sunshine', 3.12, 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_data (fan_id INT, age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(20), country VARCHAR(50)); INSERT INTO fan_data (fan_id, age, gender, city, state, country) VALUES (1, 22, 'Male', 'New York', 'NY', 'USA'); INSERT INTO fan_data (fan_id, age, gender, city, state, country) VALUES (2, 28, 'Female', 'Los Angeles', 'CA', 'USA'); | Create a view 'top_cities_v' that shows the top 3 cities with the most fans in 'fan_data' table | CREATE VIEW top_cities_v AS SELECT city, COUNT(*) AS fan_count FROM fan_data GROUP BY city ORDER BY fan_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_bases (id INT, country VARCHAR(50), base_name VARCHAR(50), base_type VARCHAR(50)); INSERT INTO military_bases (id, country, base_name, base_type) VALUES (1, 'USA', 'Fort Bragg', 'Army'), (2, 'USA', 'Pearl Harbor', 'Navy'), (3, 'Russia', 'Moscow Garrison', 'Army'); | What is the total number of military bases and their types for each country? | SELECT COUNT(*) as total_bases, base_type FROM military_bases GROUP BY base_type, country; | gretelai_synthetic_text_to_sql |
CREATE TABLE vr_users (user_id INT, headset_id INT); INSERT INTO vr_users (user_id, headset_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 1), (6, 2), (6, 3); | Which virtual reality headsets have the highest adoption rate among users in the 'vr_users' table of the 'virtual_reality' database? | SELECT headset_id, COUNT(DISTINCT user_id) as adoption_count FROM vr_users GROUP BY headset_id ORDER BY adoption_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_efforts (id INT, species_id INT, project_status VARCHAR(20)); | Delete all records from the conservation_efforts table where the project status is 'completed' | DELETE FROM conservation_efforts WHERE project_status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20), listing_price INT, co_owned BOOLEAN); INSERT INTO properties (id, city, listing_price, co_owned) VALUES (1, 'Denver', 550000, true); INSERT INTO properties (id, city, listing_price, co_owned) VALUES (2, 'Denver', 450000, false); | What is the minimum listing price for co-owned properties in Denver? | SELECT MIN(listing_price) FROM properties WHERE city = 'Denver' AND co_owned = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE max_practitioners (id INT, country VARCHAR(50), art VARCHAR(50), practitioners INT); INSERT INTO max_practitioners (id, country, art, practitioners) VALUES (1, 'Canada', 'Inuit carving', 700); INSERT INTO max_practitioners (id, country, art, practitioners) VALUES (2, 'New Zealand', 'Māori tattooing', 300); | What is the maximum number of practitioners for a traditional art in each country? | SELECT country, MAX(practitioners) FROM max_practitioners GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Library (Name VARCHAR(255), Region VARCHAR(255), Type VARCHAR(255)); INSERT INTO Library (Name, Region, Type) VALUES ('Northeast Public Library', 'Northeast', 'Public'), ('Southeast Public Library', 'Southeast', 'Public'), ('Southwest Public Library', 'Southwest', 'Public'), ('Northwest Public Library', 'Northwest', 'Public'); | How many public libraries are there in the Northeast region? | SELECT COUNT(*) FROM Library WHERE Region = 'Northeast' AND Type = 'Public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_city_features (city VARCHAR(50), feature VARCHAR(50)); INSERT INTO smart_city_features (city, feature) VALUES ('CityA', 'Smart Lighting'), ('CityB', 'Smart Waste Management'), ('CityC', 'Smart Transportation'); | Which cities have 'Smart Lighting' or 'Smart Transportation' features? | SELECT city FROM smart_city_features WHERE feature IN ('Smart Lighting', 'Smart Transportation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (department_id INT, department VARCHAR(50)); INSERT INTO departments VALUES (1, 'Computer Science'); INSERT INTO departments VALUES (2, 'Engineering'); INSERT INTO departments VALUES (3, 'Mathematics'); CREATE TABLE faculty_departments (faculty_id INT, department_id INT); INSERT INTO faculty_departments VALUES (1, 1); INSERT INTO faculty_departments VALUES (2, 2); INSERT INTO faculty_departments VALUES (3, 2); INSERT INTO faculty_departments VALUES (4, 3); CREATE TABLE grants_faculty (grant_id INT, faculty_id INT, amount DECIMAL(10, 2)); INSERT INTO grants_faculty VALUES (1, 1, 50000); INSERT INTO grants_faculty VALUES (2, 2, 75000); INSERT INTO grants_faculty VALUES (3, 2, 60000); INSERT INTO grants_faculty VALUES (4, 1, 65000); | What is the average grant amount awarded to faculty members in the Engineering department? | SELECT AVG(g.amount) FROM grants_faculty g INNER JOIN faculty_departments fd ON g.faculty_id = fd.faculty_id INNER JOIN departments d ON fd.department_id = d.department_id WHERE d.department = 'Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_stories (story_id INT, title VARCHAR(100), description TEXT, reporter_id INT, publish_date DATE); | List all news stories from the 'news_stories' table that have a word length greater than 50 and were published after 2015. | SELECT title FROM news_stories WHERE LENGTH(title) > 50 AND publish_date > '2015-01-01'; | 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.