context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE company (id INT, name VARCHAR(255)); INSERT INTO company (id, name) VALUES (1, 'MaritimeCorp'); CREATE TABLE port (id INT, name VARCHAR(255)); CREATE TABLE cargo (id INT, port_id INT, company_id INT, weight INT, year INT); INSERT INTO port (id, name) VALUES (1, 'PortA'), (2, 'PortB'), (3, 'PortC'); INSERT ...
List the ports and their total cargo weight for company "MaritimeCorp" in 2017.
SELECT port.name, SUM(cargo.weight) FROM port INNER JOIN cargo ON port.id = cargo.port_id AND cargo.year = 2017 INNER JOIN company ON cargo.company_id = company.id WHERE company.name = 'MaritimeCorp' GROUP BY port.name;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkersCanada (WorkerID INT, Age INT, Gender VARCHAR(1), Province VARCHAR(2)); INSERT INTO CommunityHealthWorkersCanada (WorkerID, Age, Gender, Province) VALUES (1, 35, 'F', 'ON'), (2, 40, 'M', 'QC');
Insert new records of 2 community health workers from 'NS' and 'NB' provinces in Canada.
INSERT INTO CommunityHealthWorkersCanada (WorkerID, Age, Gender, Province) VALUES ((SELECT MAX(WorkerID) FROM CommunityHealthWorkersCanada) + 1, 33, 'M', 'NS'), ((SELECT MAX(WorkerID) FROM CommunityHealthWorkersCanada) + 2, 47, 'F', 'NB');
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, therapy_sessions INT, treatment_outcome VARCHAR(10)); INSERT INTO patients (patient_id, therapy_sessions, treatment_outcome) VALUES (1, 10, 'positive'), (2, 5, 'negative'), (3, 8, 'positive');
What is the average number of therapy sessions attended by patients who experienced positive outcomes?
SELECT AVG(therapy_sessions) FROM patients WHERE treatment_outcome = 'positive';
gretelai_synthetic_text_to_sql
CREATE TABLE lawyers (id INT, state VARCHAR(255), name VARCHAR(255), cases_handled INT, cases_won INT); INSERT INTO lawyers (id, state, name, cases_handled, cases_won) VALUES (1, 'Texas', 'Smith', 50, 45), (2, 'Texas', 'Johnson', 75, 60), (3, 'California', 'Williams', 100, 80);
Who are the top 5 lawyers with the most number of cases won in the state of Texas?
SELECT name, cases_won FROM lawyers WHERE state = 'Texas' ORDER BY cases_won DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tourism (location TEXT, year INT, revenue INT); INSERT INTO virtual_tourism (location, year, revenue) VALUES ('Barcelona', 2022, 1500000), ('Barcelona', 2023, 1800000);
What is the virtual tourism revenue in Barcelona for 2022?
SELECT revenue FROM virtual_tourism WHERE location = 'Barcelona' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (property_id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), year_built INT, inclusive_features VARCHAR(255));
Add a new record for a property with inclusive housing features in 'Seattle' built in 2018 to the 'inclusive_housing' table
INSERT INTO inclusive_housing (property_id, address, city, state, year_built, inclusive_features) VALUES (11123, '789 Inclusive Lane', 'Seattle', 'WA', 2018, 'wheelchair accessible, visual/hearing assistance');
gretelai_synthetic_text_to_sql
CREATE TABLE open_data_initiatives (id INT, sector VARCHAR(20), status VARCHAR(10)); INSERT INTO open_data_initiatives (id, sector, status) VALUES (1, 'education', 'open'), (2, 'health', 'open'), (3, 'transportation', 'closed');
What is the total number of open data initiatives in the education and health sectors?
SELECT SUM(id) FROM open_data_initiatives WHERE sector IN ('education', 'health') AND status = 'open';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(20), language VARCHAR(20)); INSERT INTO smart_contracts (contract_id, name, language) VALUES (1, 'Crowdfund', 'Solidity'), (2, 'Voting', 'Vyper'), (3, 'Exchange', 'Rust'), (4, 'Insurance', 'LLL');
Delete smart contract with contract_id 4
DELETE FROM smart_contracts WHERE contract_id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, style VARCHAR(20), price DECIMAL(10,2)); INSERT INTO Artworks (artwork_id, style, price) VALUES (1, 'Impressionist', 1200.00), (2, 'Cubist', 1500.00), (3, 'Impressionist', 1800.00);
What is the average price of all paintings in the 'Impressionist' style?
SELECT AVG(price) FROM Artworks WHERE style = 'Impressionist';
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_mexico (month INT, max_temperature DECIMAL(5,2)); INSERT INTO temperature_mexico VALUES (7, 32.5), (7, 33.1), (7, 32.8), (7, 31.9), (7, 33.7);
What is the maximum temperature in Mexico in July for the past 5 years?
SELECT MAX(max_temperature) FROM temperature_mexico WHERE month = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), TotalDonations DECIMAL(10,2)); CREATE TABLE Outcomes (ProgramID INT, ProgramOutcome VARCHAR(20)); INSERT INTO Programs (ProgramID, ProgramName, TotalDonations) VALUES (1, 'Feeding America', 15000.00), (2, 'Education for All', 5000.00), (3, 'Feeding America'...
List the programs with the highest total donations and their respective outcomes?
SELECT Programs.ProgramName, ProgramOutcome, TotalDonations FROM Programs INNER JOIN Outcomes ON Programs.ProgramID = Outcomes.ProgramID WHERE Programs.TotalDonations IN (SELECT MAX(TotalDonations) FROM Programs);
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_id INT, project_name VARCHAR(50), region VARCHAR(50), start_year INT, end_year INT, project_status VARCHAR(20)); INSERT INTO renewable_energy_projects (project_id, project_name, region, start_year, end_year, project_status) VALUES (1, 'Solar Power Plant', 'Latin America',...
Identify the number of renewable energy projects implemented in Latin America between 2015 and 2020, grouped by project status.
SELECT project_status, COUNT(project_id) FROM renewable_energy_projects WHERE region = 'Latin America' AND start_year BETWEEN 2015 AND 2020 GROUP BY project_status;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings.green_buildings_data (city VARCHAR(20), green_building BOOLEAN); CREATE TABLE carbon_offset.offset_initiatives (city VARCHAR(20), co2_reduction_tons INT);
Find the average CO2 emission reduction (in metric tons) per green building in the 'green_buildings' and 'carbon_offset' schemas.
SELECT AVG(co2_reduction_tons / (SELECT COUNT(*) FROM green_buildings.green_buildings_data WHERE green_building = TRUE)) AS avg_co2_reduction_per_green_building FROM carbon_offset.offset_initiatives WHERE green_building = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT, equipment_name VARCHAR(50), equipment_type VARCHAR(50), region VARCHAR(50)); INSERT INTO military_equipment (id, equipment_name, equipment_type, region) VALUES (1, 'Helicopter A', 'Helicopter', 'Atlantic'), (2, 'Tank B', 'Tank', 'Pacific');
Insert a new record into the military equipment table for a helicopter in the Atlantic region?
INSERT INTO military_equipment (id, equipment_name, equipment_type, region) VALUES (3, 'Helicopter C', 'Helicopter', 'Atlantic');
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives(country VARCHAR(50), year INT, initiative_count INT, success_count INT); INSERT INTO conservation_initiatives(country, year, initiative_count, success_count) VALUES ('South Africa', 2020, 150, 120), ('South Africa', 2019, 140, 110), ('South Africa', 2018, 130, 105);
What is the percentage of water conservation initiatives implemented in South Africa that were successful?
SELECT (SUM(success_count) * 100.0 / SUM(initiative_count)) FROM conservation_initiatives WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(255)); INSERT INTO customers (id, name, state) VALUES (1, 'Customer A', 'CA'), (2, 'Customer B', 'NY'), (3, 'Customer C', 'TX'), (4, 'Customer D', 'FL'); CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, product_id INT, FOREIGN KEY (cu...
List all customers who have purchased products with a sustainability score of 90 or higher?
SELECT DISTINCT c.name FROM customers c INNER JOIN orders o ON c.id = o.customer_id INNER JOIN products p ON o.product_id = p.id WHERE p.sustainability_score >= 90;
gretelai_synthetic_text_to_sql
CREATE TABLE us_vessels (id INT, port VARCHAR(20), visit_date DATE); INSERT INTO us_vessels (id, port, visit_date) VALUES (1, 'Los Angeles', '2021-07-01'); INSERT INTO us_vessels (id, port, visit_date) VALUES (2, 'New York', '2021-07-10');
How many vessels visited the ports in the United States in July 2021?
SELECT COUNT(*) FROM us_vessels WHERE visit_date >= '2021-07-01' AND visit_date < '2021-08-01' AND port IN ('Los Angeles', 'New York', 'Seattle', 'Houston', 'Miami');
gretelai_synthetic_text_to_sql
CREATE TABLE Supplies (supplier_id INTEGER, raw_material_code TEXT); INSERT INTO Supplies (supplier_id, raw_material_code) VALUES (123, 'M123'), (456, 'M234'), (789, 'M345'), (111, 'M456'), (123, 'M567'); CREATE TABLE Products (product_code TEXT, raw_material_code TEXT); INSERT INTO Products (product_code, raw_material...
Which suppliers provide raw materials for the production of products 'A101' and 'C567'?
SELECT DISTINCT s.supplier_id FROM Supplies s JOIN Products p ON s.raw_material_code = p.raw_material_code WHERE p.product_code = 'A101' OR p.product_code = 'C567';
gretelai_synthetic_text_to_sql
CREATE TABLE ChargingStations (Country VARCHAR(50), Stations INT); INSERT INTO ChargingStations (Country, Stations) VALUES ('China', 180000), ('United States', 80000), ('Germany', 50000), ('Norway', 15000), ('Japan', 50000), ('France', 45000), ('Netherlands', 35000), ('Sweden', 20000), ('South Korea', 15000), ('United ...
What are the top 5 countries with the most electric vehicle charging stations?
SELECT Country, Stations FROM ChargingStations ORDER BY Stations DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE preparedness (id INT, city VARCHAR(255), preparedness_events INT, emergency_supplies INT, first_responder_training_hours INT); INSERT INTO preparedness (id, city, preparedness_events, emergency_supplies, first_responder_training_hours) VALUES (1, 'Toronto', 50, 200, 1000); INSERT INTO preparedness (id, cit...
Compare disaster preparedness metrics, including the number of community preparedness events, emergency supplies, and first responder training hours, between two cities in Canada.
SELECT p.city, AVG(p.preparedness_events) AS avg_preparedness_events, AVG(p.emergency_supplies) AS avg_emergency_supplies, AVG(p.first_responder_training_hours) AS avg_first_responder_training_hours FROM preparedness p WHERE p.city IN ('Toronto', 'Vancouver') GROUP BY p.city;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_sightings (id INT, species TEXT, sighting_date DATE); INSERT INTO animal_sightings (id, species, sighting_date) VALUES (1, 'Polar Bear', '2023-01-01'); INSERT INTO animal_sightings (id, species, sighting_date) VALUES (2, 'Arctic Fox', '2023-01-02'); CREATE TABLE plant_observations (id INT, species T...
List the unique species found in the 'animal_sightings', 'plant_observations', and 'fungi_findings' tables.
(SELECT species FROM animal_sightings) UNION (SELECT species FROM plant_observations) UNION (SELECT species FROM fungi_findings);
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (id INT, language VARCHAR(50), status VARCHAR(50), region VARCHAR(50)); INSERT INTO Languages (id, language, status, region) VALUES (1, 'Hawaiian', 'Vulnerable', 'Polynesia'); INSERT INTO Languages (id, language, status, region) VALUES (2, 'Samoan', 'Safe', 'Polynesia');
Which languages have been preserved in Oceania?
SELECT Languages.language FROM Languages WHERE Languages.region = 'Polynesia' AND Languages.status = 'Safe';
gretelai_synthetic_text_to_sql
CREATE TABLE consumers (id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255), ethical_awareness INT);
Identify the top 3 locations with the highest ethical awareness score among consumers, along with their average age.
SELECT c.location, AVG(c.age) as avg_age, SUM(c.ethical_awareness) as total_awareness, RANK() OVER (PARTITION BY 1 ORDER BY total_awareness DESC) as rank FROM consumers c GROUP BY c.location HAVING rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(100), cost FLOAT, state VARCHAR(50)); INSERT INTO Projects (id, name, cost, state) VALUES (1, 'Highway 90 Expansion', 1200000000, 'New York');
What is the maximum construction cost and corresponding project name for all public works projects in the state of New York?
SELECT name, MAX(cost) FROM Projects WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_gender TEXT, founder_race TEXT); INSERT INTO company (id, name, founding_year, founder_gender, founder_race) VALUES (1, 'Eco-Friendly Inc', 2020, 'female', 'Black'); INSERT INTO company (id, name, founding_year, founder_gender, founder_race) VALUES (2,...
What is the count of companies founded by Black women?
SELECT COUNT(*) FROM company WHERE founder_gender = 'female' AND founder_race = 'Black';
gretelai_synthetic_text_to_sql
CREATE TABLE parcel_delivery (route_id INT, start_location VARCHAR(255), end_location VARCHAR(255), distance INT); INSERT INTO parcel_delivery (route_id, start_location, end_location, distance) VALUES (1, 'New York', 'Los Angeles', 4000), (2, 'Chicago', 'Miami', 2500), (3, 'Toronto', 'Vancouver', 3500), (4, 'London', '...
What are the top 3 longest parcel_delivery routes by distance?
SELECT route_id, start_location, end_location, distance FROM parcel_delivery ORDER BY distance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE researchers (id INT PRIMARY KEY, name VARCHAR(100), affiliation VARCHAR(100), community VARCHAR(100));
Delete the record with id 2 from the "researchers" table
WITH del AS (DELETE FROM researchers WHERE id = 2 RETURNING id) SELECT id FROM del;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (id INT, name VARCHAR(50), membership VARCHAR(50)); INSERT INTO Members (id, name, membership) VALUES (1, 'Surae', 'Premium'), (2, 'Javier', 'Basic'), (3, 'Minh', 'Premium'), (4, 'Elena', 'Premium'); CREATE TABLE MemberDemographics (id INT, member_id INT, age INT, gender VARCHAR(50)); INSERT INTO M...
Show the membership demographics for members who have a 'Premium' membership type.
SELECT m.name, d.age, d.gender FROM Members m JOIN MemberDemographics d ON m.id = d.member_id WHERE m.membership = 'Premium';
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, base TEXT, region TEXT, personnel INT); INSERT INTO military_personnel (id, base, region, personnel) VALUES (1, 'Al Udeid Air Base', 'Middle East', 11000), (2, 'Incirlik Air Base', 'Middle East', 5000), (3, 'Ali Al Salem Air Base', 'Middle East', 3000);
What is the total number of military personnel in the 'Middle East' region?
SELECT SUM(personnel) FROM military_personnel WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID int, Region varchar(50), BillingAmount decimal(5,2)); INSERT INTO Attorneys (AttorneyID, Region, BillingAmount) VALUES (1, 'California', 500.00), (2, 'New York', 400.00), (3, 'California', 300.00), (4, 'New York', 600.00);
What is the maximum billing amount for cases handled by attorneys from the 'California' region?
SELECT MAX(BillingAmount) FROM Attorneys WHERE Region = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE media_library (id INT, type VARCHAR(10), title VARCHAR(50), length FLOAT, source VARCHAR(50)); INSERT INTO media_library (id, type, title, length, source) VALUES (1, 'article', 'Sample Article 1', 5.5, 'BBC'); INSERT INTO media_library (id, type, title, length, source) VALUES (2, 'video', 'Sample Video 1',...
What are the total number of articles and videos in the 'media_library'?
SELECT COUNT(*) FROM media_library WHERE type IN ('article', 'video');
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_id INT, name VARCHAR(100), capacity INT, technology VARCHAR(50)); INSERT INTO renewable_energy_projects (project_id, name, capacity, technology) VALUES (1, 'Wind Farm', 300, 'Wind');
What is the total installed capacity of wind energy projects in Canada?
SELECT SUM(capacity) as total_capacity FROM renewable_energy_projects WHERE country = 'Canada' AND technology = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (provider_id INT, name TEXT, state TEXT); INSERT INTO healthcare_providers (provider_id, name, state) VALUES (1, 'Jane Smith', 'NY'); CREATE TABLE cultural_competency (provider_id INT, score INT, community TEXT);
List the cultural competency scores for healthcare providers serving underrepresented communities in NY and NJ.
SELECT h.name, c.score FROM healthcare_providers h INNER JOIN cultural_competency c ON h.provider_id = c.provider_id WHERE h.state IN ('NY', 'NJ') AND c.community IN ('Underrepresented');
gretelai_synthetic_text_to_sql
CREATE TABLE state (id INT, location TEXT, country TEXT);
Find the number of renewable energy projects in each state of the United States
SELECT state.location, COUNT(*) FROM state JOIN renewable_energy ON state.location = renewable_energy.location WHERE state.country = 'United States' GROUP BY state.location;
gretelai_synthetic_text_to_sql
CREATE TABLE mineral_extraction (mine_id INT, country TEXT, quantity INT); INSERT INTO mineral_extraction (mine_id, country, quantity) VALUES (1, 'USA', 5000), (2, 'Canada', 6000), (3, 'Mexico', 4000);
What is the sum of mineral extraction for each country?
SELECT country, SUM(quantity) FROM mineral_extraction GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE private_lands.wildlife_habitat (species VARCHAR(255), score DECIMAL(5,2));
List the tree species with their respective wildlife habitat scores in the private_lands schema, in descending order.
SELECT species, score FROM private_lands.wildlife_habitat ORDER BY score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE tram_fares (region VARCHAR(10), fare DECIMAL(5,2)); INSERT INTO tram_fares (region, fare) VALUES ('east', 1.75), ('east', 2.00), ('west', 2.25), ('north', 1.50), ('south', 2.50);
What is the total fare collected from trams in the 'east' region?
SELECT SUM(fare) FROM tram_fares WHERE region = 'east';
gretelai_synthetic_text_to_sql
CREATE TABLE miami_community_policing (id INT, event_type TEXT, event_date DATE); INSERT INTO miami_community_policing (id, event_type, event_date) VALUES (1, 'Meeting', '2022-01-01'), (2, 'Workshop', '2022-02-01'), (3, 'Patrol', '2022-03-01');CREATE TABLE miami_community_policing_types (id INT, event_type TEXT); INSE...
What is the total number of community policing events in Miami?
SELECT COUNT(*) FROM miami_community_policing;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_awards (id INT, artist VARCHAR(100), country VARCHAR(100), awards_won INT); INSERT INTO artist_awards (id, artist, country, awards_won) VALUES (1, 'Artist10', 'UK', 10), (2, 'Artist11', 'USA', 15), (3, 'Artist12', 'Canada', 8);
What is the total number of awards won by artists from different countries?
SELECT country, SUM(awards_won) as total_awards_won FROM artist_awards GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE data_usage (subscriber_id INT, subscription_type VARCHAR(50), data_usage FLOAT, data_limit FLOAT); INSERT INTO data_usage (subscriber_id, subscription_type, data_usage, data_limit) VALUES (1, 'Mobile', 3.5, 2), (2, 'Broadband', 50, 40), (3, 'Mobile', 4.5, 3);
Calculate the percentage of mobile and broadband subscribers who have exceeded their data usage limits, and display the results in a format suitable for pivot tables.
SELECT subscription_type, ROUND(SUM(CASE WHEN data_usage > data_limit THEN 1 ELSE 0 END) * 100.0 / COUNT(*) , 2) as exceeded_limit_percentage FROM data_usage GROUP BY subscription_type;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_ets_data (country TEXT, date DATE, price FLOAT); INSERT INTO eu_ets_data (country, date, price) VALUES ('Germany', '2022-01-01', 30.0), ('France', '2022-01-01', 28.0), ('Italy', '2022-01-01', 32.0); CREATE TABLE japan_ets_data (country TEXT, date DATE, price FLOAT); INSERT INTO japan_ets_data (country, ...
Which countries in the EU have a higher carbon price (€/tCO2) than Japan?
SELECT country FROM eu_ets_data WHERE price > (SELECT price FROM japan_ets_data);
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, City TEXT); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, VolunteerName TEXT);
List the programs along with the number of volunteers for each program in the city of Los Angeles.
SELECT Programs.ProgramName, COUNT(Volunteers.ProgramID) AS NumberOfVolunteers FROM Programs INNER JOIN Volunteers ON Programs.ProgramID = Volunteers.ProgramID WHERE Programs.City = 'Los Angeles' GROUP BY Programs.ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT PRIMARY KEY, EventName VARCHAR(255), Attendance INT); CREATE TABLE Audience (AudienceID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Occupation VARCHAR(255), EventID INT, FOREIGN KEY (EventID) REFERENCES Events(EventID)); INSERT INTO Events (EventID, EventName, Attendance) VALUES (1, '...
What is the gender breakdown of attendees for the 'Contemporary Art' event?
SELECT Audience.Gender, COUNT(*) AS Attendance FROM Audience INNER JOIN Events ON Audience.EventID = Events.EventID WHERE Events.EventName = 'Contemporary Art' GROUP BY Audience.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_projects (id INT, name TEXT, state TEXT, investment_usd FLOAT); INSERT INTO solar_power_projects (id, name, state, investment_usd) VALUES (1, 'Solar Star', 'California', 2560.0);
Find the number of solar power projects in California, Texas, and New York with an investment over 100 million dollars.
SELECT COUNT(*) FROM solar_power_projects WHERE state IN ('California', 'Texas', 'New York') AND investment_usd > 100000000.0;
gretelai_synthetic_text_to_sql
CREATE TABLE building_energy_efficiency_history (building_id INT, city VARCHAR(255), rating_year INT, rating FLOAT); INSERT INTO building_energy_efficiency_history (building_id, city, rating_year, rating) VALUES (1, 'City Y', 2019, 75), (2, 'City Y', 2019, 80), (3, 'City Y', 2020, 85), (4, 'City Y', 2020, 90), (5, 'Cit...
What is the trend in energy efficiency ratings for buildings in 'City Y' over the last 3 years?
SELECT rating_year, rating FROM building_energy_efficiency_history WHERE city = 'City Y';
gretelai_synthetic_text_to_sql
CREATE TABLE Habitats (id INT, name VARCHAR(20)); INSERT INTO Habitats (id, name) VALUES (1, 'Habitat A'), (2, 'Habitat B'), (3, 'Habitat C'); CREATE TABLE Animals (id INT, name VARCHAR(20), habitat_id INT); INSERT INTO Animals (id, name, habitat_id) VALUES (1, 'Tiger', 1), (2, 'Elephant', 1), (3, 'Lion', 2), (4, 'Zebr...
What is the name of the habitat with the most animals?
SELECT h.name FROM Habitats h JOIN (SELECT habitat_id, COUNT(*) AS animal_count FROM Animals GROUP BY habitat_id ORDER BY animal_count DESC LIMIT 1) a ON h.id = a.habitat_id;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_incidents (id INT, incident_type VARCHAR(255), emergency_borough VARCHAR(255), response_time INT); INSERT INTO emergency_incidents (id, incident_type, emergency_borough, response_time) VALUES (1, 'Medical Emergency', 'Manhattan', 15); INSERT INTO emergency_incidents (id, incident_type, emergency_...
Find the total number of emergency incidents and associated response times, grouped by emergency type, in New York City's Manhattan borough.
SELECT e.incident_type, b.borough, COUNT(e.id) AS total_incidents, AVG(e.response_time) AS avg_response_time FROM emergency_incidents e INNER JOIN boroughs b ON e.emergency_borough = b.borough WHERE b.borough = 'Manhattan' GROUP BY e.incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT PRIMARY KEY, name VARCHAR(255), hectares DECIMAL(5,2), country VARCHAR(255)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Greenwood', 520.00, 'Canada'); CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(255), common_name VARCHAR(255)); INSERT INTO Species (id, name, c...
List all the species and the number of forests they are present in for each country?
SELECT Species.name as species_name, Forests.country, COUNT(Species_Forests.forest_id) as num_forests FROM Species LEFT JOIN Species_Forests ON Species.id = Species_Forests.species_id LEFT JOIN Forests ON Species_Forests.forest_id = Forests.id GROUP BY Species.name, Forests.country;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_date DATE, amount DECIMAL(10,2), gender TEXT); INSERT INTO donations (donor_id, donation_date, amount, gender) VALUES (1, '2020-01-01', 1000.00, 'Male'), (2, '2020-02-01', 1500.00, 'Female'), (3, '2020-03-01', 2000.00, 'Non-binary');
What was the average donation amount by gender in 2020?
SELECT gender, AVG(amount) as avg_donation_amount FROM donations WHERE YEAR(donation_date) = 2020 GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name TEXT, department TEXT, role TEXT); CREATE TABLE workforce_development (id INT PRIMARY KEY, employee_id INT, training_completed TEXT, FOREIGN KEY (employee_id) REFERENCES employees(id));
Which employees have not completed any training?
SELECT employees.name, employees.department, employees.role FROM employees LEFT JOIN workforce_development ON employees.id = workforce_development.employee_id WHERE workforce_development.training_completed IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments_2 (investment_id INT, amount FLOAT, region VARCHAR(20)); INSERT INTO network_investments_2 (investment_id, amount, region) VALUES (4, 75000.0, 'South'), (5, 80000.0, 'South'), (6, 70000.0, 'South');
Add new network infrastructure investments for the South region.
INSERT INTO network_investments SELECT * FROM network_investments_2 WHERE region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_assessments (id INT PRIMARY KEY, chemical_id INT, year INT, co2_emissions FLOAT, waste_generated FLOAT); INSERT INTO environmental_impact_assessments (id, chemical_id, year, co2_emissions, waste_generated) VALUES (1, 1, 2020, 120.5, 25.3), (2, 2, 2020, 180.2, 34.6), (3, 3, 2020, 110.8,...
Insert new environmental impact assessment records for the given chemicals.
INSERT INTO environmental_impact_assessments (id, chemical_id, year, co2_emissions, waste_generated) VALUES (6, 6, 2020, 150.7, 31.2), (7, 7, 2020, 105.6, 20.5), (8, 8, 2020, 142.3, 29.8), (9, 9, 2020, 128.8, 27.9), (10, 10, 2020, 118.1, 25.6);
gretelai_synthetic_text_to_sql
CREATE TABLE Publications (PublicationID INT PRIMARY KEY, Title VARCHAR(255), Author VARCHAR(255), Year INT, Type VARCHAR(255)); INSERT INTO Publications (PublicationID, Title, Author, Year, Type) VALUES (1, 'The Tomb of Tutankhamun', 'Howard Carter', 1923, 'Book');
Insert data into the publications table
INSERT INTO Publications (PublicationID, Title, Author, Year, Type) VALUES (1, 'The Tomb of Tutankhamun', 'Howard Carter', 1923, 'Book');
gretelai_synthetic_text_to_sql
CREATE TABLE emissions_reduction (id INT, year INT, co2 INT, methane INT);
Delete records from the 'emissions_reduction' table where the value of 'co2' is equal to 0
DELETE FROM emissions_reduction WHERE co2 = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, author VARCHAR(50), title VARCHAR(100), category VARCHAR(50), word_count INT, publication_date DATE);
What is the total number of articles published in each category, broken down by the author who wrote the most articles in that category?
SELECT category, author, COUNT(article_id) AS articles_in_category FROM articles a1 WHERE (author, category) IN (SELECT author, category FROM (SELECT author, category, COUNT(article_id) AS article_count FROM articles GROUP BY author, category) a2 WHERE article_count = (SELECT MAX(article_count) FROM a2 WHERE a2.categor...
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (Id INT, Astronaut VARCHAR(20), Mission VARCHAR(20), Duration INT); INSERT INTO SpaceMissions VALUES (1, 'Astronaut1', 'Mars Rover', 300), (2, 'Astronaut2', 'Moon Rover', 250), (3, 'Astronaut3', 'Mars Rover', 400), (4, 'Astronaut4', 'Space Station', 500), (5, 'Astronaut5', 'Moon Rover', 200);
What is the maximum duration of space missions by astronaut?
SELECT Astronaut, MAX(Duration) as MaxDuration FROM SpaceMissions GROUP BY Astronaut;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name TEXT, type TEXT, material TEXT); INSERT INTO Projects (id, name, type, material) VALUES (1, 'Highway Construction', 'Road', 'Concrete'), (2, 'Dam Construction', 'Water', 'Steel'), (3, 'Bridge Construction', 'Road', 'Steel');
Show the number of water and road type projects in the database, grouped by their construction material.
SELECT type, material, COUNT(*) FROM Projects WHERE type IN ('Water', 'Road') GROUP BY type, material
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (id INT, model VARCHAR(50), maintenance_status VARCHAR(50)); INSERT INTO aircraft (id, model, maintenance_status) VALUES (1, 'F-16', 'under_maintenance'), (2, 'F-35', 'operational'), (3, 'A-10', 'under_maintenance');
How many military aircraft are currently under maintenance?
SELECT COUNT(*) FROM aircraft WHERE maintenance_status = 'under_maintenance';
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalData (SiteName VARCHAR(50), Temperature DECIMAL(5,2), DateMeasured DATE); INSERT INTO EnvironmentalData (SiteName, Temperature, DateMeasured) VALUES ('Site A', 25.5, '2022-03-15');
What is the average temperature at each mining site?
SELECT SiteName, AVG(Temperature) FROM EnvironmentalData GROUP BY SiteName;
gretelai_synthetic_text_to_sql
CREATE TABLE refugees (id INT, country TEXT, year INT, num_refugees INT); INSERT INTO refugees
What was the average number of refugees helped per country in 2018?
SELECT AVG(num_refugees) FROM refugees WHERE year = 2018 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, release_year INT, genre TEXT); INSERT INTO songs (id, title, release_year, genre) VALUES (1, 'Song1', 2011, 'pop'), (2, 'Song2', 2009, 'rock');
Count the number of songs in the 'pop' genre released after 2010.
SELECT COUNT(*) FROM songs WHERE release_year > 2010 AND genre = 'pop';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(50), cases_handled INT, region VARCHAR(50), billable_rate DECIMAL(10,2)); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (1, 'John Lee', 40, 'Northeast', 200.00); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (2,...
Update the billable rate for an attorney
UPDATE attorneys SET billable_rate = 225.00 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(255), genre VARCHAR(255)); CREATE TABLE albums (id INT, artist_id INT, title VARCHAR(255), release_year INT); INSERT INTO artists (id, name, genre) VALUES (1, 'Miles Davis', 'Jazz'), (2, 'John Coltrane', 'Jazz'), (3, 'Nina Simone', 'Jazz'); INSERT INTO albums (id, artist_id, t...
How many albums were released by jazz artists in 2010?
SELECT COUNT(*) FROM albums WHERE genre = 'Jazz' AND release_year = 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE user_stats (id INT, user_id INT, posts INT, day DATE); INSERT INTO user_stats (id, user_id, posts, day) VALUES (1, 1, 5, '2022-03-28'), (2, 2, 3, '2022-03-29'), (3, 3, 7, '2022-03-30'); CREATE TABLE users (id INT, region VARCHAR(255)); INSERT INTO users (id, region) VALUES (1, 'Egypt'), (2, 'South Africa')...
What is the average number of posts per day by users in Africa?
SELECT AVG(posts) AS avg_posts_per_day, region FROM user_stats INNER JOIN users ON user_stats.user_id = users.id WHERE region LIKE 'Africa%' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE patient (id INT, name TEXT, mental_health_score INT, ethnicity TEXT); INSERT INTO patient (id, name, mental_health_score, ethnicity) VALUES (1, 'John Doe', 60, 'Straight'), (2, 'Jane Smith', 70, 'LGBTQ+'), (3, 'Ana Garcia', 50, 'Latino'), (4, 'Sara Johnson', 85, 'African American'), (5, 'Hiroshi Tanaka', 9...
What is the average mental health score for patients, grouped by their ethnicity?
SELECT AVG(mental_health_score), ethnicity FROM patient GROUP BY ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk (project_name VARCHAR(255), risk_level VARCHAR(255)); INSERT INTO geopolitical_risk (project_name, risk_level) VALUES ('Project A', 'medium'), ('Project B', 'low'), ('Project D', 'medium');
Update the geopolitical risk assessment of Project D to high.
UPDATE geopolitical_risk SET risk_level = 'high' WHERE project_name = 'Project D';
gretelai_synthetic_text_to_sql
CREATE TABLE Universities (UniversityID INT PRIMARY KEY, UniversityName VARCHAR(50), NumberOfStudents INT, BudgetForDisabilityAccommodations DECIMAL(10,2), UniversityLocation VARCHAR(50));
What is the average budget for disability accommodations per student with disabilities in universities located in the Asia-Pacific region?
SELECT AVG(BudgetForDisabilityAccommodations/NumberOfStudentsWithDisabilities) as AvgBudgetPerStudent FROM Universities WHERE UniversityLocation LIKE '%Asia-Pacific%';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (project_name VARCHAR(50), country VARCHAR(50), wind_capacity INT); INSERT INTO renewable_energy (project_name, country, wind_capacity) VALUES ('Project1', 'Germany', 5000), ('Project2', 'Germany', 12000), ('Project3', 'Germany', 8000);
What is the minimum installed capacity of wind turbines for all renewable energy projects in Germany?
SELECT MIN(wind_capacity) FROM renewable_energy WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, Name varchar(50), Gender varchar(10), Department varchar(50), HireDate date); INSERT INTO Employees (EmployeeID, Name, Gender, Department, HireDate) VALUES (1, 'John Doe', 'Male', 'Marketing', '2017-01-01'); INSERT INTO Employees (EmployeeID, Name, Gender, Department, HireDate) V...
How many female employees have been hired in the Marketing department since 2018?
SELECT COUNT(*) FROM Employees WHERE Gender = 'Female' AND Department = 'Marketing' AND YEAR(HireDate) >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (DispensaryID INT, DispensaryName VARCHAR(50)); CREATE TABLE Strains (StrainID INT, StrainName VARCHAR(50)); CREATE TABLE Sales (SaleID INT, DispensaryID INT, StrainID INT, QuantitySold INT, SaleDate DATE);
Find the top 3 strains sold in each dispensary, ordered by total sales amount in descending order.
SELECT DispensaryID, StrainID, SUM(QuantitySold) AS TotalSales, ROW_NUMBER() OVER (PARTITION BY DispensaryID ORDER BY SUM(QuantitySold) DESC) AS Rank FROM Sales S JOIN Dispensaries D ON S.DispensaryID = D.DispensaryID JOIN Strains ST ON S.StrainID = ST.StrainID GROUP BY DispensaryID, StrainID;
gretelai_synthetic_text_to_sql
CREATE TABLE user_demographics (user_id INT, name VARCHAR(255), registration_date DATE, age INT);
What is the average age of registered users in the 'user_demographics' table?
SELECT AVG(age) as avg_age FROM user_demographics;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR(255)); CREATE TABLE Menu (id INT, restaurant_id INT, item_name VARCHAR(255), price DECIMAL(5,2), vegetarian BOOLEAN); CREATE TABLE Sales (id INT, dish_name VARCHAR(255), revenue DECIMAL(5,2));
What is the total revenue for dishes served at Restaurant A that are vegetarian?
SELECT SUM(revenue) FROM Sales s JOIN Menu m ON s.dish_name = m.item_name JOIN Restaurants r ON m.restaurant_id = r.id WHERE r.name = 'Restaurant A' AND m.vegetarian = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT); INSERT INTO customers (customer_id, name) VALUES (1, 'John Doe'); INSERT INTO customers (customer_id, name) VALUES (2, 'Jane Smith'); INSERT INTO transactions (transaction_id, customer_id) VALUES...
Find the number of customers who made a transaction in the last month.
SELECT COUNT(DISTINCT customer_id) as num_customers FROM transactions WHERE transaction_date BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(50));CREATE TABLE inventory (product_id INT, product_name VARCHAR(50), quantity INT, store_id INT);
Find the total quantity of "organic apples" sold by each store
SELECT i.store_id, s.store_name, SUM(i.quantity) as total_quantity FROM inventory i JOIN stores s ON i.store_id = s.store_id WHERE i.product_name = 'organic apples' GROUP BY i.store_id, s.store_name;
gretelai_synthetic_text_to_sql
CREATE TABLE drought_data (id INT, region VARCHAR(30), area_size INT, drought_impact INT); INSERT INTO drought_data (id, region, area_size, drought_impact) VALUES (1, 'RegionA', 5000, 2500), (2, 'RegionB', 6000, 4000), (3, 'RegionC', 7000, 3000);
What is the percentage of drought-affected areas in each region?
SELECT region, (drought_impact * 100.0 / area_size) as drought_percentage FROM drought_data;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_disease_prevalence_2 (id INT, province TEXT, diabetes_prevalence DECIMAL(5,2), heart_disease_prevalence DECIMAL(5,2)); INSERT INTO rural_disease_prevalence_2 (id, province, diabetes_prevalence, heart_disease_prevalence) VALUES (1, 'Province1', 13.0, 7.5), (2, 'Province2', 14.8, 8.3);
What is the name of the province with the highest prevalence of diabetes in the "rural_disease_prevalence_2" table?
SELECT province FROM rural_disease_prevalence_2 WHERE diabetes_prevalence = (SELECT MAX(diabetes_prevalence) FROM rural_disease_prevalence_2);
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureProjects (id INT, project_name TEXT, location TEXT, investment FLOAT); INSERT INTO InfrastructureProjects (id, project_name, location, investment) VALUES (1, 'Road Construction Caribbean', 'Caribbean', 500000); INSERT INTO InfrastructureProjects (id, project_name, location, investment) VALUES...
Find the total investment in rural infrastructure projects in the Caribbean, excluding the Bahamas and Haiti.
SELECT SUM(investment) FROM InfrastructureProjects WHERE location NOT IN ('Bahamas', 'Haiti') AND location LIKE '%Caribbean%';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (startup_id INT, startup_name VARCHAR(20), funding_date DATE, gender VARCHAR(6)); INSERT INTO startups (startup_id, startup_name, funding_date, gender) VALUES (1, 'BioWomen', '2021-01-01', 'Female'), (2, 'CellMed', '2020-05-15', 'Male'), (3, 'NanoBio', '2019-09-24', 'Male');
What is the total funding received by women-led biotech startups in the last 3 years?
SELECT SUM(funding_amount) FROM startups JOIN (SELECT startup_id, SUM(funding_amount) as funding_amount FROM startups_funding WHERE funding_date >= DATEADD(year, -3, CURRENT_DATE()) GROUP BY startup_id) as sf ON startups.startup_id = sf.startup_id WHERE gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID int, VesselName varchar(50), VoyageID int, LoadCapacity int, CountryOfRegistry varchar(50)); INSERT INTO Vessels (VesselID, VesselName, VoyageID, LoadCapacity, CountryOfRegistry) VALUES (3, 'Marine Serpent', 103, 10000, 'Liberia'); INSERT INTO Vessels (VesselID, VesselName, VoyageID, Load...
Which vessels have the highest load capacity in their respective countries?
SELECT VesselName, LoadCapacity, RANK() OVER (PARTITION BY CountryOfRegistry ORDER BY LoadCapacity DESC) as Rank FROM Vessels WHERE LoadCapacity = (SELECT MAX(LoadCapacity) FROM Vessels v WHERE v.CountryOfRegistry = Vessels.CountryOfRegistry);
gretelai_synthetic_text_to_sql
CREATE TABLE medical_professionals (professional_id INT, region VARCHAR(20), specialty VARCHAR(30), join_year INT); INSERT INTO medical_professionals (professional_id, region, specialty, join_year) VALUES (1, 'Rural', 'General Practitioner', 2016), (2, 'Urban', 'Cardiologist', 2017), (3, 'Rural', 'Pediatrician', 2018),...
How many medical professionals have joined rural healthcare facilities each year, categorized by their specialties, for the last 5 years?
SELECT s.specialty, COUNT(mp.professional_id), s.year FROM medical_professionals mp JOIN ( SELECT region, specialty, EXTRACT(YEAR FROM age(join_year, CURRENT_DATE)) AS year FROM medical_professionals WHERE region = 'Rural' GROUP BY region, specialty, year ORDER BY year DESC LIMIT 5 ) s ON mp.specialty = s.specialty GRO...
gretelai_synthetic_text_to_sql
CREATE TABLE state_recycling_rates (state VARCHAR(20), year INT, material VARCHAR(20), recycling_rate FLOAT); INSERT INTO state_recycling_rates (state, year, material, recycling_rate) VALUES ('New York', 2022, 'Plastic', 0.3);
Identify the recycling rate for plastic waste in the state of New York for the year 2022.
SELECT recycling_rate FROM state_recycling_rates WHERE state = 'New York' AND year = 2022 AND material = 'Plastic';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, country TEXT); INSERT INTO donors (id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'USA'), (5, 'Canada');
List the top 3 countries with the highest number of donors?
SELECT country, COUNT(*) as num_donors FROM donors GROUP BY country ORDER BY num_donors DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (address VARCHAR(255), size INT, certification VARCHAR(50), city VARCHAR(100)); INSERT INTO green_buildings (address, size, certification, city) VALUES ('123 Main St', 5000, 'Gold', 'Anytown'), ('456 Elm St', 7000, 'Silver', 'Anytown'), ('789 Oak St', 6000, 'Gold', 'Othertown'), ('321 Pine ...
Show the number of green buildings in each city, ordered by the number of green buildings in descending order
SELECT city, COUNT(*) AS num_buildings FROM green_buildings GROUP BY city ORDER BY num_buildings DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO visitors (id, name, continent) VALUES (1, 'Alice', 'North America'), (2, 'Bob', 'North America'), (3, 'Charlie', 'Europe');
How many visitors came from each continent?
SELECT continent, COUNT(DISTINCT id) FROM visitors GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (spacecraft_id INT, name VARCHAR(100), launch_date DATE);
Delete records of spacecraft that were never launched
DELETE FROM spacecraft WHERE spacecraft.launch_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, name TEXT, state TEXT, success_rate DECIMAL); INSERT INTO campaigns (id, name, state, success_rate) VALUES (1, 'Campaign A', 'TX', 0.75), (2, 'Campaign B', 'NY', 0.85);
What is the success rate of the public awareness campaigns in Texas?
SELECT success_rate FROM campaigns WHERE state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, country VARCHAR(50), Terbium_imported FLOAT, importer_id INT, datetime DATETIME); INSERT INTO imports (id, country, Terbium_imported, importer_id, datetime) VALUES (1, 'South Africa', 120.0, 500, '2018-01-01 10:00:00'), (2, 'Egypt', 90.0, 350, '2018-02-15 14:30:00');
List the total quantity of Terbium imported to Africa in 2018 and the number of unique importers.
SELECT country, SUM(Terbium_imported) AS total_Terbium, COUNT(DISTINCT importer_id) AS unique_importers FROM imports WHERE YEAR(datetime) = 2018 AND Terbium_imported IS NOT NULL AND country LIKE 'Africa%' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Data (Id INT, City VARCHAR(50), Speed INT, Month VARCHAR(10)); INSERT INTO EV_Data (Id, City, Speed, Month) VALUES (1, 'LosAngeles', 70, 'February'); INSERT INTO EV_Data (Id, City, Speed, Month) VALUES (2, 'SanFrancisco', 65, 'February');
What was the maximum speed of electric vehicles in the city of Los Angeles in the month of February?
SELECT MAX(Speed) FROM EV_Data WHERE City = 'LosAngeles' AND Month = 'February' AND Type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255)); INSERT INTO menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'), (2, 'Chicken Caesar Wrap', 'Non-Vegetarian');
Find the total number of vegetarian and non-vegetarian dishes in the menu
SELECT SUM(CASE WHEN dish_type = 'Vegetarian' THEN 1 ELSE 0 END) AS vegetarian_count, SUM(CASE WHEN dish_type = 'Non-Vegetarian' THEN 1 ELSE 0 END) AS non_vegetarian_count FROM menu;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (id INT, user_id INT, pass_type VARCHAR(10), fare FLOAT, payment_date DATE); INSERT INTO fares (id, user_id, pass_type, fare, payment_date) VALUES (1, 1001, 'Monthly', 75.00, '2022-08-01'), (2, 1002, 'Daily', 5.00, '2022-08-01'), (3, 1003, 'Daily', 5.00, '2022-08-15');
What is the total fare collected from daily pass users in the month of August 2022?
SELECT SUM(fare) FROM fares WHERE pass_type = 'Daily' AND EXTRACT(MONTH FROM payment_date) = 8;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (fare_id INT, route_id INT, fare DECIMAL(5,2), fare_date DATE); INSERT INTO fares (fare_id, route_id, fare, fare_date) VALUES (1, 1, 2.00, '2022-01-01'), (2, 2, 2.50, '2022-01-03'), (3, 3, 3.00, '2022-01-05');
Calculate the total fare collected for the light rail in Los Angeles for the month of January 2022.
SELECT SUM(fare) FROM fares WHERE route_id IN (SELECT route_id FROM routes WHERE mode = 'Light Rail') AND EXTRACT(MONTH FROM fare_date) = 1 AND EXTRACT(YEAR FROM fare_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, color VARCHAR(20), quantity INT); INSERT INTO inventory (id, color, quantity) VALUES (1, 'red', 25), (2, 'blue', 30), (3, 'green', 40);
What is the total quantity of each color in the 'inventory' table?
SELECT color, SUM(quantity) FROM inventory GROUP BY color;
gretelai_synthetic_text_to_sql
CREATE TABLE safe_ai_algorithms (id INT, algorithm VARCHAR(25), evaluation_score FLOAT); INSERT INTO safe_ai_algorithms (id, algorithm, evaluation_score) VALUES (1, 'AlgorithmA', 0.92), (2, 'AlgorithmB', 0.95), (3, 'AlgorithmC', 0.88), (4, 'AlgorithmD', 0.98);
Show the top 3 safe AI algorithms based on their evaluation scores.
SELECT algorithm, evaluation_score FROM safe_ai_algorithms ORDER BY evaluation_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE football (id INT, team VARCHAR(50), league VARCHAR(50), season INT, games INT, wins INT); INSERT INTO football (id, team, league, season, games, wins) VALUES (1, 'Patriots', 'NFL', 2018, 16, 11); INSERT INTO football (id, team, league, season, games, wins) VALUES (2, 'Patriots', 'NFL', 2019, 16, 12);
What is the total number of games won by the New England Patriots in the NFL?
SELECT SUM(wins) FROM football WHERE team = 'Patriots' AND league = 'NFL';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_tools (tool_id INT, tool_name VARCHAR(50), region VARCHAR(50), rating FLOAT, launch_year INT); INSERT INTO ai_tools (tool_id, tool_name, region, rating, launch_year) VALUES (1, 'AITSG1', 'APAC', 4.3, 2021), (2, 'AITSG2', 'EMEA', 4.6, 2022), (3, 'AITSG3', 'AMER', 4.5, 2019);
What is the average rating of AI tools launched in APAC and EMEA after 2020?
SELECT region, AVG(rating) as avg_rating FROM ai_tools WHERE launch_year > 2020 AND region IN ('APAC', 'EMEA') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (mine_id INT, emission_date DATE, co2_amount INT); INSERT INTO co2_emissions (mine_id, emission_date, co2_amount) VALUES (1, '2021-01-01', 30000), (1, '2021-02-01', 32000), (1, '2021-03-01', 35000), (2, '2021-01-01', 28000), (2, '2021-02-01', 30000), (2, '2021-03-01', 33000), (3, '2021-01-01'...
What is the average monthly CO2 emission per mine?
SELECT AVG(co2_amount) AS avg_monthly_emission FROM co2_emissions GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_affordability (property_id INT, region VARCHAR(255), affordability_index DECIMAL(5,2));
Create a table named "housing_affordability" with columns "property_id", "region", and "affordability_index"
CREATE TABLE housing_affordability (property_id INT, region VARCHAR(255), affordability_index DECIMAL(5,2));
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_id INT, artwork_name VARCHAR(50), city VARCHAR(50)); INSERT INTO Exhibitions (exhibition_id, artwork_name, city) VALUES (1, 'The Weeping Woman', 'Paris'); INSERT INTO Exhibitions (exhibition_id, artwork_name, city) VALUES (2, 'Water Lilies', 'London'); INSERT INTO Exhibitions (exhib...
List the artworks displayed in exhibitions in London.
SELECT artwork_name FROM Exhibitions WHERE city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(20));CREATE TABLE Events (EventID INT, EventName VARCHAR(20), EventCategory VARCHAR(20));CREATE TABLE VisitorSpending (VisitorID INT, EventID INT, Spending INT);
What is the total spending by visitors who identify as 'Female' on events in the 'Music' category, and how many unique events have they attended?
SELECT SUM(VS.Spending) AS Total_Spending, COUNT(DISTINCT E.EventID) AS Num_Unique_Events FROM Visitors V INNER JOIN VisitorSpending VS ON V.VisitorID = VS.VisitorID INNER JOIN Events E ON VS.EventID = E.EventID WHERE V.Gender = 'Female' AND E.EventCategory = 'Music';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, registration_date DATE); INSERT INTO volunteers (volunteer_id, registration_date) VALUES (1, '2023-01-02'), (2, '2023-04-15'), (3, '2023-07-20'), (4, '2023-09-10'), (5, '2023-12-25'), (6, '2024-01-05'), (7, '2024-01-15'), (8, '2024-01-30');
How many new volunteers registered in Q1 2024, compared to Q1 2023?
SELECT (SELECT COUNT(*) FROM volunteers WHERE EXTRACT(YEAR FROM registration_date) = 2024 AND EXTRACT(MONTH FROM registration_date) BETWEEN 1 AND 3) - (SELECT COUNT(*) FROM volunteers WHERE EXTRACT(YEAR FROM registration_date) = 2023 AND EXTRACT(MONTH FROM registration_date) BETWEEN 1 AND 3) AS net_new_volunteers;
gretelai_synthetic_text_to_sql