context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE student_mental_health (student_id INT, district_id INT, mental_health_score INT, date DATE); CREATE TABLE enrollments (student_id INT, enrollment_date DATE, mental_health_score INT); | What is the number of students who have improved their mental health score by more than 10 points in each district? | SELECT d.district_name, COUNT(smh.student_id) as num_improved FROM student_mental_health smh JOIN enrollments e ON smh.student_id = e.student_id JOIN districts d ON smh.district_id = d.district_id WHERE smh.mental_health_score > e.mental_health_score + 10 GROUP BY d.district_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_output (output_id INT, machine_id INT, production_date DATE, output_quantity INT); INSERT INTO production_output (output_id, machine_id, production_date, output_quantity) VALUES (1, 1, '2022-01-01', 100), (2, 1, '2022-01-02', 120), (3, 2, '2022-01-01', 150), (4, 2, '2022-01-02', 160); CREATE TABLE facilities (facility_id INT, facility_name VARCHAR(255), country VARCHAR(255)); INSERT INTO facilities (facility_id, facility_name, country) VALUES (1, 'Tijuana Plant', 'Mexico'), (2, 'Monterrey Plant', 'Mexico'); | What is the average production output for each machine in the company's facility in Mexico? | SELECT machine_id, AVG(output_quantity) as avg_output FROM production_output po JOIN facilities f ON f.facility_name = 'Tijuana Plant' WHERE po.production_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY machine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE battery_storage (id INT PRIMARY KEY, capacity FLOAT, warranty INT, manufacturer VARCHAR(255)); | Update records in the "battery_storage" table where the warranty is less than 10 years, setting the warranty to 10 years | UPDATE battery_storage SET warranty = 10 WHERE warranty < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name VARCHAR(255)); CREATE TABLE production_rates (factory_id INT, compound_name VARCHAR(255), production_rate INT); INSERT INTO factories (id, name) VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); INSERT INTO production_rates (factory_id, compound_name, production_rate) VALUES (1, 'Compound X', 200), (1, 'Compound Y', 180), (2, 'Compound X', 250), (2, 'Compound Y', 220), (3, 'Compound Z', 300); | What is the production rate of Compound Z in each factory? | SELECT factories.name, production_rates.production_rate FROM factories INNER JOIN production_rates ON factories.id = production_rates.factory_id WHERE production_rates.compound_name = 'Compound Z'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255)); INSERT INTO restaurants (id, name) VALUES (1, 'Restaurant A'), (2, 'Restaurant B'), (3, 'Restaurant C'); CREATE TABLE menu_items (id INT, name VARCHAR(255), restaurant_id INT); INSERT INTO menu_items (id, name, restaurant_id) VALUES (1, 'Tacos', 1), (2, 'Pizza', 2), (3, 'Fried Rice', 3), (4, 'Burrito', 1), (5, 'Spaghetti', 2); | Which menu items are shared between Restaurant A and Restaurant B? | SELECT mi1.name FROM menu_items mi1 JOIN menu_items mi2 ON mi1.name = mi2.name WHERE mi1.restaurant_id = 1 AND mi2.restaurant_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, genre TEXT, followers INT); INSERT INTO artists (id, name, genre, followers) VALUES (1, 'Artist1', 'Pop', 5000000); INSERT INTO artists (id, name, genre, followers) VALUES (2, 'Artist2', 'Rock', 4000000); INSERT INTO artists (id, name, genre, followers) VALUES (3, 'Artist3', 'Jazz', 3000000); | Which music genres have the most followers on social media? | SELECT genre, MAX(followers) as max_followers FROM artists GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, product VARCHAR(50), vulnerability_count INT, vulnerability_date DATE); INSERT INTO vulnerabilities (id, product, vulnerability_count, vulnerability_date) VALUES (1, 'ProductA', 25, '2022-01-01'), (2, 'ProductB', 35, '2022-01-02'), (3, 'ProductA', 30, '2022-02-01'); CREATE TABLE products (id INT, name VARCHAR(50)); INSERT INTO products (id, name) VALUES (1, 'ProductA'), (2, 'ProductB'), (3, 'ProductC'), (4, 'ProductD'); | How many vulnerabilities were found in the last quarter for each product? | SELECT p.name, SUM(v.vulnerability_count) as total_vulnerabilities FROM vulnerabilities v JOIN products p ON v.product = p.name WHERE v.vulnerability_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Articles (id INT, title VARCHAR(255), content TEXT); INSERT INTO Articles (id, title, content) VALUES (1, 'Climate Change Impact', 'Climate change is a global issue...'), (2, 'Economic Impact', 'The economy is a significant...'), (3, 'Climate Action', 'Climate action is necessary...'); | What is the total word count of articles that contain the word 'climate'? | SELECT SUM(LENGTH(content) - LENGTH(REPLACE(content, 'climate', '')) + LENGTH(title)) as total_word_count FROM Articles WHERE content LIKE '%climate%' OR title LIKE '%climate%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness (id INT, algorithm VARCHAR(20), bias_type VARCHAR(30), dataset VARCHAR(20)); | Add a new record for 'Feature Selection' in the 'algorithmic_fairness' table, with 'Disparate Impact' bias type and 'German Credit' dataset | INSERT INTO algorithmic_fairness (id, algorithm, bias_type, dataset) VALUES (4, 'Feature Selection', 'Disparate Impact', 'German Credit'); | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai_models (model_id INT, model_name TEXT, region TEXT, fairness_score FLOAT); INSERT INTO explainable_ai_models (model_id, model_name, region, fairness_score) VALUES (1, 'Lime', 'Asia', 0.87), (2, 'Shap', 'Europe', 0.85), (3, 'Skater', 'Asia', 0.90); | Which explainable AI models have the highest fairness scores in Asia? | SELECT model_name, fairness_score FROM explainable_ai_models WHERE region = 'Asia' ORDER BY fairness_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE neighborhoods (id INT, name TEXT);CREATE TABLE crimes (id INT, neighborhood_id INT, date DATE); | What is the maximum number of crimes committed in a single day in each neighborhood in the last year? | SELECT n.name, MAX(COUNT(c.id)) as max_crimes FROM neighborhoods n JOIN crimes c ON n.id = c.neighborhood_id WHERE c.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY n.id, c.date; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy ( id INT PRIMARY KEY, company_name VARCHAR(255), location VARCHAR(255), waste_reuse_rate DECIMAL(5,2) ); | Insert a new record into the "circular_economy" table with "company_name" as "OPQ Inc", "location" as "Rio de Janeiro, Brazil", and "waste_reuse_rate" as 0.28 | INSERT INTO circular_economy (company_name, location, waste_reuse_rate) VALUES ('OPQ Inc', 'Rio de Janeiro, Brazil', 0.28); | gretelai_synthetic_text_to_sql |
CREATE TABLE Indian_Ocean_Cetaceans (species_name TEXT, population INT); INSERT INTO Indian_Ocean_Cetaceans (species_name, population) VALUES ('Sperm Whale', 15000), ('Blue Whale', 10000), ('Dolphin', 60000); | What is the total number of whales and dolphins in the Indian Ocean? | SELECT SUM(population) FROM Indian_Ocean_Cetaceans WHERE species_name = 'Sperm Whale' OR species_name = 'Blue Whale' OR species_name = 'Dolphin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_justice_initiatives (id INT, name VARCHAR(255), area FLOAT, continent VARCHAR(255)); INSERT INTO food_justice_initiatives (id, name, area, continent) VALUES (1, 'Initiative A', 12345.6, 'North America'), (2, 'Initiative B', 23456.7, 'Europe'), (3, 'Initiative C', 34567.8, 'Asia'); | What is the total area of land in square kilometers used for food justice initiatives, broken down by continent? | SELECT continent, SUM(area * 0.0001) as total_area_sq_km FROM food_justice_initiatives GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, region VARCHAR(10));CREATE TABLE claims (id INT, policyholder_id INT, amount DECIMAL(10, 2)); | What is the total claim amount for policyholders in the 'Northeast' region? | SELECT region, SUM(claims.amount) as total_claim_amount FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.region IN ('NE', 'NJ', 'NY', 'PA', 'CT', 'MA', 'VT', 'NH', 'ME') GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name TEXT, location TEXT); CREATE TABLE Visitors_Events (visitor_id INT, event_id INT); INSERT INTO Events (id, name, location) VALUES (1, 'Dance Performance', 'Paris'), (2, 'Film Festival', 'Berlin'); INSERT INTO Visitors_Events (visitor_id, event_id) VALUES (1, 1), (1, 2), (3, 1); | List the names of all visitors who attended events in 'Paris' and 'Berlin'. | SELECT Visitors_Events.visitor_id FROM Visitors_Events INNER JOIN Events ON Visitors_Events.event_id = Events.id WHERE Events.location IN ('Paris', 'Berlin') GROUP BY Visitors_Events.visitor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W004', '2021-01-01', 150.5), ('W004', '2021-01-05', 185.0); | Delete the production record for well 'W004' on '2021-01-05' from the Oil_Production table? | DELETE FROM Oil_Production WHERE well = 'W004' AND production_date = '2021-01-05'; | gretelai_synthetic_text_to_sql |
CREATE TABLE government_spending (department TEXT, amount FLOAT); INSERT INTO government_spending (department, amount) VALUES ('Education', 15000.0), ('Defense', 25000.0), ('Healthcare', 20000.0); | List all the departments in the 'government_spending' table along with the total amount spent in descending order. | SELECT department, SUM(amount) as total_amount FROM government_spending GROUP BY department ORDER BY total_amount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(10,2), cause TEXT, donation_date DATE); INSERT INTO donations (donor_id, donation_amount, cause, donation_date) VALUES (1, 6000, 'environmental sustainability', '2022-09-28'); CREATE TABLE donors (donor_id INT, donor_country TEXT); INSERT INTO donors (donor_id, donor_country) VALUES (1, 'Nigeria'); | How many unique donors have contributed to environmental sustainability in Africa in the last 4 years? | SELECT COUNT(DISTINCT donors.donor_id) FROM donations JOIN donors ON donations.donor_id = donors.donor_id WHERE cause = 'environmental sustainability' AND donors.donor_country LIKE 'Africa%' AND donation_date BETWEEN DATE_SUB(NOW(), INTERVAL 4 YEAR) AND NOW(); | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_moisture (field TEXT, moisture INTEGER, timestamp TIMESTAMP); | Show the average soil moisture levels for each field in the past week. | SELECT field, AVG(moisture) as avg_moisture FROM soil_moisture WHERE timestamp BETWEEN DATEADD(day, -7, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP GROUP BY field; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_projects(id INT, project_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO defense_projects(id, project_name, start_date, end_date) VALUES (1, 'Project A', '2021-01-01', '2024-12-31'); INSERT INTO defense_projects(id, project_name, start_date, end_date) VALUES (2, 'Project B', '2022-01-01', '2023-01-01'); | List defense projects with end dates in 2023 that have a duration greater than 12 months. | SELECT project_name FROM defense_projects WHERE YEAR(end_date) = 2023 AND DATEDIFF(end_date, start_date) > 365; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, first_name VARCHAR(50), last_name VARCHAR(50), loyalty_points INT); INSERT INTO customers (customer_id, first_name, last_name, loyalty_points) VALUES (1, 'John', 'Doe', 1000), (2, 'Jane', 'Doe', 2000); | Update the loyalty_points balance for the customer with ID 1 to 2000 | UPDATE customers SET loyalty_points = 2000 WHERE customer_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT, donor_name VARCHAR(255), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donors (id, donor_name, donation_amount, donation_date) VALUES (1, 'John Doe', 500.00, '2016-01-01'), (2, 'Jane Smith', 300.00, '2021-02-01'), (3, 'Alice Johnson', 200.00, '2019-03-01'); | Delete all records in the 'Donors' table that are older than 5 years from the current date? | DELETE FROM Donors WHERE donation_date < DATE_SUB(CURDATE(), INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_plants (country VARCHAR(50), operational BOOLEAN, year INT); INSERT INTO hydro_plants (country, operational, year) VALUES ('Canada', true, 2018), ('United States', true, 2018), ('Brazil', true, 2018), ('Norway', true, 2018); | How many hydroelectric power plants were operational in Canada as of 2018? | SELECT COUNT(*) FROM hydro_plants WHERE country = 'Canada' AND operational = true AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (project_name TEXT, state TEXT, carbon_offset INTEGER); INSERT INTO carbon_offsets (project_name, state, carbon_offset) VALUES ('Wind Farm 1', 'California', 5000); | What is the average carbon offset per project for carbon offset initiatives in the state of California? | SELECT AVG(carbon_offset) FROM carbon_offsets WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_tests (id INT PRIMARY KEY, company VARCHAR(255), brand VARCHAR(255), test_location VARCHAR(255), test_date DATE, safety_rating INT); | Show the number of safety tests performed by each brand, broken down by test location | SELECT brand, test_location, COUNT(*) as total_tests FROM safety_tests GROUP BY brand, test_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE phishing_incidents (id INT, country VARCHAR(255), incidents INT); INSERT INTO phishing_incidents (id, country, incidents) VALUES (1, 'USA', 500); INSERT INTO phishing_incidents (id, country, incidents) VALUES (2, 'Canada', 300); INSERT INTO phishing_incidents (id, country, incidents) VALUES (3, 'UK', 400); | Which countries had the highest number of security incidents related to phishing in the last year? | SELECT country, incidents FROM phishing_incidents WHERE date >= DATEADD(year, -1, GETDATE()) ORDER BY incidents DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (id INT, name VARCHAR(255), location VARCHAR(255), seismic_zone VARCHAR(10), resilience_metric1 FLOAT, resilience_metric2 FLOAT); | Which resilience metrics have been measured for infrastructure projects in seismic zones? | SELECT DISTINCT seismic_zone, resilience_metric1, resilience_metric2 FROM infrastructure_projects WHERE seismic_zone IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, name TEXT, location TEXT, funder TEXT); INSERT INTO community_development (id, name, location, funder) VALUES (1, 'Housing Renovation', 'Appalachian region', 'Federal Government'), (2, 'Education Center', 'Appalachian region', 'Non-profit Organization'); | List all community development initiatives in the Appalachian region that were funded by the federal government and non-profit organizations. | SELECT * FROM community_development WHERE location = 'Appalachian region' AND funder IN ('Federal Government', 'Non-profit Organization'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Cause TEXT, Budget FLOAT, Spent FLOAT); INSERT INTO Programs (ProgramID, ProgramName, Cause, Budget, Spent) VALUES (1, 'Education', 'Children', 15000.00, 9000.00), (2, 'Healthcare', 'Seniors', 20000.00, 15000.00); | Which causes have more than 50% of their budget spent? | SELECT Cause FROM Programs WHERE Spent > 0.5 * Budget; | gretelai_synthetic_text_to_sql |
CREATE TABLE WildlifeSightings (location TEXT, year INTEGER, sightings INTEGER); | Find the total number of wildlife sightings in Svalbard in 2018. | SELECT SUM(sightings) FROM WildlifeSightings WHERE location = 'Svalbard' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE DecentralizedApps (AppID int, AppName varchar(50), Industry varchar(50)); INSERT INTO DecentralizedApps (AppID, AppName, Industry) VALUES (1, 'App1', 'Finance'), (2, 'App2', 'Healthcare'), (3, 'App3', 'Finance'), (4, 'App4', 'Entertainment'), (5, 'App5', 'Finance'); | What is the distribution of decentralized applications by industry? | SELECT Industry, COUNT(*) as AppsPerIndustry, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM DecentralizedApps) as Percentage FROM DecentralizedApps GROUP BY Industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE producers (id INT PRIMARY KEY, location TEXT, annual_production INT); INSERT INTO producers (id, location, annual_production) VALUES (1, 'Oregon', 1500); INSERT INTO producers (id, location, annual_production) VALUES (2, 'Washington', 2000); CREATE TABLE labor (id INT PRIMARY KEY, producer_id INT, employee_count INT); INSERT INTO labor (id, producer_id, employee_count) VALUES (1, 1, 20); INSERT INTO labor (id, producer_id, employee_count) VALUES (2, 2, 25); | What is the average annual production of cannabis for producers located in Oregon and Washington, and the number of employees for each of these producers? | SELECT p.location, AVG(p.annual_production) as avg_production, l.employee_count FROM producers p INNER JOIN labor l ON p.id = l.producer_id WHERE p.location IN ('Oregon', 'Washington') GROUP BY p.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_details (member_id INT, membership VARCHAR(10)); INSERT INTO member_details (member_id, membership) VALUES (1, 'Gold'), (2, 'Platinum'), (3, 'Silver'), (4, 'Platinum'), (5, 'Gold'), (6, 'Diamond'), (7, 'Bronze'); | List all members who have a 'Gold' or 'Diamond' membership. | SELECT member_id FROM member_details WHERE membership IN ('Gold', 'Diamond'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, name VARCHAR(255)); | Update the names of all users who have a name that matches a specified pattern. | UPDATE users SET name = REPLACE(name, 'Smith', 'Black') WHERE name LIKE '%Smith%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TV_Show_Data (tv_show VARCHAR(255), director VARCHAR(50), rating FLOAT); | Avg. rating of TV shows directed by women? | SELECT AVG(rating) FROM TV_Show_Data WHERE director LIKE '%female%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (id INT, name VARCHAR(255), country VARCHAR(255), regulatory_status VARCHAR(255)); INSERT INTO digital_assets (id, name, country, regulatory_status) VALUES (1, 'Asset 1', 'France', 'Approved'), (2, 'Asset 2', 'Germany', 'Under Review'), (3, 'Asset 3', 'Spain', 'Approved'), (4, 'Asset 4', 'Ireland', 'Approved'), (5, 'Asset 5', 'Italy', 'Under Review'), (6, 'Asset 6', 'Netherlands', 'Approved'); | What's the regulatory status of digital assets in the European Union? | SELECT regulatory_status FROM digital_assets WHERE country IN ('France', 'Germany', 'Spain', 'Ireland', 'Italy', 'Netherlands') AND country = 'European Union'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fertilizers (id INT, date DATE, type VARCHAR(50), quantity INT, farm_id INT, FOREIGN KEY (farm_id) REFERENCES farmers(id)); INSERT INTO fertilizers (id, date, type, quantity, farm_id) VALUES (1, '2022-01-01', 'Organic', 50, 1), (2, '2022-01-02', 'Organic', 75, 3), (3, '2022-01-03', 'Organic', 60, 4); INSERT INTO farmers (id, name, region, age) VALUES (1, 'James', 'North', 50), (2, 'Sophia', 'South', 40), (3, 'Mason', 'North', 45), (4, 'Lily', 'East', 55); | What is the average quantity of organic fertilizers used by farmers in the North region, grouped by their names? | SELECT f.name, AVG(fertilizers.quantity) as avg_quantity FROM fertilizers JOIN farmers f ON fertilizers.farm_id = f.id WHERE fertilizers.type = 'Organic' AND f.region = 'North' GROUP BY f.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE wellness_trends (month VARCHAR(7), meditation_minutes INT, yoga_minutes INT); | Insert new records into the 'wellness_trends' table for the month of January 2023 with a value of 50 for 'meditation_minutes' | INSERT INTO wellness_trends (month, meditation_minutes, yoga_minutes) VALUES ('January 2023', 50, 0); | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonTax (Id INT, Country VARCHAR(255), Year INT, Revenue INT); INSERT INTO CarbonTax VALUES (1, 'Germany', 2018, 1000), (2, 'Germany', 2019, 1500), (3, 'Germany', 2020, 2000), (4, 'France', 2018, 1200), (5, 'France', 2019, 1800), (6, 'France', 2020, 2500), (7, 'Italy', 2018, 800), (8, 'Italy', 2019, 1200), (9, 'Italy', 2020, 1600); | What is the total carbon tax revenue for each country for the last 3 years? | SELECT Country, SUM(Revenue) as Total_Revenue FROM CarbonTax WHERE Year IN (2018, 2019, 2020) GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE AircraftTypes (AircraftTypeID INT, AircraftType VARCHAR(50));CREATE TABLE EngineLifespan (EngineLifespanID INT, AircraftTypeID INT, EngineLifespan INT); | What is the maximum engine lifespan for each aircraft type? | SELECT AircraftType, MAX(EngineLifespan) AS MaxEngineLifespan FROM EngineLifespan EL INNER JOIN AircraftTypes AT ON EL.AircraftTypeID = AT.AircraftTypeID GROUP BY AircraftType; | gretelai_synthetic_text_to_sql |
CREATE TABLE europe_recycling_rates (country_name VARCHAR(50), recycling_rate NUMERIC(10,2), measurement_date DATE); INSERT INTO europe_recycling_rates (country_name, recycling_rate, measurement_date) VALUES ('Germany', 0.40, '2022-02-28'), ('France', 0.30, '2022-02-28'); | Update the recycling rate for 'Germany' to 0.42 in the last month's data. | UPDATE europe_recycling_rates SET recycling_rate = 0.42 WHERE country_name = 'Germany' AND measurement_date >= DATEADD(month, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE stores (store_id INT, location VARCHAR(20), quantity INT); INSERT INTO stores (store_id, location, quantity) VALUES (1, 'urban', 100), (2, 'rural', 50), (3, 'urban', 150), (4, 'suburban', 75); | What is the average quantity of products sold in stores located in urban areas? | SELECT AVG(quantity) FROM stores WHERE location = 'urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50)); INSERT INTO Attorneys (AttorneyID, Name) VALUES (1, 'Smith, John'), (2, 'Garcia, Maria'), (3, 'Johnson, James'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (1, 1, 5000.00), (2, 2, 3500.00), (3, 2, 4000.00), (4, 3, 6000.00); | What is the total billing amount for cases handled by the attorney with the ID 2? | SELECT SUM(BillingAmount) FROM Cases WHERE AttorneyID = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE route_segments (segment_id INT, segment_name TEXT, route_id INT); CREATE TABLE fares (fare_id INT, segment_id INT, fare_amount DECIMAL); INSERT INTO route_segments (segment_id, segment_name, route_id) VALUES (1, 'Downtown to Midtown', 1), (2, 'Midtown to Uptown', 1), (3, 'City Center to Suburbs', 2); INSERT INTO fares (fare_id, segment_id, fare_amount) VALUES (1, 1, 2.50), (2, 1, 2.50), (3, 2, 2.50), (4, 2, 2.50), (5, 3, 3.50), (6, 3, 3.50); | What is the total fare collected for each route segment? | SELECT f.segment_id, r.segment_name, SUM(f.fare_amount) AS total_fare FROM fares f JOIN route_segments r ON f.segment_id = r.segment_id GROUP BY f.segment_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE GeneralPolicyTypes (PolicyTypeID int, PolicyType varchar(20)); CREATE TABLE GeneralClaims (ClaimID int, PolicyTypeID int, ClaimAmount decimal); INSERT INTO GeneralPolicyTypes (PolicyTypeID, PolicyType) VALUES (1, 'Boat'); INSERT INTO GeneralPolicyTypes (PolicyTypeID, PolicyType) VALUES (2, 'Motorcycle'); INSERT INTO GeneralClaims (ClaimID, PolicyTypeID, ClaimAmount) VALUES (1, 1, 400); INSERT INTO GeneralClaims (ClaimID, PolicyTypeID, ClaimAmount) VALUES (2, 2, 600); | List all policy types that have a claim amount less than $500. | SELECT GeneralPolicyTypes.PolicyType FROM GeneralPolicyTypes INNER JOIN GeneralClaims ON GeneralPolicyTypes.PolicyTypeID = GeneralClaims.PolicyTypeID WHERE GeneralClaims.ClaimAmount < 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE officers (id INT, name VARCHAR(255), division VARCHAR(255)); INSERT INTO officers (id, name, division) VALUES (1, 'Sophia Chen', 'NYPD'), (2, 'Jose Hernandez', 'NYPD'); CREATE TABLE community_engagements (id INT, officer_id INT, engagement_type VARCHAR(255), engagement_time TIMESTAMP); INSERT INTO community_engagements (id, officer_id, engagement_type, engagement_time) VALUES (1, 1, 'Community Meeting', '2022-02-01 10:00:00'), (2, 2, 'Neighborhood Watch', '2022-02-15 11:00:00'), (3, 1, 'Coffee with a Cop', '2022-02-10 09:00:00'); | Who is the officer with the fewest community engagement activities in the last month? | SELECT o.name, COUNT(ce.id) as total_engagements FROM community_engagements ce JOIN officers o ON ce.officer_id = o.id WHERE ce.engagement_time >= DATEADD(month, -1, CURRENT_TIMESTAMP) GROUP BY o.name ORDER BY total_engagements ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_name TEXT, sale_date DATE, country TEXT, organic BOOLEAN); INSERT INTO sales (product_name, sale_date, country, organic) VALUES ('Mascara A', '2022-02-01', 'Canada', true), ('Foundation B', '2022-02-02', 'US', false), ('Lipstick C', '2022-02-03', 'Canada', false); | What percentage of cosmetics sold in Canada contain organic ingredients? | SELECT (COUNT(*) FILTER (WHERE organic = true)) * 100.0 / COUNT(*) as organic_percentage FROM sales WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(100), launch_date DATE, type VARCHAR(50));CREATE VIEW v_space_debris_summary AS SELECT id, debris_name, launch_date, type FROM space_debris; | Select all data from the view 'v_space_debris_summary' | SELECT * FROM v_space_debris_summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_stats (region TEXT, material TEXT, recycling_rate FLOAT); INSERT INTO recycling_stats (region, material, recycling_rate) VALUES ('Region A', 'Metal', 0.55), ('Region A', 'Glass', 0.45), ('Region B', 'Metal', 0.60), ('Region B', 'Glass', 0.35), ('Region C', 'Metal', 0.45), ('Region C', 'Glass', 0.40); | What is the maximum recycling rate for glass in regions where the recycling rate for metal is above 50%? | SELECT MAX(recycling_rate) FROM recycling_stats WHERE region IN (SELECT region FROM recycling_stats WHERE material = 'Metal' AND recycling_rate > 0.5) AND material = 'Glass'; | gretelai_synthetic_text_to_sql |
CREATE TABLE petitions (id INT PRIMARY KEY, department_id INT, title VARCHAR(255)); | Delete all petitions related to the 'Transportation' department from the 'petitions' table. | DELETE FROM petitions WHERE department_id IN (SELECT id FROM departments WHERE name = 'Transportation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (id INT, state VARCHAR(20), year INT, usage FLOAT); | What was the total water consumption by all states in the year 2018? | SELECT SUM(usage) FROM water_usage WHERE year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE provinces (id INT, name TEXT, country TEXT); INSERT INTO provinces (id, name, country) VALUES (1, 'Ontario', 'Canada'), (2, 'Quebec', 'Canada'); | What is the total crop yield for each crop grown in Canada? | SELECT crops.name, SUM(crop_yield.yield) FROM crop_yield JOIN farms ON crop_yield.farm_id = farms.id JOIN crops ON crop_yield.crop_id = crops.id JOIN provinces ON farms.id = provinces.id WHERE provinces.country = 'Canada' GROUP BY crops.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism (id INT, country VARCHAR(50), initiative_name VARCHAR(100), start_date DATE, end_date DATE); | Insert a new record for a sustainable tourism initiative in Japan. | INSERT INTO sustainable_tourism (id, country, initiative_name, start_date, end_date) VALUES (1, 'Japan', 'Eco-Friendly Island Cleanup', '2023-04-01', '2023-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE inventories (id INT PRIMARY KEY, garment_id INT, quantity INT); INSERT INTO inventories (id, garment_id, quantity) VALUES (1, 1, 50), (2, 2, 75); | Update the quantity of garment with id 2 to 100. | UPDATE inventories SET quantity = 100 WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE VIEW top_10_teams AS SELECT team_id, SUM(wins) as total_wins, AVG(average_score) as average_score FROM esports_games GROUP BY team_id; | Generate a view for top 10 eSports teams | CREATE VIEW top_10_teams_view AS SELECT * FROM top_10_teams WHERE row_number() OVER (ORDER BY total_wins DESC, average_score DESC) <= 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name TEXT, department TEXT, salary INT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'Engineering', 70000), (2, 'Jane Smith', 'Management', 90000), (3, 'Bob Johnson', 'Assembly', 50000), (4, 'Alice Williams', 'Engineering', 75000), (5, 'Charlie Brown', 'Assembly', 55000), (6, 'Janet Doe', 'Quality', 60000), (7, 'Jim Smith', 'Management', 85000), (8, 'Jake Johnson', 'Assembly', 60000); | Update the salary of 'Bob Johnson' in the 'Assembly' department to $65000. | UPDATE employees SET salary = 65000 WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, artist_id INT, city VARCHAR(50), revenue DECIMAL(10,2)); | Find the top 3 cities by total concert revenue for a given artist. | SELECT city, SUM(revenue) AS total_revenue FROM Concerts WHERE artist_id = 1 GROUP BY city ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands(brand_id INT, brand_name TEXT); INSERT INTO brands(brand_id, brand_name) VALUES (1, 'BrandA'), (2, 'BrandB'), (3, 'BrandC'); CREATE TABLE products(product_id INT, product_name TEXT, brand_id INT, quantity INT); INSERT INTO products(product_id, product_name, brand_id, quantity) VALUES (1, 'Product1', 1, 200), (2, 'Product2', 1, 300), (3, 'Product3', 2, 500), (4, 'Product4', 3, 1000), (5, 'Product5', 3, 800); | What is the total quantity of 'organic cotton' products sold by each brand, ordered by total quantity in descending order? | SELECT brand_id, SUM(quantity) as total_quantity FROM products WHERE product_name LIKE '%organic cotton%' GROUP BY brand_id ORDER BY total_quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50), country VARCHAR(50)); INSERT INTO athletes (id, name, age, sport, country) VALUES (1, 'John Doe', 30, 'Basketball', 'USA'); | Calculate the average age of athletes in the "athletes" table. | SELECT AVG(age) FROM athletes; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA space_exploration; CREATE TABLE space_exploration.missions (mission_id INT, mission_name VARCHAR(50), mission_cost INT, mission_date DATE); INSERT INTO space_exploration.missions VALUES (1, 'Mars Rover', 2500000, '2012-08-05'); INSERT INTO space_exploration.missions VALUES (2, 'SpaceX Falcon Heavy', 9000000, '2018-02-06'); INSERT INTO space_exploration.missions VALUES (3, 'Hubble Space Telescope', 1000000, '1990-04-24'); | Which space missions had the highest and lowest cost in the last 10 years? | SELECT mission_name, mission_cost, ROW_NUMBER() OVER (ORDER BY mission_cost DESC) as mission_rank FROM space_exploration.missions WHERE mission_date >= DATEADD(year, -10, GETDATE()) ORDER BY mission_cost; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeDetails (EmployeeID INT, Department TEXT, Salary REAL, Remote TEXT); INSERT INTO EmployeeDetails (EmployeeID, Department, Salary, Remote) VALUES (1, 'IT', 70000, 'Yes'); | What is the minimum salary of remote employees? | SELECT MIN(Salary) FROM EmployeeDetails WHERE Remote = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Animals (AnimalID INT, AnimalName VARCHAR(50), Population INT, Habitat VARCHAR(50), Status VARCHAR(20)); INSERT INTO Animals (AnimalID, AnimalName, Population, Habitat, Status) VALUES (1, 'Tiger', 3890, 'Asia', 'Endangered'); INSERT INTO Animals (AnimalID, AnimalName, Population, Habitat, Status) VALUES (2, 'Giant Panda', 1864, 'Asia', 'Endangered'); | How many endangered animals are there in total, by type, in Asia? | SELECT Status, AnimalName, SUM(Population) FROM Animals WHERE Habitat = 'Asia' AND Status = 'Endangered' GROUP BY Status, AnimalName; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), gender VARCHAR(50)); CREATE TABLE training_attendance (id INT, worker_id INT, training_id INT); CREATE TABLE trainings (id INT, name VARCHAR(50), date DATE); INSERT INTO community_health_workers (id, name, gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'); INSERT INTO training_attendance (id, worker_id, training_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 1); INSERT INTO trainings (id, name, date) VALUES (1, 'Cultural Competency 101', '2022-01-01'), (2, 'Advanced Cultural Competency', '2022-02-01'); | What is the total number of cultural competency trainings attended by community health workers of each gender, in the 'training_attendance' table? | SELECT g.gender, COUNT(ta.id) FROM training_attendance ta JOIN community_health_workers g ON ta.worker_id = g.id GROUP BY g.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE gym_memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5,2)); | How many members have joined in each month of 2022? | SELECT DATE_FORMAT(start_date, '%Y-%m') AS month, COUNT(DISTINCT id) AS members_joined FROM gym_memberships WHERE start_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_aid (disaster_id INT, country_name VARCHAR(50), aid_amount INT, aid_date DATE); | Insert new humanitarian aid records for disaster_id 307, 308, and 309, country_name 'Nigeria', 'Congo', and 'Madagascar' respectively | INSERT INTO humanitarian_aid (disaster_id, country_name, aid_amount, aid_date) VALUES (307, 'Nigeria', 45000, '2022-01-05'), (308, 'Congo', 55000, '2022-02-01'), (309, 'Madagascar', 65000, '2022-02-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_type VARCHAR(10), location VARCHAR(20), production_rate FLOAT); INSERT INTO wells (well_id, well_type, location, production_rate) VALUES (1, 'offshore', 'Gulf of Mexico', 1000), (2, 'onshore', 'Texas', 800), (3, 'offshore', 'North Sea', 1200); | Delete the well with well_id 3. | DELETE FROM wells WHERE well_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location TEXT, value FLOAT); INSERT INTO ocean_acidification (location, value) VALUES ('Pacific Ocean', 8.1), ('Atlantic Ocean', 8.0); | What is the minimum ocean acidification level in the Pacific Ocean? | SELECT MIN(value) FROM ocean_acidification WHERE location = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sectors (id INT, sector_name VARCHAR(255)); INSERT INTO sectors (id, sector_name) VALUES (1, 'Construction'), (2, 'Transportation'); CREATE TABLE inspections (id INT, sector_id INT, inspection_date DATE); INSERT INTO inspections (id, sector_id, inspection_date) VALUES (1, 1, '2022-03-01'), (2, 1, '2022-02-15'); | How many workplace safety inspections have been conducted in the construction sector in the last 3 months? | SELECT COUNT(*) as total_inspections FROM inspections i JOIN sectors s ON i.sector_id = s.id WHERE s.sector_name = 'Construction' AND i.inspection_date >= DATE(NOW()) - INTERVAL 3 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE CourierCompany (id INT, name VARCHAR(255), on_time_deliveries INT, total_deliveries INT); | What is the percentage of on-time deliveries for each courier company in the last month? | SELECT name, ROUND(on_time_deliveries * 100.0 / total_deliveries, 2) as percentage_on_time_deliveries FROM CourierCompany WHERE sale_date >= (CURRENT_DATE - INTERVAL '1 month') ORDER BY percentage_on_time_deliveries DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE assessments (assessment_id INT, student_id INT, assessment_date DATE); INSERT INTO assessments (assessment_id, student_id, assessment_date) VALUES (1, 1, '2021-09-01'), (2, 1, '2022-02-15'), (3, 2, '2021-10-05'), (4, 2, '2022-03-28'), (5, 3, '2021-11-12'), (6, 3, '2022-05-03'); | What is the maximum number of mental health assessments conducted per student in the last academic year? | SELECT student_id, MAX(COUNT(assessment_id)) FROM assessments WHERE assessment_date >= DATE_SUB('2022-08-01', INTERVAL 1 YEAR) GROUP BY student_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (id INT, city VARCHAR(255), date DATE, type VARCHAR(255), description TEXT); INSERT INTO violations (id, city, date, type, description) VALUES (1, 'Chicago', '2020-01-01', 'Speeding', 'Exceeding the speed limit'), (2, 'Chicago', '2020-02-01', 'Parking', 'Parking in a no-parking zone'); | How many traffic violations were issued in Chicago in the year 2020, and what was the most common type? | SELECT COUNT(*) FROM violations WHERE city = 'Chicago' AND YEAR(date) = 2020; SELECT type, COUNT(*) FROM violations WHERE city = 'Chicago' AND YEAR(date) = 2020 GROUP BY type ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE routes (id INT, name VARCHAR(50), start_stop_id INT, end_stop_id INT); INSERT INTO routes (id, name, start_stop_id, end_stop_id) VALUES (3, 'Green Line', 45, 60); | Which stop is the last stop for route 'Green Line'? | SELECT s.name FROM stops s INNER JOIN (SELECT end_stop_id FROM routes WHERE name = 'Green Line' LIMIT 1) rt ON s.id = rt.end_stop_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT, name VARCHAR(255), sustainability_score INT); | Delete products with a sustainability score less than 50. | DELETE FROM Products WHERE sustainability_score < 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT, regulation VARCHAR(100), state VARCHAR(20), implementation_date DATE); INSERT INTO mental_health_parity (id, regulation, state, implementation_date) VALUES (1, 'Regulation 1', 'New York', '2011-01-01'), (2, 'Regulation 2', 'Florida', '2012-01-01'), (3, 'Regulation 3', 'New York', NULL); | Delete all mental health parity regulations that have not been implemented. | DELETE FROM mental_health_parity WHERE implementation_date IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, ceo TEXT, funding FLOAT); INSERT INTO companies (id, name, industry, ceo, funding) VALUES (1, 'GreenEnergy', 'Renewable Energy', 'Female', 20000000.0); | What is the maximum amount of funding received by a company with a female CEO in the renewable energy sector? | SELECT MAX(funding) FROM companies WHERE ceo = 'Female' AND industry = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, donation_date DATE, sector TEXT, country TEXT); INSERT INTO donors (donor_id, donor_name, donation_amount, donation_date, sector, country) VALUES (1, 'UNICEF', 50000, '2020-01-01', 'education', 'Afghanistan'); | What is the total amount of funds donated by each organization for the education sector in Afghanistan in 2020? | SELECT donor_name, SUM(donation_amount) as total_donation FROM donors WHERE country = 'Afghanistan' AND sector = 'education' GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE canada_residential_water (province VARCHAR(255), year INT, usage FLOAT); INSERT INTO canada_residential_water (province, year, usage) VALUES ('Alberta', 2021, 500.5), ('British Columbia', 2021, 450.3), ('Ontario', 2021, 600.2), ('Quebec', 2021, 400.1), ('Nova Scotia', 2021, 350.0); | What is the average daily water consumption for residential use in each province of Canada, for the year 2021? | SELECT province, AVG(usage) as avg_daily_usage FROM canada_residential_water WHERE year = 2021 GROUP BY province; | gretelai_synthetic_text_to_sql |
CREATE TABLE county_services (county VARCHAR(255), service_type VARCHAR(255)); | How many unique public services are offered in each county in 'county_services' table? | SELECT county, COUNT(DISTINCT service_type) FROM county_services GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccine_records (patient_id INT, vaccine_name VARCHAR(20), age INT, state VARCHAR(20)); INSERT INTO vaccine_records VALUES (1, 'Pfizer', 35, 'California'), (2, 'Pfizer', 42, 'California'), (3, 'Moderna', 50, 'Florida'); INSERT INTO vaccine_records VALUES (4, 'Pfizer', 60, 'California'), (5, 'Pfizer', 65, 'California'), (6, 'Johnson', 40, 'California'); | What is the maximum age of patients who received the Pfizer vaccine in California? | SELECT MAX(age) FROM vaccine_records WHERE vaccine_name = 'Pfizer' AND state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA GreenBuildings; USE GreenBuildings; CREATE TABLE GreenBuildingProjects (id INT, project_name VARCHAR(100), cost DECIMAL(10,2)); INSERT INTO GreenBuildingProjects (id, project_name, cost) VALUES (1, 'Solar Panel Installation', 150000.00), (2, 'Wind Turbine Installation', 200000.00); | Calculate the total cost of green building projects in the GreenBuildings schema | SELECT SUM(cost) FROM GreenBuildings.GreenBuildingProjects; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductSafety (id INT, product_id INT, year INT, incident_count INT); INSERT INTO ProductSafety (id, product_id, year, incident_count) VALUES (1, 1, 2020, 2), (2, 1, 2019, 1), (3, 2, 2020, 0), (4, 2, 2019, 3), (5, 3, 2021, 4), (6, 3, 2020, 1), (7, 4, 2019, 2), (8, 4, 2020, 0), (9, 4, 2021, 3), (10, 5, 2021, 1); | Calculate the total incident count for each product in 2021. | SELECT product_id, SUM(incident_count) as total_incident_count FROM ProductSafety WHERE year = 2021 GROUP BY product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE HumanitarianAssistance (Year INT, Spending DECIMAL(10,2)); INSERT INTO HumanitarianAssistance (Year, Spending) VALUES (2020, 120000), (2021, 150000), (2022, 180000), (2023, 200000); | What is the total spending on humanitarian assistance in the last 3 years? | SELECT SUM(Spending) FROM HumanitarianAssistance WHERE Year BETWEEN (SELECT MAX(Year) - 2 FROM HumanitarianAssistance) AND MAX(Year); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, joined DATE); CREATE TABLE donors (id INT, last_donation DATE) | Count total number of volunteers and total number of donors | SELECT COUNT(DISTINCT v.id) AS total_volunteers, COUNT(DISTINCT d.id) AS total_donors FROM volunteers v, donors d; | gretelai_synthetic_text_to_sql |
CREATE TABLE claim (claim_id INT, claim_state VARCHAR(20), claim_status VARCHAR(20)); INSERT INTO claim VALUES (1, 'California', 'Pending'); INSERT INTO claim VALUES (2, 'Texas', 'Open'); | Show all claim records for claim status 'Open' as separate columns for claim ID, claim state, and a column for each claim status value | SELECT claim_id, claim_state, MAX(CASE WHEN claim_status = 'Paid' THEN claim_status END) AS Paid, MAX(CASE WHEN claim_status = 'Pending' THEN claim_status END) AS Pending, MAX(CASE WHEN claim_status = 'Open' THEN claim_status END) AS Open FROM claim GROUP BY claim_id, claim_state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Continents (id INT, name VARCHAR(255)); INSERT INTO Continents (id, name) VALUES (1, 'Africa'), (2, 'Europe'), (3, 'Asia'), (4, 'North America'), (5, 'South America'); CREATE TABLE VirtualTours (id INT, continent_id INT, year INT, quarter INT, views INT); INSERT INTO VirtualTours (id, continent_id, year, quarter, views) VALUES (1, 1, 2022, 2, 2000), (2, 1, 2022, 3, 2500), (3, 1, 2022, 4, 3000), (4, 2, 2022, 2, 3500), (5, 2, 2022, 3, 4000), (6, 2, 2022, 4, 4500), (7, 3, 2022, 2, 5000), (8, 3, 2022, 3, 5500), (9, 3, 2022, 4, 6000), (10, 4, 2022, 2, 6500), (11, 4, 2022, 3, 7000), (12, 4, 2022, 4, 7500); | What is the number of virtual tours in Africa between Q2 and Q4 2022? | SELECT SUM(vt.views) as total_views FROM VirtualTours vt JOIN Continents c ON vt.continent_id = c.id WHERE c.name = 'Africa' AND vt.year = 2022 AND vt.quarter BETWEEN 2 AND 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism (visitor_id INT, arrival_age INT); INSERT INTO sustainable_tourism (visitor_id, arrival_age) VALUES (1, 35), (2, 45), (3, 28); | What is the average arrival age of visitors in 'sustainable_tourism' table? | SELECT AVG(arrival_age) FROM sustainable_tourism; | gretelai_synthetic_text_to_sql |
CREATE TABLE av_sales (id INT, make VARCHAR, model VARCHAR, year INT, region VARCHAR, sold INT); CREATE VIEW av_market_share AS SELECT region, SUM(sold) as total_sold FROM av_sales WHERE model LIKE '%autonomous%' GROUP BY region; | What is the market share of autonomous vehicles by region in 2025? | SELECT region, total_sold/SUM(total_sold) OVER (PARTITION BY NULL) as market_share FROM av_market_share WHERE year = 2025; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title TEXT, release_year INT, genre TEXT, revenue FLOAT); | What is the total revenue for each genre in the last 3 years? | SELECT genre, SUM(revenue) FROM songs WHERE release_year >= 2018 GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(50), account_balance DECIMAL(10,2)); | Calculate the average account balance for customers in each city in the USA. | SELECT city, AVG(account_balance) as avg_balance FROM customers WHERE state = 'USA' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_operations (id INT, operation_name VARCHAR(50), target_country VARCHAR(50), operation_type VARCHAR(50)); INSERT INTO intelligence_operations (id, operation_name, target_country, operation_type) VALUES (1, 'Olympic Games', 'Iran', 'Cyberwarfare'), (2, 'Bounty Hunter', 'Russia', 'Human intelligence'); | Which intelligence operations have been conducted against adversarial nations in the 'intelligence_operations' table? | SELECT operation_name, target_country, operation_type FROM intelligence_operations WHERE target_country IN ('Iran', 'Russia', 'North Korea', 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE product_ingredients (product_id INT, ingredient VARCHAR(255), percentage FLOAT, is_vegan BOOLEAN, PRIMARY KEY (product_id, ingredient)); | How many ingredients in the 'lotion' product are not vegan? | SELECT COUNT(ingredient) FROM product_ingredients WHERE product_id = (SELECT product_id FROM products WHERE product_name = 'lotion') AND is_vegan = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts(id INT, name VARCHAR(50), gender VARCHAR(50)); CREATE TABLE SpaceMissions(id INT, mission VARCHAR(50), leader_id INT, duration FLOAT); INSERT INTO Astronauts(id, name, gender) VALUES (1, 'Jane Smith', 'Female'), (2, 'John Doe', 'Male'); INSERT INTO SpaceMissions(id, mission, leader_id, duration) VALUES (1, 'Apollo 11', 1, 12), (2, 'Artemis I', 2, 15), (3, 'Ares III', 1, 18); | What is the maximum duration of a space mission led by a female astronaut? | SELECT MAX(duration) FROM SpaceMissions INNER JOIN Astronauts ON SpaceMissions.leader_id = Astronauts.id WHERE Astronauts.gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinics (clinic_id INT, name TEXT, location TEXT, rural BOOLEAN);CREATE TABLE patients (patient_id INT, clinic_id INT, year INT, rural BOOLEAN); | List all clinics in Arizona that have reduced their rural patient base by over 15% since 2018. | SELECT c.name FROM clinics c JOIN (SELECT clinic_id, 100.0 * COUNT(*) FILTER (WHERE rural) / SUM(COUNT(*)) OVER (PARTITION BY clinic_id) AS reduction_ratio FROM patients WHERE year IN (2018, 2022) GROUP BY clinic_id) t ON c.clinic_id = t.clinic_id WHERE t.reduction_ratio > 15.0 AND c.state = 'Arizona'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_production_figures (country_code CHAR(2), production_date DATE, oil_production FLOAT, gas_production FLOAT); | What is the total oil and gas production for each country in H1 2021? | SELECT country_code, SUM(oil_production) as total_oil_production, SUM(gas_production) as total_gas_production FROM country_production_figures WHERE production_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY country_code; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, country TEXT); INSERT INTO volunteers (id, name, country) VALUES (1, 'Alice', 'Canada'), (2, 'Bob', 'USA'), (3, 'Charlie', 'Mexico'); CREATE TABLE donations (id INT, amount REAL, program_id INT, donor_id INT, country TEXT); INSERT INTO donations (id, amount, program_id, donor_id, country) VALUES (1, 50.0, 100, 4, 'Canada'), (2, 100.0, 200, 5, 'Canada'), (3, 75.0, 100, 6, 'Mexico'); | What is the total donation amount and number of volunteers for each country? | SELECT d.country, SUM(d.amount) AS total_donation_amount, COUNT(DISTINCT v.id) AS num_volunteers FROM donations d INNER JOIN volunteers v ON d.donor_id = v.id GROUP BY d.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name VARCHAR(255)); CREATE TABLE volunteer_hours (id INT, volunteer_id INT, hours DECIMAL(10,2)); INSERT INTO volunteers (id, name) VALUES (1, 'John'), (2, 'Jane'), (3, 'Mary'); INSERT INTO volunteer_hours (id, volunteer_id, hours) VALUES (1, 1, 5), (2, 2, 10), (3, 1, 15), (4, 3, 20); | What is the average number of volunteer hours per volunteer? | SELECT volunteer_id, AVG(hours) OVER (PARTITION BY volunteer_id) AS avg_hours_per_volunteer FROM volunteer_hours; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'); | List all marine species in the 'marine_species' table with a conservation status of 'Vulnerable' | SELECT species_name FROM marine_species WHERE conservation_status = 'Vulnerable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Streaming (id INT, artist VARCHAR(50), streams INT); INSERT INTO Streaming (id, artist, streams) VALUES (1, 'Sia', 1000000), (2, 'Taylor Swift', 2000000), (3, 'Drake', 1500000); | How many streams does artist 'Sia' have in total? | SELECT SUM(streams) FROM Streaming WHERE artist = 'Sia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE interplanetary_probes (id INT, country VARCHAR(255), probe_name VARCHAR(255)); INSERT INTO interplanetary_probes (id, country, probe_name) VALUES (1, 'India', 'Chandrayaan 1'), (2, 'India', 'Mangalyaan'), (3, 'India', 'Chandrayaan 2'), (4, 'India', 'Aditya-L1'); | How many interplanetary probes have been launched by India? | SELECT COUNT(*) FROM interplanetary_probes WHERE country = 'India'; | 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.