context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE CulturalHeritageSites (id INT, country VARCHAR(20), num_virtual_tours INT); INSERT INTO CulturalHeritageSites (id, country, num_virtual_tours) VALUES (1, 'India', 120), (2, 'India', 80), (3, 'Nepal', 150);
Which cultural heritage sites in India have more than 100 virtual tours?
SELECT country, num_virtual_tours FROM CulturalHeritageSites WHERE country = 'India' AND num_virtual_tours > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, industry VARCHAR(255), salary FLOAT, union_member BOOLEAN); INSERT INTO workers (id, industry, salary, union_member) VALUES (1, 'Manufacturing', 50000.0, true), (2, 'Healthcare', 40000.0, false), (3, 'Retail', 30000.0, false);
What is the minimum salary of workers in the 'Healthcare' industry who are not part of a union?
SELECT MIN(salary) FROM workers WHERE industry = 'Healthcare' AND union_member = false;
gretelai_synthetic_text_to_sql
CREATE TABLE international_newswire (article_id INT, country VARCHAR(50), publication_date DATE);
Which countries published the most articles in 'international_newswire' table in 2020?
SELECT country, COUNT(*) FROM international_newswire WHERE YEAR(publication_date) = 2020 GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation (id INT, employee_name TEXT, hours_worked INT, salary REAL); INSERT INTO transportation (id, employee_name, hours_worked, salary) VALUES (1, 'Victoria Wilson', 40, 115000.00), (2, 'William Martin', 40, 120000.00), (3, 'Xavier Johnson', 40, 125000.00);
What is the minimum salary in the 'transportation' industry?
SELECT MIN(salary) FROM transportation WHERE industry = 'transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, name VARCHAR(255), year INT, artist_name VARCHAR(255), artist_country VARCHAR(255)); INSERT INTO artworks (id, name, year, artist_name, artist_country) VALUES (1, 'Painting1', 1850, 'Anna', 'France'), (2, 'Sculpture1', 1880, 'Bella', 'Italy'), (3, 'Painting2', 1820, 'Clara', 'France');
How many artworks were created by artists from each country?
SELECT artist_country, COUNT(*) FROM artworks GROUP BY artist_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Algorithms (AlgorithmId INT, Name TEXT, SafetyRating FLOAT, Country TEXT); INSERT INTO Algorithms (AlgorithmId, Name, SafetyRating, Country) VALUES (1, 'AlgorithmA', 4.5, 'USA'), (2, 'AlgorithmB', 4.8, 'USA'), (3, 'AlgorithmC', 4.2, 'Canada');
What is the average safety rating of all algorithms developed in the US?
SELECT AVG(SafetyRating) FROM Algorithms WHERE Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, category VARCHAR(50), resolution_time INT, timestamp TIMESTAMP);
What is the average time to resolve security incidents for each category?
SELECT category, AVG(resolution_time) as avg_resolution_time FROM security_incidents WHERE timestamp >= NOW() - INTERVAL '1 year' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_investments (id INT, investor VARCHAR(100), initiative VARCHAR(100), investment_usd FLOAT);
Display the total investment (in USD) in renewable energy initiatives by each investor, in descending order
SELECT investor, SUM(investment_usd) as total_investment FROM renewable_energy_investments GROUP BY investor ORDER BY total_investment DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (vessel_name VARCHAR(255)); INSERT INTO Vessels (vessel_name) VALUES ('VesselC'), ('VesselD'); CREATE TABLE SafetyIncidents (vessel_name VARCHAR(255), incident_date DATE); INSERT INTO SafetyIncidents (vessel_name, incident_date) VALUES ('VesselC', '2020-10-12'), ('VesselC', '2020-11-25'), ('VesselD', '2020-12-10');
How many safety incidents occurred on 'VesselC' in Q4 of 2020?
SELECT COUNT(*) FROM SafetyIncidents WHERE vessel_name = 'VesselC' AND incident_date BETWEEN '2020-10-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (application_id INT, application_date DATE, application_status VARCHAR(255), state VARCHAR(255), gender VARCHAR(255)); INSERT INTO veteran_employment (application_id, application_date, application_status, state, gender) VALUES (1, '2021-01-01', 'Applied', 'California', 'Female'); INSERT INTO veteran_employment (application_id, application_date, application_status, state, gender) VALUES (2, '2021-03-01', 'Hired', 'Florida', 'Male');
What is the number of veteran employment applications submitted by women in California in the past quarter?
SELECT COUNT(*) as total_applications FROM veteran_employment WHERE application_status = 'Applied' AND state = 'California' AND gender = 'Female' AND application_date >= DATEADD(quarter, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE SCHEMA Genetech; CREATE TABLE startup_funding (startup_name VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO startup_funding VALUES ('StartupA', 500000), ('StartupB', 750000);
What is the average funding received by startups in the 'Genetech' schema?
SELECT AVG(funding) FROM Genetech.startup_funding;
gretelai_synthetic_text_to_sql
CREATE TABLE ev_charging_stations_oregon (id INT, station_name VARCHAR(50), state VARCHAR(50), location VARCHAR(50)); INSERT INTO ev_charging_stations_oregon (id, station_name, state, location) VALUES (1, 'Oregon EV Charging Station', 'Oregon', 'Portland');
How many electric vehicle charging stations are there in the state of Oregon, by location?
SELECT location, COUNT(*) FROM ev_charging_stations_oregon GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE space_company (name TEXT, satellites_deployed INTEGER); INSERT INTO space_company (name, satellites_deployed) VALUES ('SpaceX', 2000); CREATE TABLE spacex_satellites (id INTEGER, name TEXT, launch_year INTEGER); INSERT INTO spacex_satellites (id, name, launch_year) VALUES (1, 'Starlink 1', 2019), (2, 'Starlink 2', 2020), (3, 'Starlink 3', 2021);
What is the latest satellite launch year by SpaceX?
SELECT MAX(launch_year) FROM spacex_satellites;
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (id INT PRIMARY KEY, project_name VARCHAR(100), funding_country VARCHAR(50), completion_year INT);
Add new record to research_projects table, including 'Electric Tanks' as project_name, 'USA' as funding_country, '2025' as completion_year
INSERT INTO research_projects (project_name, funding_country, completion_year) VALUES ('Electric Tanks', 'USA', 2025);
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), location VARCHAR(50), lead_time INT);
What is the average lead time for each fabric supplier in the Asia-Pacific region?
SELECT location, AVG(lead_time) as avg_lead_time FROM suppliers WHERE location LIKE '%Asia-Pacific%' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeePrograms(EmployeeID INT, Department VARCHAR(255), HiringProgram VARCHAR(255), JoinDate DATE);
What is the total number of employees who have joined through each hiring program in the IT department?
SELECT HiringProgram, Department, COUNT(*) FROM EmployeePrograms WHERE Department = 'IT' GROUP BY HiringProgram, Department;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), department VARCHAR(50), email VARCHAR(50));
Update the email address for a graduate student in the "students" table
WITH updated_email AS (UPDATE students SET email = 'jane.doe@university.edu' WHERE id = 1 RETURNING *) SELECT * FROM updated_email;
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets(id INT, name VARCHAR(255), discovery_date DATE, discovery_method VARCHAR(255), telescope VARCHAR(255)); INSERT INTO exoplanets VALUES (1, 'Pi Mensae c', '2018-09-17', 'Transit Method', 'TESS Space Telescope'); INSERT INTO exoplanets VALUES (2, 'HD 21749b', '2019-01-07', 'Transit Method', 'TESS Space Telescope'); INSERT INTO exoplanets VALUES (3, 'LHS 3844b', '2019-04-16', 'Transit Method', 'TESS Space Telescope');
How many exoplanets have been discovered by the TESS Space Telescope as of 2022?
SELECT COUNT(*) FROM exoplanets WHERE telescope = 'TESS Space Telescope' AND discovery_date <= '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE uk_aquaculture_species (species TEXT, survival_rate FLOAT, country TEXT); INSERT INTO uk_aquaculture_species (species, survival_rate, country) VALUES ('Trout', 0.91, 'UK'), ('Salmon', 0.87, 'UK');
Update the survival rate of the species 'Trout' in the UK to 0.92?
UPDATE uk_aquaculture_species SET survival_rate = 0.92 WHERE species = 'Trout';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthFacilities (Id INT, Region VARCHAR(255), ParityScore INT); INSERT INTO MentalHealthFacilities (Id, Region, ParityScore) VALUES (1, 'Midwest', 85); INSERT INTO MentalHealthFacilities (Id, Region, ParityScore) VALUES (2, 'Northeast', 90); INSERT INTO MentalHealthFacilities (Id, Region, ParityScore) VALUES (3, 'Midwest', 80);
What is the average mental health parity score for facilities in the Midwest?
SELECT AVG(ParityScore) FROM MentalHealthFacilities WHERE Region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE australia_water_consumption (id INT, state VARCHAR(50), water_consumption FLOAT, year INT); INSERT INTO australia_water_consumption (id, state, water_consumption, year) VALUES (1, 'New South Wales', 12000000, 2020); INSERT INTO australia_water_consumption (id, state, water_consumption, year) VALUES (2, 'Victoria', 10000000, 2020); INSERT INTO australia_water_consumption (id, state, water_consumption, year) VALUES (3, 'Queensland', 8000000, 2020); INSERT INTO australia_water_consumption (id, state, water_consumption, year) VALUES (4, 'Western Australia', 6000000, 2020);
What is the maximum and minimum water consumption by state in Australia for the year 2020?
SELECT MAX(water_consumption) AS max_water_consumption, MIN(water_consumption) AS min_water_consumption FROM australia_water_consumption WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name TEXT, physical_disability BOOLEAN, requires_assistive_tech BOOLEAN); INSERT INTO students (id, name, physical_disability, requires_assistive_tech) VALUES (1, 'Jane Doe', true, true), (2, 'Bob Smith', false, true);
Find the number of students who have both a physical disability and require assistive technology, along with their names.
SELECT name FROM students WHERE physical_disability = true AND requires_assistive_tech = true;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT); INSERT INTO company (id, name, founding_year) VALUES (1, 'Acme Corp', 2010), (2, 'Beta Inc', 2012);
What is the distribution of startups by founding year?
SELECT founding_year, COUNT(*) as count FROM company GROUP BY founding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), residence_area VARCHAR(50), disability BOOLEAN, mental_health_service BOOLEAN);
How many rural patients with disabilities received mental health services in 2020?
SELECT COUNT(DISTINCT patient_id) FROM patients WHERE patients.residence_area LIKE 'rural%' AND patients.disability = TRUE AND patients.mental_health_service = TRUE AND YEAR(patients.patient_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(50), country VARCHAR(50), certification VARCHAR(50)); INSERT INTO factories (id, name, country, certification) VALUES (1, 'FairVN1', 'Vietnam', 'Fair Trade'), (2, 'GreenVN', 'Vietnam', 'B Corp'), (3, 'EcoVN', 'Vietnam', 'Fair Trade');
List all factories in Vietnam that have been certified as fair trade, along with their certification dates.
SELECT * FROM factories WHERE country = 'Vietnam' AND certification = 'Fair Trade';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name VARCHAR(255), type VARCHAR(255), start_date DATE); INSERT INTO events (id, name, type, start_date) VALUES (1, 'Dance Showcase', 'dance', '2022-01-01'), (2, 'Music Festival', 'music', '2022-01-10');
How many unique visitors attended events in the past month, grouped by event category?
SELECT type, COUNT(DISTINCT visitor_id) AS unique_visitors FROM events WHERE start_date >= DATEADD(MONTH, -1, GETDATE()) GROUP BY type
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT PRIMARY KEY, sale_date DATE, item_sold VARCHAR(255), quantity INT, sale_price DECIMAL(5,2), is_organic BOOLEAN); CREATE TABLE Menu (menu_id INT PRIMARY KEY, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), is_organic BOOLEAN);
What is the total revenue generated from organic items?
SELECT SUM(s.quantity * s.sale_price) FROM Sales s JOIN Menu m ON s.item_sold = m.item_name WHERE m.is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurant (id INT, dish_type VARCHAR(10), revenue DECIMAL(10,2), has_nuts BOOLEAN); INSERT INTO Restaurant (id, dish_type, revenue, has_nuts) VALUES (1, 'Pasta', 200.00, false), (2, 'Salad', 300.00, true);
What is the total revenue from dishes without nuts in the past year?
SELECT SUM(revenue) FROM Restaurant WHERE has_nuts = false AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE movies(id INT PRIMARY KEY, name VARCHAR(255), budget INT);
update budget for movie 'Black Panther' in the movies table
UPDATE movies SET budget = 200000000 WHERE name = 'Black Panther';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name TEXT, start_date DATE, end_date DATE, troops_involved INT, partner_organization TEXT); INSERT INTO peacekeeping_operations (operation_id, operation_name, start_date, end_date, troops_involved, partner_organization) VALUES (1, 'Operation Restore Hope', '1992-12-03', '1993-05-04', 25000, 'African Union');
What is the total number of troops involved in joint peacekeeping operations with the African Union?
SELECT SUM(peacekeeping_operations.troops_involved) FROM peacekeeping_operations WHERE peacekeeping_operations.partner_organization = 'African Union' AND peacekeeping_operations.start_date <= CURDATE() AND (peacekeeping_operations.end_date IS NULL OR peacekeeping_operations.end_date > CURDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_state VARCHAR(2), donation_amount DECIMAL(10,2));
What is the average donation amount by donors from the Western US region?
SELECT AVG(donation_amount) FROM donors WHERE donor_state IN ('WA', 'OR', 'CA', 'NV', 'AZ', 'UT', 'CO', 'NM');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (project_id INT, project_name TEXT, location TEXT, project_type TEXT, start_year INT, funding_amount FLOAT); INSERT INTO climate_projects (project_id, project_name, location, project_type, start_year, funding_amount) VALUES (1, 'Adaptation 1', 'India', 'climate adaptation', 2010, 3000000.0), (2, 'Adaptation 2', 'China', 'climate adaptation', 2012, 5000000.0), (3, 'Mitigation 1', 'Japan', 'climate mitigation', 2015, 7000000.0);
What is the average funding amount per climate adaptation project in Asia?
SELECT AVG(funding_amount) FROM climate_projects WHERE project_type = 'climate adaptation' AND location LIKE 'Asia%';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(255), vulnerability VARCHAR(255)); INSERT INTO vulnerabilities (id, sector, vulnerability) VALUES (1, 'healthcare', 'SQL injection');
What is the total number of vulnerabilities found in the healthcare sector?
SELECT COUNT(*) FROM vulnerabilities WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE units (id INT, city VARCHAR, build_year INT, rent DECIMAL, green_certified BOOLEAN);
What is the average rent for properties built before 2000 with green-certified building status in Dubai?
SELECT AVG(rent) FROM units WHERE city = 'Dubai' AND build_year < 2000 AND green_certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT, name VARCHAR(50), added_date DATE); INSERT INTO machines (id, name, added_date) VALUES (1, 'Machine 1', '2021-01-15'), (2, 'Machine 2', '2022-02-20'), (3, 'Machine 3', '2022-01-05'), (4, 'Machine 4', '2023-03-12');
List all machines that were added in the month of "January" in any year
SELECT * FROM machines WHERE EXTRACT(MONTH FROM added_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO organizations (id, name, region, budget) VALUES (1, 'ABC Corp', 'Asia Pacific', 5000000.00), (2, 'XYZ Inc', 'North America', 8000000.00);
What is the average budget allocated for ethical AI research by organizations located in the United States?
SELECT AVG(budget) FROM organizations WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Paintings (id INT, artist_name VARCHAR(50), title VARCHAR(50)); CREATE TABLE Sculptures (id INT, artist_name VARCHAR(50), title VARCHAR(50)); CREATE TABLE ArtCollection (id INT, name VARCHAR(50), artist_name VARCHAR(50));
Find the names of artists who have created both paintings and sculptures, and list their art pieces in the 'ArtCollection' table.
SELECT name, artist_name FROM ArtCollection WHERE artist_name IN (SELECT artist_name FROM Paintings INTERSECT SELECT artist_name FROM Sculptures);
gretelai_synthetic_text_to_sql
CREATE TABLE EducationBudget (Department VARCHAR(25), Category VARCHAR(25), Budget INT); INSERT INTO EducationBudget (Department, Category, Budget) VALUES ('Education', 'Elementary', 5000000), ('Education', 'Secondary', 7000000), ('Education', 'Higher Education', 8000000);
What is the average budget allocated per service category in the Education department?
SELECT AVG(Budget) FROM EducationBudget WHERE Department = 'Education' GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitarySpending (Country VARCHAR(50), MilitarySpending DECIMAL(10,2)); INSERT INTO MilitarySpending (Country, MilitarySpending) VALUES ('United States', 700000000), ('China', 250000000), ('Russia', 65000000);
List the top 3 countries with the highest military spending in the field of military innovation?
SELECT Country, MilitarySpending FROM (SELECT Country, MilitarySpending, ROW_NUMBER() OVER (ORDER BY MilitarySpending DESC) AS Rank FROM MilitarySpending) AS RankedMilitarySpending WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE inmates (id INT, race VARCHAR(50), length_of_stay INT, crime VARCHAR(50));
What is the average length of stay in prison, by inmate's race, for inmates who have committed violent crimes?
SELECT race, AVG(length_of_stay) FROM inmates WHERE crime = 'violent' GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_projects (project_id INT, year INT, region VARCHAR(255), amount FLOAT); INSERT INTO climate_finance_projects VALUES (1, 2013, 'South Asia', 2000000);
What is the total climate finance for South Asian projects initiated before 2015?
SELECT SUM(amount) FROM climate_finance_projects WHERE region = 'South Asia' AND year < 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE small_scale_farmers (id INT, country VARCHAR(20), initiative_id INT); CREATE TABLE food_justice_initiatives (id INT, name VARCHAR(50)); INSERT INTO small_scale_farmers (id, country, initiative_id) VALUES (1, 'BR', 101), (2, 'ZA', 102), (3, 'BR', 103), (4, 'ZA', 104); INSERT INTO food_justice_initiatives (id, name) VALUES (101, 'Sempreviva'), (102, 'Food Sovereignty South Africa'), (103, 'Articulação Nacional de Agroecologia'), (104, 'Sustainability Institute');
How many small-scale farmers in Brazil and South Africa are part of food justice initiatives?
SELECT COUNT(DISTINCT small_scale_farmers.id) FROM small_scale_farmers INNER JOIN food_justice_initiatives ON small_scale_farmers.initiative_id = food_justice_initiatives.id WHERE small_scale_farmers.country IN ('BR', 'ZA');
gretelai_synthetic_text_to_sql
CREATE TABLE Game_Sessions (Session_ID INT, Game_ID INT, Session_Duration INT); CREATE TABLE Game_Details (Game_ID INT, Game_Name VARCHAR(30));
What is the total number of hours spent by players on each game in the 'Game_Sessions' and 'Game_Details' tables?
SELECT Game_Details.Game_Name, SUM(Session_Duration) FROM Game_Sessions JOIN Game_Details ON Game_Sessions.Game_ID = Game_Details.Game_ID GROUP BY Game_Details.Game_ID;
gretelai_synthetic_text_to_sql
CREATE TABLE new_hires (id INT, hire_date DATE); INSERT INTO new_hires (id, hire_date) VALUES (1, '2021-07-01'), (2, '2021-10-15'), (3, '2022-01-03'), (4, '2022-04-29');
How many new hires were made in each quarter?
SELECT QUARTER(hire_date) as quarter, COUNT(*) as count FROM new_hires GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE music_genres (genre VARCHAR(255), country VARCHAR(255), revenue FLOAT, event_date DATE); INSERT INTO music_genres (genre, country, revenue, event_date) VALUES ('Pop', 'USA', 10000.0, '2020-01-01'), ('Rock', 'USA', 8000.0, '2020-01-01'), ('Country', 'USA', 7000.0, '2020-01-01');
Delete all records for the Country genre from the year 2020
DELETE FROM music_genres WHERE genre = 'Country' AND YEAR(event_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE risk_assessment (id INT, company_id INT, risk_level TEXT); INSERT INTO risk_assessment (id, company_id, risk_level) VALUES (1, 3, 'High'), (2, 6, 'Very High');
Identify the riskiest companies in the renewable energy sector in Europe.
SELECT companies.* FROM companies INNER JOIN risk_assessment ON companies.id = risk_assessment.company_id WHERE companies.sector = 'Renewable Energy' AND risk_assessment.risk_level IN ('High', 'Very High') AND companies.country LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholder (PolicyholderID INT, Name TEXT, DOB DATE, Product VARCHAR(10)); INSERT INTO Policyholder (PolicyholderID, Name, DOB, Product) VALUES (1, 'John Doe', '1980-05-05', 'Auto'), (2, 'Jane Smith', '1990-01-01', 'Home'), (3, 'Mike Johnson', '1975-09-09', 'Auto');
What are the names and dates of birth of policyholders who have both home and auto insurance coverage?
SELECT Name, DOB FROM Policyholder WHERE Product = 'Auto' INTERSECT SELECT Name, DOB FROM Policyholder WHERE Product = 'Home';
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, name VARCHAR(255), description TEXT); INSERT INTO tours (id, name, description) VALUES (1, 'Sustainable Architecture Tour', 'Discover Tokyo''s unique and innovative green buildings.'), (2, 'Eco-Friendly Cycling Tour', 'Bike around Tokyo while learning about its eco-friendly initiatives.');
Update the description of the 'Sustainable Architecture Tour' in Tokyo.
UPDATE tours SET description = 'Explore Tokyo''s cutting-edge sustainable architecture on this informative tour.' WHERE name = 'Sustainable Architecture Tour';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name TEXT, country TEXT, followers INT); INSERT INTO users (id, name, country, followers) VALUES (1, 'Hiroshi', 'Japan', 1000), (2, 'Yumi', 'Japan', 2000), (3, 'Taro', 'Japan', 3000), (4, 'Hanako', 'Japan', 4000); CREATE TABLE posts (id INT, user_id INT, likes INT, timestamp DATETIME); INSERT INTO posts (id, user_id, likes, timestamp) VALUES (1, 1, 55, '2022-05-01 12:00:00'), (2, 1, 60, '2022-05-05 13:00:00'), (3, 2, 10, '2022-05-03 11:00:00'), (4, 3, 45, '2022-05-04 14:00:00'), (5, 4, 70, '2022-04-30 15:00:00');
What is the total number of followers for users from Japan, with more than 50 likes on their posts in the last month?
SELECT SUM(users.followers) FROM users JOIN posts ON users.id = posts.user_id WHERE users.country = 'Japan' AND posts.likes > 50 AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE bus_routes (route_id INT, route_name VARCHAR(255), city VARCHAR(255)); INSERT INTO bus_routes (route_id, route_name, city) VALUES (1, 'Route 10', 'Seattle'), (2, 'Route 40', 'Seattle'); CREATE TABLE fares (fare_id INT, route_id INT, fare_amount DECIMAL(5,2)); INSERT INTO fares (fare_id, route_id, fare_amount) VALUES (1, 1, 2.50), (2, 1, 2.50), (3, 2, 3.00), (4, 2, 3.00);
What is the total revenue generated from the bus routes in the city of Seattle?
SELECT SUM(f.fare_amount) FROM fares f JOIN bus_routes br ON f.route_id = br.route_id WHERE br.city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), initiation_year INT); INSERT INTO rural_infrastructure (id, project_name, initiation_year) VALUES (1, 'Irrigation System Upgrade', 2008), (2, 'Rural Road Expansion', 2022);
How many rural infrastructure projects in the 'rural_infrastructure' table were initiated before 2010 and after 2020?
SELECT COUNT(*) FROM rural_infrastructure WHERE initiation_year < 2010 OR initiation_year > 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE submarines (submarine_name VARCHAR(255), max_depth INT); INSERT INTO submarines (submarine_name, max_depth) VALUES ('Alvin', 4500), ('Pisces VI', 6000), ('Mir', 6170);
What is the maximum depth a submarine can reach?
SELECT max(max_depth) FROM submarines;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (id INT, veteran_status VARCHAR(50), employment_date DATE);
Insert a new record for a veteran employment statistic with ID 10, veteran status 'Honorably Discharged', and employment date 2022-01-01
INSERT INTO veteran_employment (id, veteran_status, employment_date) VALUES (10, 'Honorably Discharged', '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Mine (MineID int, MineName varchar(50), Location varchar(50), TotalCoalQuantity int); INSERT INTO Mine VALUES (1, 'ABC Mine', 'Colorado', 5000), (2, 'DEF Mine', 'Wyoming', 7000), (3, 'GHI Mine', 'West Virginia', 6000);
What is the total quantity of coal mined by each mine, sorted by the highest quantity?
SELECT MineName, SUM(TotalCoalQuantity) as TotalCoalQuantity FROM Mine GROUP BY MineName ORDER BY TotalCoalQuantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(50), Size VARCHAR(10), Country VARCHAR(50)); INSERT INTO Customers (CustomerID, CustomerName, Size, Country) VALUES (1, 'CustomerA', 'XS', 'USA'), (2, 'CustomerB', 'M', 'Canada'), (3, 'CustomerC', 'XL', 'Mexico'), (4, 'CustomerD', 'S', 'Brazil'), (5, 'CustomerE', 'XXL', 'Argentina');
How many unique customers have purchased size-inclusive clothing in each country?
SELECT Country, COUNT(DISTINCT CustomerID) as UniqueCustomers FROM Customers WHERE Size IN ('XS', 'S', 'M', 'L', 'XL', 'XXL') GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_usage (usage_id INT, customer_id INT, usage_date DATE, usage_amount FLOAT); INSERT INTO daily_usage (usage_id, customer_id, usage_date, usage_amount) VALUES (1, 101, '2021-06-01', 150), (2, 101, '2021-06-02', 145), (3, 101, '2021-06-03', 160);
What is the average daily water usage for a specific residential customer in Paris over the last year?
SELECT AVG(usage_amount) FROM daily_usage WHERE customer_id = 101 AND usage_date BETWEEN '2021-06-01' AND '2022-05-31';
gretelai_synthetic_text_to_sql
CREATE TABLE greenhouse_gas_emissions (country VARCHAR(255), co2_emissions DECIMAL(10,2), year INT, continent VARCHAR(255)); INSERT INTO greenhouse_gas_emissions (country, co2_emissions, year, continent) VALUES ('China', 10435.3, 2019, 'Asia'), ('USA', 5416.1, 2019, 'North America'), ('India', 2654.5, 2019, 'Asia'), ('Indonesia', 643.2, 2019, 'Asia'), ('Russia', 1530.6, 2019, 'Europe'); CREATE TABLE continent_map (country VARCHAR(255), continent VARCHAR(255)); INSERT INTO continent_map (country, continent) VALUES ('China', 'Asia'), ('USA', 'North America'), ('India', 'Asia'), ('Indonesia', 'Asia'), ('Russia', 'Europe');
What is the total CO2 emissions for each continent in the 'greenhouse_gas_emissions' table?
SELECT c.continent, SUM(g.co2_emissions) as total_emissions FROM greenhouse_gas_emissions g INNER JOIN continent_map c ON g.country = c.country GROUP BY c.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE kenyan_hotels (hotel_id INT, hotel_name TEXT, rating FLOAT); INSERT INTO kenyan_hotels (hotel_id, hotel_name, rating) VALUES (1, 'Eco Hotel Nairobi', 4.6), (2, 'Green Hotel Mombasa', 4.4);
Which eco-friendly hotel in Kenya has the highest rating?
SELECT hotel_name, MAX(rating) as max_rating FROM kenyan_hotels GROUP BY hotel_name ORDER BY max_rating DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ExhibitNames (exhibition_id INT, name VARCHAR(50)); INSERT INTO ExhibitNames (exhibition_id, name) VALUES (1, 'Art of the 80s'), (2, 'Nature Unleashed'); CREATE TABLE ExhibitVisitors (exhibition_id INT, visitor_id INT, community_id INT); INSERT INTO ExhibitVisitors (exhibition_id, visitor_id, community_id) VALUES (1, 101, 3), (1, 102, 3), (2, 103, 2);
What are the names and number of exhibits that had the most visitors from the LGBTQ+ community in 2020?
SELECT ExhibitNames.name, COUNT(DISTINCT ExhibitVisitors.visitor_id) as visitor_count FROM ExhibitVisitors INNER JOIN ExhibitNames ON ExhibitVisitors.exhibition_id = ExhibitNames.exhibition_id INNER JOIN Communities ON ExhibitVisitors.community_id = Communities.id WHERE Communities.community_type = 'LGBTQ+' AND ExhibitVisitors.exhibition_id IN (SELECT exhibition_id FROM ExhibitVisitors GROUP BY exhibition_id HAVING COUNT(DISTINCT visitor_id) = (SELECT MAX(visitor_count) FROM (SELECT exhibition_id, COUNT(DISTINCT visitor_id) as visitor_count FROM ExhibitVisitors INNER JOIN Communities ON ExhibitVisitors.community_id = Communities.id WHERE Communities.community_type = 'LGBTQ+' GROUP BY exhibition_id) as max_visitor_count)) GROUP BY ExhibitNames.name;
gretelai_synthetic_text_to_sql
CREATE TABLE music_sales (sale_id INT, genre VARCHAR(10), year INT, revenue FLOAT); INSERT INTO music_sales (sale_id, genre, year, revenue) VALUES (1, 'Pop', 2021, 50000.00), (2, 'Rock', 2021, 45000.00), (3, 'Pop', 2020, 40000.00), (4, 'Jazz', 2020, 30000.00); CREATE VIEW genre_sales AS SELECT genre, SUM(revenue) as total_revenue FROM music_sales GROUP BY genre;
What was the total revenue for the Jazz genre in 2020?
SELECT total_revenue FROM genre_sales WHERE genre = 'Jazz' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_arts (id INT, name VARCHAR(255), description TEXT); INSERT INTO traditional_arts (id, name, description) VALUES (1, 'Bharatanatyam', 'An ancient Indian dance form'), (2, 'Ukulele', 'A Hawaiian string instrument');
What are the details of traditional arts from the 'traditional_arts' schema?
SELECT * FROM traditional_arts.traditional_arts;
gretelai_synthetic_text_to_sql
CREATE TABLE gas_production (well_id INT, year INT, gas_volume FLOAT);
Calculate the total gas production for the year 2020 from the 'gas_production' table
SELECT SUM(gas_volume) FROM gas_production WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_data(id INT, vessel_name VARCHAR(50), destination VARCHAR(50), cargo_weight DECIMAL(5,2)); CREATE TABLE vessels(id INT, name VARCHAR(50), country VARCHAR(50), average_speed DECIMAL(5,2)); INSERT INTO vessels(id, name, country, average_speed) VALUES (1, 'Vessel A', 'Philippines', 14.5), (2, 'Vessel B', 'Philippines', 16.3); INSERT INTO cargo_data(id, vessel_name, destination, cargo_weight) VALUES (1, 'Vessel A', 'Port C', 200.0), (2, 'Vessel B', 'Port D', 250.0);
What is the average speed of vessels that transported cargo to Port C?
SELECT AVG(average_speed) FROM vessels JOIN cargo_data ON vessels.name = cargo_data.vessel_name WHERE destination = 'Port C';
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name VARCHAR(50), gender VARCHAR(10), ethnicity VARCHAR(20), company_id INT, founding_year INT, non_binary BOOLEAN);
How many companies were founded by individuals who identify as non-binary in 2017?
SELECT COUNT(DISTINCT founders.company_id) FROM founders WHERE founders.non_binary = true AND founders.founding_year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Genre varchar(50)); INSERT INTO Artists (ArtistID, ArtistName, Genre) VALUES (1, 'Shakira', 'Latin'), (2, 'Bad Bunny', 'Latin'), (3, 'Drake', 'Hip Hop'); CREATE TABLE StreamingData (StreamDate date, ArtistID int, Streams int); INSERT INTO StreamingData (StreamDate, ArtistID, Streams) VALUES ('2021-01-01', 1, 100000), ('2021-01-02', 2, 80000), ('2021-01-03', 3, 90000);
What is the total number of streams for Latin artists in 2021?
SELECT SUM(Streams) as TotalStreams FROM Artists JOIN StreamingData ON Artists.ArtistID = StreamingData.ArtistID WHERE StreamingData.StreamDate >= '2021-01-01' AND StreamingData.StreamDate <= '2021-12-31' AND Artists.Genre = 'Latin';
gretelai_synthetic_text_to_sql
CREATE TABLE hypertension (patient_id INT, age INT, gender TEXT, state TEXT, hypertension INT); INSERT INTO hypertension (patient_id, age, gender, state, hypertension) VALUES (1, 70, 'Female', 'New York', 1);
How many patients with hypertension are there in the state of New York who are over the age of 65?
SELECT COUNT(*) FROM hypertension WHERE state = 'New York' AND age > 65 AND hypertension = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_data (satellite_id INT, name VARCHAR(255), launch_date DATE); INSERT INTO satellite_data (satellite_id, name, launch_date) VALUES (1, 'Sputnik 1', '1957-10-04'), (2, 'Explorer 1', '1958-01-31');
Delete all satellites with a launch date before 2000-01-01 from the satellite_data table
DELETE FROM satellite_data WHERE launch_date < '2000-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), vegan BOOLEAN); INSERT INTO products (id, name, category, price, vegan) VALUES (1, 'Shampoo', 'haircare', 12.99, false), (2, 'Conditioner', 'haircare', 14.99, true), (3, 'Hair Spray', 'haircare', 7.99, false);
Delete all records of non-vegan products in the 'haircare' category.
DELETE FROM products WHERE category = 'haircare' AND vegan = false;
gretelai_synthetic_text_to_sql
CREATE TABLE erbium_transactions (country VARCHAR(20), element VARCHAR(20), price DECIMAL(5,2), transaction_date DATE); INSERT INTO erbium_transactions (country, element, price, transaction_date) VALUES ('China', 'Erbium', 30, '2020-01-01'), ('Japan', 'Erbium', 35, '2020-02-01'), ('China', 'Erbium', 25, '2020-03-01');
Calculate the average price of Erbium transactions in Asian countries.
SELECT AVG(price) FROM erbium_transactions WHERE country IN ('China', 'Japan') AND element = 'Erbium';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (id INT, equipment_name TEXT, sale_date DATE, quantity INT, unit_price FLOAT);
calculate the average unit price of military equipment sold
SELECT AVG(unit_price) FROM sales_data;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(255), collection_date DATE, collecting_agency VARCHAR(255), mass FLOAT); INSERT INTO space_debris (id, name, collection_date, collecting_agency, mass) VALUES (1, 'RemoveDEBRIS', '2018-04-16', 'ESA', 220.0); INSERT INTO space_debris (id, name, collection_date, collecting_agency, mass) VALUES (2, 'RAMA', '2024-09-27', 'ISRO', 550.5); CREATE VIEW space_debris_esa AS SELECT * FROM space_debris WHERE collecting_agency = 'ESA'; CREATE VIEW space_debris_isro AS SELECT * FROM space_debris WHERE collecting_agency = 'ISRO';
What is the total mass of space debris collected by ESA and ISRO?
SELECT SUM(s.mass) as total_mass FROM space_debris s INNER JOIN space_debris_esa e ON s.id = e.id INNER JOIN space_debris_isro i ON s.id = i.id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name TEXT, region TEXT);INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Great White Shark', 'Pacific'), (2, 'Blue Whale', 'Atlantic'), (3, 'Giant Pacific Octopus', 'Pacific'), (4, 'Green Sea Turtle', 'Atlantic');
What is the total number of marine species recorded in the 'Atlantic' and 'Pacific' regions?
SELECT COUNT(*) FROM marine_species WHERE region IN ('Atlantic', 'Pacific');
gretelai_synthetic_text_to_sql
CREATE TABLE mortality (country VARCHAR(255), region VARCHAR(255), year INT, rate DECIMAL(5,2)); INSERT INTO mortality (country, region, year, rate) VALUES ('Country A', 'Southeast Asia', 2010, 0.03), ('Country B', 'Southeast Asia', 2010, 0.02);
What is the infant mortality rate in Southeast Asia in 2010?
SELECT AVG(rate) FROM mortality WHERE region = 'Southeast Asia' AND year = 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Specialization VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, Specialization) VALUES (1, 'Civil Law'), (2, 'Criminal Law'), (3, 'Family Law'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (101, 1, 2500.00), (102, 1, 3000.00), (103, 2, 2000.00), (104, 3, 4000.00);
What is the total billing amount for cases in the 'Civil Law' specialization?
SELECT SUM(BillingAmount) FROM Cases INNER JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Specialization = 'Civil Law';
gretelai_synthetic_text_to_sql
CREATE TABLE species (species_id INT, species_name TEXT, conservation_status TEXT, population INT);
Remove the 'species' table and all its records.
DROP TABLE species;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_registrations (id INT, registration_date TIMESTAMP, vehicle_type TEXT, manufacturer TEXT);
What is the percentage of electric vehicle adoption in Germany over time?
SELECT EXTRACT(YEAR FROM registration_date) AS year, (COUNT(*) FILTER (WHERE vehicle_type = 'electric vehicle')) * 100.0 / COUNT(*) AS adoption_percentage FROM vehicle_registrations WHERE manufacturer IS NOT NULL GROUP BY year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (21, 'South Korea', 'Australia', '2024-05-09', 22), (22, 'South Korea', 'Australia', '2024-11-25', 26);
What is the minimum age of tourists visiting Australia from South Korea in 2024?
SELECT MIN(age) FROM tourism_data WHERE country = 'South Korea' AND destination = 'Australia' AND YEAR(arrival_date) = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, course_id INT, course_date DATE); INSERT INTO teacher_pd (teacher_id, course_id, course_date) VALUES (1, 1001, '2022-01-01'), (1, 1002, '2022-04-15'), (2, 1003, '2022-03-01'), (2, 1004, '2022-06-30'), (3, 1005, '2022-02-14'), (3, 1006, '2022-05-05');
What is the change in the number of professional development courses completed by each teacher per quarter, ordered by teacher_id and the change in courses?
SELECT teacher_id, DATEDIFF(quarter, LAG(course_date) OVER (PARTITION BY teacher_id ORDER BY course_date), course_date) as quarters_between, COUNT(course_id) - COALESCE(LAG(COUNT(course_id)) OVER (PARTITION BY teacher_id ORDER BY course_date), 0) as courses_diff FROM teacher_pd GROUP BY teacher_id, DATEDIFF(quarter, LAG(course_date) OVER (PARTITION BY teacher_id ORDER BY course_date), course_date) ORDER BY teacher_id, quarters_between, courses_diff;
gretelai_synthetic_text_to_sql
CREATE TABLE LegalClinics (ID INT, JusticeDistrict VARCHAR(20), Year INT, Cases INT); INSERT INTO LegalClinics (ID, JusticeDistrict, Year, Cases) VALUES (1, 'East River', 2017, 120), (2, 'East River', 2018, 150), (3, 'East River', 2019, 210), (4, 'East River', 2020, 200);
What is the minimum and maximum number of cases handled by legal clinics in 'East River' justice district in a year?
SELECT MIN(Cases), MAX(Cases) FROM LegalClinics WHERE JusticeDistrict = 'East River';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_maintenance (maintenance_company VARCHAR(255), equipment_id INT); INSERT INTO military_equipment_maintenance (maintenance_company, equipment_id) VALUES ('Global Maintainers', 1), ('Tactical Technologies', 2);
Get the number of military equipment items maintained by 'Global Maintainers'
SELECT COUNT(equipment_id) FROM military_equipment_maintenance WHERE maintenance_company = 'Global Maintainers';
gretelai_synthetic_text_to_sql
CREATE TABLE SongStreams (song VARCHAR(255), country VARCHAR(255), streams INT);
How many streams did song 'X' get in country 'Y'?
SELECT SUM(streams) FROM SongStreams WHERE song = 'X' AND country = 'Y';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, publication TEXT, year INT, month INT, day INT, topic TEXT); INSERT INTO articles (id, title, publication, year, month, day, topic) VALUES (1, 'Article 1', 'El País', 2021, 1, 1, 'Immigration'); INSERT INTO articles (id, title, publication, year, month, day, topic) VALUES (2, 'Article 2', 'El País', 2021, 1, 2, 'Immigration'); INSERT INTO articles (id, title, publication, year, month, day, topic) VALUES (3, 'Article 3', 'El País', 2021, 2, 1, 'Politics');
What is the number of articles about immigration published in "El País" in the first quarter of 2021?
SELECT COUNT(*) FROM articles WHERE publication = 'El País' AND topic = 'Immigration' AND year = 2021 AND month BETWEEN 1 AND 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists_Demographics (artist_id INT, artist_name VARCHAR(255), country VARCHAR(255), num_pieces INT); INSERT INTO Artists_Demographics (artist_id, artist_name, country, num_pieces) VALUES (1, 'Paul Cezanne', 'France', 80), (2, 'Claude Monet', 'France', 120), (3, 'Georges Seurat', 'France', 70);
What is the total number of art pieces created by artists from France?
SELECT SUM(num_pieces) FROM Artists_Demographics WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (company VARCHAR(50), location VARCHAR(50), circular_score FLOAT, certification_date DATE);
Create a table named 'circular_economy' with columns 'company', 'location', 'circular_score' and 'certification_date'
CREATE TABLE circular_economy (company VARCHAR(50), location VARCHAR(50), circular_score FLOAT, certification_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(100), ProgramCategory VARCHAR(50), StartDate DATE, EndDate DATE, TotalDonation DECIMAL(10,2), TotalExpense DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, ProgramCategory, StartDate, EndDate, TotalDonation, TotalExpense) VALUES (1, 'Health Awareness', 'Health', '2020-01-01', '2020-12-31', 35000, 25000), (3, 'Youth Empowerment', 'Education', '2021-06-01', '2022-05-31', 20000, 15000);
Update the 'ProgramCategory' of program ID 3 to 'Social Welfare'.
UPDATE Programs SET ProgramCategory = 'Social Welfare' WHERE ProgramID = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE lipstick_sales (product_name TEXT, sale_country TEXT); INSERT INTO lipstick_sales (product_name, sale_country) VALUES ('Lipstick', 'USA'), ('Lipstick', 'UK'), ('Lipstick', 'Canada');
List the top 3 countries with the highest number of sales for lipstick?
SELECT sale_country, COUNT(*) as sales_count FROM lipstick_sales GROUP BY sale_country ORDER BY sales_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE bridge_inspections (inspection_id INT, bridge_id INT, inspection_date DATE, inspection_results TEXT);
Delete all records from the 'bridge_inspections' table where the 'inspection_date' is before 2010-01-01
DELETE FROM bridge_inspections WHERE inspection_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT, region VARCHAR(50)); INSERT INTO clinics (id, name, type, capacity, region) VALUES (1, 'Clinic A', 'Primary Care', 55, 'Rural New Mexico');
Count the number of clinics in rural New Mexico that have a capacity greater than 50.
SELECT COUNT(clinics.id) FROM clinics WHERE clinics.region = 'Rural New Mexico' AND clinics.capacity > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE balances (id INT, risk_level VARCHAR(10), region VARCHAR(20), balance DECIMAL(15, 2)); INSERT INTO balances (id, risk_level, region, balance) VALUES (1, 'high', 'Africa', 200000.00), (2, 'medium', 'Europe', 150000.00), (3, 'low', 'North America', 100000.00), (4, 'high', 'Asia-Pacific', 300000.00);
What is the average balance for medium-risk accounts in the North America region?
SELECT AVG(balance) FROM balances WHERE risk_level = 'medium' AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE contractors (contractor_id INT, contractor_name VARCHAR(50), is_sustainable BOOLEAN); CREATE TABLE projects (project_id INT, project_name VARCHAR(50), contractor_id INT, start_date DATE); INSERT INTO contractors (contractor_id, contractor_name, is_sustainable) VALUES (1, 'ABC Construct', true), (2, 'GreenBuild Inc', false); INSERT INTO projects (project_id, project_name, contractor_id, start_date) VALUES (1, 'Solar Panel Installation', 1, '2022-01-15'), (2, 'Energy Efficient Office', 1, '2022-04-20'), (3, 'Concrete Paving', 2, '2022-06-01');
Which contractors were involved in sustainable building projects in the last 6 months?
SELECT contractor_name FROM contractors c JOIN projects p ON c.contractor_id = p.contractor_id WHERE start_date >= (CURRENT_DATE - INTERVAL '6 months') AND c.is_sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (PropertyID int, Price int, Borough varchar(255), SustainabilityRating int); INSERT INTO Properties (PropertyID, Price, Borough, SustainabilityRating) VALUES (1, 350000, 'Queens', 4);
List the properties in Queens with the highest SustainabilityRating.
SELECT * FROM Properties WHERE Borough = 'Queens' ORDER BY SustainabilityRating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE alternative_sentencing_usage (state VARCHAR(255), total_cases INT, alternative_sentencing INT); INSERT INTO alternative_sentencing_usage (state, total_cases, alternative_sentencing) VALUES ('California', 12000, 2500), ('Texas', 15000, 3000), ('New York', 10000, 2000), ('Florida', 14000, 3500), ('Illinois', 9000, 1500);
List the top 5 states with the highest percentage of alternative sentencing usage in the criminal justice system?
SELECT state, (alternative_sentencing / total_cases) * 100 AS percentage FROM alternative_sentencing_usage ORDER BY percentage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_type VARCHAR(255)); CREATE TABLE vehicle_maintenance (vehicle_id INT, maintenance_date DATE);
How many vehicles of each type were serviced, based on the 'vehicle_maintenance' and 'vehicles' tables?
SELECT vehicles.vehicle_type, COUNT(*) as vehicle_count FROM vehicles JOIN vehicle_maintenance ON vehicles.vehicle_id = vehicle_maintenance.vehicle_id GROUP BY vehicles.vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE police_stations_3 (id INT, city VARCHAR(50), station_count INT); INSERT INTO police_stations_3 (id, city, station_count) VALUES (1, 'CityT', 9), (2, 'CityU', 7), (3, 'CityV', 11);
What is the total number of police stations in CityT?
SELECT station_count FROM police_stations_3 WHERE city = 'CityT';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, country VARCHAR(255), name VARCHAR(255), num_workers INT, mineral VARCHAR(255)); INSERT INTO mines (id, country, name, num_workers, mineral) VALUES (1, 'Australia', 'Mine A', 75, 'Coal'), (2, 'Australia', 'Mine B', 42, 'Coal'), (3, 'Australia', 'Mine C', 60, 'Coal'), (4, 'Australia', 'Mine D', 80, 'Coal');
Number of workers in each coal mine in Australia with more than 50 employees, ordered by the number of workers descending?
SELECT name, num_workers FROM mines WHERE country = 'Australia' AND mineral = 'Coal' AND num_workers > 50 ORDER BY num_workers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE visual_arts_events (event_id INT, event_name VARCHAR(50), event_date DATE); CREATE TABLE visual_arts_audience (visitor_id INT, event_id INT, age INT); CREATE TABLE tickets_visual_arts (ticket_id INT, event_id INT, tickets_sold INT); INSERT INTO visual_arts_events (event_id, event_name, event_date) VALUES (1, 'Abstract Art Exhibit', '2023-01-01'), (2, 'Photography Retrospective', '2023-02-15'), (3, 'Contemporary Sculpture Showcase', '2023-03-31'); INSERT INTO visual_arts_audience (visitor_id, event_id, age) VALUES (1, 1, 32), (2, 1, 45), (3, 2, 28), (4, 2, 60), (5, 3, 50), (6, 3, 35); INSERT INTO tickets_visual_arts (ticket_id, event_id, tickets_sold) VALUES (1, 1, 150), (2, 2, 120), (3, 3, 200);
What was the average age of visitors who attended visual arts events in the last quarter, and how many tickets were sold for these events?
SELECT AVG(age) as avg_age, SUM(tickets_sold) as total_tickets_sold FROM (visual_arts_audience da INNER JOIN visual_arts_events de ON da.event_id = de.event_id) INNER JOIN tickets_visual_arts ts ON da.event_id = ts.event_id WHERE de.event_date >= DATEADD(quarter, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE microloans (id INT, farmer_id INT, country VARCHAR(50), amount DECIMAL(10,2), issue_date DATE); INSERT INTO microloans (id, farmer_id, country, amount, issue_date) VALUES (1, 1001, 'Nigeria', 500.00, '2020-01-02'), (2, 1002, 'Nigeria', 750.00, '2020-03-15');
What was the total amount of microloans issued to female farmers in Nigeria in 2020?
SELECT SUM(amount) FROM microloans WHERE country = 'Nigeria' AND issue_date >= '2020-01-01' AND issue_date <= '2020-12-31' AND gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE HaircareSales (ProductID INT, ProductName VARCHAR(50), IsVegan BOOLEAN, UnitsSold INT, Country VARCHAR(20)); INSERT INTO HaircareSales (ProductID, ProductName, IsVegan, UnitsSold, Country) VALUES (3, 'Vegan Shampoo', TRUE, 800, 'USA'); INSERT INTO HaircareSales (ProductID, ProductName, IsVegan, UnitsSold, Country) VALUES (4, 'Cruelty-Free Conditioner', TRUE, 900, 'USA'); INSERT INTO HaircareSales (ProductID, ProductName, IsVegan, UnitsSold, Country) VALUES (5, 'Natural Hair Mask', FALSE, 1200, 'France');
Find the top 3 countries with the highest sales of vegan haircare products?
SELECT Country, SUM(UnitsSold) AS TotalSales FROM HaircareSales WHERE IsVegan = TRUE GROUP BY Country ORDER BY TotalSales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE fans (name VARCHAR(50), city VARCHAR(30), tickets_purchased INT); INSERT INTO fans (name, city, tickets_purchased) VALUES ('Alice', 'New York', 5), ('Bob', 'Los Angeles', 3);
What is the average number of tickets purchased by fans in the 'fans' table for each city?
SELECT city, AVG(tickets_purchased) FROM fans GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents(id INT, location VARCHAR(20), time DATE);
Delete all incidents recorded in 'South Boston' before '2015-01-01'
DELETE FROM incidents WHERE location = 'South Boston' AND time < '2015-01-01';
gretelai_synthetic_text_to_sql