context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE vehicle_types (type_id INT, type_name TEXT); CREATE TABLE fleet (vehicle_id INT, vehicle_type_id INT, license_plate TEXT); CREATE TABLE failures (failure_id INT, vehicle_id INT, failure_time TIMESTAMP); INSERT INTO vehicle_types VALUES (1, 'Bus'), (2, 'Tram'), (3, 'Train'); INSERT INTO fleet VALUES (1, 1, ...
What is the average time between failures for each vehicle type?
SELECT vehicle_types.type_name, AVG(TIMESTAMPDIFF(MINUTE, failures, LEAD(failures) OVER (PARTITION BY vehicle_id ORDER BY failures.failure_time))) AS avg_time_between_failures FROM fleet INNER JOIN vehicle_types ON fleet.vehicle_type_id = vehicle_types.type_id INNER JOIN failures ON fleet.vehicle_id = failures.vehicle_...
gretelai_synthetic_text_to_sql
CREATE TABLE Visitor_Engagement (id INT, visitor_id INT, museum_id INT, date DATE); CREATE TABLE Museums (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Visitor_Engagement (id, visitor_id, museum_id, date) VALUES (1, 1001, 1, '2022-03-22'), (2, 1002, 2, '2022-02-15'), (3, 1003, 3, '2021-12-17'), (4, 1004,...
How many visitors engaged with museums in Oceania in the last year?
SELECT COUNT(*) FROM Visitor_Engagement ve JOIN Museums m ON ve.museum_id = m.id WHERE m.region = 'Oceania' AND date >= '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE fans (fan_id INT, city VARCHAR(255), age INT, gender VARCHAR(10)); INSERT INTO fans (fan_id, city, age, gender) VALUES (1, 'City A', 25, 'Male'), (2, 'City A', 35, 'Female'), (3, 'City B', 20, 'Male'), (4, 'City B', 40, 'Female');
How many fans are over 30 years old in each city?
SELECT f.city, COUNT(*) as num_fans_over_30 FROM fans f WHERE f.age > 30 GROUP BY f.city;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT, created_at DATETIME); INSERT INTO articles (id, title, category, likes, created_at) VALUES (1, 'Climate crisis: 12 years to save the planet', 'climate change', 100, '2022-01-01 10:30:00');
Find the percentage of articles in the 'politics' category out of all articles.
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM articles) as politics_percentage FROM articles WHERE category = 'politics'
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling (id INT, vessel_name VARCHAR(50), port VARCHAR(50), handling_time INT); INSERT INTO cargo_handling (id, vessel_name, port, handling_time) VALUES (1, 'Seattle Voyager', 'Seattle', 8), (2, 'Seattle Voyager', 'Seattle', 10);
What is the average cargo handling time for vessels in port 'Seattle'?
SELECT AVG(handling_time) FROM cargo_handling WHERE port = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_tracking_4 (id INT, community TEXT, cases_per_month INT, month TEXT); INSERT INTO infectious_disease_tracking_4 (id, community, cases_per_month, month) VALUES (1, 'Community A', 10, 'January'), (2, 'Community B', 15, 'February'), (3, 'Underrepresented C', 20, 'March'), (4, 'Underrepresen...
What is the maximum number of infectious disease tracking cases in a month for historically underrepresented communities, grouped by community?
SELECT community, MAX(cases_per_month) FROM infectious_disease_tracking_4 WHERE community LIKE '%underrepresented%' GROUP BY community;
gretelai_synthetic_text_to_sql
CREATE TABLE Festivals (FestivalID INT, Name TEXT, Date DATE); INSERT INTO Festivals (FestivalID, Name, Date) VALUES (1, 'Durbar Festival', '2022-02-26'); INSERT INTO Festivals (FestivalID, Name, Date) VALUES (2, 'Argungu Fishing Festival', '2022-03-04');
What are the names and dates of traditional festivals in Nigeria?
SELECT Name, Date FROM Festivals WHERE Country = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, animal_type VARCHAR(50), size_km FLOAT); INSERT INTO habitats (id, animal_type, size_km) VALUES (1, 'Bird', 12.5);
What is the maximum size (in square kilometers) of a habitat for birds in the 'habitats' table?
SELECT MAX(size_km) FROM habitats WHERE animal_type = 'Bird';
gretelai_synthetic_text_to_sql
CREATE SCHEMA usersdata; CREATE TABLE user_followers(user_id INT, followers INT, content_interests VARCHAR(255), post_date DATE); INSERT INTO usersdata.user_followers (user_id, followers, content_interests, post_date) VALUES (1, 1200, 'art', '2022-01-01'); INSERT INTO usersdata.user_followers (user_id, followers, conte...
What was the minimum number of followers for users who posted content related to 'art' in the last week?
SELECT MIN(followers) FROM usersdata.user_followers WHERE post_date >= (SELECT CURDATE() - INTERVAL 7 DAY) AND content_interests LIKE '%art%';
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(10), City VARCHAR(50)); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (1, 30, 'Male', 'Sydney'); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (2, 35, 'Female', 'Melbourne'); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUE...
What is the average age of visitors who attended exhibitions in Sydney and Melbourne?
SELECT AVG(Visitors.Age) FROM Visitors INNER JOIN Attendance ON Visitors.VisitorID = Attendance.VisitorID INNER JOIN Exhibitions ON Attendance.ExhibitionID = Exhibitions.ExhibitionID WHERE Visitors.City IN ('Sydney', 'Melbourne');
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_name VARCHAR(255), state_abbreviation VARCHAR(255)); INSERT INTO states (state_name, state_abbreviation) VALUES ('Alabama', 'AL'), ('Alaska', 'AK'), ('Arizona', 'AZ'); CREATE TABLE schools (school_name VARCHAR(255), school_type VARCHAR(255), state_abbreviation VARCHAR(255)); INSERT INTO schoo...
What is the number of public schools in each state and the percentage of those schools with free lunch programs?
SELECT s.state_abbreviation, COUNT(*) AS num_schools, 100.0 * SUM(CASE WHEN fl.has_free_lunch THEN 1 ELSE 0 END) / COUNT(*) AS pct_free_lunch FROM schools s JOIN free_lunch fl ON s.school_name = fl.school_name GROUP BY s.state_abbreviation;
gretelai_synthetic_text_to_sql
CREATE TABLE AccessibilityProjects (Project VARCHAR(50), Description TEXT, StartDate DATE, EndDate DATE); INSERT INTO AccessibilityProjects (Project, Description, StartDate, EndDate) VALUES ('Accessible Design', 'A project focused on accessible design for individuals with disabilities.', '2022-04-01', '2023-03-31');
Delete a record for a technology accessibility project in the AccessibilityProjects table.
DELETE FROM AccessibilityProjects WHERE Project = 'Accessible Design';
gretelai_synthetic_text_to_sql
CREATE TABLE MultimodalMobility(AgeGroup VARCHAR(50), Mode VARCHAR(50), Usage FLOAT);
What is the breakdown of multimodal mobility usage by age group?
SELECT AgeGroup, Mode, SUM(Usage) FROM MultimodalMobility GROUP BY AgeGroup, Mode;
gretelai_synthetic_text_to_sql
CREATE TABLE arabian_sea_farms (id INT, name TEXT, salinity FLOAT);
What is the average salinity (in ppt) in fish farms in the Arabian Sea?
SELECT AVG(salinity) FROM arabian_sea_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_registration (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), registration_date DATE);
Find the number of volunteers who joined in 2021 from the 'volunteer_registration' table.
SELECT COUNT(*) FROM volunteer_registration WHERE YEAR(registration_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (name VARCHAR(50), tickets_sold INT, price DECIMAL(5,2)); INSERT INTO exhibitions (name, tickets_sold, price) VALUES ('Modern Art', 300, 20.00), ('Classic Art', 250, 15.00);
What was the total revenue from children's tickets for the Classic Art exhibition?
SELECT SUM(price * tickets_sold) FROM exhibitions WHERE name = 'Classic Art' AND tickets_sold = (SELECT SUM(tickets_sold) FROM tickets WHERE age_group = 'Child');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Gold Ridge', 'Melbourne, Australia'), (2, 'Silver Peak', 'Nevada, USA'), (3, 'Cerro Verde', 'Arequipa, Peru'); CREATE TABLE water_consumption (site_id INT, consumption_date DATE, a...
What is the total amount of water consumed by each mining site in 2020?
SELECT site_name, SUM(amount_consumed) as total_water_consumption FROM water_consumption JOIN mining_sites ON water_consumption.site_id = mining_sites.site_id WHERE EXTRACT(YEAR FROM consumption_date) = 2020 GROUP BY site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Programs (Program_ID INT, CO2_Emission_Reduction FLOAT, Program_Start_Date DATE); INSERT INTO Carbon_Offset_Programs (Program_ID, CO2_Emission_Reduction, Program_Start_Date) VALUES (1, 5000.0, '2020-01-01'), (2, 7000.0, '2020-01-15'), (3, 3000.0, '2019-12-01');
What is the total CO2 emission reduction for each carbon offset program in the past month?
SELECT Program_ID, CO2_Emission_Reduction FROM Carbon_Offset_Programs WHERE Program_Start_Date >= DATEADD(MONTH, -1, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE mortality_rates (id INT, country VARCHAR(50), year INT, rate DECIMAL(5,2)); INSERT INTO mortality_rates (id, country, year, rate) VALUES (1, 'Canada', 2017, 8.2), (2, 'Canada', 2016, 8.1);
What was the mortality rate in Canada in 2017?
SELECT rate FROM mortality_rates WHERE country = 'Canada' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(255), trip_duration INT); INSERT INTO tourism_stats (visitor_country, trip_duration) VALUES ('New Zealand', 25), ('New Zealand', 30), ('New Zealand', 35);
Show the top 3 longest tourist trips in New Zealand.
SELECT * FROM (SELECT visitor_country, trip_duration, ROW_NUMBER() OVER (ORDER BY trip_duration DESC) as rn FROM tourism_stats WHERE visitor_country = 'New Zealand') t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation (location_id INT, location_type VARCHAR(255), num_ambulances INT); INSERT INTO transportation (location_id, location_type, num_ambulances) VALUES (1, 'Rural County', 20), (2, 'Urban County', 50), (3, 'Suburban City', 30);
Increase the number of ambulances in Rural County by 10% in the transportation table.
UPDATE transportation SET num_ambulances = num_ambulances * 1.1 WHERE location_type = 'Rural County';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing.carbon_prices (country varchar(2), year int, price decimal(5,2)); INSERT INTO carbon_pricing.carbon_prices (country, year, price) VALUES ('FR', 2020, 30.5), ('FR', 2021, 32.0), ('DE', 2020, 28.0), ('DE', 2021, 30.2), ('IT', 2020, 25.0), ('IT', 2021, 27.5);
What are the carbon pricing for countries 'DE' and 'IT' in the 'carbon_pricing' schema?
SELECT country, price FROM carbon_pricing.carbon_prices WHERE country IN ('DE', 'IT');
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (location TEXT, month INTEGER, year INTEGER, temperature REAL);
What is the minimum temperature recorded in Iceland during December across all years?
SELECT MIN(temperature) FROM WeatherData WHERE location = 'Iceland' AND month = 12;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR(255), conservation_status VARCHAR(50), ocean VARCHAR(50)); INSERT INTO marine_species (name, conservation_status, ocean) VALUES ('California Sea Lion', 'Vulnerable', 'Pacific'), ('Green Sea Turtle', 'Endangered', 'Pacific');
Identify the number of marine species in the Pacific Ocean with a vulnerable conservation status.'
SELECT COUNT(*) FROM marine_species WHERE conservation_status = 'Vulnerable' AND ocean = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (dc_id INT, dc_company VARCHAR(50), dc_country VARCHAR(50)); INSERT INTO defense_contracts (dc_id, dc_company, dc_country) VALUES (1, 'Company A', 'United States'), (2, 'Company B', 'United States'), (3, 'Company C', 'Canada');
What is the minimum number of defense contracts signed by a single company in the United States?
SELECT MIN(dc_count) FROM (SELECT COUNT(*) AS dc_count FROM defense_contracts WHERE dc_country = 'United States' GROUP BY dc_company) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255), launch_date DATE, cost INT); INSERT INTO Spacecraft (id, name, manufacturer, launch_date, cost) VALUES (1, 'Starship', 'SpaceCorp', '2019-01-01', 10000000); INSERT INTO Spacecraft (id, name, manufacturer, launch_date, cost) VALUES (2, 'Falco...
What was the total cost of spacecraft manufactured by SpaceCorp with a launch date in 2019?
SELECT SUM(cost) FROM Spacecraft WHERE manufacturer = 'SpaceCorp' AND YEAR(launch_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (community_id INT PRIMARY KEY, community_name TEXT, region TEXT); INSERT INTO indigenous_communities (community_id, community_name, region) VALUES (1, 'Inuit Community A', 'Arctic Circle');
find the number of indigenous communities in the arctic circle
SELECT COUNT(*) FROM indigenous_communities WHERE region = 'Arctic Circle';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Lakers'); CREATE TABLE games (game_id INT, season_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT); INSERT INTO games (game_id, season_id, home_team_id, away_team_id, home_tea...
How many games were won by the Lakers in the current season?
SELECT COUNT(*) FROM games WHERE (home_team_id = (SELECT team_id FROM teams WHERE team_name = 'Lakers') AND home_team_score > away_team_score) OR (away_team_id = (SELECT team_id FROM teams WHERE team_name = 'Lakers') AND away_team_score > home_team_score);
gretelai_synthetic_text_to_sql
CREATE TABLE college (college_name TEXT); INSERT INTO college (college_name) VALUES ('College of Science'), ('College of Arts'), ('College of Business'); CREATE TABLE research_grants (grant_id INTEGER, college_name TEXT, grant_year INTEGER, grant_amount INTEGER); INSERT INTO research_grants (grant_id, college_name, gra...
What is the total number of research grants awarded to each college, broken down by year?
SELECT college_name, grant_year, SUM(grant_amount) FROM research_grants GROUP BY college_name, grant_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name TEXT, nationality TEXT, birth_year INT, death_year INT); INSERT INTO Artists (id, name, nationality, birth_year, death_year) VALUES (1, 'Claude Monet', 'French', 1840, 1926), (2, 'Paul Cezanne', 'French', 1839, 1906); CREATE TABLE Artworks (id INT, title TEXT, artist_id INT, price I...
What is the total value of artworks created by artists who lived in the 19th century?
SELECT SUM(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.id WHERE Artists.birth_year <= 1900 AND Artists.death_year >= 1800;
gretelai_synthetic_text_to_sql
CREATE TABLE city_bus_stops (bus_stop_id INT, bus_stop_name VARCHAR(255), latitude DECIMAL, longitude DECIMAL); INSERT INTO city_bus_stops (bus_stop_id, bus_stop_name, latitude, longitude) VALUES (1, 'Downtown', 40.7128, -74.0060), (2, 'Times Square', 40.7590, -73.9844), (3, 'Central Park', 40.7829, -73.9654), (4, 'Har...
Delete the bus stop with bus_stop_id 5 from the city_bus_stops table
DELETE FROM city_bus_stops WHERE bus_stop_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, enrollment_date DATE); INSERT INTO students (student_id, enrollment_date) VALUES (1, '2022-04-01'), (2, '2022-06-15'), (3, '2022-02-05'), (4, '2022-03-22'), (5, '2022-01-31'); CREATE TABLE courses (course_id INT, enrollment_date DATE); INSERT INTO courses (course_id, enrollment_da...
How many students have enrolled in open pedagogy courses in the last 3 months?
SELECT COUNT(student_id) FROM students INNER JOIN courses ON students.enrollment_date = courses.enrollment_date WHERE students.enrollment_date > DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE refineries (id INT PRIMARY KEY, name TEXT, location TEXT); CREATE TABLE refinery_inspections (id INT PRIMARY KEY, refinery_id INT, inspection_date DATE, inspector_id INT); CREATE TABLE inspectors (id INT PRIMARY KEY, name TEXT, certification_date DATE);
What are the names of refineries and their inspectors, filtered based on the inspectors' certification date being later than January 1, 2021?
SELECT r.name, i.name as inspector_name FROM refineries r JOIN refinery_inspections ri ON r.id = ri.refinery_id JOIN inspectors i ON ri.inspector_id = i.id WHERE i.certification_date > '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE feedback (id INT, service VARCHAR(20), date DATE); INSERT INTO feedback (id, service, date) VALUES (1, 'Transportation', '2022-01-01'), (2, 'Transportation', '2022-02-01');
How many citizen feedback records were received in the last month for transportation services?
SELECT COUNT(*) FROM feedback WHERE service = 'Transportation' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousTests (Id INT, Manufacturer VARCHAR(100), TestDate DATE, Distance FLOAT); INSERT INTO AutonomousTests (Id, Manufacturer, TestDate, Distance) VALUES (1, 'Tesla', '2020-01-01', 150.0); INSERT INTO AutonomousTests (Id, Manufacturer, TestDate, Distance) VALUES (2, 'Waymo', '2020-02-01', 170.0); INSER...
What is the total distance driven in autonomous driving tests for each manufacturer in 2020?
SELECT Manufacturer, SUM(Distance) FROM AutonomousTests WHERE EXTRACT(YEAR FROM TestDate) = 2020 GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (project_id INT, project_name TEXT, project_start_date DATE, project_location TEXT);
Update the 'infrastructure_projects' table to set the 'project_start_date' to '2023-01-01' for all records where 'project_id' is 1
UPDATE infrastructure_projects SET project_start_date = '2023-01-01' WHERE project_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), sex VARCHAR(10), dob DATE);INSERT INTO patients (id, name, sex, dob) VALUES (1, 'John Doe', 'Male', '1980-01-01'); INSERT INTO patients (id, name, sex, dob) VALUES (2, 'Jane Smith', 'Female', '1990-02-02');
Find the number of male and female patients in the 'patients' table, separated by sex.
SELECT sex, COUNT(*) FROM patients GROUP BY sex;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerData (PlayerID INT, Name VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO PlayerData (PlayerID, Name, Age, Country) VALUES ('1', 'John Doe', '25', 'USA'), ('2', 'Jane Smith', '30', 'Canada'), ('3', 'Mike Johnson', '22', 'USA'), ('4', 'Sarah Lee', '28', 'Canada'), ('5', 'Lucas Martinez', '35', ...
List all records from the 'PlayerData' table where 'Age' is greater than 25
SELECT * FROM PlayerData WHERE Age > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE brand_transparency (brand_id INT, brand_name VARCHAR(255), transparency_score INT); CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255), country VARCHAR(255)); INSERT INTO brand_transparency (brand_id, brand_name, transparency_score) VALUES (1, 'Seoul Beauty', 65), (2, 'Tokyo Glam', 80), (3, 'Mumbai...
Which beauty brands have a transparency score lower than 70 and are based in Asia?
SELECT brand_name FROM brand_transparency INNER JOIN brands ON brand_transparency.brand_id = brands.brand_id WHERE transparency_score < 70 AND country IN ('South Korea', 'Japan', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (ID INT, Name VARCHAR(255)); CREATE TABLE Cases (ID INT, AttorneyID INT, Date DATE, Hours INT); INSERT INTO Attorneys (ID, Name) VALUES (1, 'John Smith'), (2, 'Jane Doe'), (3, 'Bob Johnson'); INSERT INTO Cases (ID, AttorneyID, Date, Hours) VALUES (1, 1, '2022-01-01', 10), (2, 2, '2022-02-15', 15)...
What is the total number of hours spent on cases in the last month, broken down by the responsible attorney?
SELECT AttorneyID, SUM(Hours) as TotalHours FROM Cases WHERE Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY AttorneyID;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation (id INT PRIMARY KEY, mode VARCHAR(50), country VARCHAR(50), energy_efficiency_index FLOAT);
Add a new record to the 'transportation' table with id 8001, mode 'Electric Rail', country 'India', and energy_efficiency_index 0.85
INSERT INTO transportation (id, mode, country, energy_efficiency_index) VALUES (8001, 'Electric Rail', 'India', 0.85);
gretelai_synthetic_text_to_sql
CREATE TABLE Exoplanets ( id INT, mission VARCHAR(255), mass FLOAT, planet_type VARCHAR(255) );
What is the average mass of exoplanets discovered by the TESS mission, and how many of these exoplanets are classified as super-Earths?
SELECT AVG(mass) as avg_mass, SUM(CASE WHEN planet_type = 'Super-Earth' THEN 1 ELSE 0 END) as super_earth_count FROM Exoplanets WHERE mission = 'TESS';
gretelai_synthetic_text_to_sql
CREATE TABLE Clinics (ClinicID INT, Name VARCHAR(50), Location POINT); INSERT INTO Clinics (ClinicID, Name, Location) VALUES (1, 'Primary Care Clinic A', POINT(-108.6351, 35.4674)); INSERT INTO Clinics (ClinicID, Name, Location) VALUES (2, 'Primary Care Clinic B', POINT(-108.5123, 35.6541)); CREATE TABLE Residents (Res...
What is the average distance to the nearest primary care clinic for residents in the "Navajo Nation" area?
SELECT AVG(ST_Distance(Residents.Location, Clinics.Location)) FROM Residents, Clinics WHERE ST_DWithin(Residents.Location, Clinics.Location, 50000) AND Residents.Location <> Clinics.Location AND Clinics.Name LIKE 'Primary Care%';
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice (case_id INT, case_type VARCHAR(10), location VARCHAR(20), facilitator VARCHAR(20)); INSERT INTO restorative_justice (case_id, case_type, location, facilitator) VALUES (5, 'community_conference', 'NY', 'John'), (6, 'restitution_session', 'CA', 'Sarah'), (7, 'community_conference', 'NY',...
What is the total number of cases in the restorative_justice table, grouped by case_type?
SELECT case_type, COUNT(*) FROM restorative_justice GROUP BY case_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Tunnels (TunnelID int, Name varchar(100), Location varchar(100), Elevation decimal(10,2)); INSERT INTO Tunnels VALUES (1, 'Tunnel A', 'Australia', 250); INSERT INTO Tunnels VALUES (2, 'Tunnel B', 'Australia', 300);
What is the minimum elevation for a tunnel in 'Australia'?
SELECT MIN(Elevation) FROM Tunnels WHERE Location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_sales (product VARCHAR(255), country VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255), organic BOOLEAN); CREATE TABLE countries (country VARCHAR(255), continent VARCHAR(255)); INSERT INTO countries (country, continen...
What is the total revenue of organic skincare products sold in the UK in 2021?
SELECT SUM(revenue) FROM cosmetics_sales JOIN cosmetics ON cosmetics_sales.product = cosmetics.product JOIN countries ON cosmetics_sales.country = countries.country WHERE cosmetics.product_category = 'Skincare' AND cosmetics.organic = true AND countries.country = 'UK' AND YEAR(sale_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name VARCHAR(255)); INSERT INTO fish_farms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'); CREATE TABLE fish_inventory (id INT, farm_id INT, species_id INT, biomass FLOAT); INSERT INTO fish_inventory (id, farm_id, species_id, biomass) VALUES (1, 1, 1, 1000), (2, 1, 2, 800...
What is the number of fish in each farm, ranked by the most to least?
SELECT f.name, COUNT(fi.id) as num_fish FROM fish_inventory fi JOIN fish_farms f ON fi.farm_id = f.id GROUP BY f.name ORDER BY COUNT(fi.id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (continent VARCHAR(255), consumption FLOAT, date DATE); INSERT INTO water_consumption (continent, consumption, date) VALUES ('Asia', 500000, '2022-01-01'); INSERT INTO water_consumption (continent, consumption, date) VALUES ('Africa', 600000, '2022-01-01');
What is the total water consumption in the top 3 water-consuming continents in the past year?
SELECT continent, SUM(consumption) FROM (SELECT continent, consumption, ROW_NUMBER() OVER (PARTITION BY continent ORDER BY consumption DESC) as rank FROM water_consumption WHERE date >= '2021-01-01' GROUP BY continent, consumption) subquery WHERE rank <= 3 GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Bikeshare (id INT, station VARCHAR(30), bike_type VARCHAR(20), total_bikes INT, last_inspection DATE); INSERT INTO Bikeshare (id, station, bike_type, total_bikes, last_inspection) VALUES (3, 'Harlem', 'Standard', 8, '2022-01-04'), (4, 'Brooklyn', 'Electric', 6, '2022-01-03');
How many electric bikes are there in total?
SELECT bike_type, SUM(total_bikes) as total_ebikes FROM Bikeshare WHERE bike_type = 'Electric' GROUP BY bike_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Asia-Pacific'), (2, 'CompanyB', 'Europe'), (3, 'CompanyD', 'Americas'); CREATE TABLE Materials (id INT, company_id INT, material VARCHAR(255), quantity INT); INSERT INTO Materials (i...
List all companies and their sustainable material usage in the 'Americas' region.
SELECT Companies.name, SUM(Materials.quantity) FROM Companies JOIN Materials ON Companies.id = Materials.company_id WHERE Companies.region = 'Americas' GROUP BY Companies.name;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (id INT, program VARCHAR(50), location VARCHAR(50), participants INT, improvementRate DECIMAL(3,2)); INSERT INTO HealthEquityMetrics (id, program, location, participants, improvementRate) VALUES (1, 'Healthy Eating', 'Los Angeles', 200, 0.35), (2, 'Physical Activity', 'San Francisco', 1...
What is the average improvement rate for the 'Physical Activity' program in each location?
SELECT program, location, AVG(improvementRate) as 'AverageImprovementRate' FROM HealthEquityMetrics WHERE program = 'Physical Activity' GROUP BY program, location;
gretelai_synthetic_text_to_sql
cargo(cargo_id, cargo_name, weight, volume, description)
Insert a new cargo record
INSERT INTO cargo (cargo_id, cargo_name, weight, volume, description) VALUES (2002, 'Electronics', 500, 100, 'Consumer electronics');
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT, sector VARCHAR(20), location VARCHAR(20), amount DECIMAL(10,2), date DATE); INSERT INTO waste_generation (id, sector, location, amount, date) VALUES (1, 'residential', 'New York City', 500, '2021-01-01');
Delete records of waste generation from the residential sector in New York City in 2021.
DELETE FROM waste_generation WHERE sector = 'residential' AND location = 'New York City' AND date = '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels_vt (id INT, segment TEXT, virtual_tour BOOLEAN); INSERT INTO hotels_vt (id, segment, virtual_tour) VALUES (1, 'boutique', true), (2, 'economy', false), (3, 'boutique', true);
What is the percentage of hotels in the 'boutique' segment with virtual tours?
SELECT segment, ROUND(100.0 * COUNT(*) / (SELECT COUNT(*) FROM hotels_vt WHERE segment = 'boutique'), 2) as percentage FROM hotels_vt WHERE segment = 'boutique' AND virtual_tour = true GROUP BY segment;
gretelai_synthetic_text_to_sql
CREATE TABLE Habitats (HabitatID INT, HabitatName TEXT, Location TEXT); INSERT INTO Habitats (HabitatID, HabitatName, Location) VALUES (1, 'Conservation Area A', 'Country A'); CREATE TABLE AnimalPopulation (AnimalID INT, AnimalName TEXT, HabitatID INT, Status TEXT); INSERT INTO AnimalPopulation (AnimalID, AnimalName, H...
Which endangered species have been introduced to 'Conservation Area A'?
SELECT AnimalName FROM AnimalPopulation WHERE HabitatID = 1 AND Status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE Production (item_id INT, material VARCHAR(255), weight DECIMAL(5,2), sustainable BOOLEAN); INSERT INTO Production (item_id, material, weight, sustainable) VALUES (1, 'Organic Cotton', 2.5, true), (1, 'Polyester', 1.5, false), (2, 'Recycled Wool', 3.0, true);
What is the total weight of unsustainable materials used in production?
SELECT SUM(weight) FROM Production WHERE sustainable = false;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT PRIMARY KEY, material VARCHAR(255), country VARCHAR(255), quantity INT); INSERT INTO fabrics (id, material, country, quantity) VALUES (1, 'cotton', 'Bangladesh', 500), (2, 'silk', 'China', 300), (3, 'wool', 'Australia', 700);
Delete records in the fabrics table where the country is 'China' and material is 'silk'
DELETE FROM fabrics WHERE country = 'China' AND material = 'silk';
gretelai_synthetic_text_to_sql
CREATE TABLE property (id INT, co_owner1 VARCHAR(255), co_owner2 VARCHAR(255), area VARCHAR(255)); INSERT INTO property (id, co_owner1, co_owner2, area) VALUES (1, 'Jane', 'Bob', 'urban'), (2, 'Alex', 'Lisa', 'rural'), (3, 'Sara', 'Mike', 'urban'), (4, 'Tom', 'Emily', 'urban');
What is the total number of properties co-owned by women in urban areas?
SELECT COUNT(*) FROM property WHERE (co_owner1 = 'Jane' OR co_owner1 = 'Sara' OR co_owner1 = 'Emily' OR co_owner2 = 'Jane' OR co_owner2 = 'Sara' OR co_owner2 = 'Emily') AND area = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), sales_volume INT);
Delete all mascaras with a sales volume lower than 500.
DELETE FROM products WHERE category = 'mascara' AND sales_volume < 500;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (FiscalYear INT, Program TEXT, Allocation DECIMAL); INSERT INTO Budget (FiscalYear, Program, Allocation) VALUES (2021, 'Education', 50000), (2021, 'Healthcare', 75000), (2022, 'Education', 60000);
What is the total budget allocated to education programs in the last fiscal year?
SELECT SUM(Allocation) FROM Budget WHERE Program = 'Education' AND FiscalYear = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE defendants (defendant_id INT, program_year INT, participated_restorative_program BOOLEAN); INSERT INTO defendants (defendant_id, program_year, participated_restorative_program) VALUES (1, 2020, true), (2, 2019, false), (3, 2020, false), (4, 2018, true);
Find the number of defendants who participated in restorative justice programs in 2020
SELECT COUNT(*) FROM defendants WHERE program_year = 2020 AND participated_restorative_program = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Feedback (Year INT, Service VARCHAR(255), Region VARCHAR(255), Score DECIMAL(3,2)); INSERT INTO Feedback (Year, Service, Region, Score) VALUES (2022, 'Bus', 'South', 8.25), (2022, 'Train', 'South', 8.50), (2022, 'Taxi', 'South', 8.75);
What is the average citizen feedback score for transportation services in the South region in 2022?
SELECT AVG(Score) FROM Feedback WHERE Year = 2022 AND Region = 'South' AND Service IN ('Bus', 'Train');
gretelai_synthetic_text_to_sql
CREATE TABLE coal_mining (id INT, mine_name VARCHAR(50), coal_amount INT, mining_date DATE); INSERT INTO coal_mining (id, mine_name, coal_amount, mining_date) VALUES (1, 'ABC Mine', 500, '2020-07-01'); INSERT INTO coal_mining (id, mine_name, coal_amount, mining_date) VALUES (2, 'XYZ Mine', 700, '2020-07-15');
Find the average amount of coal mined per day in the 'coal_mining' table for the month of July 2020.
SELECT AVG(coal_amount) FROM coal_mining WHERE mining_date >= '2020-07-01' AND mining_date <= '2020-07-31';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS rural_development;CREATE TABLE IF NOT EXISTS rural_development.agriculture_projects (name VARCHAR(255), id INT);INSERT INTO rural_development.agriculture_projects (name, id) VALUES ('sustainable_farming', 1), ('organic_gardening', 2), ('livestock_support', 3), ('aquaculture_development', 4);
What are the names of all agricultural projects in the 'rural_development' schema that have an 'id' greater than 3?
SELECT name FROM rural_development.agriculture_projects WHERE id > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE TruckSafetyTesting (id INT, rating INT, release_year INT); INSERT INTO TruckSafetyTesting (id, rating, release_year) VALUES (1, 4, 2019), (2, 5, 2020), (3, 5, 2021), (4, 4, 2018), (5, 3, 2019), (6, 5, 2022);
What is the maximum safety rating of trucks released in or after 2020?
SELECT MAX(rating) FROM TruckSafetyTesting WHERE release_year >= 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Shows (id INT, title VARCHAR(100), genre VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO TV_Shows (id, title, genre, budget) VALUES (1, 'The Witcher', 'Fantasy', 80000000.00), (2, 'Stranger Things', 'Sci-fi', 8000000.00), (3, 'The Crown', 'Drama', 130000000.00);
What is the average production budget for TV shows by genre?
SELECT genre, AVG(budget) FROM TV_Shows GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Offenders (OffenderID INT, OffenderName TEXT, FineAmount DECIMAL(10,2), OffenseDate DATE); INSERT INTO Offenders (OffenderID, OffenderName, FineAmount, OffenseDate) VALUES (1, 'John Doe', 500, '2022-01-10'); INSERT INTO Offenders (OffenderID, OffenderName, FineAmount, OffenseDate) VALUES (2, 'Jane Smith', ...
Who are the top 5 offenders by total fines in the last quarter in Texas?
SELECT OffenderName, SUM(FineAmount) as TotalFines FROM Offenders WHERE OffenseDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY OffenderName ORDER BY TotalFines DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE student_data (student_id INT, school_type VARCHAR(10));
What's the total number of students from both public and private schools in the 'student_data' table?
SELECT COUNT(student_id) FROM student_data WHERE school_type IN ('public', 'private');
gretelai_synthetic_text_to_sql
CREATE SCHEMA equipment_schema; CREATE TABLE equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(255)); CREATE TABLE maintenance (maintenance_id INT PRIMARY KEY, maintenance_cost INT, equipment_id INT, FOREIGN KEY (equipment_id) REFERENCES equipment(equipment_id)); INSERT INTO equipment (equipment_id, equip...
List the top 5 military equipment types with the highest maintenance costs
SELECT e.equipment_type, SUM(m.maintenance_cost) as total_cost FROM equipment e JOIN maintenance m ON e.equipment_id = m.equipment_id GROUP BY e.equipment_type ORDER BY total_cost DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (ID INT, Manufacturer VARCHAR(255), SafetyRating FLOAT); INSERT INTO Vehicles (ID, Manufacturer, SafetyRating) VALUES (1, 'Ferrari', 4.5), (2, 'Lamborghini', 4.3), (3, 'Seat', 4.1), (4, 'Skoda', 4.2);
What is the average safety rating for vehicles manufactured in Italy and Spain?
SELECT AVG(SafetyRating) FROM Vehicles WHERE Manufacturer IN ('Italy', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE rural_communities (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO rural_communities (id, name, country) VALUES (1, 'Makueni', 'Kenya'); CREATE TABLE infrastructure_projects (id INT, type VARCHAR(50), cost FLOAT, rural_community_id INT); INSERT INTO infrastructure_projects (id, type, cost, rura...
What is the total cost of all infrastructure projects in rural communities in Kenya, grouped by project type?
SELECT i.type, SUM(i.cost) as total_cost FROM infrastructure_projects i INNER JOIN rural_communities r ON i.rural_community_id = r.id WHERE r.country = 'Kenya' GROUP BY i.type;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (county TEXT, beds INTEGER); INSERT INTO hospitals (county, beds) VALUES ('Glacier', 500); CREATE TABLE residents (county TEXT, population INTEGER); INSERT INTO residents (county, population) VALUES ('Glacier', 10000);
What is the ratio of hospital beds to residents in rural county 'Glacier'?
SELECT (hospitals.beds / residents.population) * 100 AS bed_to_resident_ratio FROM hospitals JOIN residents ON hospitals.county = residents.county WHERE hospitals.county = 'Glacier';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, region VARCHAR(50), budget DECIMAL(10,2));
Calculate the average budget for habitat preservation in 'habitat_preservation' table
SELECT AVG(budget) FROM habitat_preservation;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite (id INT, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUES (1, 'Landsat 1', 'Earth Observation', 'Boeing', '1972-07-23'); INSERT INTO Satellite (id, name, type, manufacturer, launch_date) VALUE...
Which companies have manufactured more than 5 satellites of the type 'Earth Observation'?
SELECT m.name, m.country, COUNT(s.id) as satellite_count FROM Manufacturer m INNER JOIN Satellite s ON m.name = s.manufacturer WHERE s.type = 'Earth Observation' GROUP BY m.name, m.country HAVING COUNT(s.id) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(20), country VARCHAR(20), in_service BOOLEAN);
Delete all records in the 'military_equipment' table where 'equipment_type' is 'aircraft'
DELETE FROM military_equipment WHERE equipment_type = 'aircraft';
gretelai_synthetic_text_to_sql
CREATE TABLE UnionMembership (id INT, sector VARCHAR(255), members INT); INSERT INTO UnionMembership (id, sector, members) VALUES (1, 'Education', 5000);
What is the total number of Union members in the Education sector?
SELECT SUM(members) FROM UnionMembership WHERE sector = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE Design_Standards (Standard_ID INT, Standard_Name VARCHAR(50), Standard_Description TEXT); INSERT INTO Design_Standards (Standard_ID, Standard_Name, Standard_Description) VALUES (1, 'Drainage_System_1', '10-year design storm event'), (2, 'Drainage_System_2', '50-year design storm event'), (3, 'Bridge_Design...
What are the engineering design standards for drainage systems in the infrastructure database?
SELECT Standard_Description FROM Design_Standards WHERE Standard_Name LIKE '%Drainage%';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, Product VARCHAR(20), Quantity INT, Region VARCHAR(20)); INSERT INTO Sales VALUES (1, 'Fair Trade Coffee', 200, 'Europe'); INSERT INTO Sales VALUES (2, 'Fair Trade Tea', 300, 'Europe');
What is the total quantity of fair trade products sold in Europe?
SELECT SUM(Quantity) FROM Sales WHERE Product LIKE '%Fair Trade%' AND Region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id varchar(10), asset_name varchar(10)); INSERT INTO digital_assets (asset_id, asset_name) VALUES ('ETH', 'Ethereum'), ('BTC', 'Bitcoin'); CREATE TABLE transactions (transaction_id serial, asset_id varchar(10), transaction_amount numeric); INSERT INTO transactions (asset_id, transacti...
What is the total transaction amount for 'BTC'?
SELECT SUM(transaction_amount) FROM transactions WHERE asset_id = 'BTC';
gretelai_synthetic_text_to_sql
CREATE TABLE nyc_bus (ride_id INT, route_id INT, revenue INT); CREATE TABLE nyc_train (ride_id INT, route_id INT, revenue INT);
What is the total revenue for bus and train rides in New York?
SELECT SUM(revenue) FROM nyc_bus WHERE route_id < 10 UNION ALL SELECT SUM(revenue) FROM nyc_train WHERE route_id < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, price FLOAT, owner_id INT); CREATE TABLE owners (owner_id INT, name VARCHAR(255), gender VARCHAR(6)); INSERT INTO properties (property_id, price, owner_id) VALUES (1, 500000, 101), (2, 600000, 102), (3, 700000, 101); INSERT INTO owners (owner_id, name, gender) VALUES (101, 'Ali...
Find the number of co-owned properties by each gender.
SELECT owners.gender, COUNT(properties.property_id) FROM properties INNER JOIN owners ON properties.owner_id = owners.owner_id GROUP BY owners.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, state VARCHAR(2));CREATE TABLE investments (id INT, client_id INT, type VARCHAR(10), value FLOAT); INSERT INTO clients (id, state) VALUES (1, 'CA'), (2, 'NY'); INSERT INTO investments (id, client_id, type, value) VALUES (1, 1, 'real_estate', 500000), (2, 1, 'stocks', 300000), (3, 2, 'real_...
What is the total value of all real estate investments made by clients in California?
SELECT SUM(value) FROM investments i JOIN clients c ON i.client_id = c.id WHERE c.state = 'CA' AND i.type = 'real_estate';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, country TEXT, industry TEXT, industry_4_0 BOOLEAN, workforce_development BOOLEAN); INSERT INTO companies (id, name, country, industry, industry_4_0, workforce_development) VALUES (1, 'ABC Corp', 'Germany', 'Manufacturing', TRUE, TRUE), (2, 'DEF Corp', 'France', 'Manufacturing'...
Show the names of all companies that have implemented industry 4.0 technologies and have a strong focus on workforce development.
SELECT name FROM companies WHERE industry_4_0 = TRUE AND workforce_development = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO dishes (id, name, category, price) VALUES (1, 'Margherita Pizza', 'Pizza', 9.99), (2, 'Chicken Alfredo', 'Pasta', 12.49), (3, 'Vegetable Lasagna', 'Pasta', 10.99), (4, 'Eggplant Parmesan', 'Vegetarian', 11.99), (5, 'Ch...
List the names and prices of dishes that are not in the appetizer category and cost more than 15 dollars.
SELECT name, price FROM dishes WHERE category != 'Appetizer' AND price > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE ConsumerPreference (ConsumerID INT, ProductID INT, ProductName VARCHAR(50), Country VARCHAR(50)); INSERT INTO ConsumerPreference (ConsumerID, ProductID, ProductName, Country) VALUES (6, 301, 'Lipstick', 'Mexico'), (7, 302, 'Mascara', 'Mexico'), (8, 303, 'Foundation', 'Mexico'), (9, 304, 'Eyeshadow', 'Mexic...
Who are the top 3 consumers of cosmetic products in Mexico?
SELECT ConsumerName, COUNT(*) AS ProductCount FROM ConsumerPreference CP INNER JOIN Consumers C ON CP.ConsumerID = C.ConsumerID WHERE CP.Country = 'Mexico' GROUP BY ConsumerName ORDER BY ProductCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE company_innovation (company_id INT, sector VARCHAR(20), patent_count INT); INSERT INTO company_innovation (company_id, sector, patent_count) VALUES (1, 'technology', 3), (2, 'healthcare', 1), (3, 'technology', 2);
How many innovative patents were filed by companies in the 'technology' sector?
SELECT sector, SUM(patent_count) FROM company_innovation WHERE sector = 'technology' GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_visitors (id INT, museum VARCHAR(20), daily_visitors INT, visit_date DATE); INSERT INTO daily_visitors (id, museum, daily_visitors, visit_date) VALUES (1, 'Louvre', 15000, '2022-01-01'), (2, 'Louvre', 18000, '2022-01-02'), (3, 'Louvre', 12000, '2022-01-03');
What is the maximum number of daily visitors to the Louvre Museum in Paris in 2022?
SELECT MAX(daily_visitors) FROM daily_visitors WHERE museum = 'Louvre' AND visit_date BETWEEN '2022-01-01' AND LAST_DAY('2022-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventDate DATE, Revenue INT); INSERT INTO EsportsEvents (EventID, EventDate, Revenue) VALUES (1, '2022-01-01', 500000), (2, '2022-02-01', 700000), (3, '2022-03-01', 600000), (4, '2022-04-01', 800000);
What is the total revenue generated from esports events in the last 3 months?
SELECT SUM(Revenue) FROM EsportsEvents WHERE EventDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_data (crop_type VARCHAR(20), num_sensors INT); INSERT INTO sensor_data (crop_type, num_sensors) VALUES ('Corn', 500), ('Soybeans', 700), ('Wheat', 300);
Show the total number of IoT sensors deployed for each crop type
SELECT crop_type, SUM(num_sensors) FROM sensor_data GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, country TEXT); INSERT INTO projects VALUES (1, 'Water Project', 'Colombia'); INSERT INTO projects VALUES (2, 'Education Project', 'Colombia'); CREATE TABLE volunteers (id INT, project_id INT, number_of_volunteers INT); INSERT INTO volunteers VALUES (1, 1, 50); INSERT INTO volun...
What is the total number of volunteers for each project in Colombia?
SELECT p.name, SUM(v.number_of_volunteers) as total_volunteers FROM projects p INNER JOIN volunteers v ON p.id = v.project_id WHERE p.country = 'Colombia' GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (warehouse_id INT, location VARCHAR(50)); CREATE TABLE Locations (location_id INT, country VARCHAR(50)); INSERT INTO Warehouses (warehouse_id, location) VALUES (1, 'Los Angeles'); INSERT INTO Locations (location_id, country) VALUES (1, 'United States'); INSERT INTO Warehouses (warehouse_id, loca...
What is the total number of warehouses in each country?
SELECT Locations.country, COUNT(Warehouses.warehouse_id) FROM Warehouses INNER JOIN Locations ON Warehouses.location = Locations.location_id GROUP BY Locations.country;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), publication_date DATE, publisher VARCHAR(50)); INSERT INTO articles (id, title, publication_date, publisher) VALUES (1, 'Article1', '2017-07-21', 'The New York Times'), (2, 'Article2', '2017-10-15', 'The New York Times'), (3, 'Article3', '2017-12-05', 'The New York Tim...
How many articles were published by The New York Times in Q3 2017 and Q4 2017?
SELECT COUNT(*) FROM articles WHERE publication_date BETWEEN '2017-07-01' AND '2017-09-30' OR publication_date BETWEEN '2017-10-01' AND '2017-12-31' AND publisher = 'The New York Times';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(50), NumberOfArtworks int);INSERT INTO Artists (ArtistID, ArtistName, NumberOfArtworks) VALUES (1, 'Pablo Picasso', 500), (2, 'Vincent Van Gogh', 450), (3, 'Claude Monet', 350);
What is the total number of artworks donated by each artist, ordered by the total count in descending order?
SELECT ArtistName, SUM(NumberOfArtworks) OVER (PARTITION BY ArtistID ORDER BY ArtistID) as TotalArtworksDonated FROM Artists ORDER BY TotalArtworksDonated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE science_faculty (faculty_id INT, faculty_gender VARCHAR(10), faculty_department VARCHAR(50)); INSERT INTO science_faculty (faculty_id, faculty_gender, faculty_department) VALUES (1, 'Female', 'Physics'), (2, 'Male', 'Chemistry'), (3, 'Female', 'Biology'), (4, 'Male', 'Mathematics');
How many female and male faculty members are there in the College of Science?
SELECT faculty_gender, COUNT(*) FROM science_faculty WHERE faculty_department = 'College of Science' GROUP BY faculty_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE food_justice_orgs (org_id INT, name TEXT, location TEXT, website TEXT, city TEXT, state TEXT, country TEXT); INSERT INTO food_justice_orgs (org_id, name, location, website, city, state, country) VALUES (1, 'Fair Food Society', '321 Elm St', 'fairfoodsociety.ca', 'Vancouver', 'BC', 'Canada');
List all the food justice organizations in Vancouver, Canada with their respective websites.
SELECT name, website FROM food_justice_orgs WHERE city = 'Vancouver' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_accounts (id INT, account_type VARCHAR(255), region VARCHAR(255));
Count the number of socially responsible accounts in the Western region
SELECT COUNT(*) FROM socially_responsible_accounts WHERE region = 'Western';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, currency VARCHAR(10)); INSERT INTO clients (client_id, currency) VALUES (1, 'USD'), (2, 'EUR'), (3, 'USD'), (4, 'EUR'); CREATE TABLE assets (asset_id INT, client_id INT, value INT, currency VARCHAR(10)); INSERT INTO assets (asset_id, client_id, value, currency) VALUES (1, 1, 5000, '...
What is the total value of assets for clients who have made transactions in both USD and EUR?
SELECT SUM(value) FROM assets WHERE client_id IN (SELECT client_id FROM clients INNER JOIN assets ON clients.client_id = assets.client_id WHERE currency IN ('USD', 'EUR') GROUP BY client_id HAVING COUNT(DISTINCT currency) = 2);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region) VALUES (1, 'John Doe', 'West Coast'), (2, 'Jane Smith', 'East Coast'); INSERT INTO transact...
List all customers and their transaction amounts for customers in the Western region.
SELECT c.name, t.transaction_amount FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE c.region = 'West Coast';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory_data (inventory_id INT, product_name VARCHAR(20), inventory_status VARCHAR(10));
Update the 'inventory_data' table and set 'inventory_status' to 'low' for all records where 'product_name' is 'Acetone'
UPDATE inventory_data SET inventory_status = 'low' WHERE product_name = 'Acetone';
gretelai_synthetic_text_to_sql
CREATE TABLE AmazonRainforest (region VARCHAR(20), species_count INT); INSERT INTO AmazonRainforest (region, species_count) VALUES ('Amazon Rainforest', 456);
How many wildlife species are present in the 'Amazon Rainforest'?
SELECT species_count FROM AmazonRainforest WHERE region = 'Amazon Rainforest';
gretelai_synthetic_text_to_sql