context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE farm_regions (farm_id INT, biomass FLOAT, region VARCHAR(50)); INSERT INTO farm_regions (farm_id, biomass, region) VALUES (1, 250.3, 'Latin America'), (2, 320.5, 'Latin America'), (3, 180.7, 'Latin America'), (4, 450.9, 'Latin America'), (5, 220.1, 'Latin America'), (6, 370.2, 'Latin America'); CREATE TABL...
What is the total biomass of fish in farms in the Latin America region for each species?
SELECT species, SUM(biomass) FROM farm_regions JOIN species_farms ON farm_regions.farm_id = species_farms.farm_id WHERE region = 'Latin America' GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT, policyholder_id INT, claim_amount DECIMAL(10, 2), claim_date DATE); INSERT INTO claims (claim_id, policyholder_id, claim_amount, claim_date) VALUES (1, 3, 500.00, '2022-01-01'); INSERT INTO claims (claim_id, policyholder_id, claim_amount, claim_date) VALUES (2, 3, 750.00, '2022-02-01'...
Identify the policyholder with the most claims in California.
SELECT policyholder_id, COUNT(*) as total_claims FROM claims WHERE state = 'California' GROUP BY policyholder_id ORDER BY total_claims DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Transparency (transparency_id INT, product_id INT, is_cruelty_free BOOLEAN); INSERT INTO Transparency (transparency_id, product_id, is_cruelty_free) VALUES (1, 1, TRUE); CREATE TABLE Sales (sales_id INT, product_id INT, quantity INT, sales_date DATE); INSERT INTO Sales (sales_id, product_id, quantity, sale...
Which cruelty-free skincare products have the highest sales quantity?
SELECT Product.product_name, SUM(Sales.quantity) as total_quantity FROM Product INNER JOIN Transparency ON Product.product_id = Transparency.product_id INNER JOIN Sales ON Product.product_id = Sales.product_id WHERE Transparency.is_cruelty_free = TRUE AND Product.category = 'Skincare' GROUP BY Product.product_name ORDE...
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, city VARCHAR(20), operator VARCHAR(20), num_chargers INT, open_date DATE);
Update the 'operator' column to 'BC Hydro' for all records in the 'charging_stations' table where 'city' is 'Vancouver'
UPDATE charging_stations SET operator = 'BC Hydro' WHERE city = 'Vancouver';
gretelai_synthetic_text_to_sql
CREATE SCHEMA MarineLife; CREATE TABLE OceanFloorMapping (site_id INT, depth FLOAT); INSERT INTO OceanFloorMapping (site_id, depth) VALUES (1, 3456.2), (2, 1234.5), (3, 5678.9);
What is the average depth of ocean floor mapping project sites in the 'MarineLife' schema?
SELECT AVG(depth) FROM MarineLife.OceanFloorMapping;
gretelai_synthetic_text_to_sql
CREATE TABLE Library(Year INT, Location VARCHAR(10), Number INT); INSERT INTO Library VALUES (2018, 'Urban', 15), (2018, 'Rural', 5), (2019, 'Urban', 18), (2019, 'Rural', 4), (2020, 'Urban', 20), (2020, 'Rural', 3);
How many public libraries were there in urban areas in 2019?
SELECT SUM(Number) FROM Library WHERE Year = 2019 AND Location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE product_reviews (product_id INT, is_halal BOOLEAN, market VARCHAR(10), rating INT); INSERT INTO product_reviews (product_id, is_halal, market, rating) VALUES (1, true, 'AU', 4), (2, false, 'CA', 3), (3, true, 'AU', 5);
What is the average rating for halal cosmetics in the Australian market?
SELECT AVG(rating) FROM product_reviews pr WHERE pr.is_halal = true AND pr.market = 'AU';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerDemographics (PlayerID INT, GamePlatform VARCHAR(10)); INSERT INTO PlayerDemographics (PlayerID, GamePlatform) VALUES (1, 'Mobile'), (2, 'PC'), (3, 'Mobile'), (4, 'Console');
What is the percentage of players who prefer mobile games?
SELECT (COUNT(*) FILTER(WHERE GamePlatform = 'Mobile') * 100.0 / COUNT(*)) AS Percentage FROM PlayerDemographics;
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (FactoryID INT, Company VARCHAR(50), Location VARCHAR(50)); CREATE TABLE Production (ProductionID INT, FactoryID INT, Material VARCHAR(50), Quantity INT, Price DECIMAL(5,2)); INSERT INTO Factories VALUES (1,'Green Enterprises','Country A'),(2,'Green Enterprises','Country B'),(3,'Another Company',...
Find the total quantity of sustainable materials used by factories owned by a specific company.
SELECT SUM(Quantity) FROM Production p JOIN Factories f ON p.FactoryID = f.FactoryID WHERE f.Company = 'Green Enterprises' AND Material IN ('Eco-Friendly Material', 'Sustainable Material');
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), country VARCHAR(255), skill_level VARCHAR(50)); INSERT INTO workers (id, name, age, gender, country, skill_level) VALUES (1, 'John Doe', 30, 'Male', 'USA', 'Expert'), (2, 'Jane Doe', 25, 'Female', 'Mexico', 'Intermediate'), (3, 'A...
What is the total number of workers in each country, and the average age of those workers?
SELECT country, COUNT(*) as total_workers, AVG(age) as avg_age FROM workers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, name VARCHAR(255), latitude DECIMAL(9,6), longitude DECIMAL(9,6)); CREATE TABLE entries (station_id INT, entry_time TIMESTAMP);
Create a view named 'high_traffic_stations' containing stations with more than 1000 entries in the 'entries' table
CREATE VIEW high_traffic_stations AS SELECT s.station_id, s.name FROM stations s JOIN entries e ON s.station_id = e.station_id GROUP BY s.station_id, s.name HAVING COUNT(e.entry_time) > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_requests (id INT, country VARCHAR(50), year INT, request_count INT); INSERT INTO military_equipment_requests (id, country, year, request_count) VALUES (1, 'Germany', 2020, 150); INSERT INTO military_equipment_requests (id, country, year, request_count) VALUES (2, 'Germany', 2020, 160); I...
What is the number of military equipment maintenance requests in Germany in 2020?
SELECT SUM(request_count) FROM military_equipment_requests WHERE country = 'Germany' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE public.hospitals (id SERIAL PRIMARY KEY, name TEXT, location TEXT); INSERT INTO public.hospitals (name, location) VALUES ('General Hospital', 'California'), ('Children''s Hospital', 'California'), ('Mountain View Hospital', 'California'); CREATE TABLE public.admissions (id SERIAL PRIMARY KEY, hospital TEXT...
List the top three hospitals with the highest number of COVID-19 admissions in California in 2021.
SELECT a.hospital, COUNT(*) FROM public.admissions a JOIN public.hospitals h ON a.hospital = h.name WHERE a.diagnosis = 'COVID-19' AND h.location = 'California' GROUP BY a.hospital ORDER BY COUNT(*) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name TEXT);CREATE TABLE policing_events (id INT, city_id INT, year INT, type TEXT);
How many community policing events were held in each city in 2021?
SELECT c.name, COUNT(pe.id) FROM cities c JOIN policing_events pe ON c.id = pe.city_id WHERE pe.year = 2021 GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE EducationPrograms (program_id INT, city VARCHAR(20), funding_source VARCHAR(20), year INT); INSERT INTO EducationPrograms (program_id, city, funding_source, year) VALUES (1, 'New York', 'Cultural Trust', 2021), (2, 'Miami', 'Cultural Trust', 2021), (3, 'Chicago', 'Cultural Trust', 2021), (4, 'New York', 'A...
Identify the top 2 cities with the highest number of arts education programs funded by 'Arts Foundation' in 2021 and 2022.
SELECT city, COUNT(*) as program_count FROM EducationPrograms WHERE funding_source = 'Arts Foundation' AND year IN (2021, 2022) GROUP BY city ORDER BY program_count DESC LIMIT 2
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, location VARCHAR(50), description TEXT, price DECIMAL(5,2));
Insert a new virtual tour into the "virtual_tours" table for 'Tokyo' with an ID of 23, a description of 'A virtual tour of the Tokyo Skytree', and a price of 20.50
INSERT INTO virtual_tours (tour_id, location, description, price) VALUES (23, 'Tokyo', 'A virtual tour of the Tokyo Skytree', 20.50);
gretelai_synthetic_text_to_sql
CREATE TABLE CustomerPreferences (customer_id INT, product_id INT, preference_rating INT, is_halal BOOLEAN, country VARCHAR(50)); INSERT INTO CustomerPreferences (customer_id, product_id, preference_rating, is_halal, country) VALUES (3, 3, 5, true, 'United Kingdom');
How many unique customers prefer halal products with a rating of 3 or higher in the United Kingdom?
SELECT COUNT(DISTINCT customer_id) as unique_customers FROM CustomerPreferences WHERE preference_rating >= 3 AND is_halal = true AND country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing (id INT, company VARCHAR(255), cost INT, country VARCHAR(255));
What was the average cost of spacecraft manufactured by companies in Europe?
SELECT AVG(cost) FROM SpacecraftManufacturing WHERE country IN ('Germany', 'France', 'UK', 'Italy', 'Spain');
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists defense; CREATE TABLE if not exists peacekeeping_operations (id INT PRIMARY KEY, country VARCHAR(50), military_personnel INT); INSERT INTO peacekeeping_operations (id, country, military_personnel) VALUES (1, 'Brazil', 1200), (2, 'USA', 2500), (3, 'Egypt', 1800), (4, 'India', 3000);
What is the average number of military personnel for each country involved in peacekeeping operations?
SELECT AVG(military_personnel) FROM defense.peacekeeping_operations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, officer_id INT, event_type VARCHAR(255), attendance INT, timestamp TIMESTAMP); INSERT INTO community_policing (id, officer_id, event_type, attendance, timestamp) VALUES (1, 30, 'Neighborhood Watch', 20, '2021-01-03 14:00:00'); INSERT INTO community_policing (id, officer_id, even...
Find the community policing officers with the highest and lowest attendance?
SELECT officer_id, MIN(attendance) as lowest, MAX(attendance) as highest FROM community_policing GROUP BY officer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity(year INT, landfill VARCHAR(255), capacity INT); INSERT INTO landfill_capacity VALUES (2018, 'Landfill A', 100000), (2018, 'Landfill B', 150000), (2018, 'Landfill C', 200000), (2019, 'Landfill A', 110000), (2019, 'Landfill B', 155000), (2019, 'Landfill C', 210000), (2020, 'Landfill A', 120...
What is the average landfill capacity in 2019 and 2020?
SELECT AVG(capacity) FROM landfill_capacity WHERE year IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor_id INT, company_id INT, invested_amount FLOAT); CREATE TABLE companies (id INT, socially_responsible BOOLEAN); INSERT INTO investments (id, investor_id, company_id, invested_amount) VALUES (1, 1, 2, 5000), (2, 1, 3, 8000), (3, 2, 1, 7000), (4, 3, 3, 6000); INSERT INTO companie...
What's the average investment in socially responsible companies for each investor?
SELECT i.investor_id, AVG(i.invested_amount) as avg_investment FROM investments i JOIN companies c ON i.company_id = c.id WHERE c.socially_responsible = true GROUP BY i.investor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE DroughtAssessments (assessment_id INT, region VARCHAR(20), drought_severity VARCHAR(20)); INSERT INTO DroughtAssessments (assessment_id, region, drought_severity) VALUES (1, 'RegionA', 'Moderate'), (2, 'RegionB', 'Severe'), (3, 'RegionC', 'Critical');
How many drought assessments were conducted in 'DroughtAssessments' table?
SELECT COUNT(assessment_id) FROM DroughtAssessments;
gretelai_synthetic_text_to_sql
CREATE TABLE police_stations (id INT, name TEXT, city TEXT, avg_fines FLOAT); INSERT INTO police_stations (id, name, city, avg_fines) VALUES (1, 'West End Police', 'London', 500.0), (2, 'Croydon Police', 'London', 400.0);
What is the average amount of fines given by each police station in London?
SELECT name, AVG(avg_fines) as avg_fines FROM police_stations GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE health_metrics (id INT, species VARCHAR(50), metric FLOAT); INSERT INTO health_metrics (id, species, metric) VALUES (1, 'Tilapia', 75.0), (2, 'Catfish', 80.0), (3, 'Salmon', 60.0);
Which aquatic species have health metrics above the average?
SELECT species FROM health_metrics WHERE metric > (SELECT AVG(metric) FROM health_metrics);
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (volunteer_id INT, state VARCHAR(20), total_hours INT, volunteer_year INT); INSERT INTO Volunteers (volunteer_id, state, total_hours, volunteer_year) VALUES (1, 'New Mexico', 15, 2022), (2, 'New Mexico', 20, 2022);
What was the minimum number of hours served by a volunteer in 'New Mexico' in the year 2022?
SELECT MIN(total_hours) FROM Volunteers WHERE state = 'New Mexico' AND volunteer_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'); CREATE TABLE fare (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), collection_date DATE); INSERT INTO fare (fare_id, route_id, fare_amount, collection_date) VALUES (1, 1, 3.50, '2022-06-01'),...
What is the total fare collected from the 'Red Line' on June 1st, 2022?
SELECT SUM(fare_amount) FROM fare WHERE route_id = 1 AND collection_date = '2022-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, Department varchar(20), Degree varchar(50), GraduationYear int); INSERT INTO Employees (EmployeeID, Department, Degree, GraduationYear) VALUES (1, 'IT', 'BS in Computer Science', 2021), (2, 'IT', 'MS in Computer Science', 2019), (3, 'Sales', 'BA in Marketing', 2018), (4, 'Sales',...
Calculate the percentage of employees in each department who are recent college graduates.
SELECT e.Department, ROUND(COUNT(CASE WHEN e.GraduationYear >= YEAR(CURRENT_DATE) - 2 THEN 1 END) * 100.0 / COUNT(*), 1) AS Percent_Recent_Grads FROM Employees e GROUP BY e.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (country VARCHAR(20), energy_source VARCHAR(20), capacity INT); INSERT INTO renewable_energy (country, energy_source, capacity) VALUES ('Spain', 'Solar', 8000), ('Spain', 'Wind', 25000), ('Spain', 'Hydro', 18000);
Which renewable energy sources are available in Spain and their corresponding capacities?
SELECT energy_source, capacity FROM renewable_energy WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_communities (id INT, community_name VARCHAR(255), location VARCHAR(255), country VARCHAR(255), initiative_type VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_communities (id, community_name, location, country, initiative_type, start_date, end_date) VALUES (1, 'Community A', 'Village...
What is the total number of community development initiatives in Country V?
SELECT COUNT(*) FROM rural_communities WHERE country = 'Country V' AND initiative_type = 'Community Development';
gretelai_synthetic_text_to_sql
CREATE TABLE Joint_Military_Exercises (id INT, country VARCHAR(50), year INT, allies VARCHAR(50));
What is the number of joint military exercises conducted by each country with its allies in the last 3 years?
SELECT country, COUNT(country) as joint_exercises FROM Joint_Military_Exercises WHERE year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE FiscalYear (fiscal_year INT, year INT); INSERT INTO FiscalYear (fiscal_year, year) VALUES (2021, 2021), (2022, 2022), (2023, 2023); CREATE TABLE IncidentTypes (id INT, type VARCHAR(30)); INSERT INTO IncidentTypes (id, type) VALUES (1, 'Malware'), (2, 'Phishing'), (3, 'Ransomware'), (4, 'Data Breach'); CREA...
What is the total number of cybersecurity incidents reported for each type of incident in FY2021?
SELECT i.type, COUNT(*) FROM Incidents i INNER JOIN FiscalYear fy ON i.fiscal_year_id = fy.id WHERE fy.year = 2021 GROUP BY i.type;
gretelai_synthetic_text_to_sql
CREATE TABLE articles_by_day (title text, topic text, publish_date date); INSERT INTO articles_by_day (title, topic, publish_date) VALUES ('Article 9', 'investigative journalism', '2022-03-01'); INSERT INTO articles_by_day (title, topic, publish_date) VALUES ('Article 10', 'investigative journalism', '2022-03-02');
What is the number of articles published per day on 'investigative journalism'?
SELECT EXTRACT(DAY FROM publish_date) as day, COUNT(*) as count FROM articles_by_day WHERE topic = 'investigative journalism' GROUP BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE AIModels (id INT, model_name VARCHAR(50), organization VARCHAR(50), application_type VARCHAR(50), safety_rating INT), AIOrganizations (id INT, organization VARCHAR(50), region VARCHAR(50)); INSERT INTO AIModels (id, model_name, organization, application_type, safety_rating) VALUES (1, 'AI4Education', 'Micr...
What is the average safety rating of AI models developed for education applications, and how many of these models have been developed by organizations based in Asia?
SELECT AVG(safety_rating) as avg_safety_rating FROM AIModels WHERE application_type = 'Education'; SELECT COUNT(*) as asian_org_count FROM AIOrganizations WHERE region = 'Asia' AND organization IN (SELECT organization FROM AIModels WHERE application_type = 'Education');
gretelai_synthetic_text_to_sql
CREATE TABLE Dates (date DATE); CREATE TABLE Sales (sale_id INT, date DATE, product_id INT, quantity INT, cost INT); CREATE TABLE Products (product_id INT, product_name VARCHAR(255), is_fair_trade BOOLEAN);
What is the total cost of fair trade coffee products in the last 6 months?
SELECT SUM(s.cost) as total_cost FROM Sales s JOIN Dates d ON s.date = d.date JOIN Products p ON s.product_id = p.product_id WHERE d.date >= DATE(NOW()) - INTERVAL 6 MONTH AND p.is_fair_trade = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT); INSERT INTO company (id, name, industry, founding_date, founder_gender) VALUES (1, 'Omega Inc', 'Renewable Energy', '2017-01-01', 'Non-binary'); INSERT INTO company (id, name, industry, founding_date, founder_gender) VALUE...
Which industries had the highest number of non-binary founded startups in 2017?
SELECT industry, COUNT(*) as num_non_binary_startups FROM company WHERE founding_date >= '2017-01-01' AND founder_gender = 'Non-binary' GROUP BY industry ORDER BY num_non_binary_startups DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(20)); INSERT INTO EsportsEvents (EventID, EventName) VALUES (1, 'ESWC'), (2, 'EVO'), (3, 'BlizzCon'), (4, 'The International'), (5, 'MLG'); CREATE TABLE EventParticipants (EventID INT, PlayerID INT); INSERT INTO EventParticipants (EventID, PlayerID) VALUES (1, ...
List the names of esports events and their respective number of participants, ordered by the number of participants in descending order.
SELECT EsportsEvents.EventName, COUNT(EventParticipants.PlayerID) AS Participants FROM EsportsEvents INNER JOIN EventParticipants ON EsportsEvents.EventID = EventParticipants.EventID GROUP BY EsportsEvents.EventName ORDER BY Participants DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.flight_safety (id INT, incident VARCHAR(255), incident_date DATE);INSERT INTO aerospace.flight_safety (id, incident, incident_date) VALUES (1, 'Inc1', '2017-01-01'), (2, 'Inc2', '2018-01-01');
Delete flight safety records from 2017
DELETE FROM aerospace.flight_safety WHERE incident_date >= '2017-01-01' AND incident_date < '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (id INT, mine_id INT, region TEXT, year INT, assessment_count INT); INSERT INTO EnvironmentalImpact (id, mine_id, region, year, assessment_count) VALUES (1, 1, 'Region Z', 2015, 3), (2, 1, 'Region Z', 2016, 4), (3, 2, 'Region Y', 2015, 2);
How many environmental impact assessments were conducted in Region Z?
SELECT SUM(assessment_count) FROM EnvironmentalImpact WHERE region = 'Region Z';
gretelai_synthetic_text_to_sql
CREATE TABLE humidity_data (humidity DECIMAL(3,1), reading_date DATE, location TEXT); INSERT INTO humidity_data (humidity, reading_date, location) VALUES (82.5, '2021-07-01', 'Sri Lanka'), (85.3, '2021-07-02', 'Sri Lanka'), (79.2, '2021-01-01', 'Sri Lanka');
What is the average humidity (%) in tea plantations in Sri Lanka during the last month?
SELECT AVG(humidity) FROM humidity_data WHERE location = 'Sri Lanka' AND reading_date > DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND location LIKE '%tea%';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, country VARCHAR(100), framework VARCHAR(100)); INSERT INTO regulatory_frameworks (framework_id, country, framework) VALUES (1, 'South Korea', 'FrameworkA'), (2, 'Germany', 'FrameworkB'), (3, 'Australia', 'FrameworkC');
Show all regulatory frameworks for digital assets in South Korea and Germany?
SELECT framework_id, country, framework FROM regulatory_frameworks WHERE country IN ('South Korea', 'Germany');
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (id INT, player_id INT, event_date DATE, game_type VARCHAR(255)); INSERT INTO esports_events (id, player_id, event_date, game_type) VALUES (1, 1, '2022-01-01', 'FPS'), (2, 1, '2022-02-01', 'RPG'), (3, 2, '2021-12-01', 'FPS'), (4, 2, '2022-01-01', 'FPS');
What is the number of esports events for each game type?
SELECT game_type, COUNT(DISTINCT id) AS events_count FROM esports_events GROUP BY game_type;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_rig_years (rig_id INT, region VARCHAR(20), year INT, active INT); INSERT INTO oil_rig_years (rig_id, region, year, active) VALUES (1, 'Brazil', 2018, 1), (2, 'Brazil', 2019, 1), (3, 'Brazil', 2020, 1), (4, 'Nigeria', 2018, 2), (5, 'Nigeria', 2019, 2);
What is the average number of oil rigs active per year in the 'Brazil' region over the last 5 years?
SELECT AVG(active) FROM oil_rig_years WHERE region = 'Brazil' AND year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE innovations (id INT PRIMARY KEY, innovation_name VARCHAR(100), description TEXT, category VARCHAR(50), funding FLOAT);
Insert a new record for a military innovation in the 'innovations' table
INSERT INTO innovations (innovation_name, description, category, funding) VALUES ('Stealth Drone', 'Unmanned aerial vehicle with low radar cross-section', 'Air', 5000000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT); INSERT INTO Donors VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mike Johnson'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL); INSERT INTO Donations VALUES (1, 1, 50.00), (2, 1, 100.00), (3, 2, 75.00);
Show the number of donations for each donor.
SELECT Donors.Name, COUNT(Donations.DonationID) as NumberOfDonations FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID GROUP BY Donors.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_evaluations (model_name VARCHAR(255), year INT, fairness_score DECIMAL(5,4)); INSERT INTO fairness_evaluations (model_name, year, fairness_score) VALUES ('ModelA', 2024, 0.85), ('ModelB', 2024, 0.92), ('ModelC', 2024, 0.78), ('ModelD', 2024, 0.88), ('ModelE', 2024, 0.90);
Update fairness evaluations for model 'ModelC' in 2024
UPDATE fairness_evaluations SET fairness_score = 0.82 WHERE model_name = 'ModelC' AND year = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50)); INSERT INTO programs (id, name) VALUES (1, 'Education Support'), (2, 'Food Assistance'), (3, 'Health Services');
Insert a new record into the programs table with the following information: id = 4, name = 'Clothing Drive'.
INSERT INTO programs (id, name) VALUES (4, 'Clothing Drive');
gretelai_synthetic_text_to_sql
CREATE TABLE waste_management (waste_id INT PRIMARY KEY, waste_type VARCHAR(20)); INSERT INTO waste_management (waste_id, waste_type) VALUES (1, 'Non-Toxic'), (2, 'Toxic'), (3, 'Non-Toxic'), (4, 'Non-Toxic');
Delete all records in the "waste_management" table where the "waste_type" is 'Non-Toxic'
DELETE FROM waste_management WHERE waste_type = 'Non-Toxic';
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyStorageProjects ( ProjectID INT, Name VARCHAR(255), Country VARCHAR(255), Type VARCHAR(255) );
Find the total number of Energy Storage projects in each country?
SELECT Country, COUNT(*) FROM EnergyStorageProjects GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50), PracticeArea VARCHAR(50)); INSERT INTO Attorneys (AttorneyID, Name, PracticeArea) VALUES (1, 'Smith', 'Civil Rights'); INSERT INTO Attorneys (AttorneyID, Name, PracticeArea) VALUES (2, 'Johnson', 'Criminal Law'); CREATE TABLE Billing (BillingID INT, AttorneyID I...
What is the total billing amount for each attorney, by practice area?
SELECT A.PracticeArea, SUM(B.Amount) AS TotalBillingAmount FROM Attorneys A JOIN Billing B ON A.AttorneyID = B.AttorneyID GROUP BY A.PracticeArea;
gretelai_synthetic_text_to_sql
CREATE TABLE coal_mines (id INT, name VARCHAR(50), location VARCHAR(50), size INT, num_employees INT, co2_emissions INT); INSERT INTO coal_mines VALUES (1, 'Coal Mine 1', 'West Virginia', 450, 350, 25000); INSERT INTO coal_mines VALUES (2, 'Coal Mine 2', 'Wyoming', 600, 400, 30000); INSERT INTO coal_mines VALUES (3, 'C...
What is the total CO2 emission for coal mines that have more than 300 employees?
SELECT SUM(co2_emissions) FROM coal_mines WHERE num_employees > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(20), Name VARCHAR(20), Type VARCHAR(20), AverageSpeed FLOAT); INSERT INTO Vessels VALUES ('V009', 'Vessel I', 'Passenger', 22.5), ('V010', 'Vessel J', 'Passenger', 25.0), ('V011', 'Vessel K', 'Cargo', 15.5);
What is the average speed of all passenger vessels?
SELECT AVG(AverageSpeed) FROM Vessels WHERE Type = 'Passenger';
gretelai_synthetic_text_to_sql
CREATE TABLE element_market_value (element VARCHAR(50), market_value DECIMAL(10, 2)); INSERT INTO element_market_value (element, market_value) VALUES ('Neodymium', 110.54), ('Praseodymium', 72.34), ('Dysprosium', 143.87), ('Samarium', 51.76), ('Gadolinium', 42.58);
What is the average market value of rare earth elements?
SELECT AVG(market_value) FROM element_market_value;
gretelai_synthetic_text_to_sql
CREATE TABLE monorails (id INT, name TEXT, location TEXT, length INT, type TEXT, year INT); INSERT INTO monorails (id, name, location, length, type, year) VALUES (1, 'Las Vegas Monorail', 'Nevada, USA', 6, 'Monorail', 2004); INSERT INTO monorails (id, name, location, length, type, year) VALUES (2, 'Sydney Monorail', 'A...
What are the names, locations, and lengths of monorails constructed after 1995, excluding those in Japan?
SELECT name, location, length FROM monorails WHERE year > 1995 AND location NOT LIKE '%Japan%';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, name TEXT, factories TEXT); CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, diversity_score FLOAT);
List the names and locations of all suppliers who have not supplied to any factories with a diversity score above 90.
SELECT suppliers.name, suppliers.location FROM suppliers LEFT JOIN factories ON factories.factory_id = ANY(string_to_array(suppliers.factories, ',')) WHERE factories.factory_id IS NULL OR factories.diversity_score <= 90;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50)); CREATE TABLE SupportServices (ServiceID INT, ServiceName VARCHAR(50), ServiceType VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Regions (RegionID, RegionName) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'South'), (5, 'West'); INSERT INTO ...
Update the budget for the 'ASL Interpreter' service in the 'SupportServices' table.
UPDATE SupportServices SET Budget = 16000 WHERE ServiceName = 'ASL Interpreter';
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_tracking_3 (id INT, location TEXT, cases_per_month INT, month TEXT); INSERT INTO infectious_disease_tracking_3 (id, location, cases_per_month, month) VALUES (1, 'Rural A', 10, 'January'), (2, 'Rural B', 15, 'February'), (3, 'Urban A', 20, 'March'), (4, 'Urban A', 5, 'April');
What is the minimum number of infectious disease tracking cases per month in urban areas, grouped by month?
SELECT month, MIN(cases_per_month) FROM infectious_disease_tracking_3 WHERE location = 'urban' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Contracts (Contract_ID INT, Business_Owner VARCHAR(50), Contract_Value DECIMAL(10,2), Award_Date DATE, State VARCHAR(50));
What is the total value of construction contracts awarded to minority-owned businesses in California during 2018?
SELECT SUM(Contract_Value) FROM Contracts WHERE Business_Owner LIKE '%Minority%' AND State = 'California' AND Award_Date BETWEEN '2018-01-01' AND '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_projects (project_name VARCHAR(50), budget DECIMAL(10,2), year INT); INSERT INTO autonomous_projects (project_name, budget, year) VALUES ('Project Apollo', 7000000, 2018), ('Wayve', 6000000, 2020), ('Project Baidu', 5500000, 2017), ('Project Zoox', 9000000, 2019);
List all autonomous driving research projects with a budget over $5 million.
SELECT * FROM autonomous_projects WHERE budget > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (country, year, recycling_rate) VALUES ('India', 2017, 0.18), ('India', 2018, 0.20);
What is the recycling rate for India in 2017 and 2018?
SELECT year, recycling_rate FROM recycling_rates WHERE country = 'India' ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE DesignStandard (id INT, standard VARCHAR(50), description TEXT); INSERT INTO DesignStandard (id, standard, description) VALUES (1, 'TAA', 'Transportation Agency of Asia');
What bridges were built using design standards from the Transportation Agency of Asia (TAA)?
INSERT INTO Infrastructure (id, name, location, type) SELECT 2, 'Bridge 2', 'Country D', 'Steel' FROM DesignStandard WHERE DesignStandard.standard = 'TAA';
gretelai_synthetic_text_to_sql
CREATE TABLE team_ticket_sales (team_name VARCHAR(50), sport VARCHAR(20), tickets_sold INT, revenue DECIMAL(10,2)); INSERT INTO team_ticket_sales (team_name, sport, tickets_sold, revenue) VALUES ('Team A', 'Basketball', 1000, 25000.00), ('Team B', 'Soccer', 800, 20000.00), ('Team C', 'Basketball', 1200, 32000.00), ('Te...
What is the total number of tickets sold and the total revenue for teams in the 'Basketball' sport?
SELECT SUM(tickets_sold) AS total_tickets_sold, SUM(revenue) AS total_revenue FROM team_ticket_sales WHERE sport = 'Basketball';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, value DECIMAL(10, 2), client_id INT, client_community VARCHAR(50), date DATE);
List all Shariah-compliant financing transactions over $10,000 for clients in the LGBTQ+ community in Q3 2021.
SELECT shariah_compliant_finance.* FROM shariah_compliant_finance WHERE client_community = 'LGBTQ+' AND value > 10000 AND date BETWEEN '2021-07-01' AND '2021-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (id INT, dish VARCHAR(255), vegetarian BOOLEAN, gluten_free BOOLEAN); INSERT INTO Dishes (id, dish, vegetarian, gluten_free) VALUES (1, 'Quinoa Salad', TRUE, TRUE), (2, 'Beef Stew', FALSE, FALSE), (3, 'Vegetable Curry', TRUE, TRUE), (4, 'Chicken Fried Rice', FALSE, FALSE), (5, 'Lentil Soup', TRUE, T...
What is the total count of dishes that are both vegetarian and gluten-free?
SELECT COUNT(*) FROM Dishes WHERE vegetarian = TRUE AND gluten_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE job_categories (id INT, name VARCHAR(255)); INSERT INTO job_categories (id, name) VALUES (1, 'Manager'), (2, 'Engineer'), (3, 'Sales'); CREATE TABLE employees (id INT, name VARCHAR(255), job_category_id INT); CREATE TABLE training_programs (id INT, employee_id INT, duration INT); INSERT INTO training_progr...
What is the average training program duration by employee's job category?
SELECT job_categories.name, AVG(training_programs.duration) as avg_duration FROM job_categories JOIN employees ON job_categories.id = employees.job_category_id JOIN training_programs ON employees.id = training_programs.employee_id GROUP BY job_categories.name;
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility_audits (id INT PRIMARY KEY, university VARCHAR(255), score INT, audit_date DATE);
Insert a new record of an accessibility audit for a university with a score of 90, conducted on January 1, 2022.
INSERT INTO accessibility_audits (university, score, audit_date) VALUES ('University of California, Berkeley', 90, '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Practices ( id INT PRIMARY KEY, country_id INT, certification_date DATE, FOREIGN KEY (country_id) REFERENCES Countries(id) ); INSERT INTO Sustainable_Practices (id, country_id, certification_date) VALUES (1, 5, '2019-06-01'); INSERT INTO Sustainable_Practices (id, country_id, certification_date...
Which countries in Africa were certified for sustainable practices in 2019 or earlier?
SELECT c.name FROM Countries c INNER JOIN Sustainable_Practices sp ON c.id = sp.country_id WHERE c.continent = 'Africa' AND sp.certification_date <= '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE unhcr_funding (funding_agency VARCHAR(255), project_type VARCHAR(255), country VARCHAR(255), amount DECIMAL(10,2), year INT);
What was the total amount of funding given by UNHCR to shelter projects in Syria in 2017?
SELECT SUM(amount) FROM unhcr_funding WHERE funding_agency = 'UNHCR' AND project_type = 'shelter' AND country = 'Syria' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (facility_id INT, state TEXT, languages TEXT); INSERT INTO mental_health_facilities (facility_id, state, languages) VALUES (1, 'California', 'English, Spanish'), (2, 'Texas', 'Spanish, French'), (3, 'New York', 'English, Mandarin');
How many mental health facilities exist in each state that offer services in Spanish?
SELECT state, COUNT(*) FROM mental_health_facilities WHERE languages LIKE '%Spanish%' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_ownership (id INT, vehicle_type TEXT, owner_type TEXT);
What is the ratio of shared to private electric vehicles in New York City?
SELECT (COUNT(*) FILTER (WHERE owner_type = 'shared')) * 100.0 / COUNT(*) AS shared_ratio FROM vehicle_ownership WHERE vehicle_type = 'electric vehicle' AND owner_type IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, City TEXT, AmountDonated DECIMAL); INSERT INTO Donors (DonorID, DonorName, City, AmountDonated) VALUES (1, 'John Doe', 'Seattle', 500.00), (2, 'Jane Smith', 'New York', 300.00);
What was the average donation amount by donors from the city of "Seattle"?
SELECT AVG(AmountDonated) FROM Donors WHERE City = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE furniture_inventory (id INT, item_name VARCHAR(50), price DECIMAL(10, 2), country_of_sale VARCHAR(50), sale_date DATE); INSERT INTO furniture_inventory (id, item_name, price, country_of_sale, sale_date) VALUES (1, 'Wooden Table', 500.00, 'Canada', '2021-09-25'), (2, 'Vintage Chair', 250.00, 'Canada', '2021...
What is the average price of upcycled furniture items sold in Canada?
SELECT AVG(price) FROM furniture_inventory WHERE country_of_sale = 'Canada' AND item_name LIKE '%upcycled%';
gretelai_synthetic_text_to_sql
CREATE TABLE african_facilities (facility_id INT, facility_name TEXT, region TEXT); INSERT INTO african_facilities (facility_id, facility_name, region) VALUES (1, 'Facility X', 'West'), (2, 'Facility Y', 'North'), (3, 'Facility Z', 'Central'), (4, 'Facility W', 'East'), (5, 'Facility V', 'South');
How many chemical manufacturing facilities are there in each region (North, South, Central, East, West) in Africa?
SELECT region, COUNT(*) as facility_count FROM african_facilities GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (journalist_id INT, journalist_type VARCHAR(20), country VARCHAR(50)); CREATE TABLE articles (article_id INT, journalist_id INT, content_type VARCHAR(20)); INSERT INTO journalists VALUES (1, 'independent', 'France'); INSERT INTO articles VALUES (1, 1, 'opinion');
What is the number of articles written by independent journalists in Europe?
SELECT COUNT(*) FROM journalists INNER JOIN articles ON journalists.journalist_id = articles.journalist_id WHERE journalists.journalist_type = 'independent' AND country IN ('France', 'Germany', 'Italy');
gretelai_synthetic_text_to_sql
CREATE TABLE underwriting (policy_type VARCHAR(10), policy_number INT, state VARCHAR(2)); INSERT INTO underwriting (policy_type, policy_number, state) VALUES ('auto', 12345, 'NY'), ('home', 67890, 'CA'), ('life', 111, 'NY');
Show the unique states for each policy type in the underwriting database
SELECT DISTINCT policy_type, state FROM underwriting;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_missions (id INT, mission_name VARCHAR(255), country VARCHAR(255), duration FLOAT); INSERT INTO satellite_missions (id, mission_name, country, duration) VALUES (1, 'Sentinel-1A', 'Europe', 780), (2, 'Sentinel-1B', 'Europe', 780), (3, 'Landsat 8', 'USA', 1639), (4, 'ResourceSat-2', 'India', 1500),...
What is the maximum duration of satellite missions for each country?
SELECT country, MAX(duration) as max_duration FROM satellite_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, subscription_type VARCHAR(50), revenue DECIMAL(10, 2)); INSERT INTO broadband_subscribers (subscriber_id, subscription_type, revenue) VALUES (1, 'Residential', 100.00), (2, 'Business', 150.00);
What is the name and subscription type of the broadband subscriber with the highest revenue?
SELECT name, subscription_type FROM broadband_subscribers WHERE revenue = (SELECT MAX(revenue) FROM broadband_subscribers);
gretelai_synthetic_text_to_sql
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT);CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT);
What is the total quantity of dish A served in all branches last month?
SELECT SUM(quantity) FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE dish_name = 'Dish A' AND sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 2 MONTH) AND DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE contracts (id INT, project_id INT, contractor_id INT);
Delete all contracts in the contracts table associated with the contractor with ID 2
WITH cte AS (DELETE FROM contracts WHERE contractor_id = 2) SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE employee (id INT, mine_id INT, gender VARCHAR(10), role VARCHAR(20), salary INT);
What is the number of employees by mine, gender, and role?
SELECT mine.name, employee.gender, employee.role, COUNT(employee.id) FROM employee JOIN mine ON employee.mine_id = mine.id GROUP BY mine.name, employee.gender, employee.role;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (strategy_id INT, strategy_name TEXT, investment_date DATE, sector TEXT, amount FLOAT); CREATE TABLE returns (return_id INT, strategy_id INT, return_date DATE, return_amount FLOAT);
Identify top 3 investment strategies by ROI for Q3 2022 in the technology sector.
SELECT strategy_name, 100.0 * SUM(return_amount) / SUM(amount) AS roi FROM investment_strategies s JOIN returns r ON s.strategy_id = r.strategy_id WHERE investment_date BETWEEN '2022-07-01' AND '2022-09-30' AND sector = 'technology' GROUP BY strategy_id, strategy_name ORDER BY roi DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE member_data (member_id INT, join_date DATE); CREATE TABLE member_workouts (member_id INT, workout_date DATE);
Show members who joined in Q1 2022 and have not attended a workout
SELECT mdata.member_id FROM member_data mdata LEFT JOIN member_workouts mworkouts ON mdata.member_id = mworkouts.member_id WHERE mdata.join_date BETWEEN '2022-01-01' AND '2022-03-31' AND mworkouts.member_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE VIEW popular_hotels AS SELECT * FROM hotels WHERE region IN ('New York', 'Los Angeles'); CREATE TABLE bookings (id INT, hotel_id INT, bookings INT);
What is the total number of bookings for each hotel in the popular_hotels view?
SELECT h.hotel_name, SUM(b.bookings) FROM popular_hotels h JOIN bookings b ON h.id = b.hotel_id GROUP BY h.hotel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Species_6 (id INT, name VARCHAR(255), region VARCHAR(255), year INT); INSERT INTO Species_6 (id, name, region, year) VALUES (1, 'Kangaroo', 'Australia', 2021); INSERT INTO Species_6 (id, name, region, year) VALUES (2, 'Platypus', 'Australia', 2022); INSERT INTO Species_6 (id, name, region, year) VALUES (3,...
Insert new marine species records for 'Australia' in 2022.
INSERT INTO Species_6 (id, name, region, year) VALUES (4, 'Echidna', 'Australia', 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityEngagement (EngagementID INT, Country VARCHAR(255), EngagementScore INT, PRIMARY KEY (EngagementID));
What is the percentage of total community engagement in cultural preservation in Oceania, grouped by country?
SELECT Country, 100.0 * COUNT(*) OVER (PARTITION BY Country) * 1.0 / SUM(COUNT(*)) OVER () AS PercentageOfTotal FROM CommunityEngagement WHERE Country = 'Oceania' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure_projects (id INT, name TEXT, expenditure DECIMAL(10,2)); INSERT INTO rural_infrastructure_projects (id, name, expenditure) VALUES (1, 'RoadA', 5000.00), (2, 'SchoolB', 6000.00), (3, 'HospitalC', 7000.00), (4, 'BridgeD', 8000.00), (5, 'ParkE', 9000.00);
Display the name of the rural infrastructure project and the expenditure, sorted by the expenditure in descending order
SELECT name, expenditure FROM rural_infrastructure_projects ORDER BY expenditure DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite (Id INT, Name VARCHAR(100), LaunchDate DATETIME, Country VARCHAR(50), Function VARCHAR(50), OrbitType VARCHAR(50), Altitude INT); INSERT INTO Satellite (Id, Name, LaunchDate, Country, Function, OrbitType, Altitude) VALUES (4, 'GRACE-FO', '2018-05-22', 'United States', 'Scientific Research', 'LEO'...
What is the average altitude of satellites in Low Earth Orbit (LEO)?
SELECT AVG(Altitude) FROM Satellite WHERE OrbitType = 'LEO';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year_opened INT, total_employees INT); INSERT INTO mines (id, name, location, year_opened, total_employees) VALUES (1, 'Golden Ridge Mine', 'California', 1992, 250); INSERT INTO mines (id, name, location, year_opened, total_employees) VAL...
What is the maximum labor productivity score for mines in Colorado?
SELECT MAX(labor_productivity.productivity_score) as max_productivity FROM labor_productivity JOIN mines ON labor_productivity.mine_id = mines.id WHERE mines.location = 'Colorado';
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Health_Workers (Worker_ID INT, Gender VARCHAR(10), Region VARCHAR(255)); INSERT INTO Community_Health_Workers (Worker_ID, Gender, Region) VALUES (1, 'Male', 'Northeast'), (2, 'Female', 'Northeast'), (3, 'Male', 'South'), (4, 'Female', 'South');
What is the total number of community health workers in each region and the percentage of female community health workers in each region?
SELECT Region, COUNT(*) AS Total_Workers, COUNT(*) FILTER (WHERE Gender = 'Female') * 100.0 / COUNT(*) AS Percentage_Female_Workers FROM Community_Health_Workers GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT);CREATE TABLE fares (fare_id INT, route_id INT, fare DECIMAL); INSERT INTO routes VALUES (123, 'Route 123'); INSERT INTO routes VALUES (456, 'Route 456'); INSERT INTO fares VALUES (1, 123, 2.5); INSERT INTO fares VALUES (2, 123, 2.5); INSERT INTO fares VALUES (3, 456, ...
What is the total fare collected on each route?
SELECT routes.route_name, SUM(fares.fare) FROM routes INNER JOIN fares ON routes.route_id = fares.route_id GROUP BY routes.route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name TEXT);CREATE TABLE research_grant (id INT, faculty_id INT, amount INT);
What is the maximum number of research grants awarded to a single faculty member?
SELECT MAX(rg.count) FROM (SELECT faculty_id, COUNT(*) AS count FROM research_grant rg GROUP BY faculty_id) rg;
gretelai_synthetic_text_to_sql
CREATE TABLE marineshrimp (country VARCHAR(20), temperature DECIMAL(5,2)); INSERT INTO marineshrimp (country, temperature) VALUES ('Thailand', 29.2), ('Thailand', 28.9), ('Thailand', 29.0), ('Thailand', 28.8);
What is the minimum water temperature recorded for marine shrimp farms in Thailand?
SELECT MIN(temperature) FROM marineshrimp WHERE country = 'Thailand';
gretelai_synthetic_text_to_sql
CREATE TABLE CountryPopulation (CountryID INT PRIMARY KEY, CountryName VARCHAR(100), Population INT); INSERT INTO CountryPopulation (CountryID, CountryName, Population) VALUES (1, 'USA', 331002651), (2, 'Canada', 37410003), (3, 'Mexico', 128932753);
What is the average ethical AI certifications per capita by country?
SELECT CountryName, AVG(CertificationCount/Population) as AvgCertificationsPerCapita FROM (SELECT CountryName, COUNT(CertificationID) as CertificationCount FROM EthicalAICertifications GROUP BY CountryName) AS CertificationsPerCountry JOIN CountryPopulation ON CertificationsPerCountry.CountryName = CountryPopulation.Co...
gretelai_synthetic_text_to_sql
CREATE TABLE country_deliveries (delivery_id INT, item_count INT, delivery_date DATE, country VARCHAR(50)); INSERT INTO country_deliveries (delivery_id, item_count, delivery_date, country) VALUES (1, 10, '2022-01-01', 'Brazil'), (2, 20, '2022-01-02', 'Argentina');
What is the total number of items delivered to 'country_deliveries' table for 'South America' in the year 2022?
SELECT SUM(item_count) FROM country_deliveries WHERE EXTRACT(YEAR FROM delivery_date) = 2022 AND country = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE underwater_volcanoes (id INT, name TEXT, lat FLOAT, lon FLOAT, depth INT); INSERT INTO underwater_volcanoes (id, name, lat, lon, depth) VALUES (1, 'NW Rota-1', 14.05, 145.75, 5367), (2, 'Ferdinand De Lesseps', 11.87, 142.33, 4000); CREATE TABLE mariana_trench (id INT, point TEXT, lat FLOAT, lon FLOAT); INS...
List all underwater volcanoes near the Mariana Trench.
SELECT uv.name FROM underwater_volcanoes uv INNER JOIN mariana_trench mt ON uv.lat BETWEEN mt.lat - 1 AND mt.lat + 1 AND uv.lon BETWEEN mt.lon - 1 AND mt.lon + 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (ocean TEXT, depth FLOAT); INSERT INTO ocean_depths (ocean, depth) VALUES ('Atlantic Ocean', 8605.0);
What is the maximum depth in the Atlantic Ocean?
SELECT MAX(depth) FROM ocean_depths WHERE ocean = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, category TEXT, assets FLOAT); INSERT INTO clients (id, name, category, assets) VALUES (1, 'John Doe', 'Medium-Risk', 50000.00), (2, 'Jane Smith', 'Low-Risk', 75000.00), (3, 'Alice Johnson', 'High-Risk', 100000.00), (4, 'Bob Brown', 'Low-Risk', 120000.00);
What is the average assets value for clients in the 'Low-Risk' category?
SELECT AVG(assets) FROM clients WHERE category = 'Low-Risk';
gretelai_synthetic_text_to_sql
CREATE TABLE fans (fan_id INT, age INT, gender VARCHAR(10), city VARCHAR(20)); INSERT INTO fans VALUES (1, 25, 'Male', 'New York'); INSERT INTO fans VALUES (2, 35, 'Female', 'Los Angeles'); CREATE TABLE games (game_id INT, team VARCHAR(20), location VARCHAR(20)); INSERT INTO games VALUES (1, 'Knicks', 'New York'); INSE...
What is the average age of fans who attended home games for the basketball team in New York?
SELECT AVG(fans.age) FROM fans INNER JOIN games ON fans.city = games.location WHERE games.team = 'Knicks';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, city VARCHAR(20), capacity INT); INSERT INTO warehouse (id, city, capacity) VALUES (1, 'Chicago', 1000), (2, 'Houston', 1500), (3, 'Miami', 800);
Update the capacity of the warehouse in Miami to 1200
UPDATE warehouse SET capacity = 1200 WHERE city = 'Miami';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY, location VARCHAR(50), condition VARCHAR(50), prevalence FLOAT);
What are the most common mental health conditions in rural areas of the US?
SELECT condition FROM mental_health_conditions WHERE location = 'rural areas' GROUP BY condition ORDER BY SUM(prevalence) DESC;
gretelai_synthetic_text_to_sql