context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE songs (id INT, title TEXT, year INT, revenue FLOAT); INSERT INTO songs (id, title, year, revenue) VALUES (1, 'Song 4', 2022, 700.5), (2, 'Song 5', 2021, 800.2), (3, 'Song 6', 2022, 900.3); | What is the total revenue generated by songs released in 2022? | SELECT SUM(songs.revenue) FROM songs WHERE songs.year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE farming (id INT, name TEXT, location TEXT, crop TEXT, yield INT); INSERT INTO farming VALUES (1, 'Smith Farm', 'Colorado', 'Corn', 120), (2, 'Brown Farm', 'Nebraska', 'Soybeans', 45), (3, 'Jones Farm', 'Iowa', 'Wheat', 80); | What is the total yield of crops for each location, ranked by yield? | SELECT location, SUM(yield) as total_yield, ROW_NUMBER() OVER (ORDER BY SUM(yield) DESC) as rank FROM farming GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accidents_Manufacturers (Id INT, Accident_Id INT, Manufacturer VARCHAR(50)); INSERT INTO Accidents_Manufacturers (Id, Accident_Id, Manufacturer) VALUES (1, 1, 'Airbus'), (2, 2, 'Boeing'), (3, 3, 'Airbus'); | How many aircraft manufactured by each company were involved in accidents? | SELECT m.Name AS Manufacturer, COUNT(am.Manufacturer) AS Accidents_Involved FROM Manufacturers m JOIN Accidents_Manufacturers am ON m.Id = (SELECT m2.Id FROM Manufacturers m2 WHERE m2.Name = m.Name) GROUP BY m.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingPrograms (ID INT PRIMARY KEY, Program VARCHAR(50), City VARCHAR(50), StartYear INT, EndYear INT); INSERT INTO RecyclingPrograms (ID, Program, City, StartYear, EndYear) VALUES (1, 'Paper & Cardboard', 'Austin', 2010, 2022); | Update the name of the recycling program 'Paper & Cardboard' to 'Paper, Cardboard, and Fiber' in the city of Austin. | UPDATE RecyclingPrograms SET Program = 'Paper, Cardboard, and Fiber' WHERE Program = 'Paper & Cardboard' AND City = 'Austin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (site_id INT, state VARCHAR(2), num_workers INT, acres FLOAT); CREATE TABLE environmental_impact_assessments (assessment_id INT, site_id INT, assessment_date DATE); CREATE TABLE mining_sites (site_id INT, job_title VARCHAR(20), productivity FLOAT); | List all mining sites that have recorded environmental impact assessments but have not recorded any productivity metrics. | SELECT s.site_id, s.state FROM sites s LEFT JOIN environmental_impact_assessments e ON s.site_id = e.site_id LEFT JOIN mining_sites m ON s.site_id = m.site_id WHERE e.site_id IS NOT NULL AND m.site_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE accidents (id INT, state VARCHAR(50), year INT, accident_count INT); INSERT INTO accidents (id, state, year, accident_count) VALUES (1, 'Colorado', 2019, 3); INSERT INTO accidents (id, state, year, accident_count) VALUES (2, 'Colorado', 2019, 5); INSERT INTO accidents (id, state, year, accident_count) VALUES (3, 'Colorado', 2019, 1); | What is the minimum number of accidents in mining operations in the state of Colorado in the year 2019? | SELECT MIN(accident_count) FROM accidents WHERE state = 'Colorado' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerSizes (CustomerID INT, Size TEXT); INSERT INTO CustomerSizes (CustomerID, Size) VALUES (1, 'XS'), (2, 'S'), (3, 'M'); | Update customer size data for accurate size diversity | UPDATE CustomerSizes SET Size = 'XS-S' WHERE CustomerID = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ApplicantData (ApplicantID int, JobPosition varchar(20), ApplicantType varchar(10), Department varchar(20)); INSERT INTO ApplicantData (ApplicantID, JobPosition, ApplicantType, Department) VALUES (1, 'Sales Representative', 'Applicant', 'Sales'), (2, 'Sales Representative', 'Interviewed', 'Sales'), (3, 'Sales Manager', 'Hired', 'Sales'), (4, 'Software Engineer', 'Applicant', 'Engineering'), (5, 'Software Engineer', 'Interviewed', 'Engineering'), (6, 'Software Engineer', 'Hired', 'Engineering'); | What is the count of total applicants, interviewed applicants, and hired applicants by job position for the Engineering department? | SELECT JobPosition, COUNT(CASE WHEN ApplicantType = 'Applicant' THEN 1 END) AS TotalApplicants, COUNT(CASE WHEN ApplicantType = 'Interviewed' THEN 1 END) AS InterviewedApplicants, COUNT(CASE WHEN ApplicantType = 'Hired' THEN 1 END) AS HiredApplicants FROM ApplicantData WHERE Department = 'Engineering' GROUP BY JobPosition; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiations (id INT, country VARCHAR(50), year INT, budget FLOAT); INSERT INTO contract_negotiations (id, country, year, budget) VALUES (1, 'Country X', 2019, 8000000); | What was the budget for contract negotiations with country X in 2019? | SELECT budget FROM contract_negotiations WHERE country = 'Country X' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id INTEGER, species_name TEXT, ocean TEXT); | What is the total number of marine species in the Atlantic and Pacific oceans? | SELECT SUM(CASE WHEN ocean IN ('Atlantic', 'Pacific') THEN 1 ELSE 0 END) FROM marine_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_institutions(id INT, institution_name VARCHAR(50), quarter INT, year INT, assets INT, owner_gender VARCHAR(50)); INSERT INTO financial_institutions VALUES (1, 'JKL Bank', 2, 2022, 4000000, 'Non-binary'); INSERT INTO financial_institutions VALUES (2, 'DEF Finance', 3, 2022, 5000000, 'Male'); INSERT INTO financial_institutions VALUES (3, 'GHI Invest', 1, 2022, 6000000, 'Non-binary'); INSERT INTO financial_institutions VALUES (4, 'MNO Capital', 4, 2022, 7000000, 'Female'); | What is the total amount of assets for financial institutions in Q2 2022 owned by non-binary individuals? | SELECT SUM(assets) FROM financial_institutions WHERE quarter = 2 AND year = 2022 AND owner_gender = 'Non-binary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255), country VARCHAR(255), gender VARCHAR(10));CREATE TABLE donations (id INT, donor_id INT, cause_id INT, amount DECIMAL(10, 2), donation_date DATE); | What is the percentage of total donations made by each gender in the last 3 years? | SELECT dn.gender, (SUM(d.amount) / (SELECT SUM(amount) FROM donations d INNER JOIN donors dn ON d.donor_id = dn.id WHERE d.donation_date >= DATE_SUB(NOW(), INTERVAL 3 YEAR)) * 100) AS percentage FROM donations d INNER JOIN donors dn ON d.donor_id = dn.id WHERE d.donation_date >= DATE_SUB(NOW(), INTERVAL 3 YEAR) GROUP BY dn.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_type VARCHAR(20), sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO sales (product_type, sale_date, revenue) VALUES ('organic', '2021-01-01', 150.00), ('organic', '2021-01-02', 200.00), ('non_organic', '2021-01-01', 120.00); | What was the total revenue from organic cosmetics sales in Q1 2021? | SELECT SUM(revenue) FROM sales WHERE product_type = 'organic' AND sale_date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Subscribers (SubscriberID int, DataUsage int, Area varchar(10), BillingIssue bit); INSERT INTO Subscribers (SubscriberID, DataUsage, Area, BillingIssue) VALUES (1, 20000, 'rural', 0), (2, 30000, 'urban', 1), (3, 15000, 'rural', 1); | What is the total data usage for subscribers in 'rural' areas, excluding those who have had a billing issue in the past 6 months? | SELECT DataUsage FROM Subscribers WHERE Area = 'rural' AND BillingIssue = 0 | gretelai_synthetic_text_to_sql |
CREATE TABLE player_inventory (player_id INT, item_name VARCHAR(50), quantity INT); | Insert new records into the "player_inventory" table with the following data: (1, 'Sword of Light', 10), (2, 'Shield of Shadow', 5), (3, 'Bow of the Seas', 8) | WITH cte AS (VALUES (1, 'Sword of Light', 10), (2, 'Shield of Shadow', 5), (3, 'Bow of the Seas', 8)) INSERT INTO player_inventory (player_id, item_name, quantity) SELECT * FROM cte; | gretelai_synthetic_text_to_sql |
CREATE TABLE continents (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255), continent_id INT, FOREIGN KEY (continent_id) REFERENCES continents(id));CREATE TABLE destinations (id INT PRIMARY KEY, name VARCHAR(255), country_id INT, FOREIGN KEY (country_id) REFERENCES countries(id), sustainable BOOLEAN);CREATE VIEW sustainable_destinations_by_continent AS SELECT c.name as continent, COUNT(d.id) as sustainable_destination_count FROM continents c JOIN countries co ON c.id = co.continent_id JOIN destinations d ON co.id = d.country_id WHERE d.sustainable = true GROUP BY c.id; | How many sustainable destinations are there in each continent? | SELECT * FROM sustainable_destinations_by_continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_trends (group_name VARCHAR(50), year INT, average_price FLOAT); | Insert new records into the 'market_trends' table for 'OPEC' and 'Non-OPEC' with their respective 'average_price' for the year 2020 | INSERT INTO market_trends (group_name, year, average_price) VALUES ('OPEC', 2020, 45.0), ('Non-OPEC', 2020, 38.5); | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_projects (project_id INT, title VARCHAR(50), year INT, fair INT); INSERT INTO fairness_projects (project_id, title, year, fair) VALUES (1, 'ProjectX', 2018, 1), (2, 'ProjectY', 2022, 0), (3, 'ProjectZ', 2019, 1), (4, 'ProjectW', 2020, 1), (5, 'ProjectV', 2018, 1); | How many algorithmic fairness projects were completed between 2018 and 2020? | SELECT COUNT(*) FROM fairness_projects WHERE year BETWEEN 2018 AND 2020 AND fair = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_levels (threat_id INT, threat_level INT, region_id INT, threat_date DATE); INSERT INTO threat_levels VALUES (1, 5, 100, '2021-01-01'), (2, 3, 101, '2021-01-02'), (3, 7, 100, '2021-01-03'); | What is the average threat level for each region in the past week? | SELECT region_id, AVG(threat_level) OVER (PARTITION BY region_id) AS avg_threat_level FROM threat_levels WHERE threat_date >= DATEADD(week, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founder_gender TEXT, industry TEXT, num_patents INT); INSERT INTO company (id, name, founder_gender, industry, num_patents) VALUES (1, 'EnergyPioneers', 'Female', 'Energy', 5); INSERT INTO company (id, name, founder_gender, industry, num_patents) VALUES (2, 'PowerSolutions', 'Male', 'Energy', 10); | What is the maximum number of patents held by startups founded by women in the energy industry? | SELECT MAX(num_patents) FROM company WHERE founder_gender = 'Female' AND industry = 'Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_negotiations (id INT, union_id INT, negotiation_topic VARCHAR(50), negotiation_outcome VARCHAR(20), negotiation_date DATE); INSERT INTO union_negotiations (id, union_id, negotiation_topic, negotiation_outcome, negotiation_date) VALUES (1, 1, 'Salary Increase', 'Successful', '2022-02-14'), (2, 2, 'Working Hours', 'Unsuccessful', '2021-12-01'), (3, 3, 'Health Insurance', 'Successful', '2022-03-23'), (4, 4, 'Paid Time Off', 'Successful', '2022-01-12'); | Show all records from the 'union_negotiations' table where the negotiation_outcome is 'Successful' | SELECT * FROM union_negotiations WHERE negotiation_outcome = 'Successful'; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE articles (id INT, author_id INT, title VARCHAR(100), content TEXT); INSERT INTO articles (id, author_id, title, content) VALUES (1, 1, 'Article 1', 'Content 1'), (2, 1, 'Article 2', 'Content 2'), (3, 1, 'Article 3', 'Content 3'), (4, 1, 'Article 4', 'Content 4'), (5, 1, 'Article 5', 'Content 5'), (6, 2, 'Article 6', 'Content 6'); | Which authors have published more than 5 articles? | SELECT a.name FROM authors a JOIN articles ar ON a.id = ar.author_id GROUP BY a.name HAVING COUNT(ar.id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, policy_number INT, name VARCHAR(255), age INT, state VARCHAR(255)); INSERT INTO policyholders (id, policy_number, name, age, state) VALUES (1, 12345, 'John Doe', 35, 'CA'); INSERT INTO policyholders (id, policy_number, name, age, state) VALUES (2, 67890, 'Jane Smith', 42, 'NY'); CREATE TABLE claims (id INT, policy_number INT, claim_amount DECIMAL(10,2)); INSERT INTO claims (id, policy_number, claim_amount) VALUES (1, 12345, 500.00); INSERT INTO claims (id, policy_number, claim_amount) VALUES (2, 67890, 1200.00); | Find the average claim amount for policyholders living in 'CA' | SELECT AVG(claim_amount) FROM claims WHERE policy_number IN (SELECT policy_number FROM policyholders WHERE state = 'CA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE visitor_stats (id INT PRIMARY KEY, visitor_country VARCHAR(50), year INT, num_visitors INT); INSERT INTO visitor_stats (id, visitor_country, year, num_visitors) VALUES (1, 'India', 2020, 32000); INSERT INTO visitor_stats (id, visitor_country, year, num_visitors) VALUES (2, 'India', 2019, 30000); | How many tourists visited Canada from India in 2020? | SELECT SUM(num_visitors) FROM visitor_stats WHERE visitor_country = 'India' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (location VARCHAR(50), material_type VARCHAR(50), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (location, material_type, recycling_rate) VALUES ('London', 'Plastic', 0.75), ('London', 'Paper', 0.85), ('London', 'Glass', 0.65); | Identify the recycling rate in London for each material type. | SELECT material_type, AVG(recycling_rate) FROM recycling_rates WHERE location = 'London' GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sea_Bream_Stock (farm VARCHAR(20), quantity INT); INSERT INTO Sea_Bream_Stock (farm, quantity) VALUES ('Mediterranean Farm 1', 3000), ('Mediterranean Farm 2', 4000), ('Aegean Farm 1', 5000), ('Aegean Farm 2', 6000); | What is the sum of sea bream stock for farms in the Mediterranean and Aegean seas? | SELECT SUM(quantity) FROM Sea_Bream_Stock WHERE farm LIKE '%Mediterranean%' OR farm LIKE '%Aegean%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (artwork_type VARCHAR(20), creativity_score FLOAT); INSERT INTO creative_ai (artwork_type, creativity_score) VALUES ('painting', 0.85), ('sculpture', 0.91), ('painting', 0.78); | What is the distribution of creativity scores for AI-generated artworks in the 'creative_ai' table, grouped by artwork type? | SELECT artwork_type, COUNT(*) as count, AVG(creativity_score) as avg_score FROM creative_ai GROUP BY artwork_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE defendants_by_race (defendant_id INT, race VARCHAR(20), incarcerated BOOLEAN, incarceration_date DATE); INSERT INTO defendants_by_race (defendant_id, race, incarcerated, incarceration_date) VALUES (1, 'White', true, '2022-01-05'), (2, 'Black', false, '2022-03-10'), (3, 'Hispanic', true, '2022-04-01'); | What is the number of defendants who have been incarcerated, by race, in the last year? | SELECT defendants_by_race.race, COUNT(*) as num_defendants FROM defendants_by_race WHERE defendants_by_race.incarcerated = true AND defendants_by_race.incarceration_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY defendants_by_race.race; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (CountryID int, CountryName text, HeritageSite BOOLEAN, TraditionalArt BOOLEAN, EndangeredLanguage BOOLEAN); INSERT INTO Countries (CountryID, CountryName, HeritageSite, TraditionalArt, EndangeredLanguage) VALUES (1, 'France', TRUE, TRUE, TRUE), (2, 'Spain', TRUE, TRUE, FALSE), (3, 'Peru', TRUE, TRUE, TRUE); | What are the names of countries that have heritage sites, traditional arts, and endangered languages? | SELECT CountryName FROM Countries WHERE HeritageSite = TRUE AND TraditionalArt = TRUE AND EndangeredLanguage = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_details (user_id INT, num_posts INT); INSERT INTO user_details (user_id, num_posts) VALUES (1, 25), (2, 32), (3, 18), (4, 45); | List all users and their respective number of posts, ordered by the number of posts in descending order. | SELECT user_id, num_posts FROM user_details ORDER BY num_posts DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, garment_id INT, sustainable BOOLEAN, sale_date DATE); INSERT INTO sales (id, garment_id, sustainable, sale_date) VALUES (1, 1009, TRUE, '2021-05-22'); | Count the number of sustainable garments sold in the last week. | SELECT COUNT(*) FROM sales WHERE sustainable = TRUE AND sale_date >= DATEADD(day, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(50), state VARCHAR(50), total_donations DECIMAL(10,2)); INSERT INTO Donors (donor_id, donor_name, state, total_donations) VALUES (1, 'John Doe', 'TX', 1000.00), (2, 'Jane Smith', 'NY', 1500.00); | List the names and total donations of donors who gave more than any donor from 'NY'? | SELECT donor_name, total_donations FROM Donors d1 WHERE total_donations > (SELECT SUM(d2.donation_amount) FROM Donations JOIN Donors d2 ON Donations.donor_id = d2.donor_id WHERE d2.state = 'NY') GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm (id INT, name TEXT, crop TEXT, yield_per_acre FLOAT, region TEXT); INSERT INTO Farm (id, name, crop, yield_per_acre, region) VALUES (1, 'Smith Farm', 'Corn', 150, 'Midwest'), (2, 'Jones Farm', 'Soybeans', 80, 'Midwest'), (3, 'Brown Farm', 'Corn', 180, 'Northeast'), (4, 'Green Farm', 'Potatoes', 200, 'Northeast'), (5, 'White Farm', 'Carrots', 170, 'Northeast'); | Find the 5 farms in the Northeast region with the highest yield per acre for any crop, and display the farm name, crop, and yield per acre. | SELECT name, crop, yield_per_acre FROM (SELECT name, crop, yield_per_acre, ROW_NUMBER() OVER (PARTITION BY region ORDER BY yield_per_acre DESC) as rn FROM Farm WHERE region = 'Northeast') x WHERE rn <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, country VARCHAR(50), carbon_footprint DECIMAL(10, 2)); CREATE TABLE raw_materials (raw_material_id INT, product_id INT, country VARCHAR(50)); | What is the average carbon footprint of products made in the same country as their raw materials? | SELECT AVG(carbon_footprint) FROM products JOIN raw_materials ON products.product_id = raw_materials.product_id WHERE products.country = raw_materials.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE north_sea_oil_production (year INT, region VARCHAR(20), production_volume INT); INSERT INTO north_sea_oil_production (year, region, production_volume) VALUES (2015, 'North Sea', 500000), (2016, 'North Sea', 550000), (2017, 'North Sea', 600000), (2018, 'North Sea', 630000), (2019, 'North Sea', 670000), (2020, 'North Sea', 700000); | What is the total production of oil in the North Sea region for 2020? | SELECT production_volume FROM north_sea_oil_production WHERE year = 2020 AND region = 'North Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'), (2, 'Green Line'), (3, 'Blue Line'), (4, 'Yellow Line'); CREATE TABLE fare (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), collection_date DATE); INSERT INTO fare (fare_id, route_id, fare_amount, collection_date) VALUES (1, 1, 3.50, '2022-06-01'), (2, 1, 3.25, '2022-06-03'), (3, 2, 3.50, '2022-06-05'), (4, 2, 3.25, '2022-06-07'), (5, 3, 3.50, '2022-06-09'), (6, 3, 3.25, '2022-06-11'); | What is the average fare collected per day for each route? | SELECT route_name, AVG(fare_amount / DATEDIFF('2022-06-30', collection_date)) FROM route JOIN fare ON route.route_id = fare.route_id GROUP BY route_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrganicRestaurants (restaurant VARCHAR(20), item_category VARCHAR(15), cost DECIMAL(5,2)); INSERT INTO OrganicRestaurants (restaurant, item_category, cost) VALUES ('GreenLeaf', 'organic', 6.50), ('GreenLeaf', 'local', 7.25), ('GreenVines', 'organic', 5.75), ('GreenVines', 'local', 4.50); | Show the total inventory cost for 'organic' and 'local' items across all restaurants. | SELECT SUM(cost) FROM OrganicRestaurants WHERE item_category IN ('organic', 'local'); | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, brand VARCHAR(255), usage FLOAT); | What is the average water usage for each brand? | SELECT brand, AVG(usage) FROM water_usage GROUP BY brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE conditions (condition_id INT, condition VARCHAR(50)); INSERT INTO conditions (condition_id, condition) VALUES (1, 'Depression'), (2, 'Anxiety'), (3, 'Bipolar Disorder'); CREATE TABLE patients (patient_id INT, condition_id INT, country VARCHAR(50)); INSERT INTO patients (patient_id, condition_id, country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 3, 'Japan'), (4, 1, 'Canada'); | List of mental health conditions treated in more than one country. | SELECT conditions.condition FROM conditions INNER JOIN patients ON conditions.condition_id = patients.condition_id GROUP BY conditions.condition HAVING COUNT(DISTINCT patients.country) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, country VARCHAR(50), start_date DATE, end_date DATE, success BOOLEAN); INSERT INTO projects (id, country, start_date, end_date, success) VALUES (1, 'Nepal', '2015-01-01', '2016-12-31', true), (2, 'Nepal', '2016-01-01', '2017-12-31', false), (3, 'Nepal', '2017-01-01', '2018-12-31', true), (4, 'Nepal', '2018-01-01', '2019-12-31', false), (5, 'Nepal', '2019-01-01', '2020-12-31', true); | What was the success rate of agricultural innovation projects in Nepal between 2015 and 2020? | SELECT AVG(success) FROM projects WHERE country = 'Nepal' AND YEAR(start_date) BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing(id INT, individual_id INT, urban_rural VARCHAR(10), score INT); INSERT INTO financial_wellbeing VALUES (1, 101, 'Urban', 75); INSERT INTO financial_wellbeing VALUES (2, 102, 'Rural', 65); INSERT INTO financial_wellbeing VALUES (3, 103, 'Urban', 80); INSERT INTO financial_wellbeing VALUES (4, 104, 'Rural', 70); | What is the maximum financial wellbeing score in urban areas? | SELECT MAX(score) FROM financial_wellbeing WHERE urban_rural = 'Urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, name TEXT, year INT, artist TEXT); INSERT INTO artworks (id, name, year, artist) VALUES (1, 'Painting', 1920, 'Sarah Johnson'), (2, 'Sculpture', 2005, 'Maria Rodriguez'), (3, 'Installation', 1987, 'Yumi Lee'); | How many artworks were created in each decade, starting from 1900? | SELECT (year / 10) * 10 AS decade, COUNT(*) as num_artworks FROM artworks WHERE year >= 1900 GROUP BY decade; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_stats (id INT, ocean VARCHAR(255), incidents INT); INSERT INTO pollution_stats (id, ocean, incidents) VALUES (1, 'Pacific', 50), (2, 'Atlantic', 30), (3, 'Indian', 20), (4, 'Arctic', 10), (5, 'Southern', 30); | How many pollution incidents occurred in the Indian ocean? | SELECT incidents FROM pollution_stats WHERE ocean = 'Indian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media_posts (id INT, post_text VARCHAR(255), post_date DATE, topic VARCHAR(50)); INSERT INTO social_media_posts (id, post_text, post_date, topic) VALUES (1, 'Post1', '2022-03-01', 'Climate Change'), (2, 'Post2', '2022-02-20', 'Politics'), (3, 'Post3', '2022-03-03', 'Climate Change'); | What is the total number of social media posts about climate change in the last week? | SELECT COUNT(*) FROM social_media_posts WHERE post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND topic = 'Climate Change'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO students VALUES (1, 'Charlie', 'Mathematics'); INSERT INTO students VALUES (2, 'David', 'Physics'); INSERT INTO students VALUES (3, 'Ella', 'Engineering'); CREATE TABLE publications (id INT, student_id INT, journal VARCHAR(50)); INSERT INTO publications VALUES (1, 1, 'Journal of Algebra'); INSERT INTO publications VALUES (2, 1, 'Annals of Mathematics'); INSERT INTO publications VALUES (3, 2, 'Physical Review Letters'); INSERT INTO publications VALUES (4, 3, 'Journal of Mechanical Engineering'); INSERT INTO publications VALUES (5, 3, 'Journal of Civil Engineering'); | What is the average number of publications for graduate students in the Engineering department? | SELECT AVG(publications.id) FROM students JOIN publications ON students.id = publications.student_id WHERE students.department = 'Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (plant varchar(10), chemical varchar(20), production_date date); INSERT INTO production (plant, chemical, production_date) VALUES ('North Plant', 'Chemical A', '2022-01-01'), ('North Plant', 'Chemical B', '2022-01-05'), ('West Plant', 'Chemical C', '2022-02-10'), ('West Plant', 'Chemical D', '2022-03-20'); | Which chemicals were produced by the 'West' plant in the last 3 months? | SELECT DISTINCT chemical FROM production WHERE plant = 'West Plant' AND production_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT PRIMARY KEY, supplier_name VARCHAR(255));CREATE TABLE ingredients (ingredient_id INT PRIMARY KEY, ingredient_name VARCHAR(255), is_organic BOOLEAN, supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES suppliers(supplier_id)); | Identify suppliers providing more than 50% of organic ingredients | SELECT supplier_name FROM suppliers s WHERE (SELECT COUNT(*) FROM ingredients i WHERE i.supplier_id = s.supplier_id AND is_organic = TRUE) > 0.5 * (SELECT COUNT(*) FROM ingredients); | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT, diameter FLOAT, weight INT, material VARCHAR(255), location VARCHAR(255)); | Delete space debris with a diameter greater than 10 meters and a weight above 500 kg. | DELETE FROM space_debris WHERE diameter > 10 AND weight > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE vendors (vendor_id INT, vendor_name TEXT, city TEXT, virtual_tour BOOLEAN, sustainable BOOLEAN); INSERT INTO vendors (vendor_id, vendor_name, city, virtual_tour, sustainable) VALUES (1, 'Green Tours Melbourne', 'Melbourne', TRUE, TRUE), (2, 'Local Food Tours Melbourne', 'Melbourne', FALSE, TRUE), (3, 'Melbourne Eco Adventures', 'Melbourne', TRUE, TRUE); | How many local vendors in Melbourne offer virtual tours related to sustainable tourism? | SELECT COUNT(*) FROM vendors WHERE city = 'Melbourne' AND virtual_tour = TRUE AND sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE flights (id INT, origin TEXT, destination TEXT, co2_emission INT); INSERT INTO flights (id, origin, destination, co2_emission) VALUES (1, 'United States', 'Canada', 100), (2, 'United States', 'Mexico', 120), (3, 'Canada', 'United States', 110); | What is the total CO2 emission for all flights originating from the United States? | SELECT SUM(f.co2_emission) as total_emission FROM flights f WHERE f.origin = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE OperaPerformances3 (TheatreName TEXT, PerformanceDate DATE); INSERT INTO OperaPerformances3 (TheatreName, PerformanceDate) VALUES ('Amsterdam Opera', '2022-01-01'), ('Amsterdam Opera', '2022-02-15'), ('Amsterdam Opera', '2022-04-20'); | How many performances were there at the "Amsterdam Opera" in 2022? | SELECT COUNT(*) FROM OperaPerformances3 WHERE TheatreName = 'Amsterdam Opera' AND YEAR(PerformanceDate) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_data (supplier_id INT, product_id INT, quantity INT, ethical_source BOOLEAN); INSERT INTO supplier_data VALUES (1, 1, 50, true), (1, 2, 30, false), (2, 1, 75, true), (2, 2, 40, false), (3, 1, 80, true), (3, 2, 35, false), (4, 1, 90, true), (4, 2, 45, false); | Calculate the total quantity of ethically sourced products sold by each supplier in the last 6 months. | SELECT supplier_id, SUM(quantity) FROM supplier_data WHERE ethical_source = true AND product_id IN (SELECT product_id FROM inventory WHERE last_sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)) GROUP BY supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Contractors (ContractorID INT, ContractorName VARCHAR(100), Industry VARCHAR(50)); INSERT INTO Contractors (ContractorID, ContractorName, Industry) VALUES (1, 'Lockheed Martin', 'Aerospace'), (2, 'Boeing', 'Aerospace'), (3, 'Microsoft', 'IT'), (4, 'Amazon', 'IT'), (5, 'Northrop Grumman', 'Aerospace'); CREATE TABLE Contracts (ContractID INT, ContractorID INT, Year INT, ContractsAwarded INT); INSERT INTO Contracts (ContractID, ContractorID, Year, ContractsAwarded) VALUES (1, 1, 2021, 50), (2, 1, 2020, 40), (3, 2, 2021, 60), (4, 2, 2020, 70), (5, 5, 2021, 80), (6, 5, 2020, 90); | Find the number of contracts awarded to each contractor in the Aerospace industry in 2021? | SELECT ContractorName, SUM(ContractsAwarded) as Total_Contracts FROM Contracts c JOIN Contractors con ON c.ContractorID = con.ContractorID WHERE Industry = 'Aerospace' AND Year = 2021 GROUP BY ContractorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, underwriter_id INT, issue_date DATE); INSERT INTO policies (id, underwriter_id, issue_date) VALUES (1, 1, '2020-01-15'), (2, 2, '2019-12-31'), (3, 3, '2020-06-01'), (4, 3, '2021-01-01'); | What is the total number of policies issued by underwriter 3? | SELECT COUNT(*) FROM policies WHERE underwriter_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantInventory (ingredient_name TEXT, is_non_gmo BOOLEAN, weight DECIMAL); | Find the total weight of non-GMO ingredients used in 'FarmToTable' dishes. | SELECT SUM(weight) FROM RestaurantInventory WHERE is_non_gmo = TRUE AND ingredient_name IN (SELECT ingredient FROM FarmToTable); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(id INT, sale_date DATE, garment_id INT, quantity INT); INSERT INTO sales(id, sale_date, garment_id, quantity) VALUES (1, '2022-01-01', 1, 10), (2, '2022-02-01', 2, 15); | What is the total quantity of garments sold in the last quarter in the Asia-Pacific region? | SELECT SUM(quantity) FROM sales WHERE sale_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND store_location = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tours_canada (id INT, country VARCHAR(20), revenue FLOAT); INSERT INTO sustainable_tours_canada (id, country, revenue) VALUES (1, 'Canada', 1500.0), (2, 'Canada', 2000.0), (3, 'Canada', 2500.0); | What is the average revenue per sustainable tour in Canada? | SELECT AVG(revenue) FROM sustainable_tours_canada WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (event_name VARCHAR(255), participants VARCHAR(255), date DATE); | What is the total number of defense diplomacy events between the African Union and ASEAN since 2017? | SELECT COUNT(*) FROM defense_diplomacy WHERE participants LIKE '%African Union%' AND participants LIKE '%ASEAN%' AND date >= '2017-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterTreatmentPlants (id INT, state VARCHAR(20), cost FLOAT); INSERT INTO WaterTreatmentPlants (id, state, cost) VALUES (1, 'California', 15000.0), (2, 'California', 13000.0), (3, 'Oregon', 17000.0); | What is the minimum water treatment cost for a plant in California? | SELECT MIN(cost) FROM WaterTreatmentPlants WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_outlets (id INT, outlet_name VARCHAR(50)); CREATE TABLE media_genres (id INT, outlet_id INT, genre VARCHAR(50)); INSERT INTO media_outlets (id, outlet_name) VALUES (1, 'OutletA'), (2, 'OutletB'); INSERT INTO media_genres (id, outlet_id, genre) VALUES (1, 1, 'Comedy'), (2, 1, 'Drama'), (3, 2, 'Comedy'); | Find the number of unique genres covered by each media outlet in the media domain? | SELECT m.outlet_name, COUNT(DISTINCT m.genre) as unique_genres FROM media_genres m GROUP BY m.outlet_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops (id INT, crop_type VARCHAR(255), country VARCHAR(255)); CREATE TABLE Yield (crop_id INT, yield INT); INSERT INTO Crops (id, crop_type, country) VALUES (1, 'Corn', 'Kenya'), (2, 'Beans', 'Kenya'), (3, 'Rice', 'Kenya'); INSERT INTO Yield (crop_id, yield) VALUES (1, 500), (1, 600), (1, 700), (2, 400), (2, 500), (3, 800), (3, 700), (3, 600); | Which crops in Kenya have the lowest average yield over the past 3 years? | SELECT c.crop_type, AVG(y.yield) as avg_yield FROM Crops c INNER JOIN Yield y ON c.id = y.crop_id WHERE c.country = 'Kenya' GROUP BY c.crop_type ORDER BY avg_yield ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, actor VARCHAR(255), incident_count INT, incident_at DATETIME); | What is the number of unique threat actors that have been identified in the past month, and how many incidents have been attributed to each of them? | SELECT actor, incident_count FROM security_incidents WHERE incident_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY actor HAVING COUNT(DISTINCT incident_at) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (SaleID INT, VendorID INT, ProductID INT, ProductName VARCHAR(50), ProductCategory VARCHAR(50), Year INT, Revenue INT); INSERT INTO Sales VALUES (1, 1, 1, 'ProductA', 'CategoryA', 2020, 1000), (2, 2, 2, 'ProductB', 'CategoryB', 2021, 1500), (3, 1, 1, 'ProductA', 'CategoryA', 2020, 1500); | Find the vendor with the highest total sales for each product category, partitioned by year, ordered by product name? | SELECT ProductName, ProductCategory, Year, VendorID, MAX(Revenue) OVER (PARTITION BY ProductCategory, Year) AS HighestRevenue FROM Sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_records (id INT PRIMARY KEY, flight_number INT, year INT, flight_status VARCHAR(20)); | Insert new records into the 'safety_records' table for flights with flight numbers 1001 to 1010 in the year 2000 | INSERT INTO safety_records (id, flight_number, year, flight_status) VALUES (1, 1001, 2000, 'operational'), (2, 1002, 2000, 'operational'), (3, 1003, 2000, 'operational'), (4, 1004, 2000, 'operational'), (5, 1005, 2000, 'operational'), (6, 1006, 2000, 'operational'), (7, 1007, 2000, 'operational'), (8, 1008, 2000, 'operational'), (9, 1009, 2000, 'operational'), (10, 1010, 2000, 'operational'); | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (id INT, advisory_date DATE, destination VARCHAR(50), reason VARCHAR(200)); | How many travel advisories were issued for European destinations from 2018 to 2020? | SELECT COUNT(*) FROM travel_advisories WHERE destination LIKE 'Europe%' AND advisory_date BETWEEN '2018-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (ship_id INT, ship_name VARCHAR(255), registration_date DATE, last_maintenance_date DATE); INSERT INTO ships VALUES (1, 'Sea Giant', '2010-03-23', '2022-06-15'); | Which ships have not had maintenance in the last 6 months? | SELECT ship_id, ship_name FROM ships WHERE last_maintenance_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE port_details (id INT, name TEXT, location TEXT, num_of_berries INT); INSERT INTO port_details (id, name, location, num_of_berries) VALUES (1, 'Port A', 'Location A', 10), (2, 'Port B', 'Location B', 15); | How many ports are in the 'port_details' table? | SELECT COUNT(*) FROM port_details; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20)) | How many investments were made in 'sustainable_agriculture'? | SELECT COUNT(*) FROM investments WHERE sector = 'sustainable_agriculture' | gretelai_synthetic_text_to_sql |
CREATE TABLE vendors (id INT, name VARCHAR(50), type VARCHAR(50)); CREATE TABLE menus (id INT, vendor_id INT, category VARCHAR(50)); CREATE TABLE menu_items (id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2)); CREATE TABLE orders (id INT, menu_item_id INT, quantity INT, order_date DATE); | List all the restaurants that have a 'Gluten-Free' menu category | SELECT vendors.name FROM vendors JOIN menus ON vendors.id = menus.vendor_id JOIN menu_items ON menus.category = menu_items.category WHERE menu_items.category = 'Gluten-Free'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); INSERT INTO Hotels (hotel_id, hotel_name, country, rating) VALUES (1, 'Hotel A', 'Spain', 4.3), (2, 'Hotel B', 'Spain', 4.5), (3, 'Hotel C', 'France', 4.7); | Which countries have the highest hotel rating? | SELECT country, MAX(rating) AS max_rating FROM Hotels GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteJ (id INT PRIMARY KEY, artifact_name VARCHAR(50), date_found DATE); INSERT INTO SiteJ (id, artifact_name, date_found) VALUES (1, 'Iron Axehead', '2017-07-22'), (2, 'Leather Pouch', '2016-11-03'); | What is the oldest artifact in 'SiteJ'? | SELECT artifact_name FROM (SELECT artifact_name, ROW_NUMBER() OVER (ORDER BY date_found ASC) rn FROM SiteJ) t WHERE rn = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE industries (id INT, industry VARCHAR(255), region VARCHAR(255)); INSERT INTO industries (id, industry, region) VALUES (1, 'Industry A', 'Midwestern'), (2, 'Industry B', 'Midwestern'), (3, 'Industry C', 'Northern'); CREATE TABLE workers (id INT, worker_name VARCHAR(255), industry_id INT, is_union_member BOOLEAN); INSERT INTO workers (id, worker_name, industry_id, is_union_member) VALUES (1, 'Worker A', 1, true), (2, 'Worker B', 1, false), (3, 'Worker C', 2, true), (4, 'Worker D', 3, false); | What is the union membership rate (percentage of workers who are union members) for each industry in the Midwestern region? | SELECT i.industry, (COUNT(w.id) * 100.0 / (SELECT COUNT(*) FROM workers ww WHERE ww.industry_id = i.id)) as union_membership_rate FROM industries i JOIN workers w ON i.id = w.industry_id WHERE i.region = 'Midwestern' AND w.is_union_member = true GROUP BY i.industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_data (country VARCHAR(255), score INT); INSERT INTO country_data (country, score) VALUES ('France', 85), ('Germany', 90), ('Spain', 80); | What is the average cultural heritage preservation score for European countries? | SELECT AVG(score) FROM country_data WHERE country IN ('France', 'Germany', 'Spain', 'Italy', 'Portugal'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Department VARCHAR(50), Publications INT, PublicationYear INT); | How many graduate students in the Physics department have published more than 5 papers in the year 2019? | SELECT COUNT(StudentID) FROM GraduateStudents WHERE Department = 'Physics' AND Publications > 5 AND PublicationYear = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE forest_type (forest_type_id INT, forest_type_name TEXT, PRIMARY KEY (forest_type_id)); CREATE TABLE timber (timber_id INT, forest_type_id INT, year INT, volume INT, PRIMARY KEY (timber_id), FOREIGN KEY (forest_type_id) REFERENCES forest_type(forest_type_id)); CREATE TABLE carbon_sequestration (carbon_sequestration_id INT, forest_type_id INT, rate REAL, PRIMARY KEY (carbon_sequestration_id), FOREIGN KEY (forest_type_id) REFERENCES forest_type(forest_type_id)); | Show the average carbon sequestration rate for each forest type, along with the total timber volume, sorted by the average carbon sequestration rate in descending order. | SELECT ft.forest_type_name, AVG(cs.rate) AS avg_carbon_sequestration_rate, SUM(t.volume) AS total_timber_volume FROM forest_type ft INNER JOIN timber t ON ft.forest_type_id = t.forest_type_id INNER JOIN carbon_sequestration cs ON ft.forest_type_id = cs.forest_type_id GROUP BY ft.forest_type_name ORDER BY avg_carbon_sequestration_rate DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_energy_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), capacity FLOAT); INSERT INTO wind_energy_projects (id, project_name, city, country, capacity) VALUES (1, 'Tokyo Wind Farm', 'Tokyo', 'Japan', 25.5); | What is the total installed capacity of wind energy projects in Tokyo, Japan? | SELECT SUM(capacity) FROM wind_energy_projects WHERE city = 'Tokyo' AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (id INT PRIMARY KEY, trial_name VARCHAR(50), drug_name VARCHAR(50), trial_status VARCHAR(20), start_date DATE); CREATE TABLE trial_results (result_id INT PRIMARY KEY, trial_id INT, result VARCHAR(50)); | List drugs that have been in more than 10 clinical trials, along with their average trial outcome success rate. | SELECT ct.drug_name, COUNT(tr.trial_id) as total_trials, AVG(CASE WHEN tr.result = 'Success' THEN 1 ELSE 0 END) as success_rate FROM clinical_trials ct JOIN trial_results tr ON ct.id = tr.trial_id GROUP BY ct.drug_name HAVING total_trials > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects_4 (id INT, name VARCHAR, type VARCHAR, budget FLOAT); INSERT INTO projects_4 (id, name, type, budget) VALUES (1, 'AI for good', 'AI', 100000), (2, 'Accessible software development', 'Accessibility', 150000), (3, 'Digital divide reduction', 'Digital divide', 200000); | What is the number of projects and their total budget for each type of project? | SELECT projects_4.type, COUNT(*), SUM(projects_4.budget) FROM projects_4 GROUP BY projects_4.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE national_budget (year INT, budget FLOAT); | National security budget changes from 2018 to 2020 | SELECT year, budget - LAG(budget) OVER (ORDER BY year) AS budget_change FROM national_budget WHERE year BETWEEN 2018 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'NYC Warehouse', 'NYC'); CREATE TABLE Packages (id INT, warehouse_id INT, weight FLOAT, status VARCHAR(20)); INSERT INTO Packages (id, warehouse_id, weight, status) VALUES (1, 1, 5.0, 'shipped'), (2, 1, 3.0, 'shipped'), (3, 1, 4.0, 'processing'); | What is the total weight of packages shipped from the 'NYC' warehouse? | SELECT SUM(weight) FROM Packages WHERE warehouse_id = (SELECT id FROM Warehouse WHERE city = 'NYC') AND status = 'shipped'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), location VARCHAR(50)); INSERT INTO events (event_id, event_name, location) VALUES (1, 'Dance Performance', 'New York'); CREATE TABLE attendees (attendee_id INT, event_id INT, age INT); INSERT INTO attendees (attendee_id, event_id, age) VALUES (1, 1, 35), (2, 1, 42), (3, 1, 28), (4, 1, 32); | What is the average age of visitors who attended dance performances in New York? | SELECT AVG(age) FROM attendees JOIN events ON attendees.event_id = events.event_id WHERE events.location = 'New York' AND events.event_name = 'Dance Performance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_urbanism (property_id INT, city VARCHAR(20), score FLOAT); INSERT INTO sustainable_urbanism (property_id, city, score) VALUES (1, 'Vancouver', 85.5), (2, 'Seattle', 80.0), (3, 'NYC', 75.5); | What is the maximum sustainable urbanism score in Seattle? | SELECT MAX(score) FROM sustainable_urbanism WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_productivity (id INT, mine_id INT, type TEXT, employees INT); INSERT INTO labor_productivity (id, mine_id, type, employees) VALUES (1, 1, 'Gold', 50), (2, 2, 'Silver', 25), (3, 3, 'Bronze', 15), (4, 4, 'Platinum', 40); | What is the total number of employees in each mine type? | SELECT type, SUM(employees) as total_employees FROM labor_productivity GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatments (treatment_id INT, year INT, cost DECIMAL(10,2), condition VARCHAR(30)); INSERT INTO treatments (treatment_id, year, cost, condition) VALUES (1, 2022, 500.00, 'Anxiety'), (2, 2022, 600.00, 'Depression'), (3, 2022, 700.00, 'Anxiety'), (4, 2022, 800.00, 'PTSD'); | What is the total cost of treatment for each mental health condition in 2022? | SELECT year, condition, SUM(cost) as total_cost FROM treatments GROUP BY year, condition; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, volunteer_date DATE, hours_served INT); | Delete all records of volunteers who have not served any hours in the last year. | DELETE FROM volunteers WHERE id NOT IN (SELECT id FROM volunteers WHERE hours_served > 0 AND volunteer_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (id INT, year INT, quarter INT, projects INT); INSERT INTO military_innovation (id, year, quarter, projects) VALUES (1, 2017, 3, 20), (2, 2017, 4, 25), (3, 2018, 3, 30), (4, 2018, 4, 35), (5, 2019, 3, 40), (6, 2019, 4, 45); | Insert a new military innovation project initiated in the fourth quarter of 2021 with 50 projects. | INSERT INTO military_innovation (id, year, quarter, projects) VALUES (7, 2021, 4, 50); SELECT * FROM military_innovation; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(50), data_usage_gb FLOAT); INSERT INTO broadband_subscribers (subscriber_id, name, data_usage_gb) VALUES (1, 'Jim Brown', 80); INSERT INTO broadband_subscribers (subscriber_id, name, data_usage_gb) VALUES (2, 'Jake White', 120); | Show broadband subscribers who have used more than 100GB of data in the last month. | SELECT * FROM broadband_subscribers WHERE data_usage_gb > 100 AND data_usage_gb <= (SELECT SUM(data_usage_gb) FROM broadband_subscribers WHERE subscriber_id = B.subscriber_id AND data_usage_gb <= (SELECT MAX(data_usage_gb) FROM broadband_subscribers WHERE data_usage_gb <= (SELECT MAX(data_usage_gb) - 100 FROM broadband_subscribers) GROUP BY subscriber_id)); | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), program VARCHAR(50)); CREATE TABLE micro_investment_programs (program VARCHAR(50), is_shariah_compliant BOOLEAN); | Insert records for new clients who have recently joined the Shariah-compliant micro-investment program. | INSERT INTO clients (client_id, name, program) SELECT seq.client_id, 'Mohammed Al-Mansour', 'Shariah Micro-Investment' FROM (SELECT 1001 + ROW_NUMBER() OVER() AS client_id FROM micro_investment_programs WHERE is_shariah_compliant = TRUE LIMIT 5) AS seq; INSERT INTO micro_investment_programs (program, is_shariah_compliant) VALUES ('Shariah Micro-Investment', TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (IssueID INT, Issue VARCHAR(255), ReportedBy VARCHAR(255), ReportYear INT); | Insert a new record into the 'CulturalCompetency' table for a cultural competency issue reported by a community health worker who identifies as Afro-Latina. | INSERT INTO CulturalCompetency (IssueID, Issue, ReportedBy, ReportYear) VALUES (1, 'Language Barriers', 'Afro-Latina Community Health Worker', 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE recreation_centers (name TEXT, city TEXT, budget_allocation INT); INSERT INTO recreation_centers (name, city, budget_allocation) VALUES ('Recreation Center A', 'New York', 550000), ('Recreation Center B', 'New York', 450000); | What are the names and cities of public recreation centers that have a budget allocation over $500,000? | SELECT name, budget_allocation FROM recreation_centers WHERE city = 'New York' AND budget_allocation > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEducation (EventID int, EventName varchar(50), Attendance int, Region varchar(50)); | Insert new records for a new community education event in a different region. | INSERT INTO CommunityEducation (EventID, EventName, Attendance, Region) VALUES (3, 'Wildlife in the Andes', 80, 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); INSERT INTO Hotels (hotel_id, hotel_name, country, rating) VALUES (1, 'Hotel A', 'Japan', 4.3), (2, 'Hotel B', 'Japan', 4.5), (3, 'Hotel C', 'France', 4.7); | What is the average hotel rating in Japan? | SELECT country, AVG(rating) AS avg_rating FROM Hotels WHERE country = 'Japan' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (SiteID INT, SiteName VARCHAR(100), ArtifactID INT); INSERT INTO ExcavationSites (SiteID, SiteName, ArtifactID) VALUES (1, 'Site A', 1), (1, 'Site A', 2), (2, 'Site B', 3), (3, 'Site C', NULL), (4, 'Site D', 5), (5, 'Site E', 6); | List all excavation sites and the number of artifacts found at each site, excluding sites with no artifacts, ordered by the number of artifacts in ascending order. | SELECT SiteName, COUNT(ArtifactID) as ArtifactCount FROM ExcavationSites WHERE ArtifactID IS NOT NULL GROUP BY SiteName ORDER BY ArtifactCount ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapists (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), age INT, gender VARCHAR(10), specialty VARCHAR(50));INSERT INTO therapists (id, first_name, last_name, age, gender, specialty) VALUES (1, 'Sophia', 'Kim', 45, 'Female', 'CBT'); | Insert a new therapist record into the therapists table. | INSERT INTO therapists (id, first_name, last_name, age, gender, specialty) VALUES (2, 'Daniel', 'Patel', 50, 'Male', 'Psychotherapy'); | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research (id INT, project_name VARCHAR(100), status VARCHAR(50), country VARCHAR(50)); INSERT INTO genetic_research (id, project_name, status, country) VALUES (1, 'ProjectX', 'Ongoing', 'MX'); INSERT INTO genetic_research (id, project_name, status, country) VALUES (2, 'ProjectY', 'Completed', 'MX'); INSERT INTO genetic_research (id, project_name, status, country) VALUES (3, 'ProjectZ', 'Ongoing', 'CA'); | How many genetic research projects are ongoing in Mexico? | SELECT COUNT(*) FROM genetic_research WHERE status = 'Ongoing' AND country = 'MX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id VARCHAR(10), port_id VARCHAR(10)); INSERT INTO vessels (vessel_id, port_id) VALUES ('vessel_z', 'port_a'), ('vessel_x', 'port_b'), ('vessel_q', 'port_d'), ('vessel_y', 'port_c'); | Which ports does vessel_q travel to? | SELECT DISTINCT port_id FROM vessels WHERE vessel_id = 'vessel_q'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Race VARCHAR(25), Gender VARCHAR(10)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (1, 45, 'Native American', 'Female'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (2, 50, 'Pacific Islander', 'Male'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (3, 35, 'Latinx', 'Female'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (4, 40, 'Caucasian', 'Non-binary'); | What is the distribution of community health workers by age and gender? | SELECT Age, Gender, COUNT(*) FROM CommunityHealthWorkers GROUP BY Age, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT, Name TEXT, CargoWeight INT, SafetyScore INT, DockedAt DATETIME); INSERT INTO Vessels (ID, Name, CargoWeight, SafetyScore, DockedAt) VALUES (1, 'Vessel1', 5000, 80, '2022-01-01 10:00:00'), (2, 'Vessel2', 6000, 85, '2022-01-05 14:30:00'), (3, 'Vessel3', 7000, 90, '2022-02-01 11:00:00'); CREATE TABLE Ports (ID INT, Name TEXT); INSERT INTO Ports (ID, Name) VALUES (1, 'Oakland'), (2, 'San_Francisco'); | What is the minimum safety score of vessels that docked in the port of Oakland in the last month and have a cargo weight of more than 5000 tons? | SELECT MIN(SafetyScore) FROM Vessels WHERE CargoWeight > 5000 AND DockedAt >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND Ports.Name = 'Oakland'; | gretelai_synthetic_text_to_sql |
CREATE TABLE non_profit_orgs (name TEXT, state TEXT, focus_area TEXT, funding FLOAT); INSERT INTO non_profit_orgs (name, state, focus_area, funding) VALUES ('EcoGuardians', 'California', 'Climate Change', 350000), ('Green Earth', 'California', 'Climate Change', 500000), ('Carbon Reduction Alliance', 'California', 'Climate Change', 400000); | What is the average amount of funding received by non-profit organizations focused on climate change in the state of California? | SELECT AVG(funding) FROM non_profit_orgs WHERE state = 'California' AND focus_area = 'Climate Change'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalEvents (EventName VARCHAR(255), Country VARCHAR(255), Attendees INT); INSERT INTO CulturalEvents (EventName, Country, Attendees) VALUES ('Asian Cultural Festival', 'China', 800), ('Asian Heritage Week', 'Japan', 600), ('Asian Art Exhibition', 'South Korea', 700), ('Asian Film Festival', 'India', 900), ('Asian Music Festival', 'Indonesia', 500); | What is the percentage of cultural events in Asia with more than 500 attendees? | SELECT EventName, Country, Attendees, (COUNT(*) OVER (PARTITION BY Country) - COUNT(CASE WHEN Attendees > 500 THEN 1 END) OVER (PARTITION BY Country)) * 100.0 / COUNT(*) OVER (PARTITION BY Country) AS PercentageMoreThan500 FROM CulturalEvents WHERE Country = 'Asia'; | 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.