context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE subscriber_regions (subscriber_id INT, technology VARCHAR(20), region VARCHAR(20)); INSERT INTO subscriber_regions (subscriber_id, technology, region) VALUES (1, '4G', 'North'), (2, '5G', 'South'), (3, '3G', 'East'), (4, 'Fiber', 'North'), (5, 'Cable', 'South'), (6, 'DSL', 'East');
|
Show the top 3 regions with the highest mobile and broadband subscriber count for each technology.
|
SELECT technology, region, COUNT(*) as total FROM subscriber_regions GROUP BY technology, region ORDER BY technology, total DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo_details (id INT, vessel_name VARCHAR(50), cargo_type VARCHAR(50), quantity INT); INSERT INTO cargo_details (id, vessel_name, cargo_type, quantity) VALUES (1, 'Atlantic Crusader', 'Container', 7000), (2, 'Atlantic Crusader', 'Bulk', 8000);
|
What is the total cargo handled by vessel 'Atlantic Crusader'?
|
SELECT SUM(quantity) FROM cargo_details WHERE vessel_name = 'Atlantic Crusader';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE courses (course_id INT, province VARCHAR(50), enrolled_students INT); INSERT INTO courses (course_id, province, enrolled_students) VALUES (1, 'Ontario', 50), (2, 'Quebec', 30), (3, 'British Columbia', 20);
|
What is the number of students enrolled in open pedagogy courses per province in Canada?
|
SELECT c.province, COUNT(c.course_id) as num_courses FROM courses c GROUP BY c.province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ocean_Volumes (ocean TEXT, volume_cubic_km FLOAT); INSERT INTO Ocean_Volumes (ocean, volume_cubic_km) VALUES ('Indian Ocean', 292140000), ('Atlantic Ocean', 329610000);
|
What is the water volume of the Indian Ocean compared to the Atlantic Ocean?
|
SELECT (SELECT volume_cubic_km FROM Ocean_Volumes WHERE ocean = 'Indian Ocean') / (SELECT volume_cubic_km FROM Ocean_Volumes WHERE ocean = 'Atlantic Ocean') AS ratio;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE work_injuries (injury_date DATE, mine_id INT, injury_type TEXT); INSERT INTO work_injuries (injury_date, mine_id, injury_type) VALUES ('2021-01-15', 1, 'Fracture'), ('2021-02-03', 1, 'Burn'), ('2021-03-12', 2, 'Electrocution'), ('2021-04-20', 3, 'Fracture'), ('2021-05-05', 1, 'Burn'), ('2021-06-18', 2, 'Electrocution'), ('2021-07-02', 3, 'Fracture'), ('2021-08-16', 1, 'Burn'), ('2021-09-01', 2, 'Electrocution'), ('2021-10-14', 3, 'Fracture'), ('2021-11-29', 1, 'Burn'), ('2021-12-15', 2, 'Electrocution'), ('2021-01-05', 4, 'Fracture');
|
What is the number of work-related injuries reported per month by type?
|
SELECT EXTRACT(MONTH FROM injury_date) AS month, injury_type, COUNT(*) AS injuries_count FROM work_injuries GROUP BY month, injury_type ORDER BY month, injury_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Country (Code TEXT, Name TEXT, Continent TEXT); INSERT INTO Country (Code, Name, Continent) VALUES ('CN', 'China', 'Asia'), ('AU', 'Australia', 'Australia'), ('KR', 'South Korea', 'Asia'), ('IN', 'India', 'Asia'); CREATE TABLE ProductionYearly (Year INT, Country TEXT, Element TEXT, Quantity INT); INSERT INTO ProductionYearly (Year, Country, Element, Quantity) VALUES (2019, 'CN', 'Europium', 1000), (2019, 'AU', 'Europium', 800), (2019, 'KR', 'Europium', 700), (2020, 'CN', 'Europium', 1100), (2020, 'AU', 'Europium', 850), (2020, 'KR', 'Europium', 750);
|
Find the difference in total production of Europium between 2019 and 2020 for countries that produced more Europium in 2020 than in 2019.
|
SELECT a.Country, b.Quantity - a.Quantity AS Difference FROM ProductionYearly a JOIN ProductionYearly b ON a.Country = b.Country WHERE a.Element = 'Europium' AND b.Element = 'Europium' AND a.Year = 2019 AND b.Year = 2020 AND b.Quantity > a.Quantity AND a.Country IN (SELECT Name FROM Country WHERE Continent = 'Asia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sites (id INT, site_name VARCHAR(50), location VARCHAR(50), period VARCHAR(50), type VARCHAR(50)); INSERT INTO Sites (id, site_name, location, period, type) VALUES (1, 'Site1', 'Location1', 'Period1', 'Settlement'), (2, 'Site2', 'Location2', 'Period5', 'Village'); CREATE TABLE Reports (id INT, site_name VARCHAR(50), date DATE, type VARCHAR(50), views INT); INSERT INTO Reports (id, site_name, date, type, views) VALUES (1, 'Site1', '2021-01-01', 'Excavation', 1000), (2, 'Site2', '2021-02-01', 'Survey', 800);
|
What is the maximum number of views for a report on a site from Period5, and the type of report with that view count?
|
SELECT r.type, r.views FROM Reports r JOIN Sites s ON r.site_name = s.site_name WHERE s.period = 'Period5' AND r.views = (SELECT MAX(views) FROM Reports WHERE site_name IN (SELECT site_name FROM Sites WHERE period = 'Period5'));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE industry_4_0 (id INT PRIMARY KEY, initiative_name VARCHAR(100), implementation_date DATE);
|
Insert new records into the 'industry_4_0' table with the following data: (1, 'Automated Production Line', '2022-05-01')
|
INSERT INTO industry_4_0 (id, initiative_name, implementation_date) VALUES (1, 'Automated Production Line', '2022-05-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gulf_wells (well_name TEXT, region TEXT, production_quantity INT); INSERT INTO gulf_wells (well_name, region, production_quantity) VALUES ('Well A', 'gulf', 4000), ('Well B', 'gulf', 5000), ('Well C', 'gulf', 6000);
|
What is the total production quantity for wells in the 'gulf' region?
|
SELECT SUM(production_quantity) FROM gulf_wells WHERE region = 'gulf';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Organization (OrgID INT, Name VARCHAR(255)); CREATE TABLE Donation (DonID INT, OrgID INT, Amount DECIMAL(10, 2)); INSERT INTO Organization VALUES (1, 'Greenpeace'), (2, 'Red Cross'), (3, 'Wildlife Fund'); INSERT INTO Donation VALUES (1, 1, 50.00), (2, 1, 150.00), (3, 2, 75.00), (4, 3, 120.00);
|
Which organizations have received donations greater than $100?
|
SELECT OrgID, Name FROM Organization o WHERE EXISTS (SELECT * FROM Donation d WHERE d.OrgID = o.OrgID AND d.Amount > 100);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscriber_data (subscriber_id INT, subscriber_type VARCHAR(20), country VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id, subscriber_type, country) VALUES (1, 'Regular', 'USA'), (2, 'Test', 'Canada'), (3, 'Regular', 'Mexico');
|
Display the total number of subscribers in each country, excluding subscribers with a 'test' account type
|
SELECT country, COUNT(*) as total_subscribers FROM subscriber_data WHERE subscriber_type != 'Test' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(50), city VARCHAR(50)); INSERT INTO Artists (artist_id, artist_name, city) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'Los Angeles'), (3, 'John Doe', 'Los Angeles');
|
Find artists who have performed in both New York and Los Angeles.
|
SELECT artist_name FROM Artists WHERE city IN ('New York', 'Los Angeles') GROUP BY artist_name HAVING COUNT(DISTINCT city) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (ssn VARCHAR(11), first_name VARCHAR(20), last_name VARCHAR(20), job_title VARCHAR(30));
|
Delete the record for the veteran with the SSN 123-45-6789 from the employees table.
|
DELETE FROM employees WHERE ssn = '123-45-6789';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gulf_of_mexico_drilling_rigs (id INT, name VARCHAR(50), operator VARCHAR(50), location VARCHAR(50)); INSERT INTO gulf_of_mexico_drilling_rigs VALUES (1, 'Rig A', 'Company X', 'Gulf of Mexico'); INSERT INTO gulf_of_mexico_drilling_rigs VALUES (2, 'Rig B', 'Company Y', 'Gulf of Mexico'); INSERT INTO gulf_of_mexico_drilling_rigs VALUES (3, 'Rig C', 'Company X', 'Gulf of Mexico'); INSERT INTO gulf_of_mexico_drilling_rigs VALUES (4, 'Rig D', 'Company Z', 'Gulf of Mexico'); INSERT INTO gulf_of_mexico_drilling_rigs VALUES (5, 'Rig E', 'Company Y', 'Gulf of Mexico');
|
Which companies own the most number of drilling rigs located in the Gulf of Mexico region?
|
SELECT operator, COUNT(*) AS num_of_rigs FROM gulf_of_mexico_drilling_rigs WHERE location = 'Gulf of Mexico' GROUP BY operator ORDER BY num_of_rigs DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo (cargo_id INT, vessel_id INT, destination VARCHAR(50), delivery_date DATE);
|
Create a view named "cargo_summary" that displays the average delivery time for cargo to each destination.
|
CREATE VIEW cargo_summary AS SELECT destination, AVG(DATEDIFF(delivery_date, GETDATE())) AS avg_delivery_time FROM cargo GROUP BY destination;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.captains (id INT PRIMARY KEY, name VARCHAR(100));CREATE TABLE if not exists ocean_shipping.trips (id INT PRIMARY KEY, captain_id INT, port VARCHAR(100));INSERT INTO ocean_shipping.captains (id, name) VALUES (1, 'Captain A'), (2, 'Captain B'), (3, 'Captain C');INSERT INTO ocean_shipping.trips (id, captain_id, port) VALUES (1, 1, 'Port of Singapore'), (2, 2, 'Port of Singapore'), (3, 1, 'Port of Oakland'), (4, 3, 'Port of Oakland');
|
How many trips have been made to the Port of Singapore by each captain?
|
SELECT captains.name, COUNT(trips.id) FROM ocean_shipping.captains LEFT JOIN ocean_shipping.trips ON captains.id = trips.captain_id WHERE trips.port = 'Port of Singapore' GROUP BY captains.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE electric_vehicles (id INT, name VARCHAR(50), safety_rating FLOAT); CREATE TABLE vehicles (id INT, type VARCHAR(50)); INSERT INTO electric_vehicles VALUES (1, 'Tesla Model 3', 5.2); INSERT INTO vehicles VALUES (1, 'electric');
|
What is the average safety rating for electric vehicles in the 'automotive' schema?
|
SELECT AVG(safety_rating) FROM electric_vehicles INNER JOIN vehicles ON electric_vehicles.id = vehicles.id WHERE vehicles.type = 'electric';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy_projects (project_id INT, project_name TEXT, location TEXT, funded_year INT, funding_amount FLOAT); INSERT INTO renewable_energy_projects (project_id, project_name, location, funded_year, funding_amount) VALUES (1, 'Solar Farm 1', 'Egypt', 2015, 5000000.0), (2, 'Wind Farm 1', 'Morocco', 2013, 7000000.0), (3, 'Hydro Plant 1', 'South Africa', 2012, 9000000.0);
|
What is the total amount of climate finance committed to renewable energy projects in Africa since 2010?
|
SELECT SUM(funding_amount) FROM renewable_energy_projects WHERE funded_year >= 2010 AND location LIKE 'Africa%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policy (PolicyNumber INT, PolicyholderName VARCHAR(50)); CREATE TABLE Claim (ClaimID INT, PolicyNumber INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Policy VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO Claim VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 7000), (4, 2, 8000), (5, 2, 9000);
|
Find the policy number, policyholder name, and claim amount for the top 5 claims in descending order by claim amount.
|
SELECT PolicyNumber, PolicyholderName, ClaimAmount FROM (SELECT PolicyNumber, PolicyholderName, ClaimAmount, ROW_NUMBER() OVER (ORDER BY ClaimAmount DESC) as rn FROM Policy JOIN Claim ON Policy.PolicyNumber = Claim.PolicyNumber) x WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT); CREATE TABLE professional_development_courses (course_id INT, course_name TEXT, year INT, teacher_id INT); INSERT INTO teachers (teacher_id, teacher_name) VALUES (1, 'Jane Smith'); INSERT INTO professional_development_courses (course_id, course_name, year, teacher_id) VALUES (101, 'Python for Educators', 2021, 1), (102, 'Data Visualization', 2020, 1);
|
Which professional development courses did teacher Jane Smith attend in 2021?
|
SELECT pdc.course_name FROM professional_development_courses pdc INNER JOIN teachers t ON pdc.teacher_id = t.teacher_id WHERE t.teacher_name = 'Jane Smith' AND pdc.year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE high_speed_rail_routes (id INT PRIMARY KEY, route_name VARCHAR(255), departure_city VARCHAR(255), destination_city VARCHAR(255), distance INT, avg_speed INT);
|
Delete the existing high-speed train route from Rome to Milan
|
DELETE FROM high_speed_rail_routes WHERE route_name = 'Rome-Milan Express';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shelters (shelter_id INT, shelter_name VARCHAR(30), region_id INT); INSERT INTO shelters (shelter_id, shelter_name, region_id) VALUES (1, 'Emergency Shelter 1', 3), (2, 'Temporary Home', 3), (3, 'Relief House', 1), (4, 'New Shelter Name', 4), (5, 'Casa de Ayuda', 4);
|
What is the name of the shelter with ID '1'?
|
SELECT shelter_name FROM shelters WHERE shelter_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255), credit_score INT, last_purchase_date DATE); INSERT INTO customers (id, name, credit_score, last_purchase_date) VALUES (1, 'Jane Smith', 750, '2022-04-15'), (2, 'Bob Johnson', 680, '2022-03-20');
|
List all customers with a credit score above 700 who have made a purchase in the last month.
|
SELECT * FROM customers WHERE credit_score > 700 AND last_purchase_date BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_monitoring_stations (id INT, station_name VARCHAR(255), country VARCHAR(255)); INSERT INTO climate_monitoring_stations (id, station_name, country) VALUES (1, 'Station A', 'canada'), (2, 'Station B', 'greenland'), (3, 'Station C', 'canada'), (4, 'Station D', 'norway');
|
Which climate monitoring stations are located in the same country as 'Station A'?
|
SELECT station_name FROM climate_monitoring_stations WHERE country = (SELECT country FROM climate_monitoring_stations WHERE station_name = 'Station A');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'Biology'), (2, 'Mathematics'), (3, 'Sociology'); CREATE TABLE faculty (id INT, name VARCHAR(255), department_id INT, gender VARCHAR(10)); INSERT INTO faculty (id, name, department_id, gender) VALUES (1, 'Alice', 1, 'Female'), (2, 'Bob', 2, 'Male'), (3, 'Charlie', 3, 'Non-binary'), (4, 'Dave', 1, 'Male'), (5, 'Eve', 3, 'Female');
|
What is the percentage of female and non-binary faculty in each department?
|
SELECT d.name, g.gender, COUNT(f.id) * 100.0 / SUM(COUNT(f.id)) OVER (PARTITION BY d.name) FROM faculty f JOIN departments d ON f.department_id = d.id JOIN (VALUES ('Female'), ('Non-binary')) AS g(gender) ON f.gender = g.gender GROUP BY d.name, g.gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Country VARCHAR(50), HireDate DATE);
|
What is the total number of employees hired from South America in the year 2020, sorted by their hire date?
|
SELECT COUNT(*) FROM Employees WHERE Country IN ('South America') AND YEAR(HireDate) = 2020 ORDER BY HireDate;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_scores (game_id INT, home_team VARCHAR(50), away_team VARCHAR(50), home_score INT, away_score INT); INSERT INTO nba_scores (game_id, home_team, away_team, home_score, away_score) VALUES (1, 'Detroit Pistons', 'Denver Nuggets', 186, 184);
|
What is the highest-scoring NBA game in history and which teams were involved?
|
SELECT home_team, away_team, home_score, away_score FROM nba_scores WHERE home_score + away_score = (SELECT MAX(home_score + away_score) FROM nba_scores);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_categories (menu_category VARCHAR(255), vegetarian BOOLEAN); INSERT INTO menu_categories (menu_category, vegetarian) VALUES ('Appetizers', FALSE), ('Entrees', FALSE), ('Desserts', TRUE); CREATE TABLE menu_items_ext (item_name VARCHAR(255), menu_category VARCHAR(255), vegetarian BOOLEAN); INSERT INTO menu_items_ext (item_name, menu_category, vegetarian) VALUES ('Chicken Strips', 'Appetizers', FALSE), ('Garden Salad', 'Appetizers', TRUE), ('Veggie Burger', 'Entrees', TRUE), ('Steak', 'Entrees', FALSE), ('Ice Cream', 'Desserts', TRUE), ('Chocolate Mousse', 'Desserts', FALSE);
|
What is the number of vegetarian and non-vegetarian menu items in each menu category?
|
SELECT menu_category, SUM(CASE WHEN vegetarian THEN 1 ELSE 0 END) AS vegetarian_items, SUM(CASE WHEN NOT vegetarian THEN 1 ELSE 0 END) AS non_vegetarian_items FROM menu_items_ext GROUP BY menu_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.hospitals (id SERIAL PRIMARY KEY, name TEXT, location TEXT, num_beds INTEGER); INSERT INTO public.hospitals (name, location, num_beds) VALUES ('General Hospital', 'San Francisco', 500), ('Children''s Hospital', 'Oakland', 300); CREATE TABLE public.clinics (id SERIAL PRIMARY KEY, name TEXT, location TEXT); INSERT INTO public.clinics (name, location) VALUES ('Community Clinic', 'San Francisco'), ('Wellness Clinic', 'Berkeley');
|
What is the total number of hospitals and clinics in the San Francisco Bay Area?
|
SELECT COUNT(*) FROM public.hospitals UNION ALL SELECT COUNT(*) FROM public.clinics;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (id INT, project_name VARCHAR(255), city VARCHAR(255), start_date DATE);
|
Identify the top 5 cities globally with the highest number of renewable energy projects in the past year.
|
SELECT city, COUNT(*) AS project_count FROM renewable_projects WHERE start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY city ORDER BY project_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.technologies(id INT, name TEXT, location TEXT, funding DECIMAL(10,2), type TEXT);INSERT INTO biosensors.technologies (id, name, location, funding, type) VALUES (1, 'BioSensorA', 'Germany', 1200000.00, 'Optical'), (2, 'BioSensorB', 'UK', 1500000.00, 'Electrochemical'), (3, 'BioSensorC', 'USA', 900000.00, 'Optical');
|
How many biosensor technologies are there in the UK?
|
SELECT COUNT(*) FROM biosensors.technologies WHERE location = 'UK';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE intel_operations (id INT, country VARCHAR(255), year INT, operations_count INT); INSERT INTO intel_operations (id, country, year, operations_count) VALUES (1, 'Russia', 2017, 500), (2, 'Russia', 2018, 600), (3, 'Russia', 2019, 700), (4, 'Russia', 2020, 800);
|
What is the average number of intelligence operations conducted by the Russian government per year?
|
SELECT AVG(operations_count) FROM intel_operations WHERE country = 'Russia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityDevelopment (id INT, country VARCHAR(20), quarter INT, score FLOAT); INSERT INTO CommunityDevelopment (id, country, quarter, score) VALUES (1, 'Iran', 4, 85.5), (2, 'Saudi Arabia', 3, 82.3), (3, 'Turkey', 2, 78.7), (4, 'United Arab Emirates', 1, 88.2), (5, 'Israel', 4, 90.1);
|
What was the average community development score for Middle Eastern countries in Q4 2021?
|
SELECT AVG(score) FROM CommunityDevelopment WHERE country IN ('Iran', 'Saudi Arabia', 'Turkey', 'United Arab Emirates', 'Israel') AND quarter = 4;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifacts (ArtifactID INT, SiteID INT, ArtifactType TEXT, Date DATE); INSERT INTO Artifacts (ArtifactID, SiteID, ArtifactType, Date) VALUES (1, 3, 'Pottery', '1950-01-01'), (2, 3, 'Bronze Sword', '1950-01-02'), (3, 1, 'Glassware', '1900-01-01');
|
Which artifacts were found at 'Gournay-sur-Aronde'? Provide their IDs, types, and dates.
|
SELECT ArtifactID, ArtifactType, Date FROM Artifacts WHERE SiteID = (SELECT SiteID FROM ExcavationSites WHERE SiteName = 'Gournay-sur-Aronde');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, name VARCHAR(100), location VARCHAR(50), carbon_offset FLOAT); INSERT INTO green_buildings (id, name, location, carbon_offset) VALUES (1, 'Green Building A', 'Greater Toronto Area', 500.3); INSERT INTO green_buildings (id, name, location, carbon_offset) VALUES (2, 'Green Building B', 'New York', 400.2);
|
Determine the average carbon offsetting (in metric tons) of green building projects in the 'Greater Toronto Area'
|
SELECT AVG(carbon_offset) FROM green_buildings WHERE location = 'Greater Toronto Area';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfills_mexico(location VARCHAR(50), capacity INT); INSERT INTO landfills_mexico(location, capacity) VALUES ('Mexico City', 120000), ('Mexico City', 150000), ('Mexico City', 100000), ('Guadalajara', 130000), ('Guadalajara', 140000), ('Guadalajara', 110000);
|
What is the maximum landfill capacity in tons for landfills in Mexico City?
|
SELECT MAX(capacity) FROM landfills_mexico WHERE location = 'Mexico City';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT, sustainability_rating INT);
|
Update the sustainability_rating of hotel with hotel_id 1 to 5.
|
UPDATE hotels SET sustainability_rating = 5 WHERE hotel_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE streams (song_id INT, stream_date DATE, genre VARCHAR(20), country VARCHAR(20), revenue DECIMAL(10,2));
|
Insert a record of a new Reggae music stream in Jamaica on April 10, 2021 with revenue of 1.50.
|
INSERT INTO streams (song_id, stream_date, genre, country, revenue) VALUES (15, '2021-04-10', 'Reggae', 'Jamaica', 1.50);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biotech_startups (id INT, name TEXT, region TEXT, budget FLOAT); INSERT INTO biotech_startups (id, name, region, budget) VALUES (1, 'StartupA', 'East Coast', 5000000), (2, 'StartupB', 'West Coast', 7000000), (3, 'StartupC', 'East Coast', 3000000);
|
What is the total funding for biotech startups in the 'east_coast' region?
|
SELECT SUM(budget) FROM biotech_startups WHERE region = 'East Coast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PollutionIncidents (IncidentID INT, Country VARCHAR(50), PollutionLevel INT); INSERT INTO PollutionIncidents (IncidentID, Country, PollutionLevel) VALUES (1, 'US', 5), (2, 'Canada', 7), (3, 'Mexico', 6), (4, 'Brazil', 8), (5, 'Argentina', 4);
|
What are the top 3 countries with the most pollution incidents in the 'PollutionIncidents' table?
|
SELECT Country, PollutionLevel FROM PollutionIncidents ORDER BY PollutionLevel DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name TEXT); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'UK'), (4, 'Australia'); CREATE TABLE conferences (id INT, country_id INT, name TEXT, topic TEXT); INSERT INTO conferences (id, country_id, name, topic) VALUES (1, 1, 'Conf1', 'AI Safety'), (2, 1, 'Conf2', 'AI Safety'), (3, 3, 'Conf3', 'AI Safety'), (4, 4, 'Conf4', 'AI Safety');
|
List all countries and the number of AI safety conferences held there.
|
SELECT countries.name, COUNT(conferences.id) as conferences_count FROM countries LEFT JOIN conferences ON countries.id = conferences.country_id AND conferences.topic = 'AI Safety' GROUP BY countries.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerSessions (SessionID int, PlayerID int, GameID int, Playtime int); INSERT INTO PlayerSessions (SessionID, PlayerID, GameID, Playtime) VALUES (1, 1, 1, 60), (2, 1, 1, 90), (3, 2, 1, 75), (4, 2, 2, 120), (5, 3, 2, 100), (6, 3, 3, 80);
|
What is the total playtime for each player?
|
SELECT P.PlayerName, SUM(PS.Playtime) as TotalPlaytime FROM Players P JOIN PlayerSessions PS ON P.PlayerID = PS.PlayerID GROUP BY P.PlayerName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, country VARCHAR(50), raw_material VARCHAR(50)); CREATE VIEW country_products AS SELECT country, raw_material FROM products GROUP BY country;
|
What is the number of unique materials used in the production of products in each country?
|
SELECT country, COUNT(DISTINCT raw_material) FROM country_products GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LanguagePreservation (id INT, program VARCHAR(255), region VARCHAR(255), funding FLOAT); INSERT INTO LanguagePreservation (id, program, region, funding) VALUES (1, 'Language Immersion', 'North America', 30000), (2, 'Bilingual Education', 'Europe', 25000), (3, 'Community Workshops', 'Asia', 22000);
|
What is the average funding per language preservation program by region?
|
SELECT region, AVG(funding) FROM LanguagePreservation GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE topics (id INT, title TEXT, continent TEXT);
|
What is the distribution of AI creativity research topics by continent?
|
SELECT continent, COUNT(*) as num_topics, ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM topics) , 1) as percentage FROM topics GROUP BY continent ORDER BY percentage DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Expeditions (ExpeditionID INT, Society VARCHAR(25), Depth INT); INSERT INTO Expeditions (ExpeditionID, Society, Depth) VALUES (1, 'Undersea Exploration Society', 3000), (2, 'Oceanic Research Foundation', 4000), (3, 'Marine Discovery Institute', 5000);
|
Delete expeditions led by the 'Marine Discovery Institute' with a depth greater than 4500 meters.
|
DELETE FROM Expeditions WHERE Society = 'Marine Discovery Institute' AND Depth > 4500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT PRIMARY KEY, product_id INT, date DATE, revenue FLOAT, FOREIGN KEY (product_id) REFERENCES products(id)); INSERT INTO sales (id, product_id, date, revenue) VALUES (3, 3, '2022-05-05', 500.00); CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (id, name, category) VALUES (4, 'Eco Denim Jacket', 'Clothing');
|
What is the total revenue for each product category in the past week, sorted by revenue in descending order?
|
SELECT p.category, SUM(s.revenue) AS total_revenue FROM sales s JOIN products p ON s.product_id = p.id WHERE s.date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND CURDATE() GROUP BY p.category ORDER BY total_revenue DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Contracts (id INT, contract_number VARCHAR(50), contract_date DATE, contract_value FLOAT, contract_type VARCHAR(50));
|
Count the number of defense contracts awarded in the last 6 months.
|
SELECT COUNT(*) FROM Contracts WHERE contract_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND contract_type = 'Defense';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE box_office (movie_id INT, title VARCHAR(100), release_year INT, collection INT, production_company VARCHAR(50)); INSERT INTO box_office (movie_id, title, release_year, collection, production_company) VALUES (1, 'PK', 2014, 800000000, 'UTV Motion Pictures'), (2, 'Dangal', 2016, 1000000000, 'Walt Disney Pictures');
|
Find the annual growth rate in box office collections for Bollywood movies since 2010.
|
SELECT production_company, AVG(collection) as avg_annual_collection, (EXP(AVG(LOG(collection + 1))) - 1) * 100.0 AS annual_growth_rate FROM box_office WHERE production_company LIKE '%Bollywood%' GROUP BY production_company;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Company (id INT, name TEXT, industry TEXT, founding_date DATE); INSERT INTO Company (id, name, industry, founding_date) VALUES (1, 'Acme Inc', 'Tech', '2016-01-02'); INSERT INTO Company (id, name, industry, founding_date) VALUES (2, 'Wright Startups', 'Transport', '2015-05-15'); INSERT INTO Company (id, name, industry, founding_date) VALUES (3, 'Bella Innovations', 'FashionTech', '2018-09-09'); CREATE TABLE Funding (id INT, company_id INT, amount INT, funding_date DATE); INSERT INTO Funding (id, company_id, amount, funding_date) VALUES (1, 1, 5000000, '2021-03-20'); INSERT INTO Funding (id, company_id, amount, funding_date) VALUES (2, 2, 7000000, '2020-08-05'); INSERT INTO Funding (id, company_id, amount, funding_date) VALUES (3, 3, 9000000, '2019-01-10');
|
Which companies have received funding since 2020 and their respective industry?
|
SELECT Company.name, Company.industry, Funding.funding_date FROM Company INNER JOIN Funding ON Company.id = Funding.company_id WHERE Funding.funding_date > '2019-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (city varchar(50), year int, route varchar(50), budget int); INSERT INTO routes (city, year, route, budget) VALUES ('Philadelphia', 2024, 'Route 1', 5000000), ('Philadelphia', 2024, 'Route 2', 4000000), ('Philadelphia', 2024, 'Route 3', 3000000), ('Philadelphia', 2024, 'Route 4', 2000000);
|
List all public transportation routes in the city of Philadelphia and their respective budgets for 2024, ordered by budget amount in descending order.
|
SELECT route, budget FROM routes WHERE city = 'Philadelphia' AND year = 2024 ORDER BY budget DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessel_safety (id INT, vessel_id INT, record_date DATE);
|
List all the vessels that have a safety record between 5 and 10 years old.
|
SELECT v.name FROM vessel_safety vs JOIN vessel v ON vs.vessel_id = v.id WHERE vs.record_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) AND DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmIrrigation (farm_type VARCHAR(10), irrigation_type VARCHAR(20), rainfall FLOAT); INSERT INTO FarmIrrigation (farm_type, irrigation_type, rainfall) VALUES ('Farm A', 'Drip Irrigation', 45.2), ('Farm A', 'Drip Irrigation', 46.1), ('Farm A', 'Flood Irrigation', 50.5), ('Farm A', 'Flood Irrigation', 51.0), ('Farm B', 'Drip Irrigation', 48.7), ('Farm B', 'Drip Irrigation', 49.3), ('Farm B', 'Flood Irrigation', 54.1), ('Farm B', 'Flood Irrigation', 55.0);
|
Find the difference in average rainfall between farms with drip irrigation and flood irrigation systems.
|
SELECT farm_type, AVG(CASE WHEN irrigation_type = 'Drip Irrigation' THEN rainfall ELSE NULL END) - AVG(CASE WHEN irrigation_type = 'Flood Irrigation' THEN rainfall ELSE NULL END) as rainfall_diff FROM FarmIrrigation GROUP BY farm_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE outbreaks (id INT, year INT, type VARCHAR, location VARCHAR, cases INT);
|
Determine the number of infectious disease outbreaks, by type and year.
|
SELECT o.type, o.year, COUNT(o.id) AS num_outbreaks FROM outbreaks o GROUP BY o.type, o.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InclusiveHousing (area TEXT, num_units INT, wheelchair_accessible BOOLEAN, pets_allowed BOOLEAN); INSERT INTO InclusiveHousing (area, num_units, wheelchair_accessible, pets_allowed) VALUES ('Eastside', 10, TRUE, FALSE), ('Westside', 15, TRUE, TRUE), ('Downtown', 25, TRUE, TRUE);
|
Delete the record for the Downtown area from the InclusiveHousing table.
|
DELETE FROM InclusiveHousing WHERE area = 'Downtown';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), location VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, species, location, conservation_status) VALUES (1, 'Blue Whale', 'Balaenoptera musculus', 'Great Barrier Reef', 'Endangered'); CREATE TABLE expeditions (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO expeditions (id, name, location, year, type) VALUES (1, 'Great Barrier Reef Expedition', 'Great Barrier Reef', 2022, 'Research');
|
What are the names of marine species that have been recorded in the same location as a research expedition?
|
SELECT ms.name FROM marine_species ms INNER JOIN expeditions e ON ms.location = e.location WHERE e.type = 'Research';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE covid_cases (id INT, country VARCHAR(255), case_number INT);
|
Insert a new record into the covid_cases table with a case number of 8008 from the country of Brazil.
|
INSERT INTO covid_cases (id, country, case_number) VALUES (8, 'Brazil', 8008);
|
gretelai_synthetic_text_to_sql
|
species_observations
|
Show the number of observations for each species
|
SELECT species, COUNT(*) as total_observations FROM species_observations GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transportation_Dept (Dept_Name VARCHAR(255), Project_Name VARCHAR(255), Budget INT); INSERT INTO Transportation_Dept VALUES ('Transportation', 'Road Construction', 5000000), ('Transportation', 'Bridge Building', 8000000), ('Transportation', 'Traffic Signal Installation', 2000000);
|
What is the average budget allocated per project in the Transportation department?
|
SELECT AVG(Budget) FROM Transportation_Dept WHERE Dept_Name = 'Transportation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(25), state VARCHAR(20), monthly_cost FLOAT); CREATE TABLE broadband_plans (plan_id INT, plan_name VARCHAR(25), state VARCHAR(20), monthly_cost FLOAT); INSERT INTO mobile_plans (plan_id, plan_name, state, monthly_cost) VALUES (1, 'Basic', 'Florida', 30), (2, 'Premium', 'Florida', 60); INSERT INTO broadband_plans (plan_id, plan_name, state, monthly_cost) VALUES (1, 'Basic', 'Florida', 40), (2, 'Premium', 'Florida', 80);
|
What is the average monthly cost of mobile and broadband services offered by the telecom company in the state of Florida?
|
SELECT AVG(mobile_plans.monthly_cost + broadband_plans.monthly_cost) FROM mobile_plans, broadband_plans WHERE mobile_plans.state = 'Florida' AND broadband_plans.state = 'Florida' AND mobile_plans.plan_id = broadband_plans.plan_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tickets (id INT, salesperson_id INT, quantity INT, city VARCHAR(50), price DECIMAL(5,2)); INSERT INTO tickets (id, salesperson_id, quantity, city, price) VALUES (1, 1, 50, 'New York', 100.00), (2, 1, 75, 'New York', 100.00), (3, 2, 30, 'Los Angeles', 75.00), (4, 2, 40, 'Los Angeles', 75.00), (5, 3, 25, 'Chicago', 50.00);
|
Calculate the average ticket price for each city.
|
SELECT city, AVG(price) as avg_price FROM tickets GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentSales (garment_id INT, category VARCHAR(50), year INT, revenue DECIMAL(10,2)); INSERT INTO GarmentSales (garment_id, category, year, revenue) VALUES (1, 'Tops', 2020, 5000.00), (2, 'Bottoms', 2020, 6000.00), (3, 'Tops', 2020, 4000.00);
|
Find the garment with the highest revenue for each category and year.
|
SELECT garment_id, category, year, MAX(revenue) AS max_revenue FROM GarmentSales GROUP BY category, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, first_name VARCHAR(20), last_name VARCHAR(20), ethnicity VARCHAR(20)); INSERT INTO clients (client_id, first_name, last_name, ethnicity) VALUES (1, 'John', 'Doe', 'Caucasian'); INSERT INTO clients (client_id, first_name, last_name, ethnicity) VALUES (2, 'Jane', 'Smith', 'Native American'); INSERT INTO clients (client_id, first_name, last_name, ethnicity) VALUES (3, 'Maria', 'Garcia', 'Hispanic');
|
What are the case outcomes for all clients who identify as Native American or Alaska Native?
|
SELECT case_outcome FROM cases INNER JOIN clients ON cases.client_id = clients.client_id WHERE clients.ethnicity IN ('Native American', 'Alaska Native');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (department_id INT, department_name TEXT); CREATE TABLE financials (financial_id INT, department_id INT, financial_date DATE, financial_amount FLOAT); INSERT INTO financials (financial_id, department_id, financial_date, financial_amount) VALUES (1, 1, '2023-07-01', 6000.00), (2, 1, '2023-09-15', 4000.00), (3, 2, '2023-08-30', 9000.00);
|
What is the total financial contribution by each department for Q3 2023?
|
SELECT department_name, SUM(financial_amount) as total_financial_contribution FROM financials f JOIN departments d ON f.department_id = d.department_id WHERE financial_date BETWEEN '2023-07-01' AND '2023-09-30' GROUP BY department_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trawlers (id INT, name VARCHAR(50)); CREATE TABLE catch (trawler_id INT, date DATE, species VARCHAR(50), quantity INT, price FLOAT); INSERT INTO trawlers VALUES (1, 'South Pacific Trawler 1'), (2, 'South Pacific Trawler 2'), (3, 'South Pacific Trawler 3'); INSERT INTO catch VALUES (1, '2020-01-01', 'Tuna', 1300, 5.5), (1, '2020-01-02', 'Marlin', 1100, 4.2), (2, '2020-01-01', 'Swordfish', 1600, 3.8);
|
List the number of fish caught and total revenue for each trawler in the South Pacific during 2020.
|
SELECT t.name, COUNT(c.trawler_id) as catches, SUM(c.quantity * c.price) as revenue FROM trawlers t INNER JOIN catch c ON t.id = c.trawler_id WHERE YEAR(c.date) = 2020 AND t.name LIKE '%South Pacific%' GROUP BY t.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hockey (team VARCHAR(50), location VARCHAR(5), points INT);
|
What is the difference in total points scored between the home and away games, for each team in the hockey table?
|
SELECT team, SUM(CASE WHEN location = 'home' THEN points ELSE 0 END) - SUM(CASE WHEN location = 'away' THEN points ELSE 0 END) AS points_diff FROM hockey GROUP BY team;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT PRIMARY KEY, donation_amount DECIMAL(10, 2), donation_date DATE, first_donation_date DATE); INSERT INTO donors (donor_id, donation_amount, donation_date, first_donation_date) VALUES (1, 250, '2020-01-01', '2019-01-01'), (2, 750, '2020-01-03', '2018-01-01'), (3, 900, '2020-02-05', '2020-01-01');
|
What is the minimum donation amount in the year 2020 from donors who have donated more than once?
|
SELECT MIN(donation_amount) FROM donors WHERE YEAR(donation_date) = 2020 AND donor_id IN (SELECT donor_id FROM donors GROUP BY donor_id HAVING COUNT(*) > 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence (metric_id INT, metric_date DATE, region VARCHAR(255)); INSERT INTO threat_intelligence (metric_id, metric_date, region) VALUES (1, '2021-08-01', 'Middle East'), (2, '2021-06-15', 'Europe'), (3, '2021-02-14', 'Middle East');
|
Count the number of threat intelligence metrics reported in the Middle East in the last 6 months.
|
SELECT COUNT(*) FROM threat_intelligence WHERE region = 'Middle East' AND metric_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id INT, timestamp TIMESTAMP, asset_name VARCHAR(50), asset_type VARCHAR(50), asset_price DECIMAL(18,8), asset_volume DECIMAL(18,8)); INSERT INTO digital_assets VALUES (2, '2022-02-01 10:00:00', 'asset2', 'NFT', 200, 500000);
|
What is the total volume of NFT assets in the last 30 days?
|
SELECT asset_type, SUM(asset_volume) OVER (PARTITION BY asset_type ORDER BY timestamp ROWS BETWEEN 30 PRECEDING AND CURRENT ROW) as total_volume_30d FROM digital_assets WHERE asset_type = 'NFT' ORDER BY timestamp
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales(sale_id INT, equipment_name VARCHAR(50), sale_country VARCHAR(50), sale_price FLOAT); INSERT INTO military_sales VALUES (1, 'Tank', 'India', 5000000), (2, 'Helicopter', 'Canada', 2000000), (3, 'Airplane', 'Mexico', 8000000), (4, 'Radar', 'India', 3000000);
|
What is the total cost of military equipment sales to India?
|
SELECT SUM(sale_price) FROM military_sales WHERE sale_country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name TEXT, dob DATE, branch TEXT);CREATE TABLE accounts (account_id INT, client_id INT, account_type TEXT, balance DECIMAL);INSERT INTO clients VALUES (7, 'William Garcia', '1988-04-05', 'Los Angeles');INSERT INTO accounts VALUES (107, 7, 'Investment', 30000);
|
What is the maximum balance for clients with investment accounts in the Los Angeles branch?
|
SELECT MAX(accounts.balance) FROM clients INNER JOIN accounts ON clients.client_id = accounts.client_id WHERE accounts.account_type = 'Investment' AND clients.branch = 'Los Angeles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (id INT, region VARCHAR(255), well_type VARCHAR(255), production_rate DECIMAL(5,2)); INSERT INTO wells (id, region, well_type, production_rate) VALUES (1, 'North Sea', 'Oil', 100.5), (2, 'North Sea', 'Gas', 75.2), (3, 'Gulf of Mexico', 'Oil', 150.0), (4, 'Gulf of Mexico', 'Gas', 120.5);
|
What is the average production rate of oil wells in the North Sea and Gulf of Mexico?
|
SELECT AVG(production_rate) as avg_oil_production_rate FROM wells WHERE region IN ('North Sea', 'Gulf of Mexico') AND well_type = 'Oil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours_engagement (tour_id INT, city TEXT, views INT, clicks INT, month INT); INSERT INTO virtual_tours_engagement (tour_id, city, views, clicks, month) VALUES (1, 'City A', 1000, 200, 1), (1, 'City A', 1200, 240, 2), (1, 'City A', 1400, 280, 3), (2, 'City B', 1500, 300, 1), (2, 'City B', 1800, 360, 2), (2, 'City B', 2100, 420, 3);
|
What is the virtual tour engagement rate by city and month?
|
SELECT city, month, (SUM(clicks) * 100.0 / SUM(views)) as engagement_rate FROM virtual_tours_engagement GROUP BY city, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Rovers (RoverID INT, Name VARCHAR(50), LaunchDate DATE, Destination VARCHAR(50), Success BOOLEAN); INSERT INTO Rovers VALUES (1, 'Perseverance', '2020-07-30', 'Mars', true); INSERT INTO Rovers VALUES (2, 'Curiosity', '2011-11-26', 'Mars', true); INSERT INTO Rovers VALUES (3, 'Beagle 2', '2003-06-02', 'Mars', false);
|
What is the earliest launch date for a successful Mars rover mission, and which mission was it?
|
SELECT * FROM Rovers WHERE Destination = 'Mars' AND Success = true AND ROW_NUMBER() OVER (ORDER BY LaunchDate ASC) = 1
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE buildings (id INT, name TEXT, region TEXT, co2_emission FLOAT); INSERT INTO buildings (id, name, region, co2_emission) VALUES (1, 'A', 'urban', 1200.0), (2, 'B', 'rural', 800.0);
|
What is the average CO2 emission of buildings in the 'urban' region?
|
SELECT AVG(co2_emission) FROM buildings WHERE region = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (item_id INT, name TEXT, category TEXT, unit_price FLOAT, unit_quantity INT, unit_weight FLOAT, waste_factor FLOAT); INSERT INTO inventory (item_id, name, category, unit_price, unit_quantity, unit_weight, waste_factor) VALUES (1, 'Plastic Spoon', 'Disposable', 0.05, 100, 0.01, 0.02), (2, 'Paper Plate', 'Disposable', 0.10, 50, 0.05, 0.10); CREATE TABLE sales (sale_id INT, item_id INT, sale_quantity INT, sale_date DATE); INSERT INTO sales (sale_id, item_id, sale_quantity, sale_date) VALUES (1, 1, 200, '2022-01-01'), (2, 1, 300, '2022-04-12'), (3, 2, 100, '2022-03-15'), (4, 1, 150, '2022-12-31');
|
What is the total weight of plastic waste generated in a year?
|
SELECT SUM(i.unit_quantity * i.unit_weight * s.sale_quantity * i.waste_factor) as total_waste FROM inventory i JOIN sales s ON i.item_id = s.item_id WHERE i.category = 'Disposable' AND s.sale_date BETWEEN '2022-01-01' AND '2022-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WeatherData (region TEXT, crop TEXT, month INTEGER, temperature REAL); INSERT INTO WeatherData (region, crop, month, temperature) VALUES ('X', 'A', 6, 22.5), ('X', 'A', 7, 25.0), ('Y', 'B', 6, 18.2);
|
Delete the data for crop B in region Y in June.
|
DELETE FROM WeatherData WHERE region = 'Y' AND crop = 'B' AND month = 6;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (SaleID int, ProductID int, ProductName varchar(50), Category varchar(50), SalesNumber int); INSERT INTO Sales (SaleID, ProductID, ProductName, Category, SalesNumber) VALUES (1, 1, 'Eye Shadow A', 'Eye Shadow', 100), (2, 2, 'Eye Shadow B', 'Eye Shadow', 200), (3, 3, 'Lipstick C', 'Lipstick', 300);
|
What is the sum of sales for the 'Eye Shadow' category?
|
SELECT SUM(SalesNumber) as TotalSales FROM Sales WHERE Category = 'Eye Shadow';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contract_negotiations (contractor VARCHAR(255), country VARCHAR(255), negotiation_year INT); INSERT INTO contract_negotiations (contractor, country, negotiation_year) VALUES ('Lockheed Martin', 'Russia', 2019), ('Raytheon', 'Russia', 2019), ('BAE Systems', 'Russia', 2018);
|
What is the total number of contract negotiations with the Russian government by all defense contractors in 2019?
|
SELECT COUNT(*) FROM contract_negotiations WHERE country = 'Russia' AND negotiation_year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museum_artists (artist_id INT, artist_name TEXT, num_solo_exhibitions INT);
|
Which artists have never held a solo exhibition at the museum_artists table?
|
DELETE FROM museum_artists WHERE artist_id IN (SELECT artist_id FROM (SELECT artist_id, MIN(num_solo_exhibitions) AS min_solo FROM museum_artists) WHERE min_solo = 0);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trips (id INT, vehicle_type VARCHAR(20), speed FLOAT, date DATE); INSERT INTO trips (id, vehicle_type, speed, date) VALUES (1, 'ElectricCar', 75.3, '2022-04-01'); INSERT INTO trips (id, vehicle_type, speed, date) VALUES (2, 'ElectricBike', 28.1, '2022-04-02'); INSERT INTO trips (id, vehicle_type, speed, date) VALUES (3, 'ElectricScooter', 42.7, '2022-04-03');
|
What is the average speed of electric vehicles per day for the last 7 days in the 'trips' table?
|
SELECT DATE(date) as trip_date, AVG(speed) as avg_speed FROM trips WHERE vehicle_type LIKE 'Electric%' AND date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() GROUP BY trip_date ORDER BY trip_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, building_name VARCHAR(50), city VARCHAR(50), building_type VARCHAR(50)); INSERT INTO green_buildings (id, building_name, city, building_type) VALUES (1, 'New York Green Tower', 'New York', 'Residential');
|
How many green buildings are there in the city of New York, by type?
|
SELECT building_type, COUNT(*) FROM green_buildings WHERE city = 'New York' GROUP BY building_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tennis (player VARCHAR(255), match_id INT); INSERT INTO tennis (player, match_id) VALUES ('Federer', 1), ('Federer', 2), ('Federer', 3), ('Djokovic', 4), ('Djokovic', 5);
|
How many matches did each player participate in during the 2020 tennis season?
|
SELECT player, COUNT(*) FROM tennis GROUP BY player;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, donor_name VARCHAR(255)); INSERT INTO donors (id, donor_name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); CREATE TABLE causes (id INT, cause_name VARCHAR(255)); INSERT INTO causes (id, cause_name) VALUES (1, 'Poverty Reduction'), (2, 'Disaster Relief'); CREATE TABLE donations (id INT, donor_id INT, cause_id INT, donation_date DATE); INSERT INTO donations (id, donor_id, cause_id, donation_date) VALUES (1, 1, 1, '2021-01-01'), (2, 2, 1, '2021-01-02'), (3, 3, 2, '2021-01-03');
|
How many unique donors supported each cause in Q1 2021?
|
SELECT d.cause_id, COUNT(DISTINCT d.donor_id) as unique_donors FROM donations d WHERE QUARTER(d.donation_date) = 1 AND YEAR(d.donation_date) = 2021 GROUP BY d.cause_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gender (vol_id INT, vol_name VARCHAR(255), gender VARCHAR(10)); INSERT INTO gender (vol_id, vol_name, gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'), (3, 'Mike Johnson', 'Male'), (4, 'Alice Davis', 'Female'), (5, 'Bob Brown', 'Male'), (6, 'Charlie Green', 'Female');
|
Which organizations have more male than female volunteers?
|
SELECT organization.org_name, COUNT(CASE WHEN gender.gender = 'Male' THEN 1 END) as num_male, COUNT(CASE WHEN gender.gender = 'Female' THEN 1 END) as num_female FROM organization JOIN volunteer ON organization.org_id = volunteer.org_id JOIN gender ON volunteer.vol_id = gender.vol_id GROUP BY organization.org_name HAVING num_male > num_female;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE media_creators (id INT, community VARCHAR(50)); INSERT INTO media_creators (id, community) VALUES (1, 'LGBTQ+'), (2, 'Female'), (3, 'Minority'), (4, 'Male'), (5, 'Minority');
|
How many creators in the media_creators table are from underrepresented communities?
|
SELECT COUNT(*) FROM media_creators WHERE community = 'LGBTQ+' OR community = 'Female' OR community = 'Minority';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cases (ID INT, CaseNumber INT, DateOpened DATE, DateClosed DATE); INSERT INTO Cases (ID, CaseNumber, DateOpened, DateClosed) VALUES (1, 12345, '2022-01-01', '2022-03-15'), (2, 67890, '2022-02-15', '2022-04-30'), (3, 111213, '2022-03-28', NULL);
|
What is the percentage change in the number of cases opened and closed in the last 6 months?
|
SELECT (SUM(CASE WHEN DateClosed IS NOT NULL THEN 1 ELSE 0 END) - SUM(CASE WHEN DateOpened IS NOT NULL THEN 1 ELSE 0 END)) * 100.0 / COUNT(*) as PercentageChange FROM Cases WHERE DateOpened >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dams (name TEXT, state TEXT, reservoir_capacity INTEGER); INSERT INTO Dams (name, state, reservoir_capacity) VALUES ('Bonneville Dam', 'Oregon', 750000); INSERT INTO Dams (name, state, reservoir_capacity) VALUES ('Grand Coulee Dam', 'Washington', 5500000);
|
What are the names of all dams and their reservoir capacities in 'Oregon' and 'Washington'?
|
SELECT name, reservoir_capacity FROM Dams WHERE state IN ('Oregon', 'Washington');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_practices (practice_id INT, practice_name VARCHAR(20), implementation_date DATE);INSERT INTO sustainable_practices (practice_id, practice_name, implementation_date) VALUES (1, 'Solar Panels', '2020-01-01');INSERT INTO sustainable_practices (practice_id, practice_name, implementation_date) VALUES (2, 'Green Roofs', '2019-06-15');
|
Which sustainable building practices were implemented in New York and when were they added to the database?
|
SELECT practice_name, implementation_date FROM sustainable_practices WHERE practice_name IN ('Solar Panels', 'Green Roofs') AND location = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255), City varchar(255)); CREATE TABLE Inspections (InspectionID int, RestaurantID int, ViolationCount int, InspectionScore int, InspectionDate date);
|
What is the average food safety inspection score for restaurants in each city, grouped by city and year?'
|
SELECT R.City, YEAR(I.InspectionDate) as Year, AVG(I.InspectionScore) as AverageInspectionScore FROM Restaurants R INNER JOIN Inspections I ON R.RestaurantID = I.RestaurantID GROUP BY R.City, YEAR(I.InspectionDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Trees (id INT, species VARCHAR(255), age INT); INSERT INTO Trees (id, species, age) VALUES (1, 'Oak', 50), (2, 'Pine', 30), (3, 'Maple', 40);
|
What is the maximum biomass of a tree in the Trees table, if each tree has a biomass of 0.022 pounds per year per inch of age?
|
SELECT MAX(age * 0.022) FROM Trees;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, population INT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, population, revenue) VALUES (1, 'Asian Fusion', 'New York', 8500000, 50000.00), (2, 'Bella Italia', 'Los Angeles', 4000000, 60000.00), (3, 'Sushi House', 'New York', 8500000, 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 2700000, 80000.00), (5, 'Taqueria El Sol', 'Los Angeles', 4000000, 40000.00), (6, 'Fish and Chips', 'London', 8700000, 30000.00), (7, 'Brasserie Moderne', 'Paris', 2200000, 45000.00);
|
Compare the average revenue of restaurants in cities with a population greater than 5 million to the average revenue of restaurants in cities with a population less than 1 million.
|
SELECT 'Greater than 5 million' as city, AVG(revenue) as avg_revenue FROM Restaurants WHERE population > 5000000 UNION ALL SELECT 'Less than 1 million', AVG(revenue) FROM Restaurants WHERE population < 1000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (name TEXT, last_update DATE, component_type TEXT, circular_economy BOOLEAN); INSERT INTO suppliers (name, last_update, component_type, circular_economy) VALUES ('Mu Supplies', '2022-03-10', 'Recycled Materials', TRUE), ('Nu Components', '2022-02-05', 'Renewable Energy', FALSE);
|
List the names and component types of suppliers that have been updated in the last month and supply components for circular economy initiatives.
|
SELECT name, component_type FROM suppliers WHERE last_update >= DATE('now', '-1 month') AND circular_economy = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agri_innovation (id INT, country VARCHAR(50), project VARCHAR(50), completion_year INT); INSERT INTO agri_innovation (id, country, project, completion_year) VALUES (1, 'Vietnam', 'GMO Crops', 2018), (2, 'Vietnam', 'Drip Irrigation', 2020), (3, 'Vietnam', 'Solar-Powered Pumps', 2019);
|
Calculate the number of agricultural innovation projects completed in Vietnam between 2018 and 2020.
|
SELECT COUNT(*) FROM agri_innovation WHERE country = 'Vietnam' AND completion_year BETWEEN 2018 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name TEXT, founder_continent TEXT, funding FLOAT); INSERT INTO startups(id, name, founder_continent, funding) VALUES (1, 'StartupA', 'North America', 500000), (2, 'StartupB', 'North America', 750000), (3, 'StartupC', 'North America', 250000), (4, 'StartupD', 'South America', 300000), (5, 'StartupE', 'South America', 150000);
|
What is the total funding received by startups founded by individuals from each continent?
|
SELECT founder_continent, SUM(funding) FROM startups GROUP BY founder_continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WeekdayWorkouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT INTO WeekdayWorkouts (WorkoutID, MemberID, WorkoutDate) VALUES (1, 1, '2021-01-05'), (2, 1, '2021-01-06'), (3, 2, '2021-03-18'), (4, 3, '2021-08-14');
|
Count the number of users who have never participated in a workout during the weekends.
|
SELECT COUNT(DISTINCT Members.MemberID) FROM Members LEFT JOIN WeekdayWorkouts ON Members.MemberID = WeekdayWorkouts.MemberID WHERE WeekdayWorkouts.WorkoutDate IS NULL OR DATEPART(dw, WeekdayWorkouts.WorkoutDate) NOT IN (1, 7);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE se_asian_spending (country VARCHAR(50), year INT, spending FLOAT); INSERT INTO se_asian_spending (country, year, spending) VALUES ('Indonesia', 2020, 8700000000), ('Thailand', 2020, 6600000000), ('Malaysia', 2020, 5200000000), ('Singapore', 2020, 11000000000), ('Vietnam', 2020, 5700000000), ('Philippines', 2020, 3700000000);
|
What was the highest military spending in 2020 by a Southeast Asian country?
|
SELECT MAX(spending) FROM se_asian_spending WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Economic_Diversification (id INT, country VARCHAR(50), year INT, initiative VARCHAR(50)); INSERT INTO Economic_Diversification (id, country, year, initiative) VALUES (1, 'Mexico', 2016, 'Initiated'), (2, 'Mexico', 2017, 'Planned'), (3, 'Brazil', 2018, 'Initiated');
|
How many economic diversification projects were initiated in Mexico in 2016 or 2017?
|
SELECT COUNT(*) FROM Economic_Diversification WHERE country = 'Mexico' AND (year = 2016 OR year = 2017);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorType TEXT, Country TEXT, TotalDonations INT); INSERT INTO Donors (DonorID, DonorName, DonorType, Country, TotalDonations) VALUES (1, 'Bill & Melinda Gates Foundation', 'Organization', 'United States', 5000000), (2, 'Open Society Foundations', 'Organization', 'United States', 4000000), (3, 'Ford Foundation', 'Organization', 'United States', 3000000), (4, 'The William and Flora Hewlett Foundation', 'Organization', 'United States', 2000000);
|
What is the total amount donated by the top 3 donor organizations based in the US?
|
SELECT SUM(TotalDonations) FROM Donors WHERE DonorType = 'Organization' AND Country = 'United States' AND DonorID IN (SELECT DonorID FROM (SELECT DonorID, ROW_NUMBER() OVER (ORDER BY TotalDonations DESC) rn FROM Donors WHERE DonorType = 'Organization' AND Country = 'United States') t WHERE rn <= 3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_check_ins (user_id INT, check_in_id INT);
|
Count the number of users who have never checked in
|
SELECT COUNT(DISTINCT user_id) as num_users FROM user_check_ins WHERE user_id NOT IN (SELECT DISTINCT user_id FROM check_ins);
|
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.