context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE financial_transactions (id INT, transaction_date DATE); | How many financial transactions were there per month in the last year? | SELECT MONTH(ft.transaction_date) as month, YEAR(ft.transaction_date) as year, COUNT(*) as num_transactions FROM financial_transactions ft WHERE ft.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY month, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, industry TEXT, valuation INT, founder_ethnicity TEXT); INSERT INTO company (id, name, industry, valuation, founder_ethnicity) VALUES (1, 'BankCo', 'Fintech', 2000000, 'African American'); | What is the maximum valuation for startups in the fintech sector founded by underrepresented ethnicities? | SELECT MAX(c.valuation) FROM company c WHERE c.industry = 'Fintech' AND c.founder_ethnicity IN ('African American', 'Hispanic', 'Native American', 'Pacific Islander'); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(100), is_vegan BOOLEAN, price DECIMAL(5,2), country VARCHAR(50)); INSERT INTO products (product_id, name, is_vegan, price, country) VALUES (1, 'Lipstick', true, 25.99, 'Canada'); INSERT INTO products (product_id, name, is_vegan, price, country) VALUES (2, 'Foundation'... | What is the average price of vegan cosmetics sold in Canada? | SELECT AVG(price) FROM products WHERE is_vegan = true AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT, year INT, country TEXT, engaged_in_sustainable_tourism BOOLEAN); INSERT INTO visitors (id, year, country, engaged_in_sustainable_tourism) VALUES (1, 2019, 'Australia', true), (2, 2018, 'Australia', false); | What is the percentage of visitors to Australia in 2019 who engaged in sustainable tourism activities? | SELECT (SUM(engaged_in_sustainable_tourism) * 100.0 / COUNT(*)) AS percentage FROM visitors WHERE year = 2019 AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_inspections (id INT, union_name VARCHAR(50), inspection_date DATE, passed BOOLEAN); | Insert record for a new safety inspection | INSERT INTO safety_inspections (id, union_name, inspection_date, passed) VALUES (1, 'United Auto Workers', '2022-06-01', true); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists startups; USE startups; CREATE TABLE if not exists budgets (id INT, startup_id INT, budget DECIMAL(10, 2)); INSERT INTO budgets (id, startup_id, budget) VALUES (1, 1, 30000000.00), (2, 2, 20000000.00), (3, 3, 18000000.00), (4, 4, 25000000.00), (5, 5, 13000000.00); | What is the average budget for biotech startups in South America? | SELECT AVG(budget) FROM startups.budgets WHERE startup_id IN (SELECT id FROM startups.startups WHERE region = 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (join_date DATE, region VARCHAR(255)); INSERT INTO volunteers (join_date, region) VALUES ('2021-01-01', 'North'), ('2021-01-05', 'South'), ('2021-02-01', 'North'), ('2021-02-10', 'East'), ('2021-03-01', 'West'); | What is the total number of volunteers who joined from a specific region? | SELECT COUNT(*) FROM volunteers WHERE region = 'North'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ancient_artifacts (id INT, artifact_name VARCHAR(50), weight FLOAT, material VARCHAR(50), excavation_site VARCHAR(50)); | What is the total weight of artifacts made of copper at each excavation site? | SELECT excavation_site, SUM(weight) OVER (PARTITION BY excavation_site) as total_copper_weight FROM ancient_artifacts WHERE material = 'copper'; | gretelai_synthetic_text_to_sql |
CREATE TABLE plan_data_usage (plan_id INT, plan_type VARCHAR(50), network_type VARCHAR(50), data_usage INT); INSERT INTO plan_data_usage (plan_id, plan_type, network_type, data_usage) VALUES (1, 'Plan A', '3G', 2000), (2, 'Plan B', '3G', 3000), (3, 'Plan C', '4G', 4000); | What is the average data usage for each plan type in the 3G network? | SELECT plan_type, AVG(data_usage) FROM plan_data_usage WHERE network_type = '3G' GROUP BY plan_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramName VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Programs (ProgramName, Budget) VALUES ('Education', 15000.00), ('Healthcare', 22000.00), ('Arts', 10000.00); | What are the names of the programs that have a budget equal to the average program budget? | SELECT ProgramName FROM Programs WHERE Budget = (SELECT AVG(Budget) FROM Programs); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (id INT, product VARCHAR(255), vegan BOOLEAN, sales INT, country VARCHAR(255)); INSERT INTO sales_data (id, product, vegan, sales, country) VALUES (1, 'Foundation', true, 75, 'UK'), (2, 'Eyeshadow', false, 50, 'UK'), (3, 'Blush', true, 100, 'UK'); | What is the total number of cosmetics products that are vegan and were sold in the UK? | SELECT SUM(sales) FROM sales_data WHERE vegan = true AND country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClaimDetails (PolicyID INT, PolicyType VARCHAR(20), ClaimAmount DECIMAL(10, 2)); INSERT INTO ClaimDetails (PolicyID, PolicyType, ClaimAmount) VALUES (1, 'Auto', 500.00), (2, 'Home', 1000.00), (3, 'Auto', 250.00); | Calculate the total claim amount for policy types 'Auto' and 'Home'. | SELECT PolicyType, SUM(ClaimAmount) FROM ClaimDetails WHERE PolicyType IN ('Auto', 'Home') GROUP BY PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT PRIMARY KEY, region_name VARCHAR(255)); INSERT INTO regions (region_id, region_name) VALUES (1, 'East'), (2, 'West'), (3, 'Central'), (4, 'North'), (5, 'South'); CREATE TABLE mobile_subscribers (subscriber_id INT PRIMARY KEY, region_id INT); INSERT INTO mobile_subscribers (subscriber... | Which mobile subscribers reside in the same regions as broadband subscribers with data usage over 90? | SELECT m.subscriber_id, m.region_id FROM mobile_subscribers m JOIN broadband_subscribers b ON m.region_id = b.region_id WHERE b.data_usage > 90; | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (PropertyID INT, Price INT, SustainabilityScore INT, Neighborhood VARCHAR(20), Size INT); INSERT INTO Properties (PropertyID, Price, SustainabilityScore, Neighborhood, Size) VALUES (1, 300000, 80, 'RenewableHeights', 1200), (2, 450000, 95, 'RenewableHeights', 1500), (3, 250000, 60, 'RenewableHei... | List the top 2 most affordable properties based on their sustainability scores in the 'RenewableHeights' neighborhood, ordered by size. | SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY Neighborhood ORDER BY Price, Size) AS rn FROM Properties WHERE Neighborhood = 'RenewableHeights' ORDER BY Price, Size) sub WHERE rn <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(50)); CREATE TABLE grants (id INT, department_id INT, amount INT); INSERT INTO departments VALUES (1, 'English'), (2, 'History'), (3, 'Philosophy'); INSERT INTO grants VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000), (4, 3, 4000); | Find the number of grants awarded to each department in the College of Humanities. | SELECT department_id, COUNT(*) AS grant_count FROM grants GROUP BY department_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels(id INT, name VARCHAR(50), type VARCHAR(50)); CREATE TABLE visits(vessel_id INT, port VARCHAR(50), visit_date DATE); INSERT INTO vessels VALUES (1, 'Vessel1', 'Container'); INSERT INTO visits VALUES (1, 'Port of Los Angeles', '2022-01-15'); | Which vessels have visited the Port of Los Angeles in the last 6 months? | SELECT vessels.name FROM vessels INNER JOIN visits ON vessels.id = visits.vessel_id WHERE visits.port = 'Port of Los Angeles' AND visits.visit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE causes (cause_id INT, cause_name VARCHAR(50)); INSERT INTO causes (cause_id, cause_name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE donations (donation_id INT, cause_id INT, donation_amount DECIMAL(10,2)); INSERT INTO donations (donation_id, cause_id, donation_amount) VALUES (... | What is the total donation amount by each cause? | SELECT cause_name, SUM(donation_amount) as total_donation_amount FROM donations JOIN causes ON donations.cause_id = causes.cause_id GROUP BY cause_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dances (id INT, name TEXT, origin TEXT); INSERT INTO Dances (id, name, origin) VALUES (1, 'Samba', 'Brazil'); CREATE TABLE Communities (id INT, dance_id INT, name TEXT); INSERT INTO Communities (id, dance_id, name) VALUES (1, 1, 'Cariocas'); | What are the traditional dances, their origins, and the communities that perform them in South America? | SELECT D.name, D.origin, C.name FROM Dances D INNER JOIN Communities C ON D.id = C.dance_id WHERE C.name = 'Cariocas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndianFood (menu_item VARCHAR(50), cuisine VARCHAR(20), type VARCHAR(20), price DECIMAL(5,2), revenue DECIMAL(5,2)); INSERT INTO IndianFood (menu_item, cuisine, type, price, revenue) VALUES ('Butter Chicken', 'Indian', 'Non-vegetarian', 12.99, 0), ('Lamb Rogan Josh', 'Indian', 'Non-vegetarian', 14.99, 0); | What is the total revenue generated from non-vegetarian dishes in the Indian cuisine category? | SELECT SUM(price * revenue) FROM IndianFood WHERE cuisine = 'Indian' AND type = 'Non-vegetarian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_statistics (state VARCHAR(2), year INT, total_workers INT, avg_hourly_wage DECIMAL(5,2), total_payroll DECIMAL(10,2)); INSERT INTO labor_statistics (state, year, total_workers, avg_hourly_wage, total_payroll) VALUES ('CA', 2020, 500000, 30.50, 762500000), ('NY', 2020, 400000, 31.20, 624000000); | Update the total payroll for New York in the 'labor_statistics' table to $640,000,000 for the year 2020 | UPDATE labor_statistics SET total_payroll = 640000000 WHERE state = 'NY' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE risks(id INT, country VARCHAR(50), region VARCHAR(20), score NUMERIC, year INT); | What are the geopolitical risk scores for African nations in 2022? | SELECT country, score FROM risks WHERE region = 'Africa' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name TEXT, domain TEXT); INSERT INTO unions (id, name, domain) VALUES (1, 'American Federation of Government Employees', 'Government'); INSERT INTO unions (id, name, domain) VALUES (2, 'National Treasury Employees Union', 'Government'); | Which labor rights organization has the most members in the 'Government' domain? | SELECT name FROM unions WHERE domain = 'Government' GROUP BY name ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id int, age int, gender varchar(10), country varchar(20)); INSERT INTO players (player_id, age, gender, country) VALUES (1, 25, 'Male', 'Brazil'), (2, 30, 'Female', 'Argentina'), (3, 22, 'Male', 'Colombia'), (4, 35, 'Female', 'Peru'); CREATE TABLE game_sessions (session_id int, player_id in... | List the names of all players who have played VR games from South America. | SELECT DISTINCT players.player_id, players.country, game_sessions.game_name FROM players INNER JOIN game_sessions ON players.player_id = game_sessions.player_id INNER JOIN game_catalog ON game_sessions.game_name = game_catalog.game_name WHERE players.country LIKE 'South%' AND game_catalog.game_type = 'VR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists CityTransitIndBra(city CHAR(20), country CHAR(10), transit_usage INT); INSERT INTO CityTransitIndBra(city, country, transit_usage) VALUES ('Mumbai', 'India', 1500), ('Mumbai', 'India', 1600), ('Delhi', 'India', 1400), ('Delhi', 'India', 1300), ('SaoPaulo', 'Brazil', 1200), ('SaoPaulo', 'Brazi... | Identify cities in India and Brazil with the lowest public transit usage. | SELECT city, transit_usage, country FROM CityTransitIndBra WHERE country IN ('India', 'Brazil') GROUP BY city, country ORDER BY transit_usage LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE investigations (id INT, title VARCHAR(100), status VARCHAR(20)); INSERT INTO investigations (id, title, status) VALUES (1, 'Corruption in City Hall', 'Closed'); INSERT INTO investigations (id, title, status) VALUES (2, 'Mysterious Death of a Politician', 'In Progress'); | Delete all records from the 'investigations' table where 'status' is 'Closed' | DELETE FROM investigations WHERE status = 'Closed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipping_lines (shipping_line_id INT, shipping_line_name VARCHAR(100)); CREATE TABLE containers (container_id INT, container_weight INT, shipping_line_id INT); INSERT INTO shipping_lines VALUES (1, 'Maersk Line'); INSERT INTO shipping_lines VALUES (2, 'MSC Mediterranean Shipping Company'); INSERT INTO cont... | How many containers were transported by each shipping line, along with their total weight and average weight per container? | SELECT shipping_lines.shipping_line_name, COUNT(containers.container_id) as num_containers, SUM(containers.container_weight) as total_weight, AVG(containers.container_weight) as avg_weight_per_container FROM shipping_lines INNER JOIN containers ON shipping_lines.shipping_line_id = containers.shipping_line_id GROUP BY s... | gretelai_synthetic_text_to_sql |
CREATE TABLE Individuals (id INT, impairment TEXT, location TEXT); INSERT INTO Individuals (id, impairment, location) VALUES (1, 'Visual', 'Texas'), (2, 'Hearing', 'Texas'); | How many individuals with visual impairments are enrolled in support programs in Texas? | SELECT COUNT(*) FROM Individuals WHERE impairment = 'Visual' AND location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (ID INT, Name VARCHAR(50)); INSERT INTO Countries (ID, Name) VALUES (1, 'USA'), (2, 'China'), (3, 'Germany'), (4, 'Japan'), (5, 'South Korea'); CREATE TABLE ResearchPapers (ID INT, Title VARCHAR(100), PublishedDate DATE, Author VARCHAR(50), Country VARCHAR(50)); INSERT INTO ResearchPapers (ID, Ti... | How many autonomous driving research papers were published in the last year, by country? | SELECT Country, COUNT(*) as Total_Papers FROM ResearchPapers WHERE PublishedDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, exchange VARCHAR(50), chain VARCHAR(50), timestamp TIMESTAMP, fee_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, exchange, chain, timestamp, fee_amount) VALUES (1, 'Uniswap', 'Ethereum', '2022-01-01 12:00:00', 0.5), (2, 'Sushiswap', 'Ethereum', '2022-01-0... | What are the total transaction fees paid in the last 30 days for decentralized exchanges on the Binance Smart Chain? | SELECT SUM(fee_amount) as total_fees FROM transactions WHERE chain = 'Binance Smart Chain' AND exchange IN ('PancakeSwap') AND timestamp >= NOW() - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_inventory (id INT, item_name VARCHAR(255), quantity INT, warehouse_location VARCHAR(50), restock_date DATE); | Update the quantity of all refrigerators in the Miami warehouse by 10%. | UPDATE warehouse_inventory SET quantity = quantity * 1.1 WHERE warehouse_location = 'Miami' AND item_name = 'refrigerator'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeSafetyIncidents (IncidentID INT, EmployeeID INT, IncidentType VARCHAR(255), Region VARCHAR(255), Timestamp DATETIME); | How many safety incidents were reported by the employees in the North region in the past month? | SELECT COUNT(*) FROM EmployeeSafetyIncidents WHERE Region = 'North' AND Timestamp BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) AND CURRENT_DATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(50), description TEXT, price DECIMAL(5,2), category VARCHAR(20), is_vegan BOOLEAN); | Insert a new record into the menu_items table for a non-vegan dish, 'chicken parmesan', priced at $18.99 | INSERT INTO menu_items (name, description, price, category, is_vegan) VALUES ('chicken parmesan', 'Breaded chicken breast with marinara sauce and melted mozzarella', 18.99, 'entree', FALSE); | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (transport_id INT, transport_name TEXT, city TEXT, state TEXT, budget INT); INSERT INTO public_transportation (transport_id, transport_name, city, state, budget) VALUES (1, 'New York City Subway', 'New York', 'New York', 8000000000); INSERT INTO public_transportation (transport_id, tr... | What is the total budget allocated for public transportation in New York City? | SELECT SUM(budget) FROM public_transportation WHERE city = 'New York' AND state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (id INT PRIMARY KEY, student_id INT, survey_date DATE, anxiety_score INT, depression_score INT); CREATE TABLE students (id INT PRIMARY KEY, name TEXT, grade INT); | Create a view to show student mental health trends | CREATE VIEW student_mental_health_trends AS SELECT s.name, AVG(smh.anxiety_score) as avg_anxiety, AVG(smh.depression_score) as avg_depression FROM student_mental_health smh JOIN students s ON smh.student_id = s.id GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE otas (ota_id INT, ota_name TEXT, region TEXT); CREATE TABLE bookings (booking_id INT, ota_id INT, hotel_id INT, timestamp TIMESTAMP); | What is the total number of hotel bookings made through online travel agencies in the Middle East? | SELECT COUNT(*) FROM bookings JOIN otas ON bookings.ota_id = otas.ota_id WHERE otas.region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, region VARCHAR(50)); INSERT INTO forests (id, region) VALUES (1, 'Mediterranean'); CREATE TABLE species (id INT, name VARCHAR(50)); CREATE TABLE carbon_sequestration (id INT, species_id INT, forest_id INT, year INT, sequestration FLOAT); INSERT INTO carbon_sequestration (id, species_id, fo... | What is the 'average carbon sequestration' in '2022' for 'Mediterranean' forests? | SELECT AVG(sequestration) FROM carbon_sequestration JOIN forests ON carbon_sequestration.forest_id = forests.id WHERE forests.region = 'Mediterranean' AND carbon_sequestration.year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(20), HireYear INT, Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Gender, HireYear, Department, Salary) VALUES (1, 'Female', 2020, 'IT', 70000.00), (2, 'Male', 2019, 'HR', 60000.00), (3, 'Non-binary', 2021, 'Engineering', 80000.00); | What is the average salary of employees who identify as non-binary, hired in 2021, and work in the Engineering department? | SELECT AVG(Salary) FROM Employees WHERE Gender = 'Non-binary' AND HireYear = 2021 AND Department = 'Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50)); CREATE TABLE Ship (id INT, name VARCHAR(50), type VARCHAR(50), length FLOAT); CREATE TABLE Cargo (id INT, name VARCHAR(50), weight FLOAT, PortId INT, ShipId INT); | Update the weight of all cargos in US ports by 5%. | UPDATE Cargo SET weight = Cargo.weight * 1.05 WHERE PortId IN (SELECT id FROM Port WHERE country = 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, name VARCHAR(100), city VARCHAR(50), state VARCHAR(20)); INSERT INTO policyholders (id, name, city, state) VALUES (1, 'Jane Smith', 'San Francisco', 'CA'), (2, 'Mike Johnson', 'Los Angeles', 'CA'); CREATE TABLE claims (id INT, policyholder_id INT, amount DECIMAL(10, 2)); INSERT INTO ... | List all policyholders and their total claims from the state of California, ordered by the total claim amount in descending order. | SELECT policyholders.name, SUM(claims.amount) as total_claims FROM policyholders JOIN claims ON policyholders.id = claims.policyholder_id WHERE policyholders.state = 'CA' GROUP BY policyholders.id ORDER BY total_claims DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players_Games (player_id INT, game_id INT); CREATE TABLE Games (id INT, name VARCHAR(50), designer VARCHAR(50)); INSERT INTO Players_Games (player_id, game_id) VALUES (1, 1), (2, 2), (3, 3); INSERT INTO Games (id, name, designer) VALUES (1, 'Beat Saber', 'Jan Kozlovsky'), (2, 'Job Simulator', 'Alex Schwart... | Get the names of players who have played a game designed by 'Alex Schwartz' | SELECT Players.name FROM Players_Games JOIN Players ON Players_Games.player_id = Players.id JOIN Games ON Players_Games.game_id = Games.id WHERE Games.designer = 'Alex Schwartz'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_sales(company_name TEXT, sale_amount INT, sale_quarter INT, sale_year INT); INSERT INTO company_sales(company_name, sale_amount, sale_quarter, sale_year) VALUES('CompanyY', 3000, 2, 2019); | What were the sales figures for 'CompanyY' in Q2 2019? | SELECT SUM(sale_amount) FROM company_sales WHERE company_name = 'CompanyY' AND sale_quarter = 2 AND sale_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (incident_id INT, incident_date DATE, country TEXT); INSERT INTO safety_incidents (incident_id, incident_date, country) VALUES (1, '2022-01-10', 'Japan'), (2, '2022-02-12', 'China'), (3, '2022-03-15', 'Japan'), (4, '2022-04-18', 'China'); | What is the total number of AI safety incidents reported in Japan and China? | SELECT COUNT(*) as num_incidents FROM safety_incidents WHERE country IN ('Japan', 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE DispensarySales (id INT, state VARCHAR(50), year INT, price_per_pound FLOAT); INSERT INTO DispensarySales (id, state, year, price_per_pound) VALUES (1, 'Colorado', 2020, 2000.0), (2, 'Colorado', 2019, 1800.0), (3, 'California', 2020, 2200.0), (4, 'California', 2019, 2000.0); | What was the average price per pound of cannabis sold by dispensaries in the state of Colorado in 2020? | SELECT AVG(price_per_pound) FROM DispensarySales WHERE state = 'Colorado' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistId INT, ArtistName VARCHAR(255), Genre VARCHAR(255)); CREATE TABLE Sales (SaleId INT, ArtistId INT, Revenue DECIMAL(10,2), StreamCount INT); INSERT INTO Artists (ArtistId, ArtistName, Genre) VALUES (1, 'Taylor Swift', 'Pop'), (2, 'BTS', 'K-Pop'), (3, 'Ed Sheeran', 'Pop'); INSERT INTO Sales (... | Show the average revenue per stream for each artist in the 'Pop' genre. | SELECT A.ArtistName, AVG(S.Revenue / S.StreamCount) AS AvgRevenuePerStream FROM Artists A INNER JOIN Sales S ON A.ArtistId = S.ArtistId WHERE A.Genre = 'Pop' GROUP BY A.ArtistName; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, region VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, region, response_time) VALUES (1, 'Western', 120); | What is the total response time for emergency calls in the 'Western' region? | SELECT SUM(response_time) FROM emergency_calls WHERE region = 'Western'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (project_name VARCHAR(255), region VARCHAR(255), type VARCHAR(255)); INSERT INTO climate_projects (project_name, region, type) VALUES ('Tree Planting', 'Asia', 'Mitigation'), ('Solar Power Plant', 'Africa', 'Adaptation'), ('Wind Farm', 'Europe', 'Mitigation'); | How many climate mitigation projects have been implemented in Asia? | SELECT COUNT(*) FROM climate_projects WHERE region = 'Asia' AND type = 'Mitigation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (member_id INT, member_name VARCHAR(50), age INT); CREATE TABLE agriculture_innovation (farmer_id INT, farmer_name VARCHAR(50), member_id INT); | Get the names and ages of community members who are involved in agricultural innovation from the 'community_development' and 'agriculture_innovation' tables | SELECT c.member_name, c.age FROM community_development c INNER JOIN agriculture_innovation a ON c.member_id = a.member_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_reporters (reporter_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), hire_date DATE); | What is the average age of all reporters in the 'news_reporters' table? | SELECT AVG(age) FROM news_reporters; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Performances (artist_id INT, city VARCHAR(20)); INSERT INTO Artists (id, name) VALUES (1, 'Artist A'), (2, 'Artist B'); INSERT INTO Performances (artist_id, city) VALUES (1, 'New York'), (1, 'Chicago'), (2, 'New York'), (2, 'Los Angeles'); | Which artists have performed in both New York and Chicago? | SELECT a.name FROM Artists a INNER JOIN Performances p1 ON a.id = p1.artist_id INNER JOIN Performances p2 ON a.id = p2.artist_id WHERE p1.city = 'New York' AND p2.city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Blockchain (id INT, name VARCHAR(20), type VARCHAR(20)); CREATE TABLE Transactions (id INT, blockchain_id INT, volume DECIMAL(18,2), date DATE); ALTER TABLE Transactions ADD FOREIGN KEY (blockchain_id) REFERENCES Blockchain(id); | What is the total number of transactions per month for the 'Ethereum' blockchain in the 'Transactions' table? | SELECT DATE_FORMAT(date, '%Y-%m') AS month, COUNT(*) FROM Transactions JOIN Blockchain ON Transactions.blockchain_id = Blockchain.id WHERE Blockchain.name = 'Ethereum' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE EVSales (make VARCHAR(20), model VARCHAR(20), country VARCHAR(10)); INSERT INTO EVSales (make, model, country) VALUES ('Tesla', 'Model 3', 'USA'); INSERT INTO EVSales (make, model, country) VALUES ('Tesla', 'Model 3', 'Canada'); INSERT INTO EVSales (make, model, country) VALUES ('Chevrolet', 'Bolt', 'USA')... | Which electric vehicles are sold in more than one country? | SELECT make, model FROM EVSales GROUP BY make, model HAVING COUNT(DISTINCT country) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (item_name VARCHAR(50), category VARCHAR(50), quantity INTEGER); INSERT INTO inventory (item_name, category, quantity) VALUES ('Bruschetta', 'Appetizers', 10), ('Chicken Caesar Salad', 'Salads', 0), ('Veggie Burger', 'Entrees', 5); | How many items are sold out in the inventory? | SELECT category, SUM(CASE WHEN quantity = 0 THEN 1 ELSE 0 END) AS sold_out_count FROM inventory GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability(customer_id INT, score DECIMAL(3, 1), measure_date DATE); INSERT INTO financial_capability VALUES (1, 75, '2022-01-15'), (2, 80, '2022-04-01'), (3, 70, '2022-03-05'), (4, 85, '2022-05-12'); | Compute the average financial capability score for each quarter of the year. | SELECT TO_CHAR(measure_date, 'YYYY-Q') AS quarter, AVG(score) AS avg_score FROM financial_capability GROUP BY quarter ORDER BY quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(255), price DECIMAL(5,2), vegan BOOLEAN, launch_date DATE); INSERT INTO products (product_id, name, price, vegan, launch_date) VALUES (1, 'Lipstick', 15.99, true, '2021-03-15'), (2, 'Eye Shadow', 25.49, false, '2020-06-20'), (3, 'Mascara', 10.99, true, '2021-11-17'); | Find the average price of vegan products launched in 2021. | SELECT AVG(price) FROM products WHERE vegan = true AND launch_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, state VARCHAR(20), city VARCHAR(20), year INT, crime_type VARCHAR(20), number_of_crimes INT); | What is the total number of crimes committed in the state of Florida in the year 2020, grouped by crime type and city? | SELECT city, crime_type, SUM(number_of_crimes) FROM crimes WHERE state = 'Florida' AND year = 2020 GROUP BY city, crime_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_data (id INT PRIMARY KEY, mine_id INT, year INT, monthly_production INT);CREATE TABLE reclamation_data (id INT PRIMARY KEY, mine_id INT, year INT, reclamation_cost INT);CREATE TABLE mine_employees (id INT PRIMARY KEY, mine_id INT, employee_id INT, employment_start_date DATE, employment_end_date ... | What is the diversity score and average tenure for mines in the Middle East? | SELECT d.mine_id, d.diversity_score, e.avg_tenure FROM diversity_stats d JOIN employee_stats e ON d.mine_id = e.mine_id WHERE d.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5) AND e.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (name VARCHAR(255)); INSERT INTO regions (name) VALUES ('Northeast'), ('Southeast'); CREATE TABLE disaster_preparedness_kits (id INT, region VARCHAR(255), quantity INT); INSERT INTO disaster_preparedness_kits (id, region, quantity) VALUES (1, 'Northeast', 100), (2, 'Southeast', 150); | How many disaster preparedness kits have been distributed in each region? | SELECT region, SUM(quantity) as total_kits_distributed FROM disaster_preparedness_kits GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists post (post_id int, user_id int, content_type varchar(10), post_date date);CREATE TABLE if not exists hashtag (hashtag_id int, hashtag_text varchar(50), post_id int); | Get the top 10 hashtags and corresponding number of posts containing those hashtags in the last month. | SELECT h.hashtag_text, COUNT(h.post_id) as total_posts FROM hashtag h INNER JOIN post p ON h.post_id = p.post_id WHERE p.post_date >= DATEADD(day, -30, GETDATE()) GROUP BY h.hashtag_text ORDER BY total_posts DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE agents (id INT, agent_name TEXT, region TEXT); CREATE TABLE policies (id INT, policy_number INT, agent_id INT); INSERT INTO agents VALUES (1, 'Agent A', 'New York'); INSERT INTO agents VALUES (2, 'Agent B', 'New York'); INSERT INTO policies VALUES (1, 1234, 1); INSERT INTO policies VALUES (2, 5678, 2); INS... | Who is the agent with the most policies in the 'New York' region? | SELECT agents.agent_name, COUNT(policies.id) FROM agents JOIN policies ON agents.id = policies.agent_id WHERE agents.region = 'New York' GROUP BY agents.agent_name ORDER BY COUNT(policies.id) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sale_price (drug_name VARCHAR(50), sale_year INT, region VARCHAR(50), price FLOAT); INSERT INTO sale_price (drug_name, sale_year, region, price) VALUES ('DrugX', 2020, 'North', 100), ('DrugX', 2020, 'South', 120), ('DrugX', 2020, 'East', 140), ('DrugZ', 2020, 'North', 150), ('DrugZ', 2020, 'South', 170), (... | What was the average sale price of a specific drug, 'DrugZ', in different regions in the year 2020? | SELECT AVG(price) as avg_price FROM sale_price WHERE drug_name = 'DrugZ' AND sale_year = 2020 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE retailers (retailer_id INT, retailer_name TEXT);CREATE TABLE products (product_id INT, product_name TEXT, country_of_origin TEXT);CREATE TABLE inventory (retailer_id INT, product_id INT); | Which retailers have carried products from more than two different countries of origin? | SELECT retailers.retailer_name FROM retailers JOIN inventory ON retailers.retailer_id = inventory.retailer_id JOIN products ON inventory.product_id = products.product_id GROUP BY retailers.retailer_name HAVING COUNT(DISTINCT products.country_of_origin) > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureBudget (Year INTEGER, Budget INTEGER); INSERT INTO InfrastructureBudget (Year, Budget) VALUES (2019, 12000000), (2020, 15000000); | What is the total budget allocated for infrastructure development in 2019 and 2020? | SELECT SUM(Budget) FROM InfrastructureBudget WHERE Year IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), region VARCHAR(50), salary INT); | Update the role of any employee in the "Northeast" region with a salary of more than 75000 to "Senior Manager". | UPDATE employees SET role = 'Senior Manager' WHERE region = 'Northeast' AND salary > 75000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Salary INT, Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, HireDate, Salary, Department) VALUES (1, '2021-01-15', 70000, 'IT'); INSERT INTO Employees (EmployeeID, HireDate, Salary, Department) VALUES (2, '2021-02-01', 75000, 'HR'); | What is the average salary for employees who were hired in each month of 2021, grouped by department? | SELECT EXTRACT(MONTH FROM HireDate) AS Month, Department, AVG(Salary) FROM Employees WHERE HireDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Month, Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Program (ProgramID int, ProgramName varchar(50), ImpactScore int, ProgramDate date); | What is the maximum impact score for each program in the last year? | SELECT ProgramName, MAX(ImpactScore) as MaxImpactScore FROM Program WHERE ProgramDate >= DATEADD(year, -1, GETDATE()) GROUP BY ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_ethics (id INT, topic TEXT, description TEXT, created_at DATE); | Insert a new record into the "media_ethics" table with the following details: id 5, topic "Social media algorithms", description "Impact on news consumption", created_at "2022-03-15" | INSERT INTO media_ethics (id, topic, description, created_at) VALUES (5, 'Social media algorithms', 'Impact on news consumption', '2022-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, animal_species VARCHAR(50), population INT); INSERT INTO animal_population (id, animal_species, population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 5000), (3, 'Giraffe', 8000), (4, 'Tiger', 3000); | List all animal species and their populations, sorted by population in ascending order | SELECT animal_species, population FROM animal_population ORDER BY population ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ChargingStations (Country VARCHAR(50), Stations INT); INSERT INTO ChargingStations (Country, Stations) VALUES ('United States', 42000), ('China', 79000), ('Germany', 35000), ('Norway', 11000), ('Japan', 33000), ('France', 28000), ('Netherlands', 25000), ('Sweden', 14000), ('South Korea', 13000), ('United K... | What is the total number of electric vehicle charging stations by country? | SELECT Country, SUM(Stations) as TotalStations FROM ChargingStations GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_circular_sustainable_chains (supplier_id INT, product_id INT, quantity INT, sustainable_practices BOOLEAN, FOREIGN KEY (supplier_id) REFERENCES suppliers(id), FOREIGN KEY (product_id) REFERENCES circular_supply_chains(product_id)); | What is the average quantity of products manufactured by each supplier in a circular supply chain with sustainable practices? | SELECT supplier_id, AVG(quantity) FROM supplier_circular_sustainable_chains WHERE sustainable_practices = TRUE GROUP BY supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(255), mission_id INT); INSERT INTO astronauts (id, name, mission_id) VALUES (1, 'Neil Armstrong', 1), (2, 'Buzz Aldrin', 1), (3, 'Pete Conrad', 2), (4, 'Alan Bean', 2), (5, 'John Young', 3); | Which astronauts have participated in more than one space mission? | SELECT name FROM (SELECT name, ROW_NUMBER() OVER (PARTITION BY name ORDER BY mission_id) as row_num FROM astronauts) t WHERE row_num > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_games(id INT, team VARCHAR(50), league VARCHAR(50), location VARCHAR(50), result VARCHAR(10), year INT); INSERT INTO soccer_games(id, team, league, location, result, year) VALUES (1, 'FC Barcelona', 'La Liga', 'Camp Nou', 'Win', 2018), (2, 'FC Barcelona', 'La Liga', 'Camp Nou', 'Win', 2018), (3, 'FC... | How many home games did the FC Barcelona win in La Liga during the 2018-2019 season? | SELECT COUNT(*) FROM soccer_games WHERE team = 'FC Barcelona' AND league = 'La Liga' AND location = 'Camp Nou' AND result = 'Win' AND (year = 2018 OR year = 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(city VARCHAR(20), year INT, rate DECIMAL(5,2)); INSERT INTO recycling_rates VALUES('Nairobi', 2022, 30); | Update the recycling rate for the city of Nairobi to 35% in 2022. | UPDATE recycling_rates SET rate = 35 WHERE city = 'Nairobi' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (id INT, company VARCHAR(255), spacecraft VARCHAR(255)); | What is the total number of spacecrafts produced by each company? | SELECT company, COUNT(spacecraft) FROM SpacecraftManufacturing GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_storage_requirements (chemical_name VARCHAR(255), min_temperature FLOAT); | What is the minimum temperature required for storing each chemical in the chemical_storage_requirements table? | SELECT chemical_name, MIN(min_temperature) FROM chemical_storage_requirements GROUP BY chemical_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE raw_materials (id INT, material TEXT, quantity INT, processing_date DATE); INSERT INTO raw_materials (id, material, quantity, processing_date) VALUES (1, 'A', 100, '2021-01-02'); INSERT INTO raw_materials (id, material, quantity, processing_date) VALUES (2, 'B', 200, '2021-01-05'); INSERT INTO raw_material... | What is the total quantity of raw materials 'A' and 'B' that were processed after 2021-01-01? | SELECT SUM(quantity) AS total_quantity FROM raw_materials WHERE material IN ('A', 'B') AND processing_date > '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE disease_prevalence (id INT, county TEXT, disease TEXT); INSERT INTO disease_prevalence (id, county, disease) VALUES (1, 'County A', 'Disease X'), (2, 'County A', 'Disease Y'), (3, 'County B', 'Disease X'), (4, 'County B', 'Disease Z'); | What is the most common disease in each rural county? | SELECT county, MAX(DISTINCT disease) FROM disease_prevalence WHERE county IN ('Rural County A', 'Rural County B') GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE acidity_measurements (location TEXT, acidity_level REAL); INSERT INTO acidity_measurements (location, acidity_level) VALUES ('Hawaii', 8.1), ('California', 7.9), ('Oregon', 7.8); | What is the maximum ocean acidity level measured in the Pacific Ocean? | SELECT MAX(acidity_level) FROM acidity_measurements WHERE location IN ('Hawaii', 'California', 'Oregon'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GalacticQuestPlayers (PlayerID INT, PlayerName VARCHAR(50), PlaytimeMinutes INT, Rank VARCHAR(10)); INSERT INTO GalacticQuestPlayers VALUES (1, 'LiamGonzalez', 800, 'Gold'), (2, 'OliviaHarris', 900, 'Platinum'), (3, 'MiaWilson', 700, 'Gold'), (4, 'NoahGarcia', 1000, 'Diamond'); | What is the maximum playtime in minutes for players who have achieved a rank of Gold or higher in the game "Galactic Quest"? | SELECT MAX(PlaytimeMinutes) FROM GalacticQuestPlayers WHERE Rank IN ('Gold', 'Platinum', 'Diamond'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), training_completion_date DATE); | List the employees who have not completed diversity training | SELECT id, first_name, last_name FROM Employees WHERE training_completion_date IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE); CREATE VIEW decade_view AS SELECT launch_country, DATE_PART('decade', launch_date) as launch_decade FROM satellites; | How many satellites were launched by decade? | SELECT launch_country, launch_decade, COUNT(*) as num_satellites FROM decade_view GROUP BY launch_country, launch_decade; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (sale_id INT PRIMARY KEY, team_id INT, sale_date DATE, quantity INT); INSERT INTO ticket_sales (sale_id, team_id, sale_date, quantity) VALUES (1, 101, '2022-02-15', 500); | List ticket sales for team_id 101 | SELECT * FROM ticket_sales WHERE team_id = 101; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftMissions (MissionID INT PRIMARY KEY, SpacecraftID INT, Destination VARCHAR(255), LaunchDate DATE); INSERT INTO SpacecraftMissions (MissionID, SpacecraftID, Destination, LaunchDate) VALUES (5, 5, 'Mars', '2003-06-10'); INSERT INTO SpacecraftMissions (MissionID, SpacecraftID, Destination, LaunchDat... | What is the earliest launch date for spacecraft that performed missions to Mars? | SELECT MIN(LaunchDate) FROM SpacecraftMissions WHERE Destination = 'Mars'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_amount DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, sale_amount) VALUES (1, 1, 25.99), (2, 2, 19.99), (3, 3, 39.99), (4, 4, 35.99); CREATE TABLE products (product_id INT, material VARCHAR(20), is_sustainable BOOLEAN); INSERT INTO products (product_id, mate... | What is the total revenue generated from sustainable materials? | SELECT SUM(sale_amount) FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.is_sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, is_cruelty_free BOOLEAN, price DECIMAL(5,2)); INSERT INTO products (product_id, is_cruelty_free, price) VALUES (1, true, 12.99), (2, false, 20.99), (3, true, 18.99), (4, false, 24.99); | What is the average cruelty-free product price, ranked in descending order? | SELECT AVG(price) as avg_price, is_cruelty_free FROM products WHERE is_cruelty_free = true GROUP BY is_cruelty_free ORDER BY avg_price DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_atlantic_water_usage(state VARCHAR(20), usage NUMERIC(10,2), population NUMERIC(10,2)); INSERT INTO south_atlantic_water_usage VALUES ('Delaware', 50.67, 954678), ('Florida', 60.78, 2056789), ('Georgia', 70.89, 1067890), ('Maryland', 80.90, 6178901), ('North Carolina', 90.10, 1089012), ('South Caroli... | What is the average water usage per person in the South Atlantic region, grouped by state? | SELECT state, AVG(usage) FROM south_atlantic_water_usage GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_assessments_v2 (assessment_id INT, year INT, co2_emissions INT); INSERT INTO environmental_assessments_v2 (assessment_id, year, co2_emissions) VALUES (1, 2018, 5000), (2, 2019, 6000), (3, 2020, 7000), (4, 2018, 4000); | What is the average CO2 emissions per environmental impact assessment? | SELECT year, AVG(co2_emissions) FROM environmental_assessments_v2 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), country VARCHAR(255));CREATE VIEW US_Astronauts AS SELECT * FROM Astronauts WHERE country = 'USA';CREATE VIEW CA_Astronauts AS SELECT * FROM Astronauts WHERE country = 'Canada'; | List all space missions that had astronauts from the USA and Canada. | SELECT name FROM SpaceMissions WHERE id IN (SELECT mission_id FROM US_Astronauts_Missions) OR id IN (SELECT mission_id FROM CA_Astronauts_Missions); | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, forest VARCHAR(50), year INT, carbon_sequestration FLOAT); INSERT INTO forests (id, forest, year, carbon_sequestration) VALUES (1, 'Forest A', 2019, 12.5), (2, 'Forest A', 2020, 15.2), (3, 'Forest B', 2019, 10.0), (4, 'Forest B', 2020, 11.8); | List all the forests in descending order of their total carbon sequestration in 2019 and 2020. | SELECT forest, SUM(carbon_sequestration) AS total_carbon_sequestration FROM forests WHERE year IN (2019, 2020) GROUP BY forest ORDER BY total_carbon_sequestration DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, policy_holder VARCHAR(50), coverage_amount INT); INSERT INTO policy (policy_id, policy_holder, coverage_amount) VALUES (1, 'John Doe', 400000), (2, 'Jane Smith', 600000), (3, 'Mary Johnson', 350000); | Update policy records for 'Mary Johnson' to decrease coverage amount by 10% | UPDATE policy SET coverage_amount = coverage_amount * 0.9 WHERE policy_holder = 'Mary Johnson'; | gretelai_synthetic_text_to_sql |
CREATE TABLE stations (station_id INT, station_name VARCHAR(255), line VARCHAR(255));CREATE TABLE trips (trip_id INT, station_id INT, entry_time TIMESTAMP, fare FLOAT); INSERT INTO stations (station_id, station_name, line) VALUES (1, 'Ruggles', 'Green Line'), (2, 'Boylston', 'Green Line'), (3, 'Lechmere', 'Green Line')... | Identify the station on the Green Line with the highest fare collected in a single day | SELECT s.station_name, SUM(t.fare) as total_fare FROM trips t JOIN stations s ON t.station_id = s.station_id WHERE s.line = 'Green Line' GROUP BY s.station_name ORDER BY total_fare DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE rehabilitated_animals (id INT, animal_name VARCHAR(50), rehabilitated_date DATE); INSERT INTO rehabilitated_animals VALUES (1, 'Tiger', '2021-01-01'), (2, 'Lion', '2021-02-01'); | What is the number of distinct animals in 'rehabilitated_animals' table? | SELECT COUNT(DISTINCT animal_name) FROM rehabilitated_animals; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(255), machine_id INT);CREATE TABLE machines (id INT, name VARCHAR(255), energy_consumption DECIMAL(10, 2)); | Find the average energy consumption of machines in the 'textiles' department. | SELECT AVG(machines.energy_consumption) FROM machines INNER JOIN departments ON machines.id = departments.machine_id WHERE departments.name = 'textiles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (SiteID INT, SiteName VARCHAR(255), Type VARCHAR(255), Continent VARCHAR(255), YearEstablished INT); INSERT INTO HeritageSites (SiteID, SiteName, Type, Continent, YearEstablished) VALUES (1, 'Machu Picchu', 'Historic', 'South America', 1983), (2, 'Great Barrier Reef', 'Natural', 'Australia', ... | What is the average number of years since the establishment of heritage sites by continent? | SELECT Continent, AVG(YEAR(CURRENT_DATE) - YearEstablished) as Avg_Years_Since_Estab FROM HeritageSites GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2), claim_date DATE, policy_type VARCHAR(20)); | Show the number of policies and total claim amount for each policy type in the month of August | SELECT policy_type, COUNT(*), SUM(claim_amount) FROM claims WHERE MONTH(claim_date) = 8 GROUP BY policy_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name VARCHAR(255), founding_year INT); INSERT INTO startups (id, name, founding_year) VALUES (1, 'Acme Inc', 2015), (2, 'Bravo Corp', 2017); CREATE TABLE funding (startup_id INT, amount INT); INSERT INTO funding (startup_id, amount) VALUES (1, 500000), (1, 1000000), (2, 750000); | What is the total funding received by startups founded in 2015? | SELECT SUM(funding.amount) FROM funding INNER JOIN startups ON funding.startup_id = startups.id WHERE startups.founding_year = 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cargo (CargoID INT, VesselFlag VARCHAR(50), Destination VARCHAR(50), CargoWeight INT, TransportDate DATE); INSERT INTO Cargo VALUES (1, 'India', 'Australia', 10000, '2021-07-10'), (2, 'India', 'Australia', 12000, '2021-09-25'), (3, 'Norway', 'Europe', 11000, '2021-08-18'); | What is the total cargo weight transported by vessels flying the flag of India to Australia in Q3 2021? | SELECT SUM(CargoWeight) FROM Cargo WHERE VesselFlag = 'India' AND Destination = 'Australia' AND TransportDate >= '2021-07-01' AND TransportDate <= '2021-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (region VARCHAR(50), quarter INT, year INT, project_count INT); INSERT INTO climate_projects VALUES ('Asia', 1, 2021, 120); | How many climate adaptation projects were initiated in Asia in Q1 2021? | SELECT SUM(project_count) FROM climate_projects WHERE region = 'Asia' AND quarter = 1 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE AIRCRAFT_INFO (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), cost INT); | What is the name and type of the most expensive military aircraft in the AIRCRAFT_INFO table? | SELECT name, type FROM AIRCRAFT_INFO WHERE cost = (SELECT MAX(cost) FROM AIRCRAFT_INFO); | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT PRIMARY KEY, union_id INT, campaign_status VARCHAR(255)); CREATE TABLE cb_agreements (id INT PRIMARY KEY, union_id INT); CREATE TABLE unions (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO campaigns (id, union_id, campaign_status) VALUES (1, 1, 'Active'), (2, 2, 'Inactive'), (3, 4, '... | Display union names with no collective bargaining agreements, but active labor rights advocacy campaigns. | SELECT name FROM unions u WHERE u.id IN (SELECT union_id FROM campaigns WHERE campaign_status = 'Active') AND u.id NOT IN (SELECT union_id FROM cb_agreements); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT, program_name VARCHAR(255), budget DECIMAL(10,2), start_date DATE, end_date DATE, city VARCHAR(255)); CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, program_id INT); | Which programs received donations over $500 and their respective city? | SELECT p.program_name, p.city, SUM(d.donation_amount) as total_donations FROM Programs p INNER JOIN Donations d ON p.id = d.program_id WHERE d.donation_amount > 500 GROUP BY p.program_name, p.city; | 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.