context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE CommunityDevelopment (id INT, country VARCHAR(50), initiative VARCHAR(50), budget FLOAT, year INT); INSERT INTO CommunityDevelopment (id, country, initiative, budget, year) VALUES (1, 'Tanzania', 'Youth Skills Training', 300000, 2018), (2, 'Tanzania', 'Community Health Center', 500000, 2019), (3, 'Kenya', ... | What was the total budget for community development initiatives in Tanzania in 2018? | SELECT SUM(budget) FROM CommunityDevelopment WHERE country = 'Tanzania' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_properties2 (id INT, city VARCHAR(20), green_score INT); INSERT INTO sustainable_properties2 (id, city, green_score) VALUES (1, 'New_York', 75), (2, 'Los_Angeles', 60), (3, 'Chicago', 80); | How many properties in the 'sustainable_properties2' table have a 'green_score' less than 70? | SELECT COUNT(*) FROM sustainable_properties2 WHERE green_score < 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name TEXT, sport TEXT); CREATE TABLE competitions (id INT, athlete INT, event TEXT); | List all the athletes who have competed in both the Olympics and Commonwealth Games. | SELECT a.name FROM athletes a INNER JOIN competitions c1 ON a.id = c1.athlete INNER JOIN competitions c2 ON a.id = c2.athlete WHERE c1.event = 'Olympics' AND c2.event = 'Commonwealth Games'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerName VARCHAR(255), TournamentWins INT); INSERT INTO Players (PlayerName, TournamentWins) VALUES ('PlayerA', 12), ('PlayerB', 8), ('PlayerC', 15), ('PlayerD', 6), ('PlayerE', 11); | Who are the eSports players with more than 10 wins in "Call of Duty" tournaments? | SELECT PlayerName FROM Players WHERE TournamentWins > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, employee_id INT, salary INT, salary_date DATE, department VARCHAR(255)); INSERT INTO salaries (id, employee_id, salary, salary_date, department) VALUES (1, 201, 50000, '2020-01-01', 'Sales'); INSERT INTO salaries (id, employee_id, salary, salary_date, department) VALUES (2, 202, 60000, '2... | Show the total salaries for employees who changed their department in 2020 | SELECT SUM(salary) FROM salaries JOIN department_changes ON salaries.employee_id = department_changes.employee_id WHERE YEAR(department_changes.change_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(50), developer_id INT, gas_price DECIMAL(10,2), network VARCHAR(50)); INSERT INTO smart_contracts (contract_id, name, developer_id, gas_price, network) VALUES (1, 'SmartContract1', 1, 21000, 'Ethereum'), (2, 'SmartContract2', 2, 19000, 'Ethereum'); | What are the names and gas prices of smart contracts on the Ethereum network with gas prices above the average? | SELECT smart_contracts.name, smart_contracts.gas_price FROM smart_contracts WHERE smart_contracts.network = 'Ethereum' AND smart_contracts.gas_price > (SELECT AVG(smart_contracts.gas_price) FROM smart_contracts WHERE smart_contracts.network = 'Ethereum'); | gretelai_synthetic_text_to_sql |
CREATE TABLE case_outcomes (case_id INT, mediator_id INT, case_duration INT); | What is the average duration of cases for each mediator in the 'case_outcomes' table? | SELECT mediator_id, AVG(case_duration) AS avg_duration FROM case_outcomes GROUP BY mediator_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Freight_Forwarders (forwarder_id INT, name TEXT); CREATE TABLE Shipments (shipment_id INT, forwarder_id INT, origin_country TEXT, destination_country TEXT, units_shipped INT); INSERT INTO Freight_Forwarders (forwarder_id, name) VALUES (1, 'FF1'), (2, 'FF2'); INSERT INTO Shipments (shipment_id, forwarder_id... | Which freight forwarders have shipped more than 1000 units from the USA to Mexico? | SELECT f.name FROM Freight_Forwarders f INNER JOIN Shipments s ON f.forwarder_id = s.forwarder_id WHERE s.origin_country = 'USA' AND s.destination_country = 'Mexico' GROUP BY f.name HAVING SUM(s.units_shipped) > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, region VARCHAR(20), response_time INT); | What is the maximum response time for emergency calls in 'Riverdale'? | SELECT MAX(response_time) FROM emergency_calls WHERE region = 'Riverdale'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(10), City VARCHAR(50)); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (1, 25, 'Male', 'Paris'); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (2, 32, 'Female', 'Paris'); CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50),... | What is the average age of visitors who attended exhibitions in Paris? | SELECT AVG(Visitors.Age) FROM Visitors INNER JOIN Attendance ON Visitors.VisitorID = Attendance.VisitorID INNER JOIN Exhibitions ON Attendance.ExhibitionID = Exhibitions.ExhibitionID WHERE Visitors.City = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE geothermal_plants (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), capacity FLOAT); INSERT INTO geothermal_plants (id, country, name, capacity) VALUES (1, 'Indonesia', 'Geothermal Plant A', 100.5), (2, 'Indonesia', 'Geothermal Plant B', 115.2); | What is the maximum capacity of geothermal plants in Indonesia? | SELECT MAX(capacity) FROM geothermal_plants WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE medical_procedures (procedure_id INT, patient_id INT, hospital_id INT, procedure_date DATE, procedure_name TEXT); INSERT INTO medical_procedures (procedure_id, patient_id, hospital_id, procedure_date, procedure_name) VALUES (1, 1, 1, '2022-01-01', 'Surgery'); CREATE TABLE patient (patient_id INT, patient_n... | What is the total number of medical procedures performed in hospitals located in the rural areas of "Colorado" for patients with diabetes? | SELECT SUM(procedures) FROM (SELECT patient_id, COUNT(*) as procedures FROM medical_procedures WHERE patient.diagnosis = 'Diabetes' GROUP BY patient_id) as subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_name VARCHAR(255), budget INT); INSERT INTO cities (city_name, budget) VALUES ('Vancouver', 1800000), ('Montreal', 2000000); CREATE TABLE services (service_name VARCHAR(255), city_name VARCHAR(255), budget INT); INSERT INTO services (service_name, city_name, budget) VALUES ('waste management',... | What is the total budget allocated for waste management and housing services in the city of Vancouver? | SELECT SUM(budget) FROM services WHERE city_name = 'Vancouver' AND service_name IN ('waste management', 'housing'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts(astronaut_id INT, name VARCHAR(50), country VARCHAR(50), missions INT); | list all astronauts with more than 5 space missions | SELECT name FROM Astronauts WHERE missions > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS workers (id INT, sector VARCHAR(20), wage DECIMAL(5,2), is_union_member BOOLEAN); INSERT INTO workers (id, sector, wage, is_union_member) VALUES (1, 'manufacturing', 50000.00, true), (2, 'manufacturing', 55000.00, true), (3, 'retail', 30000.00, false); | What is the average wage of unionized workers in the 'manufacturing' sector? | SELECT AVG(wage) FROM workers WHERE sector = 'manufacturing' AND is_union_member = true; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS Cybersecurity; CREATE TABLE IF NOT EXISTS Cybersecurity.Cyber_Strategies (strategy_id INT, strategy_name VARCHAR(255), description TEXT); INSERT INTO Cybersecurity.Cyber_Strategies (strategy_id, strategy_name, description) VALUES (1, 'NIST Cybersecurity Framework', 'Provides guidelines for m... | How many cybersecurity strategies are available for the 'Cybersecurity' schema? | SELECT COUNT(*) FROM Cybersecurity.Cyber_Strategies; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralInfrastructure (location VARCHAR(50), year INT, precipitation FLOAT); | What is the average annual precipitation in the 'RuralInfrastructure' table? | SELECT AVG(precipitation) FROM (SELECT precipitation, ROW_NUMBER() OVER(PARTITION BY location ORDER BY year) as rn FROM RuralInfrastructure) WHERE rn = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (city VARCHAR(50), building_type VARCHAR(50), num_buildings INT); INSERT INTO green_buildings (city, building_type, num_buildings) VALUES ('NYC', 'Residential', 1000), ('NYC', 'Commercial', 2000), ('LA', 'Residential', 1500), ('LA', 'Commercial', 2500); | How many green buildings are there in each city, broken down by building type? | SELECT city, building_type, SUM(num_buildings) FROM green_buildings GROUP BY city, building_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (CityID INT, CityName VARCHAR(50)); INSERT INTO City (CityID, CityName) VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE Fares (FareID INT, FareAmount DECIMAL(5,2), CityID INT); INSERT INTO Fares (FareID, FareAmount, CityID) VALUES (1, 2.50, 1), (2, 3.00, 1), (3, 2.75, 2), (4, 3.25, 2); | What is the average fare of public transportation in CityA and CityB? | SELECT AVG(FareAmount) FROM Fares INNER JOIN City ON Fares.CityID = City.CityID WHERE City.CityName IN ('CityA', 'CityB'); | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_id INT, region VARCHAR(10), technology VARCHAR(20), installed_capacity INT); INSERT INTO renewable_projects (project_id, region, technology, installed_capacity) VALUES (1, 'NA', 'Wind', 4000), (2, 'NA', 'Solar', 5000), (3, 'NA', 'Wind', 3000), (4, 'NA', 'Solar', 6000); | What are the total installed capacities of wind and solar projects in North America and their respective averages? | SELECT 'NA' AS region, SUM(installed_capacity) FILTER (WHERE technology = 'Wind') AS wind_capacity, AVG(installed_capacity) FILTER (WHERE technology = 'Wind') AS wind_avg, SUM(installed_capacity) FILTER (WHERE technology = 'Solar') AS solar_capacity, AVG(installed_capacity) FILTER (WHERE technology = 'Solar') AS solar_... | gretelai_synthetic_text_to_sql |
CREATE TABLE space_company (name TEXT, satellites_deployed INTEGER); INSERT INTO space_company (name, satellites_deployed) VALUES ('SpaceX', 2000); CREATE TABLE spacex_satellites (id INTEGER, name TEXT, launch_year INTEGER); INSERT INTO spacex_satellites (id, name, launch_year) VALUES (1, 'Starlink 1', 2019), (2, 'Star... | What is the average launch year of SpaceX satellites? | SELECT AVG(launch_year) FROM spacex_satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT PRIMARY KEY, company VARCHAR(50), launch_year INT); INSERT INTO satellites (id, company, launch_year) VALUES (1, 'SpaceX', 2018), (2, 'Rocket Lab', 2019), (3, 'SpaceX', 2020), (4, 'Rocket Lab', 2021); | What is the latest launch year for a satellite? | SELECT MAX(launch_year) FROM satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, ad_revenue DECIMAL(10,2), hashtags TEXT, post_date DATE); | What is the total revenue earned from ads targeting users in Germany, in the last week, for posts containing the hashtag #business? | SELECT SUM(ad_revenue) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'Germany' AND hashtags LIKE '%#business%' AND post_date >= DATE(NOW()) - INTERVAL 1 WEEK; | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding (Id INT, Amount DECIMAL(10,2), FundingSource VARCHAR(50), ProgramId INT);CREATE TABLE PerformingArtsPrograms (Id INT, State VARCHAR(5), Category VARCHAR(50)); | What is the total funding received for performing arts programs, broken down by state and program category? | SELECT P.State, P.Category, SUM(F.Amount) FROM Funding F INNER JOIN PerformingArtsPrograms P ON F.ProgramId = P.Id GROUP BY P.State, P.Category; | gretelai_synthetic_text_to_sql |
CREATE TABLE banks (id INT PRIMARY KEY, bank_name VARCHAR(255), region_id INT, is_shariah_compliant BOOLEAN); CREATE TABLE transactions (id INT PRIMARY KEY, bank_id INT, transaction_date DATE, amount DECIMAL(10,2)); CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE VIEW bank_tra... | Identify the top 3 most active Shariah-compliant financial institutions in the Middle East by transaction count. | SELECT active_banks.bank_name, active_banks.transaction_count FROM active_banks WHERE active_banks.transaction_count IN (SELECT transaction_count FROM (SELECT active_banks.transaction_count FROM active_banks WHERE active_banks.country = 'Middle East' AND active_banks.is_shariah_compliant = TRUE ORDER BY transaction_cou... | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_storage_tanks (tank_id INT, tank_name VARCHAR(50), last_inspection_date DATE); INSERT INTO chemical_storage_tanks (tank_id, tank_name, last_inspection_date) VALUES (1, 'Tank 1', '2021-01-01'), (2, 'Tank 2', '2021-06-01'); | Which chemical storage tanks have not been inspected in the past year? | SELECT tank_id, tank_name FROM chemical_storage_tanks WHERE last_inspection_date < DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE FDAInspections (id INT, facilityId INT, region VARCHAR(50), inspectionDate DATE); | How many times has the FDA inspected facilities in the Northeast region in the past year? | SELECT COUNT(*) FROM FDAInspections WHERE region = 'Northeast' AND inspectionDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (drug VARCHAR(255), approval_date DATE, company VARCHAR(255), approval_status VARCHAR(255)); INSERT INTO drug_approval (drug, approval_date, company, approval_status) VALUES ('Otezla', '2015-09-30', 'Celgene', 'Approved'); | Which drugs were approved between 2015 and 2017 and what is their approval status? | SELECT drug, approval_status FROM drug_approval WHERE approval_date BETWEEN '2015-01-01' AND '2017-12-31' AND approval_status = 'Approved'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Playtime INT); INSERT INTO Players (PlayerID, Age, Gender, Playtime) VALUES (1, 25, 'Male', 10); INSERT INTO Players (PlayerID, Age, Gender, Playtime) VALUES (2, 30, 'Female', 15); INSERT INTO Players (PlayerID, Age, Gender, Playtime) VALUES (3, 22, 'Male... | Who are the top 5 players with the highest playtime? | SELECT Players.PlayerID, Players.Playtime FROM Players ORDER BY Players.Playtime DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, treatment VARCHAR(10)); INSERT INTO patients (patient_id, age, treatment) VALUES (1, 35, 'CBT'), (2, 42, 'CBT'), (3, 28, 'Medication'); CREATE TABLE outcomes (patient_id INT, improvement BOOLEAN); INSERT INTO outcomes (patient_id, improvement) VALUES (1, TRUE), (2, TRUE),... | What is the average age of patients who improved after cognitive behavioral therapy (CBT) treatment? | SELECT AVG(patients.age) FROM patients INNER JOIN outcomes ON patients.patient_id = outcomes.patient_id WHERE outcomes.improvement = TRUE AND patients.treatment = 'CBT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, donation_date DATE, amount DECIMAL, donor_gender VARCHAR); INSERT INTO donations (id, donor_id, donation_date, amount, donor_gender) VALUES (1, 1, '2022-01-01', 100.00, 'Female'), (2, 2, '2022-02-01', 150.00, 'Male'), (3, 3, '2022-03-01', 120.00, 'Non-binary'); CREATE TABLE... | What is the total amount donated by each gender in the last year? | SELECT donor_gender, SUM(amount) FROM donations d INNER JOIN donors donor ON d.donor_id = donor.id WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY donor_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation (id INT, region VARCHAR(50), budget DECIMAL(10, 2)); INSERT INTO agricultural_innovation (id, region, budget) VALUES (1, 'region_1', 100000.00); INSERT INTO agricultural_innovation (id, region, budget) VALUES (2, 'region_2', 150000.00); | What is the minimum budget for any agricultural innovation project? | SELECT MIN(budget) FROM agricultural_innovation; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, Name TEXT, TotalDonation FLOAT); INSERT INTO Donors (DonorID, Name, TotalDonation) VALUES (1, 'John Smith', 500.00), (2, 'Jane Doe', 350.00); | What's the total amount donated by each donor? | SELECT Name, SUM(TotalDonation) FROM Donors GROUP BY Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Research_Projects (ID INT, Year INT, Sub_Domain VARCHAR(50), Number_Of_Projects INT); INSERT INTO Research_Projects (ID, Year, Sub_Domain, Number_Of_Projects) VALUES (1, 2015, 'Space Exploration', 20), (2, 2015, 'Aircraft Manufacturing', 30), (3, 2016, 'Space Exploration', 25), (4, 2016, 'Aircraft Manufact... | What is the total number of research projects conducted in the aerospace domain per year, broken down by sub-domain? | SELECT Year, Sub_Domain, SUM(Number_Of_Projects) FROM Research_Projects GROUP BY Year, Sub_Domain; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, OfficeLocation VARCHAR(255), WinRate DECIMAL); CREATE TABLE Cases (CaseID INT, AttorneyID INT, CaseOutcome VARCHAR(10)); | What is the percentage of cases won by attorneys from the 'San Francisco' office? | SELECT AVG(WinRate) FROM Attorneys JOIN Cases ON Attorneys.AttorneyID = Cases.AttorneyID WHERE OfficeLocation = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleSales (Type VARCHAR(50), Country VARCHAR(50), Sales INT); INSERT INTO VehicleSales (Type, Country, Sales) VALUES ('Electric', 'India', 50000), ('Gasoline', 'India', 2000000), ('Diesel', 'India', 1500000); | What is the market share of electric vehicles in India? | SELECT (Sales * 100.0 / (SELECT SUM(Sales) FROM VehicleSales WHERE Country = 'India')) FROM VehicleSales WHERE Type = 'Electric' AND Country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Devices (id INT, name VARCHAR(50), company VARCHAR(50), price DECIMAL(5,2), country VARCHAR(50)); INSERT INTO Devices (id, name, company, price, country) VALUES (1, 'Phone X', 'ABC Tech', 200.00, 'Egypt'), (2, 'Tablet Y', 'XYZ Enterprises', 350.00, 'South Africa'), (3, 'Laptop Z', 'Tech for Good', 700.00, ... | What is the average price of devices produced by companies located in Africa? | SELECT AVG(price) FROM Devices WHERE country IN ('Egypt', 'South Africa', 'Nigeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE machines (id INT, name VARCHAR(255), category VARCHAR(255), production_date DATE); INSERT INTO machines (id, name, category, production_date) VALUES (1, 'ABC Machine', 'ethical_manufacturing', '2008-01-01'), (2, 'XYZ Machine', 'ethical_manufacturing', '2012-01-01'), (3, 'DEF Machine', 'ethical_manufacturin... | What is the total number of machines in the 'ethical_manufacturing' category that were produced before 2010? | SELECT COUNT(*) FROM machines WHERE category = 'ethical_manufacturing' AND production_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (event_id INT, event_name TEXT, year INT, game TEXT); INSERT INTO esports_events (event_id, event_name, year, game) VALUES (1, 'DreamHack Masters', 2020, 'CS:GO'), (2, 'League of Legends World Championship', 2020, 'League of Legends'), (3, 'International Dota 2 Championships', 2019, 'Dota 2'... | How many esports events were held for each game in 2020? | SELECT games.game, COUNT(esports_events.event_id) FROM esports_events JOIN games ON esports_events.game = games.game WHERE esports_events.year = 2020 GROUP BY games.game; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArtCountry (id INT, type VARCHAR(255), country VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO TraditionalArtCountry (id, type, country, price) VALUES (1, 'Painting', 'Japan', 300), (2, 'Sculpture', 'Japan', 600), (3, 'Pottery', 'Mexico', 200); | How many traditional art pieces were created in each country and their average prices? | SELECT country, type, COUNT(*) as total_pieces, AVG(price) as avg_price FROM TraditionalArtCountry GROUP BY country, type; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryVehicles (id INT, year INT, make VARCHAR(255), model VARCHAR(255), quantity INT); INSERT INTO MilitaryVehicles (id, year, make, model, quantity) VALUES (1, 2018, 'Humvee', 'M998', 500), (2, 2020, 'Humvee', 'M1151', 700), (3, 2019, 'Tank', 'M1 Abrams', 300), (4, 2020, 'Tank', 'M1A2 SEP', 400); | What is the total number of military vehicles produced in 2020? | SELECT SUM(quantity) FROM MilitaryVehicles WHERE year = 2020 AND make = 'Humvee' OR make = 'Tank'; | gretelai_synthetic_text_to_sql |
CREATE TABLE livestock_farms (id INT, farm_id INT, livestock_species VARCHAR(50)); | Which 'livestock' species are present in the 'livestock_farms' table? | SELECT DISTINCT livestock_species FROM livestock_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE commercial_buildings (building_id INT, country VARCHAR(100), energy_efficiency FLOAT); INSERT INTO commercial_buildings (building_id, country, energy_efficiency) VALUES (1, 'Japan', 80.0), (2, 'Australia', 60.0), (3, 'South Korea', 70.0), (4, 'Singapore', 50.0); | What is the average energy efficiency (in kWh/sq.m) of commercial buildings in the 'Asia Pacific' region? | SELECT AVG(energy_efficiency) FROM commercial_buildings WHERE country IN (SELECT country FROM regions WHERE region = 'Asia Pacific'); | gretelai_synthetic_text_to_sql |
CREATE TABLE space_company (name TEXT, satellites_deployed INTEGER); INSERT INTO space_company (name, satellites_deployed) VALUES ('SpaceX', 2000); CREATE TABLE spacex_satellites (id INTEGER, name TEXT, launch_year INTEGER); INSERT INTO spacex_satellites (id, name, launch_year) VALUES (1, 'Starlink 1', 2019), (2, 'Star... | How many satellites has SpaceX deployed in total? | SELECT SUM(satellites_deployed) FROM space_company WHERE name = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_habitats (id INT, fish_id INT, habitat_type VARCHAR(20), temperature DECIMAL(5,2)); INSERT INTO fish_habitats (id, fish_id, habitat_type, temperature) VALUES (1, 1, 'tropical', 28.3); INSERT INTO fish_habitats (id, fish_id, habitat_type, temperature) VALUES (2, 2, 'temperate', 15.5); | What is the average water temperature for tropical fish habitats? | SELECT AVG(temperature) FROM fish_habitats WHERE habitat_type = 'tropical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT PRIMARY KEY, name TEXT, email TEXT, joined_date DATE, word_count INT); CREATE TABLE articles_authors (article_id INT, author_id INT); | What is the average word count of the top 5 most prolific authors in the "authors" table? | SELECT a.name, AVG(aa.word_count) as avg_word_count FROM authors a JOIN articles_authors aa ON a.id = aa.author_id GROUP BY a.name ORDER BY avg_word_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (id, name) VALUES (10, 'Binance'); CREATE TABLE transaction_counts (smart_contract_id INT, transaction_count INT, transaction_date DATE); INSERT INTO transaction_counts (smart_contract_id, transaction_count, transaction_date) VALUES (... | What is the total number of transactions for the 'Binance' smart contract in the last month? | SELECT transaction_count FROM transaction_counts WHERE smart_contract_id = (SELECT id FROM smart_contracts WHERE name = 'Binance') AND transaction_date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Gender VARCHAR(10), Region VARCHAR(20), MembershipDate DATE); INSERT INTO Members (MemberID, Gender, Region, MembershipDate) VALUES (2, 'Female', 'California', '2020-06-01'); CREATE TABLE WearableTech (DeviceID INT, MemberID INT, UsageDate DATE); INSERT INTO WearableTech (DeviceID, M... | Identify the number of female members in California who did not use wearable devices in the last month and their earliest membership date. | SELECT Members.MemberID, Members.Gender, Members.Region, MIN(Members.MembershipDate) FROM Members LEFT JOIN WearableTech ON Members.MemberID = WearableTech.MemberID WHERE Members.Gender = 'Female' AND Members.Region = 'California' AND WearableTech.MemberID IS NULL AND Members.MembershipDate <= DATE_SUB(CURRENT_DATE, IN... | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArts (Continent VARCHAR(255), Country VARCHAR(255), Budget INT); INSERT INTO TraditionalArts (Continent, Country, Budget) VALUES ('Asia', 'Japan', 400000), ('Asia', 'China', 300000), ('Asia', 'India', 500000), ('Asia', 'Indonesia', 200000); | What is the average budget spent on traditional arts programs per country in Asia? | SELECT Country, AVG(Budget) as Avg_Budget FROM TraditionalArts WHERE Continent = 'Asia' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (farmer_id INT, farmer_name VARCHAR(50)); CREATE TABLE crops (crop_id INT, crop_name VARCHAR(50)); CREATE TABLE farmer_crop (farmer_id INT, crop_id INT); INSERT INTO farmers (farmer_id, farmer_name) VALUES (1, 'Farmer 1'), (2, 'Farmer 2'), (3, 'Farmer 3'); INSERT INTO crops (crop_id, crop_name) VAL... | List all farmers and their respective crops in the 'farmer_crop' table? | SELECT farmers.farmer_name, crops.crop_name FROM farmers INNER JOIN farmer_crop ON farmers.farmer_id = farmer_crop.farmer_id INNER JOIN crops ON farmer_crop.crop_id = crops.crop_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_projects (year INT, funding FLOAT); INSERT INTO climate_finance_projects (year, funding) VALUES (2020, 12000000), (2020, 18000000), (2020, 15000000); | What is the average funding per climate finance project in 2020? | SELECT AVG(funding) FROM climate_finance_projects WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (country VARCHAR(255), element VARCHAR(255), quantity INT, year INT); INSERT INTO production (country, element, quantity, year) VALUES ('China', 'Gadolinium', 50000, 2019), ('United States', 'Gadolinium', 20000, 2019), ('Australia', 'Gadolinium', 10000, 2019), ('Brazil', 'Gadolinium', 8000, 2019... | What is the production of Gadolinium by the top 2 producing countries in 2019? | SELECT country, quantity FROM (SELECT country, quantity, RANK() OVER (PARTITION BY element ORDER BY quantity DESC) as rank FROM production WHERE element = 'Gadolinium' AND year = 2019) WHERE rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); | Create a table named 'stations' with columns 'station_id', 'name', 'latitude', 'longitude' | CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); | gretelai_synthetic_text_to_sql |
CREATE TABLE diversion_program (id INT, offender_name TEXT, offender_age INT, offender_gender TEXT); INSERT INTO diversion_program (id, offender_name, offender_age, offender_gender) VALUES (1, 'Michael Brown', 25, 'Male'); INSERT INTO diversion_program (id, offender_name, offender_age, offender_gender) VALUES (2, 'Davi... | What is the average age of male offenders who completed the diversion program? | SELECT AVG(offender_age) FROM diversion_program WHERE offender_gender = 'Male'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fleets (fleet_id INT, name VARCHAR(255)); INSERT INTO fleets (fleet_id, name) VALUES (1, 'Fleet A'), (2, 'Fleet B'); CREATE TABLE vessels (vessel_id INT, fleet_id INT, type VARCHAR(255)); INSERT INTO vessels (vessel_id, fleet_id, type) VALUES (1, 1, 'Cargo Ship'), (2, 2, 'Cargo Ship'); CREATE TABLE contain... | What is the total number of containers lost at sea by each fleet in 2021? | SELECT f.name, SUM(cl.lost_containers) FROM container_losses cl JOIN vessels v ON cl.vessel_id = v.vessel_id JOIN fleets f ON v.fleet_id = f.fleet_id WHERE cl.loss_date >= '2021-01-01' AND cl.loss_date < '2022-01-01' GROUP BY f.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (shipment_id INT, shipment_date DATE, revenue DECIMAL(10,2)); INSERT INTO shipments (shipment_id, shipment_date, revenue) VALUES (1, '2022-01-01', 1000), (2, '2022-01-05', 2000), (3, '2022-02-03', 3000); | What was the average revenue per shipment for the month of January 2022? | SELECT AVG(revenue) FROM shipments WHERE shipment_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup_funding (name VARCHAR(255), year INT, budget FLOAT); INSERT INTO startup_funding (name, year, budget) VALUES ('StartupA', 2021, 6000000), ('StartupB', 2021, 8000000), ('StartupC', 2021, 10000000); | What is the average budget for biotech startups founded in 2021? | SELECT AVG(budget) FROM startup_funding WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE tickets (ticket_id INT, type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO tickets (ticket_id, type, price) VALUES (1, 'General Admission', 25.00), (2, 'VIP', 100.00); | List all unique ticket types and their corresponding prices in the tickets table. | SELECT DISTINCT type, price FROM tickets; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name TEXT, Age INT, Genre TEXT); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (1, 'Eminem', 49, 'Rap'); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (2, 'Kendrick Lamar', 34, 'Rap'); | What is the minimum age of all rap artists? | SELECT MIN(Age) FROM Artists WHERE Genre = 'Rap'; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_occupations (state VARCHAR(2), occupation VARCHAR(50), employed_veterans INT, total_veterans INT); INSERT INTO veteran_occupations (state, occupation, employed_veterans, total_veterans) VALUES ('CA', 'Software Engineer', 1000, 2000); INSERT INTO veteran_occupations (state, occupation, employed_vete... | Analyze veteran employment by occupation | SELECT occupation, (employed_veterans/total_veterans) as employment_rate FROM veteran_occupations; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerDemographics (PlayerID INT, Age INT, Country VARCHAR(50), Genre VARCHAR(20)); INSERT INTO PlayerDemographics (PlayerID, Age, Country, Genre) VALUES (1, 22, 'USA', 'Racing'); INSERT INTO PlayerDemographics (PlayerID, Age, Country, Genre) VALUES (2, 25, 'Japan', 'Simulation'); INSERT INTO PlayerDemogra... | What is the favorite game genre of players from Japan? | SELECT Genre, COUNT(*) as Count FROM PlayerDemographics WHERE Country = 'Japan' GROUP BY Genre ORDER BY Count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableSeafood (id INT, country VARCHAR(50), year INT, tons_produced INT, sustainable BOOLEAN); INSERT INTO SustainableSeafood (id, country, year, tons_produced, sustainable) VALUES (1, 'Canada', 2016, 1200, true), (2, 'Iceland', 2017, 1000, true), (3, 'Canada', 2018, 1300, true), (4, 'Iceland', 2019, ... | What is the average amount of seafood (in tons) produced per year by sustainable aquaculture farms in Canada and Iceland, for the period 2016-2021? | SELECT AVG(tons_produced) FROM SustainableSeafood WHERE country IN ('Canada', 'Iceland') AND sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_depths (species VARCHAR(255), max_depth FLOAT); INSERT INTO marine_species_depths (species, max_depth) VALUES ('Anglerfish', 3000.0), ('Giant Squid', 3000.0); | What is the maximum depth at which any marine species is found? | SELECT MAX(max_depth) FROM marine_species_depths; | gretelai_synthetic_text_to_sql |
CREATE TABLE Product (id INT, productName VARCHAR(50), price DECIMAL(5,2)); INSERT INTO Product (id, productName, price) VALUES (4, 'Blush', 14.99), (5, 'Foundation', 29.99), (6, 'Lip Liner', 16.99); CREATE TABLE Ingredient (id INT, productId INT, ingredient VARCHAR(50), sourceCountry VARCHAR(50), crueltyFree BOOLEAN);... | What are the product names and preferences of consumers who have expressed a preference for products that contain rosehip oil as an ingredient? | SELECT P.productName, C.preference FROM ConsumerPreference C INNER JOIN Product P ON C.productId = P.id INNER JOIN Ingredient I ON P.id = I.productId WHERE I.ingredient = 'Rosehip Oil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, city VARCHAR(255), hours_served INT, activity_date DATE); INSERT INTO volunteer_hours (id, city, hours_served, activity_date) VALUES (1, 'New York', 50, '2022-01-01'), (2, 'Los Angeles', 70, '2022-02-01'), (3, 'Chicago', 60, '2022-03-01'), (4, 'Houston', 80, '2022-03-01'), (5, 'Pho... | What is the total number of volunteers and their average hours served per city in the last six months? | SELECT city, COUNT(*) AS num_volunteers, AVG(hours_served) AS avg_hours_served FROM volunteer_hours WHERE activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutoShow (id INT, name TEXT); CREATE TABLE ElectricVehicle (id INT, name TEXT, show_id INT); INSERT INTO AutoShow (id, name) VALUES (1, 'LA Auto Show'), (2, 'Detroit Auto Show'); INSERT INTO ElectricVehicle (id, name, show_id) VALUES (1, 'Model 3', 1), (2, 'Bolt', 1), (3, 'Tesla Semi', 2); | List the auto shows and number of electric vehicle models showcased in each | SELECT AutoShow.name, COUNT(ElectricVehicle.id) FROM AutoShow INNER JOIN ElectricVehicle ON AutoShow.id = ElectricVehicle.show_id GROUP BY AutoShow.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE shelter_info (id INT, company VARCHAR(255), country VARCHAR(255), units_constructed INT); INSERT INTO shelter_info (id, company, country, units_constructed) VALUES ('1', 'Alpha Construction', 'Iraq', '10'), ('2', 'Beta Construction', 'Iraq', '15'), ('3', 'Gamma Construction', 'Lebanon', '20'), ('4', 'Delta... | What is the total number of shelter units constructed in Iraq and Lebanon, grouped by construction company? | SELECT company, SUM(units_constructed) as total_units FROM shelter_info WHERE country IN ('Iraq', 'Lebanon') GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE disease_prevalence (disease_id INT, name VARCHAR(50), location VARCHAR(20), prevalence INT); INSERT INTO disease_prevalence (disease_id, name, location, prevalence) VALUES (1, 'Diabetes', 'Rural Florida', 1000); INSERT INTO disease_prevalence (disease_id, name, location, prevalence) VALUES (2, 'Heart Disea... | What is the most common disease prevalence in rural areas of Florida? | SELECT name, MAX(prevalence) FROM disease_prevalence WHERE location = 'Rural Florida' GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, is_first_time_donor BOOLEAN); CREATE TABLE donors (id INT, country VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, donation_date, is_first_time_donor) VALUES (1, 1, 50.00, '2021-03-01', true); INSERT INT... | How many first-time donors from Nigeria have donated in the past 6 months? | SELECT COUNT(DISTINCT donations.donor_id) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.country = 'Nigeria' AND is_first_time_donor = true AND donation_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, location VARCHAR(50), tour_date DATE); INSERT INTO virtual_tours (tour_id, location, tour_date) VALUES (1, 'Acropolis, Athens', '2009-02-01'), (2, 'Parthenon, Athens', '2011-05-15'), (3, 'Temple of Olympian Zeus, Athens', '2012-07-20'), (4, 'Ancient Agora, Athens', '2015-11-09')... | Delete virtual tours for historical sites in Athens that were created before 2010. | DELETE FROM virtual_tours WHERE location LIKE '%Athens%' AND tour_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonEmissions(id INT, region VARCHAR(50), emissions_metric_tons BIGINT, emissions_date DATE); | What is the total amount of carbon emissions, in metric tons, for each region, in the past year, that have emitted more than 1,000,000 metric tons of carbon emissions? | SELECT region, SUM(emissions_metric_tons) as total_emissions FROM CarbonEmissions WHERE emissions_date >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY region HAVING total_emissions > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, quantity FLOAT); INSERT INTO production (element, year, quantity) VALUES ('Neodymium', 2015, 12000), ('Neodymium', 2016, 15000), ('Neodymium', 2017, 17000), ('Neodymium', 2018, 19000), ('Neodymium', 2019, 21000), ('Dysprosium', 2015, 300), ('Dysprosium', 2016, 350... | Which rare earth element had the highest production increase between 2015 and 2019? | SELECT element, MAX(diff) FROM (SELECT element, (quantity - LAG(quantity) OVER (PARTITION BY element ORDER BY year)) AS diff FROM production) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellite_deployment (id, name, country, launch_date) VALUES (1, 'Sentinel-2A', 'European Union', '2015-06-23'); INSERT INTO satellite_deployment (id, name, country, launch_date) VALUES (2, 'GS... | Delete the record for the satellite 'Landsat 9' | DELETE FROM satellite_deployment WHERE name = 'Landsat 9'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nasa_astronauts (id INT, name VARCHAR(50), flights INT); INSERT INTO nasa_astronauts (id, name, flights) VALUES (1, 'Neil Armstrong', 2), (2, 'Buzz Aldrin', 2), (3, 'Peggy Whitson', 3); CREATE TABLE esa_astronauts (id INT, name VARCHAR(50), flights INT); INSERT INTO esa_astronauts (id, name, flights) VALUE... | List the names of astronauts who flew with NASA and ESA? | SELECT name FROM nasa_astronauts JOIN esa_astronauts ON nasa_astronauts.name = esa_astronauts.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_facts (id INTEGER, name TEXT, fact TEXT); INSERT INTO ocean_facts (id, name, fact) VALUES (1, 'Pacific Ocean', 'Mariana Trench is the deepest point'); INSERT INTO ocean_facts (id, name, fact) VALUES (2, 'Indian Ocean', '3,741 meters deep on average'); | How many ocean facts are there in the database? | SELECT COUNT(*) FROM ocean_facts; | gretelai_synthetic_text_to_sql |
CREATE TABLE factory_data (factory_id INT, region VARCHAR(20), sustainability_score FLOAT, year INT); INSERT INTO factory_data (factory_id, region, sustainability_score, year) VALUES (1, 'Asia', 85, 2020), (2, 'Asia', 90, 2020), (3, 'Europe', 88, 2020); | What was the average sustainability score of factories in region "Asia" in 2020? | SELECT AVG(sustainability_score) FROM factory_data WHERE region = 'Asia' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_heritage (country VARCHAR(50), project_name VARCHAR(100), start_date DATE, end_date DATE); INSERT INTO cultural_heritage (country, project_name, start_date, end_date) VALUES ('Italy', 'Historic Building Restoration', '2022-01-01', '2022-12-31'); | Update the end date of a cultural heritage preservation project in Italy. | UPDATE cultural_heritage SET end_date = '2023-12-31' WHERE country = 'Italy' AND project_name = 'Historic Building Restoration'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (restaurant_id INT, sustainable BOOLEAN, amount DECIMAL(10,2), revenue_date DATE); INSERT INTO revenue (restaurant_id, sustainable, amount, revenue_date) VALUES (8, true, 1200.00, '2022-04-01'), (8, false, 800.00, '2022-04-01'), (8, true, 1500.00, '2022-04-15'), (8, false, 500.00, '2022-04-30'); | What is the total revenue for 'Restaurant G' from sustainable sourced ingredients in the month of April 2022? | SELECT SUM(amount) FROM revenue WHERE restaurant_id = 8 AND sustainable = true AND revenue_date BETWEEN '2022-04-01' AND '2022-04-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT); CREATE TABLE education_programs (id INT PRIMARY KEY, name VARCHAR(50), animal_id INT, coordinator VARCHAR(50)); | List all animals that have not been assigned to an education program. | SELECT animals.name, animals.species FROM animals LEFT JOIN education_programs ON animals.id = education_programs.animal_id WHERE education_programs.animal_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT, region TEXT); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'US'), (2, 'Jane Smith', 'APAC'), (3, 'Mike Johnson', 'EU'), (4, 'Sophia Chen', 'APAC'); CREATE TABLE transactions (transaction_id INT, client_id INT, currency TEXT, amount DECIMAL(10, 2), ... | Insert a new transaction record with 'BTC' as the currency, 1.25 as the amount, 'withdrawal' as the type, and '2022-04-05' as the transaction_date for the client with client_id 2 in the 'transactions' table. | INSERT INTO transactions (client_id, currency, amount, type, transaction_date) VALUES (2, 'BTC', 1.25, 'withdrawal', '2022-04-05'); | gretelai_synthetic_text_to_sql |
CREATE TABLE water_consumption (operation_id INT, consumption_date DATE, water_quantity INT); INSERT INTO water_consumption (operation_id, consumption_date, water_quantity) VALUES (1, '2021-01-15', 5000), (2, '2021-01-20', 8000), (3, '2021-03-01', 7000), (4, '2020-12-14', 9500); | What is the total amount of water consumed by our mining operations in the last 12 months? | SELECT water_quantity FROM water_consumption WHERE consumption_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND CURRENT_DATE | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(20)); INSERT INTO users (id, country) VALUES (1, 'India'), (2, 'USA'); CREATE TABLE transactions (id INT, user_id INT, type VARCHAR(20), amount DECIMAL(10, 2)); INSERT INTO transactions (id, user_id, type, amount) VALUES (1, 1, 'credit', 100.00), (2, 1, 'debit', 50.00), (3, 2... | What is the average transaction amount per user for users from India, partitioned by transaction type? | SELECT type, AVG(amount) as avg_amount FROM transactions INNER JOIN users ON transactions.user_id = users.id WHERE users.country = 'India' GROUP BY type, users.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_farms (id INT, name VARCHAR(255), state VARCHAR(255), capacity FLOAT, completion_date DATE); | What is the maximum and minimum installed capacity of solar farms in the state of California, and what are their names? | SELECT name, MAX(capacity) AS max_capacity, MIN(capacity) AS min_capacity FROM solar_farms WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE routes (route_id INT, route_name VARCHAR(20)); CREATE TABLE passenger_trips (trip_id INT, passenger_id INT, route_id INT, fare AMOUNT); | Display the total fare collected on each route | SELECT routes.route_name, SUM(passenger_trips.fare) FROM routes JOIN passenger_trips ON routes.route_id = passenger_trips.route_id GROUP BY routes.route_id, routes.route_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE industrial_water_usage (id INT, sector VARCHAR(20), consumption FLOAT, month VARCHAR(10)); INSERT INTO industrial_water_usage (id, sector, consumption, month) VALUES (1, 'industrial', 70, 'January'), (2, 'industrial', 75, 'February'); | What is the total water consumption per month in the 'industrial' sector? | SELECT sector, SUM(consumption) as total_consumption FROM industrial_water_usage GROUP BY sector, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20), price INT, year_built INT); INSERT INTO properties (id, city, price, year_built) VALUES (1, 'Oakland', 700000, 1975), (2, 'Oakland', 800000, 2000), (3, 'San_Francisco', 1000000, 2010); | What is the maximum property price for buildings constructed before 1980 in Oakland, CA? | SELECT MAX(price) FROM properties WHERE city = 'Oakland' AND year_built < 1980; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (id INT, game_date DATE, game_type VARCHAR(10), quantity INT); | What is the total number of tickets sold for all games in the last year, and what is the percentage that was sold for basketball games? | SELECT SUM(CASE WHEN game_type = 'basketball' THEN quantity ELSE 0 END) / SUM(quantity) * 100 as basketball_percentage FROM ticket_sales WHERE game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_players_stats (player_id INT PRIMARY KEY, player_name VARCHAR(255), team_id INT, position VARCHAR(50), blocks INT, FOREIGN KEY (player_id) REFERENCES basketball_players(player_id), FOREIGN KEY (team_id) REFERENCES basketball_teams(team_id)); | What is the minimum number of blocks per game for each player in the basketball_players table, grouped by their team, and only for players who have more than 75 blocks in total? | SELECT t.team_name, MIN(blocks) as min_blocks FROM basketball_players_stats p JOIN basketball_teams t ON p.team_id = t.team_id WHERE position = 'center' GROUP BY t.team_name HAVING SUM(blocks) > 75; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_missions (mission_id INT, mission_name VARCHAR(255), region VARCHAR(255), year INT, budget INT); INSERT INTO humanitarian_missions (mission_id, mission_name, region, year, budget) VALUES (1, 'Disaster Relief', 'Asia', 2019, 5000000), (2, 'Flood Relief', 'Africa', 2020, 10000000), (3, 'Earthqua... | What is the average budget for humanitarian missions per region in the last 3 years? | SELECT region, AVG(budget) as avg_budget FROM humanitarian_missions WHERE year BETWEEN (SELECT YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (department_id INT, department_name VARCHAR(20)); INSERT INTO departments (department_id, department_name) VALUES (1, 'Computer Science'), (2, 'Mathematics'), (3, 'Physics'); CREATE TABLE research_grants (grant_id INT, title VARCHAR(50), amount DECIMAL(10,2), principal_investigator VARCHAR(50),... | What is the total amount of research grants awarded to the "Computer Science" department? | SELECT SUM(amount) FROM research_grants WHERE department_id = (SELECT department_id FROM departments WHERE department_name = 'Computer Science'); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, state TEXT, condition TEXT); INSERT INTO patients (patient_id, age, gender, state, condition) VALUES (1, 30, 'Female', 'Florida', 'Depression'); INSERT INTO patients (patient_id, age, gender, state, condition) VALUES (2, 45, 'Male', 'Florida', 'Anxiety'); INS... | What is the most common mental health condition among patients in Florida? | SELECT condition, COUNT(*) as count FROM patients WHERE state = 'Florida' GROUP BY condition ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE agri_projects (project_id INT, district_id INT, budget FLOAT, project_category VARCHAR(50)); INSERT INTO agri_projects (project_id, district_id, budget, project_category) VALUES (1, 16, 120000, 'Crop Research'), (2, 16, 80000, 'Livestock Research'), (3, 17, 180000, 'Farm Machinery'), (4, 17, 90000, 'Fertil... | List the total budget for agricultural innovation projects in district 16 and district 17. | SELECT district_id, SUM(budget) FROM agri_projects GROUP BY district_id HAVING district_id IN (16, 17); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency (id INT, country VARCHAR(255), year INT, primary_energy_consumption FLOAT, final_energy_consumption FLOAT); | Find energy efficiency stats for specific countries | SELECT country, primary_energy_consumption, final_energy_consumption FROM energy_efficiency WHERE country IN ('Germany', 'Brazil', 'India', 'South Africa', 'Indonesia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE funding_sources (id INT, source_type VARCHAR(255), amount FLOAT); CREATE TABLE visual_arts_programs (id INT, program_name VARCHAR(255), region VARCHAR(255)); | Find the total funding from private sources for visual arts programs in the Pacific Northwest region? | SELECT SUM(funding_sources.amount) as total_funding FROM funding_sources INNER JOIN visual_arts_programs ON funding_sources.id = visual_arts_programs.id WHERE visual_arts_programs.region = 'Pacific Northwest' AND funding_sources.source_type = 'Private'; | gretelai_synthetic_text_to_sql |
CREATE TABLE proteins (id INT PRIMARY KEY, name TEXT, molecular_weight INT); | Delete all records in the 'proteins' table where the 'molecular_weight' is greater than 100000 | DELETE FROM proteins WHERE molecular_weight > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE material_costs (material_id INT, state VARCHAR(2), material_type VARCHAR(20), cost DECIMAL(5,2)); INSERT INTO material_costs (material_id, state, material_type, cost) VALUES (1, 'TX', 'Concrete', 1000.00), (2, 'TX', 'Steel', 2000.50), (3, 'TX', 'Glass', 1500.00); | What is the total cost of sustainable construction materials used in Texas, grouped by material type? | SELECT material_type, SUM(cost) FROM material_costs WHERE state = 'TX' GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'Rajasthan'); CREATE TABLE water_meter_readings (id INT, state_id INT, consumption FLOAT, reading_date DATE); INSERT INTO water_meter_readings (id, state_id, consumption, reading_date) VALUES (1, 1, 100, '2022-05-01'); | Calculate the average daily water consumption in the state of Rajasthan, India for the month of May | SELECT AVG(water_meter_readings.consumption) as avg_daily_consumption FROM water_meter_readings WHERE water_meter_readings.reading_date >= '2022-05-01' AND water_meter_readings.reading_date <= '2022-05-31' AND water_meter_readings.state_id IN (SELECT id FROM states WHERE name = 'Rajasthan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE LocationTypes (LocId INT, Type VARCHAR(50)); CREATE TABLE EmergencyCalls (CallId INT, LocId INT, ResponseTime INT, Time TIME); | What is the average response time for emergency calls in each location type during nighttime hours, separated by location type and sorted by average response time in ascending order? | SELECT LT.Type, AVG(EC.ResponseTime) AS AvgResponseTime FROM LocationTypes LT INNER JOIN EmergencyCalls EC ON LT.LocId = EC.LocId WHERE EC.Time BETWEEN '22:00:00' AND '06:00:00' GROUP BY LT.Type ORDER BY AvgResponseTime ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircrafts (aircraft_id INT, model VARCHAR(50), airline_id INT); INSERT INTO aircrafts (aircraft_id, model, airline_id) VALUES (1, '787-9', 101), (2, '787-10', 101), (3, '777-300ER', 101), (4, '737 MAX 8', 102), (5, '737 MAX 9', 102); CREATE TABLE flight_hours (flight_hour_id INT, aircraft_id INT, flight_ho... | Which airline has the highest average flight hours per aircraft model? | SELECT a.airline_name, AVG(fh.flight_hours) as avg_flight_hours FROM aircrafts a JOIN flight_hours fh ON a.aircraft_id = fh.aircraft_id JOIN airlines al ON a.airline_id = al.airline_id GROUP BY a.airline_id ORDER BY avg_flight_hours DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (id INT, menu_item_id INT, quantity INT); INSERT INTO inventory (id, menu_item_id, quantity) VALUES (1, 1, 10), (2, 2, 20), (3, 3, 30), (4, 4, 40), (5, 5, 50), (6, 6, 60), (7, 7, 70), (8, 8, 80), (9, 9, 90), (10, 10, 100); | Identify the top 3 menu items with the least inventory quantity? | SELECT menu_item_id, SUM(quantity) AS total_quantity FROM inventory GROUP BY menu_item_id ORDER BY total_quantity ASC LIMIT 3; | 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.