context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE GovernmentDepartments (DepartmentID int, DepartmentName varchar(255), Country varchar(255), Budget decimal(10,2)); INSERT INTO GovernmentDepartments (DepartmentID, DepartmentName, Country, Budget) VALUES (1, 'Canadian Department of Defense', 'Canada', 25000000.00), (2, 'Canadian Department of Health', 'Can... | What is the total budget for all government departments in Canada? | SELECT SUM(Budget) FROM GovernmentDepartments WHERE Country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_fish_farms (id INT, name TEXT, region TEXT, dissolved_oxygen FLOAT); INSERT INTO marine_fish_farms (id, name, region, dissolved_oxygen) VALUES (1, 'Farm A', 'Pacific', 6.5), (2, 'Farm B', 'Pacific', 6.3), (3, 'Farm C', 'Atlantic', 7.0); | What is the average dissolved oxygen level for marine fish farms in the Pacific region? | SELECT AVG(dissolved_oxygen) FROM marine_fish_farms WHERE region = 'Pacific' AND species = 'marine'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, ocean_basin TEXT); INSERT INTO marine_protected_areas (area_name, ocean_basin) VALUES ('Galapagos Islands', 'Pacific'), ('Great Barrier Reef', 'Pacific'), ('Palau National Marine Sanctuary', 'Pacific'), ('Northwest Atlantic Marine National Monument', 'Atlantic'); | How many marine protected areas are there in each ocean basin? | SELECT ocean_basin, COUNT(*) FROM marine_protected_areas GROUP BY ocean_basin; | gretelai_synthetic_text_to_sql |
CREATE TABLE retailers (retailer_id INT, retailer_name VARCHAR(255), category VARCHAR(255), recycled_materials_quantity INT); INSERT INTO retailers (retailer_id, retailer_name, category, recycled_materials_quantity) VALUES (1, 'Green Toys', 'Toys', 300); INSERT INTO retailers (retailer_id, retailer_name, category, recy... | What is the minimum quantity of recycled materials used by retailers in the 'Toys' category? | SELECT MIN(recycled_materials_quantity) FROM retailers WHERE category = 'Toys'; | gretelai_synthetic_text_to_sql |
CREATE TABLE studio (studio_id INT, studio_name VARCHAR(50), country VARCHAR(50)); INSERT INTO studio (studio_id, studio_name, country) VALUES (1, 'Studio A', 'USA'), (2, 'Studio B', 'Canada'); CREATE TABLE movie (movie_id INT, title VARCHAR(50), release_year INT, studio_id INT); INSERT INTO movie (movie_id, title, rel... | What's the number of movies released per year by a specific studio? | SELECT release_year, COUNT(title) FROM movie JOIN studio ON movie.studio_id = studio.studio_id WHERE studio.studio_name = 'Studio A' GROUP BY release_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, team_name VARCHAR(50), platform VARCHAR(50), followers INT); INSERT INTO fans (fan_id, team_name, platform, followers) VALUES (1, 'Red Sox', 'Twitter', 500000), (2, 'Yankees', 'Instagram', 700000); | Find the total number of fans who engaged with each social media platform for a specific team? | SELECT team_name, SUM(followers) as total_followers FROM fans GROUP BY team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT); CREATE TABLE conservation_status (id INT, animal_name VARCHAR(50), status VARCHAR(20)); | List all the animal species in the 'animal_population' table along with their conservation status from the 'conservation_status' table. | SELECT ap.animal_name, cs.status FROM animal_population ap INNER JOIN conservation_status cs ON ap.animal_name = cs.animal_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, customer_id INT, region VARCHAR(20), investment_amount DECIMAL(10,2)); INSERT INTO investments (investment_id, customer_id, region, investment_amount) VALUES (1, 3, 'North', 10000.00), (2, 4, 'South', 15000.00); | What is the total investment amount for each customer in the North region? | SELECT customer_id, SUM(investment_amount) FROM investments WHERE region = 'North' GROUP BY customer_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (city VARCHAR(255), year INT, amount FLOAT); INSERT INTO waste_generation (city, year, amount) VALUES ('CityA', 2020, 1200.5), ('CityA', 2019, 1100.3), ('CityB', 2020, 1500.6), ('CityB', 2019, 1400.2); | What is the total waste generation in kg for all cities in the year 2020? | SELECT SUM(amount) FROM waste_generation WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE researchers (researcher_id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), experience INT); | Update the "experience" field in the "researchers" table for the researcher with "researcher_id" 405 to 9. | UPDATE researchers SET experience = 9 WHERE researcher_id = 405; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_name TEXT, ocean_basin TEXT, coral_reef_area FLOAT); INSERT INTO countries (country_name, ocean_basin, coral_reef_area) VALUES ('Japan', 'Pacific', 15000.0), ('Australia', 'Pacific', 60000.0), ('Philippines', 'Pacific', 27000.0); | What is the total coral reef area for countries in the Pacific Ocean? | SELECT SUM(coral_reef_area) FROM countries WHERE ocean_basin = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (id INT, name TEXT, size_km2 FLOAT); INSERT INTO habitats (id, name, size_km2) VALUES (1, 'Forest', 50.3), (2, 'Wetlands', 32.1), (3, 'Grasslands', 87.6); | What is the average size of protected habitats in square kilometers? | SELECT AVG(size_km2) FROM habitats; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255)); CREATE TABLE Inspections (InspectionID int, RestaurantID int, InspectionGrade varchar(10), InspectionDate date); | List all food safety inspections with a passing grade, their corresponding restaurant, and the date of inspection. | SELECT R.RestaurantName, I.InspectionGrade, I.InspectionDate FROM Restaurants R INNER JOIN Inspections I ON R.RestaurantID = I.RestaurantID WHERE I.InspectionGrade = 'Pass'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation_ridership (id INT, trip_date DATE, mode TEXT, ridership INT); | What is the daily ridership of public transportation in London over the past week? | SELECT trip_date, mode, AVG(ridership) AS daily_ridership FROM public_transportation_ridership WHERE trip_date >= CURRENT_DATE - INTERVAL '7 days' GROUP BY trip_date, mode; | gretelai_synthetic_text_to_sql |
CREATE TABLE ContractNegotiations (id INT, contractor VARCHAR(255), government VARCHAR(255), contract_value INT, negotiation_date DATE); INSERT INTO ContractNegotiations (id, contractor, government, contract_value, negotiation_date) VALUES (1, 'Contractor A', 'US Government', 20000000, '2020-01-01'), (2, 'Contractor B'... | What is the total value of contracts negotiated with the US government by defense contractors in the last 2 years? | SELECT SUM(contract_value) as total_value FROM ContractNegotiations WHERE government = 'US Government' AND negotiation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (city VARCHAR(255), year INT, rate DECIMAL(5,4)); CREATE TABLE waste_generation (city VARCHAR(255), year INT, amount INT); INSERT INTO recycling_rates (city, year, rate) VALUES ('San Francisco', 2021, 0.35), ('New York', 2021, 0.40), ('Los Angeles', 2021, 0.25); INSERT INTO waste_generation... | List the recycling rates for the top 3 cities with the highest waste generation in 2021. | SELECT wg.city, r.rate FROM (SELECT city, year, SUM(amount) AS total_waste FROM waste_generation GROUP BY city, year ORDER BY total_waste DESC LIMIT 3) wg INNER JOIN recycling_rates r ON wg.city = r.city AND wg.year = r.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE); | How many donations were made in the year 2020? | SELECT COUNT(*) FROM donations WHERE YEAR(donation_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (policyholder_id INT, claim_number INT, state VARCHAR(2)); INSERT INTO claims (policyholder_id, claim_number, state) VALUES (1, 1, 'CA'), (1, 2, 'CA'), (2, 1, 'CA'); | Identify policyholders with more than one claim in California | SELECT policyholder_id FROM claims WHERE state = 'CA' GROUP BY policyholder_id HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT, sustainability_rating INT); | Add a column named "sustainability_rating" to the existing "hotels" table. | ALTER TABLE hotels ADD sustainability_rating INT; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, name VARCHAR(50), department VARCHAR(50), is_international BOOLEAN); | What is the percentage of graduate students in the Engineering department who are international students? | SELECT (COUNT(s.student_id) * 100.0 / (SELECT COUNT(*) FROM students)) AS percentage FROM students s WHERE s.department = 'Engineering' AND s.is_international = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, department VARCHAR(255), severity VARCHAR(255), date DATE); INSERT INTO vulnerabilities (id, department, severity, date) VALUES (1, 'Finance', 'high', '2022-01-01'), (2, 'HR', 'medium', '2022-05-15'), (3, 'IT', 'low', '2022-06-20'), (4, 'Finance', 'high', '2022-04-01'), (5, 'Financ... | How many high severity vulnerabilities were detected in the Finance department in the last quarter? | SELECT COUNT(*) FROM vulnerabilities WHERE department = 'Finance' AND severity = 'high' AND date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonFootprint (id INT, garment_id INT, material VARCHAR(255), carbon_footprint INT); INSERT INTO CarbonFootprint (id, garment_id, material, carbon_footprint) VALUES (1, 1000, 'Recycled Polyester', 5), (2, 1001, 'Organic Cotton', 7), (3, 1002, 'Recycled Polyester', 6); | Delete all garments with a carbon footprint greater than 10 | DELETE FROM CarbonFootprint WHERE carbon_footprint > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(50)); INSERT INTO drugs (drug_id, drug_name) VALUES (1, 'DrugA'), (2, 'DrugB'); CREATE TABLE sales (sale_id INT, drug_id INT, year INT, revenue INT); INSERT INTO sales (sale_id, drug_id, year, revenue) VALUES (1, 1, 2020, 50000), (2, 1, 2021, 60000), (3, 2, 2020, 45000... | What was the total sales revenue of a specific drug in a given year? | SELECT s.revenue FROM sales s JOIN drugs d ON s.drug_id = d.drug_id WHERE d.drug_name = 'DrugA' AND s.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ethical_AI_Funding (University VARCHAR(50), Funding INT); | What is the total funding received by universities in South America for ethical AI research? | SELECT SUM(Funding) FROM Ethical_AI_Funding WHERE University IN (SELECT University FROM Ethical_AI_Funding WHERE Country IN ('Argentina', 'Brazil', 'Colombia') GROUP BY University HAVING COUNT(*) >= 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_areas (area_name VARCHAR(30), state VARCHAR(20), drought_status VARCHAR(10)); CREATE TABLE drought_categories (drought_status VARCHAR(10), description VARCHAR(20)); | Determine the percentage of drought-impacted areas in Arizona? | SELECT 100.0 * COUNT(CASE WHEN da.drought_status = 'D4' THEN 1 END) / COUNT(*) as pct_drought FROM drought_areas da JOIN drought_categories dc ON da.drought_status = dc.drought_status WHERE da.state = 'Arizona'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hr.employees (id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50)); INSERT INTO hr.employees (id, name, gender, department) VALUES (1, 'Jane Doe', 'Female', 'HR'); INSERT INTO hr.employees (id, name, gender, department) VALUES (2, 'John Smith', 'Male', 'IT'); INSERT INTO hr.employees (id, ... | Count the number of employees who identify as female in the "hr" schema | SELECT COUNT(*) FROM hr.employees WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (site_id INT, name VARCHAR(255), list VARCHAR(255)); CREATE VIEW list_summary AS SELECT list, COUNT(site_id) as site_count FROM heritage_sites GROUP BY list; | Show the number of cultural heritage sites in each world heritage list. | SELECT list, site_count FROM list_summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE metro_trips (entry_time TIME, day VARCHAR(10)); INSERT INTO metro_trips (entry_time, day) VALUES ('10:00:00', 'Saturday'), ('12:30:00', 'Sunday'), ('16:45:00', 'Saturday'); | What is the total number of trips taken on the Moscow metro during the weekend? | SELECT COUNT(*) FROM metro_trips WHERE day IN ('Saturday', 'Sunday'); | gretelai_synthetic_text_to_sql |
CREATE TABLE boston_disaster_preparedness (id INT, training_name VARCHAR(255), city VARCHAR(255), attendance INT); INSERT INTO boston_disaster_preparedness (id, training_name, city, attendance) VALUES (1, 'Earthquake Preparedness', 'Boston', 25); | What is the number of disaster preparedness trainings held in Boston and their respective attendance?" | SELECT training_name, SUM(attendance) as total_attendance FROM boston_disaster_preparedness WHERE city = 'Boston' GROUP BY training_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (id INT, name VARCHAR(50), occupation VARCHAR(50), state VARCHAR(2), joined_date DATE); INSERT INTO union_members (id, name, occupation, state, joined_date) VALUES (1, 'Alice Brown', 'Teacher', 'CA', '2019-09-01'); INSERT INTO union_members (id, name, occupation, state, joined_date) VALUES (2... | What is the number of union members that are also teachers in Canada? | SELECT COUNT(*) FROM union_members WHERE occupation = 'Teacher' AND state = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesign (GameID INT, GameName VARCHAR(20), Platform VARCHAR(10), VR BIT, CrossPlatform BIT); | Identify the total number of VR games that support cross-platform play, and list the game names. | SELECT GameName FROM GameDesign WHERE VR = 1 AND CrossPlatform = 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.patents (id INT, name VARCHAR(50), location VARCHAR(50), filed_date DATE, industry VARCHAR(50)); INSERT INTO biotech.patents (id, name, location, filed_date, industry) VALUES (1, 'PatentA', 'USA', '2019-05-15', 'Genetic Research'), (2, 'PatentB', '... | How many unique genetic research patents have been filed in each country, in the past 5 years? | SELECT location, COUNT(DISTINCT id) as num_patents FROM biotech.patents WHERE industry = 'Genetic Research' AND filed_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE fast_food.health_inspections (restaurant_id INT, category TEXT, health_score INT); INSERT INTO fast_food.health_inspections (restaurant_id, category, health_score) VALUES (1, 'Burger', 90), (2, 'Pizza', 85), (3, 'Fried Chicken', 80); | Calculate the average health score for each restaurant category in the 'fast_food' schema. | SELECT category, AVG(health_score) FROM fast_food.health_inspections GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Disability_Accommodations (Student_ID INT, Student_Name TEXT, Disability_Type TEXT, Accommodation_Type TEXT); INSERT INTO Disability_Accommodations (Student_ID, Student_Name, Disability_Type, Accommodation_Type) VALUES (1, 'John Doe', 'Visual Impairment', 'Extended Time'), (2, 'Jane Smith', 'Hearing Impair... | What is the number of students who received accommodations for exams for each disability type? | SELECT Disability_Type, Accommodation_Type, COUNT(*) FROM Disability_Accommodations GROUP BY Disability_Type, Accommodation_Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE museums (museum_id INT, name VARCHAR(50), city VARCHAR(50), opening_year INT); INSERT INTO museums (museum_id, name, city, opening_year) VALUES (1, 'Guggenheim Museum', 'New York', 1939); CREATE TABLE exhibitions (exhibition_id INT, title VARCHAR(50), year INT, museum_id INT); INSERT INTO exhibitions (exhi... | How many exhibitions have been held at 'Guggenheim Museum' since its opening? | SELECT COUNT(*) FROM exhibitions e WHERE e.museum_id = (SELECT museum_id FROM museums m WHERE m.name = 'Guggenheim Museum'); | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending (id INT PRIMARY KEY, loan_amount DECIMAL(10, 2), community_type TEXT, lending_date DATE); | What is the total amount of socially responsible loans issued to minority communities in 2021? | SELECT SUM(loan_amount) FROM socially_responsible_lending WHERE community_type IN ('Minority Community 1', 'Minority Community 2') AND lending_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Influential_Artists (artist_id INT, artist_name VARCHAR(255), influence_score FLOAT); | Who are the most influential artists in the 'Influential_Artists' table? | SELECT artist_name FROM Influential_Artists ORDER BY influence_score DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE event (id INT, year INT, type_id INT, name VARCHAR(50), revenue INT);CREATE TABLE event_type (id INT, name VARCHAR(50)); | What is the total revenue generated by each event type ('event_type' table) for the year 2020? | SELECT et.name, SUM(e.revenue) FROM event e JOIN event_type et ON e.type_id = et.id WHERE e.year = 2020 GROUP BY et.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, country TEXT, region TEXT, initiative_count INT); INSERT INTO initiatives (id, country, region, initiative_count) VALUES (1, 'France', 'European', 10), (2, 'Germany', 'European', 12), (3, 'Spain', 'European', 8), (4, 'United States', 'American', 15); | What is the average number of open data initiatives per country in the European region? | SELECT AVG(initiative_count) FROM initiatives WHERE region = 'European'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_tech_adoption (hotel_id INT, region VARCHAR(50), ai_integration VARCHAR(50)); | Add new records to hotel_tech_adoption_table for hotels in the Americas region | INSERT INTO hotel_tech_adoption (hotel_id, region, ai_integration) VALUES (1001, 'Americas', 'Yes'), (1002, 'Americas', 'No'), (1003, 'Americas', 'Yes'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, name TEXT); CREATE TABLE VolunteerDonations (id INT, volunteer_id INT, amount FLOAT); | Who are the volunteers with no donation records? | SELECT Volunteers.name FROM Volunteers LEFT JOIN VolunteerDonations ON Volunteers.id = VolunteerDonations.volunteer_id WHERE VolunteerDonations.id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE CyberIncidents (IncidentID int, IncidentDate date, ThreatLevel varchar(50)); INSERT INTO CyberIncidents (IncidentID, IncidentDate, ThreatLevel) VALUES (1, '2021-08-01', 'High'), (2, '2021-07-01', 'Medium'), (3, '2021-06-01', 'Low'); | List all cybersecurity incidents with their corresponding threat level in descending order by date. | SELECT * FROM CyberIncidents ORDER BY IncidentDate DESC, ThreatLevel DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, name VARCHAR(50), location VARCHAR(50), year INT, production INT); INSERT INTO crops (id, name, location, year, production) VALUES (1, 'Corn', 'US', 2020, 5000), (2, 'Wheat', 'US', 2020, 7000), (3, 'Soybean', 'Canada', 2020, 3000), (4, 'Barley', 'Canada', 2020, 4000), (5, 'Corn', 'US', 2019,... | What is the total production of each crop? | SELECT name, SUM(production) as total_production FROM crops GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sea_surface_temperature (ocean VARCHAR(255), date DATE, temperature FLOAT); INSERT INTO sea_surface_temperature (ocean, date, temperature) VALUES ('Pacific', '2017-01-01', 26.5), ('Pacific', '2017-07-01', 27.2), ('Pacific', '2018-01-01', 26.8), ('Pacific', '2018-07-01', 27.1), ('Pacific', '2019-01-01', 26.... | What is the 5-year trend of sea surface temperature in the Pacific Ocean? | SELECT date, temperature, ROW_NUMBER() OVER (ORDER BY date) as rn, AVG(temperature) OVER (ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) as moving_avg FROM sea_surface_temperature WHERE ocean = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_issues (issue_id INTEGER, issue_description TEXT, reported_country TEXT); | List unique safety_issues reported by country in descending order of count. | SELECT reported_country, COUNT(*) as count FROM safety_issues GROUP BY reported_country ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE african_production (id INT, year INT, quantity FLOAT); INSERT INTO african_production (id, year, quantity) VALUES (1, 2014, 4000), (2, 2015, 5000), (3, 2016, 6000); | What is the total production quantity (in metric tons) for rare earth elements in Africa for the year 2015? | SELECT SUM(quantity) FROM african_production WHERE year = 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE pharmaceuticals (country VARCHAR(50), num_pharmaceuticals INT); INSERT INTO pharmaceuticals (country, num_pharmaceuticals) VALUES ('USA', 823), ('Germany', 405), ('Japan', 519); | What is the number of pharmaceutical companies in each country of the world? | SELECT country, COUNT(*) as num_pharmaceutical_companies FROM pharmaceuticals GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donor (DonorID INT, DonationAmount NUMERIC(15,2)); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE); | What is the percentage of total donations made by top 10 donors? | SELECT Percentage FROM (SELECT SUM(DonationAmount) as TotalDonations, ROW_NUMBER() OVER (ORDER BY SUM(DonationAmount) DESC) as Rank, SUM(DonationAmount)/SUM(DonationAmount) OVER () as Percentage FROM Donations INNER JOIN Donor ON Donations.DonorID = Donor.DonorID GROUP BY DonorID) WHERE Rank <= 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE jupiter_moons (id INT, name VARCHAR(50), mass FLOAT); INSERT INTO jupiter_moons (id, name, mass) VALUES (1, 'Metis', 1200); INSERT INTO jupiter_moons (id, name, mass) VALUES (2, 'Adrastea', 1800); INSERT INTO jupiter_moons (id, name, mass) VALUES (3, 'Amalthea', 7000); | What is the mass of the smallest satellite of Jupiter? | SELECT MIN(mass) FROM jupiter_moons; | gretelai_synthetic_text_to_sql |
CREATE TABLE investors (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), investment_amount DECIMAL(10,2)); INSERT INTO investors (id, name, location, investment_amount) VALUES (1, 'Alice', 'USA', 5000.00), (2, 'Bob', 'Canada', 3000.00); | What is the total investment amount for each investor? | SELECT id, SUM(investment_amount) FROM investors GROUP BY id; | gretelai_synthetic_text_to_sql |
CREATE TABLE tree_carbon_sequestration (id INT, tree_type VARCHAR(255), carbon_sequestration INT); | Find the average carbon sequestration value for tree species in the tree_carbon_sequestration table, grouped by tree type. | SELECT tree_type, AVG(carbon_sequestration) FROM tree_carbon_sequestration GROUP BY tree_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_personnel(id INT, rank VARCHAR(255), status VARCHAR(255), date DATE); | What is the total number of military personnel, by rank, and the percentage of total personnel each rank represents, for the past year? | SELECT rank, COUNT(*) as count, ROUND(100 * COUNT(*) / (SELECT COUNT(*) FROM military_personnel WHERE date > DATE_SUB(NOW(), INTERVAL 1 YEAR) AND status = 'active'), 2) as percent FROM military_personnel WHERE date > DATE_SUB(NOW(), INTERVAL 1 YEAR) AND status = 'active' GROUP BY rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, city VARCHAR(50), country VARCHAR(50), energy_rating FLOAT); INSERT INTO green_buildings (id, city, country, energy_rating) VALUES (1, 'Mumbai', 'India', 85.0), (2, 'Rio de Janeiro', 'Brazil', 88.5), (3, 'Johannesburg', 'South Africa', 82.0); | What is the average energy rating for each city in the green buildings table? | SELECT city, AVG(energy_rating) as avg_energy_rating FROM green_buildings GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, FirstName VARCHAR(50), LastName VARCHAR(50), PracticeArea VARCHAR(50), TotalBilling FLOAT); INSERT INTO Attorneys (AttorneyID, FirstName, LastName, PracticeArea, TotalBilling) VALUES (1, 'Clara', 'Rivera', 'Personal Injury', 8000.00), (2, 'Jamal', 'Lee', 'Personal Injury', 6000.0... | What is the average billing amount for attorneys in the 'Personal Injury' practice area, partitioned by attorney's last name and ordered by the average billing amount in descending order? | SELECT LastName, AVG(TotalBilling) OVER (PARTITION BY LastName) AS AvgBilling FROM Attorneys WHERE PracticeArea = 'Personal Injury' ORDER BY AvgBilling DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExoplanetDiscoveries (telescope TEXT, num_exoplanets INTEGER); INSERT INTO ExoplanetDiscoveries (telescope, num_exoplanets) VALUES ('Kepler', 2300), ('COROT', 32), ('CoRoT', 31), ('HATNet', 90), ('K2', 400); | How many exoplanets have been discovered by each space telescope? | SELECT telescope, num_exoplanets FROM ExoplanetDiscoveries ORDER BY num_exoplanets DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_records (vessel_id INT, inspection_status VARCHAR(10)); | Update the safety_records table to set inspection_status as 'Passed' for vessels with vessel_id in (1, 3, 5) | UPDATE safety_records SET inspection_status = 'Passed' WHERE vessel_id IN (1, 3, 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitat_Preservation (PreservationID INT, Habitat VARCHAR(20), Budget DECIMAL(10, 2), Species VARCHAR(20)); INSERT INTO Habitat_Preservation (PreservationID, Habitat, Budget, Species) VALUES (1, 'Asia', 25000.00, 'Tiger'); INSERT INTO Habitat_Preservation (PreservationID, Habitat, Budget, Species) VALUES (... | What is the average budget allocated for endangered species conservation in 'Asia'? | SELECT AVG(Budget) FROM Habitat_Preservation WHERE Habitat = 'Asia' AND Species IN (SELECT Species FROM Endangered_Species); | gretelai_synthetic_text_to_sql |
CREATE TABLE Workout (MemberID INT, Duration INT, Subscription VARCHAR(50)); INSERT INTO Workout (MemberID, Duration, Subscription) VALUES (1, 60, 'Premium'); | Determine the total workout duration for members with the 'Premium' subscription type. | SELECT SUM(Duration) FROM Workout WHERE Subscription = 'Premium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(50), last_name VARCHAR(50), position VARCHAR(50), age INT); INSERT INTO players (player_id, name, last_name, position, age) VALUES (1, 'John', 'Doe', 'Pitcher', 30), (2, 'Jane', 'Smith', 'Catcher', 28); | What is the average age of players in each position? | SELECT position, AVG(age) as avg_age FROM players GROUP BY position; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (id INT, country VARCHAR(50), year INT, completion_rate DECIMAL(5,2)); INSERT INTO clinical_trials (id, country, year, completion_rate) VALUES (1, 'USA', 2020, 0.85), (2, 'Germany', 2020, 0.82), (3, 'Canada', 2020, 0.78), (4, 'USA', 2020, 0.90), (5, 'Germany', 2020, 0.87), (6, 'Canada', 202... | What are the top 3 countries with the highest clinical trial completion rates in 2020? | SELECT country, MAX(completion_rate) as max_completion_rate FROM clinical_trials WHERE year = 2020 GROUP BY country ORDER BY max_completion_rate DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (country TEXT, year INT, waste_generation FLOAT); INSERT INTO waste_generation (country, year, waste_generation) VALUES ('Country A', 2018, 1200), ('Country A', 2019, 1300), ('Country A', 2020, 1400), ('Country A', 2021, 1500), ('Country B', 2018, 1500), ('Country B', 2019, 1600), ('Countr... | What is the total waste generation in each country for the last 5 years? | SELECT country, SUM(waste_generation) FROM waste_generation WHERE year BETWEEN 2017 AND 2021 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, investment_type VARCHAR(20), value DECIMAL(10,2)); INSERT INTO investments (investment_id, investment_type, value) VALUES (1, 'Stocks', 30000.00), (2, 'Bonds', 20000.00), (3, 'Mutual Funds', 50000.00), (4, 'Stocks', 8000.00), (5, 'Bonds', 15000.00), (6, 'Mutual Funds', 20000... | What is the total value of investments for each investment type, excluding investments with a value less than 10000? | SELECT investment_type, SUM(value) as total_value FROM investments WHERE value >= 10000 GROUP BY investment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), brand_id INT, rating INT); CREATE TABLE ingredients (ingredient_id INT, product_id INT, is_organic BOOLEAN); | What is the average rating for organic skincare products by brand? | SELECT b.brand_name, AVG(p.rating) as avg_rating FROM brands b INNER JOIN products p ON b.brand_id = p.brand_id INNER JOIN ingredients i ON p.product_id = i.product_id WHERE i.is_organic = TRUE GROUP BY b.brand_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(100), position VARCHAR(50), team_id INT); INSERT INTO players (player_id, name, position, team_id) VALUES (1, 'John Doe', 'Forward', 1), (2, 'Jane Smith', 'Goalie', 2); CREATE TABLE teams (team_id INT, name VARCHAR(100), city VARCHAR(100)); INSERT INTO teams (team_id, n... | Delete team 2 | DELETE FROM teams WHERE team_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Local_Economic_Impact (City VARCHAR(50), Annual_Revenue INT, Job_Creation INT); INSERT INTO Local_Economic_Impact (City, Annual_Revenue, Job_Creation) VALUES ('Barcelona', 28000000, 65000), ('Rome', 25000000, 70000), ('Prague', 12000000, 30000), ('Oslo', 18000000, 40000); | Delete rows from the Local_Economic_Impact table where the Annual_Revenue is more than 10% below the average annual revenue across all rows in the table. | DELETE FROM Local_Economic_Impact WHERE Annual_Revenue < (SELECT AVG(Annual_Revenue) * 0.9 FROM Local_Economic_Impact); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, country TEXT, followers INT); INSERT INTO users (id, name, country, followers) VALUES (1, 'Alice', 'USA', 700), (2, 'Bob', 'USA', 600), (3, 'Charlie', 'Canada', 800); CREATE TABLE posts (id INT, user_id INT, likes INT, timestamp DATETIME); INSERT INTO posts (id, user_id, likes, ti... | What is the average number of likes on posts by users from the United States, having more than 500 followers, in the last month? | SELECT AVG(posts.likes) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country = 'USA' AND users.followers > 500 AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(50), region VARCHAR(50), depth FLOAT); INSERT INTO marine_protected_areas (id, name, region, depth) VALUES (1, 'MPA1', 'Pacific', 500.0), (2, 'MPA2', 'Pacific', 700.0), (3, 'MPA3', 'Pacific', 300.0); | What is the total number of marine protected areas in the Pacific ocean that are deeper than 500 meters? | SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Pacific' AND depth > 500.0; | 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 ('Culture Fest', 30, 'Male'), ('Culture Fest', 42, 'Female'), ('Culture Fest', 35, 'Non-binary'), ('Culture Fest', 50, 'Prefer not to say'... | What was the total number of attendees for 'Culture Fest' who identified as 'Non-binary' or 'Prefer not to say'? | SELECT COUNT(*) FROM EventAttendance WHERE event_name = 'Culture Fest' AND attendee_gender IN ('Non-binary', 'Prefer not to say'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, RecipientID INT, Amount DECIMAL(10,2), Country TEXT); INSERT INTO Donations (DonationID, DonorID, RecipientID, Amount, Country) VALUES (1, 1, 101, 1000.00, 'USA'), (2, 1, 102, 2000.00, 'Canada'), (3, 2, 101, 500.00, 'USA'), (4, 3, 103, 3000.00, 'Mexico'); | What is the total amount donated in each country? | SELECT Country, SUM(Amount) AS TotalDonated FROM Donations GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE hr.employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10, 2)); INSERT INTO hr.employees (id, name, department, salary) VALUES (1, 'John Doe', 'HR', 50000.00); INSERT INTO hr.employees (id, name, department, salary) VALUES (2, 'Jane Smith', 'IT', 60000.00); INSERT INTO hr.employees ... | Show total salary expenses for each department in the "hr" schema | SELECT department, SUM(salary) FROM hr.employees GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation.yearly_vehicle_sales (year INT, total_vehicle_sales INT, electric_vehicle_sales INT); | Create a view that shows the percentage of electric vehicle sales out of total vehicle sales per year | CREATE VIEW transportation.yearly_electric_vehicle_sales_percentage AS SELECT year, (electric_vehicle_sales * 100.0 / total_vehicle_sales)::numeric(5,2) AS percentage FROM transportation.yearly_vehicle_sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, roaming BOOLEAN, country VARCHAR(20)); INSERT INTO mobile_customers (customer_id, roaming, country) VALUES (1, true, 'Germany'), (2, false, 'Germany'), (3, true, 'Germany'); | What is the percentage of mobile customers who have used roaming services while in the country of Germany? | SELECT (COUNT(*) FILTER (WHERE roaming = true)) * 100.0 / COUNT(*) FROM mobile_customers WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, username VARCHAR(20), region VARCHAR(20));CREATE TABLE transactions (transaction_id INT, user_id INT, amount DECIMAL(10,2), transaction_time TIMESTAMP); | Find users who made more than 5 transactions in the last week? | SELECT user_id FROM transactions WHERE transaction_time > DATEADD(week, -1, GETDATE()) GROUP BY user_id HAVING COUNT(*) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, mental_health_score INT, participated_in_open_pedagogy BOOLEAN); INSERT INTO students (student_id, mental_health_score, participated_in_open_pedagogy) VALUES (1, 80, FALSE), (2, 60, FALSE), (3, 90, TRUE); | What is the maximum mental health score for students who have not participated in open pedagogy activities? | SELECT MAX(mental_health_score) FROM students WHERE participated_in_open_pedagogy = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE VesselPositions (vessel_id INT, timestamp TIMESTAMP, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); | Find the vessel with the longest continuous journey | SELECT t1.vessel_id, MAX(t2.timestamp) - MIN(t1.timestamp) AS duration FROM VesselPositions t1 JOIN VesselPositions t2 ON t1.vessel_id = t2.vessel_id AND t2.timestamp > t1.timestamp GROUP BY t1.vessel_id ORDER BY duration DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (UserID INT, UserName VARCHAR(255), Age INT); INSERT INTO Users (UserID, UserName, Age) VALUES (1, 'UserA', 25), (2, 'UserB', 35), (3, 'UserC', 45); CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(255), Genre VARCHAR(255)); INSERT INTO Artists (ArtistID, ArtistName, Genre) VALUES (1, 'ArtistA'... | Show the number of unique users who have streamed songs by artists from different genres. | SELECT A.Genre, COUNT(DISTINCT S.UserID) as UniqueUsers FROM Artists A JOIN Streams S ON A.ArtistID = S.ArtistID GROUP BY A.Genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy (course_id INT, open_pedagogy_score INT); | Create a table for open pedagogy data | CREATE TABLE open_pedagogy (course_id INT, open_pedagogy_score INT); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, Category TEXT, Amount DECIMAL); INSERT INTO Donations (DonationID, DonorID, Category, Amount) VALUES (1, 1, 'Social Services', 100), (2, 1, 'Education', 200), (3, 2, 'Social Services', 150), (4, 2, 'Arts', 50); | What is the total amount donated in the 'Social Services' category? | SELECT SUM(Amount) FROM Donations WHERE Category = 'Social Services'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cnn (article_id INT, title TEXT, category TEXT, publisher TEXT); INSERT INTO cnn (article_id, title, category, publisher) VALUES (1, 'Article 1', 'Technology', 'CNN'), (2, 'Article 2', 'Politics', 'CNN'), (3, 'Article 3', 'Business', 'CNN'); | What is the total number of articles published by 'CNN' in the politics and technology categories? | SELECT COUNT(*) FROM cnn WHERE category IN ('Politics', 'Technology'); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donation_id INT, country VARCHAR(50), amount DECIMAL(10,2), project_id INT); INSERT INTO donations (donation_id, country, amount, project_id) VALUES (1, 'USA', 50.00, 1), (2, 'Canada', 100.00, 1), (3, 'Mexico', 200.00, 1); | What is the total amount donated by each country for a specific project in Q1 2022? | SELECT country, SUM(amount) AS total_donated FROM donations WHERE project_id = 1 AND QUARTER(donation_date) = 1 AND YEAR(donation_date) = 2022 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment(state VARCHAR(20), treatment_capacity INT); INSERT INTO wastewater_treatment VALUES('New York', 50000); | What is the wastewater treatment capacity in New York? | SELECT treatment_capacity FROM wastewater_treatment WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_catch_data (species VARCHAR(255), year INT, number_caught INT, region VARCHAR(255)); INSERT INTO fish_catch_data (species, year, number_caught, region) VALUES ('Salmon', 2018, 1000, 'North Atlantic'), ('Salmon', 2019, 1200, 'North Atlantic'), ('Salmon', 2020, 1500, 'North Atlantic'), ('Cod', 2018, 200... | What is the number of fish caught for each species and year in the Pacific? | SELECT species, year, SUM(number_caught) as total_caught FROM fish_catch_data WHERE region = 'Pacific' GROUP BY species, year ORDER BY species, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, date DATE, neighborhood VARCHAR(50), type VARCHAR(50));CREATE TABLE arrests (id INT, crime_id INT, date DATE); | What is the clearance rate for crimes committed in a specific neighborhood, by type? | SELECT neighborhood, type, COUNT(arrests.id) / COUNT(crimes.id) as clearance_rate FROM crimes LEFT JOIN arrests ON crimes.id = arrests.crime_id WHERE neighborhood = 'Bronx' GROUP BY neighborhood, type; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_figures(country VARCHAR(255), resource VARCHAR(255), year INT, production INT);INSERT INTO production_figures(country, resource, year, production) VALUES('United States','Shale Oil',2018,1000000),('United States','Shale Oil',2019,1100000),('United States','Shale Oil',2020,1200000),('Argentina','... | Compare production figures of unconventional shale oil in the United States and Argentina. | SELECT country, (production * 100 / (SELECT SUM(production) FROM production_figures WHERE country = pf.country AND resource = 'Shale Oil') ) AS production_percentage FROM production_figures pf WHERE country IN ('United States', 'Argentina') AND resource = 'Shale Oil' GROUP BY country, production; | gretelai_synthetic_text_to_sql |
CREATE TABLE eia_reports (report_id INT, mine_id INT, report_status TEXT); INSERT INTO eia_reports (report_id, mine_id, report_status) VALUES (1, 1, 'In Progress'), (2, 2, 'Completed'), (3, 3, 'Approved'), (4, 4, 'Rejected'); CREATE TABLE mines (mine_id INT, mine_name TEXT); INSERT INTO mines (mine_id, mine_name) VALUE... | Identify the EIA reports that have been reviewed and approved, and list the corresponding mine names and report_ids. | SELECT e.report_id, m.mine_name FROM eia_reports e JOIN mines m ON e.mine_id = m.mine_id WHERE e.report_status = 'Approved'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), country VARCHAR(50), launch_date DATE); INSERT INTO space_missions (id, mission_name, country, launch_date) VALUES (1, 'Mission 1', 'USA', '2018-01-01'); INSERT INTO space_missions (id, mission_name, country, launch_date) VALUES (2, 'Mission 2', 'China', '2... | How many space missions has each country conducted, ordered by the most missions? | SELECT country, COUNT(*) as total_missions FROM space_missions GROUP BY country ORDER BY total_missions DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT PRIMARY KEY, campaign_name VARCHAR(50), start_date DATE, end_date DATE, budget DECIMAL(5,2), location VARCHAR(50));INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, location) VALUES (1, 'End Stigma', '2022-01-01', '2022-02-28', 10000.00, 'New York'); | Insert a new campaign record into the campaigns table. | INSERT INTO campaigns (id, campaign_name, start_date, end_date, budget, location) VALUES (2, 'Mental Health Awareness', '2022-03-01', '2022-03-31', 7500.00, 'Los Angeles'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, FirstName VARCHAR(255), LastName VARCHAR(255), JerseyNumber INT); | Update the jersey number for athlete 'John Doe' to '12' in the 'Players' table. | UPDATE Players SET JerseyNumber = 12 WHERE FirstName = 'John' AND LastName = 'Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_stats (player_id INT, game_id INT, hours_played INT, PRIMARY KEY (player_id, game_id)); INSERT INTO player_stats VALUES (1, 1, 100), (1, 1, 200), (2, 1, 300), (2, 1, 400), (3, 1, 500), (3, 1, 600), (4, 1, 700), (4, 1, 800), (5, 1, 900), (5, 1, 1000), (6, 1, 1100), (6, 1, 1200); CREATE TABLE game_tit... | List the number of hours played by the top 10 players in 'World of Warcraft' | SELECT player_id, SUM(hours_played) as total_hours_played FROM player_stats ps INNER JOIN game_titles gt ON ps.game_id = gt.game_id WHERE gt.title = 'World of Warcraft' GROUP BY player_id ORDER BY total_hours_played DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_donations (disaster_type TEXT, donation_amount INTEGER); INSERT INTO disaster_donations (disaster_type, donation_amount) VALUES ('Flood', 50000), ('Earthquake', 75000), ('Fire', 30000); | What's the total donation amount for each disaster type? | SELECT d.disaster_type, SUM(d.donation_amount) FROM disaster_donations d GROUP BY d.disaster_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE accidents (id INT, year INT, country TEXT, incidents INT); INSERT INTO accidents (id, year, country, incidents) VALUES (1, 2015, 'Canada', 3), (2, 2016, 'Canada', 4), (3, 2017, 'Canada', 5); | How many aircraft accidents were there in Canada between 2015 and 2020? | SELECT SUM(incidents) FROM accidents WHERE country = 'Canada' AND year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding_records (company_name VARCHAR(50), funding_amount INT); | Insert a new funding record for company STU with funding amount 1000000 in the 'funding_records' table | INSERT INTO funding_records (company_name, funding_amount) VALUES ('STU', 1000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (city VARCHAR(20), initiative VARCHAR(20), is_circular BOOLEAN); INSERT INTO circular_economy_initiatives (city, initiative, is_circular) VALUES ('Berlin', 'Recycling program', true), ('Berlin', 'Waste-to-energy plant', false); | What is the percentage of circular economy initiatives in the city of Berlin, Germany?' | SELECT ROUND(COUNT(is_circular) * 100.0 / (SELECT COUNT(*) FROM circular_economy_initiatives WHERE city = 'Berlin') , 2) as percentage_of_circular_economy_initiatives FROM circular_economy_initiatives WHERE city = 'Berlin' AND is_circular = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_status VARCHAR(10), resolved_date DATE); INSERT INTO cases (case_id, case_status, resolved_date) VALUES (1, 'Defendant', '2021-01-15'), (2, 'Plaintiff', '2021-02-20'), (3, 'Defendant', '2021-03-05'); | How many cases were resolved in favor of the defendant in the last quarter? | SELECT COUNT(*) FROM cases WHERE case_status = 'Defendant' AND resolved_date >= '2021-01-01' AND resolved_date < '2021-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE asian_buses (city VARCHAR(20), num_buses INT); INSERT INTO asian_buses (city, num_buses) VALUES ('Singapore', 400), ('Seoul', 350), ('Tokyo', 300), ('Beijing', 250), ('Mumbai', 200); | List the top 2 cities with the most autonomous buses in Asia. | SELECT city, num_buses FROM (SELECT city, num_buses, ROW_NUMBER() OVER (ORDER BY num_buses DESC) rn FROM asian_buses WHERE city LIKE 'S%' OR city LIKE 'T%' OR city LIKE 'B%' OR city LIKE 'M%') tmp WHERE rn <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_metrics (id INT, employee_id INT, gender VARCHAR(50), race VARCHAR(50), veteran_status VARCHAR(50)); | Create a table for employee diversity metrics and insert data on gender, race, and veteran status | CREATE TABLE diversity_metrics (id INT, employee_id INT, gender VARCHAR(50), race VARCHAR(50), veteran_status VARCHAR(50)) AS SELECT * FROM (VALUES (1, 123, 'Female', 'Asian', 'No'), (2, 234, 'Male', 'Black', 'Yes'), (3, 345, 'Non-binary', 'White', 'No'), (4, 456, 'Female', 'Latinx', 'No')) AS t(id, employee_id, gender... | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (operation_id INT, operation_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO humanitarian_assistance (operation_id, operation_name, region, start_date, end_date) VALUES (1, 'Operation Aid', 'Southeast Asia', '2015-01-01', '2015-12-31'), (2, 'Oper... | What is the total number of humanitarian assistance operations in Southeast Asia from 2015 to 2020? | SELECT COUNT(*) FROM humanitarian_assistance INNER JOIN operations ON humanitarian_assistance.operation_id = operations.operation_id WHERE region = 'Southeast Asia' AND YEAR(start_date) BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmos_validators (validator_id INT, active BOOLEAN); | What is the number of active validators on the Cosmos network? | SELECT COUNT(validator_id) FROM cosmos_validators WHERE active = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (customer_id INT, transaction_date DATE, amount DECIMAL(10,2)); INSERT INTO transactions (customer_id, transaction_date, amount) VALUES (1, '2022-01-01', 100), (1, '2022-01-02', 150), (2, '2022-01-01', 50), (2, '2022-01-02', 200); | What is the transaction amount difference between the previous day and the current day for each customer? | SELECT customer_id, transaction_date, amount, LAG(amount) OVER (PARTITION BY customer_id ORDER BY transaction_date) AS previous_day_amount, amount - LAG(amount) OVER (PARTITION BY customer_id ORDER BY transaction_date) AS difference FROM transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (forest_id INT, forest_type VARCHAR(50), year INT, carbon_seq INT); INSERT INTO forests (forest_id, forest_type, year, carbon_seq) VALUES (1, 'Tropical', 2020, 5000), (2, 'Temperate', 2020, 4000), (3, 'Boreal', 2020, 3000); | What is the total carbon sequestered by each forest type in 2020, ranked from highest to lowest? | SELECT forest_type, SUM(carbon_seq) AS total_carbon_seq, RANK() OVER (ORDER BY SUM(carbon_seq) DESC) AS carbon_rank FROM forests WHERE year = 2020 GROUP BY forest_type ORDER BY carbon_rank ASC; | 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.