context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE if not exists smart_contracts (id INT PRIMARY KEY, name TEXT, language TEXT, version TEXT); INSERT INTO smart_contracts (id, name, language, version) VALUES (1, 'CryptoKitties', 'Solidity', '0.4.24'); | Insert a new row in the smart_contracts table with name 'Sushiswap' if it doesn't exist. | INSERT INTO smart_contracts (name, language, version) SELECT 'Sushiswap', 'Vyper', '0.3.0' WHERE NOT EXISTS (SELECT * FROM smart_contracts WHERE name = 'Sushiswap'); | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_institutions (institution_id INT, institution_name TEXT); INSERT INTO financial_institutions (institution_id, institution_name) VALUES (1, 'GreenBank Europe'), (2, 'FairFinance Europe'), (3, 'EthicalBank Europe'); CREATE TABLE loans (loan_id INT, institution_id INT, loan_type TEXT); INSERT INTO l... | How many socially responsible loans were issued by financial institutions in Europe? | SELECT COUNT(*) FROM loans WHERE loan_type = 'socially responsible' AND institution_id IN (SELECT institution_id FROM financial_institutions WHERE institution_name LIKE '%Europe%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE FacultyDemographics (id INT, name VARCHAR(255), rank VARCHAR(255), department VARCHAR(255), gender VARCHAR(10)); | Determine the percentage of female and male faculty members in the College of Business and Management, for each rank, and order the results by rank. | SELECT rank, gender, COUNT(*) as count, ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY rank), 2) as percentage FROM FacultyDemographics WHERE department LIKE 'Business%' GROUP BY rank, gender ORDER BY rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE producers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), production_volume INT); | List producers with a production volume greater than 1500 | SELECT name FROM producers WHERE production_volume > (SELECT 1500); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, supplier VARCHAR(50), Dysprosium_sold FLOAT, revenue FLOAT, datetime DATETIME); INSERT INTO transactions (id, supplier, Dysprosium_sold, revenue, datetime) VALUES (1, 'China National Nuke', 150.0, 2500.0, '2019-01-01 10:00:00'), (2, 'Korea Resource', 200.0, 3000.0, '2019-01-15 14:30:0... | Calculate the number of transactions and total revenue from Dysprosium sales by each supplier in Asia, for 2019. | SELECT supplier, COUNT(DISTINCT id) AS transactions, SUM(revenue) AS total_revenue FROM transactions WHERE YEAR(datetime) = 2019 AND supplier LIKE 'Asia%' GROUP BY supplier; | gretelai_synthetic_text_to_sql |
CREATE TABLE field_production (field VARCHAR(50), year INT, oil_production FLOAT, gas_production FLOAT); INSERT INTO field_production (field, year, oil_production, gas_production) VALUES ('Girassol', 2019, 1234.5, 678.9); | What are the production figures for the 'Girassol' field for the year 2019? | SELECT year, oil_production, gas_production FROM field_production WHERE field = 'Girassol'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EventAttendance (event_name VARCHAR(255), attendee_age INT, attendee_gender VARCHAR(50)); INSERT INTO EventAttendance (event_name, attendee_age, attendee_gender) VALUES ('Theater for All', 30, 'Male'), ('Theater for All', 40, 'Female'), ('Theater for All', 45, 'Non-binary'), ('Music for Everyone', 22, 'Mal... | What is the average age of attendees who attended 'Theater for All' and 'Music for Everyone' events? | SELECT AVG(attendee_age) FROM EventAttendance WHERE event_name IN ('Theater for All', 'Music for Everyone'); | gretelai_synthetic_text_to_sql |
CREATE TABLE initiative (id INT, name TEXT, location TEXT, economic_diversification_impact INT); INSERT INTO initiative (id, name, location, economic_diversification_impact) VALUES (1, 'Handicraft Training', 'Bangladesh', 50), (2, 'Agricultural Training', 'Pakistan', 70), (3, 'IT Training', 'Nepal', 90), (4, 'Fishery T... | Which community development initiatives have the lowest and highest economic diversification impact? | SELECT name, economic_diversification_impact FROM (SELECT name, economic_diversification_impact, RANK() OVER (ORDER BY economic_diversification_impact ASC) as low_rank, RANK() OVER (ORDER BY economic_diversification_impact DESC) as high_rank FROM initiative) sub WHERE low_rank = 1 OR high_rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation_projects ( id INT, name VARCHAR(255), location VARCHAR(255), funding FLOAT ); INSERT INTO climate_mitigation_projects (id, name, location, funding) VALUES (1, 'Project A', 'Brazil', 5000000); | What are the details of projects that have received funding for climate change mitigation in Brazil? | SELECT * FROM climate_mitigation_projects WHERE location = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (id INT, name TEXT, capacity FLOAT, region TEXT); INSERT INTO energy_storage (id, name, capacity, region) VALUES (4, 'GHI Battery', 4000, 'East'); | Delete the energy storage system with id 4 if it exists. | DELETE FROM energy_storage WHERE id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending (lender_name TEXT, total_loans_issued NUMERIC, country TEXT); INSERT INTO socially_responsible_lending (lender_name, total_loans_issued, country) VALUES ('Amalgamated Bank', 3456, 'USA'); INSERT INTO socially_responsible_lending (lender_name, total_loans_issued, country) VALUES... | List the top 5 socially responsible lenders in the US by total loans issued? | SELECT lender_name, total_loans_issued FROM socially_responsible_lending WHERE country = 'USA' ORDER BY total_loans_issued DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE FlightSafety(id INT, aircraft_id INT, manufacturer VARCHAR(255), flight_hours INT); INSERT INTO FlightSafety(id, aircraft_id, manufacturer, flight_hours) VALUES (1, 1001, 'Boeing', 12000), (2, 1002, 'Airbus', 10500), (3, 1003, 'Boeing', 18000), (4, 1004, 'Airbus', 12000), (5, 1005, 'Airbus', 11000); | What is the minimum flight hours for aircrafts manufactured by Airbus? | SELECT MIN(flight_hours) FROM FlightSafety WHERE manufacturer = 'Airbus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE passenger_counts (station VARCHAR(255), passenger_count INT); | List the stations with a passenger count greater than 1000, based on the 'passenger_counts' table. | SELECT station FROM passenger_counts WHERE passenger_count > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE tours (id INT, name TEXT, country TEXT, co2_emission FLOAT); INSERT INTO tours (id, name, country, co2_emission) VALUES (1, 'Tour A', 'Germany', 2.5), (2, 'Tour B', 'Germany', 3.2); | What is the average CO2 emission of tours in Germany? | SELECT AVG(co2_emission) FROM tours WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inspections (id INT, restaurant_id INT, location VARCHAR(50), rating INT); INSERT INTO Inspections (id, restaurant_id, location, rating) VALUES (1, 1, 'New York', 5); INSERT INTO Inspections (id, restaurant_id, location, rating) VALUES (2, 2, 'Los Angeles', 3); INSERT INTO Inspections (id, restaurant_id, l... | How many 4-star food safety inspections were there in Los Angeles? | SELECT COUNT(*) FROM Inspections WHERE location = 'Los Angeles' AND rating = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitats (id INT, region VARCHAR(255), habitat_type VARCHAR(255)); | how many wildlife habitats are there in each region? | SELECT region, COUNT(DISTINCT id) as num_habitats FROM wildlife_habitats GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), hectares DECIMAL(10,2)); CREATE TABLE animals (id INT PRIMARY KEY, species VARCHAR(50), population INT, forest_id INT, FOREIGN KEY (forest_id) REFERENCES forests(id)); INSERT INTO forests (id, name, country, hectares) VALUES (1, 'Savannah ... | Find the total hectares of forests in Africa with koala populations. | SELECT SUM(hectares) FROM forests INNER JOIN animals ON forests.id = animals.forest_id WHERE forests.country = 'Africa' AND animals.species = 'Koala'; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (expedition_name TEXT, year INT, new_species_discovered INT); INSERT INTO deep_sea_expeditions (expedition_name, year, new_species_discovered) VALUES ('Mariana Trench Exploration', 2017, 32), ('Atlantic Canyons Expedition', 2018, 28), ('Arctic Ocean Exploration', 2019, 15); | What is the average number of new species discovered per deep-sea expedition in the last 5 years? | SELECT AVG(new_species_discovered) FROM deep_sea_expeditions WHERE year >= 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE UnderwritingData (PolicyholderID INT, Smoker BOOLEAN, VehicleYear INT, HouseLocation VARCHAR(25)); INSERT INTO UnderwritingData (PolicyholderID, Smoker, VehicleYear, HouseLocation) VALUES (1, True, 2015, 'Urban'); INSERT INTO UnderwritingData (PolicyholderID, Smoker, VehicleYear, HouseLocation) VALUES (2, ... | What is the average risk score for policyholders living in rural areas? | SELECT AVG(RiskScore) FROM RiskAssessment WHERE PolicyholderID IN (SELECT PolicyholderID FROM UnderwritingData WHERE HouseLocation = 'Rural'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ClimateAdaptationProjects (project_id INT, project_name VARCHAR(50), continent VARCHAR(50), year INT); INSERT INTO ClimateAdaptationProjects (project_id, project_name, continent, year) VALUES (1, 'Coastal Protection', 'South America', 2020), (2, 'Drought Resistance', 'South America', 2021); | What is the number of climate adaptation projects in South America for each year? | SELECT continent, year, COUNT(*) as num_projects FROM ClimateAdaptationProjects WHERE continent = 'South America' GROUP BY continent, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); | Delete a record of a marine species from the 'marine_species' table | DELETE FROM marine_species WHERE species_name = 'Green Sea Turtle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (accommodation_id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), num_reviews INT, avg_review_score DECIMAL(5,2), country VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO accommodations (accommodation_id, name, location, type, num_reviews, avg_review_score, country, revenu... | What is the total revenue generated by sustainable tourism accommodations in each country? | SELECT country, SUM(revenue) AS total_revenue FROM accommodations GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapy_sessions_london (id INT, patient_id INT, session_date DATE); INSERT INTO therapy_sessions_london (id, patient_id, session_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'), (4, 3, '2021-04-01'), (5, 3, '2021-04-15'), (6, 4, '2021-05-01'); | What is the average number of therapy sessions per month for patients in London? | SELECT EXTRACT(MONTH FROM session_date) AS month, AVG(therapy_sessions_london.id) AS avg_sessions FROM therapy_sessions_london WHERE city = 'London' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE rice_yields (farmer_id INT, country VARCHAR(50), crop VARCHAR(50), yield INT, is_organic BOOLEAN); INSERT INTO rice_yields (farmer_id, country, crop, yield, is_organic) VALUES (1, 'Indonesia', 'Rice', 1000, true), (2, 'Indonesia', 'Rice', 1200, false), (3, 'Indonesia', 'Rice', 1500, true); | What is the average yield of rice crops in Indonesia, considering only organic farming methods? | SELECT AVG(yield) FROM rice_yields WHERE country = 'Indonesia' AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workers (ID INT, Age INT, Gender VARCHAR(10), Salary DECIMAL(5,2), Industry VARCHAR(20), Ethical_Training BOOLEAN); INSERT INTO Workers (ID, Age, Gender, Salary, Industry, Ethical_Training) VALUES (1, 42, 'Female', 50000.00, 'Textile', FALSE); INSERT INTO Workers (ID, Age, Gender, Salary, Industry, Ethical... | Insert a new record for a worker in the 'Electronics' industry who is 30 years old, male, earns a salary of $65,000, and has received ethical manufacturing training. | INSERT INTO Workers (ID, Age, Gender, Salary, Industry, Ethical_Training) VALUES (4, 30, 'Male', 65000.00, 'Electronics', TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE fire_data (fire_id INT, fire_type TEXT, district TEXT, date DATE); | How many fires were reported in the 'Harlem' district during each month in 2022? | SELECT district, EXTRACT(MONTH FROM date) AS month, COUNT(*) AS num_fires FROM fire_data WHERE district = 'Harlem' AND date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY district, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (claim_number INT, policy_number INT, claim_amount INT, claim_date DATE); | Update the claims table and insert a new claim record for policy number 3 with a claim amount of 5000 and claim date of '2021-03-15' | INSERT INTO claims (claim_number, policy_number, claim_amount, claim_date) VALUES (1, 3, 5000, '2021-03-15'); UPDATE claims SET claim_amount = 6000 WHERE policy_number = 3 AND claim_date = '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (id INT, habitat_type VARCHAR(255)); INSERT INTO habitats (id, habitat_type) VALUES (1, 'Forest'), (2, 'Savannah'), (3, 'Wetlands'); | Delete all records from the 'Habitats' table. | DELETE FROM habitats; | gretelai_synthetic_text_to_sql |
CREATE TABLE sector_year_consumption (year INT, sector INT, consumption FLOAT, PRIMARY KEY(year, sector)); INSERT INTO sector_year_consumption (year, sector, consumption) VALUES (2015, 1, 15000), (2015, 2, 20000), (2015, 3, 30000), (2016, 1, 16000), (2016, 2, 22000), (2016, 3, 32000), (2017, 1, 17000), (2017, 2, 24000)... | What is the total water consumption by each sector in the most recent year? | SELECT syc.sector, SUM(syc.consumption) as total_consumption FROM sector_year_consumption syc JOIN (SELECT MAX(year) as most_recent_year FROM sector_year_consumption) max_year ON 1=1 WHERE syc.year = max_year.most_recent_year GROUP BY syc.sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, project_id INT, name TEXT); INSERT INTO volunteers (id, project_id, name) VALUES (1, 1, 'Alice'), (2, 1, 'Bob'), (3, 2, 'Charlie'); CREATE TABLE projects (id INT, funder TEXT, total_funding DECIMAL); INSERT INTO projects (id, funder, total_funding) VALUES (1, 'European Union', 20000.00)... | How many total volunteers have there been in projects funded by the European Union? | SELECT COUNT(*) FROM volunteers INNER JOIN projects ON volunteers.project_id = projects.id WHERE projects.funder = 'European Union'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name VARCHAR(50), country VARCHAR(50), num_volunteers INT); INSERT INTO organizations (id, name, country, num_volunteers) VALUES (1, 'UNICEF', 'India', 500), (2, 'Red Cross', 'China', 700), (3, 'Greenpeace', 'Japan', 300); | Find the top 5 organizations with the largest number of volunteers in Asia. | SELECT name, num_volunteers FROM organizations WHERE country IN ('India', 'China', 'Japan', 'Pakistan', 'Indonesia') ORDER BY num_volunteers DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, monthly_bill FLOAT, city VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, monthly_bill, city) VALUES (1, 60.5, 'San Francisco'), (2, 70.3, 'Houston'), (3, 55.7, 'San Francisco'); | What is the minimum monthly bill for broadband subscribers in the city of San Francisco? | SELECT MIN(monthly_bill) FROM broadband_subscribers WHERE city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (garment_type VARCHAR(20)); INSERT INTO Inventory (garment_type) VALUES ('Dress'), ('Shirt'), ('Pants'), ('Unisex'); | List all unique garment types in the 'Inventory' table, excluding 'Unisex' entries. | SELECT DISTINCT garment_type FROM Inventory WHERE garment_type != 'Unisex'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Flight_Data (flight_date DATE, aircraft_model VARCHAR(255), flight_time TIME); INSERT INTO Flight_Data (flight_date, aircraft_model, flight_time) VALUES ('2020-01-01', 'Boeing 737', '03:00:00'), ('2020-02-01', 'Boeing 737', '04:00:00'), ('2020-03-01', 'Boeing 737', '05:00:00'), ('2020-04-01', 'Boeing 737',... | What is the maximum flight time for Boeing 737 aircraft? | SELECT MAX(EXTRACT(EPOCH FROM flight_time)) / 60.0 AS max_flight_time FROM Flight_Data WHERE aircraft_model = 'Boeing 737'; | gretelai_synthetic_text_to_sql |
CREATE TABLE albums (id INT, title TEXT, release_date DATE); INSERT INTO albums (id, title, release_date) VALUES (1, 'Millennium', '1999-12-31'), (2, 'Hybrid Theory', '2000-01-02'); | What is the earliest release date of any album? | SELECT MIN(release_date) FROM albums; | gretelai_synthetic_text_to_sql |
CREATE TABLE MineSites (SiteID INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), LaborProductivityDecimal FLOAT); CREATE VIEW LaborProductivityView AS SELECT Employees.SiteID, AVG(LaborProductivity.ProductivityDecimal) AS AverageProductivity FROM Employees JOIN LaborProductivity ON Employees.EmployeeID = LaborPro... | Identify the top 3 mine sites with the highest labor productivity. | SELECT MineSites.Name, AVG(LaborProductivityView.AverageProductivity) AS AverageProductivity FROM MineSites JOIN LaborProductivityView ON MineSites.SiteID = LaborProductivityView.SiteID GROUP BY MineSites.Name ORDER BY AverageProductivity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE MakeupSales (sale_id INT, product_name VARCHAR(100), category VARCHAR(50), price DECIMAL(10,2), quantity INT, sale_date DATE, country VARCHAR(50), vegan BOOLEAN); | What is the total revenue of vegan makeup products in the UK in 2021? | SELECT SUM(price * quantity) FROM MakeupSales WHERE category = 'Makeup' AND country = 'UK' AND vegan = TRUE AND sale_date >= '2021-01-01' AND sale_date < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN, price DECIMAL(5,2), attendance INT, fan_country VARCHAR(50));INSERT INTO teams (team_id, team_name) VALUES (1, 'Knicks'), (2, 'Lakers');INSERT INTO games (game_id, team_id, home_team, price, attendan... | List the number of fans from different countries who have attended home games of each team, excluding games with attendance less than 15000. | SELECT t.team_name, COUNT(DISTINCT g.fan_country) AS unique_fan_countries FROM teams t INNER JOIN games g ON t.team_id = g.team_id AND g.home_team = t.team_id WHERE g.attendance >= 15000 GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (restaurant VARCHAR(20), item_type VARCHAR(15), cost DECIMAL(5,2)); INSERT INTO Inventory (restaurant, item_type, cost) VALUES ('GreenLeaf', 'vegan', 5.50), ('GreenLeaf', 'gluten-free', 4.75), ('Sprout', 'vegan', 6.25), ('Sprout', 'gluten-free', 5.00); | Show the total inventory cost for 'vegan' and 'gluten-free' items across all restaurants. | SELECT SUM(cost) FROM Inventory WHERE item_type IN ('vegan', 'gluten-free'); | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayersLA (PlayerID INT, PlayerName VARCHAR(100), Country VARCHAR(50)); INSERT INTO PlayersLA (PlayerID, PlayerName, Country) VALUES (1, 'Pedro Alvarez', 'Brazil'), (2, 'Jose Garcia', 'Argentina'), (3, 'Maria Rodriguez', 'Colombia'); CREATE TABLE GameSessionsLA (SessionID INT, PlayerID INT, GameID INT); IN... | What is the count of players from Latin America who have played at least 5 different games? | SELECT COUNT(DISTINCT PlayerID) FROM (SELECT PlayerID FROM GameSessionsLA JOIN PlayersLA ON GameSessionsLA.PlayerID = PlayersLA.PlayerID GROUP BY PlayerID HAVING COUNT(DISTINCT GameID) >= 5) AS Subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE viewership (id INT, event VARCHAR(50), platform VARCHAR(20), viewers INT); INSERT INTO viewership (id, event, platform, viewers) VALUES (1, 'Music Concert', 'Streaming', 500000), (2, 'Sports Event', 'Streaming', 750000), (3, 'Movie Night', 'Theater', 300000); | How many viewers watched the 'Music Concert' from the 'Streaming' platform? | SELECT viewers FROM viewership WHERE event = 'Music Concert' AND platform = 'Streaming'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2), DonationPurpose VARCHAR(50)); CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), DonationType VARCHAR(50)); | What is the average donation amount for each category? | SELECT DonationPurpose, AVG(DonationAmount) FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID GROUP BY DonationPurpose; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainabilityMetrics (ProductID INT, SustainabilityRating INT, CarbonFootprint INT); INSERT INTO SustainabilityMetrics (ProductID, SustainabilityRating, CarbonFootprint) VALUES (1, 90, 50); INSERT INTO SustainabilityMetrics (ProductID, SustainabilityRating, CarbonFootprint) VALUES (2, 85, 75); | Assign a quartile rank based on carbon footprint, ordered by carbon footprint in ascending order. | SELECT ProductID, SustainabilityRating, CarbonFootprint, NTILE(4) OVER (ORDER BY CarbonFootprint ASC) as 'Quartile' FROM SustainabilityMetrics; | gretelai_synthetic_text_to_sql |
CREATE TABLE court_cases (case_id INT, judge_name TEXT, case_state TEXT); INSERT INTO court_cases (case_id, judge_name, case_state) VALUES (11111, 'Judge Smith', 'Texas'); INSERT INTO court_cases (case_id, judge_name, case_state) VALUES (22222, 'Judge Johnson', 'Texas'); | Identify the number of cases heard by each judge, along with the judge's name, in the state of Texas. | SELECT judge_name, COUNT(*) as cases_heard FROM court_cases WHERE case_state = 'Texas' GROUP BY judge_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (exhibition_id INT, exhibition_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO exhibitions (exhibition_id, exhibition_name, start_date, end_date) VALUES (1, 'Art of the Renaissance', '2020-01-01', '2020-12-31'); CREATE TABLE visitors (visitor_id INT, exhibition_id INT, age INT, ... | What was the average age of visitors who attended the 'Art of the Renaissance' exhibition? | SELECT AVG(age) FROM visitors WHERE exhibition_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT PRIMARY KEY, name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO campaigns (id, name, start_date, end_date) VALUES (7, 'Mindfulness in Daily Life', '2023-01-02', '2023-12-31'); | What are the campaigns running after January 1, 2023? | SELECT * FROM campaigns WHERE start_date >= '2023-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (sale_id INT, team VARCHAR(50), quantity INT); INSERT INTO ticket_sales (sale_id, team, quantity) VALUES (1, 'home_team', 100); INSERT INTO ticket_sales (sale_id, team, quantity) VALUES (2, 'away_team', 75); | How many tickets were sold for the home_team in the ticket_sales table? | SELECT SUM(quantity) FROM ticket_sales WHERE team = 'home_team'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, title VARCHAR(255), genre VARCHAR(255), century VARCHAR(255)); | Add a new exhibition with ID 3, title 'Surrealism in the 20th Century', genre 'Surrealism', and century '20th Century'. | INSERT INTO Exhibitions (id, title, genre, century) VALUES (3, 'Surrealism in the 20th Century', 'Surrealism', '20th Century'); | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genomic Solutions', 'USA', 5000000), (2, 'BioTech Innovations', 'Europe', 7000000), (3, 'Medical Innovations', 'UK', 6000000), (4, 'Innovative Biotech', 'India', 8000000)... | What is the total funding received by biotech startups located in India? | SELECT SUM(funding) FROM startups WHERE location = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (country VARCHAR(255), date DATE, price FLOAT); INSERT INTO carbon_prices VALUES ('USA', '2023-01-01', 10), ('Canada', '2023-01-01', 15), ('USA', '2023-02-01', 11), ('Canada', '2023-02-01', 16); | Identify the carbon price for a specific country on a particular date. | SELECT price FROM carbon_prices WHERE country = 'Canada' AND date = '2023-02-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE feedback (id INT, created_at DATETIME); INSERT INTO feedback (id, created_at) VALUES (1, '2023-01-01 12:34:56'), (2, '2023-01-15 10:20:34'), (3, '2023-02-20 16:45:01'); | What is the average number of citizen feedback records per month for 2023? | SELECT AVG(num_records) FROM (SELECT DATE_FORMAT(created_at, '%Y-%m') as month, COUNT(*) as num_records FROM feedback WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY month) as subquery; | gretelai_synthetic_text_to_sql |
SELECT * FROM policyholder_claim_info; | Write a SQL query to retrieve the policyholder information and corresponding claim data from the view you created | SELECT * FROM policyholder_claim_info; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation_projects (id INT, country VARCHAR(255), start_year INT, end_year INT, started INT); INSERT INTO agricultural_innovation_projects (id, country, start_year, end_year, started) VALUES (1, 'Nigeria', 2010, 2014, 1), (2, 'Nigeria', 2012, 2016, 1), (3, 'Nigeria', 2011, 2015, 1); | How many agricultural innovation projects were started in Nigeria between 2010 and 2014?' | SELECT COUNT(*) FROM agricultural_innovation_projects WHERE country = 'Nigeria' AND start_year >= 2010 AND end_year <= 2014 AND started = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, industry TEXT, founding_date DATE, founder_race TEXT); INSERT INTO startup (id, name, industry, founding_date, founder_race) VALUES (1, 'AptDeco', 'E-commerce', '2014-02-14', 'Black'), (2, 'Blavity', 'Media', '2014-07-17', 'Black'); | What is the number of startups founded by individuals from underrepresented racial or ethnic backgrounds in the tech sector? | SELECT COUNT(*) FROM startup WHERE industry = 'Tech' AND founder_race IN ('Black', 'Hispanic', 'Indigenous', 'Asian', 'Pacific Islander', 'Multiracial'); | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_program (id INT, name VARCHAR(50), age INT, location VARCHAR(30)); INSERT INTO volunteer_program (id, name, age, location) VALUES (1, 'John Doe', 25, 'New York'), (2, 'Jane Smith', 32, 'California'), (3, 'Alice Johnson', 22, 'Texas'); | What is the average age of volunteers in the 'volunteer_program' table? | SELECT AVG(age) FROM volunteer_program; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vaccination (ID INT, Age INT, Population INT, Vaccinated INT); INSERT INTO Vaccination (ID, Age, Population, Vaccinated) VALUES (1, 18, 1000, 800), (2, 19, 1000, 850), (3, 20, 1000, 750); | What is the percentage of the population that is fully vaccinated, broken down by age group? | SELECT Age, (SUM(Vaccinated) OVER (PARTITION BY Age)::FLOAT / SUM(Population) OVER (PARTITION BY Age)) * 100 as VaccinationPercentage FROM Vaccination; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_projects (project_id INT PRIMARY KEY, project_name VARCHAR(50), project_status VARCHAR(50)); | Update the 'project_status' for 'Project 123' in the 'research_projects' table to 'completed' | UPDATE research_projects SET project_status = 'completed' WHERE project_name = 'Project 123'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_address VARCHAR(64), user_address VARCHAR(64)); | Delete all smart contracts for a specific user '0xabc...'. | DELETE FROM smart_contracts WHERE user_address = '0xabc...'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INT, donation_date DATE, donation_amount FLOAT); INSERT INTO donations (donor_id, donation_date, donation_amount) VALUES (1, '2020-01-01', 50.00), (2, '2019-12-31', 100.00), (3, '2020-05-15', 25.00); | How many donations were made by first-time donors in the year 2020? | SELECT COUNT(*) FROM donations WHERE YEAR(donation_date) = 2020 AND donor_id NOT IN (SELECT donor_id FROM donations WHERE YEAR(donation_date) < 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), common_name VARCHAR(50), region VARCHAR(20));INSERT INTO marine_species (id, species_name, common_name, region) VALUES (1, 'Orcinus_orca', 'Killer Whale', 'Arctic');INSERT INTO marine_species (id, species_name, common_name, region) VALUES (2, 'Balaenoptera_... | Which marine species have been observed in more than one region? | SELECT species_name FROM marine_species GROUP BY species_name HAVING COUNT(DISTINCT region) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops(CropID INT, CropName VARCHAR(50), CropYield INT); INSERT INTO Crops(CropID, CropName, CropYield) VALUES (1, 'Corn', 25), (2, 'Soybean', 30), (3, 'Wheat', 18); | Delete all records in the 'Crops' table where the 'CropYield' is less than 20 | DELETE FROM Crops WHERE CropYield < 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE Refugees (RefugeeID INT, Region VARCHAR(20)); INSERT INTO Refugees (RefugeeID, Region) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'); | How many refugees were supported in each region? | SELECT Region, COUNT(RefugeeID) as NumRefugees FROM Refugees GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_metrics (brand VARCHAR(255) PRIMARY KEY, metric VARCHAR(255), value INT); INSERT INTO sustainable_metrics (brand, metric, value) VALUES ('AnotherBrand', 'CarbonFootprint', 12), ('BrandX', 'WaterConsumption', 15); | Insert a new record in the sustainable_metrics table for brand 'EcoFriendlyBrand', metric 'WaterConsumption' and value 10 | INSERT INTO sustainable_metrics (brand, metric, value) VALUES ('EcoFriendlyBrand', 'WaterConsumption', 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE fleet_management (vessel_id INT, vessel_name VARCHAR(50), total_capacity INT); INSERT INTO fleet_management (vessel_id, vessel_name, total_capacity) VALUES (1, 'Vessel_A', 5000), (2, 'Vessel_B', 6000), (3, 'Vessel_C', 4000); | What is the total capacity of containers for all vessels in the fleet_management table? | SELECT SUM(total_capacity) FROM fleet_management; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (region VARCHAR(50), subscriber_id INT); INSERT INTO mobile_subscribers VALUES ('Region A', 100); INSERT INTO mobile_subscribers VALUES ('Region A', 200); INSERT INTO mobile_subscribers VALUES ('Region B', 300); INSERT INTO mobile_subscribers VALUES ('Region C', 400); INSERT INTO broadba... | What is the total number of mobile and broadband subscribers for each sales region? | SELECT region, COUNT(mobile_subscribers.subscriber_id) + COUNT(broadband_subscribers.subscriber_id) as total_subscribers FROM mobile_subscribers FULL OUTER JOIN broadband_subscribers ON mobile_subscribers.region = broadband_subscribers.region GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryData (Country VARCHAR(20), Year INT, Visitors INT); INSERT INTO CountryData (Country, Year, Visitors) VALUES ('France', 2021, 6000), ('Spain', 2021, 4000), ('Germany', 2021, 7000), ('France', 2020, 5000); | List the countries that had more than 5000 visitors in 2021. | SELECT Country FROM CountryData WHERE Year = 2021 AND Visitors > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(255), grade INT, mental_health_score INT); INSERT INTO students (id, name, grade, mental_health_score) VALUES (1, 'Jane Doe', 12, 80); | What is the average mental health score for students in grade 12? | SELECT AVG(mental_health_score) FROM students WHERE grade = 12; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_costs (warehouse_id INT, warehouse_location VARCHAR(255), cost DECIMAL(10,2), quarter INT, year INT); INSERT INTO warehouse_costs (warehouse_id, warehouse_location, cost, quarter, year) VALUES (1, 'NYC Warehouse', 2500.00, 2, 2022), (2, 'LA Warehouse', 3000.00, 2, 2022), (3, 'CHI Warehouse', 2000... | What are the average warehouse management costs for each warehouse in Q2 2022? | SELECT warehouse_location, AVG(cost) as avg_cost FROM warehouse_costs WHERE quarter = 2 AND year = 2022 GROUP BY warehouse_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), avg_depth FLOAT); INSERT INTO marine_protected_areas (name, location, avg_depth) VALUES ('MPA 1', 'Indian Ocean', 700.0), ('MPA 2', 'Atlantic Ocean', 300.0); | Which marine protected areas in the Indian Ocean have an average depth greater than 500 meters? | SELECT name FROM marine_protected_areas WHERE location = 'Indian Ocean' AND avg_depth > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (id INT, location TEXT, type TEXT, date DATE); INSERT INTO violations (id, location, type, date) VALUES (1, 'California', 'wage theft', '2021-01-01'); CREATE TABLE months (id INT, month TEXT, year INT); INSERT INTO months (id, month, year) VALUES (1, 'January', 2021), (2, 'February', 2021); | What is the total number of labor rights violations reported each month, including months with no violations? | SELECT m.month, m.year, COALESCE(SUM(v.id), 0) FROM months m LEFT JOIN violations v ON EXTRACT(MONTH FROM v.date) = m.id AND EXTRACT(YEAR FROM v.date) = m.year GROUP BY m.month, m.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_abbr CHAR(2), state_name VARCHAR(50)); INSERT INTO states VALUES ('CA', 'California'), ('NY', 'New York'), ('TX', 'Texas'); CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR(100), state_abbr CHAR(2)); INSERT INTO hospitals VALUES (1, 'UCSF Medical Center', 'CA'), (2, 'NY Presbyte... | What is the number of hospitals and clinics in each state? | SELECT s.state_name, COUNT(h.hospital_id) AS hospitals, COUNT(c.clinic_id) AS clinics FROM states s LEFT JOIN hospitals h ON s.state_abbr = h.state_abbr LEFT JOIN clinics c ON s.state_abbr = c.state_abbr GROUP BY s.state_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_zones (id INT, zone VARCHAR(255), depth INT, pollution_level INT); INSERT INTO arctic_zones VALUES (1, 'Zone A', 4000, 30); INSERT INTO arctic_zones VALUES (2, 'Zone B', 5000, 20); INSERT INTO arctic_zones VALUES (3, 'Zone C', 3500, 45); | Find the average depth of the Arctic Ocean floor mapping project zones with pollution levels above the median. | SELECT AVG(depth) FROM arctic_zones WHERE pollution_level > (SELECT AVG(pollution_level) FROM arctic_zones); | gretelai_synthetic_text_to_sql |
CREATE TABLE DriverMaintenance (MaintenanceID INT, DriverID INT, MaintenanceCost DECIMAL(5,2), Service VARCHAR(50), MaintenanceDate DATE); INSERT INTO DriverMaintenance (MaintenanceID, DriverID, MaintenanceCost, Service, MaintenanceDate) VALUES (1, 1, 200.00, 'Tram', '2022-02-01'), (2, 1, 250.00, 'Tram', '2022-02-03'),... | What is the average maintenance cost for each driver in the 'Tram' service in the last month? | SELECT d.DriverName, AVG(dm.MaintenanceCost) as AvgMaintenanceCost FROM Drivers d JOIN DriverMaintenance dm ON d.DriverID = dm.DriverID WHERE d.Service = 'Tram' AND dm.MaintenanceDate >= DATEADD(month, -1, GETDATE()) GROUP BY d.DriverName; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_monthly (id INT, incident_date DATE, severity VARCHAR(10)); INSERT INTO incident_monthly (id, incident_date, severity) VALUES (1, '2022-01-01', 'Low'), (2, '2022-01-15', 'Medium'), (3, '2022-02-01', 'High'), (4, '2022-03-01', 'Critical'), (5, '2022-03-15', 'Low'), (6, '2022-04-01', 'Medium'); | Show the number of security incidents and their severity by month | SELECT EXTRACT(MONTH FROM incident_date) as month, severity, COUNT(*) as incidents FROM incident_monthly GROUP BY month, severity; | gretelai_synthetic_text_to_sql |
CREATE TABLE RealEstateCoOwnership.Properties (id INT, city VARCHAR(50)); INSERT INTO RealEstateCoOwnership.Properties (id, city) VALUES (1, 'San Francisco'), (2, 'New York'); CREATE TABLE RealEstateCoOwnership.CoOwnership (property_id INT, coowner VARCHAR(50)); INSERT INTO RealEstateCoOwnership.CoOwnership (property_i... | List all co-owned properties and their corresponding city in the RealEstateCoOwnership schema. | SELECT Properties.id, Properties.city, CoOwnership.coowner FROM RealEstateCoOwnership.Properties INNER JOIN RealEstateCoOwnership.CoOwnership ON Properties.id = CoOwnership.property_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (id INT, name TEXT, state TEXT, community_service_hours INT); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (1, 'John Doe', 'Washington', 50); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (2, 'Jane Smith', 'Oregon', 75); INSERT INTO offenders (... | How many community service hours were completed by offenders in each state? | SELECT state, SUM(community_service_hours) FROM offenders GROUP BY state | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, Gender TEXT, Department TEXT, WeeklyWage DECIMAL); | What is the average weekly wage for male workers in the 'Manufacturing' industry? | SELECT AVG(WeeklyWage) FROM Employees WHERE Gender = 'Male' AND Department = 'Manufacturing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT PRIMARY KEY, product_name TEXT, discontinued_date DATE); | Delete records of products that have been discontinued in the past 3 years from the products table. | DELETE FROM products WHERE discontinued_date >= DATE(NOW()) - INTERVAL 3 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), City VARCHAR(50), State VARCHAR(20)); INSERT INTO Members (MemberID, Name, Age, Gender, City, State) VALUES (1011, 'Ella Nguyen', 33, 'Female', 'Hanoi', 'Vietnam'); INSERT INTO Members (MemberID, Name, Age, Gender, City, State) VALUES (1... | SELECT MemberID, COUNT(*) as WorkoutCountLastMonth FROM Workouts WHERE DATE_TRUNC('month', Date) = DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') GROUP BY MemberID ORDER BY WorkoutCountLastMonth DESC; | SELECT MemberID, WorkoutType, DATE_TRUNC('hour', Date) as Hour, COUNT(*) as WorkoutCountPerHour FROM Workouts GROUP BY MemberID, WorkoutType, Hour ORDER BY Hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthcareAccess (Location VARCHAR(50), Continent VARCHAR(50), Year INT, Score FLOAT); INSERT INTO HealthcareAccess (Location, Continent, Year, Score) VALUES ('Rural', 'Africa', 2018, 65.2), ('Urban', 'Africa', 2018, 80.5); | What is the healthcare access score for urban areas in Africa in 2018? | SELECT Score FROM HealthcareAccess WHERE Location = 'Urban' AND Continent = 'Africa' AND Year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_companies (id INT PRIMARY KEY, name VARCHAR(50), year_founded INT, region VARCHAR(50)); INSERT INTO ai_companies (id, name, year_founded, region) VALUES (1, 'AlphaAI', 2010, 'North America'); INSERT INTO ai_companies (id, name, year_founded, region) VALUES (2, 'BetaTech', 2015, 'Europe'); INSERT INTO ai... | Who are the founders of AI companies in 'Asia' and when were they founded? | SELECT name, year_founded FROM ai_companies WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, CaseOpenDate DATETIME, CaseCloseDate DATETIME); | List all cases that were opened more than 30 days ago, but have not yet been closed. | SELECT CaseID, CaseOpenDate, CaseCloseDate FROM Cases WHERE CaseOpenDate < DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND CaseCloseDate IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE ContractNegotiations (contract_id INT, contractor VARCHAR(50), contract_cost DECIMAL(10, 2)); INSERT INTO ContractNegotiations (contract_id, contractor, contract_cost) VALUES (1, 'ABC', 1000000.00); INSERT INTO ContractNegotiations (contract_id, contractor, contract_cost) VALUES (2, 'DEF', 2000000.00); | What is the total number of contracts negotiated by each contractor and their total cost? | SELECT contractor, COUNT(*) as total_contracts, SUM(contract_cost) as total_cost FROM ContractNegotiations GROUP BY contractor; | gretelai_synthetic_text_to_sql |
CREATE TABLE Safety_Tests_2 (Test_Quarter INT, Vehicle_Type VARCHAR(20)); INSERT INTO Safety_Tests_2 (Test_Quarter, Vehicle_Type) VALUES (1, 'Autonomous'), (1, 'Gasoline'), (2, 'Autonomous'), (2, 'Gasoline'), (3, 'Autonomous'), (3, 'Gasoline'), (4, 'Autonomous'), (4, 'Gasoline'); | How many safety tests were conducted on autonomous vehicles in Q1 2021? | SELECT COUNT(*) FROM Safety_Tests_2 WHERE Vehicle_Type = 'Autonomous' AND Test_Quarter = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_rentals (id INT, equipment_id INT, rental_dates DATE); | Delete records in the 'equipment_rentals' table that have rental_dates older than 2 years | DELETE FROM equipment_rentals WHERE rental_dates < DATE_SUB(CURDATE(), INTERVAL 2 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, category VARCHAR(255), description TEXT, created_at TIMESTAMP); INSERT INTO cases (id, category, description, created_at) VALUES (1, 'Civil', 'Case description 1', '2021-01-01 10:00:00'), (2, 'Criminal', 'Case description 2', '2021-01-02 10:00:00'), (3, 'Civil', 'Case description 3', '2021-0... | What is the total number of cases in each category, ordered by the total count? | SELECT category, COUNT(*) as total_cases FROM cases GROUP BY category ORDER BY total_cases DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE HumanitarianAssistance (Country VARCHAR(50), Year INT, Amount FLOAT); INSERT INTO HumanitarianAssistance (Country, Year, Amount) VALUES ('Country 1', 2009, 1000000), ('Country 2', 2009, 1100000); | What was the total humanitarian assistance provided in 2009? | SELECT SUM(Amount) FROM HumanitarianAssistance WHERE Year = 2009; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (id, name, donation_amount, donation_date) VALUES (1, 'John Doe', 1000.00, '2020-01-05'); INSERT INTO donors (id, name, donation_amount, donation_date) VALUES (2, 'Jane Smith', 1500.00, '2020-03-12'); | Who are the top 3 donors in terms of total donation amount in 2020, and how much did they donate in total? | SELECT name, SUM(donation_amount) AS total_donation FROM donors WHERE donation_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY name ORDER BY total_donation DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE HybridSales (Id INT, Vehicle VARCHAR(255), ModelYear INT, State VARCHAR(255), QuantitySold INT, Quarter INT); INSERT INTO HybridSales (Id, Vehicle, ModelYear, State, QuantitySold, Quarter) VALUES (1, 'Toyota Prius', 2021, 'Washington', 3000, 4), (2, 'Honda Insight', 2021, 'Washington', 1500, 4), (3, 'Hyund... | How many hybrid vehicles were sold in Washington in Q4 of 2021? | SELECT SUM(QuantitySold) FROM HybridSales WHERE ModelYear = 2021 AND State = 'Washington' AND Quarter = 4 AND Vehicle LIKE '%Hybrid%' | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), area_size FLOAT, region VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, area_size, region) VALUES (1, 'Chagos Marine Reserve', 640000, 'Indian'); | What is the maximum size of a marine protected area (in square kilometers) in the Indian Ocean? | SELECT MAX(area_size) FROM marine_protected_areas WHERE region = 'Indian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Education_Programs AS SELECT 'Young_Protectors' AS program, 11000 AS budget UNION SELECT 'Green_Champions', 13000; | What is the minimum budget for any education program? | SELECT MIN(budget) FROM Education_Programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_platform (id INT, genre VARCHAR(50), streams INT, country VARCHAR(50)); | What is the total number of streams for all songs in the R&B genre on the music streaming platform in Germany? | SELECT SUM(streams) as total_streams FROM music_platform WHERE genre = 'R&B' AND country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_agency_leaders (id INT, agency_name VARCHAR(255), leader_name VARCHAR(255), leader_background TEXT); INSERT INTO intelligence_agency_leaders (id, agency_name, leader_name, leader_background) VALUES (1, 'CSIS', 'David Vigneault', 'David Vigneault has been the Director of the Canadian Security I... | Who is the head of the Canadian Security Intelligence Service and what is their background? | SELECT leader_name, leader_background FROM intelligence_agency_leaders WHERE agency_name = 'CSIS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, drill_date DATE); INSERT INTO wells (well_id, drill_date) VALUES (1, '2018-01-01'), (2, '2019-01-01'), (3, '2020-01-01'), (4, '2021-01-01'), (5, '2022-01-01'); | How many wells were drilled each year in the last 5 years? | SELECT YEAR(drill_date) AS Year, COUNT(*) AS Number_of_Wells FROM wells WHERE drill_date >= DATEADD(year, -5, GETDATE()) GROUP BY YEAR(drill_date) ORDER BY Year | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_date DATE, customer_id INT, transaction_amt DECIMAL(10, 2)); INSERT INTO transactions (transaction_date, customer_id, transaction_amt) VALUES ('2022-01-01', 1, 200.00), ('2022-01-02', 1, 250.00), ('2022-01-03', 1, 300.00); | What is the difference in transaction amount between consecutive transactions for each customer? | SELECT transaction_date, customer_id, transaction_amt, LAG(transaction_amt, 1) OVER (PARTITION BY customer_id ORDER BY transaction_date) AS previous_transaction_amt, transaction_amt - LAG(transaction_amt, 1) OVER (PARTITION BY customer_id ORDER BY transaction_date) AS transaction_diff FROM transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE reefs (reef_id INT, reef_name TEXT, temperature FLOAT, depth FLOAT, conservation_status TEXT); | Update the 'reefs' table to set the conservation_status to 'critical' for the reef with reef_id '10'. | UPDATE reefs SET conservation_status = 'critical' WHERE reef_id = 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (SaleID INT, Item TEXT, Region TEXT, IsEcoFriendly BOOLEAN); INSERT INTO Sales (SaleID, Item, Region, IsEcoFriendly) VALUES (1, 'T-Shirt', 'North', TRUE), (2, 'Pants', 'South', FALSE), (3, 'Jacket', 'East', TRUE), (4, 'Hat', 'West', FALSE); | What are the total sales of eco-friendly clothing items in each region? | SELECT Region, SUM(TotalSales) FROM (SELECT Region, Item, IsEcoFriendly, COUNT(*) AS TotalSales FROM Sales GROUP BY Region, Item, IsEcoFriendly) AS Subquery WHERE IsEcoFriendly = TRUE GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-01-02'), (3, 3, '2021-01-03'); CREATE TABLE users (id INT, country VARCHAR(50)); INSERT INTO users (id, country) VALUES (1, 'Iran'), (2, 'Saudi Arabia'), (3, 'Turkey'); | Show the number of posts made by users from the Middle East, grouped by day of the week. | SELECT DATE_FORMAT(post_date, '%W') as day_of_week, COUNT(*) as post_count FROM posts JOIN users ON posts.user_id = users.id WHERE users.country IN ('Iran', 'Saudi Arabia', 'Turkey') GROUP BY day_of_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE DroughtImpact (Id INT, Location VARCHAR(50), Impact DECIMAL(5,2), Date DATE); INSERT INTO DroughtImpact (Id, Location, Impact, Date) VALUES (1, 'Texas', 0.8, '2021-06-15'); INSERT INTO DroughtImpact (Id, Location, Impact, Date) VALUES (2, 'Texas', 0.6, '2021-07-01'); | On which dates did Texas have a drought impact greater than 0.7? | SELECT Date, AVG(Impact) FROM DroughtImpact WHERE Location = 'Texas' GROUP BY Date HAVING AVG(Impact) > 0.7; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_nutrient_levels (crop_type VARCHAR(255), nutrient_name VARCHAR(255), level INT, record_date DATE); INSERT INTO crop_nutrient_levels (crop_type, nutrient_name, level, record_date) VALUES ('corn', 'nitrogen', 100, '2022-02-01'), ('soybeans', 'nitrogen', 110, '2022-02-02'), ('corn', 'nitrogen', 95, '2022... | Update the nitrogen level for crop type 'wheat' to 120 in the last 60 days. | UPDATE crop_nutrient_levels SET level = 120 WHERE crop_type = 'wheat' AND record_date >= DATE_SUB(CURDATE(), INTERVAL 60 DAY); | 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.