context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE military_personnel (country VARCHAR(50), region VARCHAR(50), num_personnel INT); INSERT INTO military_personnel (country, region, num_personnel) VALUES ('Country6', 'Africa', 2000), ('Country7', 'Africa', 3000), ('Country8', 'Africa', 4000), ('Country9', 'Europe', 5000), ('Country10', 'Asia-Pacific', 6000);
What is the total number of military personnel in African countries?
SELECT SUM(num_personnel) FROM military_personnel WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID INT, Name VARCHAR(50), Country VARCHAR(50), Score INT);
How many players have a score lower than 50?
SELECT COUNT(*) FROM Player WHERE Score < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_statements (statement_length INTEGER); INSERT INTO artist_statements (statement_length) VALUES (50), (100), (150);
What is the maximum length of all artist statements in the database?
SELECT MAX(statement_length) FROM artist_statements;
gretelai_synthetic_text_to_sql
CREATE TABLE posts(region VARCHAR(20), post_date DATE, hashtags VARCHAR(50)); INSERT INTO posts(region, post_date, hashtags) VALUES('Europe', '2021-11-01', '#environment, #sustainability'), ('Europe', '2021-11-02', '#climateaction, #ecofriendly'), ('Europe', '2021-11-03', '#nature, #recycle'), ('Europe', '2021-11-04', '#environment, #greenliving'), ('Europe', '2021-11-05', '#sustainability, #ecofriendly');
What is the total number of posts related to #environment in Europe in the last month?
SELECT COUNT(*) FROM posts WHERE region = 'Europe' AND post_date >= DATEADD(month, -1, CURRENT_DATE) AND hashtags LIKE '%environment%'
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety_testing (vehicle_id INT, vehicle_name VARCHAR(50), horsepower INT, safety_rating FLOAT);
What is the average horsepower of electric vehicles in the vehicle_safety_testing table?
SELECT AVG(horsepower) FROM vehicle_safety_testing WHERE vehicle_type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE program_outcomes (id INT, program_id INT, outcome_date DATE); INSERT INTO program_outcomes (id, program_id, outcome_date) VALUES (1, 1, '2020-01-01'), (2, 2, '2021-06-01'), (3, 3, NULL);
Delete program outcomes that were not achieved in the last year.
DELETE FROM program_outcomes WHERE outcome_date IS NULL OR outcome_date < DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_movements (id INT PRIMARY KEY, cargo_id INT, vessel_id INT, port_id INT, movement_date DATE);
Insert a new cargo shipment record into the "cargo_movements" table
INSERT INTO cargo_movements (id, cargo_id, vessel_id, port_id, movement_date) VALUES (12345, 67890, 111213, 14, '2022-06-15');
gretelai_synthetic_text_to_sql
CREATE TABLE eco_awareness(user_id INT, post_date DATE, post_text TEXT, likes INT);
How many users have posted about 'ecofashion' in the 'eco_awareness' table and what is the average number of likes for their posts?
SELECT COUNT(DISTINCT user_id) AS users, AVG(likes) AS avg_likes FROM eco_awareness WHERE post_text LIKE '%ecofashion%';
gretelai_synthetic_text_to_sql
CREATE TABLE CrimeStatistics (Id INT, Crime VARCHAR(20), Location VARCHAR(20), Date TIMESTAMP, Population INT);
What is the total population and number of crimes for each city, ordered by population?
SELECT Location, SUM(Population) as TotalPopulation, COUNT(*) as NumberOfCrimes FROM CrimeStatistics GROUP BY Location ORDER BY TotalPopulation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (AccidentID INT, Date DATE, Location VARCHAR(50), Type VARCHAR(50), Injuries INT, Fatalities INT); INSERT INTO Accidents (AccidentID, Date, Location, Type, Injuries, Fatalities) VALUES (1, '2018-03-12', 'Texas', 'SpaceX', 3, 0), (2, '2019-04-20', 'California', 'Blue Origin', 0, 1), (3, '2020-05-29', 'Florida', 'SpaceX', 1, 0);
List the accidents with a descending number of fatalities.
SELECT AccidentID, Date, Location, Type, Injuries, Fatalities, ROW_NUMBER() OVER (ORDER BY Fatalities DESC) AS Rank FROM Accidents;
gretelai_synthetic_text_to_sql
CREATE TABLE weather (location VARCHAR(50), temperature INT, record_date DATE); INSERT INTO weather VALUES ('Seattle', 45, '2022-01-01'); INSERT INTO weather VALUES ('Seattle', 50, '2022-02-01'); INSERT INTO weather VALUES ('Seattle', 55, '2022-03-01'); INSERT INTO weather VALUES ('New York', 30, '2022-01-01'); INSERT INTO weather VALUES ('New York', 35, '2022-02-01'); INSERT INTO weather VALUES ('New York', 40, '2022-03-01');
What is the change in temperature between consecutive records for each location in 'weather' table?
SELECT location, record_date, temperature, LEAD(temperature) OVER (PARTITION BY location ORDER BY record_date) - temperature AS temp_change FROM weather;
gretelai_synthetic_text_to_sql
CREATE TABLE aid_distribution (agency VARCHAR(255), country VARCHAR(255), aid_amount DECIMAL(10,2), num_people INT, year INT);
What was the average amount of aid per person provided by WFP in South Sudan during 2017?
SELECT AVG(aid_amount/num_people) FROM aid_distribution WHERE agency = 'WFP' AND country = 'South Sudan' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, army_branch VARCHAR(255), maintenance_type VARCHAR(255), maintenance_cost DECIMAL(10,2), maintenance_date DATE); INSERT INTO military_equipment (equipment_id, army_branch, maintenance_type, maintenance_cost, maintenance_date) VALUES (1, 'Canadian Army', 'Armored Vehicles', 15000.00, '2019-02-22'); INSERT INTO military_equipment (equipment_id, army_branch, maintenance_type, maintenance_cost, maintenance_date) VALUES (2, 'Canadian Army', 'Artillery', 20000.00, '2019-08-18');
List all military equipment maintenance records for the Canadian Army in 2019, along with the maintenance types and costs.
SELECT maintenance_type, maintenance_cost FROM military_equipment WHERE army_branch = 'Canadian Army' AND maintenance_date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE cause (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE donation (id INT PRIMARY KEY, cause_id INT, amount DECIMAL(10,2));
Which causes have donations greater than $10,000?
SELECT c.name FROM cause c JOIN donation d ON c.id = d.cause_id WHERE d.amount > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, neodymium_production FLOAT); INSERT INTO mines (id, name, location, neodymium_production) VALUES (1, 'Mine A', 'Canada', 120.5), (2, 'Mine B', 'Canada', 150.7), (3, 'Mine C', 'USA', 200.3);
What is the average production of Neodymium in 2020 from mines located in Canada?
SELECT AVG(neodymium_production) FROM mines WHERE location = 'Canada' AND YEAR(mines.timestamp) = 2020 AND mine_type = 'Neodymium';
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (site_id INT, site_name TEXT, region TEXT); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type TEXT); INSERT INTO excavation_sites (site_id, site_name, region) VALUES (1, 'Site A', 'Southern Region'), (2, 'Site B', 'Northern Region'), (3, 'Site C', 'Southern Region'); INSERT INTO artifacts (artifact_id, site_id, artifact_type) VALUES (1, 1, 'pottery'), (2, 1, 'stone'), (3, 2, 'metal'), (4, 3, 'pottery'), (5, 3, 'wooden'), (6, 4, 'stone'), (7, 4, 'pottery');
Find the number of unique artifact types for each site in the 'Southern Region'?
SELECT e.site_name, COUNT(DISTINCT a.artifact_type) as unique_artifact_types FROM excavation_sites e JOIN artifacts a ON e.site_id = a.site_id WHERE e.region = 'Southern Region' GROUP BY e.site_id;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT PRIMARY KEY, manufacturer VARCHAR(255), location VARCHAR(255), capacity FLOAT);
Delete records in the 'wind_turbines' table where the 'manufacturer' is 'NorthernWinds' and the 'location' is not 'Ontario'
DELETE FROM wind_turbines WHERE manufacturer = 'NorthernWinds' AND location != 'Ontario';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (project_id INT, sector VARCHAR(20), budget DECIMAL(10,2), start_date DATE); INSERT INTO community_development (project_id, sector, budget, start_date) VALUES (1001, 'Education', 50000.00, '2022-01-01'), (1002, 'Healthcare', 75000.00, '2022-02-15'), (1003, 'Infrastructure', 100000.00, '2022-03-30'), (1004, 'Agriculture', 80000.00, '2022-04-12');
List the number of community development projects and total budget for each sector in H1 2022?
SELECT sector, COUNT(*) as projects_count, SUM(budget) as total_budget FROM community_development WHERE EXTRACT(QUARTER FROM start_date) = 1 AND EXTRACT(YEAR FROM start_date) = 2022 GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, month INT, element TEXT, quantity INT); INSERT INTO production (year, month, element, quantity) VALUES (2018, 1, 'Europium', 50), (2018, 2, 'Europium', 60), (2018, 3, 'Europium', 70), (2018, 4, 'Europium', 80), (2018, 5, 'Europium', 90), (2018, 6, 'Europium', 100), (2018, 7, 'Europium', 110), (2018, 8, 'Europium', 120), (2018, 9, 'Europium', 130), (2018, 10, 'Europium', 140), (2018, 11, 'Europium', 150), (2018, 12, 'Europium', 160);
What is the maximum monthly production of Europium in 2018?
SELECT MAX(quantity) FROM production WHERE element = 'Europium' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE workout_sessions (id INT, user_id INT, session_date DATE); CREATE TABLE memberships (id INT, user_id INT, membership_type VARCHAR(255), start_date DATE, end_date DATE);
Find the number of users who have attended a workout session in the last month and have a 'Premium' membership?
SELECT COUNT(DISTINCT ws.user_id) FROM workout_sessions ws JOIN memberships m ON ws.user_id = m.user_id WHERE m.membership_type = 'Premium' AND ws.session_date >= DATE(NOW()) - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions_indian (expedition_name VARCHAR(255), discovered_species INT, expedition_date DATE, ocean VARCHAR(255)); INSERT INTO deep_sea_expeditions_indian (expedition_name, discovered_species, expedition_date, ocean) VALUES ('Indian Ocean Expedition', 50, '2000-01-01', 'Indian Ocean'), ('Deep-Sea Expedition', 100, '2010-01-01', 'Indian Ocean'), ('Indian Ocean Exploration', 150, '2020-01-01', 'Indian Ocean');
List all deep-sea expeditions that resulted in new species discoveries in the Indian Ocean.
SELECT expedition_name, discovered_species, expedition_date FROM deep_sea_expeditions_indian WHERE ocean = 'Indian Ocean' AND discovered_species > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10)); INSERT INTO faculty (id, name, department, gender) VALUES (1, 'Alice', 'Mathematics', 'Female'); INSERT INTO faculty (id, name, department, gender) VALUES (2, 'Bob', 'Physics', 'Male');
What is the average research grant amount awarded to female faculty members in the Mathematics department?
SELECT AVG(rg.amount) FROM research_grants rg JOIN faculty f ON rg.faculty_id = f.id WHERE f.department = 'Mathematics' AND f.gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE sites (site_id INT, state VARCHAR(2), num_workers INT, acres FLOAT);
Insert new records for mining sites located in 'TX' into the 'sites' table.
INSERT INTO sites (site_id, state, num_workers, acres) VALUES (101, 'TX', 50, 120.5), (102, 'TX', 75, 150.3);
gretelai_synthetic_text_to_sql
CREATE TABLE Defense_Projects(id INT, project_name VARCHAR(255), start_year INT, end_year INT); INSERT INTO Defense_Projects(id, project_name, start_year, end_year) VALUES (1, 'Project A', 2015, 2018), (2, 'Project B', 2016, 2019), (3, 'Project C', 2017, 2020), (4, 'Project D', 2018, 2021), (5, 'Project E', 2015, 2020), (6, 'Project F', 2016, 2017);
Update the end year of defense project 'Project A' to 2022.
UPDATE Defense_Projects SET end_year = 2022 WHERE project_name = 'Project A';
gretelai_synthetic_text_to_sql
CREATE TABLE public.emissions_data(id serial PRIMARY KEY, vehicle_type varchar(255), location varchar(255), co2_emission numeric);
What is the average CO2 emission of hybrid vehicles in 'urban' areas?
SELECT AVG(co2_emission) FROM public.emissions_data WHERE vehicle_type = 'Hybrid' AND location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_class TEXT, year INTEGER, sales_amount INTEGER);
What was the total sales for orphan drugs in 2021?
SELECT SUM(sales_amount) FROM sales WHERE drug_class = 'orphan' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_data (id INT PRIMARY KEY, chemical_name VARCHAR(255), quantity_produced INT, date_manufactured DATE); INSERT INTO manufacturing_data (id, chemical_name, quantity_produced, date_manufactured) VALUES (1, 'Ammonia', 100, '2022-01-01');
Update the quantity produced for 'Ammonia' in the "manufacturing_data" table
UPDATE manufacturing_data SET quantity_produced = 150 WHERE chemical_name = 'Ammonia';
gretelai_synthetic_text_to_sql
CREATE VIEW TOTAL_PRODUCTION AS SELECT SUM(PRODUCTION_QTY) FROM GAS_WELLS;
What is the total production quantity for all wells in the 'TOTAL_PRODUCTION' view?
SELECT SUM(PRODUCTION_QTY) FROM TOTAL_PRODUCTION;
gretelai_synthetic_text_to_sql
CREATE TABLE UnionG(member_id INT, job_title VARCHAR(20)); INSERT INTO UnionG(member_id, job_title) VALUES(7001, 'Engineer'), (7002, 'Engineer'), (7003, 'Manager'), (7004, 'Clerk'), (7005, 'Manager'), (7006, 'Engineer');
List all unique job titles in Union 'G' with more than 30 members.
SELECT DISTINCT job_title FROM UnionG GROUP BY job_title HAVING COUNT(*) > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (PropertyID INT, Price DECIMAL(10,2), City VARCHAR(255), NumberOfOwners INT); INSERT INTO Properties (PropertyID, Price, City, NumberOfOwners) VALUES (1, 700000, 'Toronto', 1), (2, 600000, 'Toronto', 2), (3, 800000, 'Toronto', 2);
How many properties are co-owned in the city of Toronto?
SELECT COUNT(*) FROM Properties WHERE City = 'Toronto' AND NumberOfOwners > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE city_population (city VARCHAR(50), country VARCHAR(50), population INT); INSERT INTO city_population (city, country, population) VALUES ('New York', 'United States', 8550405), ('Los Angeles', 'United States', 3971883), ('Chicago', 'United States', 2705275), ('Houston', 'United States', 2325502), ('Phoenix', 'United States', 1660272), ('Philadelphia', 'United States', 1585577), ('San Antonio', 'United States', 1547253), ('San Diego', 'United States', 1425876);
What is the maximum population of cities in North America?
SELECT MAX(population) FROM city_population WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE player_skills (id INT, game VARCHAR(20), skill_level INT); INSERT INTO player_skills (id, game, skill_level) VALUES (1, 'Game1', 5), (2, 'Game1', 10), (3, 'Game2', 8);
What is the distribution of player skill levels for a specific game?
SELECT game, skill_level, COUNT(*) as count FROM player_skills GROUP BY game, skill_level;
gretelai_synthetic_text_to_sql
CREATE TABLE RegulatoryActions (country VARCHAR(255), action_date DATE); INSERT INTO RegulatoryActions (country, action_date) VALUES ('USA', '2021-01-01'), ('USA', '2021-03-01'), ('China', '2021-02-01'), ('Japan', '2021-04-01'), ('India', '2021-05-01');
Display the top 3 countries with the most regulatory actions in descending order
SELECT country, COUNT(*) as total_actions FROM RegulatoryActions GROUP BY country ORDER BY total_actions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, threat_type VARCHAR(50), date DATE, region VARCHAR(50)); INSERT INTO threat_intelligence (id, threat_type, date, region) VALUES (1, 'Cyber', '2021-01-01', 'Asia'), (2, 'Physical', '2021-06-01', 'Europe');
Delete all threat intelligence records that are older than 6 months and from the Asia region?
DELETE FROM threat_intelligence WHERE region = 'Asia' AND date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), JobRole varchar(50), Salary int); INSERT INTO Employees (EmployeeID, FirstName, LastName, JobRole, Salary) VALUES (1, 'John', 'Doe', 'Software Engineer', 50000); INSERT INTO Employees (EmployeeID, FirstName, LastName, JobRole, Salary) VALUES (2, 'Jane', 'Smith', 'HR Manager', 70000);
What is the average salary for employees in each job role, ordered by average salary?
SELECT JobRole, AVG(Salary) as AvgSalary FROM Employees GROUP BY JobRole ORDER BY AvgSalary DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, category VARCHAR(20), year INT); INSERT INTO Artworks (id, category, year) VALUES (1, 'modern', 1998), (2, 'contemporary', 2002), (3, 'classic', 1800), (4, 'modern', 2005), (5, 'classic', 1920);
Find the total number of artworks in the 'modern' category that were created after 2000.
SELECT COUNT(*) FROM Artworks WHERE category = 'modern' AND year > 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicMeatImports (id INT, country VARCHAR(50), year INT, quantity INT); INSERT INTO OrganicMeatImports (id, country, year, quantity) VALUES (1, 'Spain', 2020, 200), (2, 'Spain', 2021, 300), (3, 'Italy', 2020, 250), (4, 'Italy', 2021, 275);
Find the number of organic meat products imported from Spain in 2021.
SELECT COUNT(*) FROM OrganicMeatImports WHERE country = 'Spain' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE asia_complaints (complaint_id INT, subscriber_type VARCHAR(10), country VARCHAR(10), complaint VARCHAR(50));
List all customer complaints related to mobile services in the Asia region
SELECT complaint FROM asia_complaints WHERE subscriber_type = 'mobile' AND country IN (SELECT country FROM country WHERE region = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE PolarBearSightings (location VARCHAR(50), year INT, sightings INT); INSERT INTO PolarBearSightings (location, year, sightings) VALUES ('Svalbard', 2020, 350);
How many polar bear sightings were recorded in Svalbard in 2020?
SELECT sightings FROM PolarBearSightings WHERE location = 'Svalbard' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE microfinance_institutions (institution_id INT, institution_name VARCHAR(50));
List all socially responsible lending initiatives by microfinance institutions
CREATE TABLE lending_initiatives (initiative_id INT, initiative_name VARCHAR(50), institution_id INT); SELECT institution_name, initiative_name FROM microfinance_institutions
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, region VARCHAR(20)); CREATE TABLE transactions (id INT, customer_id INT, transaction_date DATE); INSERT INTO customers (id, region) VALUES (1, 'Middle East and Africa'); INSERT INTO transactions (id, customer_id, transaction_date) VALUES (1, 1, '2022-03-01');
Find the total number of transactions made by customers from the 'Middle East and Africa' region in the last quarter.
SELECT COUNT(*) FROM transactions JOIN customers ON transactions.customer_id = customers.id WHERE customers.region = 'Middle East and Africa' AND transaction_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY AUTO_INCREMENT, Name VARCHAR(100), Genre VARCHAR(50));
Insert a new artist named 'Maria Gonzalez' who produces 'Latin' music
INSERT INTO Artists (Name, Genre) VALUES ('Maria Gonzalez', 'Latin');
gretelai_synthetic_text_to_sql
CREATE TABLE mission_destinations (mission_name VARCHAR(50), mission_status VARCHAR(50), destination VARCHAR(50), launch_date DATE);
List all unique mission destinations and their respective launch dates.
SELECT destination, MIN(launch_date) as first_launch_date FROM mission_destinations GROUP BY destination;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_advisors (advisor_id INT, name VARCHAR(50), email VARCHAR(50)); CREATE TABLE clients (client_id INT, advisor_id INT, name VARCHAR(50), account_type VARCHAR(50));
Delete records of financial advisors who are not associated with any clients from the financial_advisors table.
DELETE FROM financial_advisors WHERE advisor_id NOT IN (SELECT DISTINCT advisor_id FROM clients);
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption_by_sector (id INT, sector TEXT, location TEXT, consumption FLOAT); INSERT INTO energy_consumption_by_sector (id, sector, location, consumption) VALUES (1, 'industrial', 'Sydney', 1200.0), (2, 'residential', 'Sydney', 500.0);
What is the average energy consumption of industrial buildings in Sydney?
SELECT AVG(consumption) FROM energy_consumption_by_sector WHERE sector = 'industrial' AND location = 'Sydney';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(255), incidents INT, region VARCHAR(255)); INSERT INTO vessels (id, name, incidents, region) VALUES (1, 'Southern Harvester', 2, 'Southern Ocean');
What is the total number of vessels that have been involved in incidents of ocean acidification in the Southern Ocean?
SELECT SUM(incidents) FROM vessels WHERE region = 'Southern Ocean' AND incidents > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE attractions (attraction_id INT, name TEXT, country TEXT, certified BOOLEAN); INSERT INTO attractions (attraction_id, name, country, certified) VALUES (1, 'Victoria Falls', 'Zambia', TRUE), (2, 'Mount Kilimanjaro', 'Tanzania', TRUE), (3, 'Pyramids of Giza', 'Egypt', FALSE);
Which African countries have the most tourist attractions with sustainable tourism certifications?
SELECT country, COUNT(*) as certified_attractions FROM attractions WHERE certified = TRUE GROUP BY country ORDER BY certified_attractions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Navy_Equipment (equipment VARCHAR(50), year INT, quantity INT);
Delete all records related to 'Helicopters' sold in 2022 from the Navy_Equipment table.
DELETE FROM Navy_Equipment WHERE equipment = 'Helicopters' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (station_id INT, city VARCHAR(50));
What is the total number of charging stations for electric vehicles in Vancouver, Canada?
SELECT COUNT(*) FROM charging_stations WHERE city = 'Vancouver';
gretelai_synthetic_text_to_sql
CREATE TABLE young_forest (id INT, species VARCHAR(255), age INT); INSERT INTO young_forest (id, species, age) VALUES (1, 'Pine', 5), (2, 'Oak', 7), (3, 'Maple', 6);
How many trees are there in the young_forest table for the species 'Maple'?
SELECT COUNT(*) FROM young_forest WHERE species = 'Maple';
gretelai_synthetic_text_to_sql
CREATE TABLE District (did INT, district_name VARCHAR(255)); INSERT INTO District (did, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Harborside'); CREATE TABLE WasteData (wid INT, did INT, year INT, amount INT); INSERT INTO WasteData (wid, did, year, amount) VALUES (1, 1, 2018, 5000), (2, 1, 2019, 5500), (3, 2, 2018, 4000), (4, 2, 2019, 4400), (5, 3, 2018, 6000), (6, 3, 2019, 6600);
What are the total waste generation figures for each district in 'CityA'?
SELECT District.district_name, SUM(WasteData.amount) as total_waste FROM District INNER JOIN WasteData ON District.did = WasteData.did GROUP BY District.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE offenses (id INT, victim_id INT, offense_type VARCHAR(50), date_of_offense DATE);
Delete an offense from the "offenses" table
DELETE FROM offenses WHERE id = 2002;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_habitats (id INT PRIMARY KEY, habitat_name VARCHAR, num_animals INT); INSERT INTO animal_habitats (id, habitat_name, num_animals) VALUES (1, 'Rainforest', 500), (2, 'Savannah', 300), (3, 'Mountains', 200);
Update animal count in 'animal_habitats' for Rainforest
UPDATE animal_habitats SET num_animals = 600 WHERE habitat_name = 'Rainforest';
gretelai_synthetic_text_to_sql
CREATE TABLE customer_usage (customer_id INT, service VARCHAR(10), data_usage FLOAT, usage_duration INT);
Create a table named 'customer_usage' to store data on broadband and mobile customers' usage patterns
CREATE TABLE customer_usage (customer_id INT, service VARCHAR(10), data_usage FLOAT, usage_duration INT);
gretelai_synthetic_text_to_sql
CREATE TABLE BioprocessEngineering (project_id INT, completion_date DATE); INSERT INTO BioprocessEngineering (project_id, completion_date) VALUES (1, '2020-01-01'), (2, '2019-12-31'), (3, '2021-03-15'), (4, '2018-06-20'), (5, '2020-12-27');
How many bioprocess engineering projects have been completed in the last 3 years?
SELECT COUNT(project_id) FROM BioprocessEngineering WHERE completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, event_name VARCHAR(100), event_type VARCHAR(50), location VARCHAR(100), start_time TIMESTAMP); CREATE TABLE Tickets (id INT, ticket_number INT, event_id INT, purchaser_name VARCHAR(100), purchase_date DATE);
What is the number of tickets sold per day, for events in Chicago, in the month of June?
SELECT DATE(purchase_date) as purchase_day, COUNT(ticket_number) as tickets_sold FROM Events JOIN Tickets ON Events.id = Tickets.event_id WHERE location LIKE '%Chicago%' AND DATE_TRUNC('month', purchase_date) = DATE_TRUNC('month', '2022-06-01') GROUP BY purchase_day;
gretelai_synthetic_text_to_sql
CREATE TABLE mlb_players (player_id INT, name VARCHAR(50), team VARCHAR(50), homeruns INT); INSERT INTO mlb_players (player_id, name, team, homeruns) VALUES (1, 'Mike Trout', 'Los Angeles Angels', 45); INSERT INTO mlb_players (player_id, name, team, homeruns) VALUES (2, 'Aaron Judge', 'New York Yankees', 52);
How many home runs has each baseball player hit in the MLB?
SELECT name, homeruns FROM mlb_players;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_stats (hotel_id INT, region VARCHAR(50), num_unique_users INT);
Update the virtual_tour_stats_table to include the region for each hotel
UPDATE virtual_tour_stats vts INNER JOIN hotels h ON vts.hotel_id = h.hotel_id SET vts.region = h.region;
gretelai_synthetic_text_to_sql
CREATE TABLE car_claims (policyholder_name TEXT, claim_amount INTEGER); CREATE TABLE home_claims (policyholder_name TEXT, claim_amount INTEGER); INSERT INTO car_claims VALUES ('Alice', 500), ('Bob', 200), ('Carol', 300), ('Dave', 400); INSERT INTO home_claims VALUES ('Bob', 1000), ('Eve', 800), ('Alice', 900);
Show the total claim amounts for policyholders who have made claims in both the car and home insurance categories.
SELECT SUM(claim_amount) FROM car_claims WHERE policyholder_name IN (SELECT policyholder_name FROM home_claims);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, country TEXT, rd_expenditure FLOAT); INSERT INTO company (id, name, country, rd_expenditure) VALUES (1, 'ABC Pharma', 'UK', 12000000); INSERT INTO company (id, name, country, rd_expenditure) VALUES (2, 'XYZ Labs', 'UK', 20000000); INSERT INTO company (id, name, country, rd_expenditure) VALUES (3, 'DEF Industries', 'USA', 15000000);
What is the average R&D expenditure for companies located in the United Kingdom?
SELECT AVG(rd_expenditure) FROM company WHERE country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE production (well_id INT, type VARCHAR(10), region VARCHAR(50), quantity INT); INSERT INTO production (well_id, type, region, quantity) VALUES (1, 'Oil', 'Northern', 1000), (2, 'Gas', 'Northern', 2000), (3, 'Oil', 'Southern', 3000);
Calculate the total production in the Northern region for each type of resource
SELECT type, SUM(quantity) as total_production FROM production WHERE region = 'Northern' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(100), country_1 VARCHAR(50), country_2 VARCHAR(50), duration INT); INSERT INTO space_missions (mission_id, mission_name, country_1, country_2, duration) VALUES (1, 'Mars Rover', 'USA', 'Russia', 120), (2, 'ISS', 'Russia', 'USA', 360), (3, 'Luna', 'Russia', 'None', 180), (4, 'Apollo', 'USA', 'None', 150), (5, 'Artemis', 'USA', 'Canada', 200);
What is the total duration of space missions with international partners?
SELECT SUM(duration) FROM space_missions WHERE country_2 IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE worker_salaries (id INT, region VARCHAR(255), industry VARCHAR(255), salary DECIMAL(10,2));
What is the minimum salary of a worker in the 'Aerospace' industry in the 'East' region?
SELECT MIN(salary) FROM worker_salaries WHERE region = 'East' AND industry = 'Aerospace';
gretelai_synthetic_text_to_sql
CREATE TABLE sales(id INT, item VARCHAR(255), price DECIMAL(10,2), quantity INT); INSERT INTO sales(id, item, price, quantity) VALUES (1, 'Salad', 10.00, 50), (2, 'Sandwich', 12.00, 75), (3, 'Pasta', 15.00, 25);
What is the average price of items in the top 20% of sales?
SELECT AVG(price) as avg_price FROM (SELECT price, RANK() OVER (ORDER BY quantity DESC) as rank FROM sales) subquery WHERE rank <= COUNT(*) * 0.2;
gretelai_synthetic_text_to_sql
CREATE TABLE Charging_Stations_South_Korea (Id INT, Type VARCHAR(50), Location VARCHAR(50)); INSERT INTO Charging_Stations_South_Korea (Id, Type, Location) VALUES (1, 'Public', 'South Korea'), (2, 'Private', 'South Korea'), (3, 'Public', 'Japan');
How many charging stations are there in South Korea?
SELECT COUNT(*) FROM Charging_Stations_South_Korea WHERE Type = 'Public' OR Type = 'Private';
gretelai_synthetic_text_to_sql
CREATE TABLE participatory_budgeting (project VARCHAR(50), budget INT); INSERT INTO participatory_budgeting (project, budget) VALUES ('Project A', 120000), ('Project B', 90000), ('Project C', 150000);
What is the total number of participatory budgeting projects with a budget over $100,000?
SELECT COUNT(*) FROM participatory_budgeting WHERE budget > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title TEXT, publish_date DATE); CREATE VIEW news_summary AS SELECT id, title, publish_date, EXTRACT(MONTH FROM publish_date) as month, EXTRACT(YEAR FROM publish_date) as year FROM news_articles;
How many news articles were published on the website in each month of 2021?
SELECT month, COUNT(*) as num_articles FROM news_summary WHERE year = 2021 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors_patents; CREATE TABLE if not exists biosensors_patents.patents (id INT, name VARCHAR(100), country VARCHAR(50), technology VARCHAR(50), filed_year INT); INSERT INTO biosensors_patents.patents (id, name, country, technology, filed_year) VALUES (1, 'Biosensor A', 'USA', 'Optical', 2020), (2, 'Biosensor B', 'China', 'Electrochemical', 2019), (3, 'Biosensor C', 'USA', 'Mass Spectrometry', 2018), (4, 'Biosensor D', 'China', 'Optical', 2021);
Display the number of biosensor technology patents filed by year for the USA and China.
SELECT country, filed_year, COUNT(*) as patent_count FROM biosensors_patents.patents WHERE country IN ('USA', 'China') GROUP BY country, filed_year ORDER BY filed_year;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (account_id INT, customer_id INT, balance DECIMAL(10, 2), risk_level VARCHAR(50)); INSERT INTO accounts (account_id, customer_id, balance, risk_level) VALUES (1, 1, 15000.00, 'high'), (2, 2, 2000.00, 'low'), (3, 3, 5000.00, 'medium');
List all high-risk accounts with a balance greater than $10,000.
SELECT * FROM accounts WHERE balance > 10000 AND risk_level = 'high';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates_africa (material TEXT, rate REAL, year INTEGER, area TEXT);
What are the recycling rates for glass and metal, in 2020, in urban areas in Africa?
SELECT material, rate FROM recycling_rates_africa WHERE area = 'Africa' AND year = 2020 AND material IN ('glass', 'metal');
gretelai_synthetic_text_to_sql
CREATE TABLE MaxCapacityProjects (id INT, project_name TEXT, location TEXT, project_type TEXT, capacity INT);
What is the maximum capacity for a single renewable energy project in 'MaxCapacityProjects' table?
SELECT MAX(capacity) FROM MaxCapacityProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), PRIMARY KEY (name)); INSERT INTO neighborhoods (name, city, state, country) VALUES ('Wynwood', 'Miami', 'FL', 'USA');
Rank the neighborhoods in Miami, Florida by the total square footage of all listings, in descending order.
SELECT name, SUM(square_footage) as total_sqft FROM real_estate_listings WHERE city = 'Miami' GROUP BY name ORDER BY total_sqft DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(50), habitat VARCHAR(50), population INT);CREATE TABLE conservation_efforts (id INT PRIMARY KEY, species_id INT, effort VARCHAR(50), start_date DATE, end_date DATE);
What conservation efforts have been made for seagrass species?
SELECT m.name, c.effort FROM marine_species m JOIN conservation_efforts c ON m.id = c.species_id WHERE m.name = 'Seagrass';
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (id INT, name TEXT, state TEXT, water_savings FLOAT); INSERT INTO conservation_initiatives (id, name, state, water_savings) VALUES (1, 'Water-efficient appliances', 'Arizona', 10), (2, 'Rainwater harvesting', 'Arizona', 5), (3, 'Greywater reuse', 'Arizona', 7); CREATE TABLE water_usage (id INT, location TEXT, usage FLOAT); INSERT INTO water_usage (id, location, usage) VALUES (1, 'Phoenix', 150), (2, 'Tucson', 120), (3, 'Scottsdale', 130);
What is the effect of water conservation initiatives on water usage in Arizona?
SELECT a.name, AVG(b.usage) as avg_usage FROM conservation_initiatives a INNER JOIN water_usage b ON a.state = b.location GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (country TEXT, regulatory_status TEXT); INSERT INTO regulations (country, regulatory_status) VALUES ('United States', 'Partially regulated'), ('Canada', 'Under development'), ('Australia', 'Fully regulated');
What is the regulatory status of smart contracts in the United States, Canada, and Australia?
SELECT country, regulatory_status FROM regulations WHERE country IN ('United States', 'Canada', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_id INT, name VARCHAR(50), co2_emission_per_item FLOAT); CREATE TABLE ingredients (ingredient_id INT, name VARCHAR(50), supplier_location VARCHAR(50), co2_emission_per_kg FLOAT); CREATE TABLE recipe (menu_id INT, ingredient_id INT, quantity FLOAT); CREATE TABLE supplier_distances (supplier_location VARCHAR(50), restaurant_location VARCHAR(50), distance FLOAT);
What is the total CO2 emission of each menu item, taking into account the distance from the supplier to the restaurant?
SELECT m.name, SUM(i.co2_emission_per_kg * r.quantity * d.distance / 100) as total_co2_emission FROM menu_items m JOIN recipe r ON m.menu_id = r.menu_id JOIN ingredients i ON r.ingredient_id = i.ingredient_id JOIN supplier_distances d ON i.supplier_location = d.supplier_location GROUP BY m.menu_id;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE timber_harvest (harvest_id INT, region_id INT, year INT, volume INT); INSERT INTO timber_harvest (harvest_id, region_id, year, volume) VALUES (1, 3, 2020, 1200), (2, 1, 2020, 1500), (3, 2, 2020, 1700), (4, 4, 2020, 2000), (5, 3, 2020, 2500), (6, 1, 2020, 3000);
What is the total volume of timber harvested in each region for the year 2020, ordered by the total volume in descending order?
SELECT region_id, SUM(volume) AS total_volume FROM timber_harvest WHERE year = 2020 GROUP BY region_id ORDER BY total_volume DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE DeforestationData (country VARCHAR(50), year INT, deforestation_rate FLOAT, population_growth FLOAT);
What is the correlation between deforestation rates and population growth in Latin America and the Caribbean between 1990 and 2020?
SELECT CORR(deforestation_rate, population_growth) FROM DeforestationData WHERE country LIKE 'Latin America%' OR country LIKE 'Caribbean%' AND year BETWEEN 1990 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE military_threats (threat_id INT, country VARCHAR(255), level VARCHAR(255), threat_date DATE);
List the top 3 countries with the highest number of military threats in the last 3 months
SELECT country, COUNT(*) as num_threats FROM military_threats WHERE threat_date >= DATE(NOW()) - INTERVAL 3 MONTH GROUP BY country ORDER BY num_threats DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_inventory (vehicle_id INT, vehicle_type VARCHAR(10)); INSERT INTO vehicle_inventory (vehicle_id, vehicle_type) VALUES (1, 'Bus'), (2, 'Train'), (3, 'Bus'), (4, 'Tram');
Count the number of vehicles of each type
SELECT vehicle_type, COUNT(*) as number_of_vehicles FROM vehicle_inventory GROUP BY vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT); INSERT INTO well_production (well_id, measurement_date, production_rate) VALUES (1, '2022-01-01', 500), (1, '2022-02-01', 550), (2, '2022-01-01', 700), (2, '2022-02-01', 650);
Which wells had an increase in production rate between January and February?
SELECT a.well_id FROM well_production a JOIN well_production b ON a.well_id = b.well_id WHERE a.measurement_date = '2022-01-01' AND b.measurement_date = '2022-02-01' AND b.production_rate > a.production_rate
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), industry VARCHAR(50), location VARCHAR(50)); INSERT INTO company (id, name, industry, location) VALUES (1, 'GenTech', 'Genetic Research', 'San Francisco'); INSERT INTO company (id, name, industry, location) VALUES (2, 'BioEngineer', 'Bioprocess Engineering', 'Boston'); INSERT INTO company (id, name, industry, location) VALUES (3, 'BioSolutions', 'Bioprocess Engineering', 'Seattle'); CREATE TABLE funding (company_id INT, round VARCHAR(50), amount FLOAT); INSERT INTO funding (company_id, round, amount) VALUES (1, 'Series A', 5000000); INSERT INTO funding (company_id, round, amount) VALUES (1, 'Series B', 15000000); INSERT INTO funding (company_id, round, amount) VALUES (2, 'Seed', 2000000); INSERT INTO funding (company_id, round, amount) VALUES (3, 'Series A', 7000000);
Calculate the total funding for all genetic research companies.
SELECT c.industry, ROUND(SUM(f.amount), 2) as total_funding FROM company c JOIN funding f ON c.id = f.company_id WHERE c.industry = 'Genetic Research' GROUP BY c.industry
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_image (id INT, field_id INT, image_url TEXT, anomaly BOOLEAN, timestamp TIMESTAMP);
Insert new records into the satellite image table for the past week with no anomalies.
INSERT INTO satellite_image (field_id, image_url, anomaly, timestamp) SELECT f.id, 'https://example.com/image.jpg', false, s.timestamp FROM field f CROSS JOIN generate_series(NOW() - INTERVAL '1 week', NOW(), INTERVAL '1 day') s(timestamp);
gretelai_synthetic_text_to_sql
CREATE TABLE product_sales (product_id INT, sale_date DATE, units_sold INT); INSERT INTO product_sales (product_id, sale_date, units_sold) VALUES (1, '2021-01-01', 100), (1, '2021-02-01', 120), (1, '2021-03-01', 150), (2, '2021-01-01', 75), (2, '2021-02-01', 85), (2, '2021-03-01', 95), (3, '2021-01-01', 130), (3, '2021-02-01', 145), (3, '2021-03-01', 160), (4, '2021-01-01', 80), (4, '2021-02-01', 85), (4, '2021-03-01', 90), (5, '2021-01-01', 60), (5, '2021-02-01', 65), (5, '2021-03-01', 70), (6, '2021-01-01', 90), (6, '2021-02-01', 95), (6, '2021-03-01', 100);
How many units of each cosmetic product were sold per month?
SELECT product_id, DATE_TRUNC('month', sale_date) as sale_month, SUM(units_sold) as monthly_sales FROM product_sales GROUP BY product_id, sale_month ORDER BY product_id, sale_month;
gretelai_synthetic_text_to_sql
CREATE TABLE support_tiers (subscriber_id INT, name VARCHAR(255), region VARCHAR(255), mobile_number VARCHAR(20), broadband_speed DECIMAL(10, 2), support_tier VARCHAR(255));
What is the total number of subscribers in each support tier?
SELECT support_tier, COUNT(*) AS num_subscribers FROM support_tiers GROUP BY support_tier;
gretelai_synthetic_text_to_sql
CREATE TABLE costs (county_id INT, year INT, cost INT);
Identify counties in Washington state with stagnant healthcare costs for 3 or more years.
SELECT county_id FROM costs WHERE year IN (2019, 2020, 2021, 2022) GROUP BY county_id HAVING COUNT(DISTINCT cost) < 2 AND county_id IN (SELECT county_id FROM costs WHERE state = 'Washington');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, organization TEXT, sector TEXT); INSERT INTO volunteers (id, name, organization, sector) VALUES (1, 'John Doe', 'UNICEF', 'Education'), (2, 'Jane Smith', 'Save the Children', 'Health');
How many volunteers have provided support in the health sector?
SELECT COUNT(*) FROM volunteers WHERE sector = 'Health';
gretelai_synthetic_text_to_sql
CREATE TABLE consumers (consumer_id INT, consumer_name TEXT); CREATE TABLE purchases (purchase_id INT, consumer_id INT, supplier_id INT, product_id INT, quantity INT);
Which consumers bought the most products from ethical suppliers?
SELECT consumers.consumer_name, SUM(quantity) FROM consumers JOIN purchases ON consumers.consumer_id = purchases.consumer_id JOIN suppliers ON purchases.supplier_id = suppliers.supplier_id WHERE suppliers.labor_practice = 'Ethical' GROUP BY consumers.consumer_name ORDER BY SUM(quantity) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, diagnosis TEXT, therapy_type TEXT, therapy_start_date DATE, country TEXT); INSERT INTO patients (patient_id, age, gender, diagnosis, therapy_type, therapy_start_date, country) VALUES (1, 35, 'Female', 'PTSD', 'CBT', '2021-06-01', 'Japan'); INSERT INTO patients (patient_id, age, gender, diagnosis, therapy_type, therapy_start_date, country) VALUES (2, 42, 'Male', 'Depression', 'DBT', '2022-01-01', 'Japan');
How many patients with PTSD have not received therapy in the last year in Japan?
SELECT COUNT(*) FROM patients WHERE diagnosis = 'PTSD' AND country = 'Japan' AND therapy_start_date < DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE CompanyFundings (company_id INT, funding_round VARCHAR(50), funding_amount INT); INSERT INTO CompanyFundings (company_id, funding_round, funding_amount) VALUES (1, 'Seed', 500000), (1, 'Series A', 2000000), (2, 'Seed', 750000), (2, 'Series A', 3000000);
What is the average funding amount by company and funding round?
SELECT company_id, funding_round, AVG(funding_amount) as avg_funding_amount FROM CompanyFundings GROUP BY company_id, funding_round;
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicleAdoption (City VARCHAR(50), Make VARCHAR(50), Model VARCHAR(50), Year INT, Adoption DECIMAL(5,2)); INSERT INTO ElectricVehicleAdoption (City, Make, Model, Year, Adoption) VALUES ('Los Angeles', 'Tesla', 'Model 3', 2020, 25.3), ('New York', 'Chevrolet', 'Bolt', 2020, 12.6), ('Beijing', 'BYD', 'e5', 2020, 18.8), ('Berlin', 'Audi', 'e-Tron', 2020, 10.5), ('Tokyo', 'Nissan', 'Leaf', 2020, 15.2);
What is the adoption rate of electric vehicles in each major city?
SELECT City, AVG(Adoption) as Avg_Adoption_Rate FROM ElectricVehicleAdoption GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscriptions (customer_id INT, subscription BOOLEAN); INSERT INTO broadband_subscriptions (customer_id, subscription) VALUES (1, TRUE), (2, FALSE), (3, TRUE); CREATE TABLE city_customers (customer_id INT, city VARCHAR(50)); INSERT INTO city_customers (customer_id, city) VALUES (1, 'Seattle'), (2, 'Bellevue'), (3, 'Seattle');
What is the percentage of mobile customers in each city who have broadband subscriptions?
SELECT mc.city, (COUNT(CASE WHEN bs.subscription = TRUE THEN 1 END) * 100.0 / COUNT(bs.customer_id)) AS percentage FROM city_customers cc JOIN broadband_subscriptions bs ON cc.customer_id = bs.customer_id JOIN mobile_customers mc ON cc.customer_id = mc.customer_id GROUP BY mc.city;
gretelai_synthetic_text_to_sql
CREATE TABLE expedition (org VARCHAR(20), species VARCHAR(50)); INSERT INTO expedition VALUES ('Ocean Explorer', 'Dolphin'), ('Ocean Explorer', 'Tuna'), ('Sea Discoverers', 'Shark'), ('Sea Discoverers', 'Whale'), ('Marine Investigators', 'Starfish');
List all unique marine species observed by expeditions, ordered alphabetically.
SELECT DISTINCT species FROM expedition ORDER BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_farms (id INT, name TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO salmon_farms (id, name, country, latitude, longitude) VALUES (1, 'Farm A', 'Scotland', 55.78456, -3.123456); INSERT INTO salmon_farms (id, name, country, latitude, longitude) VALUES (2, 'Farm B', 'Scotland', 56.54321, -4.234567); CREATE TABLE water_temperature (date DATE, farm_id INT, temperature DECIMAL(5,2)); INSERT INTO water_temperature (date, farm_id, temperature) VALUES ('2022-01-01', 1, 8.5); INSERT INTO water_temperature (date, farm_id, temperature) VALUES ('2022-01-01', 2, 9.2);
What is the maximum water temperature recorded for salmon farms in Scotland?
SELECT MAX(temperature) FROM water_temperature wt JOIN salmon_farms sf ON wt.farm_id = sf.id WHERE sf.country = 'Scotland';
gretelai_synthetic_text_to_sql
CREATE TABLE disinformation (id INT, detected_at TIMESTAMP, source VARCHAR, confirmed BOOLEAN); INSERT INTO disinformation (id, detected_at, source, confirmed) VALUES (1, '2021-01-01 12:00:00', 'WebsiteA', true); INSERT INTO disinformation (id, detected_at, source, confirmed) VALUES (2, '2021-01-02 13:00:00', 'WebsiteB', false);
How many instances of disinformation were detected in a specific time period?
SELECT COUNT(*) FROM disinformation WHERE detected_at BETWEEN '2021-01-01' AND '2021-01-07' AND confirmed = true;
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_farms (id INT, name TEXT, type TEXT, location TEXT, water_temp FLOAT); INSERT INTO salmon_farms (id, name, type, location, water_temp) VALUES (1, 'Farm F', 'Salmon', 'Norway', 6.0), (2, 'Farm G', 'Salmon', 'Canada', 2.5), (3, 'Farm H', 'Salmon', 'Scotland', 9.0);
List the names of salmon farms in countries with water temperatures below 10 degrees Celsius in January.
SELECT name FROM salmon_farms WHERE water_temp < 10.0 AND EXTRACT(MONTH FROM datetime('now', '-1 month')) = 1 AND location IN (SELECT location FROM salmon_farms WHERE water_temp < 10.0 GROUP BY location HAVING COUNT(*) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE production_sites (id INT, name TEXT, location TEXT, element TEXT); INSERT INTO production_sites (id, name, location, element) VALUES (1, 'Denison Mine', 'Canada', 'Europium'); INSERT INTO production_sites (id, name, location, element) VALUES (2, 'Mount Weld', 'Australia', 'Europium'); INSERT INTO production_sites (id, name, location, element) VALUES (3, 'Bayan Obo', 'China', 'Europium');
Count the number of Europium production sites in Canada and the United States.
SELECT COUNT(*) FROM production_sites WHERE location IN ('Canada', 'United States') AND element = 'Europium';
gretelai_synthetic_text_to_sql
ARTWORK(artwork_id, title, date_created, period, artist_id); ARTIST(artist_id, name, gender)
Find the number of artworks in the 'modern' period and their respective artist's gender
SELECT COUNT(a.artwork_id), g.gender FROM ARTWORK a INNER JOIN ARTIST g ON a.artist_id = g.artist_id WHERE a.period = 'modern' GROUP BY g.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Research (ResearchID int, ResearchName varchar(255), Location varchar(255), StartDate date, EndDate date, Budget int); INSERT INTO Research (ResearchID, ResearchName, Location, StartDate, EndDate, Budget) VALUES (1, 'AI ethics in healthcare', 'USA', '2022-01-01', '2022-12-31', 5000000), (2, 'AI ethics in finance', 'UK', '2022-01-01', '2022-12-31', 7000000);
What is the total number of ethical AI research projects and their budget in the year 2022?
SELECT 'Total projects', COUNT(*) as NumProjects, 'Total budget', SUM(Budget) as TotalBudget FROM Research WHERE YEAR(StartDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255), last_login DATETIME);
Delete users who have not logged in for over a year from the users table
DELETE FROM users WHERE last_login <= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql