context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE artist_galleries (artist_id INT, gallery_name TEXT); INSERT INTO artist_galleries (artist_id, gallery_name) VALUES (1, 'Gagosian'), (2, 'Pace'), (3, 'Hauser & Wirth'); CREATE TABLE artworks (id INT, artist_id INT, title TEXT); INSERT INTO artworks (id, artist_id, title) VALUES (1, 1, 'Dora Maar au Chat'), (2, 2, 'Red Painting'), (3, 3, 'Untitled');
What is the total number of artworks from artists who have a 'gallery' representation?
SELECT COUNT(*) FROM artworks INNER JOIN artist_galleries ON artworks.artist_id = artist_galleries.artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (ArtPieceID INT PRIMARY KEY, ArtPieceName VARCHAR(100), CreationDate DATE, ArtistID INT); INSERT INTO ArtPieces (ArtPieceID, ArtPieceName, CreationDate, ArtistID) VALUES (1, 'The Great Wave', '1831-05-10', 1); INSERT INTO ArtPieces (ArtPieceID, ArtPieceName, CreationDate, ArtistID) VALUES (2, 'The Lonely Castle', '1800-01-01', 2); CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(100), Age INT, Nationality VARCHAR(50), Period VARCHAR(50)); INSERT INTO Artists (ArtistID, ArtistName, Age, Nationality, Period) VALUES (1, 'Hokusai', 89, 'Japanese', 'Edo'); INSERT INTO Artists (ArtistID, ArtistName, Age, Nationality, Period) VALUES (2, 'Morikage Kaseda', 62, 'Japanese', 'Edo');
Get the number of artworks created by Japanese artists in the Edo period
SELECT COUNT(*) FROM ArtPieces JOIN Artists ON ArtPieces.ArtistID = Artists.ArtistID WHERE Artists.Nationality = 'Japanese' AND Artists.Period = 'Edo';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (trench_name TEXT, ocean_region TEXT, average_depth NUMERIC);
What is the average depth of all Pacific Ocean trenches, excluding the Mariana Trench?"
SELECT AVG(at.average_depth) FROM ocean_trenches at WHERE at.ocean_region = 'Pacific' AND at.trench_name != 'Mariana';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, district_name VARCHAR(50), total_population INT, water_usage_gallons_per_day INT); INSERT INTO districts (id, district_name, total_population, water_usage_gallons_per_day) VALUES (1, 'Central', 50000, 1200000); INSERT INTO districts (id, district_name, total_population, water_usage_gallons_per_day) VALUES (2, 'North', 60000, 1500000); CREATE TABLE conservation_programs (id INT, program_name VARCHAR(50), district_id INT, total_participants INT, water_savings_gallons INT); INSERT INTO conservation_programs (id, program_name, district_id, total_participants, water_savings_gallons) VALUES (1, 'Rainwater Harvesting', 1, 2000, 500000); INSERT INTO conservation_programs (id, program_name, district_id, total_participants, water_savings_gallons) VALUES (2, 'Smart Irrigation', 2, 2500, 750000);
What is the total water savings for conservation programs in each district, and what percentage of the district's water usage does each program represent?
SELECT cp.id, cp.program_name, cp.district_id, SUM(cp.water_savings_gallons) as total_water_savings, (SUM(cp.water_savings_gallons) * 100.0 / d.water_usage_gallons_per_day) as water_savings_percentage FROM conservation_programs cp JOIN districts d ON cp.district_id = d.id GROUP BY cp.id, cp.program_name, cp.district_id;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_staff (staff_id INT, clinic_id INT, role VARCHAR(20), experience INT); INSERT INTO medical_staff (staff_id, clinic_id, role, experience) VALUES (1, 1, 'doctor', 10), (2, 1, 'nurse', 6), (3, 2, 'doctor', 8), (4, 2, 'nurse', 12), (5, 3, 'doctor', 15), (6, 3, 'nurse', 7), (7, 4, 'nurse', 5), (8, 4, 'nurse', 6), (9, 4, 'nurse', 7), (10, 4, 'nurse', 8), (11, 4, 'nurse', 9), (12, 4, 'nurse', 10), (13, 4, 'nurse', 11), (14, 4, 'nurse', 12); CREATE TABLE clinic_detail (clinic_id INT, location VARCHAR(20)); INSERT INTO clinic_detail (clinic_id, location) VALUES (1, 'California'), (2, 'California'), (3, 'New York'), (4, 'Montana');
What is the maximum number of nurses with more than 5 years of experience in rural health clinics in the state of Montana?
SELECT MAX(experience) FROM medical_staff WHERE role = 'nurse' AND clinic_id IN (SELECT clinic_id FROM clinic_detail WHERE location = 'Montana') AND experience > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, sale_date DATE, revenue INT);
What is the total revenue generated in each quarter of the year, ordered by the total revenue?
SELECT DATE_TRUNC('quarter', sale_date) AS sale_quarter, SUM(revenue) AS total_revenue FROM sales GROUP BY sale_quarter ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Machines (Id INT, Name VARCHAR(50), Type VARCHAR(50), Status VARCHAR(50)); INSERT INTO Machines (Id, Name, Type, Status) VALUES (1, 'Reactor 1', 'Chemical', 'Operational'), (2, 'Separator 2', 'Purification', 'Under Maintenance');
Display machines that are 'Operational' and 'Under Maintenance'.
SELECT * FROM Machines WHERE Status IN ('Operational', 'Under Maintenance');
gretelai_synthetic_text_to_sql
CREATE TABLE patents (patent_id INT, patent_name VARCHAR(255), country VARCHAR(255), patent_date DATE, domain VARCHAR(255));
What is the number of patents filed in the clean energy domain, for each country, for the years 2016 to 2020?
SELECT country, COUNT(*) FROM patents WHERE domain = 'clean energy' AND patent_date BETWEEN '2016-01-01' AND '2020-12-31' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), JoinDate DATETIME);
Insert new records for 5 members who joined in January 2022 with no workouts yet into the 'Workouts' table
INSERT INTO Workouts (WorkoutID, MemberID, Duration, MembershipType) SELECT NULL, m.MemberID, 0, 'Standard' FROM (SELECT MemberID FROM Members WHERE MONTH(JoinDate) = 1 AND YEAR(JoinDate) = 2022 LIMIT 5) m WHERE NOT EXISTS (SELECT 1 FROM Workouts w WHERE w.MemberID = m.MemberID);
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName VARCHAR(50), Region VARCHAR(20)); INSERT INTO Policyholders VALUES (1, 'John Smith', 'Southeast Asia'); INSERT INTO Policyholders VALUES (2, 'Jane Doe', 'North America'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2), ClaimDate DATE, Region VARCHAR(20)); INSERT INTO Claims VALUES (1, 1, 500, '2022-01-01', 'Southeast Asia'); INSERT INTO Claims VALUES (2, 2, 300, '2022-02-15', 'North America'); CREATE TABLE Policies (PolicyID INT, PolicyType VARCHAR(20)); INSERT INTO Policies VALUES (1, 'Auto'); INSERT INTO Policies VALUES (2, 'Home');
How many policyholders are there in each region, and what is the total claim amount for each region?
SELECT ph.Region, COUNT(DISTINCT ph.PolicyID) as NumPolicyholders, SUM(c.ClaimAmount) as TotalClaimAmount FROM Policyholders ph INNER JOIN Claims c ON ph.PolicyID = c.PolicyID GROUP BY ph.Region;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage(state VARCHAR(20), year INT, consumption INT); INSERT INTO water_usage(state, year, consumption) VALUES ('Arizona', 2015, 5000), ('Arizona', 2016, 5500), ('Arizona', 2017, 6000), ('Arizona', 2018, 6500);
What is the average water consumption in Arizona from 2015 to 2018?
SELECT AVG(consumption) FROM water_usage WHERE state = 'Arizona' AND year BETWEEN 2015 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, name TEXT, region TEXT, capacity_mw FLOAT, efficiency FLOAT); INSERT INTO wind_farms (id, name, region, capacity_mw, efficiency) VALUES (1, 'Windfarm A', 'west', 150.5, 0.35); INSERT INTO wind_farms (id, name, region, capacity_mw, efficiency) VALUES (2, 'Windfarm B', 'east', 120.2, 0.42);
What is the average energy efficiency of wind farms in the 'east' region?
SELECT AVG(efficiency) FROM wind_farms WHERE region = 'east';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, ai_adoption) VALUES (1, 'The Amazon Eco-Hotel', 'Brazil', true), (2, 'The Andean Retreat', 'Peru', false), (3, 'The Patagonian Lodge', 'Argentina', true);
What is the total number of hotels in South America that have adopted AI technology?
SELECT COUNT(*) FROM hotels WHERE ai_adoption = true AND country = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), founding_year INT); INSERT INTO company (id, name, founding_year) VALUES (1, 'Acme Inc', 2018), (2, 'Beta Corp', 2019), (3, 'Gamma Startup', 2015); CREATE TABLE funding (id INT, company_id INT, amount INT, funding_year INT); INSERT INTO funding (id, company_id, amount, funding_year) VALUES (1, 1, 500000, 2021), (2, 1, 1000000, 2020), (3, 2, 2000000, 2021);
Which companies have received funding in the last 3 years and have more than 5 founders?
SELECT company.name FROM company INNER JOIN funding ON company.id = funding.company_id WHERE funding_year >= YEAR(CURRENT_DATE) - 3 AND (SELECT COUNT(*) FROM company WHERE company.id = funding.company_id) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, release_year INT, director VARCHAR(50));
List the directors and their respective total number of movies for those who have directed more than 5 movies.
SELECT director, COUNT(*) as total_movies FROM movies GROUP BY director HAVING total_movies > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE SupportPrograms (ProgramID INT, ProgramName VARCHAR(50), Region VARCHAR(50), ImplementationMonth INT, ImplementationYear INT); INSERT INTO SupportPrograms (ProgramID, ProgramName, Region, ImplementationMonth, ImplementationYear) VALUES (1, 'Assistive Technology', 'Eastern', 1, 2021), (2, 'Sign Language Interpretation', 'Eastern', 2, 2021), (3, 'Accessible Furniture', 'Eastern', 3, 2021);
How many support programs were implemented in the Eastern region each month for the year 2021?
SELECT ImplementationYear, ImplementationMonth, COUNT(ProgramID) FROM SupportPrograms WHERE Region = 'Eastern' GROUP BY ImplementationYear, ImplementationMonth;
gretelai_synthetic_text_to_sql
CREATE TABLE directors (id INT, name VARCHAR(255), gender VARCHAR(10), total_movies INT); INSERT INTO directors (id, name, gender, total_movies) VALUES (1, 'Director1', 'Female', 5), (2, 'Director2', 'Male', 8), (3, 'Director3', 'Female', 10);
Who is the most prolific female director in India?
SELECT name, total_movies FROM directors WHERE gender = 'Female' ORDER BY total_movies DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmLocation (LocationID INT, FarmName VARCHAR(50), Country VARCHAR(50)); INSERT INTO FarmLocation (LocationID, FarmName, Country) VALUES (1, 'FishFirst Farm', 'United States'); CREATE TABLE Transactions (TransactionID INT, FarmID INT, QuantitySold INT); INSERT INTO Transactions (TransactionID, FarmID, QuantitySold) VALUES (1, 1, 200); INSERT INTO Transactions (TransactionID, FarmID, QuantitySold) VALUES (2, 1, 300);
What is the average quantity of fish sold per transaction in the United States?
SELECT AVG(QuantitySold) FROM Transactions WHERE FarmID = (SELECT LocationID FROM FarmLocation WHERE Country = 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO virtual_tours VALUES (1, 'Himeji Castle', 'Japan'), (2, 'Mount Fuji', 'Japan'), (3, 'Tower of London', 'England');
How many virtual tours are available for historical sites in England?
SELECT COUNT(*) FROM virtual_tours WHERE country = 'England';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT PRIMARY KEY, site_id INT, date DATE, attendees INT, notes TEXT);
Insert a new outreach event into the 'events' table for the 'Tutankhamun's Tomb'
INSERT INTO events (id, site_id, date, attendees, notes) VALUES (1, 2, '2023-07-15', 150, 'Virtual tour of Tutankhamun''s Tomb');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistGenre3 (ArtistID INT, Genre VARCHAR(20)); INSERT INTO ArtistGenre3 (ArtistID, Genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'), (4, 'R&B'), (4, 'Hip Hop'), (5, 'Pop'), (6, 'Jazz'), (7, 'R&B');
Which artists have released music in both the R&B and Jazz genres?
SELECT ArtistID FROM ArtistGenre3 WHERE Genre = 'Jazz' INTERSECT SELECT ArtistID FROM ArtistGenre3 WHERE Genre = 'R&B';
gretelai_synthetic_text_to_sql
CREATE TABLE BioMed_ClinicalTrials(company VARCHAR(20), year INT, trials INT);INSERT INTO BioMed_ClinicalTrials VALUES('BioMed', 2021, 30);
How many clinical trials did 'BioMed' conduct in 2021?
SELECT COUNT(trials) FROM BioMed_ClinicalTrials WHERE company = 'BioMed' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;USE genetics;CREATE TABLE if not exists projects(id INT, name VARCHAR(255), start_date DATE);INSERT INTO projects(id, name, start_date) VALUES (1, 'ProjectX', '2021-03-15'), (2, 'ProjectY', '2019-12-31'), (3, 'ProjectZ', '2020-05-10');
Which genetic research projects have a start date on or after Jan 1, 2020?
SELECT * FROM genetics.projects WHERE start_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_models (model_name TEXT, safety_rating INTEGER); INSERT INTO fairness_models (model_name, safety_rating) VALUES ('Model J', 6), ('Model K', 8), ('Model L', 7);
What is the average safety rating for algorithmic fairness models?
SELECT AVG(safety_rating) FROM fairness_models;
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policies (id INT, policy VARCHAR(50), region VARCHAR(50)); INSERT INTO clean_energy_policies (id, policy, region) VALUES (1, 'Renewable Portfolio Standard', 'south_america'), (2, 'Net Metering', 'south_america'), (3, 'Production Tax Credit', 'south_america');
What is the total number of clean energy policies in the 'south_america' region, ranked in descending order?
SELECT region, COUNT(policy) as total_policies FROM clean_energy_policies WHERE region = 'south_america' GROUP BY region ORDER BY total_policies DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO products (product_id, product_name, category, price) VALUES (1, 'Sensitive Skin Cleanser', 'Skincare', 17.99), (2, 'Gentle Makeup Remover', 'Skincare', 12.99);
Update the price of the 'Sensitive Skin' cleanser to $19.99
UPDATE products SET price = 19.99 WHERE product_name = 'Sensitive Skin Cleanser';
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTourCompanies (name VARCHAR(50), location VARCHAR(20), year INT, reviews INT, rating INT);
What is the average number of positive reviews received by virtual tour companies in Canada for the year 2022?
SELECT AVG(rating) FROM VirtualTourCompanies WHERE location = 'Canada' AND year = 2022 AND reviews > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists smart_city_projects (project_id INT PRIMARY KEY, project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO smart_city_projects (project_id, project_name, start_date, end_date) VALUES (1, 'Smart Traffic Management', '2018-01-01', '2019-12-31'), (2, 'Smart Waste Management', '2017-07-01', '2019-06-30'), (3, 'Smart Lighting', '2019-04-01', '2021-03-31');
Which smart city projects were completed before 2020?
SELECT project_name FROM smart_city_projects WHERE end_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Caribbean_Marine_Species (species_name TEXT, population INT, is_affected_by_pollution BOOLEAN); INSERT INTO Caribbean_Marine_Species (species_name, population, is_affected_by_pollution) VALUES ('Manatee', 1300, true), ('Coral', 65000, true), ('Seahorse', 5000, false);
How many marine species are affected by pollution in the Caribbean Sea?
SELECT COUNT(*) FROM Caribbean_Marine_Species WHERE is_affected_by_pollution = true;
gretelai_synthetic_text_to_sql
CREATE TABLE city_feedback (city VARCHAR(255), feedback_id INT, feedback TEXT); INSERT INTO city_feedback
How many citizen feedback records are there for 'City E'?
SELECT COUNT(*) FROM city_feedback WHERE city = 'City E'
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftComponents (id INT, component_name VARCHAR(50), manufacturing_cost FLOAT); CREATE VIEW ComponentManufacturingCosts AS SELECT component_name, AVG(manufacturing_cost) as avg_cost FROM AircraftComponents GROUP BY component_name;
What is the average manufacturing cost for aircraft components?
SELECT ComponentManufacturingCosts.component_name, ComponentManufacturingCosts.avg_cost FROM ComponentManufacturingCosts;
gretelai_synthetic_text_to_sql
CREATE TABLE hydro_power (country VARCHAR(20), installed_capacity INT); INSERT INTO hydro_power (country, installed_capacity) VALUES ('Colombia', 15678), ('Colombia', 17000), ('Peru', 12000), ('Peru', 14500), ('Peru', 13000);
What is the maximum installed capacity for hydroelectric power plants in Colombia and Peru?
SELECT MAX(installed_capacity) FROM hydro_power WHERE country IN ('Colombia', 'Peru');
gretelai_synthetic_text_to_sql
CREATE TABLE paris_metro (trip_id INT, fare FLOAT, trip_date DATE);
What is the total fare collected for all trips on the Paris metro in the past week?
SELECT SUM(fare) FROM paris_metro WHERE trip_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (strategy_id INT, name VARCHAR(50), risk_level VARCHAR(50), AUM DECIMAL(10,2)); INSERT INTO investment_strategies (strategy_id, name, risk_level, AUM) VALUES (1, 'Growth', 'Moderate', 5000000.00), (2, 'Income', 'Conservative', 3000000.00);
What is the total assets under management (AUM) for investment strategies with a risk level of 'conservative'?
SELECT SUM(AUM) FROM investment_strategies WHERE risk_level = 'Conservative';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.research (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), status VARCHAR(255)); INSERT INTO biotech.research (id, name, country, status) VALUES (1, 'Genome Indonesia', 'Indonesia', 'Completed'); INSERT INTO biotech.research (id, name, country, status) VALUES (2, 'Brain Indonesia', 'Indonesia', 'Ongoing');
Which genetic research projects have been completed in Indonesia?
SELECT name FROM biotech.research WHERE country = 'Indonesia' AND status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, country VARCHAR(255), type VARCHAR(255)); INSERT INTO factories (id, country, type) VALUES
Which country has the most garment factories by type?
SELECT country, type, COUNT(*) AS factory_count FROM factories GROUP BY country, type ORDER BY factory_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites(site_id INT, site_name VARCHAR(50), country VARCHAR(50), received_funding BOOLEAN); CREATE VIEW cultural_heritage_sites AS SELECT site_id, site_name, country FROM heritage_sites WHERE site_name LIKE '%cultural%';
How many cultural heritage sites in Spain have received funding for preservation?
SELECT COUNT(*) FROM cultural_heritage_sites WHERE country = 'Spain' AND received_funding = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Athlete (AthleteID INT, Name VARCHAR(50), Age INT, JoinedWellbeingProgram DATE); INSERT INTO Athlete (AthleteID, Name, Age, JoinedWellbeingProgram) VALUES (1, 'Jane Smith', 28, '2022-01-01');
What is the average age of athletes who joined the Wellbeing Program in 2022?
SELECT AVG(Age) FROM Athlete WHERE YEAR(JoinedWellbeingProgram) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title VARCHAR(255), is_investigative BOOLEAN, word_count INT, date DATE); INSERT INTO articles (id, title, is_investigative, word_count, date) VALUES (1, 'Investigating Corruption', true, 2500, '2021-01-01'), (2, 'The Rise of Solar Energy', false, 1500, '2022-03-15'), (3, 'The Hidden World of Cryptocurrency', true, 3000, '2020-12-20'), (4, 'The Impact of Climate Change on Agriculture', false, 2000, '2022-06-01');
Show the total word count for all investigative articles published before 2022
SELECT SUM(word_count) FROM articles WHERE is_investigative = true AND date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_apps (app_id INT, app_name VARCHAR(50), category VARCHAR(50), platform VARCHAR(50), launch_date DATE);
Delete records from the 'decentralized_apps' table where 'app_name' is 'Uniswap'
DELETE FROM decentralized_apps WHERE app_name = 'Uniswap';
gretelai_synthetic_text_to_sql
CREATE TABLE textile_sourcing (id INT, material VARCHAR(20), country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO textile_sourcing (id, material, country, price) VALUES (1, 'cotton', 'Brazil', 3.50), (2, 'silk', 'China', 7.00);
Update the price of sustainable cotton textiles sourced from Brazil to $4.00.
UPDATE textile_sourcing SET price = 4.00 WHERE material = 'cotton' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE EVSales (State VARCHAR(255), EVSales INT); INSERT INTO EVSales (State, EVSales) VALUES ('California', 50000), ('Texas', 35000), ('Florida', 30000), ('New York', 28000), ('Washington', 25000);
List the top 3 states with the most electric vehicle sales.
SELECT State, SUM(EVSales) AS TotalEVSales FROM EVSales GROUP BY State ORDER BY TotalEVSales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyOrgs (name VARCHAR(20), country VARCHAR(10)); INSERT INTO SafetyOrgs (name, country) VALUES ('Euro NCAP', 'Germany'); INSERT INTO SafetyOrgs (name, country) VALUES ('ADAC', 'Germany');
Which vehicle safety testing organizations operate in Germany?
SELECT name FROM SafetyOrgs WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50)); INSERT INTO Vessels (ID, Name, Type) VALUES (1, 'Ocean Titan', 'Cargo'); INSERT INTO Vessels (ID, Name, Type) VALUES (2, 'Sea Serpent', 'Tanker');
Update the type of the vessel 'Sea Serpent' to 'Passenger'.
UPDATE Vessels SET Type = 'Passenger' WHERE Name = 'Sea Serpent';
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE); INSERT INTO project (id, name, location, start_date) VALUES (1, 'Green Build', 'NYC', '2020-01-01'), (2, 'Solar Tower', 'LA', '2019-12-15'), (3, 'Eco House', 'Austin', '2020-03-01'); CREATE TABLE sustainable (project_id INT, solar_panels BOOLEAN, wind_turbines BOOLEAN, green_roof BOOLEAN); INSERT INTO sustainable (project_id, solar_panels, wind_turbines, green_roof) VALUES (1, TRUE, TRUE, TRUE), (2, TRUE, TRUE, FALSE), (3, FALSE, FALSE, TRUE), (4, FALSE, TRUE, FALSE);
How many sustainable features are present in projects in 'LA'?
SELECT COUNT(*) FROM sustainable s JOIN project p ON s.project_id = p.id WHERE p.location = 'LA';
gretelai_synthetic_text_to_sql
CREATE TABLE game_servers (server_id INT, region VARCHAR(10), player_capacity INT);
Delete all records in the game_servers table where the region is 'Asia'
DELETE FROM game_servers WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contractor_name VARCHAR(255), contract_value FLOAT, contractor_region VARCHAR(255)); INSERT INTO defense_contracts (contractor_name, contract_value, contractor_region) VALUES ('Lockheed Martin', 1000000000, 'Northeast'), ('Boeing', 800000000, 'Midwest'), ('Raytheon', 700000000, 'West'), ('Northrop Grumman', 600000000, 'South'), ('General Dynamics', 500000000, 'Northeast');
What is the total value of defense contracts awarded to companies in a specific region?
SELECT contractor_region, SUM(contract_value) FROM defense_contracts GROUP BY contractor_region;
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain_transparency (element VARCHAR(10), supplier VARCHAR(20), transparency INT); INSERT INTO supply_chain_transparency VALUES ('Yttrium', 'Supplier A', 7), ('Yttrium', 'Supplier B', 8), ('Lutetium', 'Supplier A', 9), ('Lutetium', 'Supplier C', 6);
Find the supply chain transparency for Yttrium and Lutetium
SELECT element, AVG(transparency) AS avg_transparency FROM supply_chain_transparency GROUP BY element;
gretelai_synthetic_text_to_sql
CREATE TABLE Courts (Location VARCHAR(255), CourtID INT); CREATE TABLE Cases (CaseID INT, CourtID INT, CaseDate DATE);
What is the average number of cases per month for each court location, for the past year?
SELECT Courts.Location, AVG(DATEDIFF(MONTH, CaseDate, GETDATE())) OVER(PARTITION BY Courts.Location) FROM Courts JOIN Cases ON Courts.CourtID = Cases.CourtID WHERE CaseDate >= DATEADD(YEAR, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE support_group_meetings (meeting_date DATE); INSERT INTO support_group_meetings (meeting_date) VALUES ('2023-01-02'), ('2023-01-15'), ('2023-02-03'), ('2023-03-01'), ('2023-03-15');
How many support group meetings were held in Q1 of 2023?
SELECT COUNT(*) FROM (SELECT meeting_date FROM support_group_meetings WHERE meeting_date >= '2023-01-01' AND meeting_date < '2023-04-01') AS q1_meetings;
gretelai_synthetic_text_to_sql
CREATE TABLE haiti_relief (id INT, supply_type VARCHAR(20), quantity INT); INSERT INTO haiti_relief (id, supply_type, quantity) VALUES (1, 'food', 500), (2, 'water', 800), (3, 'shelter', 300); CREATE TABLE colombia_relief (id INT, supply_type VARCHAR(20), quantity INT); INSERT INTO colombia_relief (id, supply_type, quantity) VALUES (1, 'food', 600), (2, 'water', 400), (3, 'medical', 700);
What is the total number of relief supplies distributed in Haiti and Colombia?
SELECT SUM(h.quantity + c.quantity) FROM haiti_relief h, colombia_relief c WHERE h.supply_type = c.supply_type;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, location VARCHAR(50), capacity INT); INSERT INTO factories (factory_id, location, capacity) VALUES (1, 'Madrid, Spain', 5000), (2, 'Paris, France', 7000), (3, 'London, UK', 6000);
How many factories are there in Spain and the United Kingdom?
SELECT COUNT(*) FROM factories WHERE location LIKE '%Spain%' OR location LIKE '%UK%';
gretelai_synthetic_text_to_sql
CREATE TABLE battery_storage (id INT PRIMARY KEY, capacity FLOAT, warranty INT, manufacturer VARCHAR(255));
Delete records in the "battery_storage" table where the warranty is less than 8 years
DELETE FROM battery_storage WHERE warranty < 8;
gretelai_synthetic_text_to_sql
CREATE TABLE offices (office_id INT, office_name VARCHAR(20)); INSERT INTO offices (office_id, office_name) VALUES (1, 'Boston'), (2, 'New York'), (3, 'Chicago'); CREATE TABLE cases (case_id INT, attorney_id INT, office_id INT); INSERT INTO cases (case_id, attorney_id, office_id) VALUES (1, 101, 1), (2, 102, 1), (3, 103, 1), (4, 104, 2), (5, 105, 3), (6, 106, 3), (7, 107, 3);
List the number of cases for each attorney from the 'Chicago' office, ordered by the number of cases in descending order?
SELECT attorney_id, COUNT(*) as num_cases FROM cases JOIN offices ON cases.office_id = offices.office_id WHERE offices.office_name = 'Chicago' GROUP BY attorney_id ORDER BY num_cases DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE public_services (service_id INT, service_name VARCHAR(255), region_id INT, budget INT);
Find the total budget allocated for public services in each region, ranked from highest to lowest.
SELECT r.region_name, SUM(ps.budget) as total_budget FROM regions r JOIN public_services ps ON r.region_id = ps.region_id GROUP BY r.region_name ORDER BY total_budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, company VARCHAR(50), launch_year INT); INSERT INTO satellites (satellite_id, company, launch_year) VALUES (1, 'SpaceX', 2012), (2, 'ISRO', 2010), (3, 'ULA', 2015), (4, 'Roscosmos', 2014), (5, 'China National Space Administration', 2018);
What is the total number of satellites launched by each company in the last decade?
SELECT company, COUNT(*) as total_launches FROM satellites WHERE launch_year >= 2010 GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE nutrition_facts (fact_id INT, meal_id INT, calories INT, protein INT, vitamins VARCHAR(50)); INSERT INTO nutrition_facts (fact_id, meal_id, calories, protein, vitamins) VALUES (1, 1, NULL, 15, 'A, C, D'), (2, 2, 220, NULL, 'B12, E'), (3, 3, 400, 12, 'B6, K'), (4, 5, 300, 20, NULL);
How many nutrition facts are missing in the nutrition_facts table?
SELECT COUNT(*) FROM nutrition_facts WHERE calories IS NULL OR protein IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_protocols (id INT, compound_name VARCHAR(255), last_use DATE); INSERT INTO safety_protocols (id, compound_name, last_use) VALUES (1, 'Compound A', '2020-06-15'), (2, 'Compound B', '2021-02-03'), (3, 'Compound C', '2019-09-28');
List the chemical compounds that have been used in any safety protocols in the last year.
SELECT compound_name FROM safety_protocols WHERE last_use >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscription_type (subscriber_id INT, subscription_start_date DATE, subscription_type VARCHAR(50), subscription_fee DECIMAL(10, 2)); INSERT INTO mobile_subscription_type (subscriber_id, subscription_start_date, subscription_type, subscription_fee) VALUES (1, '2020-01-01', 'Postpaid', 50.00), (2, '2019-06-15', 'Prepaid', 40.00), (3, '2021-02-20', 'Postpaid', 55.00); CREATE TABLE subscription_duration (subscriber_id INT, subscription_end_date DATE); INSERT INTO subscription_duration (subscriber_id, subscription_end_date) VALUES (1, '2021-01-01'), (2, '2020-12-31'), (3, '2022-01-01');
What is the total revenue generated from each subscription type ('Postpaid', 'Prepaid') in the 'mobile_subscription_type' table?
SELECT subscription_type, SUM(DATEDIFF(subscription_end_date, subscription_start_date) * subscription_fee) as total_revenue FROM mobile_subscription_type JOIN subscription_duration ON mobile_subscription_type.subscriber_id = subscription_duration.subscriber_id GROUP BY subscription_type;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE, amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, client_id, transaction_date, amount) VALUES (1, 1, '2021-01-01', 500.00), (2, 1, '2021-01-01', 1000.00), (3, 2, '2021-01-02', 250.00), (4, 3, '2021-01-03', 10000.00), (5, 4, '2021-01-03', 500.00); CREATE TABLE clients (client_id INT, region VARCHAR(20)); INSERT INTO clients (client_id, region) VALUES (1, 'EMEA'), (2, 'Americas'), (3, 'APAC'), (4, 'EMEA');
What is the average daily value of transactions for clients in the EMEA region?
SELECT AVG(amount) FROM transactions JOIN clients ON transactions.client_id = clients.client_id WHERE clients.region = 'EMEA';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT PRIMARY KEY, attorney_name VARCHAR(50), experience INT, area_of_practice VARCHAR(50)); INSERT INTO attorneys (attorney_id, attorney_name, experience, area_of_practice) VALUES (6, 'Dave', 11, 'Criminal Law'), (7, 'Danielle', 8, 'Family Law');
Update the area of practice for attorney 'Dave' to 'Civil Law' in the 'attorneys' table
UPDATE attorneys SET area_of_practice = 'Civil Law' WHERE attorney_name = 'Dave';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT);
List the total number of menu items with a price greater than $10.00
SELECT COUNT(*) FROM menu_items WHERE price > 10.00;
gretelai_synthetic_text_to_sql
CREATE TABLE AuthenticationLogs (id INT PRIMARY KEY, username VARCHAR(255), login_time TIMESTAMP, logout_time TIMESTAMP, authentication_status VARCHAR(50)); INSERT INTO AuthenticationLogs (id, username, login_time, logout_time, authentication_status) VALUES (1, 'jane.doe', '2021-03-15 11:00:00', '2021-03-15 12:00:00', 'Success'), (2, 'john.doe', '2021-03-15 13:00:00', '2021-03-15 13:30:00', 'Failed');
Calculate the total duration of successful authentications for the user 'jane.doe'.
SELECT username, SUM(TIMESTAMPDIFF(MINUTE, login_time, logout_time)) FROM AuthenticationLogs WHERE username = 'jane.doe' AND authentication_status = 'Success' GROUP BY username;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_labor (id INT, worker_name VARCHAR(50), hours_worked INT, project_type VARCHAR(20), state VARCHAR(20)); INSERT INTO construction_labor (id, worker_name, hours_worked, project_type, state) VALUES (1, 'Jane Doe', 100, 'Sustainable', 'New York');
Update the hours worked by a worker on a sustainable project in New York.
UPDATE construction_labor SET hours_worked = 110 WHERE worker_name = 'Jane Doe' AND project_type = 'Sustainable' AND state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255), cuisine VARCHAR(255)); INSERT INTO restaurants (restaurant_id, name, cuisine) VALUES (1, 'Big Burger', 'American'); INSERT INTO restaurants (restaurant_id, name, cuisine) VALUES (2, 'Sushi Hana', 'Japanese'); CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), restaurant_id INT); INSERT INTO menu_items (menu_item_id, name, price, restaurant_id) VALUES (1, 'Big Burger', 12.99, 1); INSERT INTO menu_items (menu_item_id, name, price, restaurant_id) VALUES (2, 'Chicken Teriyaki', 15.99, 2);
What are the total sales and number of menu items for each cuisine type?
SELECT cuisine, SUM(price) AS total_sales, COUNT(*) AS num_menu_items FROM restaurants JOIN menu_items ON restaurants.restaurant_id = menu_items.restaurant_id GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE artifact_details (id INT, artifact_id INT, artifact_type VARCHAR(50), weight INT);
Which countries had more than 50% of artifacts made of pottery?
SELECT country, AVG(CASE WHEN artifact_type = 'pottery' THEN 1.0 ELSE 0.0 END) as pottery_percentage FROM excavation_sites GROUP BY country HAVING AVG(CASE WHEN artifact_type = 'pottery' THEN 1.0 ELSE 0.0 END) > 0.5
gretelai_synthetic_text_to_sql
CREATE TABLE material_production (material_id INT, material_name VARCHAR(50), production_date DATE, production_cost DECIMAL(10,2)); INSERT INTO material_production (material_id, material_name, production_date, production_cost) VALUES (1, 'Organic Cotton', '2022-01-01', 450.00), (2, 'Recycled Polyester', '2022-02-05', 600.00), (3, 'Hemp', '2022-03-10', 700.00);
Delete the record of 'Organic Cotton' production in Africa on 2022-01-01 with production cost $450.
DELETE FROM material_production WHERE material_name = 'Organic Cotton' AND production_date = '2022-01-01' AND production_cost = 450.00;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_donations (category TEXT, donation_month INT, donation_amount FLOAT); INSERT INTO monthly_donations (category, donation_month, donation_amount) VALUES ('impact_investing', 12, 5000.00), ('philanthropic_trends', 11, 3000.00);
What is the total donation amount for the 'impact_investing' category in the month of December?
SELECT SUM(donation_amount) FROM monthly_donations WHERE category = 'impact_investing' AND donation_month = 12;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(255)); INSERT INTO artists (id, name) VALUES (1, 'Sia'); CREATE TABLE albums (id INT, artist_id INT, release_date DATE);
How many albums were released by artist 'Sia'?
SELECT COUNT(*) FROM albums WHERE albums.artist_id = (SELECT id FROM artists WHERE artists.name = 'Sia');
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (id INT, name TEXT, province TEXT, year INT); INSERT INTO Dams (id, name, province, year) VALUES (1, 'Niagara Dam', 'Ontario', 1965); INSERT INTO Dams (id, name, province, year) VALUES (2, 'Gardiner Dam', 'Saskatchewan', 1967);
How many dams were built in the province of Ontario between 1950 and 1980?
SELECT COUNT(*) FROM Dams WHERE province = 'Ontario' AND year BETWEEN 1950 AND 1980
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_type VARCHAR(255), purchase_date DATE); INSERT INTO military_equipment (equipment_type, purchase_date) VALUES ('Tank', '2011-01-01'), ('Jet', '2012-01-01'), ('Submarine', '2005-01-01');
List all equipment types and their corresponding purchase dates from the military_equipment table, ordered by purchase date in descending order
SELECT equipment_type, purchase_date FROM military_equipment ORDER BY purchase_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (model_name TEXT, safety_score INTEGER); INSERT INTO ai_safety (model_name, safety_score) VALUES ('model1', 85), ('model2', 92), ('model3', 88);
Delete the record with the highest safety score in the 'ai_safety' table.
DELETE FROM ai_safety WHERE safety_score = (SELECT MAX(safety_score) FROM ai_safety);
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, country VARCHAR(50), labor_practices VARCHAR(50)); CREATE TABLE workers (worker_id INT, factory_id INT, position VARCHAR(50)); INSERT INTO factories (factory_id, country, labor_practices) VALUES (1, 'Spain', 'fair'), (2, 'Italy', 'unfair'), (3, 'Spain', 'fair'), (4, 'Italy', 'fair'); INSERT INTO workers (worker_id, factory_id, position) VALUES (1, 1, 'manager'), (2, 1, 'engineer'), (3, 2, 'worker'), (4, 3, 'manager'), (5, 3, 'engineer'), (6, 4, 'manager');
What is the total number of workers in factories that have implemented fair labor practices in Spain and Italy?
SELECT COUNT(workers.worker_id) FROM workers INNER JOIN factories ON workers.factory_id = factories.factory_id WHERE factories.country IN ('Spain', 'Italy') AND factories.labor_practices = 'fair';
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (id INT, city_id INT, type VARCHAR(50), passengers INT); INSERT INTO public_transportation (id, city_id, type, passengers) VALUES (4, 3, 'Tram', 300000); INSERT INTO public_transportation (id, city_id, type, passengers) VALUES (5, 3, 'Ferry', 50000);
How many public transportation systems are available in each city?
SELECT city_id, COUNT(DISTINCT type) FROM public_transportation GROUP BY city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_identity TEXT); INSERT INTO companies (id, name, industry, founder_identity) VALUES (1, 'SolarPower', 'Renewable Energy', 'LGBTQ+'); INSERT INTO companies (id, name, industry, founder_identity) VALUES (2, 'TechMates', 'Technology', 'Straight'); INSERT INTO companies (id, name, industry, founder_identity) VALUES (3, 'InnovateIT', 'Technology', 'LGBTQ+');
How many companies have been founded by individuals who identify as LGBTQ+ in the renewable energy sector?
SELECT COUNT(*) FROM companies WHERE industry = 'Renewable Energy' AND founder_identity = 'LGBTQ+';
gretelai_synthetic_text_to_sql
CREATE TABLE media_content (id INT, title VARCHAR(255), release_year INT, rating FLOAT, genre VARCHAR(255), format VARCHAR(50), country VARCHAR(255), director VARCHAR(255));
What is the average rating of movies and TV shows directed by women, and how many unique female directors are there?
SELECT director, AVG(rating) AS avg_rating, COUNT(DISTINCT director) AS unique_directors FROM media_content WHERE director LIKE '%female%' GROUP BY director;
gretelai_synthetic_text_to_sql
CREATE TABLE forests_volume (id INT, type VARCHAR(20), area FLOAT, volume FLOAT); INSERT INTO forests_volume (id, type, area, volume) VALUES (1, 'Temperate', 1500, 1500000);
List the temperate forests with more than 1000 square kilometers and timber volume
SELECT type FROM forests_volume WHERE area > 1000 AND volume > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_management (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT);
What is the capacity of the vessel with the ID 3 in the 'fleet_management' table?
SELECT capacity FROM fleet_management WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id INT, category VARCHAR(255), has_natural_ingredients BOOLEAN, price DECIMAL(5,2));INSERT INTO products (product_id, category, has_natural_ingredients, price) VALUES (1, 'Cleanser', true, 19.99), (2, 'Toner', false, 12.99), (3, 'Serum', true, 35.99), (4, 'Moisturizer', false, 24.99);
Count the number of skincare products that contain natural ingredients and have a price above the median?
SELECT COUNT(*) FROM products WHERE category = 'skincare' AND has_natural_ingredients = true AND price > (SELECT AVG(price) FROM products WHERE category = 'skincare');
gretelai_synthetic_text_to_sql
CREATE TABLE Astrophysics_Research (ARid INT, Title VARCHAR, Description TEXT, Researcher_Name VARCHAR, University VARCHAR);
Insert new astrophysics research records into the Astrophysics_Research table.
WITH new_research AS (VALUES (1, 'Black Holes and Singularities', 'Study of black hole properties and formation of singularities', 'Dr. Rajesh Patel', 'Cambridge University'), (2, 'Dark Matter and Dark Energy', 'Investigating the nature of dark matter and dark energy', 'Dr. Sophia Rodriguez', 'Princeton University')) INSERT INTO Astrophysics_Research (ARid, Title, Description, Researcher_Name, University) SELECT * FROM new_research;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(100), Playtime FLOAT, PlayerCountry VARCHAR(50)); INSERT INTO Games (GameID, GameName, Playtime, PlayerCountry) VALUES (1, 'GameA', 12.5, 'USA'), (2, 'GameB', 15.6, 'Canada'), (3, 'GameC', 18.2, 'USA');
What is the average playtime of each game by players from the USA?
SELECT GameName, AVG(Playtime) as AvgPlaytime FROM Games WHERE PlayerCountry = 'USA' GROUP BY GameName;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (country VARCHAR(255), energy_type VARCHAR(255), project_count INT); INSERT INTO energy_storage (country, energy_type, project_count) VALUES ('United States', 'Batteries', 500), ('Canada', 'Batteries', 300), ('United States', 'Pumped Hydro', 700), ('Canada', 'Pumped Hydro', 400);
Find the number of energy storage projects in the United States and Canada for each energy type.
SELECT country, energy_type, SUM(project_count) FROM energy_storage WHERE country IN ('United States', 'Canada') GROUP BY country, energy_type;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (region VARCHAR(255), funding INT); INSERT INTO climate_communication VALUES ('Europe', 6000000); INSERT INTO climate_communication VALUES ('Asia', 8000000);
What is the combined funding for climate communication projects in Europe and Asia?
SELECT SUM(funding) FROM climate_communication WHERE region IN ('Europe', 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE startup_funding_3 (id INT, name TEXT, country TEXT, year INT, funding FLOAT); INSERT INTO startup_funding_3 (id, name, country, year, funding) VALUES (1, 'Startup1', 'Brazil', 2021, 800000.0), (2, 'Startup2', 'Brazil', 2020, 1000000.0);
Calculate the total funding received by biotech startups in Brazil for the current and previous year.
SELECT country, SUM(funding) AS total_funding, EXTRACT(YEAR FROM CURRENT_DATE) AS current_year, EXTRACT(YEAR FROM DATE_ADD(CURRENT_DATE, INTERVAL -1 YEAR)) AS previous_year FROM startup_funding_3 WHERE country = 'Brazil' AND (year = EXTRACT(YEAR FROM CURRENT_DATE) OR year = EXTRACT(YEAR FROM DATE_ADD(CURRENT_DATE, INTERVAL -1 YEAR))) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), is_vegan BOOLEAN, country VARCHAR(50), category VARCHAR(50));
What percentage of hair care products are vegan and sold in Canada?
SELECT (COUNT(products.product_id) * 100.0 / (SELECT COUNT(*) FROM products)) AS percentage FROM products WHERE products.category = 'Hair Care' AND products.is_vegan = TRUE AND products.country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (state VARCHAR(255), source_type VARCHAR(255), capacity INT); INSERT INTO energy_storage (state, source_type, capacity) VALUES ('California', 'Batteries', 4200), ('Texas', 'Batteries', 5000), ('California', 'Pumped Hydro', 12000);
Which state in the USA has the highest energy storage capacity?
SELECT state, MAX(capacity) FROM energy_storage GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy VARCHAR(50)); INSERT INTO investment_strategies (id, strategy) VALUES (1, 'Green energy'); INSERT INTO investment_strategies (id, strategy) VALUES (2, 'Water conservation'); INSERT INTO investment_strategies (id, strategy) VALUES (3, 'Sustainable agriculture');
Delete all records related to green energy strategies from the investment_strategies table.
DELETE FROM investment_strategies WHERE strategy = 'Green energy';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, budget INT, production_country VARCHAR(50)); INSERT INTO movies (id, title, release_year, budget, production_country) VALUES (1, 'Movie1', 2010, 7000000, 'Spain'), (2, 'Movie2', 2015, 3000000, 'France'), (3, 'Movie3', 2020, 8000000, 'Spain');
What is the total number of movies produced in Spain with a budget over $5 million?
SELECT COUNT(*) FROM movies WHERE production_country = 'Spain' AND budget > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE canada_sales (id INT, garment_size INT);INSERT INTO canada_sales (id, garment_size) VALUES (1, 10), (2, 12), (3, 8);
What is the minimum garment size sold to 'Canada'?
SELECT MIN(garment_size) FROM canada_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, country TEXT, industry TEXT, ethical_manufacturing BOOLEAN, product_type TEXT, production_volume INT); INSERT INTO companies (id, name, country, industry, ethical_manufacturing, product_type, production_volume) VALUES (1, 'DEF Corp', 'Germany', 'Manufacturing', TRUE, 'Bolt', 1000), (2, 'GHI Inc', 'France', 'Manufacturing', TRUE, 'Nut', 1200), (3, 'JKL Co', 'Italy', 'Manufacturing', FALSE, 'Washer', 1500);
Show the production volumes for all products made by companies with a focus on ethical manufacturing practices in Europe.
SELECT product_type, production_volume FROM companies WHERE ethical_manufacturing = TRUE AND country IN ('Germany', 'France', 'Italy');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Nationality VARCHAR(50), BirthDate DATE); INSERT INTO Artists VALUES (1, 'Claude Monet', 'French', '1840-11-14'); INSERT INTO Artists VALUES (2, 'Vincent van Gogh', 'Dutch', '1853-03-30'); CREATE TABLE Artwork (ArtworkID INT, Title VARCHAR(100), Type VARCHAR(50), Price FLOAT, ArtistID INT); INSERT INTO Artwork VALUES (1, 'Water Lilies', 'Painting', 3000000, 1); INSERT INTO Artwork VALUES (2, 'Starry Night', 'Painting', 2000000, 2); INSERT INTO Artwork VALUES (3, 'The Starry Night Over the Rhone', 'Painting', 1500000, 1);
What is the count of artwork by medium for artists born before 1900?
SELECT AR.Nationality, A.Type, COUNT(*) FROM Artwork A JOIN Artists AR ON A.ArtistID = AR.ArtistID WHERE YEAR(AR.BirthDate) < 1900 GROUP BY AR.Nationality, A.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name TEXT, menu_type TEXT, price DECIMAL, daily_sales INT, is_vegan BOOLEAN, region TEXT);
What is the total number of vegan menu items sold in the Southeast region?
SELECT SUM(daily_sales) FROM menu WHERE menu_type = 'vegan' AND region = 'Southeast';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSchools (id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(100), country VARCHAR(50)); INSERT INTO ArtSchools (id, name, city, country) VALUES (1, 'École des Beaux-Arts', 'Paris', 'France'); INSERT INTO ArtSchools (id, name, city, country) VALUES (2, 'Royal College of Art', 'London', 'United Kingdom'); INSERT INTO ArtSchools (id, name, city, country) VALUES (3, 'California College of the Arts', 'San Francisco', 'United States');
Which countries have more than 5 art schools?
SELECT country, COUNT(*) as art_school_count FROM ArtSchools GROUP BY country HAVING art_school_count > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (category VARCHAR(20), project_cost INT); INSERT INTO Projects (category, project_cost) VALUES ('Bridge', 5000000), ('Road', 3000000), ('Water Treatment', 6500000), ('Dams Safety', 7500000), ('Transit System', 9000000);
What is the average project cost for each category?
SELECT category, AVG(project_cost) FROM Projects GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Accessible_Tech (region VARCHAR(50), initiatives INT); INSERT INTO Accessible_Tech (region, initiatives) VALUES ('North America', 50), ('South America', 30), ('Europe', 70), ('Asia', 60), ('Africa', 40);
List the top 5 regions with the highest number of accessible technology initiatives?
SELECT Accessible_Tech.region, Accessible_Tech.initiatives FROM Accessible_Tech ORDER BY Accessible_Tech.initiatives DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, program VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, program, amount) VALUES (1, 'Animal Welfare', 500.00), (2, 'Education', 1000.00);
Which program had the highest total donation amount?
SELECT program FROM donations WHERE amount = (SELECT MAX(amount) FROM donations);
gretelai_synthetic_text_to_sql
CREATE TABLE LuxuryVehicles (id INT, make VARCHAR(50), model VARCHAR(50), safetyrating INT); CREATE TABLE VehicleSafety (id INT, vehicle_id INT, safetyrating INT, PRIMARY KEY (id), FOREIGN KEY (vehicle_id) REFERENCES LuxuryVehicles(id));
Find the number of luxury vehicles with a safety rating above 8 in the vehiclesafety schema.
SELECT COUNT(*) FROM vehicleSafety JOIN LuxuryVehicles ON vehicleSafety.vehicle_id = LuxuryVehicles.id WHERE safetyrating > 8;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, region VARCHAR(10), quantity INT); INSERT INTO production (element, year, region, quantity) VALUES ('Neodymium', 2015, 'Asia', 1200), ('Neodymium', 2016, 'Asia', 1400), ('Neodymium', 2017, 'Asia', 1500), ('Neodymium', 2018, 'Asia', 1600), ('Neodymium', 2019, 'Asia', 1800), ('Neodymium', 2020, 'Asia', 2000);
What is the average monthly production of Neodymium from 2015 to 2020 in the Asia region?
SELECT AVG(quantity) FROM production WHERE element = 'Neodymium' AND region = 'Asia' AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ImpressionismVisitors (id INT, museum_name VARCHAR(30), city VARCHAR(20), year INT, visitor_count INT); INSERT INTO ImpressionismVisitors (id, museum_name, city, year, visitor_count) VALUES (1, 'Metropolitan Museum', 'New York', 2020, 60000), (2, 'Louvre Museum', 'Paris', 2020, 75000), (3, 'National Gallery', 'London', 2020, 50000);
What is the total number of visitors for the 'Impressionism' exhibition across museums worldwide in 2020?
SELECT SUM(visitor_count) FROM ImpressionismVisitors WHERE exhibition_name = 'Impressionism' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerData (PlayerID INT, PlayerCountry VARCHAR(50), AvgHoursPlayed DECIMAL(5,2)); INSERT INTO PlayerData (PlayerID, PlayerCountry, AvgHoursPlayed) VALUES (1, 'USA', 15.5), (2, 'Canada', 12.7), (3, 'Mexico', 18.3), (4, 'Brazil', 20.0);
Calculate the average number of hours played by players using VR devices, per country, and rank them.
SELECT PlayerCountry, AvgHoursPlayed, RANK() OVER (ORDER BY AvgHoursPlayed DESC) AS Rank FROM PlayerData WHERE PlayerCountry IN (SELECT PlayerCountry FROM VRAdoption)
gretelai_synthetic_text_to_sql