context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(100), last_inspection_date DATE, capacity INT); INSERT INTO vessels VALUES (1, 'MV Ever Given', '2022-02-28', 20000); INSERT INTO vessels VALUES (2, 'MV Maersk Mc-Kinney Moller', '2022-03-15', 15000); INSERT INTO vessels VALUES (3, 'MV CMA CGM Jacques Saade', NULL, 22000); | Which vessels have not been inspected for over a month, and what is their average capacity? | SELECT vessels.vessel_name, AVG(vessels.capacity) as avg_capacity FROM vessels WHERE vessels.last_inspection_date < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY vessels.vessel_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (id INT, project VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO project_timeline (id, project, start_date, end_date) VALUES (1, 'Office Building', '2019-12-20', '2021-04-30'), (2, 'Residential Apartments', '2021-03-01', '2022-08-01'), (3, 'School', '2020-06-15', '2021-10-15'); | List all building projects that started before 2020-06-01 and ended after 2020-12-31? | SELECT * FROM project_timeline WHERE start_date < '2020-06-01' AND end_date > '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, country VARCHAR(50)); INSERT INTO users VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); CREATE TABLE interactions (interaction_id INT, user_id INT, technology_type VARCHAR(20)); INSERT INTO interactions VALUES (1, 1, 'accessible'), (2, 2, 'non-accessible'), (3, 3, 'accessible'); | How many users have interacted with accessible technology in each country? | SELECT country, COUNT(DISTINCT user_id) FROM interactions INNER JOIN users ON interactions.user_id = users.user_id WHERE technology_type = 'accessible' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name TEXT, budget INT, created_at DATETIME); INSERT INTO department (id, name, budget, created_at) VALUES (1, 'education', 500000, '2021-01-01'), (2, 'healthcare', 1000000, '2022-01-01'); | What is the maximum budget allocated to a department in 2023? | SELECT name, MAX(budget) as max_budget FROM department WHERE created_at BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tech_For_Good (project_id INT, project_name VARCHAR(100), region VARCHAR(50), budget FLOAT); INSERT INTO Tech_For_Good (project_id, project_name, region, budget) VALUES (1, 'Project A', 'Middle East', 45000.00), (2, 'Project B', 'Africa', 55000.00), (3, 'Project C', 'Asia', 65000.00); | What is the total budget for technology for social good projects in the Middle East? | SELECT SUM(budget) FROM Tech_For_Good WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Trams (tram_id INT, region VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO Trams (tram_id, region, fare) VALUES (501, 'Riverside', 2.00), (502, 'Riverside', 2.50), (503, 'Riverside', 3.00); | What is the minimum fare for trams in the 'Riverside' region? | SELECT MIN(fare) FROM Trams WHERE region = 'Riverside'; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(100), age INT, craft VARCHAR(50), mission VARCHAR(100)); INSERT INTO astronauts (astronaut_id, name, age, craft, mission) VALUES (1, 'John', 45, 'Dragon', 'Mars'), (2, 'Sarah', 36, 'Starship', 'ISS'), (3, 'Mike', 50, 'Falcon', 'Mars'), (4, 'Jane', 42, 'Apollo', 'Moon'), (5, 'Emma', 34, 'Shuttle', 'Space'), (6, 'Bruce', 30, 'Shuttle', 'Space'), (7, 'Sally', 38, 'Dragon', 'Mars'), (8, 'Sam', 40, 'Apollo', 'Moon'); CREATE TABLE spacex_crafts (craft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO spacex_crafts (craft, manufacturer) VALUES ('Dragon', 'SpaceX'), ('Starship', 'SpaceX'), ('Falcon', 'SpaceX'); CREATE TABLE nasa_crafts (craft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO nasa_crafts (craft, manufacturer) VALUES ('Apollo', 'NASA'), ('Shuttle', 'NASA'); | What are the names of astronauts who have flown on both SpaceX and NASA crafts and their respective missions? | SELECT DISTINCT a.name, a.mission FROM astronauts a INNER JOIN spacex_crafts c ON a.craft = c.craft INNER JOIN nasa_crafts n ON a.craft = n.craft; | gretelai_synthetic_text_to_sql |
CREATE TABLE age_groups (age_group_id INT, age_group_name VARCHAR(50), lower_bound INT, upper_bound INT); | How many tickets were sold by age group? | SELECT ag.age_group_name, SUM(t.quantity) as tickets_sold FROM age_groups ag JOIN tickets t ON t.age BETWEEN ag.lower_bound AND ag.upper_bound GROUP BY ag.age_group_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, VesselType VARCHAR(50), AvgSpeed DECIMAL(5,2)); INSERT INTO Vessels VALUES (1, 'Container Ship', 21.5), (2, 'Tanker', 18.2), (3, 'Container Ship', 22.6); | What is the maximum speed of vessels in the container ship category? | SELECT MAX(AvgSpeed) FROM Vessels WHERE VesselType = 'Container Ship'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vaccinations (Disease VARCHAR(50), Continent VARCHAR(50), Percentage_Vaccinated FLOAT); INSERT INTO Vaccinations (Disease, Continent, Percentage_Vaccinated) VALUES ('Hepatitis B', 'South America', 90.0); | What is the percentage of children vaccinated for Hepatitis B in South America? | SELECT Percentage_Vaccinated FROM Vaccinations WHERE Disease = 'Hepatitis B' AND Continent = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, city VARCHAR(20), call_date DATE, response_time INT); INSERT INTO emergency_calls (id, city, call_date, response_time) VALUES (1, 'Chicago', '2021-12-01', 120), (2, 'Chicago', '2022-01-15', 150), (3, 'Chicago', '2022-02-28', 90); | What is the average response time for emergency calls in the city of Chicago during the winter months (December, January, February)? | SELECT AVG(response_time) FROM emergency_calls WHERE city = 'Chicago' AND EXTRACT(MONTH FROM call_date) IN (12, 1, 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Country VARCHAR(50), TechnicalTraining BOOLEAN); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, TechnicalTraining) VALUES (1, 'John', 'Doe', 'USA', true); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, TechnicalTraining) VALUES (2, 'Jane', 'Doe', 'Canada', false); | Display the number of employees who have completed technical training, by country, and sort the results by the number of employees in descending order | SELECT Country, COUNT(*) as NumberOfEmployees FROM Employees WHERE TechnicalTraining = true GROUP BY Country ORDER BY NumberOfEmployees DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibition_visits (id INT, visitor_id INT, exhibition_id INT, duration_mins INT, state TEXT); INSERT INTO exhibition_visits (id, visitor_id, exhibition_id, duration_mins, state) VALUES (1, 1, 1, 60, 'CA'), (2, 2, 1, 75, 'NY'); | Calculate the total duration spent on exhibitions by visitors from each US state. | SELECT state, SUM(duration_mins) FROM exhibition_visits WHERE state IS NOT NULL GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, state VARCHAR(20)); CREATE TABLE workout_data (id INT, user_id INT, hr INT, date DATE); | Calculate the minimum heart rate recorded for users living in Florida on weekends. | SELECT MIN(hr) FROM workout_data w JOIN users u ON w.user_id = u.id WHERE u.state = 'Florida' AND (DAYOFWEEK(w.date) = 1 OR DAYOFWEEK(w.date) = 7); | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, category VARCHAR(255), likes INT); INSERT INTO posts (id, category, likes) VALUES (1, 'Vegan Food', 100), (2, 'Vegan Food', 200), (3, 'Fitness', 300), (4, 'Travel', 400), (5, 'Vegan Food', 500); | What is the minimum number of likes for posts related to vegan food? | SELECT MIN(posts.likes) AS min_likes FROM posts WHERE posts.category = 'Vegan Food'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), avg_depth FLOAT); | Delete any marine protected areas with an average depth below 100 meters. | DELETE FROM marine_protected_areas WHERE avg_depth < 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE ROSCOSMOS_Missions (mission_id INT, name VARCHAR(50), type VARCHAR(50), expenses DECIMAL(10,2)); INSERT INTO ROSCOSMOS_Missions (mission_id, name, type, expenses) VALUES (1, 'MIR', 'Space Station', 3500000.00), (2, 'ISS Upgrades', 'Space Station', 2000000.00); | What are the total expenses for SpaceX satellite deployment projects, NASA space exploration research programs, and ROSCOSMOS space station missions? | SELECT SUM(expenses) FROM SpaceX_Projects WHERE type IN ('Satellite Deployment', 'Space Exploration') UNION ALL SELECT SUM(expenses) FROM NASA_Research WHERE type IN ('Space Exploration', 'Space Station') UNION ALL SELECT SUM(expenses) FROM ROSCOSMOS_Missions WHERE type = 'Space Station'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name TEXT, country TEXT); INSERT INTO customers (customer_id, name, country) VALUES (1, 'John Doe', 'USA'); INSERT INTO customers (customer_id, name, country) VALUES (2, 'Jane Smith', 'Canada'); | Which customers have made investments in both the US and Canada? | SELECT customer_id, name FROM customers WHERE country = 'USA' INTERSECT SELECT customer_id, name FROM customers WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cultural_Events (name VARCHAR(255), city VARCHAR(255), visitors_per_month DECIMAL(5,2)); | What is the average number of visitors per month for cultural events in Tokyo? | SELECT AVG(visitors_per_month) FROM Cultural_Events WHERE city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RegionName VARCHAR(20), HospitalName VARCHAR(20), HospitalCapacity INT); INSERT INTO Regions (RegionName, HospitalName, HospitalCapacity) VALUES ('Region3', 'HospitalX', 200), ('Region3', 'HospitalY', 250); | list all hospitals and their capacities in 'Region3' | SELECT HospitalName, HospitalCapacity FROM Regions WHERE RegionName = 'Region3'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(30)); CREATE TABLE properties (id INT, city VARCHAR(20), price INT, green_certified BOOLEAN); INSERT INTO cities (id, name) VALUES (1, 'Vancouver'), (2, 'Seattle'), (3, 'Portland'); INSERT INTO properties (id, city, price, green_certified) VALUES (101, 'Vancouver', 600000, true), (102, 'Vancouver', 700000, false), (103, 'Seattle', 800000, true), (104, 'Seattle', 900000, false), (105, 'Portland', 500000, true), (106, 'Portland', 400000, false); | What is the average property price for buildings with a green certification in each city? | SELECT cities.name, AVG(properties.price) FROM cities INNER JOIN properties ON cities.name = properties.city WHERE properties.green_certified = true GROUP BY cities.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), revenue INT); CREATE VIEW EventRevenue AS SELECT id, SUM(revenue) AS total_revenue FROM Events GROUP BY id; | What is the total revenue for events in the 'Art' category? | SELECT total_revenue FROM EventRevenue WHERE id IN (SELECT id FROM Events WHERE category = 'Art'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Transport_Emissions (id INT, mode VARCHAR(20), co2_emission FLOAT, year INT); INSERT INTO Transport_Emissions (id, mode, co2_emission, year) VALUES (1, 'Plane', 120.0, 2021), (2, 'Train', 15.0, 2021), (3, 'Bus', 40.0, 2021), (4, 'Car', 60.0, 2021), (5, 'Plane', 130.0, 2022), (6, 'Train', 16.0, 2022), (7, 'Bus', 42.0, 2022), (8, 'Car', 65.0, 2022); | What is the average CO2 emission for each mode of transport in 2021 and 2022? | SELECT mode, AVG(co2_emission) as avg_emission FROM Transport_Emissions WHERE year IN (2021, 2022) GROUP BY mode; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT); INSERT INTO packages (id, warehouse_id, weight) VALUES (1, 1, 50.5), (2, 1, 45.3), (3, 2, 60.1), (4, 2, 70.0), (5, 3, 30.2); | List the top 3 cities with the most packages shipped in March 2022 | SELECT warehouses.city, COUNT(*) as num_shipments FROM shipments JOIN packages ON shipments.id = packages.id JOIN warehouses ON shipments.warehouse_id = warehouses.id WHERE sent_date >= '2022-03-01' AND sent_date < '2022-04-01' GROUP BY warehouses.city ORDER BY num_shipments DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding_distribution (program_name VARCHAR(50), city VARCHAR(50), attendees INT, amount DECIMAL(10,2)); INSERT INTO funding_distribution (program_name, city, attendees, amount) VALUES ('Theater for All', 'New York', 100, 15000.00); | What was the average funding per attendee for the 'Theater for All' programs in New York? | SELECT AVG(amount / attendees) FROM funding_distribution WHERE program_name = 'Theater for All' AND city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_programs (id INT, program VARCHAR(30), city VARCHAR(20), start_year INT); INSERT INTO community_programs (id, program, city, start_year) VALUES (1, 'Coffee with a Cop', 'Denver', 2015), (2, 'Block Watch', 'Denver', 2016), (3, 'Community Police Academy', 'Denver', 2017), (4, 'Junior Police Academy', 'Denver', 2018), (5, 'Police Explorers', 'Denver', 2019); | How many community policing programs were implemented in Denver in 2018? | SELECT COUNT(*) as total FROM community_programs WHERE city = 'Denver' AND start_year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_data_2021 (id INT, crop VARCHAR(20), sensor_id INT); INSERT INTO sensor_data_2021 (id, crop, sensor_id) VALUES (1, 'Corn', 101), (2, 'Soybean', 102), (3, 'Corn', 103); | Find the number of sensors for each crop type in the 'sensor_data_2021' table. | SELECT crop, COUNT(DISTINCT sensor_id) FROM sensor_data_2021 GROUP BY crop; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (Player_ID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20)); INSERT INTO Players (Player_ID, Age, Gender, Country) VALUES (1, 25, 'Male', 'Country_X'), (2, 30, 'Female', 'Country_Y'); | What is the total number of players in the Players table? | SELECT COUNT(*) FROM Players; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (incident_time TIMESTAMP, source_ip VARCHAR(255)); | Show the total number of security incidents that occurred in the last month, broken down by the day they occurred and the source IP address. | SELECT DATE(incident_time) AS incident_date, source_ip, COUNT(*) AS total FROM security_incidents WHERE incident_time >= NOW() - INTERVAL '1 month' GROUP BY incident_date, source_ip; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_revenues (drug_name VARCHAR(100), revenue FLOAT, year INT); INSERT INTO drug_revenues (drug_name, revenue, year) VALUES ('DrugA', 1500000, 2022), ('DrugB', 2000000, 2022), ('DrugC', 1200000, 2022), ('DrugD', 2200000, 2022); | What was the highest revenue drug in 2022? | SELECT drug_name, revenue FROM drug_revenues WHERE year = 2022 AND revenue = (SELECT MAX(revenue) FROM drug_revenues WHERE year = 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(100), game_id INT, high_score INT); CREATE TABLE games (id INT, name VARCHAR(100)); INSERT INTO players (id, name, game_id, high_score) VALUES (1, 'Jane Doe', 1, 1500); INSERT INTO games (id, name) VALUES (1, 'Call of Duty'); | Identify players who achieved a high score of over 1000 in game 'Call of Duty' | SELECT players.name FROM players JOIN games ON players.game_id = games.id WHERE games.name = 'Call of Duty' AND players.high_score > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Garments (garment_id INT, garment_name VARCHAR(50), retail_price DECIMAL(5,2), fabric VARCHAR(50)); INSERT INTO Garments (garment_id, garment_name, retail_price, fabric) VALUES (1, 'Sequin Evening Gown', 850.99, 'Sequin'), (2, 'Cashmere Sweater', 250.00, 'Cashmere'), (3, 'Silk Blouse', 150.00, 'Silk'); | Find the total retail price of garments for each fabric type. | SELECT fabric, SUM(retail_price) FROM Garments GROUP BY fabric; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainablePractices (PracticeID INT, PracticeName VARCHAR(50), Description VARCHAR(255), Department VARCHAR(50), Cost DECIMAL(10,2)); INSERT INTO SustainablePractices (PracticeID, PracticeName, Description, Department, Cost) VALUES (3, 'Geothermal Energy', 'Utilizing geothermal energy to power construction equipment.', 'Mechanical Engineering', 15000.00); | What is the total cost of sustainable practices for the 'Mechanical Engineering' department? | SELECT SUM(SustainablePractices.Cost) FROM SustainablePractices WHERE SustainablePractices.Department = 'Mechanical Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE destinations (destination_id INT, destination_name VARCHAR(50), region VARCHAR(20), sustainable_practices_score DECIMAL(3,1), PRIMARY KEY (destination_id)); | Update the "region" field in the "destinations" table for all records with a "destination_name" of 'Rio de Janeiro' to be 'South America' | UPDATE destinations SET region = 'South America' WHERE destination_name = 'Rio de Janeiro'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(255), city VARCHAR(255)); INSERT INTO customers (customer_id, name, city) VALUES (1, 'John Doe', 'Seattle'), (2, 'Jane Smith', 'New York'); CREATE TABLE data_usage (customer_id INT, monthly_data_usage DECIMAL(10,2)); INSERT INTO data_usage (customer_id, monthly_data_usage) VALUES (1, 10.5), (2, 15.6); | What is the average data usage in gigabytes per month for customers in the city of Seattle? | SELECT AVG(monthly_data_usage) FROM data_usage INNER JOIN customers ON data_usage.customer_id = customers.customer_id WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TransportationTrips (Year INT, Mode VARCHAR(255), City VARCHAR(255), Count INT); INSERT INTO TransportationTrips (Year, Mode, City, Count) VALUES (2020, 'Bus', 'New York', 500000), (2020, 'Subway', 'New York', 700000), (2020, 'Bus', 'Los Angeles', 400000), (2020, 'Subway', 'Los Angeles', 600000), (2020, 'LightRail', 'Los Angeles', 300000); | How many public transportation trips were taken in 2020, by mode and city? | SELECT Mode, City, SUM(Count) AS TotalTrips FROM TransportationTrips WHERE Year = 2020 GROUP BY Mode, City; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_outcome VARCHAR(10), attorney_id INT); INSERT INTO cases (case_id, case_outcome, attorney_id) VALUES (1, 'Won', 101), (2, 'Lost', 102), (3, 'Won', 101); CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(20)); INSERT INTO attorneys (attorney_id, attorney_name) VALUES (101, 'Smith'), (102, 'Johnson'), (103, 'Williams'); | List the names of attorneys who have never lost a case. | SELECT a.attorney_name FROM attorneys a LEFT JOIN cases c ON a.attorney_id = c.attorney_id WHERE c.case_outcome IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE VRHeadsetsSales (SaleID INT, State VARCHAR(50), Country VARCHAR(50), Year INT, QuantitySold INT); INSERT INTO VRHeadsetsSales (SaleID, State, Country, Year, QuantitySold) VALUES (1, 'California', 'USA', 2017, 2000), (2, 'Texas', 'USA', 2018, 3000), (3, 'California', 'USA', 2018, 4000), (4, 'California', 'USA', 2019, 5000), (5, 'New York', 'USA', 2020, 6000); | What is the total number of VR headsets sold in California, USA between 2018 and 2020? | SELECT SUM(QuantitySold) FROM VRHeadsetsSales WHERE State = 'California' AND Year BETWEEN 2018 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (project_id INT, city VARCHAR(20), project_type VARCHAR(20), timeline_in_months INT); INSERT INTO project_timeline (project_id, city, project_type, timeline_in_months) VALUES (1, 'Chicago', 'Sustainable', 18), (2, 'Chicago', 'Conventional', 20), (3, 'New York', 'Sustainable', 22), (4, 'Los Angeles', 'Sustainable', 24), (5, 'Los Angeles', 'Conventional', 26); | What is the average project timeline in months for sustainable building projects in the city of Los Angeles? | SELECT city, AVG(timeline_in_months) FROM project_timeline WHERE city = 'Los Angeles' AND project_type = 'Sustainable' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255), is_cruelty_free BOOLEAN, customer_satisfaction_rating DECIMAL(3,2)); | Which cruelty-free makeup brands have the highest customer satisfaction ratings? | SELECT brand_name, MAX(customer_satisfaction_rating) FROM brands WHERE is_cruelty_free = TRUE GROUP BY brand_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, state VARCHAR(20), date DATE, crime VARCHAR(20)); INSERT INTO crimes (id, state, date, crime) VALUES (1, 'Florida', '2021-01-01', 'Theft'), (2, 'Florida', '2021-02-01', 'Burglary'), (3, 'Florida', '2021-03-01', 'Assault'); | What is the total number of reported crimes in the state of Florida? | SELECT COUNT(*) FROM crimes WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE banks (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE loans (id INT, bank_id INT, amount DECIMAL(10, 2), issue_date DATE); INSERT INTO banks (id, name, region) VALUES (1, 'Islamic Bank 1', 'Middle East'), (2, 'Islamic Bank 2', 'Asia'), (3, 'Ethical Bank 1', 'Europe'), (4, 'Socially Responsible Bank 1', 'North America'); INSERT INTO loans (id, bank_id, amount, issue_date) VALUES (1, 1, 5000, '2022-01-01'), (2, 1, 7000, '2022-04-01'), (3, 2, 6000, '2022-03-15'), (4, 2, 8000, '2022-01-10'), (5, 3, 9000, '2022-02-15'), (6, 3, 10000, '2022-05-01'), (7, 4, 11000, '2022-03-01'), (8, 4, 12000, '2022-06-15'); | What is the maximum loan amount issued by a bank in a specific region? | SELECT MAX(l.amount) as max_loan_amount FROM banks b JOIN loans l ON b.id = l.bank_id WHERE b.region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE UserStreamCountries (Country VARCHAR(20), UserCount INT); INSERT INTO UserStreamCountries (Country, UserCount) VALUES ('USA', '10000000'), ('UK', '6000000'), ('Canada', '4000000'), ('Australia', '3000000'), ('Germany', '5000000'); | List the top 5 countries with the highest number of unique users who have streamed music. | SELECT Country, UserCount FROM UserStreamCountries ORDER BY UserCount DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vulnerabilities (id INT, operating_system VARCHAR(255), severity INT); INSERT INTO Vulnerabilities (id, operating_system, severity) VALUES (1, 'Windows', 7), (2, 'Linux', 5), (3, 'Windows', 9); CREATE TABLE OperatingSystems (id INT, name VARCHAR(255)); INSERT INTO OperatingSystems (id, name) VALUES (1, 'Windows'), (2, 'Linux'), (3, 'Mac'); | What is the average severity of vulnerabilities for each operating system? | SELECT OperatingSystems.name AS Operating_System, AVG(Vulnerabilities.severity) AS Average_Severity FROM Vulnerabilities INNER JOIN OperatingSystems ON Vulnerabilities.operating_system = OperatingSystems.name GROUP BY OperatingSystems.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, biomass FLOAT); INSERT INTO fish_farms (id, name, location, biomass) VALUES (1, 'Farm A', 'Arctic Ocean', 100.5), (2, 'Farm B', 'Arctic Ocean', 120.0), (3, 'Farm C', 'Antarctic Ocean', 150.0); | What is the total biomass (kg) of fish in fish farms located in the Arctic Ocean? | SELECT SUM(biomass) FROM fish_farms WHERE location = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, name TEXT, provider TEXT, country TEXT); INSERT INTO virtual_tours (tour_id, name, provider, country) VALUES (1, 'Lisbon City Tour', 'Virtual Voyages', 'Portugal'), (2, 'Sintra Palace Tour', 'Virtually There', 'Portugal'); | List the names and providers of virtual tours offered in Portugal and their respective providers. | SELECT name, provider FROM virtual_tours WHERE country = 'Portugal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_stations (station_id INT, station_name VARCHAR(50), city VARCHAR(50), time_between_arrivals TIME); INSERT INTO subway_stations (station_id, station_name, city, time_between_arrivals) VALUES (1, 'Times Square', 'New York City', '5:00'), (2, 'Grand Central', 'New York City', '3:00'), (3, 'Penn Station', 'New York City', '4:00'); | What is the minimum time between subway train arrivals in New York City? | SELECT MIN(TIME_TO_SEC(time_between_arrivals))/60.0 FROM subway_stations WHERE city = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecrafts (id INT, name VARCHAR(100), manufacturer VARCHAR(100), mission_to_mars BOOLEAN); CREATE TABLE Manufacturers (id INT, name VARCHAR(100)); INSERT INTO Spacecrafts VALUES (1, 'Mars Rover 1', 'SpaceCorp', TRUE); INSERT INTO Spacecrafts VALUES (2, 'Mars Rover 2', 'SpaceCorp', FALSE); INSERT INTO Manufacturers VALUES (1, 'SpaceCorp'); INSERT INTO Manufacturers VALUES (2, 'NASA'); | What is the total number of spacecraft built by each manufacturer and the number of those spacecraft that were part of missions to Mars? | SELECT Manufacturers.name, SUM(CASE WHEN Spacecrafts.mission_to_mars = TRUE THEN 1 ELSE 0 END) AS missions_to_mars, SUM(CASE WHEN Spacecrafts.mission_to_mars = TRUE THEN 1 ELSE 0 END) / COUNT(*) * 100 AS mars_mission_percentage FROM Spacecrafts INNER JOIN Manufacturers ON Spacecrafts.manufacturer = Manufacturers.name GROUP BY Manufacturers.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_ai_frameworks (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, organization VARCHAR(255)); INSERT INTO ethical_ai_frameworks (id, name, description, organization) VALUES (1, 'Ethical AI 1.0', 'A framework for building ethical AI', 'AI for Good Foundation'); INSERT INTO ethical_ai_frameworks (id, name, description, organization) VALUES (2, 'AI for Climate 1.0', 'A framework for using AI to combat climate change', 'AI for Good Foundation'); INSERT INTO ethical_ai_frameworks (id, name, description, organization) VALUES (3, 'Accessibility 1.0', 'A framework for building accessible tech', 'Tech for Social Impact Inc.'); CREATE TABLE talks (id INT PRIMARY KEY, title VARCHAR(255), speaker_id INT, conference_id INT, organization VARCHAR(255)); INSERT INTO talks (id, title, speaker_id, conference_id, organization) VALUES (1, 'Ethical AI in Healthcare', 1, 1, 'AI for Good Foundation'); INSERT INTO talks (id, title, speaker_id, conference_id, organization) VALUES (2, 'AI for Climate Change', 1, 2, 'AI for Good Foundation'); INSERT INTO talks (id, title, speaker_id, conference_id, organization) VALUES (3, 'Accessibility in Tech', 2, 3, 'Tech for Social Impact Inc.'); INSERT INTO talks (id, title, speaker_id, conference_id, organization) VALUES (4, 'AI for Social Good', 1, 4, 'AI for Good Foundation'); CREATE TABLE conferences (id INT PRIMARY KEY, name VARCHAR(255), city VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO conferences (id, name, city, start_date, end_date) VALUES (1, 'AI for Social Good Summit', 'San Francisco', '2022-06-01', '2022-06-03'); INSERT INTO conferences (id, name, city, start_date, end_date) VALUES (2, 'Climate Change Tech Conference', 'Vancouver', '2022-07-01', '2022-07-02'); INSERT INTO conferences (id, name, city, start_date, end_date) VALUES (3, 'Accessibility in Tech Conference', 'Toronto', '2022-08-01', '2022-08-03'); INSERT INTO conferences (id, name, city, start_date, end_date) VALUES (4, 'Ethical AI Conference', 'New York', '2022-09-01', '2022-09-03'); | Which organizations are associated with ethical AI frameworks and have given more than one talk? | SELECT DISTINCT organization FROM talks WHERE organization IN (SELECT organization FROM ethical_ai_frameworks) GROUP BY organization HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (id INT, name VARCHAR(50), location VARCHAR(50), efficiency FLOAT, capacity INT); INSERT INTO solar_plants (id, name, location, efficiency, capacity) VALUES (1, 'SolarPlant1', 'Africa', 0.25, 100), (2, 'SolarPlant2', 'Africa', 0.28, 150); | What is the total installed capacity (in MW) of solar power plants in 'Africa' that have an efficiency rating above 22%? | SELECT SUM(capacity) FROM solar_plants WHERE location = 'Africa' AND efficiency > 0.22; | gretelai_synthetic_text_to_sql |
CREATE TABLE salesperson (salesperson_id INT, name VARCHAR(50), position VARCHAR(50)); CREATE TABLE tickets (ticket_id INT, salesperson_id INT, event_id INT, price DECIMAL(5,2), quantity INT); CREATE TABLE events (event_id INT, name VARCHAR(50), date DATE); INSERT INTO salesperson VALUES (1, 'John Doe', 'Senior Salesperson'); INSERT INTO events VALUES (2, 'New Event', '2023-04-15'); | Insert new records of ticket sales for a new event, identified by its event ID, including salesperson information. | INSERT INTO tickets (ticket_id, salesperson_id, event_id, price, quantity) VALUES (2, 1, 2, 75, 50); | gretelai_synthetic_text_to_sql |
CREATE TABLE Teachers (TeacherID INT, Name VARCHAR(100), Subject VARCHAR(50)); CREATE VIEW TopTeachers AS SELECT Name, Subject FROM Teachers WHERE Subject = 'Science'; | Drop the 'TopTeachers' view | DROP VIEW TopTeachers; | gretelai_synthetic_text_to_sql |
CREATE TABLE impact_investments (id INT, sector VARCHAR(20), investment_amount FLOAT); INSERT INTO impact_investments (id, sector, investment_amount) VALUES (1, 'microfinance', 10000), (2, 'renewable_energy', 50000), (3, 'microfinance', 15000); | What is the minimum impact investment amount for the 'microfinance' sector? | SELECT MIN(investment_amount) FROM impact_investments WHERE sector = 'microfinance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_name VARCHAR(50), jersey_number INT, country_name VARCHAR(50)); INSERT INTO players (player_name, jersey_number, country_name) VALUES ('John', 10, 'USA'), ('Alex', 12, 'USA'), ('James', 7, 'Australia'), ('Ben', 8, 'Australia'); | Delete all records for the 'Australia' team from the players table. | DELETE FROM players WHERE country_name = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops (name VARCHAR(50), farming_method VARCHAR(50)); INSERT INTO Crops (name, farming_method) VALUES ('Corn', 'Organic'), ('Soybean', 'Conventional'), ('Wheat', 'Organic'); | Identify crops that are present in both organic and conventional farming methods. | SELECT name FROM Crops WHERE farming_method IN ('Organic', 'Conventional') GROUP BY name HAVING COUNT(DISTINCT farming_method) = 2 | gretelai_synthetic_text_to_sql |
CREATE TABLE Missions (id INT, name VARCHAR(50), launch_year INT); INSERT INTO Missions (id, name, launch_year) VALUES (1, 'Mission1', 2000), (2, 'Mission2', 1999), (3, 'Mission3', 2001); | What is the total number of space missions launched before 1999? | SELECT COUNT(*) FROM Missions WHERE launch_year < 1999; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_missions (id INT, mission VARCHAR(255), country VARCHAR(255), year INT); | Add a new record of a humanitarian mission. | INSERT INTO humanitarian_missions (id, mission, country, year) VALUES (1, 'Rebuilding Schools in Haiti', 'Haiti', 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, country_code CHAR(2)); | What's the total amount of donations received by each country? | SELECT country_code, SUM(donation_amount) FROM donations GROUP BY country_code; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (startup_id INT, amount INT, sector VARCHAR(20)); | Calculate the average funding amount for startups in the "technology" sector | SELECT AVG(funding.amount) FROM funding INNER JOIN startups ON funding.startup_id = startups.id WHERE startups.sector = 'technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (id INT, state VARCHAR(255), genre VARCHAR(255), streams INT); | What is the average number of streams per user for users in Texas who have streamed songs by artists from the Country genre? | SELECT AVG(streams) FROM Users WHERE state = 'Texas' AND genre = 'Country'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fund_green_investments(fund_id INT, investment_id INT); | List of green investments by a specific Canadian fund | SELECT investment_id FROM fund_green_investments WHERE fund_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Country VARCHAR(50)); INSERT INTO Artists (ArtistID, ArtistName, Country) VALUES (6, 'Burna Boy', 'Nigeria'); | Update the country of the artist with ID 6 to Ghana. | UPDATE Artists SET Country = 'Ghana' WHERE ArtistID = 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (Company_ID INT, Company_Name VARCHAR(100), Industry_4_0 BOOLEAN); | List companies that have implemented Industry 4.0 practices | SELECT DISTINCT Company_Name FROM Companies WHERE Industry_4_0 = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS iot_sensors_3 (id int, location varchar(50), temperature float, timestamp datetime); INSERT INTO iot_sensors_3 (id, location, temperature, timestamp) VALUES (1, 'Kenya', 31.6, '2022-03-22 10:00:00'); | What is the maximum temperature recorded by IoT sensors in Kenya in the last 14 days? | SELECT MAX(temperature) FROM iot_sensors_3 WHERE location = 'Kenya' AND timestamp >= DATE_SUB(NOW(), INTERVAL 14 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, therapist_id INT, age INT, gender TEXT); INSERT INTO patients (patient_id, therapist_id, age, gender) VALUES (1, 1, 30, 'Female'), (2, 1, 40, 'Male'), (3, 2, 50, 'Female'), (4, 2, 60, 'Non-binary'), (5, 3, 25, 'Male'), (6, 3, 35, 'Female'); CREATE TABLE therapists (therapist_id INT, first_name TEXT); INSERT INTO therapists (therapist_id, first_name) VALUES (1, 'Sophia'), (2, 'Liam'), (3, 'James'); | Identify the average age of patients who have been treated by therapists named "Sophia" or "Liam", and group the result by their gender. | SELECT therapists.first_name, patients.gender, AVG(patients.age) AS avg_age FROM patients JOIN therapists ON patients.therapist_id = therapists.therapist_id WHERE therapists.first_name IN ('Sophia', 'Liam') GROUP BY therapists.first_name, patients.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(50), country VARCHAR(20)); INSERT INTO mining_sites (site_id, site_name, country) VALUES (1, 'Mining Site A', 'Peru'), (2, 'Mining Site B', 'Peru'), (3, 'Mining Site C', 'Peru'); CREATE TABLE eia_schedule (site_id INT, eia_date DATE); INSERT INTO eia_schedule (site_id, eia_date) VALUES (1, '2023-05-01'), (2, '2023-06-15'), (3, '2023-07-20'); | List mining sites in Peru with EIA due dates in the next 3 months. | SELECT site_name FROM mining_sites INNER JOIN eia_schedule ON mining_sites.site_id = eia_schedule.site_id WHERE eia_schedule.eia_date BETWEEN DATE_ADD(CURDATE(), INTERVAL 3 MONTH) AND DATE_ADD(CURDATE(), INTERVAL 4 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (booking_id INT, booking_date DATE); INSERT INTO bookings (booking_id, booking_date) VALUES (1, '2022-08-01'), (2, '2022-08-02'), (3, '2022-08-03'); | What is the number of bookings per day for the 'bookings' table in the month of August 2022? | SELECT DATE(booking_date) AS booking_day, COUNT(*) AS bookings_per_day FROM bookings WHERE EXTRACT(MONTH FROM booking_date) = 8 GROUP BY booking_day; | gretelai_synthetic_text_to_sql |
CREATE TABLE emissions (id INT PRIMARY KEY, country VARCHAR(50), emissions INT); INSERT INTO emissions (id, country, emissions) VALUES (1, 'China', 10000), (2, 'US', 8000), (3, 'India', 6000); | List the top 3 contributing countries to climate change based on emissions data | SELECT country, emissions FROM emissions ORDER BY emissions DESC LIMIT 3 | gretelai_synthetic_text_to_sql |
CREATE TABLE penguins (id INT, species VARCHAR(20), avg_weight FLOAT); | What is the average weight of all penguins in the 'penguins' table? | SELECT avg(avg_weight) FROM penguins; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, supplier_id INT, ethical_rating INT); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), ethical_rating INT); INSERT INTO products (product_id, supplier_id, ethical_rating) VALUES (1, 101, 9), (2, 102, 5), (3, 103, 8); INSERT INTO suppliers (supplier_id, supplier_name, ethical_rating) VALUES (101, 'Supplier X', 9), (102, 'Supplier Y', 5), (103, 'Supplier Z', 8); | Remove products sourced from a supplier with a low ethical rating | DELETE FROM products WHERE supplier_id IN (SELECT supplier_id FROM suppliers WHERE ethical_rating < 7); | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (name VARCHAR(50), genre VARCHAR(50)); INSERT INTO artists (name, genre) VALUES ('Beyoncé', 'Pop'), ('Drake', 'Hip Hop'), ('Taylor Swift', 'Country Pop'), ('Kendrick Lamar', 'Hip Hop'); CREATE TABLE concerts (artist_name VARCHAR(50), venue VARCHAR(50), ticket_price DECIMAL(5,2)); INSERT INTO concerts (artist_name, venue, ticket_price) VALUES ('Beyoncé', 'Madison Square Garden', 200.00), ('Beyoncé', 'Staples Center', 180.00), ('Drake', 'Barclays Center', 150.00), ('Taylor Swift', 'MetLife Stadium', 250.00), ('Kendrick Lamar', 'Staples Center', 120.00); | List the top 2 genres with the highest average concert ticket prices. | SELECT genre, AVG(ticket_price) AS avg_ticket_price, ROW_NUMBER() OVER(ORDER BY AVG(ticket_price) DESC) AS rank FROM artists JOIN concerts ON artists.name = concerts.artist_name GROUP BY genre ORDER BY rank ASC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (Id INT, Name VARCHAR(100), Genre VARCHAR(50), Platform VARCHAR(50), Sales INT, PlayTime FLOAT, Region VARCHAR(50)); INSERT INTO Games VALUES (1, 'GameG', 'Action', 'Console', 5000, 20.5, 'North America'), (2, 'GameH', 'Role-playing', 'Console', 7000, 35.2, 'Europe'), (3, 'GameI', 'Action', 'Console', 8000, 18.4, 'North America'), (4, 'GameJ', 'Role-playing', 'Console', 6000, 25.8, 'Asia'), (5, 'GameK', 'Role-playing', 'Console', 9000, 30.5, 'Europe'), (6, 'GameL', 'Action', 'Console', 4000, 40.0, 'Asia'); | What are the total sales and average play time for 'Action' games on Console by region? | SELECT Region, SUM(Sales) AS Total_Sales, AVG(PlayTime) AS Avg_PlayTime FROM Games WHERE Genre = 'Action' AND Platform = 'Console' GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mumbai_districts (district_id INT, district_name VARCHAR(50), city VARCHAR(20), year INT, meetings_held INT); INSERT INTO mumbai_districts (district_id, district_name, city, year, meetings_held) VALUES (1, 'Colaba', 'Mumbai', 2020, 10); | List the names and number of public meetings for each district in the city of Mumbai for the year 2020 | SELECT district_name, SUM(meetings_held) FROM mumbai_districts WHERE city = 'Mumbai' AND year = 2020 GROUP BY district_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonSequestration (ID INT, Location TEXT, Year INT, Sequestration INT); INSERT INTO CarbonSequestration (ID, Location, Year, Sequestration) VALUES (1, 'Greenland', 2010, 1000); INSERT INTO CarbonSequestration (ID, Location, Year, Sequestration) VALUES (2, 'Greenland', 2011, 1500); | What is the maximum carbon sequestration observed in a year in Greenland? | SELECT MAX(Year) as Max_Year, MAX(Sequestration) as Max_Sequestration FROM CarbonSequestration WHERE Location = 'Greenland'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_data (id INT, season VARCHAR(10), rainfall DECIMAL(3,1)); | What is the minimum rainfall in the 'climate_data' table for each season? | SELECT season, MIN(rainfall) FROM climate_data GROUP BY season; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_building_certifications (id INT, certification_date DATE); | Count the number of green building certifications for each year | SELECT EXTRACT(YEAR FROM certification_date) AS year, COUNT(*) FROM green_building_certifications GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE grants (id INT, faculty_id INT, year INT, amount DECIMAL(10,2)); INSERT INTO grants (id, faculty_id, year, amount) VALUES (1, 1, 2020, 25000); INSERT INTO grants (id, faculty_id, year, amount) VALUES (2, 2, 2019, 30000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO faculty (id, name, department) VALUES (1, 'Eva', 'Physics'); INSERT INTO faculty (id, name, department) VALUES (2, 'Frank', 'Chemistry'); | What is the maximum amount of grant funding received by a single faculty member in the Physics department in a single year? | SELECT MAX(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Physics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rainfall_data (id INT, farm_id INT, rainfall FLOAT, record_date DATE); INSERT INTO rainfall_data (id, farm_id, rainfall, record_date) VALUES (1, 1, 25.5, '2022-01-01'), (2, 2, 30.0, '2022-01-01'), (3, 3, 18.2, '2022-01-01'), (4, 4, 22.8, '2022-01-01'), (5, 5, 35.1, '2022-01-01'), (6, 6, 20.5, '2022-01-01'), (7, 7, 40.0, '2022-01-01'), (8, 8, 10.3, '2022-01-01'), (9, 9, 28.9, '2022-01-01'), (10, 10, 32.1, '2022-01-01'); | What is the average rainfall for farms located in India? | SELECT AVG(rainfall) FROM rainfall_data WHERE farm_id IN (SELECT id FROM farmers WHERE location = 'India'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA aerospace; CREATE TABLE aerospace.satellites (satellite_id INT, country VARCHAR(50), launch_date DATE); INSERT INTO aerospace.satellites VALUES (1, 'USA', '2000-01-01'); INSERT INTO aerospace.satellites VALUES (2, 'Russia', '2001-02-01'); INSERT INTO aerospace.satellites VALUES (3, 'China', '2002-03-01'); | What is the total number of satellites launched by country in descending order? | SELECT country, COUNT(satellite_id) OVER (ORDER BY COUNT(satellite_id) DESC) as total_launched FROM aerospace.satellites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, region VARCHAR(10), element VARCHAR(10), quantity INT); INSERT INTO production (year, region, element, quantity) VALUES (2015, 'Asia', 'Lanthanum', 1200), (2016, 'Asia', 'Lanthanum', 1400), (2017, 'Asia', 'Lanthanum', 1500), (2018, 'Asia', 'Lanthanum', 1800), (2019, 'Asia', 'Lanthanum', 2000); | Which element had the highest production increase from 2017 to 2018 in Asia? | SELECT element, (MAX(quantity) - MIN(quantity)) AS production_increase FROM production WHERE region = 'Asia' AND year IN (2017, 2018) GROUP BY element ORDER BY production_increase DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_planets (name TEXT, distance_from_sun FLOAT); INSERT INTO space_planets (name, distance_from_sun) VALUES ('Mercury', 0.39), ('Venus', 0.72), ('Earth', 1.00), ('Mars', 1.52), ('Jupiter', 5.20), ('Saturn', 9.58), ('Uranus', 19.18), ('Neptune', 30.07); | What is the minimum distance between Earth and any other planet? | SELECT MIN(ABS(distance_from_sun - 1.00)) FROM space_planets; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT, species VARCHAR(255), area INT); | Find the species with the lowest total habitat area in 'habitat_preservation' table. | SELECT species, SUM(area) AS total_area FROM habitat_preservation GROUP BY species ORDER BY total_area LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sargasso_sea (location TEXT, depth INTEGER); INSERT INTO sargasso_sea (location, depth) VALUES ('Sargasso Sea', 4000); | What is the minimum depth recorded in the Sargasso Sea? | SELECT MIN(depth) FROM sargasso_sea; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_content (id INT, content_id INT, represents_group BOOLEAN, group_name VARCHAR); INSERT INTO media_content (id, content_id, represents_group, group_name) VALUES (1, 1, true, 'LGBTQ+'); INSERT INTO media_content (id, content_id, represents_group, group_name) VALUES (2, 2, false, 'Women'); | What are the top 5 most represented cultural groups in media content? | SELECT group_name, represents_group, COUNT(*) as num_representations FROM media_content WHERE represents_group = true GROUP BY group_name ORDER BY num_representations DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE factory_emissions (id INT, factory VARCHAR(100), location VARCHAR(100), co2_emissions DECIMAL(5,2)); INSERT INTO factory_emissions (id, factory, location, co2_emissions) VALUES (1, 'Germany Factory', 'Germany', 50), (2, 'France Factory', 'France', 70), (3, 'Italy Factory', 'Italy', 60); | What is the average CO2 emission of factories in Europe? | SELECT AVG(co2_emissions) FROM factory_emissions WHERE location = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage_sk (id INT, year INT, country VARCHAR(255), capacity FLOAT); INSERT INTO energy_storage_sk (id, year, country, capacity) VALUES (1, 2016, 'South Korea', 120.5), (2, 2017, 'South Korea', 135.2), (3, 2018, 'South Korea', 142.1), (4, 2019, 'South Korea', 150.9); | What is the change in energy storage capacity in South Korea between 2016 and 2019? | SELECT (capacity - LAG(capacity) OVER (PARTITION BY country ORDER BY year)) FROM energy_storage_sk WHERE country = 'South Korea' AND year IN (2017, 2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_name VARCHAR(50), num_citizens INT, num_satisfied_citizens INT); INSERT INTO districts VALUES ('District A', 10000, 8000); INSERT INTO districts VALUES ('District B', 12000, 9500); INSERT INTO districts VALUES ('District C', 15000, 11000); | What is the percentage of citizens who are satisfied with public transportation in each district? | SELECT district_name, (num_satisfied_citizens * 100.0 / num_citizens) as percentage_satisfied FROM districts; | gretelai_synthetic_text_to_sql |
CREATE TABLE Textiles (brand VARCHAR(20), fabric_type VARCHAR(20), quantity INT); INSERT INTO Textiles (brand, fabric_type, quantity) VALUES ('Eco-friendly Fashions', 'Organic Cotton', 1500), ('Eco-friendly Fashions', 'Recycled Polyester', 2000), ('Fab Fashions', 'Viscose', 1200); | Find the total quantity of sustainable fabric used by the 'Eco-friendly Fashions' brand in the 'Textiles' table. | SELECT SUM(quantity) FROM Textiles WHERE brand = 'Eco-friendly Fashions' AND fabric_type = 'Organic Cotton' OR fabric_type = 'Recycled Polyester'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT PRIMARY KEY, mental_health_score INT, hours_spent_on_ll INT); | What is the minimum number of hours spent on lifelong learning by students who have a mental health score above the average? | SELECT MIN(st.hours_spent_on_ll) FROM students st WHERE st.mental_health_score > (SELECT AVG(st2.mental_health_score) FROM students st2); | gretelai_synthetic_text_to_sql |
CREATE TABLE risk_assessments (assess_id INT, assess_description TEXT, region VARCHAR(50)); | Insert new geopolitical risk assessments for 'Europe' | INSERT INTO risk_assessments (assess_id, assess_description, region) VALUES (1, 'Rising political tensions', 'Europe'), (2, 'Economic instability', 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE geology_company (id INT, name VARCHAR, position VARCHAR, department VARCHAR, salary DECIMAL); INSERT INTO geology_company (id, name, position, department, salary) VALUES (1, 'Amy Pond', 'Geologist', 'Geology', 80000.00), (2, 'Rory Williams', 'Assistant Geologist', 'Geology', 60000.00), (3, 'Melody Pond', 'Lab Technician', 'Geology', 55000.00); | What is the average salary for geologists in the 'geology_company' table? | SELECT AVG(salary) FROM geology_company WHERE position LIKE '%Geologist%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (id INT, country VARCHAR(50), price FLOAT, start_date DATE, end_date DATE); INSERT INTO carbon_prices (id, country, price, start_date, end_date) VALUES (1, 'Brazil', 12.0, '2023-04-01', '2023-12-31'); INSERT INTO carbon_prices (id, country, price, start_date, end_date) VALUES (2, 'South Africa', 10.5, '2023-04-01', '2023-12-31'); | What is the carbon price for Brazil and South Africa on April 1, 2023? | SELECT country, price FROM carbon_prices WHERE start_date <= '2023-04-01' AND end_date >= '2023-04-01' AND country IN ('Brazil', 'South Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE game_designers (designer_id INT, gender VARCHAR(10), genre VARCHAR(10), players INT); | How many male players have designed a puzzle game and have more than 5,000 players? | SELECT COUNT(*) FROM game_designers WHERE gender = 'male' AND genre = 'puzzle' AND players > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_revenue(restaurant_id INT, cuisine VARCHAR(255), region VARCHAR(255), revenue DECIMAL(10,2), revenue_date DATE); | What is the total revenue for the 'Seafood' cuisine category in the 'North America' region for the month of April 2022? | SELECT SUM(revenue) FROM restaurant_revenue WHERE cuisine = 'Seafood' AND region = 'North America' AND revenue_date BETWEEN '2022-04-01' AND '2022-04-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_age (id INT, member_id INT, age INT); INSERT INTO member_age (id, member_id, age) VALUES (1, 501, 55), (2, 502, 45), (3, 503, 60), (4, 504, 35); | Which members have an age greater than 50? | SELECT DISTINCT member_id FROM member_age WHERE age > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL); INSERT INTO donors (id, name, country, amount_donated) VALUES (1, 'John Doe', 'USA', 500.00), (2, 'Jane Smith', 'Canada', 300.00); | What is the average amount donated by donors from the United States? | SELECT AVG(amount_donated) FROM donors WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales(artist_id INT, region VARCHAR(50), sales INT); | Update the ticket sales for the artist 'BTS' in 'Asia' by 10%. | UPDATE ticket_sales SET sales = sales * 1.1 WHERE artist_id = (SELECT artist_id FROM artists WHERE name = 'BTS') AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists(id INT, name VARCHAR(255), category VARCHAR(255), num_works INT); INSERT INTO artists (id, name, category, num_works) VALUES (1, 'Picasso', 'Modern Art', 1000), (2, 'Matisse', 'Modern Art', 800), (3, 'Warhol', 'Contemporary Art', 700); | Who is the most prolific artist in the 'Modern Art' category? | SELECT name FROM artists WHERE category = 'Modern Art' ORDER BY num_works DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE states ( state_id INT, state_name TEXT ); INSERT INTO states (state_id, state_name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'), (4, 'Florida'), (5, 'Illinois'); CREATE TABLE residential_water_usage ( id INT, state_id INT, year INT, water_consumption FLOAT ); INSERT INTO residential_water_usage (id, state_id, year, water_consumption) VALUES (1, 1, 2019, 6000), (2, 2, 2019, 4500), (3, 3, 2019, 5000), (4, 4, 2019, 4000), (5, 5, 2019, 3500), (6, 1, 2019, 7000), (7, 2, 2019, 4700), (8, 3, 2019, 5200), (9, 4, 2019, 4200), (10, 5, 2019, 3700); | List the top 3 states with the highest water consumption in the residential sector in 2019? | SELECT s.state_name, SUM(r.water_consumption) as total_water_consumption FROM states s JOIN residential_water_usage r ON s.state_id = r.state_id WHERE r.year = 2019 GROUP BY s.state_name ORDER BY total_water_consumption DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_ferries (ferry_id INT, passenger_capacity INT, city VARCHAR(50)); | What is the total number of electric ferries in Oslo and their total passenger capacity? | SELECT COUNT(*), SUM(passenger_capacity) FROM electric_ferries WHERE city = 'Oslo'; | 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.