context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE public_transportation (city TEXT, trip_count INT, year INT); INSERT INTO public_transportation (city, trip_count, year) VALUES ('New York', 5000, 2020), ('Los Angeles', 4000, 2020);
What is the total number of public transportation trips taken in each city in 2020?
SELECT city, SUM(trip_count) as total_trips FROM public_transportation WHERE year = 2020 GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, name TEXT, region TEXT); INSERT INTO warehouses (id, name, region) VALUES (1, 'Seattle Warehouse', 'west'), (2, 'Dallas Warehouse', 'south'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, state TEXT); INSERT INTO packages (id, warehouse_id, weight, state) VALUES (1, 1, 15.5, 'Texas'), (2, 1, 20.3, 'California'), (3, 2, 12.8, 'Texas');
What is the average weight of packages shipped to Texas from the 'west' region?
SELECT AVG(weight) FROM packages p JOIN warehouses w ON p.warehouse_id = w.id WHERE w.region = 'west' AND p.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), Country VARCHAR(50), Amount DECIMAL(10,2), DonationYear INT); INSERT INTO Donors (DonorID, DonorName, Country, Amount, DonationYear) VALUES (1, 'John Doe', 'USA', 500.00, 2020), (2, 'Jane Smith', 'USA', 350.00, 2020), (3, 'Alice Johnson', 'USA', 700.00, 2020);
What is the average donation amount per donor in the United States, for the year 2020, rounded to the nearest dollar?
SELECT ROUND(AVG(Amount), 0) AS AvgDonationPerDonor FROM Donors WHERE Country = 'USA' AND DonationYear = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(255));
Update the 'players' table to set the name to 'Anonymous' for the player with ID 1
UPDATE players SET name = 'Anonymous' WHERE player_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy (student_id INT, project_type VARCHAR(255)); INSERT INTO open_pedagogy (student_id, project_type) VALUES (1, 'Research Paper'), (2, 'Presentation'), (3, 'Group Project'), (4, 'Individual Project'), (5, 'Presentation'), (6, 'Group Project');
What is the distribution of open pedagogy project types?
SELECT project_type, COUNT(*) FROM open_pedagogy GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, open_date DATE); INSERT INTO cases (id, open_date) VALUES (1, '2022-01-05'), (2, '2022-02-10'), (3, '2022-01-20');
How many cases were opened in the month of January 2022?
SELECT COUNT(*) FROM cases WHERE open_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, quantity INT); INSERT INTO production VALUES ('Neodymium', 2015, 1200), ('Praseodymium', 2015, 1500), ('Dysprosium', 2015, 800), ('Neodymium', 2016, 1300), ('Praseodymium', 2016, 1600), ('Dysprosium', 2016, 900), ('Neodymium', 2017, 1400), ('Praseodymium', 2017, 1700), ('Dysprosium', 2017, 1000), ('Neodymium', 2018, 1500), ('Praseodymium', 2018, 1800), ('Dysprosium', 2018, 1100);
How many types of rare earth elements were produced in 2018?
SELECT COUNT(DISTINCT element) FROM production WHERE year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, order_value DECIMAL(10,2), device VARCHAR(20), country VARCHAR(50)); INSERT INTO orders (id, order_value, device, country) VALUES (1, 150.50, 'mobile', 'USA'), (2, 75.20, 'desktop', 'Canada'), (3, 225.00, 'mobile', 'USA');
What is the average order value for purchases made using a mobile device in the United States?
SELECT AVG(order_value) FROM orders WHERE device = 'mobile' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, country TEXT, environmental_impact_score INT); INSERT INTO mine VALUES (1, 'Mine A', 'Country A', 60); INSERT INTO mine VALUES (2, 'Mine B', 'Country B', 75); INSERT INTO mine VALUES (3, 'Mine C', 'Country A', 45);
List all mines and their environmental impact score, grouped by country
SELECT country, environmental_impact_score, AVG(environmental_impact_score) as avg_score FROM mine GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE sector_incidents (id INT, sector VARCHAR(255), incident_time TIMESTAMP, incident_type VARCHAR(255));
What are the most common types of security incidents in the 'finance' sector in the last month?
SELECT incident_type, COUNT(*) as incident_count FROM sector_incidents WHERE sector = 'finance' AND incident_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) GROUP BY incident_type ORDER BY incident_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(255), worker_count INT, average_salary DECIMAL(10,2)); INSERT INTO factories VALUES (1, 'textiles', 50, 2500.00), (2, 'metalwork', 30, 3000.00), (3, 'renewable energy', 40, 2800.00);
Increase the average salary for workers in the 'metalwork' department by 10%.
UPDATE factories SET average_salary = average_salary * 1.10 WHERE department = 'metalwork';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), division VARCHAR(50)); INSERT INTO teams (team_id, team_name, division) VALUES (1, 'Seahawks', 'Pacific Division'), (2, '49ers', 'Pacific Division'), (3, 'Cardinals', 'Pacific Division'), (4, 'Rams', 'Pacific Division'); CREATE TABLE games (game_id INT, team_id INT, ticket_price DECIMAL(5,2)); INSERT INTO games (game_id, team_id, ticket_price) VALUES (1, 1, 120.00), (2, 1, 130.00), (3, 2, 110.00), (4, 2, 105.00), (5, 3, 90.00), (6, 3, 95.00), (7, 4, 140.00), (8, 4, 135.00);
What is the average ticket price for football games in the 'Pacific Division'?
SELECT AVG(ticket_price) FROM games JOIN teams ON games.team_id = teams.team_id WHERE division = 'Pacific Division';
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (booking_id INT, hotel_id INT, guest_name VARCHAR(50), checkin_date DATE, checkout_date DATE, price DECIMAL(10,2));
Delete all records from the "bookings" table where the "hotel_id" is 3
DELETE FROM bookings WHERE hotel_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE articles (id INT, author_id INT, title VARCHAR(100), content TEXT); INSERT INTO articles (id, author_id, title, content) VALUES (1, 1, 'Article 1', 'Content 1'), (2, 1, 'Article 2', 'Content 2'), (3, 2, 'Article 3', 'Content 3');
What is the total number of news articles by each author?
SELECT a.name, COUNT(*) as total_articles FROM articles a JOIN authors au ON a.author_id = au.id GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE public.scooters (id SERIAL PRIMARY KEY, name TEXT, speed FLOAT, city TEXT); INSERT INTO public.scooters (name, speed, city) VALUES ('Electric Scooter 1', 25.8, 'Austin'), ('Electric Scooter 2', 28.1, 'Austin');
What is the maximum speed of electric scooters in Austin?
SELECT MAX(speed) FROM public.scooters WHERE city = 'Austin' AND name LIKE 'Electric Scooter%';
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, station_name VARCHAR(255), line VARCHAR(255));CREATE TABLE trips (trip_id INT, station_id INT, entry_time TIMESTAMP); INSERT INTO stations (station_id, station_name, line) VALUES (1, 'Broadway', 'Red Line'), (2, 'Andrew', 'Red Line'), (3, 'Alewife', 'Red Line'); INSERT INTO trips (trip_id, station_id, entry_time) VALUES (1, 1, '2022-07-04 06:00:00'), (2, 1, '2022-07-04 18:00:00'), (3, 2, '2022-07-04 12:00:00'), (4, 3, '2022-07-04 10:00:00'), (5, 3, '2022-07-04 16:00:00');
Find the station on the Red Line with the least number of entries on 2022-07-04
SELECT s.station_name, COUNT(t.station_id) as num_entries FROM trips t JOIN stations s ON t.station_id = s.station_id WHERE s.line = 'Red Line' AND t.entry_time::date = '2022-07-04' GROUP BY s.station_name ORDER BY num_entries ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_certifications(hotel_id INT, eco_certified BOOLEAN); INSERT INTO hotel_certifications (hotel_id, eco_certified) VALUES (1, TRUE), (2, FALSE); CREATE TABLE hotel_info(hotel_id INT, name TEXT, country TEXT); INSERT INTO hotel_info (hotel_id, name, country) VALUES (1, 'Eco Hotel', 'Brazil'), (2, 'Regular Hotel', 'Brazil');
How many eco-friendly hotels are there in Brazil?
SELECT COUNT(*) FROM hotel_info hi INNER JOIN hotel_certifications hc ON hi.hotel_id = hc.hotel_id WHERE hi.country = 'Brazil' AND hc.eco_certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerActionGames (PlayerID INT, Playtime INT); INSERT INTO PlayerActionGames (PlayerID, Playtime) VALUES (1, 5000); CREATE TABLE ActionGames (GameID INT, GameType VARCHAR(10)); INSERT INTO ActionGames (GameID, GameType) VALUES (1, 'action');
What is the total playtime of all players in action games?
SELECT SUM(Playtime) FROM PlayerActionGames JOIN ActionGames ON PlayerActionGames.GameID = ActionGames.GameID WHERE ActionGames.GameType = 'action';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (id INT, year INT, location VARCHAR(50), sequestration FLOAT); INSERT INTO carbon_sequestration (id, year, location, sequestration) VALUES (2, 2010, 'Temperate Rainforests', 6000);
What is the total carbon sequestration in 'Temperate Rainforests' in 2010?
SELECT SUM(sequestration) FROM carbon_sequestration WHERE year = 2010 AND location = 'Temperate Rainforests';
gretelai_synthetic_text_to_sql
CREATE TABLE AstroFunding (id INT, project_name VARCHAR(30), funding FLOAT);
What is the total funding received by each astrophysics research project?
SELECT project_name, SUM(funding) FROM AstroFunding GROUP BY project_name;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id VARCHAR(10), well_location VARCHAR(20)); CREATE TABLE production (well_id VARCHAR(10), production_count INT);
Insert a new record for well 'L12' in 'Gulf of Mexico' with a production count of 16000.
INSERT INTO wells (well_id, well_location) VALUES ('L12', 'Gulf of Mexico'); INSERT INTO production (well_id, production_count) VALUES ('L12', 16000);
gretelai_synthetic_text_to_sql
CREATE TABLE NationalSecurity (id INT, threat VARCHAR(255), description TEXT, level VARCHAR(255), date DATE); INSERT INTO NationalSecurity (id, threat, description, level, date) VALUES (1, 'Terrorism', 'Planned attacks targeting civilians', 'High', '2022-01-10'), (2, 'Cyber Threat', 'Unauthorized access to critical infrastructure', 'Medium', '2022-01-12');
Which national security threats have the highest priority based on their start dates?
SELECT threat, description, level, date, RANK() OVER(ORDER BY date ASC) as rank FROM NationalSecurity WHERE level = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (salesperson VARCHAR(255), product VARCHAR(255), quantity INT); INSERT INTO sales_data (salesperson, product, quantity) VALUES ('John', 'Tilapia', 200), ('Jane', 'Salmon', 350), ('John', 'Catfish', 150), ('Mike', 'Tilapia', 250), ('Jane', 'Catfish', 100), ('Mike', 'Salmon', 300);
What is the total quantity of seafood sold by each salesperson in the 'sales_data' table?
SELECT salesperson, SUM(quantity) as total_quantity FROM sales_data GROUP BY salesperson;
gretelai_synthetic_text_to_sql
CREATE TABLE binance_smart_chain (smart_contract_id INT, deployment_timestamp TIMESTAMP);
How many smart contracts have been deployed on the Binance Smart Chain in the last week?
SELECT COUNT(smart_contract_id) FROM binance_smart_chain WHERE deployment_timestamp >= NOW() - INTERVAL '1 week';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items_2 (item VARCHAR(255), vegan BOOLEAN); INSERT INTO menu_items_2 (item, vegan) VALUES ('Burger', false), ('Veggie Burger', false), ('Salad', true);
How many vegan options are available on the menu?
SELECT COUNT(*) FROM menu_items_2 WHERE vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteProjects (id INT, name VARCHAR(50), total_budget FLOAT); CREATE TABLE SatelliteLaunches (id INT, project_id INT, launch_date DATE);
List all satellite launches with their project's total budget?
SELECT SatelliteLaunches.id, SatelliteLaunches.launch_date, SatelliteProjects.total_budget FROM SatelliteLaunches JOIN SatelliteProjects ON SatelliteLaunches.project_id = SatelliteProjects.id;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (id INT, temperature FLOAT, humidity FLOAT, pressure FLOAT, wind_speed FLOAT, station_id INT, timestamp TIMESTAMP); INSERT INTO weather_data (id, temperature, humidity, pressure, wind_speed, station_id, timestamp) VALUES (1, 20.5, 50.3, 1013.2, 5.6, 1, '2022-01-01 10:00:00');
What is the average temperature and humidity for each weather station in the month of July?
SELECT station_id, AVG(temperature), AVG(humidity) FROM weather_data WHERE EXTRACT(MONTH FROM timestamp) = 7 GROUP BY station_id;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), price DECIMAL(5,2), certification VARCHAR(255));
What is the maximum price of Organic products?
SELECT MAX(price) FROM products WHERE certification = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(255), imo INT); CREATE TABLE events (id INT, vessel_id INT, event_type VARCHAR(255), event_date DATE);
Which vessels had a security breach in the last 6 months?
SELECT v.name FROM vessels v JOIN events e ON v.id = e.vessel_id WHERE e.event_type = 'Security Breach' AND e.event_date >= CURDATE() - INTERVAL 6 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(50), country VARCHAR(50), techniques VARCHAR(50)); INSERT INTO projects (id, name, country, techniques) VALUES (1, 'ProjectA', 'Brazil', 'CRISPR, PCR'); INSERT INTO projects (id, name, country, techniques) VALUES (2, 'ProjectB', 'Brazil', 'PCR, bioinformatics'); INSERT INTO projects (id, name, country, techniques) VALUES (3, 'ProjectC', 'Brazil', 'CRISPR, bioinformatics'); INSERT INTO projects (id, name, country, techniques) VALUES (4, 'ProjectD', 'Brazil', 'Bioinformatics');
How many genetic research projects in Brazil use CRISPR technology?
SELECT COUNT(*) FROM projects WHERE country = 'Brazil' AND techniques LIKE '%CRISPR%';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance(project_name TEXT, region TEXT, source TEXT); INSERT INTO climate_finance(project_name, region, source) VALUES ('Project E', 'USA', 'Government Grant'), ('Project F', 'Australia', 'Private Donation');
List all unique climate finance sources for projects in North America and Oceania.
SELECT DISTINCT source FROM climate_finance WHERE region IN ('North America', 'Oceania');
gretelai_synthetic_text_to_sql
CREATE VIEW ev_prices AS SELECT gv.*, price FROM green_vehicles gv JOIN vehicle_prices vp ON gv.id = vp.vehicle_id WHERE gv.type = 'Electric';
What is the average price of electric vehicles with a range greater than 300 miles in the "ev_prices" view?
SELECT AVG(price) FROM ev_prices WHERE range > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE employee (id INT, mine_id INT, name TEXT, diversity_group TEXT, join_date DATE); INSERT INTO mine VALUES (1, 'Mine A', 'Country A'); INSERT INTO mine VALUES (2, 'Mine B', 'Country B'); INSERT INTO employee VALUES (1, 1, 'John', 'Underrepresented Group 1', '2021-01-01'); INSERT INTO employee VALUES (2, 1, 'Maria', 'Underrepresented Group 2', '2021-02-01'); INSERT INTO employee VALUES (3, 2, 'David', 'Underrepresented Group 1', '2021-01-01'); INSERT INTO employee VALUES (4, 2, 'Sophia', 'Underrepresented Group 2', '2021-02-01'); INSERT INTO employee VALUES (5, 2, 'James', 'Not Underrepresented', '2021-03-01');
Show the change in workforce diversity in each mine over time
SELECT mine.name, diversity_group, COUNT(employee.id) AS total_count, COUNT(DISTINCT employee.join_date) AS unique_dates FROM mine INNER JOIN employee ON mine.id = employee.mine_id GROUP BY mine.name, employee.diversity_group;
gretelai_synthetic_text_to_sql
CREATE TABLE tennis_players (id INT, name VARCHAR(50), matches_won INT, match_date DATE);
Who is the top-performing tennis player in terms of number of matches won in the last 6 months?
SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY matches_won DESC) as rank FROM tennis_players WHERE match_date >= DATEADD(month, -6, GETDATE())) subquery WHERE rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, name VARCHAR(255)); INSERT INTO routes (route_id, name) VALUES (8, 'Route 8'), (9, 'Route 9'); CREATE TABLE stations (station_id INT, route_id INT); INSERT INTO stations (station_id, route_id) VALUES (9, 9), (10, 8);
What is the name of the route that passes through station 9?
SELECT name FROM routes WHERE route_id IN (SELECT route_id FROM stations WHERE station_id = 9);
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (id INT, state VARCHAR(2), length FLOAT, build_year INT, maintenance_cost FLOAT); INSERT INTO Bridges (id, state, length, build_year, maintenance_cost) VALUES (1, 'TX', 600, 1995, 10000), (2, 'TX', 400, 2000, 8000), (3, 'TX', 700, 1985, 12000);
How many bridges in Texas have a length greater than 500 meters and were built after 1990, along with their average maintenance cost?
SELECT COUNT(*), AVG(maintenance_cost) FROM Bridges WHERE state = 'TX' AND length > 500 AND build_year > 1990;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name TEXT, country TEXT, year INT, corn_yield FLOAT, soybean_yield FLOAT, wheat_yield FLOAT);
What is the average yield of corn, soybeans, and wheat for farmers in the 'rural_development' database, grouped by country and year?
SELECT country, year, AVG(corn_yield), AVG(soybean_yield), AVG(wheat_yield) FROM farmers GROUP BY country, year;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, category VARCHAR(255), success_bool BOOLEAN); INSERT INTO threat_intelligence (id, category, success_bool) VALUES (1, 'Phishing', TRUE), (2, 'Ransomware', FALSE), (3, 'Phishing', TRUE), (4, 'Ransomware', TRUE), (5, 'Phishing', FALSE);
Calculate the percentage of successful attacks on each threat category in the last month.
SELECT category, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY NULL) as percentage FROM threat_intelligence WHERE success_bool = TRUE AND category IN ('Phishing', 'Ransomware') GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency (id INT PRIMARY KEY, state VARCHAR(2), year INT, training_hours FLOAT);
Drop the table for cultural competency data
DROP TABLE IF EXISTS cultural_competency;
gretelai_synthetic_text_to_sql
CREATE TABLE Consumer_Preference (ConsumerID INT, ProductID INT, Preference INT, Country VARCHAR(50)); INSERT INTO Consumer_Preference (ConsumerID, ProductID, Preference, Country) VALUES (11, 104, 8, 'US'), (12, 101, 9, 'US'), (13, 105, 7, 'US'), (14, 103, 6, 'US'), (15, 102, 5, 'US');
What is the average consumer preference score for cosmetic products in the US?
SELECT AVG(Preference) as AveragePreference FROM Consumer_Preference WHERE Country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name VARCHAR(255), location VARCHAR(255), last_accident_date DATE); INSERT INTO mines (id, name, location, last_accident_date) VALUES (1, 'Mine A', 'Australia', '2021-01-15'), (2, 'Mine B', 'Canada', '2021-06-20'), (3, 'Mine C', 'Australia', '2021-02-10'), (4, 'Mine D', 'USA', NULL), (5, 'Mine E', 'Australia', '2021-05-01');
What is the total number of accidents for each mine in the last 12 months?
SELECT m.name, COUNT(m.id) as total_accidents FROM mines m WHERE m.last_accident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY m.name;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_destinations (id INT, country VARCHAR(10), visitors INT); INSERT INTO sustainable_destinations (id, country, visitors) VALUES (1, 'Norway', 5000); INSERT INTO sustainable_destinations (id, country, visitors) VALUES (2, 'Sweden', 7000); INSERT INTO sustainable_destinations (id, country, visitors) VALUES (3, 'Finland', 6000);
Identify the countries with the highest number of visitors to sustainable tourism destinations in Q3 of 2022.
SELECT country FROM sustainable_destinations WHERE QUARTER(arrival_date) = 3 GROUP BY country ORDER BY SUM(visitors) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, department VARCHAR(20)); CREATE TABLE employees (employee_id INT, company_id INT); CREATE TABLE training (employee_id INT, training VARCHAR(20)); INSERT INTO companies (company_id, department) VALUES (1, 'manufacturing'), (2, 'HR'), (3, 'manufacturing'); INSERT INTO employees (employee_id, company_id) VALUES (1, 1), (2, 1), (3, 2); INSERT INTO training (employee_id, training) VALUES (1, 'welding'), (2, 'safety'), (3, 'safety');
What is the total number of employees working in the 'manufacturing' department, including any employees who also appear in the 'training' table?
SELECT COUNT(*) FROM companies INNER JOIN employees ON companies.company_id = employees.company_id WHERE companies.department = 'manufacturing' AND employees.employee_id IN (SELECT employee_id FROM training);
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_data (id INT, country VARCHAR(20), type VARCHAR(20), cases INT); INSERT INTO infectious_disease_data (id, country, type, cases) VALUES (1, 'Canada', 'Influenza', 15000), (2, 'Canada', 'COVID-19', 120000), (3, 'Canada', 'Hepatitis A', 5000);
What is the second most common type of infectious disease in Canada?
SELECT type, cases FROM infectious_disease_data WHERE country = 'Canada' ORDER BY cases DESC LIMIT 1 OFFSET 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, attorney_id INT, outcome TEXT); INSERT INTO cases (id, attorney_id, outcome) VALUES (1, 1, 'Lost'); CREATE TABLE attorneys (id INT, name TEXT, region TEXT, title TEXT); INSERT INTO attorneys (id, name, region, title) VALUES (1, 'Jane Smith', 'New York', 'Partner');
What is the number of cases with a 'Lost' outcome in the 'New York' region?
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.region = 'New York' AND cases.outcome = 'Lost';
gretelai_synthetic_text_to_sql
CREATE TABLE arts_orgs (id INT, state VARCHAR(2), org_name VARCHAR(20)); CREATE TABLE org_funding (id INT, org_name VARCHAR(20), amount INT); INSERT INTO arts_orgs (id, state, org_name) VALUES (1, 'OR', 'OrgA'), (2, 'PA', 'OrgB'); INSERT INTO org_funding (id, org_name, amount) VALUES (1, 'OrgA', 25000), (2, 'OrgB', 50000);
How many arts organizations in Oregon and Pennsylvania have received funding and what is the total amount?
SELECT COUNT(DISTINCT ao.org_name), SUM(of.amount) FROM arts_orgs ao INNER JOIN org_funding of ON ao.org_name = of.org_name WHERE ao.state IN ('OR', 'PA');
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites ( id INT, country VARCHAR(255), launch_date DATE ); CREATE TABLE Satellite_Details ( id INT, satellite_name VARCHAR(255), launch_date DATE, mass FLOAT );
List the number of satellites launched by each country, ordered by the total number of satellites launched in descending order, and only show countries that have launched more than 50 satellites.
SELECT s.country, COUNT(s.id) as total_satellites FROM Satellites s JOIN Satellite_Details sd ON s.launch_date = sd.launch_date GROUP BY s.country HAVING total_satellites > 50 ORDER BY total_satellites DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (country VARCHAR(255), sector VARCHAR(255), year INT, ghg_emissions FLOAT); INSERT INTO emissions (country, sector, year, ghg_emissions) VALUES ('CountryA', 'Energy', 2017, 500), ('CountryB', 'Industry', 2017, 400), ('CountryC', 'Energy', 2017, 600), ('CountryA', 'Energy', 2018, 550), ('CountryB', 'Industry', 2018, 420), ('CountryC', 'Energy', 2018, 620);
What are the top 3 greenhouse gas emitters by sector in the last 5 years?
SELECT sector, country, SUM(ghg_emissions) AS total_emissions FROM emissions WHERE year BETWEEN 2017 AND 2021 GROUP BY sector, country ORDER BY total_emissions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, name VARCHAR(255), artist_id INT, date_sold DATE, price DECIMAL(10,2)); CREATE TABLE Artists (artist_id INT, name VARCHAR(255), nationality VARCHAR(255), gender VARCHAR(255));
Who are the top 2 most expensive female painters from Asia?
SELECT Artists.name, MAX(Artworks.price) as price FROM Artists INNER JOIN Artworks ON Artists.artist_id = Artworks.artist_id WHERE Artists.gender = 'Female' AND Artists.nationality = 'Asian' GROUP BY Artists.name ORDER BY price DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE city_complaints (city varchar(50), year int, category varchar(50), num_complaints int); INSERT INTO city_complaints (city, year, category, num_complaints) VALUES ('Chicago', 2021, 'Public Transportation', 3500);
How many citizen complaints were received by the city of Chicago regarding public transportation in 2021?
SELECT SUM(num_complaints) FROM city_complaints WHERE city = 'Chicago' AND category = 'Public Transportation' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (system_name VARCHAR(255), biodiversity_score FLOAT);
Find the indigenous food systems with the highest and lowest biodiversity scores.
SELECT system_name, MAX(biodiversity_score) as highest_score, MIN(biodiversity_score) as lowest_score FROM indigenous_food_systems GROUP BY system_name;
gretelai_synthetic_text_to_sql
CREATE TABLE evidence_based_policies (state VARCHAR(255), year INT, num_policies INT); INSERT INTO evidence_based_policies (state, year, num_policies) VALUES ('California', 2018, 15); INSERT INTO evidence_based_policies (state, year, num_policies) VALUES ('California', 2019, 18);
What is the average number of evidence-based policies adopted per year by the state government of California?
SELECT AVG(num_policies) FROM evidence_based_policies WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE ChargingStations (id INT, city VARCHAR(20), num_chargers INT); INSERT INTO ChargingStations (id, city, num_chargers) VALUES (1, 'Seattle', 10), (2, 'Seattle', 8), (3, 'Portland', 12); CREATE TABLE ElectricVehicles (id INT, city VARCHAR(20), num_evs INT); INSERT INTO ElectricVehicles (id, city, num_evs) VALUES (1, 'Seattle', 50), (2, 'Seattle', 75), (3, 'Portland', 30);
What is the average number of electric vehicles per charging station in the city of Seattle?
SELECT AVG(evs.num_evs/cs.num_chargers) FROM ElectricVehicles evs JOIN ChargingStations cs ON evs.city = cs.city WHERE cs.city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE forests (forest_id INT, country TEXT, region TEXT, area REAL, carbon_sequestration REAL); INSERT INTO forests (forest_id, country, region, area, carbon_sequestration) VALUES (1, 'Brazil', 'South America', 5000, 200), (2, 'Argentina', 'South America', 7000, 180), (3, 'Peru', 'South America', 3000, 220);
Identify the forest with the highest carbon sequestration value in the 'South America' region?
SELECT forest_id, carbon_sequestration FROM forests WHERE region = 'South America' ORDER BY carbon_sequestration DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, campaign_name TEXT, start_date DATE, region TEXT, participants INT); INSERT INTO campaigns (id, campaign_name, start_date, region, participants) VALUES (1, 'Equal Rights', '2020-02-15', 'Europe', 600), (2, 'Climate Action', '2019-09-01', 'Europe', 800), (3, 'Peace Initiative', '2021-03-25', 'Asia', 300);
List all advocacy campaigns in Europe that were started before June 2020 and had more than 500 participants.
SELECT * FROM campaigns WHERE region = 'Europe' AND start_date < '2020-06-01' AND participants > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE e_sports_tournaments (id INT, tournament_name VARCHAR(100), game_name VARCHAR(100), start_date DATE, end_date DATE, location VARCHAR(100)); INSERT INTO e_sports_tournaments (id, tournament_name, game_name, start_date, end_date, location) VALUES (1, 'League of Legends World Championship', 'League of Legends', '2022-10-01', '2022-11-06', 'China'), (2, 'The International', 'Dota 2', '2022-10-15', '2022-10-30', 'Sweden');
Insert new eSports tournament records for the next season?
INSERT INTO e_sports_tournaments (id, tournament_name, game_name, start_date, end_date, location) VALUES (3, 'Call of Duty League Championship', 'Call of Duty', '2022-12-01', '2022-12-04', 'USA'), (4, 'Overwatch League Grand Finals', 'Overwatch', '2023-01-28', '2023-01-29', 'South Korea');
gretelai_synthetic_text_to_sql
CREATE TABLE Garments (GarmentID INT, GarmentName TEXT, SizeDiverse BOOLEAN, TrendID INT); INSERT INTO Garments VALUES (1, 'Garment1', TRUE, 1), (2, 'Garment2', FALSE, 2), (3, 'Garment3', TRUE, 3);
What is the number of size-diverse garments sold to each customer segment in the past month, grouped by garment name?
SELECT c.CustomerSegment, g.GarmentName, COUNT(*) AS NumberOfGarmentsSold FROM Customers c JOIN GarmentSales s ON c.CustomerID = s.CustomerID JOIN Garments g ON s.GarmentID = g.GarmentID WHERE g.SizeDiverse = TRUE AND PurchaseDate >= DATEADD(MONTH, -1, CURRENT_DATE) GROUP BY c.CustomerSegment, g.GarmentName;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks_Movements3(artist VARCHAR(20), artwork VARCHAR(20), movement VARCHAR(20)); INSERT INTO Artworks_Movements3 VALUES ('Picasso', 'Guernica', 'Cubism'), ('Picasso', 'Three Musicians', 'Cubism'), ('Dali', 'The Persistence of Memory', 'Surrealism'), ('Munch', 'The Scream', 'Expressionism'), ('Munch', 'Madonna', 'Symbolism'), ('Kandinsky', 'Composition VIII', 'Abstraction'), ('Kandinsky', 'Improvisation 28 (SECOND VERSION)', 'Abstraction');
What are the Cubist artworks by artists who also created Surrealist pieces?
SELECT artwork FROM Artworks_Movements3 WHERE artist IN (SELECT artist FROM Artworks_Movements3 WHERE movement = 'Surrealism') AND movement = 'Cubism';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, content_type VARCHAR(10)); INSERT INTO posts (id, user_id, content_type) VALUES (1, 1, 'text'), (2, 2, 'image'), (3, 1, 'video'), (4, 2, 'image'), (5, 2, 'image'), (6, 3, 'image'), (7, 1, 'image'), (8, 1, 'image'), (9, 1, 'image');
Which users have posted more than 5 images, and how many images have they posted?
SELECT user_id, COUNT(*) AS num_images FROM posts WHERE content_type = 'image' GROUP BY user_id HAVING COUNT(*) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (location VARCHAR(50), quantity INT); INSERT INTO machines (location, quantity) VALUES ('factory1', 50), ('factory2', 75);
How many 'machines' are there in the 'factory1' location?
SELECT quantity FROM machines WHERE location = 'factory1';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(255), genre VARCHAR(255)); CREATE TABLE artworks (id INT, artist_id INT, title VARCHAR(255)); INSERT INTO artists (id, name, genre) VALUES (1, 'Matisse', 'drawing'), (2, 'Schiele', 'drawing'); INSERT INTO artworks (id, artist_id, title) VALUES (1, 1, 'The Dance'), (2, 2, 'Self-Portrait');
Find the top 2 artists with the highest number of artworks in the 'drawing' genre.
SELECT artist_id, name, COUNT(*) OVER (PARTITION BY genre ORDER BY COUNT(*) DESC) as artwork_count FROM artists JOIN artworks ON artists.id = artworks.artist_id WHERE genre = 'drawing' QUALIFY RANK() OVER (PARTITION BY genre ORDER BY COUNT(*) DESC) <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE coral_reefs (id INT, name VARCHAR(50), region VARCHAR(50), status VARCHAR(20)); INSERT INTO coral_reefs (id, name, region, status) VALUES (1, 'Great Star', 'Caribbean', 'vulnerable'); INSERT INTO coral_reefs (id, name, region, status) VALUES (2, 'Staghorn', 'Caribbean', 'threatened');
Update the 'status' column to 'endangered' for all records in the 'coral_reefs' table where the 'region' is 'Caribbean'
UPDATE coral_reefs SET status = 'endangered' WHERE region = 'Caribbean';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(100), country VARCHAR(100)); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port of Tokyo', 'Japan'); CREATE TABLE cargo_ships (ship_id INT, ship_name VARCHAR(100), port_id INT, containers_transported INT); INSERT INTO cargo_ships (ship_id, ship_name, port_id, containers_transported) VALUES (1, 'Middle Eastern Ship 1', 1, 300), (2, 'Middle Eastern Ship 2', 1, 400), (3, 'Middle Eastern Ship 3', 1, 500);
What is the total number of containers that were transported by cargo ships from Middle Eastern countries to the Port of Tokyo?
SELECT SUM(containers_transported) FROM cargo_ships WHERE country = 'Middle East' AND port_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE species_phosphorus (species VARCHAR(255), year INT, avg_phosphorus FLOAT); INSERT INTO species_phosphorus (species, year, avg_phosphorus) VALUES ('Salmon', 2024, 12.0), ('Tilapia', 2024, 7.5), ('Catfish', 2024, 6.0), ('Trout', 2024, 10.5), ('Shrimp', 2024, 14.0), ('Lobster', 2024, 15.0);
What is the average phosphorus concentration (in µg/L) for each species in 2024, ordered by the average value?
SELECT species, AVG(avg_phosphorus) as avg_phosphorus_ug_l FROM species_phosphorus WHERE year = 2024 GROUP BY species ORDER BY avg_phosphorus_ug_l;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (city VARCHAR(50), trips INT); INSERT INTO public_transportation (city, trips) VALUES ('New York', 500000), ('Los Angeles', 300000), ('Chicago', 400000);
Calculate the total number of trips taken by public transportation in each city
SELECT city, SUM(trips) as total_trips FROM public_transportation GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales_statistics (id INT PRIMARY KEY, ticket_sale_date DATE, total_sales FLOAT, profit FLOAT);
Show the total sales and profit for each quarter
SELECT QUARTER(ticket_sale_date) as quarter, SUM(total_sales) as total_sales, SUM(profit) as profit FROM ticket_sales_statistics GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, rating DECIMAL(3,2), num_ratings INT); INSERT INTO sales VALUES (1, 1, 4.5, 100), (2, 1, 3.5, 200), (3, 2, 5.0, 50), (4, 2, 4.0, 100), (5, 3, 2.5, 30);
Find the number of sales for each product, and the average rating for each product, ordered by the number of sales in descending order.
SELECT product_id, COUNT(*) as num_sales, AVG(rating) as avg_rating FROM sales GROUP BY product_id ORDER BY num_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_name VARCHAR(30), region VARCHAR(20)); INSERT INTO regulatory_frameworks (framework_name, region) VALUES ('Framework1', 'USA'), ('Framework2', 'European Union'), ('Framework3', 'China'), ('Framework4', 'Canada');
List all regulatory frameworks in place for digital assets in the European Union
SELECT framework_name FROM regulatory_frameworks WHERE region = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT, city VARCHAR(50), organization VARCHAR(50), type VARCHAR(50), year INT);
Insert a new record for the 'Traditional Craftsmanship' program in 'Village D' in 2021 into the 'community_engagement' table
INSERT INTO community_engagement (id, city, organization, type, year) VALUES (4, 'Village D', 'Cultural Foundation', 'Traditional Craftsmanship', 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name TEXT, course_type TEXT); CREATE TABLE professional_development (pd_id INT, course_id INT, instructor TEXT);
How many professional development courses are available for teachers, and what are their names, categorized by course type?
SELECT c.course_type, c.course_name, COUNT(p.pd_id) as num_courses FROM courses c JOIN professional_development p ON c.course_id = p.course_id GROUP BY c.course_type, c.course_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ViewershipData(Show VARCHAR(30), Age INT, Views INT, Year INT); INSERT INTO ViewershipData(Show, Age, Views, Year) VALUES ('Stranger Things', 22, 4500000, 2021), ('Breaking Bad', 28, 3500000, 2021), ('The Mandalorian', 19, 5000000, 2021), ('Stranger Things', 23, 5000000, 2021), ('Breaking Bad', 30, 3800000, 2021), ('The Mandalorian', 20, 5200000, 2021), ('Stranger Things', 18, 3900000, 2021), ('Breaking Bad', 25, 3200000, 2021), ('The Mandalorian', 17, 4800000, 2021);
What are the top 3 most popular TV shows among viewers aged 18-24 in 2021?
SELECT Show, SUM(Views) as Total_Views FROM ViewershipData WHERE Age BETWEEN 18 AND 24 AND Year = 2021 GROUP BY Show ORDER BY Total_Views DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu_Items (Item_ID INT, Item_Name TEXT); INSERT INTO Menu_Items (Item_ID, Item_Name) VALUES (1, 'Burger'), (2, 'Pizza'); CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location1'), (2, 'Location2'); CREATE TABLE Revenue_By_Item (Item_ID INT, Location_ID INT, Revenue DECIMAL); INSERT INTO Revenue_By_Item (Item_ID, Location_ID, Revenue) VALUES (1, 1, 100.00), (1, 2, 400.00), (2, 1, 300.00), (2, 2, 400.00);
What is the average revenue per menu item per location?
SELECT MI.Item_Name, L.Location_Name, AVG(Revenue) as Avg_Revenue FROM Revenue_By_Item RBI JOIN Menu_Items MI ON RBI.Item_ID = MI.Item_ID JOIN Locations L ON RBI.Location_ID = L.Location_ID GROUP BY MI.Item_Name, L.Location_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Nationality varchar(50)); INSERT INTO Artists (ArtistID, ArtistName, Nationality) VALUES (1, 'Claude Monet', 'French'), (2, 'Pierre-Auguste Renoir', 'French'); CREATE TABLE Exhibitions (ExhibitionID int, ExhibitionName varchar(100), City varchar(50), Year int); INSERT INTO Exhibitions (ExhibitionID, ExhibitionName, City, Year) VALUES (1, 'Impressionist Exhibition', 'Paris', 1874); CREATE TABLE ExhibitedWorks (WorkID int, ArtistID int, ExhibitionID int); INSERT INTO ExhibitedWorks (WorkID, ArtistID, ExhibitionID) VALUES (1, 1, 1), (2, 2, 1);
Which artists had their works exhibited in the "Impressionist Exhibition" that took place in Paris, 1874?
SELECT Artists.ArtistName FROM Artists INNER JOIN ExhibitedWorks ON Artists.ArtistID = ExhibitedWorks.ArtistID INNER JOIN Exhibitions ON ExhibitedWorks.ExhibitionID = Exhibitions.ExhibitionID WHERE Exhibitions.ExhibitionName = 'Impressionist Exhibition' AND Exhibitions.Year = 1874 AND Exhibitions.City = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE crypto_regulations (regulation_id INT, country_name VARCHAR(50), regulation_description VARCHAR(255), effective_date DATE);
Delete all records in the 'crypto_regulations' table where 'country_name' is 'China'
DELETE FROM crypto_regulations WHERE country_name = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE DailyOilProduction (FieldName TEXT, OilProduction INT, Date DATE); INSERT INTO DailyOilProduction (FieldName, OilProduction, Date) VALUES ('FieldA', 50, '2020-01-01'), ('FieldB', 100, '2020-02-01'), ('FieldC', 150, '2020-03-01');
What is the maximum daily oil production in the Caspian Sea in 2020?
SELECT MAX(OilProduction) AS MaxDailyOilProduction FROM DailyOilProduction WHERE FieldName IN ('FieldA', 'FieldB', 'FieldC') AND Date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 75000.00), (2, 'IT', 80000.00), (3, 'HR', 60000.00), (4, 'HR', 65000.00), (5, 'Marketing', 70000.00);
What is the sum of salaries for all employees?
SELECT SUM(Salary) FROM Employees;
gretelai_synthetic_text_to_sql
CREATE TABLE WorkingHours (EmployeeID INT, Sector VARCHAR(20), WeeklyHours DECIMAL(10, 2)); INSERT INTO WorkingHours (EmployeeID, Sector, WeeklyHours) VALUES (1, 'Healthcare', 40.50), (2, 'Healthcare', 45.00), (3, 'Education', 35.00);
What is the maximum weekly working hours for employees in the 'Healthcare' sector?
SELECT MAX(WeeklyHours) FROM WorkingHours WHERE Sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, hashtags VARCHAR(50), likes INT); INSERT INTO posts (id, hashtags, likes) VALUES (1, '#food, #recipe', 100), (2, '#food, #cooking', 200), (3, '#travel', 150);
What is the total number of likes on posts with the hashtag #food?
SELECT SUM(posts.likes) as total_likes FROM posts WHERE posts.hashtags LIKE '%#food%';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT, name VARCHAR(255), type VARCHAR(255), PRIMARY KEY(id)); INSERT INTO materials (id, name, type) VALUES (23, 'Organic Cotton', 'Fabric'); CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2), material_id INT, PRIMARY KEY(id), FOREIGN KEY (material_id) REFERENCES materials(id)); INSERT INTO products (id, name, category, price, material_id) VALUES (24, 'Organic Cotton T-Shirt', 'Clothing', 45.00, 23), (25, 'Organic Cotton Pants', 'Clothing', 70.00, 23);
What is the total revenue of organic cotton clothing?
SELECT SUM(price) FROM products WHERE name IN ('Organic Cotton T-Shirt', 'Organic Cotton Pants') AND material_id = (SELECT id FROM materials WHERE name = 'Organic Cotton');
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (destination_id INT, name TEXT); CREATE TABLE accommodations (accommodation_id INT, destination_id INT, name TEXT, is_eco BOOLEAN); INSERT INTO destinations (destination_id, name) VALUES (1, 'Fiji'), (2, 'Maldives'), (3, 'Seychelles'), (4, 'Bahamas'); INSERT INTO accommodations (accommodation_id, destination_id, name, is_eco) VALUES (1, 1, 'Hotel Denarau', true), (2, 1, 'Hotel Coral Coast', false), (3, 2, 'Hotel Male', false), (4, 2, 'Hotel Ari', false), (5, 3, 'Hotel Mahé', false), (6, 3, 'Hotel Praslin', false), (7, 4, 'Hotel Nassau', false), (8, 4, 'Hotel Paradise', false);
Which destinations have no eco-friendly accommodations?
SELECT destinations.name FROM destinations LEFT JOIN accommodations ON destinations.destination_id = accommodations.destination_id WHERE accommodations.is_eco IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farms (country VARCHAR(50), has_agroecology BOOLEAN); INSERT INTO urban_farms (country, has_agroecology) VALUES ('Nigeria', true), ('Kenya', false), ('South Africa', true);
How many urban farms have adopted agroecological practices in Africa?
SELECT COUNT(*) FROM urban_farms WHERE country IN ('Nigeria', 'Kenya', 'South Africa') AND has_agroecology = true;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name VARCHAR(100), contract_value DECIMAL(10, 2), contract_date DATE);
Determine the number of defense contracts awarded per month in the 'defense_contracts' table
SELECT EXTRACT(MONTH FROM contract_date) as month, COUNT(*) as num_contracts FROM defense_contracts GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE feedback (id INT, service VARCHAR(20), rating INT, date DATE); INSERT INTO feedback VALUES (1, 'Public Service A', 5, '2022-01-01'), (2, 'Public Service B', 3, '2022-01-02'), (3, 'Public Service A', 4, '2022-01-03'), (4, 'Public Service C', 2, '2022-01-04'), (5, 'Public Service A', 5, '2022-01-05'); CREATE TABLE cities (id INT, name VARCHAR(20), type VARCHAR(10)); INSERT INTO cities VALUES (1, 'CityX', 'Urban'), (2, 'CityY', 'Rural'), (3, 'CityZ', 'Urban');
What is the average rating of public services in urban areas over the last year?
SELECT AVG(rating) FROM feedback INNER JOIN cities ON feedback.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND feedback.date < DATE_SUB(CURRENT_DATE, INTERVAL 0 YEAR) WHERE cities.type = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_sensors (id INT, farm_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); INSERT INTO farm_sensors (id, farm_id, sensor_type, value, timestamp) VALUES (1, 101, 'temperature', 23.5, '2022-01-01 10:00:00');
What is the average temperature per farm over the past month?
SELECT farm_id, AVG(value) as avg_temperature FROM farm_sensors WHERE sensor_type = 'temperature' AND timestamp >= CURRENT_TIMESTAMP - INTERVAL '30 days' GROUP BY farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), cuisine VARCHAR(255)); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (1, 'Big Burger', 12.99, 'American'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (2, 'Chicken Teriyaki', 15.99, 'Japanese'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (3, 'Garden Salad', 7.99, 'American'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (4, 'Sushi Roll', 18.99, 'Japanese'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (5, 'Taco', 6.99, 'Mexican'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (6, 'Nachos', 8.99, 'Mexican'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (7, 'Pizza', 12.99, 'Italian'); INSERT INTO menu_items (menu_item_id, name, price, cuisine) VALUES (8, 'Pasta', 14.99, 'Italian');
Find the average price of menu items for each cuisine type, excluding the cuisine type 'Italian'.
SELECT cuisine, AVG(price) AS avg_price FROM menu_items WHERE cuisine <> 'Italian' GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT, country VARCHAR(50), count INT); INSERT INTO autonomous_vehicles (id, country, count) VALUES (1, 'USA', 1000), (2, 'China', 1500), (3, 'Germany', 800);
Which countries have the most autonomous vehicles?
SELECT country, MAX(count) FROM autonomous_vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (garment_id INTEGER, garment_type TEXT, garment_color TEXT, price INTEGER, quantity INTEGER); INSERT INTO garments (garment_id, garment_type, garment_color, price, quantity) VALUES (1, 't-shirt', 'red', 20, 100), (2, 'jeans', 'blue', 50, 75), (3, 'hoodie', 'black', 30, 120);
Find the average price and quantity of garments in the 'garments' table, for each garment type, and display the results in descending order based on the average quantity.
SELECT garment_type, AVG(price) AS avg_price, AVG(quantity) AS avg_quantity FROM garments GROUP BY garment_type ORDER BY avg_quantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE TeacherProfessionalDevelopment (id INT, name TEXT, school_type TEXT, hours_trained INT); INSERT INTO TeacherProfessionalDevelopment (id, name, school_type, hours_trained) VALUES (1, 'Pam', 'Elementary', 15), (2, 'Sam', 'High School', 30), (3, 'Terry', 'Elementary', 22);
What is the total number of hours of professional development for teachers in the 'TeacherProfessionalDevelopment' table who teach in elementary schools?
SELECT SUM(hours_trained) FROM TeacherProfessionalDevelopment WHERE school_type = 'Elementary';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_sites (site_id INT, site_name TEXT, city TEXT, monthly_visitors INT); INSERT INTO cultural_sites (site_id, site_name, city, monthly_visitors) VALUES (1, 'British Museum', 'London', 10000), (2, 'Tower of London', 'London', 7000), (3, 'Natural History Museum', 'London', 8000);
What is the minimum and maximum number of monthly visitors to cultural sites in London?
SELECT MIN(monthly_visitors), MAX(monthly_visitors) FROM cultural_sites WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerSessionTimes (PlayerID int, SessionID int, Playtime int, Country varchar(50)); INSERT INTO PlayerSessionTimes (PlayerID, SessionID, Playtime, Country) VALUES (6, 1, 100, 'Japan'), (7, 1, 120, 'Japan'), (8, 1, 150, 'Japan'), (9, 1, 180, 'Japan'), (10, 1, 200, 'Japan'), (6, 2, 220, 'Japan'), (7, 2, 250, 'Japan'), (8, 2, 280, 'Japan'), (9, 2, 300, 'Japan'), (10, 2, 320, 'Japan');
What is the average playtime per session for players from Japan?
SELECT AVG(Playtime) FROM PlayerSessionTimes WHERE Country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics_basketball (id INT PRIMARY KEY, fan_id INT, age INT, gender VARCHAR(255))
What is the percentage of fans who are female and attend basketball matches?
SELECT (COUNT(fd.id) * 100.0 / (SELECT COUNT(*) FROM fan_demographics_basketball)) AS percentage
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_health_monitor (date DATE, do_value DECIMAL(3,1)); INSERT INTO ocean_health_monitor (date, do_value) VALUES ('2022-01-01', 6.5), ('2022-01-02', 6.2), ('2022-02-01', 5.9), ('2022-02-02', 6.8);
What is the minimum dissolved oxygen level (DO) in the ocean_health_monitor table for each month in 2022?
SELECT EXTRACT(MONTH FROM date) as month, MIN(do_value) as min_do_value FROM ocean_health_monitor WHERE date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(100), department VARCHAR(50), country VARCHAR(50)); INSERT INTO Employees (id, name, department, country) VALUES (1, 'John Doe', 'IT', 'United States'), (2, 'Jane Smith', 'Marketing', 'Canada'), (3, 'Mike Johnson', 'IT', 'France'), (4, 'Sara Connor', 'HR', 'United States'), (5, 'David Brown', 'Finance', 'Canada');
List all employees who have the same department as John Doe.
SELECT * FROM Employees WHERE department = (SELECT department FROM Employees WHERE name = 'John Doe');
gretelai_synthetic_text_to_sql
CREATE TABLE transportation_infrastructure (project_id INT, project_name VARCHAR(50), project_type VARCHAR(50), budget INT); INSERT INTO transportation_infrastructure (project_id, project_name, project_type, budget) VALUES (1, 'Highway Expansion', 'Road', 8000000), (2, 'Intersection Improvement', 'Road', 3000000), (3, 'Bicycle Lane Installation', 'Bike', 1000000);
What is the total budget for all projects in the 'transportation_infrastructure' table that are for road construction?
SELECT SUM(budget) FROM transportation_infrastructure WHERE project_type = 'Road';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (mission_location VARCHAR(255), mission_id INT);
What is the total number of humanitarian assistance missions in the Middle East?
SELECT SUM(mission_id) FROM humanitarian_assistance WHERE mission_location LIKE '%Middle East%';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_customers (customer_id INT, state VARCHAR(20), last_outage DATE); INSERT INTO broadband_customers (customer_id, state, last_outage) VALUES (1, 'California', DATE '2022-01-15'), (2, 'Texas', DATE '2022-02-01'), (3, 'California', DATE '2022-02-20');
List all broadband customers in the state of California who have experienced a service outage in the past month.
SELECT * FROM broadband_customers WHERE state = 'California' AND last_outage >= DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, industry TEXT, founder_country TEXT); INSERT INTO startup (id, name, industry, founder_country) VALUES (1, 'HealthCareGlobal', 'Healthcare', 'Nigeria');
How many startups in the healthcare sector have a founder from an underrepresented country and have received Series B funding or higher?
SELECT COUNT(*) FROM startup INNER JOIN investment_rounds ON startup.id = investment_rounds.startup_id WHERE startup.industry = 'Healthcare' AND startup.founder_country IN ('Nigeria', 'India', 'Brazil', 'Mexico', 'China') AND funding_round IN ('Series B', 'Series C', 'Series D', 'Series E', 'Series F', 'IPO');
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, organic TEXT, product_id INT, country TEXT); INSERT INTO ingredients VALUES (1, 'Jojoba Oil', 'Organic', 1, 'Mexico'), (2, 'Shea Butter', 'Organic', 2, 'Ghana'), (3, 'Aloe Vera', 'Organic', 3, 'Mexico'), (4, 'Rosehip Oil', 'Organic', 4, 'Chile'), (5, 'Cocoa Butter', 'Conventional', 5, 'Ghana'); CREATE TABLE cosmetics (product_id INT, product_name TEXT, cruelty_free BOOLEAN, price FLOAT); INSERT INTO cosmetics VALUES (1, 'Lipstick A', true, 12.99), (2, 'Foundation B', false, 18.50), (3, 'Mascara C', true, 9.99), (4, 'Eyeshadow D', true, 14.99), (5, 'Blush E', false, 11.99);
List the top 5 countries with the most cruelty-free cosmetic products.
SELECT country, COUNT(*) as product_count FROM ingredients JOIN cosmetics ON ingredients.product_id = cosmetics.product_id WHERE cosmetics.cruelty_free = true GROUP BY country ORDER BY product_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE location (location_id INT, location_name TEXT); INSERT INTO location (location_id, location_name) VALUES (1, 'Arctic Ocean'); CREATE TABLE temperature (temperature_id INT, location_id INT, water_temp FLOAT); INSERT INTO temperature (temperature_id, location_id, water_temp) VALUES (1, 1, -1.8), (2, 1, -2.1), (3, 1, -1.9), (4, 1, -2.2), (5, 1, -2.3);
What is the minimum water temperature in the Arctic Ocean?
SELECT MIN(water_temp) FROM temperature WHERE location_id = (SELECT location_id FROM location WHERE location_name = 'Arctic Ocean');
gretelai_synthetic_text_to_sql
CREATE SCHEMA fleet; CREATE TABLE fleet.vehicles (id INT PRIMARY KEY, type VARCHAR(255), year INT); INSERT INTO fleet.vehicles (id, type, year) VALUES (1, 'Bus', 2015), (2, 'Tram', 2018), (3, 'Trolleybus', 2020), (4, 'Ferry', 2017), (5, 'Bus', 2019);
What are the vehicle types and their quantities in the 'fleet' schema?
SELECT type, COUNT(*) as quantity FROM fleet.vehicles GROUP BY type;
gretelai_synthetic_text_to_sql