context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE industries (industry_id INT, industry VARCHAR(20));CREATE TABLE employees (employee_id INT, industry_id INT); | What is the total number of employees in the 'sustainable textiles' industry? | SELECT COUNT(employees.employee_id) FROM employees INNER JOIN industries ON employees.industry_id = industries.industry_id WHERE industries.industry = 'sustainable textiles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title VARCHAR(255), genre VARCHAR(50), release_year INT, length FLOAT); INSERT INTO songs (song_id, title, genre, release_year, length) VALUES (1, 'Song1', 'Pop', 2005, 180.5), (2, 'Song2', 'Rock', 2004, 210.3), (3, 'Song3', 'Jazz', 2005, 250.7); | What is the maximum length (in seconds) of any song released in 2005? | SELECT MAX(length) FROM songs WHERE release_year = 2005; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(255), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 50.3), (2, 'Habitat2', 32.7), (3, 'Habitat3', 86.9); | Insert a new record into the 'wildlife_habitat' table for a habitat named 'Habitat4' with an area of 45.6 square kilometers. | INSERT INTO wildlife_habitat (name, area) VALUES ('Habitat4', 45.6); | gretelai_synthetic_text_to_sql |
CREATE TABLE Port_Oakland_Crane_Stats (crane_name TEXT, containers_handled INTEGER, total_weight INTEGER); INSERT INTO Port_Oakland_Crane_Stats (crane_name, containers_handled, total_weight) VALUES ('CraneA', 60, 1200), ('CraneB', 45, 900), ('CraneC', 75, 1500), ('CraneD', 30, 600); | What is the average weight (in metric tons) of containers handled by each crane in the Port of Oakland in February 2021, grouped by crane name, that handled more than 50 containers? | SELECT crane_name, AVG(total_weight/1000.0) as avg_weight FROM Port_Oakland_Crane_Stats WHERE containers_handled > 50 GROUP BY crane_name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'India', 4000000), (2, 'StartupB', 'India', 5000000), (3, 'StartupC', 'Canada'... | Update the funding for a specific biotech startup | UPDATE biotech.startups SET funding = 6000000 WHERE name = 'StartupA'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA satellite_deployment; CREATE TABLE satellite_deployment.launches (launch_id INT, launch_year INT, mass INT); INSERT INTO satellite_deployment.launches VALUES (1, 2000, 500); INSERT INTO satellite_deployment.launches VALUES (2, 2001, 600); INSERT INTO satellite_deployment.launches VALUES (3, 2002, 400); | What is the number of satellites launched per year and the total mass of these satellites? | SELECT launch_year, COUNT(*) OVER (PARTITION BY launch_year) as num_satellites, SUM(mass) OVER (PARTITION BY launch_year) as total_mass FROM satellite_deployment.launches; | gretelai_synthetic_text_to_sql |
CREATE TABLE region_data (incident_id INT, region VARCHAR(50)); INSERT INTO region_data (incident_id, region) VALUES (1, 'RegionA'), (2, 'RegionB'), (3, 'RegionA'); | What is the total number of AI safety incidents for each region, ranked by the highest total? | SELECT region, COUNT(*) as total_incidents FROM region_data GROUP BY region ORDER BY total_incidents DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, founding_year INT, founder_gender TEXT); INSERT INTO startups (id, name, founding_year, founder_gender) VALUES (1, 'Acme Inc', 2010, 'Female'); INSERT INTO startups (id, name, founding_year, founder_gender) VALUES (2, 'Beta Corp', 2015, 'Male'); INSERT INTO startups (id, name, f... | List all the startups founded by non-binary individuals in the year 2017 | SELECT * FROM startups WHERE founder_gender = 'Non-binary' AND founding_year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMission (Id INT, Name VARCHAR(100), LaunchDate DATETIME, LandingDate DATETIME, Duration INT, AgencyId INT); INSERT INTO SpaceMission (Id, Name, LaunchDate, LandingDate, Duration, AgencyId) VALUES (7, 'Apollo 17', '1972-12-07', '1972-12-19', 301, 1); | What is the maximum duration of any space mission? | SELECT MAX(Duration) FROM SpaceMission; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_readings (sensor_id INT, sensor_status VARCHAR(10), reading INT, timestamp DATETIME); INSERT INTO sensor_readings (sensor_id, sensor_status, reading, timestamp) VALUES (1, 'working', 550, '2022-06-01 10:00:00'), (2, 'malfunction', 400, '2022-06-03 15:30:00'); | List all IoT sensor malfunctions in the greenhouse in the last week. | SELECT * FROM sensor_readings WHERE sensor_status = 'malfunction' AND timestamp >= DATEADD(day, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE education (id INT, topic VARCHAR(50), attendees INT); | Delete all records from the education table where the topic is not 'Conservation' | DELETE FROM education WHERE topic != 'Conservation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT); INSERT INTO production (id, country, element, quantity) VALUES (1, 'China', 'Yttrium', 3000), (2, 'USA', 'Yttrium', 2000), (3, 'Australia', 'Yttrium', 1000); CREATE TABLE world_production (element VARCHAR(255), quantity INT); IN... | Calculate the percentage of world's Yttrium production for each country. | SELECT country, (quantity * 100.0 / world_quantity) as pct FROM production, world_production WHERE element = 'Yttrium' AND production.element = world_production.element GROUP BY country, world_quantity; | gretelai_synthetic_text_to_sql |
CREATE TABLE salesperson (id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO salesperson (id, name, city) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'Los Angeles'); CREATE TABLE tickets (id INT, salesperson_id INT, quantity INT, city VARCHAR(50)); INSERT INTO tickets (id, salesperson_id, quantity, city... | Find the number of tickets sold by each salesperson, grouped by city. | SELECT s.city, s.name, SUM(t.quantity) as total_quantity FROM salesperson s JOIN tickets t ON s.id = t.salesperson_id GROUP BY s.city, s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, FirstName varchar(50), LastName varchar(50), Country varchar(50)); CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount decimal(10,2)); | Insert a new donor from Kenya who has donated $200 to the 'Effective Altruism' organization. | INSERT INTO Donors (DonorID, FirstName, LastName, Country) VALUES (5, 'Njamba', 'Warioba', 'Kenya'); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (5, 5, 200.00); INSERT INTO DonationRecipients (DonationID, OrganizationID) VALUES (5, 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE exploration_projects (id INT, location VARCHAR(50), budget FLOAT); INSERT INTO exploration_projects (id, location, budget) VALUES (1, 'Gulf of Mexico', 1500000000); | List all exploration projects in the Gulf of Mexico with budget > $1B | SELECT * FROM exploration_projects WHERE location = 'Gulf of Mexico' AND budget > 1000000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments(dept_id INT, dept_name VARCHAR(50)); INSERT INTO departments VALUES (1, 'HR'), (2, 'IT'), (3, 'Sales'); CREATE TABLE employees(emp_id INT, hire_date DATE, dept_id INT); INSERT INTO employees VALUES (1, '2020-01-01', 1), (2, '2019-05-01', 1), (3, '2020-07-01', 2); | Find the number of employees hired in 2020, grouped by department | SELECT e.dept_id, COUNT(e.emp_id) as num_hires FROM employees e JOIN departments d ON e.dept_id = d.dept_id WHERE YEAR(e.hire_date) = 2020 GROUP BY e.dept_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE TransportationData (id INT, trip_type VARCHAR(50), trip_cost DECIMAL(5,2)); INSERT INTO TransportationData (id, trip_type, trip_cost) VALUES (1, 'Bus', 3.50), (2, 'Subway', 5.25), (3, 'Bus', 4.00), (4, 'Train', 7.00); | How many public transportation trips were taken in the "TransportationData" table, for each type of transportation, where the trip cost was more than $5? | SELECT trip_type, COUNT(*) as num_trips FROM TransportationData WHERE trip_cost > 5 GROUP BY trip_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_budgets (city varchar(50), year int, service varchar(50), budget int); INSERT INTO city_budgets (city, year, service, budget) VALUES ('New York City', 2022, 'Healthcare', 15000000); | What is the total budget allocated for healthcare services in New York City in 2022? | SELECT SUM(budget) FROM city_budgets WHERE city = 'New York City' AND service = 'Healthcare' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_practices (record_id INT, country VARCHAR(50), practice VARCHAR(50)); | Delete all records related to unethical manufacturing practices in the manufacturing_practices table. | DELETE FROM manufacturing_practices WHERE practice = 'Animal Cruelty'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (id INT, name VARCHAR(255), region VARCHAR(255), project_type VARCHAR(255)); | How many renewable energy projects are in the Americas? | SELECT COUNT(*) FROM renewable_energy WHERE region IN ('North America', 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Mascaras (product_id INT, product_name VARCHAR(255), sales_qty INT, sale_date DATE); INSERT INTO Mascaras (product_id, product_name, sales_qty, sale_date) VALUES (1, 'Mascara 1', 50, '2022-01-01'), (2, 'Mascara 2', 40, '2022-01-05'), (3, 'Mascara 3', 60, '2022-01-10'); | How many units of the top-selling mascara were sold in the first quarter? | SELECT SUM(sales_qty) FROM Mascaras WHERE product_name = (SELECT product_name FROM Mascaras ORDER BY sales_qty DESC LIMIT 1) AND sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE public_works (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE); | Find the number of projects in the 'public_works' table that were completed in each month of the year, for the year 2019. | SELECT DATEPART(year, completion_date) as year, DATEPART(month, completion_date) as month, COUNT(*) as num_projects FROM public_works WHERE completion_date >= '2019-01-01' AND completion_date < '2020-01-01' GROUP BY DATEPART(year, completion_date), DATEPART(month, completion_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT PRIMARY KEY, region VARCHAR(20), year INT, equipment_name VARCHAR(30), quantity INT, value FLOAT); INSERT INTO military_sales (id, region, year, equipment_name, quantity, value) VALUES (1, 'Asia', 2025, 'Fighter Jet', 10, 6000000), (2, 'Asia', 2025, 'Tank', 20, 13000000), (3, 'Asia',... | Update the quantity of 'Tank' sales records in 'Asia' to 22 for the year '2025' | UPDATE military_sales SET quantity = 22 WHERE region = 'Asia' AND equipment_name = 'Tank' AND year = 2025; | 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); | Select the total quantity of fish sold by the vendor 'Seafood Haven' from the 'sales' table. | SELECT SUM(quantity) FROM sales WHERE vendor = 'Seafood Haven'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT); CREATE TABLE extraction (id INT, company_id INT, date DATE, quantity INT); | What is the average amount of resources extracted daily by each company, for the past year? | SELECT company.name, AVG(extraction.quantity/365) as avg_daily_quantity FROM company INNER JOIN extraction ON company.id = extraction.company_id WHERE extraction.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY company.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE FreshwaterFish (id INT, species VARCHAR(255), weight FLOAT, length FLOAT); INSERT INTO FreshwaterFish (id, species, weight, length) VALUES (1, 'Tilapia', 1.2, 20.5); INSERT INTO FreshwaterFish (id, species, weight, length) VALUES (2, 'Catfish', 2.5, 30.6); | Calculate the average weight of fish in the 'FreshwaterFish' table | SELECT AVG(weight) FROM FreshwaterFish; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50)); INSERT INTO movies (title, genre) VALUES ('Movie1', 'Action'), ('Movie2', 'Drama'), ('Movie3', 'Comedy'), ('Movie4', 'Action'), ('Movie5', 'Drama'), ('Movie6', 'Sci-Fi'); | What is the distribution of genres in the database? | SELECT genre, COUNT(*) as genre_count FROM movies GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE captain(captain_id INT, name VARCHAR(255), years_of_experience INT, nationality VARCHAR(255)); CREATE TABLE captain_vessel(captain_id INT, vessel_id INT); CREATE TABLE vessel(vessel_id INT, name VARCHAR(255), flag VARCHAR(255)); INSERT INTO captain VALUES (1, 'Rajesh Patel', 15, 'India'), (2, 'Aisha Khan',... | Find the captains from 'India', their respective nationalities, and the number of vessels they commanded | SELECT c.name AS captain_name, c.nationality, COUNT(cv.vessel_id) AS number_of_vessels FROM captain c JOIN captain_vessel cv ON c.captain_id = cv.captain_id JOIN vessel v ON cv.vessel_id = v.vessel_id WHERE c.nationality = 'India' GROUP BY c.captain_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, content TEXT); | Delete all posts with content containing 'free trial' | DELETE FROM posts WHERE content LIKE '%free trial%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID INT, SupplierName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, Recycled BOOLEAN, SupplierID INT); INSERT INTO Suppliers (SupplierID, SupplierName, Country) VALUES (1, 'SupplierA', 'USA'), (2, 'SupplierB', 'Canada'), (3, 'SupplierC', 'Franc... | What is the average price of recycled products sold by suppliers in Japan? | SELECT AVG(Price) FROM Products JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Recycled = true AND Country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_details (member_id INT, gender VARCHAR(10), uses_heart_rate_monitor INT, age INT); INSERT INTO member_details (member_id, gender, uses_heart_rate_monitor, age) VALUES (1, 'Male', 1, 30), (2, 'Female', 0, 40), (3, 'Male', 1, 25), (4, 'Female', 0, 35), (5, 'Male', 1, 32); | What is the average age of male members who use a heart rate monitor? | SELECT AVG(age) FROM member_details WHERE gender = 'Male' AND uses_heart_rate_monitor = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE savings (account_number INT, customer_name VARCHAR(50), balance DECIMAL(10, 2), is_shariah_compliant BOOLEAN); INSERT INTO savings (account_number, customer_name, balance, is_shariah_compliant) VALUES (1, 'Ahmed', 5000, true), (2, 'Sara', 7000, false), (3, 'Mohammed', 800, true); | What is the balance for the savings account with the lowest balance? | SELECT MIN(balance) FROM savings; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm (id INT, name VARCHAR(50), size FLOAT, region VARCHAR(50), PRIMARY KEY(id)); INSERT INTO farm (id, name, size, region) VALUES (1, 'Farm A', 50.3, 'Asia'); INSERT INTO farm (id, name, size, region) VALUES (2, 'Farm B', 75.8, 'Africa'); INSERT INTO farm (id, name, size, region) VALUES (3, 'Farm C', 35.1... | What's the maximum temperature for farms located in the Asia region? | SELECT f.region, MAX(t.temperature) FROM farm f INNER JOIN temperature t ON f.id = t.farm_id WHERE f.region = 'Asia' GROUP BY f.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE exoplanets (id INT, name VARCHAR(50), discovery_date DATE, discovery_method VARCHAR(50), host_star VARCHAR(50), habitable BOOLEAN); | List the stars hosting at least 3 habitable exoplanets. | SELECT host_star FROM exoplanets WHERE habitable = TRUE GROUP BY host_star HAVING COUNT(*) >= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE fare_collection (id INT PRIMARY KEY, transaction_time TIMESTAMP, route_id INT, payment_type VARCHAR(20)); | List fare collection transactions from the month of March 2022 with payment type 'Credit Card' | SELECT transaction_time, route_id FROM fare_collection WHERE transaction_time >= '2022-03-01 00:00:00' AND transaction_time < '2022-04-01 00:00:00' AND payment_type = 'Credit Card'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, garment_id INT, garment_type VARCHAR(50), sale_date DATE, quantity INT); | How many garments of each type were sold in the 'sales' table during the busiest month in the past year? | SELECT garment_type, MAX(sale_quantity) AS busiest_month_quantity FROM ( SELECT garment_type, MONTH(sale_date) AS sale_month, SUM(quantity) AS sale_quantity FROM sales WHERE sale_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY garment_type, sale_month ) AS sales_per_month GROUP BY garment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media(user_id INT, user_name VARCHAR(50), region VARCHAR(50), post_date DATE, likes INT); | What is the daily number of posts in the 'social_media' table, for users in 'Europe', for the last 30 days? | SELECT post_date, COUNT(*) as daily_posts FROM social_media WHERE region = 'Europe' AND post_date >= CURDATE() - INTERVAL 30 DAY GROUP BY post_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE credit_cards (id INT, card_type VARCHAR(255), monthly_balance DECIMAL(10,2)); INSERT INTO credit_cards (id, card_type, monthly_balance) VALUES (1, 'Socially Responsible', 500.00), (2, 'Traditional', 700.00); | What is the average monthly balance for socially responsible credit cards? | SELECT AVG(monthly_balance) FROM credit_cards WHERE card_type = 'Socially Responsible'; | gretelai_synthetic_text_to_sql |
CREATE TABLE yearly_funding (id INT, year INT, total_funding INT); INSERT INTO yearly_funding (id, year, total_funding) VALUES (1, 2010, 5000000), (2, 2011, 6000000), (3, 2012, 8000000), (4, 2013, 9000000), (5, 2014, 10000000), (6, 2015, 3000000), (7, 2016, 4000000), (8, 2017, 5000000), (9, 2018, 7000000), (10, 2019, 8... | Determine the average funding per startup per year | SELECT year, AVG(total_funding) as avg_funding FROM yearly_funding, startups_per_year WHERE yearly_funding.year = startups_per_year.year GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE resilience_standards (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE); | List the projects in the 'resilience_standards' table that have a completion date within the last 90 days, ordered by their completion date. | SELECT * FROM resilience_standards WHERE completion_date >= DATEADD(day, -90, GETDATE()) ORDER BY completion_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE, payment_method VARCHAR(50)); | What is the daily average transaction amount for each payment method in Q1 2022? | SELECT AVG(transaction_amount), payment_method FROM transactions WHERE transactions.transaction_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY payment_method; | gretelai_synthetic_text_to_sql |
CREATE TABLE AdoptionStatistics(Id INT, Vehicle VARCHAR(50), AdoptionYear INT, Country VARCHAR(50), NumberOfVehicles INT); INSERT INTO AdoptionStatistics(Id, Vehicle, AdoptionYear, Country, NumberOfVehicles) VALUES (1, 'Tesla Model 3', 2022, 'India', 100); INSERT INTO AdoptionStatistics(Id, Vehicle, AdoptionYear, Count... | What is the total number of electric vehicles adopted in India and China by 2025? | SELECT SUM(NumberOfVehicles) FROM AdoptionStatistics WHERE AdoptionYear <= 2025 AND (Country = 'India' OR Country = 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE emissions (country VARCHAR(50), year INT, co2_emission INT);INSERT INTO emissions (country, year, co2_emission) VALUES ('USA', 2020, 5134044000); INSERT INTO emissions (country, year, co2_emission) VALUES ('China', 2020, 10086480000); INSERT INTO emissions (country, year, co2_emission) VALUES ('India', 202... | What is the total CO2 emission for each country in the year 2020? | SELECT country, SUM(co2_emission) as total_emission FROM emissions WHERE year = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (id INT, language VARCHAR(50), speakers INT); INSERT INTO languages (id, language, speakers) VALUES (1, 'English', 379000000), (2, 'Spanish', 460000000), (3, 'French', 76000000); | Which languages have more than 500 speakers? | SELECT language FROM languages WHERE speakers > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, date DATE, item VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO sales (id, date, item, revenue) VALUES (1, '2021-01-01', 'Postcard', 1.50), (2, '2021-02-01', 'Mug', 10.00); | What is the total revenue for museum shop sales in the year 2021? | SELECT SUM(revenue) FROM sales WHERE YEAR(date) = 2021 AND item LIKE '%museum%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name VARCHAR(50), region VARCHAR(50), hectares DECIMAL(5,2), carbon_sequestration_rate DECIMAL(5,2)); INSERT INTO forests (id, name, region, hectares, carbon_sequestration_rate) VALUES (1, 'Forest 1', 'Tropical', 1500.00, 2.50), (2, 'Forest 2', 'Temperate', 2000.00, 1.80), (3, 'Forest 3', ... | What is the total carbon sequestration for each forest and its respective region? | SELECT f.name, f.region, SUM(f.hectares * f.carbon_sequestration_rate) as total_carbon_sequestration FROM forests f GROUP BY f.name, f.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_platform (id INT, artist VARCHAR(100), country VARCHAR(50), streams INT); | How many unique countries are represented in the music streaming platform? | SELECT COUNT(DISTINCT country) as num_countries FROM music_platform; | gretelai_synthetic_text_to_sql |
CREATE TABLE police_officers (id INT, district INT, city VARCHAR(255), role VARCHAR(255)); INSERT INTO police_officers (id, district, city, role) VALUES (1, 1, 'Chicago', 'Police Officer'), (2, 2, 'Chicago', 'Police Officer'), (3, 1, 'Chicago', 'Sergeant'); | How many police officers are there in total in Chicago? | SELECT COUNT(id) as total_officers FROM police_officers WHERE city = 'Chicago' AND role = 'Police Officer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_id INT, city_name VARCHAR(255), state VARCHAR(255)); CREATE TABLE charging_stations (station_id INT, station_name VARCHAR(255), city_id INT, station_type VARCHAR(255)); | How many electric vehicle charging stations are there in each city in the state of California? | SELECT c.city_name, COUNT(cs.station_id) FROM cities c INNER JOIN charging_stations cs ON c.city_id = cs.city_id WHERE cs.station_type = 'Electric' GROUP BY c.city_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE shuttle_distances (id INT, shuttle_id INT, shuttle_type VARCHAR(20), distance FLOAT, date DATE, city VARCHAR(20)); INSERT INTO shuttle_distances (id, shuttle_id, shuttle_type, distance, date, city) VALUES (1, 101, 'Autonomous', 120.5, '2022-05-01', 'Tokyo'); INSERT INTO shuttle_distances (id, shuttle_id, s... | What is the total distance traveled by autonomous shuttles in Tokyo on a specific date? | SELECT SUM(distance) as total_distance FROM shuttle_distances WHERE shuttle_type = 'Autonomous' AND city = 'Tokyo' AND date = '2022-05-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2), transaction_date DATE, country VARCHAR(50)); INSERT INTO transactions (transaction_id, client_id, amount, transaction_date, country) VALUES (1, 1, 50.00, '2022-04-01', 'USA'), (2, 1, 100.00, '2022-04-15', 'Canada'), (3, 2, 75.00, '2022... | How many transactions were made in each country for the month of April? | SELECT DATE_FORMAT(transaction_date, '%Y-%m') AS month, country, COUNT(*) FROM transactions GROUP BY month, country; | gretelai_synthetic_text_to_sql |
CREATE TABLE nfl_scores (team TEXT, total_points INT); INSERT INTO nfl_scores (team, total_points) VALUES ('Patriots', 523), ('Eagles', 518), ('Chiefs', 516); | Which team had the highest total points in the 2022 NFL season? | SELECT team, SUM(total_points) as total_points FROM nfl_scores GROUP BY team ORDER BY total_points DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO dispensaries (id, name, city, state) VALUES (1, 'Dispensary A', 'Seattle', 'WA'); CREATE TABLE sales (id INT, dispensary_id INT, amount DECIMAL(10, 2), tax_rate DECIMAL(10, 2)); | Identify dispensaries with the highest sales tax in Washington, limited to top 5. | SELECT d.name, SUM(s.amount * s.tax_rate) as total_tax FROM dispensaries d INNER JOIN sales s ON d.id = s.dispensary_id WHERE d.state = 'WA' GROUP BY d.name ORDER BY total_tax DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_trenches (id INT, name TEXT, depth FLOAT, location TEXT); INSERT INTO marine_trenches (id, name, depth, location) VALUES (1, 'Java Trench', 7450.0, 'Indian Ocean'), (2, 'Sunda Trench', 7192.0, 'Indian Ocean'); | What is the maximum depth of all marine trenches in the Indian Ocean? | SELECT MAX(depth) FROM marine_trenches WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unfunded_startups(id INT, name TEXT, industry TEXT); INSERT INTO unfunded_startups (id, name, industry) VALUES (1, 'FintechLady', 'FinTech'); | Which startups have not yet received any funding and were founded by women in the fintech sector? | SELECT name FROM unfunded_startups JOIN startups ON unfunded_startups.id = startups.id JOIN founders ON startups.id = founders.startup_id WHERE industry = 'FinTech' AND founder_gender = 'Female' AND startups.id NOT IN (SELECT startup_id FROM funding_rounds); | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (Region VARCHAR(255), Country VARCHAR(255), Budget INT); INSERT INTO LanguagePreservation (Region, Country, Budget) VALUES ('North America', 'USA', 500000), ('North America', 'Canada', 400000), ('South America', 'Brazil', 300000), ('Europe', 'Spain', 800000), ('Asia', 'Japan', 900000),... | What is the total budget for language preservation programs in each continent? | SELECT Region, SUM(Budget) as Total_Budget FROM LanguagePreservation GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(50)); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Gender) VALUES (1, 'John Doe', 'IT', 'Male'), (2, 'Jane Smith', 'HR', 'Female'), (3, 'Alice Johnson', 'IT', 'Female'), (4, 'Bob Brown', 'Finance', '... | What is the percentage of employees who are female, by department? | SELECT Department, Gender, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY Department) AS Percentage FROM Employees GROUP BY Department, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (id INT, country VARCHAR(50), region VARCHAR(50), capacity_cubic_meters INT); INSERT INTO LandfillCapacity (id, country, region, capacity_cubic_meters) VALUES (1, 'Germany', 'EMEA', 120000), (2, 'France', 'EMEA', 150000), (3, 'Spain', 'EMEA', 180000); | What is the average landfill capacity in the EMEA region? | SELECT AVG(capacity_cubic_meters) FROM LandfillCapacity WHERE region = 'EMEA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Languages (id INT PRIMARY KEY, language VARCHAR(255), script VARCHAR(255), speakers INT, region VARCHAR(255)); INSERT INTO Languages (id, language, script, speakers, region) VALUES (3, 'Nahuatl', 'Latin', 1500000, 'Mesoamerica'); | Which scripts are used by languages in Mesoamerica with over 500,000 speakers? | SELECT l.language, l.script, l.speakers FROM Languages l WHERE l.region = 'Mesoamerica' AND l.speakers > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50)); INSERT INTO Countries (CountryID, CountryName) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); CREATE TABLE VirtualTours (TourID INT, CountryID INT, Revenue DECIMAL(10,2)); INSERT INTO VirtualTours (TourID, CountryID, Revenue) VALUES (1, 1, 5000.00), (2,... | Which countries had the highest revenue from virtual tours in Q1 2022? | SELECT C.CountryName, SUM(VT.Revenue) as TotalRevenue FROM Countries C INNER JOIN VirtualTours VT ON C.CountryID = VT.CountryID WHERE QUARTER(VT.TourDate) = 1 AND YEAR(VT.TourDate) = 2022 GROUP BY C.CountryName ORDER BY TotalRevenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndigenousCommunity (ID INT, Name TEXT, Country TEXT, Population INT); INSERT INTO IndigenousCommunity (ID, Name, Country, Population) VALUES (1, 'Community1', 'Canada', 200); INSERT INTO IndigenousCommunity (ID, Name, Country, Population) VALUES (2, 'Community2', 'Canada', 300); INSERT INTO IndigenousComm... | What is the total population of indigenous communities in each Arctic country? | SELECT Country, SUM(Population) as Total_Population FROM IndigenousCommunity GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), IngredientID INT); INSERT INTO Products (ProductID, ProductName, IngredientID) VALUES (1, 'Lip Balm', 101), (2, 'Face Cream', 102), (3, 'Moisturizer', 103); CREATE TABLE Ingredients (IngredientID INT, IngredientName VARCHAR(50), SourceCountry VARCHAR(50)); ... | Update the ingredient source of a specific cosmetic product due to recent safety concerns. | UPDATE Products SET IngredientID = 104 WHERE ProductName = 'Lip Balm'; UPDATE Ingredients SET SourceCountry = 'South Africa' WHERE IngredientID = 104; INSERT INTO Ingredients (IngredientID, IngredientName, SourceCountry) VALUES (104, 'Mango Butter', 'South Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, brand_id INT, quantity INT); INSERT INTO transactions (transaction_id, transaction_date, brand_id, quantity) VALUES (1, '2022-01-05', 1, 10), (2, '2022-02-10', 1, 20), (3, '2022-03-25', 2, 30), (4, '2022-04-15', 3, 40), (5, '2022-05-08', 3, 50), (6, ... | List all transactions that have been rolled back in the system, showing the transaction ID, date, and quantity of garments sold. | SELECT transaction_id, transaction_date, quantity FROM transactions WHERE transaction_id IN (SELECT transaction_id FROM transaction_log WHERE operation = 'ROLLBACK'); | gretelai_synthetic_text_to_sql |
CREATE TABLE production (item_id INT, energy_source VARCHAR(255), quantity INT); INSERT INTO production (item_id, energy_source, quantity) VALUES (1, 'Solar', 500), (2, 'Wind', 600), (3, 'Hydro', 400), (4, 'Fossil Fuels', 700), (5, 'Nuclear', 800); | What is the total quantity of clothing items produced using renewable energy sources? | SELECT SUM(quantity) FROM production WHERE energy_source IN ('Solar', 'Wind', 'Hydro'); | gretelai_synthetic_text_to_sql |
CREATE TABLE banks(id INT, name TEXT);CREATE TABLE shariah_compliant_loans(id INT, bank_id INT, amount INT); INSERT INTO banks VALUES (1, 'Bank A'), (2, 'Bank B'); INSERT INTO shariah_compliant_loans VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 3000); | What is the total amount of Shariah-compliant loans issued by each bank? | SELECT s.bank_id, SUM(s.amount) FROM shariah_compliant_loans s GROUP BY s.bank_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT PRIMARY KEY, Name TEXT, Category TEXT, CargoWeight FLOAT); INSERT INTO Vessels (ID, Name, Category, CargoWeight) VALUES (1, 'Cargo Ship 1', 'Cargo Ship', 5500), (2, 'Fishing Vessel 1', 'Fishing Vessel', 300), (3, 'Cargo Ship 2', 'Cargo Ship', 7000); | What is the total cargo weight for vessels in the 'Fishing Vessel' category? | SELECT SUM(CargoWeight) FROM Vessels WHERE Category = 'Fishing Vessel'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT, name TEXT, state TEXT, type TEXT, co2_savings INT); INSERT INTO project (id, name, state, type, co2_savings) VALUES (16, 'Texas Wind', 'Texas', 'Wind', 765432), (17, 'Oklahoma Solar', 'Oklahoma', 'Solar', 345678), (18, 'Texas Solar', 'Texas', 'Solar', 987654), (19, 'Oklahoma Wind', 'Oklaho... | Calculate the total CO2 emissions savings (in metric tons) of renewable projects in Texas and Oklahoma | SELECT SUM(co2_savings) FROM project WHERE (state = 'Texas' OR state = 'Oklahoma') AND type IN ('Wind', 'Solar'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); | Show all menu items in the Vegan category | SELECT * FROM Menu WHERE category = 'Vegan'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA eu_schema2;CREATE TABLE eu_schema2.libraries (country VARCHAR(20), library_type VARCHAR(20), num_libraries INT);INSERT INTO eu_schema2.libraries (country, library_type, num_libraries) VALUES ('Spain', 'Public Libraries', 4000), ('Portugal', 'Public Libraries', 2500), ('Greece', 'Public Libraries', 3000); | Identify the number of public libraries in Spain, Portugal, and Greece. | SELECT country, num_libraries FROM eu_schema2.libraries WHERE (country = 'Spain' OR country = 'Portugal' OR country = 'Greece') AND library_type = 'Public Libraries'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name TEXT, country TEXT, launch_date DATE, mass FLOAT); INSERT INTO satellites (id, name, country, launch_date, mass) VALUES (1, 'GSAT-11', 'India', '2018-12-04', 5850); | What is the maximum mass of a satellite launched by India? | SELECT MAX(mass) FROM satellites WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE decentralized_apps (app_id INT, app_name VARCHAR(50), category VARCHAR(50), platform VARCHAR(50), launch_date DATE); | Update the 'category' column of 'app_id' 1001 in the 'decentralized_apps' table to 'AMM' | UPDATE decentralized_apps SET category = 'AMM' WHERE app_id = 1001; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces (id INT, city VARCHAR(10), safety_issues INT); INSERT INTO workplaces (id, city, safety_issues) VALUES (1, 'New York', 10), (2, 'Los Angeles', 5), (3, 'Houston', 15), (4, 'Miami', 8); CREATE TABLE cities (id INT, city VARCHAR(10)); INSERT INTO cities (id, city) VALUES (1, 'New York'), (2, 'Los A... | What is the total number of workplaces with safety issues in each city? | SELECT w.city, SUM(w.safety_issues) OVER (PARTITION BY w.city) AS total_safety_issues FROM workplaces w INNER JOIN cities c ON w.city = c.city; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_reserves (reserve_id INT, reserve_name VARCHAR(50), country_code CHAR(2)); CREATE TABLE country_codes (country_code CHAR(2), country_name VARCHAR(50)); | List the number of marine reserves in each country in the 'marine_reserves' table, sorted by the number of reserves in descending order. | SELECT country_code, COUNT(*) as num_reserves FROM marine_reserves INNER JOIN country_codes ON marine_reserves.country_code = country_codes.country_code GROUP BY country_code ORDER BY num_reserves DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (date DATE, species VARCHAR(50), biomass FLOAT, stock_count INTEGER); INSERT INTO fish_stock (date, species, biomass, stock_count) VALUES ('2022-01-01', 'Tilapia', 2500, 5000); | What are the total biomass and stock counts for each species in Q1 2022? | SELECT EXTRACT(QUARTER FROM date) as quarter, species, SUM(biomass) as total_biomass, SUM(stock_count) as total_stock_count FROM fish_stock WHERE date >= '2022-01-01' AND date <= '2022-03-31' GROUP BY quarter, species; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact_table (record_id INT, chemical_id INT, environmental_impact_float); | Update the environmental impact of 'Methyl Ethyl Ketone' to 2.8 in the environmental_impact_table | UPDATE environmental_impact_table SET environmental_impact_float = 2.8 WHERE chemical_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farms_europe (country VARCHAR(50), num_farms INT); INSERT INTO organic_farms_europe (country, num_farms) VALUES ('France', 12000), ('Spain', 15000), ('Germany', 9000); | What is the total number of organic farms in Europe? | SELECT SUM(num_farms) FROM organic_farms_europe WHERE country IN ('France', 'Spain', 'Germany'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Contract_Negotiations (contract_id INT, equipment_name VARCHAR(50), customer_country VARCHAR(50), negotiation_date DATE, negotiation_duration INT); INSERT INTO Contract_Negotiations (contract_id, equipment_name, customer_country, negotiation_date, negotiation_duration) VALUES (1, 'Tank A', 'Mexico', '2020-... | What is the minimum contract negotiation duration for military equipment sales to Mexico? | SELECT customer_country, MIN(negotiation_duration) AS min_negotiation_duration FROM Contract_Negotiations WHERE customer_country = 'Mexico' GROUP BY customer_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE PortCargo (port_id INT, vessel_id INT, cargo_weight INT); | List the top 3 ports with the highest average cargo weight per vessel | SELECT port_id, AVG(cargo_weight) FROM (SELECT port_id, vessel_id, AVG(cargo_weight) AS cargo_weight FROM PortCargo GROUP BY port_id, vessel_id) t GROUP BY port_id ORDER BY AVG(cargo_weight) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_costs (project_id INT, material VARCHAR(100), cost INT); CREATE TABLE sustainable_materials (material VARCHAR(100)); | Get the total cost of sustainable building materials for each project | SELECT pc.project_id, SUM(pc.cost) AS total_sustainable_cost FROM project_costs pc INNER JOIN sustainable_materials sm ON pc.material = sm.material GROUP BY pc.project_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturer (name VARCHAR(50), country VARCHAR(50), domain VARCHAR(20)); INSERT INTO Manufacturer (name, country, domain) VALUES ('ISRO', 'India', 'Aerospace'); INSERT INTO Manufacturer (name, country, domain) VALUES ('Bharat Electronics', 'India', 'Aerospace'); | What are the names and launch dates of all satellites manufactured by Indian companies? | SELECT s.name, s.launch_date FROM Satellite s INNER JOIN Manufacturer m ON s.manufacturer = m.name WHERE m.country = 'India'; | gretelai_synthetic_text_to_sql |
USE biotech; CREATE TABLE if not exists projects (id INT, name VARCHAR(255), country VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO projects (id, name, country, budget) VALUES (1, 'ProjectX', 'UK', 1500000.00), (2, 'ProjectY', 'Germany', 800000.00), (3, 'ProjectZ', 'UK', 1200000.00), (4, 'ProjectA', 'France', 1800000... | Which genetic research projects in the UK have a budget greater than £1,000,000? | SELECT * FROM projects WHERE country = 'UK' AND budget > 1000000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, concert_date DATE, ticket_sales INT); INSERT INTO concerts (id, concert_date, ticket_sales) VALUES (1, '2022-01-01', 5000); | Avg. ticket sales for concerts in 2022 | SELECT AVG(ticket_sales) AS avg_ticket_sales FROM concerts WHERE YEAR(concert_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (15, 'Belgium', 'Netherlands', '2022-06-28', 30), (16, 'Belgium', 'Netherlands', '2022-10-14', 24); | What is the average age of tourists visiting the Netherlands in 2022? | SELECT AVG(age) FROM tourism_data WHERE destination = 'Netherlands' AND YEAR(arrival_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_equity_metrics (id INT, metric_type VARCHAR(50), value INT); INSERT INTO health_equity_metrics (id, metric_type, value) VALUES (1, 'accessibility', 70), (2, 'quality', 85), (3, 'cost', 65); | Delete all records from the table 'health_equity_metrics' where the metric type is 'accessibility'. | DELETE FROM health_equity_metrics WHERE metric_type = 'accessibility'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams_esp (country VARCHAR(50), name VARCHAR(50), height INT); INSERT INTO dams_esp (country, name, height) VALUES ('Spain', 'Alcantara Dam', 152), ('Spain', 'Aguilar del Alfambra Dam', 133); | What are the dams in Spain with a height greater than 150 meters? | SELECT name FROM dams_esp WHERE country = 'Spain' AND height > 150; | gretelai_synthetic_text_to_sql |
CREATE TABLE sea_surface_temperature (id INT, location TEXT, temperature REAL); | Get the maximum sea surface temperature in the Bay of Bengal | SELECT MAX(temperature) FROM sea_surface_temperature WHERE location = 'Bay of Bengal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ai_2 (hotel_id INT, hotel_name TEXT, region TEXT, ai_chatbot BOOLEAN, ai_concierge BOOLEAN); INSERT INTO hotel_ai_2 (hotel_id, hotel_name, region, ai_chatbot, ai_concierge) VALUES (1, 'Hotel E', 'LATAM', true, true), (2, 'Hotel F', 'NA', false, true), (3, 'Hotel G', 'LATAM', false, false), (4, 'Hotel... | What is the total number of hotels that have adopted AI solutions in LATAM? | SELECT COUNT(*) FROM hotel_ai_2 WHERE region = 'LATAM' AND ai_chatbot = true AND ai_concierge = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Material VARCHAR(50), Quantity INT);INSERT INTO Brands (BrandID, BrandName, Material, Quantity) VALUES (1, 'BrandA', 'Organic Cotton', 3000), (2, 'BrandB', 'Recycled Polyester', 2500), (1, 'BrandA', 'Hemp', 1500), (3, 'BrandC', 'Organic Cotton', 2000), (2, 'Brand... | Show the total quantity of sustainable materials used by each brand, ordered from highest to lowest? | SELECT BrandName, SUM(Quantity) as TotalQuantity FROM Brands GROUP BY BrandName ORDER BY TotalQuantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (menu_id INT, menu_name VARCHAR(20)); INSERT INTO Menu (menu_id, menu_name) VALUES (1, 'Breakfast'), (2, 'Lunch'), (3, 'Dinner'); CREATE TABLE Menu_Orders (order_id INT, menu_id INT, order_date DATE); INSERT INTO Menu_Orders (order_id, menu_id, order_date) VALUES (1, 1, '2021-07-01'), (2, 2, '2021-07-... | What is the most popular meal in the breakfast menu? | SELECT menu_name, COUNT(*) AS meal_count FROM Menu_Orders INNER JOIN Menu ON Menu_Orders.menu_id = Menu.menu_id WHERE menu_name = 'Breakfast' GROUP BY menu_name ORDER BY meal_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_2021 AS SELECT * FROM sales WHERE sale_date BETWEEN '2021-01-01' AND '2021-12-31'; ALTER TABLE sales_2021 ADD COLUMN sale_country VARCHAR(50); UPDATE sales_2021 SET sale_country = CASE WHEN sale_city IN ('Accra', 'Lagos', 'Cairo') THEN 'Africa' ELSE sale_country END; ALTER TABLE sales_2021 ADD COLUMN... | What was the total sales amount for each product category in Africa in 2021? | SELECT sale_country, product_category, SUM(sale_amount) FROM sales_2021 WHERE sale_country = 'Africa' GROUP BY sale_country, product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibition (id INT, name VARCHAR(100), Visitor_id INT); CREATE TABLE Visitor (id INT, name VARCHAR(100)); INSERT INTO Exhibition (id, name, Visitor_id) VALUES (1, 'Ancient Civilizations', 1), (2, 'Modern Art', 1), (3, 'Nature Photography', 2); INSERT INTO Visitor (id, name) VALUES (1, 'John Doe'), (2, 'Jan... | What is the percentage of visitors who have attended more than one exhibition? | SELECT (COUNT(DISTINCT Visitor.id) - COUNT(DISTINCT Exhibition.Visitor_id)) * 100.0 / COUNT(DISTINCT Visitor.id) as percentage FROM Visitor LEFT JOIN Exhibition ON Visitor.id = Exhibition.Visitor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, city TEXT, founder_gender TEXT); INSERT INTO companies (id, name, city, founder_gender) VALUES (1, 'Acme Inc', 'San Francisco', 'Female'), (2, 'Beta Corp', 'San Francisco', 'Male'), (3, 'Gamma Inc', 'New York', 'Female'), (4, 'Delta Co', 'Los Angeles', 'Male'); | What is the number of companies founded by women, per city, as a percentage of total companies in that city? | SELECT city, 100.0 * COUNT(*) FILTER (WHERE founder_gender = 'Female') / COUNT(*) AS pct_women_founded FROM companies GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE WAProducers (ProducerID INT, Name VARCHAR(100), State VARCHAR(100)); CREATE TABLE WAFlowerPrices (PriceID INT, ProducerID INT, PricePerGram DECIMAL(5,2), PriceDate DATE); | Delete records of transactions with a price per gram of zero or null in Washington dispensaries since August 2021 | DELETE FROM WAFlowerPrices WHERE PricePerGram IN (0, NULL) AND ProducerID IN (SELECT ProducerID FROM WAProducers WHERE State = 'Washington') AND PriceDate >= '2021-08-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (BudgetID int, DepartmentID int, Amount decimal, StartDate date, EndDate date); INSERT INTO Budget (BudgetID, DepartmentID, Amount, StartDate, EndDate) VALUES (1, 1, 50000, '2024-01-01', '2024-12-31'); INSERT INTO Budget (BudgetID, DepartmentID, Amount, StartDate, EndDate) VALUES (2, 2, 70000, '2024... | What is the total budget allocated for each department in 2024? | SELECT DepartmentID, SUM(Amount) as TotalBudget FROM Budget WHERE YEAR(StartDate) = 2024 AND YEAR(EndDate) = 2024 GROUP BY DepartmentID; | gretelai_synthetic_text_to_sql |
CREATE TABLE Victims (Id INT, Name VARCHAR(50), Age INT); INSERT INTO Victims (Id, Name, Age) VALUES (1, 'Alice', 32), (2, 'Brian', 45); CREATE TABLE RestorativePrograms (Id INT, VictimId INT, Program VARCHAR(50)); INSERT INTO RestorativePrograms (Id, VictimId, Program) VALUES (1, 1, 'Mediation'), (2, 2, 'RestorativeCi... | What are the names and ages of victims who have participated in restorative justice programs and are above 30 years old? | SELECT Victims.Name, Victims.Age FROM Victims INNER JOIN RestorativePrograms ON Victims.Id = RestorativePrograms.VictimId WHERE Victims.Age > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_i(item_id INT, item_type VARCHAR(10), quantity INT);CREATE TABLE warehouse_j(item_id INT, item_type VARCHAR(10), quantity INT);INSERT INTO warehouse_i(item_id, item_type, quantity) VALUES (1, 'A', 200), (2, 'B', 300), (3, 'A', 50), (4, 'B', 400);INSERT INTO warehouse_j(item_id, item_type, quantit... | What is the total quantity of items with type 'A' or type 'B' in warehouse I and warehouse J? | SELECT quantity FROM warehouse_i WHERE item_type IN ('A', 'B') UNION ALL SELECT quantity FROM warehouse_j WHERE item_type IN ('A', 'B'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Brand (id INT, brand_name VARCHAR(50), PRIMARY KEY (id)); INSERT INTO Brand (id, brand_name) VALUES (1, 'Ecco Bella'), (2, 'Herbivore Botanicals'), (3, 'Tarte'), (4, 'Bite Beauty'); | What are the names of brands that have certified cruelty-free products? | SELECT DISTINCT brand_name FROM Brand b INNER JOIN Cruelty_Free_Certification c ON b.id = c.product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE certifications (certification_id INT, product_id INT, certification_date DATE, is_cruelty_free BOOLEAN); INSERT INTO certifications VALUES (1, 1, '2022-01-01', true), (2, 2, '2022-02-01', false), (3, 3, '2022-03-01', true); CREATE TABLE products (product_id INT, product_name VARCHAR(50)); INSERT INTO produ... | How many cosmetic products have been certified as cruelty-free in each region? | SELECT r.region_name, COUNT(c.certification_id) FROM certifications c INNER JOIN products p ON c.product_id = p.product_id INNER JOIN regions r ON p.region_id = r.region_id WHERE c.is_cruelty_free = true GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE uk_data (subscriber_id INT, subscriber_type VARCHAR(10), region VARCHAR(10)); INSERT INTO uk_data (subscriber_id, subscriber_type, region) VALUES (1, 'mobile', 'London'), (2, 'broadband', 'London'), (3, 'mobile', 'Manchester'), (4, 'broadband', 'Manchester'), (5, 'mobile', 'Liverpool'); | What is the total number of mobile and broadband subscribers in the United Kingdom for each region? | SELECT region, COUNT(*) as total_subscribers FROM uk_data WHERE subscriber_type IN ('mobile', 'broadband') GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE ElectricVehicleSales (id INT, name VARCHAR(50), horsepower INT, sale_year INT); INSERT INTO ElectricVehicleSales (id, name, horsepower, sale_year) VALUES (1, 'Tesla Model S', 522, 2021); INSERT INTO ElectricVehicleSales (id, name, horsepower, sale_year) VALUES (2, 'Audi e-Tron', 402, 2021); | What is the maximum horsepower of electric vehicles sold in 2021? | SELECT MAX(horsepower) FROM ElectricVehicleSales WHERE sale_year = 2021 AND horsepower IS NOT NULL; | 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.