context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE CosmeticsSales (productID INT, productName VARCHAR(50), category VARCHAR(50), country VARCHAR(50), isHalal BOOLEAN, price DECIMAL(5,2), quantity INT, saleDate DATE); INSERT INTO CosmeticsSales (productID, productName, category, country, isHalal, price, quantity, saleDate) VALUES (1, 'Lipstick', 'Cosmetics'... | How many units of halal cosmetics were sold in Saudi Arabia in 2021? | SELECT SUM(quantity) FROM CosmeticsSales WHERE country = 'Saudi Arabia' AND isHalal = TRUE AND YEAR(saleDate) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment_factory_workers (factory_id INT, worker_id INT, worker_name VARCHAR(255), role VARCHAR(255), country VARCHAR(255)); INSERT INTO garment_factory_workers (factory_id, worker_id, worker_name, role, country) VALUES (1, 1, 'Rajesh Patel', 'sewer', 'India'); INSERT INTO garment_factory_workers (factory_i... | Which role has the highest number of workers in a garment factory in India? | SELECT role, COUNT(DISTINCT worker_id) AS worker_count FROM garment_factory_workers WHERE factory_id = 1 AND country = 'India' GROUP BY role ORDER BY worker_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_fleet (id INT, ship_name VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO cargo_fleet (id, ship_name, type, capacity) VALUES (1, 'Aquamarine', 'Container', 5000), (2, 'Bluewhale', 'Bulk', 8000), (3, 'Starfish', 'Tanker', 3000), (4, 'Seahorse', 'Container', 6000); | What is the average capacity of container ships in the 'cargo_fleet' table? | SELECT AVG(capacity) FROM cargo_fleet WHERE type = 'Container'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ai (hotel_id INT, hotel_name TEXT, region TEXT, ai_adoption BOOLEAN); INSERT INTO hotel_ai (hotel_id, hotel_name, region, ai_adoption) VALUES (1, 'Hotel Royal', 'Asia', true), (2, 'Palace Hotel', 'Europe', false), (3, 'Beach Resort', 'Americas', true), (4, 'Luxury Villa', 'Europe', true), (5, 'Mounta... | Hotel AI adoption rate by region? | SELECT region, AVG(ai_adoption) FROM hotel_ai GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE certifications (certification_id INT, certification_name TEXT); INSERT INTO certifications (certification_id, certification_name) VALUES (1, 'Fair Trade'), (2, 'GOTS Organic'), (3, 'B Corp'); CREATE TABLE garments (garment_id INT, garment_name TEXT, production_cost FLOAT, certification_id INT); INSERT INTO... | What is the minimum production cost of GOTS Organic certified garments across all factories? | SELECT MIN(g.production_cost) FROM garments g WHERE g.certification_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE penalties (id INT, team TEXT, season INT, minutes INT); INSERT INTO penalties (id, team, season, minutes) VALUES (1, 'Ice Warriors', 2021, 150); INSERT INTO penalties (id, team, season, minutes) VALUES (2, 'Blizzard', 2021, 120); | What is the total number of penalty minutes for the 'Ice Warriors' in the 2021 season? | SELECT team, SUM(minutes) FROM penalties WHERE team = 'Ice Warriors' AND season = 2021 GROUP BY team; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_sources (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO energy_sources (id, name, country, capacity) VALUES (1, 'Wind', 'France', 10000); INSERT INTO energy_sources (id, name, country, capacity) VALUES (2, 'Solar', 'France', 15000); INSERT INTO energy_sources (id, name, country, capac... | List all distinct energy types and their total capacity in France | SELECT DISTINCT name, SUM(capacity) FROM energy_sources WHERE country = 'France' GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), num_primary_care_physicians INT); INSERT INTO Hospitals (name, location, type, num_primary_care_physicians) VALUES ('Rural General Hospital', 'Springfield', 'Hospital', 50); CREATE TABLE Clinics (name VARCHAR(255), location VARCHAR(255... | How many primary care physicians work in hospitals and clinics in rural areas? | SELECT SUM(num_primary_care_physicians) FROM Hospitals WHERE location LIKE '%rural%' UNION ALL SELECT SUM(num_primary_care_physicians) FROM Clinics WHERE location LIKE '%rural%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation (id INT, project_name VARCHAR(50), country VARCHAR(50), year INT, cost FLOAT); INSERT INTO climate_adaptation (id, project_name, country, year, cost) VALUES (1, 'Drought Resistance', 'Brazil', 2016, 500000); | What is the average cost of climate adaptation projects in Latin America for each year since 2016? | SELECT year, AVG(cost) FROM climate_adaptation WHERE country LIKE '%Latin%' GROUP BY year ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_hotels (hotel_id INT, hotel_name TEXT, country TEXT, listings INT); INSERT INTO ota_hotels (hotel_id, hotel_name, country, listings) VALUES (1, 'Marina Bay Sands', 'Singapore', 900), (2, 'Grand Hyatt Tokyo', 'Japan', 800), (3, 'Four Seasons Mumbai', 'India', 700), (4, 'The Landmark Mandarin Oriental', ... | What is the maximum number of listings per hotel in 'APAC'? | SELECT region, MAX(listings) FROM ota_hotels WHERE region = 'APAC' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft_Manufacturing(manufacturer VARCHAR(20), year INT, quantity INT); INSERT INTO Spacecraft_Manufacturing(manufacturer, year, quantity) VALUES ('SpaceCorp', 2015, 120), ('SpaceCorp', 2016, 150), ('SpaceCorp', 2017, 175), ('Galactic Inc', 2015, 110), ('Galactic Inc', 2016, 145), ('Galactic Inc', 2017... | Retrieve the number of spacecraft manufactured by SpaceCorp in 2017 | SELECT SUM(quantity) FROM Spacecraft_Manufacturing WHERE manufacturer = 'SpaceCorp' AND year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (worker_id INT, name TEXT, mental_health_parity_score INT); INSERT INTO mental_health_parity (worker_id, name, mental_health_parity_score) VALUES (1, 'James', 95), (2, 'Sophia', 90), (3, 'Carlos', 85), (4, 'Maria', 92), (5, 'David', 98), (6, 'Lisa', 88); | Identify the top 3 community health workers with the highest mental health parity scores, ordered by score in descending order. | SELECT worker_id, name, mental_health_parity_score FROM (SELECT worker_id, name, mental_health_parity_score, ROW_NUMBER() OVER (ORDER BY mental_health_parity_score DESC) as rn FROM mental_health_parity) t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO countries VALUES (1, 'Nigeria', 'Africa'); INSERT INTO countries VALUES (2, 'Brazil', 'South America'); CREATE TABLE factories (factory_id INT, name VARCHAR(255), location VARCHAR(255), country_id INT, labor_rating INT); INSERT... | What is the average labor rating for factories in each country? | SELECT countries.name, AVG(factories.labor_rating) FROM countries JOIN factories ON countries.country_id = factories.country_id GROUP BY countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (id INT, program_name TEXT, location TEXT, facilitator TEXT, participants INT); INSERT INTO restorative_justice_programs (id, program_name, location, facilitator, participants) VALUES (1, 'Victim Offender Mediation', 'Chicago', 'John Smith', 15), (2, 'Restorative Circles', 'Los... | What is the average number of participants in restorative justice programs, by location, for programs facilitated by 'Ahmed Rami'? | SELECT location, AVG(participants) AS avg_participants FROM restorative_justice_programs WHERE facilitator = 'Ahmed Rami' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title TEXT, rating TEXT); | Remove all movies with a rating under 'PG' | DELETE FROM movies WHERE rating < 'PG'; | gretelai_synthetic_text_to_sql |
CREATE TABLE middle_east_oil_fields (field_name TEXT, oil_production INTEGER); INSERT INTO middle_east_oil_fields (field_name, oil_production) VALUES ('Field1', 500000), ('Field2', 600000), ('Field3', 300000), ('Field4', 400000); | What are the names of the oil fields in the Middle East with the highest and lowest production figures? | SELECT field_name, MAX(oil_production) AS max_production, MIN(oil_production) AS min_production FROM middle_east_oil_fields; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Country VARCHAR(20), Gender VARCHAR(6)); INSERT INTO Players (PlayerID, Age, Country, Gender) VALUES (1, 25, 'Canada', 'Female'); | Which country has the highest percentage of female players? | SELECT Country, ROUND(100.0 * SUM(CASE WHEN Gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*), 2) AS FemalePercentage FROM Players GROUP BY Country ORDER BY FemalePercentage DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE course_enrollment (student_id INT, course_id TEXT, enrollment_status TEXT); INSERT INTO course_enrollment (student_id, course_id, enrollment_status) VALUES (1, 'Math 101', 'enrolled'), (2, 'Math 101', 'withdrawn'), (3, 'English 101', 'enrolled'), (4, 'English 101', 'enrolled'); CREATE TABLE open_pedagogy_c... | What is the number of students who have withdrawn from each open pedagogy course? | SELECT c.course_name, COUNT(e.student_id) as withdrawals FROM course_enrollment e JOIN open_pedagogy_courses c ON e.course_id = c.course_id WHERE e.enrollment_status = 'withdrawn' GROUP BY c.course_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Airline_Companies (Company_Name VARCHAR(50), Region_Name VARCHAR(20)); INSERT INTO Airline_Companies (Company_Name, Region_Name) VALUES ('ABC Airlines', 'Asia'), ('DEF Airlines', 'Europe'), ('GHI Airlines', 'North America'); CREATE TABLE Emissions (Company_Name VARCHAR(50), Year INT, CO2_Emissions INT); I... | What is the total CO2 emissions of the airline industry by region from 2010 to 2019? | SELECT E.Region_Name, E.Year, SUM(E.CO2_Emissions) AS Total_Emissions FROM Emissions E JOIN Airline_Companies AC ON E.Company_Name = AC.Company_Name GROUP BY E.Region_Name, E.Year ORDER BY E.Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop (id INT, type VARCHAR(255), temperature FLOAT); INSERT INTO crop (id, type, temperature) VALUES (1, 'corn', 22.5), (2, 'soybean', 20.0), (3, 'cotton', 24.3), (4, 'corn', 25.0), (5, 'soybean', 23.5); | Find the average temperature for all crops | SELECT AVG(temperature) FROM crop; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (id INT, product VARCHAR(255), sales_amount DECIMAL(10, 2), is_recyclable BOOLEAN, has_natural_ingredients BOOLEAN); INSERT INTO sales_data (id, product, sales_amount, is_recyclable, has_natural_ingredients) VALUES (1, 'Moisturizer', 25.99, true, true), (2, 'Cleanser', 15.99, false, false), (3, ... | Calculate the total sales of products with a recyclable package and natural ingredients. | SELECT SUM(sales_amount) FROM sales_data WHERE is_recyclable = true AND has_natural_ingredients = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, name VARCHAR(50), is_recurring BOOLEAN, city VARCHAR(50)); CREATE TABLE donations (donation_id INT, donor_id INT, amount DECIMAL(10,2), event_type VARCHAR(50)); INSERT INTO donors (donor_id, name, is_recurring, city) VALUES (1, 'Jane Smith', TRUE, 'San Francisco'); INSERT INTO donatio... | What is the total amount donated by recurring donors for dance performances in San Francisco? | SELECT SUM(d.amount) AS total_donated FROM donations d JOIN donors don ON d.donor_id = don.donor_id WHERE don.city = 'San Francisco' AND don.is_recurring = TRUE AND d.event_type = 'Dance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, autonomous_driving BOOLEAN); INSERT INTO research_papers (id, title, publication_year, autonomous_driving) VALUES (1, 'Autonomous Driving and AI', 2020, true), (2, 'Hybrid Vehicle Efficiency', 2021, false), (3, 'EV Charging Infrastructure',... | Determine the total number of autonomous driving research papers published in 2021 | SELECT COUNT(*) FROM research_papers WHERE publication_year = 2021 AND autonomous_driving = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE content_locations (id INT, content_id INT, country VARCHAR(50)); INSERT INTO content_locations (id, content_id, country) VALUES (1, 1, 'USA'), (2, 1, 'Canada'), (3, 2, 'France'); | How many unique countries are represented in the 'content_locations' table? | SELECT COUNT(DISTINCT country) FROM content_locations; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_projects (project_id INT, project_cost FLOAT, state VARCHAR(50), start_date DATE); INSERT INTO construction_projects (project_id, project_cost, state, start_date) VALUES (15, 500000, 'California', '2021-07-01'); INSERT INTO construction_projects (project_id, project_cost, state, start_date) VA... | What was the minimum cost of construction projects in the state of California in Q3 2021? | SELECT MIN(project_cost) FROM construction_projects WHERE state = 'California' AND QUARTER(start_date) = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (strain_id INT, name TEXT, state TEXT); INSERT INTO strains (strain_id, name, state) VALUES (1, 'Strain X', 'Washington'), (2, 'Strain Y', 'Washington'), (3, 'Strain Z', 'California'); CREATE TABLE sales (sale_id INT, strain_id INT, price DECIMAL, grams INT); INSERT INTO sales (sale_id, strain_id, ... | What is the average price per gram of cannabis for each strain in Washington, grouped by strain? | SELECT s.name, AVG(s.price / s.grams) AS avg_price_per_gram FROM strains st JOIN sales s ON st.strain_id = s.strain_id WHERE st.state = 'Washington' GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE risk_assessments(id INT, country VARCHAR(255), year INT, score FLOAT); | What are the geopolitical risk assessment scores for African countries in 2020? | SELECT country, score FROM risk_assessments WHERE year = 2020 AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (app_id INT, app_name TEXT, fairness_score FLOAT); CREATE TABLE ai_safety (app_id INT, app_name TEXT, fairness_score FLOAT); | What is the total number of AI models in the 'creative_ai' and 'ai_safety' tables that have a fairness score greater than 0.7? | SELECT COUNT(*) FROM (SELECT app_id FROM creative_ai WHERE fairness_score > 0.7 UNION ALL SELECT app_id FROM ai_safety WHERE fairness_score > 0.7) AS high_fairness_models; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (id, name, location, depth) VALUES (1, 'MPA 1', 'Pacific Ocean', 123.4), (2, 'MPA 2', 'Atlantic Ocean', 150.0), (3, 'MPA 3', 'Indian Ocean', 75.0); | Update the depth of all marine protected areas in the Indian Ocean by 10%. | UPDATE marine_protected_areas SET depth = depth * 1.1 WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (pid INT, name TEXT, organic BOOLEAN, locally_sourced BOOLEAN);INSERT INTO Products VALUES (1, 'ProductA', true, true), (2, 'ProductB', false, true), (3, 'ProductC', true, false), (4, 'ProductD', false, false); | Find the total number of products that are not both organic and locally sourced. | SELECT COUNT(*) FROM Products WHERE organic = false OR locally_sourced = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage ( id INT PRIMARY KEY, location VARCHAR(255), usage_date DATE, water_amount INT); | Update water usage metrics for location 'San Francisco' to reflect a 10% increase | UPDATE water_usage SET water_amount = water_amount * 1.10 WHERE location = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE juvenile_offenders (offender_id INT, state VARCHAR(20), program_date DATE); INSERT INTO juvenile_offenders (offender_id, state, program_date) VALUES (1, 'Florida', '2021-01-01'), (2, 'Florida', '2020-12-01'); | What is the number of juvenile offenders in Florida who have participated in rehabilitation programs in the past year? | SELECT COUNT(*) FROM juvenile_offenders WHERE state = 'Florida' AND program_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, country VARCHAR(50), location VARCHAR(50), score INT); INSERT INTO student_mental_health (student_id, country, location, score) VALUES (1, 'USA', 'Rural', 75), (2, 'Canada', 'Rural', 80), (3, 'Mexico', 'Rural', 70), (4, 'Brazil', 'Rural', 60); | Which countries have the highest and lowest average mental health scores for students in rural areas? | SELECT country, AVG(score) as avg_score FROM student_mental_health WHERE location = 'Rural' GROUP BY country ORDER BY avg_score DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE post_engagements (user_id INT, post_id INT, engagement_date DATE, post_topic VARCHAR(50)); | Show the number of unique users who engaged with posts about 'social media trends' in the post_engagements table in the last week. | SELECT COUNT(DISTINCT user_id) as unique_users FROM post_engagements WHERE post_topic = 'social media trends' AND engagement_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE driver (driver_id INT, name TEXT);CREATE TABLE bus_trip (trip_id INT, driver_id INT, route_id INT, distance FLOAT); | Who are the top 5 drivers with the most trips in the 'bus' system? | SELECT d.name, COUNT(*) FROM driver d INNER JOIN bus_trip bt ON d.driver_id = bt.driver_id GROUP BY d.name ORDER BY COUNT(*) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE workshops (workshop_id INT, region_id INT, workshop_topic VARCHAR(255)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'); INSERT INTO workshops (workshop_id, region_id, workshop_topic) VALUES (1, 1, 'Pyth... | How many professional development workshops were offered in each region, and what were their respective topics? | SELECT r.region_name, COUNT(w.workshop_id) as num_workshops, w.workshop_topic FROM regions r JOIN workshops w ON r.region_id = w.region_id GROUP BY r.region_name, w.workshop_topic; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, state VARCHAR(255), cause VARCHAR(255)); INSERT INTO volunteers (id, state, cause) VALUES (1, 'New York', 'animals'), (2, 'New York', 'education'), (3, 'New York', 'healthcare'); | What is the total number of volunteers for each cause in New York? | SELECT cause, COUNT(*) FROM volunteers WHERE state = 'New York' GROUP BY cause; | gretelai_synthetic_text_to_sql |
CREATE TABLE driver (driver_id INT, name TEXT);CREATE TABLE trip (trip_id INT, driver_id INT, distance FLOAT); | Who are the top 3 drivers with the most trips? | SELECT d.name, COUNT(*) FROM driver d INNER JOIN trip t ON d.driver_id = t.driver_id GROUP BY d.name ORDER BY COUNT(*) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE worker_welfare_records (brand VARCHAR(50), score DECIMAL(3,2), audit_year INT); INSERT INTO worker_welfare_records (brand, score, audit_year) VALUES ('BrandD', 7.5, 2020), ('BrandE', 8.2, 2020), ('BrandF', 7.8, 2020); | Update the worker_welfare_records table with the latest working conditions audit data for 2022. | UPDATE worker_welfare_records SET score = 7.6, audit_year = 2022 WHERE brand = 'BrandD'; UPDATE worker_welfare_records SET score = 8.3, audit_year = 2022 WHERE brand = 'BrandE'; UPDATE worker_welfare_records SET score = 8.1, audit_year = 2022 WHERE brand = 'BrandF'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouses (warehouse_id INT, name TEXT, capacity INT, country TEXT); INSERT INTO Warehouses (warehouse_id, name, capacity, country) VALUES (1, 'Warehouse A', 5000, 'Canada'), (2, 'Warehouse B', 7000, 'USA'), (3, 'Warehouse C', 6000, 'USA'); | What is the total capacity of all warehouses located in the USA? | SELECT SUM(capacity) FROM Warehouses WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (project_name TEXT, location TEXT, amount INTEGER); INSERT INTO climate_finance (project_name, location, amount) VALUES ('Project A', 'Asia', 500000), ('Project B', 'Africa', 300000); | What is the total climate finance provided to projects in 'Asia' and 'Africa'? | SELECT SUM(amount) FROM climate_finance WHERE location IN ('Asia', 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE GH_Well (Well_ID VARCHAR(10), Production_Rate INT); INSERT INTO GH_Well (Well_ID, Production_Rate) VALUES ('W001', 200), ('W002', 300); | What is the maximum production rate in the 'GH_Well' table? | SELECT MAX(Production_Rate) FROM GH_Well; | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitats (id INT, name VARCHAR(20)); INSERT INTO Habitats (id, name) VALUES (1, 'Habitat A'), (2, 'Habitat B'), (3, 'Habitat C'), (4, 'Habitat D'), (5, 'Habitat E'); CREATE TABLE Animals (id INT, name VARCHAR(20), habitat_id INT); INSERT INTO Animals (id, name, habitat_id) VALUES (1, 'Tiger', 3), (2, 'Elep... | What is the minimum number of animals in 'Habitat E'? | SELECT MIN(num_animals) FROM (SELECT habitat_id, COUNT(*) as num_animals FROM Animals GROUP BY habitat_id HAVING habitat_id = 5) AS subquery | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY, exhibition_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255)); | List the exhibitions that have the same city | SELECT exhibition_name FROM exhibitions GROUP BY city HAVING COUNT(exhibition_id) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_studies (id INT, study_title VARCHAR, publication_year INT, num_participants INT); | Find the autonomous driving research studies published in 2021, ordered by the number of participants in descending order. | SELECT * FROM research_studies WHERE publication_year = 2021 ORDER BY num_participants DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (ConcertID INT PRIMARY KEY, ConcertName VARCHAR(100), Location VARCHAR(100), TicketsSold INT); INSERT INTO Concerts (ConcertID, ConcertName, Location, TicketsSold) VALUES (1, 'Concert 1', 'California', 500), (2, 'Concert 2', 'New York', 700), (3, 'Concert 3', 'California', 800); | How many tickets were sold for concerts in California? | SELECT SUM(TicketsSold) FROM Concerts WHERE Location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE la_crime_stats (id INT, crime_type TEXT, crime_date DATE); INSERT INTO la_crime_stats (id, crime_type, crime_date) VALUES (1, 'Theft', '2021-01-01'), (2, 'Vandalism', '2021-02-01'), (3, 'Assault', '2021-03-01'); | What is the total crime count in Los Angeles in 2021? | SELECT COUNT(*) FROM la_crime_stats WHERE YEAR(crime_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales(sale_id INT, product_id INT, quantity INT, sale_price DECIMAL(10, 2), sale_date DATE); CREATE TABLE ingredient_sourcing(ingredient_id INT, product_id INT, country VARCHAR(50)); CREATE TABLE cosmetics_products(product_id INT, product_name VARCHAR(100), category VARCHAR(50)); | What is the total consumer spending on cosmetics products in the past year for each country? | SELECT ingredient_sourcing.country, SUM(sales.quantity * sales.sale_price) as total_spending FROM sales JOIN ingredient_sourcing ON sales.product_id = ingredient_sourcing.product_id JOIN cosmetics_products ON ingredient_sourcing.product_id = cosmetics_products.product_id WHERE sales.sale_date >= DATE_SUB(CURRENT_DATE, ... | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_tours (tour_id INT, location TEXT, revenue FLOAT, date DATE); INSERT INTO heritage_tours (tour_id, location, revenue, date) VALUES (1, 'Colosseum', 35000, '2021-09-01'), (2, 'Leaning Tower', 20000, '2021-10-01'); | What is the revenue generated by cultural heritage tours in Italy last quarter? | SELECT SUM(revenue) FROM heritage_tours WHERE location = 'Italy' AND date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), type VARCHAR(10), donation_amount DECIMAL(10, 2)); | What is the total donation amount and average donation amount for each state in the 'Donors' and 'Donations' tables? | SELECT d.state, SUM(Donations.amount) as total_donations, AVG(donation_amount) as avg_donation FROM Donors JOIN Donations ON Donors.id = Donations.donor_id GROUP BY d.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (id INT, event_name VARCHAR(50), date DATE, venue_id INT); CREATE TABLE venues (id INT, name VARCHAR(50), capacity INT); INSERT INTO esports_events (id, event_name, date, venue_id) VALUES (1, 'GameX', '2023-06-01', 101); INSERT INTO venues (id, name, capacity) VALUES (101, 'Staples Center', ... | What is the total capacity of all venues that have hosted esports events? | SELECT SUM(capacity) FROM venues WHERE id IN (SELECT venue_id FROM esports_events); | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerTransactions (CustomerID int, TransactionID int, Amount decimal(18,2)); INSERT INTO CustomerTransactions (CustomerID, TransactionID, Amount) VALUES (1, 1, 5000.00), (1, 2, 7000.00); | Calculate the average transaction value for each customer in the 'CustomerTransactions' table. | SELECT CustomerID, AVG(Amount) FROM CustomerTransactions GROUP BY CustomerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_mediterranean (species_name TEXT); INSERT INTO marine_species_mediterranean (species_name) VALUES ('Dolphin'), ('Swordfish'), ('Tuna'), ('Bluefin Tuna'); | How many marine species are there in total in the Mediterranean Sea? | SELECT COUNT(*) FROM marine_species_mediterranean; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment_prices (price DECIMAL(10,2), category VARCHAR(50), date DATE); | What is the average price of garments by category in H1 2022? | SELECT category, AVG(price) AS avg_price FROM garment_prices WHERE date >= '2022-01-01' AND date < '2022-07-01' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Gender VARCHAR(10), Genre VARCHAR(50)); INSERT INTO Artists VALUES (1, 'Taylor Swift', 'Female', 'Country'), (2, 'Carrie Underwood', 'Female', 'Country'), (3, 'Garth Brooks', 'Male', 'Country'); | What is the average age of all female country music artists? | SELECT AVG(EXTRACT(YEAR FROM CURRENT_DATE - Artists.BirthDate)) AS AvgAge FROM Artists WHERE Artists.Gender = 'Female' AND Artists.Genre = 'Country'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensary_sales (id INT, region VARCHAR(255), strain VARCHAR(255), quantity INT, revenue FLOAT); | What is the total revenue for each region in 'dispensary_sales' table? | SELECT region, SUM(revenue) as total_revenue FROM dispensary_sales GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE collective_bargaining (union_name VARCHAR(20), company_name VARCHAR(20), start_date DATE); | Insert a new record into the "collective_bargaining" table with the following values: "Union A", "Company XYZ", "2022-01-01" | INSERT INTO collective_bargaining (union_name, company_name, start_date) VALUES ('Union A', 'Company XYZ', '2022-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE tech_initiatives (id INT, initiative_name VARCHAR(255), location VARCHAR(255), accessibility_score FLOAT); CREATE VIEW latam_caribbean AS SELECT * FROM tech_initiatives WHERE location IN ('Latin America', 'Caribbean'); | What is the average accessibility score for technology initiatives in Latin America and the Caribbean? | SELECT AVG(accessibility_score) FROM latam_caribbean; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO products (product_id, product_name, category, price, quantity) VALUES (1, 'Sativa Flower', 'Flower', 12.50, 250), (2, 'Indica Flower', 'Flower', 13.00, 300), (3, 'Hybrid Flower', 'Flower... | Find the total sales revenue and quantity sold for each product category | SELECT category, SUM(price * quantity) AS total_sales_revenue, SUM(quantity) AS total_quantity_sold FROM products GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_abbr CHAR(2), state_name VARCHAR(50)); INSERT INTO states (state_abbr, state_name) VALUES ('CA', 'California'), ('CO', 'Colorado'), ('OR', 'Oregon'); CREATE TABLE wholesale_prices (state_abbr CHAR(2), price DECIMAL(5,2)); INSERT INTO wholesale_prices (state_abbr, price) VALUES ('CA', 2000), (... | Which state has the highest average wholesale price for cannabis flower? | SELECT state_name, AVG(price) FROM wholesale_prices wp JOIN states s ON wp.state_abbr = s.state_abbr GROUP BY state_abbr ORDER BY AVG(price) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name VARCHAR, location VARCHAR, preservation_program VARCHAR); INSERT INTO heritage_sites (id, name, location, preservation_program) VALUES (1, 'Heritage Site A', 'City A', 'Language Preservation'), (2, 'Heritage Site B', 'City B', 'Art Preservation'); CREATE TABLE preservation_stat... | What is the name and location of all heritage sites with language preservation programs? | SELECT heritage_sites.name, heritage_sites.location FROM heritage_sites INNER JOIN preservation_status ON heritage_sites.preservation_program = preservation_status.status WHERE preservation_status.status = 'Active'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plants(plant_id INT, plant_name TEXT, drought_impact FLOAT); INSERT INTO water_treatment_plants(plant_id, plant_name, drought_impact) VALUES (1, 'Plant A', 0.75), (2, 'Plant B', 0.88), (3, 'Plant C', 0.62); | List all water treatment plants with drought impact assessments above 0.8? | SELECT plant_id, plant_name FROM water_treatment_plants WHERE drought_impact > 0.8; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_depth (species_name VARCHAR(255), phylum VARCHAR(255), max_depth FLOAT); INSERT INTO marine_species_depth (species_name, phylum, max_depth) VALUES ('Giant Squid', 'Cephalopoda', 3000), ('Blue Whale', 'Mammalia', 300), ('Anglerfish', 'Vertebrata', 2000); | What is the maximum depth reached by any marine species, grouped by phylum?" | SELECT phylum, MAX(max_depth) as max_depth FROM marine_species_depth GROUP BY phylum; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_projects (project_id INT, country VARCHAR(50), capacity_mw FLOAT); INSERT INTO hydro_projects (project_id, country, capacity_mw) VALUES (1, 'Canada', 1200.5), (2, 'Colombia', 1500.2), (3, 'Canada', 1800.9), (4, 'Colombia', 1000.6); | What is the total capacity (in MW) of hydroelectric power projects in Canada and Colombia? | SELECT SUM(capacity_mw) FROM hydro_projects WHERE country IN ('Canada', 'Colombia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_humidity (crop_type TEXT, date DATE, humidity INTEGER); | What is the average humidity level for each crop type in the past month? | SELECT crop_type, AVG(humidity) as avg_humidity FROM crop_humidity WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_speed_tests (test_id INT, subscriber_id INT, test_date DATE, download_speed FLOAT, upload_speed FLOAT); | What is the average download speed for subscribers who have had more than 3 speed tests in 2022? | SELECT subscriber_id, AVG(download_speed) as avg_download_speed FROM broadband_speed_tests WHERE test_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY subscriber_id HAVING COUNT(subscriber_id) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (OID VARCHAR(10), Labor_Conditions VARCHAR(20)); INSERT INTO Factories (OID, Labor_Conditions) VALUES ('001', 'Unfair'), ('002', 'Fair'), ('003', 'Unfair'); | Update labor conditions in the factory with OID 001 to fair. | UPDATE Factories SET Labor_Conditions = 'Fair' WHERE OID = '001'; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_grants (id INT, faculty_id INT, department VARCHAR(50), grant_amount DECIMAL(10,2), grant_date DATE); | What is the total number of research grants awarded to each gender? | SELECT gender, COUNT(*) FROM research_grants rg JOIN faculty f ON rg.faculty_id = f.id GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, state VARCHAR(255)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, state) VALUES (1, 50.5, 'Texas'), (2, 60.3, 'Texas'), (3, 40.2, 'Texas'), (4, 25, 'Florida'), (5, 32, 'Florida'); CREATE TABLE states (state_id INT, state VARCHAR(255)); ... | What is the average data usage for mobile subscribers in each state? | SELECT AVG(ms.data_usage), s.state FROM mobile_subscribers ms JOIN states s ON ms.state = s.state GROUP BY s.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE article_word_count (article_id INT, word_count INT, category VARCHAR(20)); INSERT INTO article_word_count (article_id, word_count, category) VALUES (1, 500, 'Politics'), (2, 800, 'Sports'); | What is the distribution of article word counts in the 'article_word_count' table? | SELECT word_count, COUNT(*) as article_count FROM article_word_count GROUP BY word_count; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (account_id INT, customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2)); INSERT INTO accounts (account_id, customer_id, account_type, balance) VALUES (1, 1, 'Savings', 12000.00), (2, 1, 'Checking', 5000.00), (3, 2, 'Savings', 8000.00), (4, 2, 'Checking', 3000.00); | How many customers have a balance greater than $10,000 in their savings account? | SELECT COUNT(*) FROM accounts WHERE account_type = 'Savings' AND balance > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification (country VARCHAR(50), project_type VARCHAR(50), project_start_date DATE); | Compare the economic diversification efforts of two countries, one in Africa and one in Asia, by showing the number and type of projects in each country. | SELECT 'African Country' as country, project_type, COUNT(*) as project_count FROM economic_diversification WHERE country = 'African Country' UNION ALL SELECT 'Asian Country' as country, project_type, COUNT(*) as project_count FROM economic_diversification WHERE country = 'Asian Country'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, Hours INT, VolunteerDate DATE); | Find the top 3 programs with the most volunteer hours in the past year, and the total volunteer hours for each program. | SELECT Programs.ProgramName, SUM(Volunteers.Hours) AS TotalHours FROM Programs JOIN Volunteers ON Programs.ProgramID = Volunteers.ProgramID WHERE VolunteerDate >= DATEADD(year, -1, GETDATE()) GROUP BY Programs.ProgramName ORDER BY TotalHours DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE age_groups (age_group_id INT, age_group_range VARCHAR(255)); CREATE TABLE primary_care_clinics (clinic_id INT, clinic_name VARCHAR(255), appointment_wait_time INT, age_group_id INT); INSERT INTO age_groups (age_group_id, age_group_range) VALUES (1, '0-18'), (2, '19-30'), (3, '31-50'), (4, '51-80'), (5, '80... | What is the average waiting time for appointments in primary care clinics, for each age group? | SELECT age_group_range, AVG(appointment_wait_time) as avg_wait_time FROM primary_care_clinics JOIN age_groups ON primary_care_clinics.age_group_id = age_groups.age_group_id GROUP BY age_group_range; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_cars (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, horsepower INT, is_electric BOOLEAN); | What is the total horsepower of electric vehicles in the 'green_cars' table by year? | SELECT year, SUM(horsepower) as total_hp FROM green_cars WHERE is_electric = TRUE GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE certifications (certification_id INT, hotel_id INT, issue_date DATE); CREATE TABLE hotels (hotel_id INT, name TEXT, country TEXT, stars FLOAT); CREATE TABLE countries (country_id INT, name TEXT, region TEXT); | Count the number of hotels in each country that have received a sustainable tourism certification. | SELECT h.country, COUNT(DISTINCT c.hotel_id) AS certified_hotels FROM hotels h INNER JOIN certifications c ON h.hotel_id = c.hotel_id GROUP BY h.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_types (incident_id INT, incident_date DATE, incident_type VARCHAR(50), region VARCHAR(50)); INSERT INTO incident_types (incident_id, incident_date, incident_type, region) VALUES (1, '2021-10-01', 'malware', 'North America'), (2, '2021-10-02', 'phishing', 'South America'), (3, '2021-11-01', 'malwar... | What are the most common types of security incidents by region in the last quarter, and how many occurrences were there? | SELECT region, incident_type, COUNT(incident_id) as num_incidents FROM incident_types WHERE incident_date >= DATEADD(quarter, -1, CURRENT_DATE) GROUP BY region, incident_type ORDER BY region, num_incidents DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_stats (district_id INT, crime_rate DECIMAL(5,2)); INSERT INTO crime_stats (district_id, crime_rate) VALUES (1, 2.5), (2, 3.2), (3, 1.8); CREATE TABLE training_programs (id INT, district_id INT, program_type VARCHAR(255)); INSERT INTO training_programs (id, district_id, program_type) VALUES (1, 1, 'Di... | Identify disaster preparedness training programs and community policing initiatives in districts with the highest crime rates. | SELECT t.district_id, t.program_type FROM training_programs t INNER JOIN (SELECT district_id FROM crime_stats ORDER BY crime_rate DESC LIMIT 1) c ON t.district_id = c.district_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, age INT, game_genre VARCHAR(20), location VARCHAR(20)); INSERT INTO players (id, age, game_genre, location) VALUES (1, 25, 'racing', 'USA'), (2, 30, 'rpg', 'Germany'), (3, 22, 'shooter', 'France'); | What is the average age of players who play games in the 'rpg' genre in Europe? | SELECT AVG(age) FROM players WHERE game_genre = 'rpg' AND location LIKE 'Europe%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodation_costs_by_disability (accommodation_id INT, student_id INT, accommodation_type TEXT, accommodation_year INT, cost FLOAT); INSERT INTO accommodation_costs_by_disability (accommodation_id, student_id, accommodation_type, accommodation_year, cost) VALUES (1, 1, 'Extra Time', 2018, 200.00), (2, 2,... | What is the total cost of accommodations for students with mobility impairments in 2019? | SELECT accommodation_year, SUM(cost) AS total_cost FROM accommodation_costs_by_disability WHERE student_id IN (SELECT student_id FROM mobility_impairments) GROUP BY accommodation_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalOrganizations (id INT, organization_name VARCHAR(50), country VARCHAR(50), funding_amount DECIMAL(10, 2)); INSERT INTO CulturalOrganizations (id, organization_name, country, funding_amount) VALUES (1, 'Museum', 'Brazil', 50000.00), (2, 'Theater', 'Russia', 75000.00), (3, 'Art Gallery', 'Brazil', 60... | What was the total amount of funding received by cultural organizations in Brazil and Russia? | SELECT SUM(funding_amount) FROM CulturalOrganizations WHERE country IN ('Brazil', 'Russia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Pollution_Data (pollution_type TEXT, location TEXT); INSERT INTO Pollution_Data (pollution_type, location) VALUES ('Plastic', 'Mediterranean Sea'), ('Chemical Spills', 'Mediterranean Sea'), ('Oil Spills', 'Mediterranean Sea'), ('Nutrient Pollution', 'Mediterranean Sea'), ('Litter', 'Mediterranean Sea'); | What are the most common types of ocean pollution in the Mediterranean Sea? | SELECT pollution_type, COUNT(*) FROM Pollution_Data WHERE location = 'Mediterranean Sea' GROUP BY pollution_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_id INT, delivery_location VARCHAR(20), shipped_date DATE, weight FLOAT); INSERT INTO warehouse (id, name) VALUES (1, 'Seattle'), (2, 'NY'), (3, 'LA'), (4, 'Paris'), (5, 'London'); INSERT INTO shipment (id, warehouse_id, delivery... | What is the minimum weight of packages shipped from the 'London' warehouse to 'Madrid' between March 15 and March 31, 2021? | SELECT MIN(weight) AS min_weight FROM shipment WHERE warehouse_id = 5 AND delivery_location = 'Madrid' AND shipped_date >= '2021-03-15' AND shipped_date < '2021-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtWorks (ArtworkID int, Title varchar(100), ArtistID int); | Which artists have created more than 10 artworks? | SELECT Artists.Name, COUNT(ArtWorks.ArtworkID) FROM Artists | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels_paris (hotel_id INT, hotel_name TEXT, rating FLOAT, ai_adoption BOOLEAN); INSERT INTO hotels_paris (hotel_id, hotel_name, rating, ai_adoption) VALUES (1, 'Hotel de Ville', 4.2, false), (2, 'Hotel Ritz', 4.8, false), (3, 'Hotel Louvre', 4.6, true); | What is the average rating of hotels in Paris that have not adopted hospitality AI? | SELECT AVG(rating) FROM hotels_paris WHERE city = 'Paris' AND ai_adoption = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), HasPlayedVR BOOLEAN); INSERT INTO Players (PlayerID, Age, Gender, HasPlayedVR) VALUES (1, 25, 'Male', TRUE), (2, 30, 'Female', FALSE), (3, 22, 'Male', TRUE); | What is the minimum age of players who have not played a VR game? | SELECT MIN(Age) FROM Players WHERE HasPlayedVR = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Machines (MachineID INT, MachineType VARCHAR(50), Manufacturer VARCHAR(50), PurchaseDate DATE, PurchasePrice DECIMAL(10,2), Department VARCHAR(50)); INSERT INTO Machines (MachineID, MachineType, Manufacturer, PurchaseDate, PurchasePrice, Department) VALUES (1, 'CNC', 'GreenTech', '2019-01-01', 150000.00, '... | List the machines in the Manufacturing department that were purchased after January 1, 2020 and their purchase prices, excluding machines manufactured by 'GreenTech' company. | SELECT MachineType, PurchasePrice FROM Machines WHERE Department = 'Manufacturing' AND PurchaseDate > '2020-01-01' AND Manufacturer <> 'GreenTech'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (id INT, name VARCHAR(100), location VARCHAR(100), energy_consumption FLOAT); | What is the total energy consumption of buildings located in 'New York' in the 'GreenBuildings' table? | SELECT SUM(energy_consumption) FROM GreenBuildings WHERE location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT PRIMARY KEY, title VARCHAR(255), content TEXT, publish_date DATE, author_id INT); CREATE TABLE authors (author_id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255)); | Get all articles and their corresponding authors from 'articles' and 'authors' tables | SELECT articles.title, authors.name FROM articles INNER JOIN authors ON articles.author_id = authors.author_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME, content TEXT, hashtags TEXT); INSERT INTO posts (id, user_id, timestamp, content, hashtags) VALUES (1, 1, '2022-04-01 10:00:00', 'Beautiful nature scene', '#nature'), (2, 2, '2022-04-02 15:00:00', 'Love #nature', '#travel'); | How many users liked, shared, or commented on posts containing the hashtag "#nature" in April 2022? | SELECT COUNT(DISTINCT user_id) FROM posts WHERE hashtags LIKE '%#nature%' AND MONTH(timestamp) = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_operators (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), gender VARCHAR(10), years_of_experience INT); INSERT INTO mine_operators (id, name, role, gender, years_of_experience) VALUES (1, 'John Doe', 'Mining Engineer', 'Male', 7), (2, 'Maria', 'Mining Engineer', 'Female', 5); | Calculate the average years of experience of male and female mining engineers. | SELECT AVG(years_of_experience) FROM mine_operators GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, state TEXT, condition TEXT); INSERT INTO patients (patient_id, age, gender, state, condition) VALUES (1, 35, 'Female', 'California', 'Depression'); INSERT INTO patients (patient_id, age, gender, state, condition) VALUES (2, 45, 'Male', 'Texas', 'Anxiety'); CR... | What is the number of patients with depression, anxiety, or PTSD who were prescribed medication, and what is the most common medication prescribed for each condition? | SELECT condition, medication, COUNT(patient_id) as count FROM patients INNER JOIN prescriptions ON patients.patient_id = prescriptions.patient_id WHERE condition IN ('Depression', 'Anxiety', 'PTSD') GROUP BY condition, medication HAVING count > 1 ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists user_login (login_id int, user_id int, login_date date, login_city varchar(50), age int); | Get the number of daily logins for users aged 18-24 and 35-44 in the last month. | SELECT CASE WHEN age BETWEEN 18 AND 24 THEN '18-24' WHEN age BETWEEN 35 AND 44 THEN '35-44' END as age_range, COUNT(*) as daily_logins FROM user_login WHERE login_date >= DATEADD(day, -30, GETDATE()) GROUP BY age_range; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Age INT); INSERT INTO Employees (EmployeeID, Gender, Age) VALUES (1, 'Female', 35), (2, 'Male', 40), (3, 'Female', 45); | What is the average age of female employees? | SELECT AVG(Age) FROM Employees WHERE Gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (workout_id INT, member_id INT, type VARCHAR(20), date DATE); INSERT INTO workouts VALUES (1,3,'Outdoor Yoga','2022-02-05'); INSERT INTO workouts VALUES (2,4,'Outdoor Yoga','2022-02-10'); CREATE TABLE members (member_id INT, tier VARCHAR(10)); INSERT INTO members VALUES (3,'Premium'); INSERT INTO ... | How many outdoor yoga sessions were conducted for premium members in the past week? | SELECT COUNT(workouts.workout_id) FROM workouts INNER JOIN members ON workouts.member_id = members.member_id WHERE workouts.type = 'Outdoor Yoga' AND members.tier = 'Premium' AND workouts.date >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE state_water_usage (state VARCHAR(50), usage BIGINT); INSERT INTO state_water_usage (state, usage) VALUES ('California', 1230000000), ('Texas', 950000000), ('Florida', 720000000); | Find the state with the lowest water usage in Mega Liters. | SELECT state, usage FROM state_water_usage ORDER BY usage ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Oakland'), (2, 'Seattle'), (5, 'Mumbai'), (6, 'Singapore'); CREATE TABLE vessels (vessel_id INT, port_id INT, quantity_containers INT, year INT); INSERT INTO vessels (vessel_id, port_id, quantity_containers, year) ... | What is the total quantity of containers loaded on vessels in the ports of Mumbai and Singapore for the year 2020, excluding vessels that have less than 500 containers? | SELECT SUM(quantity_containers) FROM vessels JOIN port ON vessels.port_id = port.port_id WHERE (port.port_name = 'Mumbai' OR port.port_name = 'Singapore') AND vessels.year = 2020 AND vessels.quantity_containers >= 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, EventDate DATE, TotalAttendees INT, Program VARCHAR(255)); INSERT INTO Events (EventID, EventDate, TotalAttendees, Program) VALUES (1, '2023-07-01', 75, 'Visual Arts'), (2, '2023-10-01', 50, 'Visual Arts'); | What is the percentage change in attendance for visual arts programs between Q3 and Q4 2023? | SELECT ((Q4Attendance - Q3Attendance) * 100.0 / Q3Attendance) AS PercentageChange FROM (SELECT SUM(CASE WHEN QUARTER(EventDate) = 3 AND YEAR(EventDate) = 2023 THEN TotalAttendees ELSE 0 END) AS Q3Attendance, SUM(CASE WHEN QUARTER(EventDate) = 4 AND YEAR(EventDate) = 2023 THEN TotalAttendees ELSE 0 END) AS Q4Attendance ... | gretelai_synthetic_text_to_sql |
CREATE TABLE Roadways (id INT, type VARCHAR(50), state VARCHAR(50)); INSERT INTO Roadways (id, type, state) VALUES (1, 'Highway', 'Florida'); | How many highways are there in Florida? | SELECT COUNT(*) FROM Roadways WHERE state = 'Florida' AND type = 'Highway'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_trenches (id INT, name VARCHAR(255), depth FLOAT, trench_type VARCHAR(255)); INSERT INTO marine_trenches (id, name, depth, trench_type) VALUES (1, 'Mariana Trench', 10994, 'Oceanic'); INSERT INTO marine_trenches (id, name, depth, trench_type) VALUES (2, 'Tonga Trench', 10882, 'Oceanic'); INSERT INTO... | What is the maximum depth of all marine trenches, grouped by trench type? | SELECT trench_type, MAX(depth) FROM marine_trenches GROUP BY trench_type; | 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.