context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE City_EV_Adoption (id INT, city VARCHAR(50), ev_adoption DECIMAL(5,2));
What is the minimum adoption rate of electric vehicles in each city?
SELECT city, MIN(ev_adoption) FROM City_EV_Adoption GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_installations (id INT, location TEXT, year INT, size FLOAT); INSERT INTO solar_installations (id, location, year, size) VALUES (1, 'SolarInstallation A', 2020, 1.2), (2, 'SolarInstallation B', 2019, 2.5);
How many solar installations were made in 'New York' in the year 2020?
SELECT COUNT(*) FROM solar_installations WHERE location LIKE '%New York%' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Movie (movie_id INT, title VARCHAR(50), budget DECIMAL(5,2), genre VARCHAR(20)); INSERT INTO Movie (movie_id, title, budget, genre) VALUES (1, 'Inception', 160.0, 'Sci-Fi'), (2, 'Titanic', 200.0, 'Romance'), (3, 'The Dark Knight', 185.0, 'Action'); CREATE VIEW Genre_Count AS SELECT genre, COUNT(*) as genre_count FROM Movie GROUP BY genre;
What are the top 3 genres with the highest average movie budget?
SELECT g.genre, AVG(m.budget) as avg_budget FROM Movie m JOIN Genre_Count g ON m.genre = g.genre GROUP BY g.genre ORDER BY avg_budget DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Mission_Stats (id INT, spacecraft_id INT, mission_name VARCHAR(100), mission_date DATE, commander_gender VARCHAR(10), total_missions INT); INSERT INTO Spacecraft_Mission_Stats (id, spacecraft_id, mission_name, mission_date, commander_gender, total_missions) VALUES (1, 1, 'Apollo 11', '1969-07-16', 'Male', 5);
Calculate the percentage of missions led by female commanders for each spacecraft.
SELECT spacecraft_id, ROUND(100.0 * SUM(CASE WHEN commander_gender = 'Female' THEN 1 ELSE 0 END) / NULLIF(SUM(total_missions), 0), 2) as female_commander_percentage FROM Spacecraft_Mission_Stats GROUP BY spacecraft_id
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (id INT, country VARCHAR(50), year INT, number_of_satellites INT, deployment_status VARCHAR(50));
List the number of successful and failed satellite deployments by 'China' in the last 10 years?
SELECT country, year, SUM(CASE WHEN deployment_status = 'successful' THEN 1 ELSE 0 END) AS successful_deployments, SUM(CASE WHEN deployment_status = 'failed' THEN 1 ELSE 0 END) AS failed_deployments FROM SatelliteDeployments WHERE country = 'China' AND year >= YEAR(DATEADD(year, -10, GETDATE())) GROUP BY country, year;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name VARCHAR(50), country VARCHAR(50), funding DECIMAL(10,2));INSERT INTO biotech.startups(id, name, country, funding) VALUES (1, 'StartupA', 'US', 1500000.00), (2, 'StartupB', 'Canada', 2000000.00), (3, 'StartupC', 'Mexico', 500000.00), (4, 'StartupD', 'US', 1000000.00), (5, 'StartupE', 'Brazil', 750000.00), (6, 'StartupF', 'Canada', 2500000.00);
Identify the top 3 countries with the highest number of biotech startups.
SELECT country, COUNT(*) num_startups FROM biotech.startups GROUP BY country ORDER BY num_startups DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, trans_date DATE, amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, trans_date, amount) VALUES (1, '2021-11-01', 50.00), (2, '2021-11-01', 100.00), (3, '2021-11-02', 200.00), (4, '2021-11-02', 300.00), (5, '2021-11-03', 500.00), (6, '2021-11-03', 600.00), (7, '2021-11-04', 700.00), (8, '2021-11-04', 800.00), (9, '2021-11-05', 900.00), (10, '2021-11-05', 1000.00), (11, '2021-11-06', 1100.00), (12, '2021-11-06', 1200.00), (13, '2021-11-07', 1300.00), (14, '2021-11-07', 1400.00);
What is the median transaction amount per day for the past week?
SELECT AVG(amount) AS median_trans FROM (SELECT trans_date, amount, ROW_NUMBER() OVER (PARTITION BY trans_date ORDER BY amount) rn, COUNT(*) OVER (PARTITION BY trans_date) cnt FROM transactions WHERE trans_date >= DATEADD(day, -7, CURRENT_DATE)) x WHERE rn IN ((cnt+1)/2, (cnt+2)/2);
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Gender VARCHAR(5), Region VARCHAR(50)); INSERT INTO Attorneys (AttorneyID, Gender, Region) VALUES (1, 'F', 'Northeast'), (2, 'M', 'Northeast'), (3, 'F', 'Midwest'), (4, 'M', 'Midwest'), (5, 'F', 'South'), (6, 'M', 'South'), (7, 'F', 'West'), (8, 'M', 'West');
How many cases were handled by female attorneys in each region?
SELECT A.Region, COUNT(*) AS Cases_Handled_By_Female_Attorneys FROM Attorneys A WHERE A.Gender = 'F' GROUP BY A.Region;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (project_name VARCHAR(255), type VARCHAR(100), capacity INT, location VARCHAR(100));
Create a table for storing climate mitigation projects and insert records for renewable energy projects
INSERT INTO climate_mitigation_projects (project_name, type, capacity, location) VALUES ('Solar Park A', 'Solar', 10000, 'Morocco'), ('Wind Farm B', 'Wind', 20000, 'Mexico'), ('Hydroelectric Plant C', 'Hydro', 15000, 'Brazil'), ('Geothermal Field D', 'Geothermal', 5000, 'Indonesia'), ('Tidal Energy E', 'Tidal', 8000, 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, gender VARCHAR(10), hours_per_week FLOAT); INSERT INTO volunteers (volunteer_id, gender, hours_per_week) VALUES (1, 'female', 5.0), (2, 'male', 8.0), (3, 'female', 3.0), (4, 'male', 4.0), (5, 'non-binary', 6.0);
What is the percentage of total volunteer hours contributed by female volunteers?
SELECT (SUM(CASE WHEN gender = 'female' THEN hours_per_week ELSE 0 END) / SUM(hours_per_week)) * 100 AS percentage FROM volunteers;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), category VARCHAR(20));CREATE TABLE media_ethics_ratings (id INT, rating INT, article_id INT);INSERT INTO news_articles (id, title, category) VALUES (1, 'Artificial Intelligence Advancements', 'technology');INSERT INTO media_ethics_ratings (id, rating, article_id) VALUES (1, 85, 1);
List all news articles and their corresponding media ethics ratings, if available, for the technology category.
SELECT news_articles.title, media_ethics_ratings.rating FROM news_articles LEFT JOIN media_ethics_ratings ON news_articles.id = media_ethics_ratings.article_id WHERE news_articles.category = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, region TEXT); INSERT INTO organizations (id, name, region) VALUES (1, 'Habitat for Humanity', 'Southwest'), (2, 'American Red Cross', 'Northeast');
Insert new records for 2 additional organizations in the 'Midwest' region.
INSERT INTO organizations (id, name, region) VALUES (3, 'Food Bank of Iowa', 'Midwest'), (4, 'Habitat for Humanity Chicago', 'Midwest');
gretelai_synthetic_text_to_sql
CREATE TABLE IncidentByApp (id INT, app VARCHAR(255), region VARCHAR(255), incident_count INT); INSERT INTO IncidentByApp (id, app, region, incident_count) VALUES (1, 'AI Writer', 'North America', 12), (2, 'AI Artist', 'Europe', 15), (3, 'AI Composer', 'Asia', 8), (4, 'AI Writer', 'South America', 5), (5, 'AI Artist', 'Africa', 2), (6, 'AI Composer', 'North America', 10), (7, 'AI Writer', 'Europe', 18), (8, 'AI Writer', 'Asia', 9), (9, 'AI Writer', 'Africa', 7);
What is the total number of algorithmic fairness incidents in each region for the AI Writer application?
SELECT region, SUM(incident_count) as total_incidents FROM IncidentByApp WHERE app = 'AI Writer' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Gender VARCHAR(10), Region VARCHAR(20), MembershipDate DATE); INSERT INTO Members (MemberID, Gender, Region, MembershipDate) VALUES (6, 'Non-binary', 'Northeast', '2020-07-01'); CREATE TABLE Classes (ClassID INT, ClassType VARCHAR(20), Duration INT, MemberID INT); INSERT INTO Classes (ClassID, ClassType, Duration, MemberID) VALUES (60, 'Pilates', 45, 6);
Identify the number of non-binary members in the Northeast who did not participate in any classes in the last week and their latest membership date.
SELECT Members.MemberID, Members.Gender, Members.Region, MAX(Members.MembershipDate) FROM Members LEFT JOIN Classes ON Members.MemberID = Classes.MemberID WHERE Members.Gender = 'Non-binary' AND Members.Region = 'Northeast' AND Classes.MemberID IS NULL AND Members.MembershipDate <= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY Members.MemberID;
gretelai_synthetic_text_to_sql
CREATE TABLE HabitatPreservation (year INT, region VARCHAR(20), acres INT, cost INT); INSERT INTO HabitatPreservation (year, region, acres, cost) VALUES (2018, 'North', 500, 15000), (2018, 'South', 700, 21000), (2018, 'East', 600, 18000), (2018, 'West', 800, 24000), (2019, 'North', 550, 15500), (2019, 'South', 750, 22000), (2019, 'East', 650, 18500), (2019, 'West', 850, 25000);
What was the average habitat preservation cost per acre for each region in 2018?
SELECT region, AVG(cost / acres) FROM HabitatPreservation WHERE year = 2018 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_plans (plan_id INT, plan_name VARCHAR(255), download_speed INT, upload_speed INT, price DECIMAL(5,2));
Delete a broadband plan from the 'broadband_plans' table
DELETE FROM broadband_plans WHERE plan_id = 3001;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, price FLOAT, city VARCHAR(20), sustainable_urbanism_rating INT); INSERT INTO properties (id, price, city, sustainable_urbanism_rating) VALUES (1, 950000, 'Denver', 9), (2, 800000, 'Denver', 8), (3, 700000, 'Denver', 7), (4, 1000000, 'Denver', 10), (5, 600000, 'Denver', 6);
What is the median property price for properties in the city of Denver with a sustainable urbanism rating above 8?
SELECT AVG(price) FROM (SELECT price FROM properties WHERE city = 'Denver' AND sustainable_urbanism_rating > 8 ORDER BY price LIMIT 2 OFFSET 1) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE production_cost_distribution (country VARCHAR(255), material VARCHAR(255), product VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO production_cost_distribution (country, material, product, cost) VALUES ('France', 'linen', 'shirt', 10.50); INSERT INTO production_cost_distribution (country, material, product, cost) VALUES ('France', 'linen', 'pants', 20.75);
What is the production cost distribution of linen products in France?
SELECT product, cost FROM production_cost_distribution WHERE country = 'France' AND material = 'linen' ORDER BY cost;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, Country TEXT, Amount DECIMAL(10,2)); INSERT INTO Donations VALUES (1, 1, 'Brazil', 200.00), (2, 2, 'Mexico', 300.00), (3, 3, 'Argentina', 100.00); CREATE TABLE Donors (DonorID INT, DonorName TEXT, Region TEXT); INSERT INTO Donors VALUES (1, 'John Smith', 'Latin America and Caribbean'), (2, 'Jane Doe', 'Latin America and Caribbean');
List the top 5 countries with the highest average donation amount in the Latin America and Caribbean region.
SELECT Country, AVG(Amount) as AvgDonation FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID WHERE Region = 'Latin America and Caribbean' GROUP BY Country ORDER BY AvgDonation DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (region VARCHAR(50), year INT, capacity FLOAT); INSERT INTO landfill_capacity (region, year, capacity) VALUES ('Africa', 2020, 15000), ('Asia', 2020, 35000);
What is the landfill capacity for Africa in the year 2020?
SELECT capacity FROM landfill_capacity WHERE region = 'Africa' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10, 2), cause_id INT); CREATE TABLE causes (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO causes (id, name, type) VALUES (1, 'Education', 'Social'), (2, 'Health', 'Social'), (3, 'Environment', 'Non-social'), (4, 'Animal Welfare', 'Non-social'); INSERT INTO donors (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Marie Johnson'), (4, 'James Brown'), (5, 'Sophie White'); INSERT INTO donations (id, donor_id, amount, cause_id) VALUES (1, 1, 500.00, 3), (2, 1, 300.00, 3), (3, 2, 250.00, 4), (4, 2, 400.00, 4), (5, 3, 100.00, 3), (6, 4, 700.00, 4), (7, 5, 1200.00, 3), (8, 1, 600.00, 4), (9, 2, 800.00, 3), (10, 2, 900.00, 3);
What is the total donation amount for each donor in each non-social cause category?
SELECT d.donor_id, c.type, SUM(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id GROUP BY d.donor_id, c.type HAVING c.type != 'Social';
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT, rating INT);
Insert new records for the TV shows released in 2023 with a rating above 8.5
INSERT INTO tv_shows (title, genre, budget, release_year, rating) VALUES ('Show10', 'Comedy', 12000000, 2023, 8.7), ('Show11', 'Drama', 14000000, 2023, 9), ('Show12', 'Action', 16000000, 2023, 8.6);
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_customers (id INT, name VARCHAR(255), subscription_date DATE, net_neutrality_compliance BOOLEAN, state VARCHAR(255)); INSERT INTO broadband_customers (id, name, subscription_date, net_neutrality_compliance, state) VALUES (1, 'ABC Corp', '2022-01-01', false, 'California'); INSERT INTO broadband_customers (id, name, subscription_date, net_neutrality_compliance, state) VALUES (2, 'XYZ Inc', '2022-02-15', true, 'California');
List all broadband customers who have not complied with net neutrality regulations in the state of California, sorted by their subscription date in descending order.
SELECT * FROM broadband_customers WHERE net_neutrality_compliance = false AND state = 'California' ORDER BY subscription_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), supplier_id INT, price DECIMAL(5,2)); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50)); INSERT INTO products (product_id, product_name, supplier_id, price) VALUES (1, 'T-Shirt', 1, 20.00), (2, 'Jeans', 2, 50.00), (3, 'Shoes', 3, 75.00), (4, 'Dress', 1, 30.00), (5, 'Bag', 2, 40.00); INSERT INTO suppliers (supplier_id, supplier_name) VALUES (1, 'GreenEarth'), (2, 'EcoBlue'), (3, 'CircularWear');
What is the average price of products per supplier?
SELECT suppliers.supplier_name, AVG(products.price) FROM suppliers INNER JOIN products ON suppliers.supplier_id = products.supplier_id GROUP BY suppliers.supplier_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Port (PortID INT, PortName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Port (PortID, PortName, Location) VALUES (1, 'New York', 'USA'); INSERT INTO Port (PortID, PortName, Location) VALUES (2, 'London', 'UK'); CREATE TABLE Weather (WeatherID INT, VoyageID INT, PortID INT, Temperature FLOAT, Date DATE); INSERT INTO Weather (WeatherID, VoyageID, PortID, Temperature, Date) VALUES (1, 1, 1, 20, '2022-01-01'); INSERT INTO Weather (WeatherID, VoyageID, PortID, Temperature, Date) VALUES (2, 2, 2, 15, '2022-01-02');
What is the average temperature for each port?
SELECT p.PortName, AVG(w.Temperature) as AvgTemperature FROM Port p JOIN Weather w ON p.PortID = w.PortID GROUP BY p.PortName;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (ID INT PRIMARY KEY, WasteType VARCHAR(50), Sector VARCHAR(50), City VARCHAR(50), Year INT, Quantity DECIMAL(10,2)); INSERT INTO WasteGeneration (ID, WasteType, Sector, City, Year, Quantity) VALUES (1, 'Municipal Solid Waste', 'Commercial', 'Seattle', 2021, 5000.50);
What is the total waste generated by commercial sectors in the city of Seattle in 2021?
SELECT SUM(Quantity) FROM WasteGeneration WHERE Sector = 'Commercial' AND City = 'Seattle' AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE MultiYearBudget (Quarter TEXT, Year INTEGER, Service TEXT, Amount INTEGER); INSERT INTO MultiYearBudget (Quarter, Year, Service, Amount) VALUES ('Q1 2022', 2022, 'Housing', 1000000), ('Q1 2022', 2022, 'Infrastructure', 1200000);
What is the total budget allocated for housing and infrastructure services in Q1 2022?
SELECT SUM(Amount) FROM MultiYearBudget WHERE Quarter = 'Q1 2022' AND Service IN ('Housing', 'Infrastructure');
gretelai_synthetic_text_to_sql
CREATE TABLE patent (id INT, title VARCHAR(255), country VARCHAR(255), date DATE); INSERT INTO patent (id, title, country, date) VALUES (1, 'Explainable AI System', 'USA', '2021-05-15'), (2, 'Interpretable AI Framework', 'Germany', '2020-08-23'), (3, 'Transparent AI Model', 'Canada', '2019-12-18');
Top 3 countries with the most Explainable AI patents granted?
SELECT country, COUNT(*) as num_patents, RANK() OVER (PARTITION BY 1 ORDER BY COUNT(*) DESC) as rank FROM patent GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT PRIMARY KEY, event_name VARCHAR(100), event_type VARCHAR(50), num_tickets_sold INT);
What is the maximum number of tickets sold for any event in the 'events' table?
SELECT MAX(num_tickets_sold) AS max_tickets_sold FROM events;
gretelai_synthetic_text_to_sql
CREATE TABLE approvals(year int, drug varchar(10)); INSERT INTO approvals(year, drug) VALUES('2010', 'DrugE'), ('2010', 'DrugF'), ('2015', 'DrugG');
Find the number of drugs approved in '2010' and '2015'?
SELECT COUNT(*) FROM approvals WHERE year IN (2010, 2015)
gretelai_synthetic_text_to_sql
CREATE TABLE workout_sessions (session_id INT, user_id INT, distance DECIMAL(10,2), session_date DATE); INSERT INTO workout_sessions (session_id, user_id, distance, session_date) VALUES (1, 1, 5.5, '2022-08-01'), (2, 2, 7.3, '2022-08-02'), (3, 3, 4.2, '2022-08-03'), (4, 4, 8.8, '2022-08-04');
Which users had a workout session with a distance of over 5 miles in the last month?
SELECT user_id FROM workout_sessions WHERE distance > 5 AND session_date >= DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE VIEW peacekeeping_view AS SELECT peacekeeping_operations.operation_name, peacekeeping_forces.force_name, peacekeeping_forces.strength FROM peacekeeping_operations INNER JOIN peacekeeping_forces ON peacekeeping_operations.operation_id = peacekeeping_forces.operation_id;
Describe the 'peacekeeping_view' view
DESCRIBE peacekeeping_view;
gretelai_synthetic_text_to_sql
CREATE TABLE network_devices (id INT, region VARCHAR(255), device_type VARCHAR(255));
How many network devices have been installed in each region?
SELECT region, COUNT(*) FROM network_devices GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE VIEW cultural_heritage AS SELECT * FROM historical_sites WHERE type = 'cultural_heritage';
Remove the cultural_heritage view
DROP VIEW cultural_heritage;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing (id INT, age INT, country VARCHAR(50), percentage DECIMAL(5,2)); INSERT INTO financial_wellbeing (id, age, country, percentage) VALUES (1, 18, 'USA', 60.5), (2, 25, 'USA', 65.2), (3, 35, 'USA', 72.1), (4, 45, 'USA', 75.6), (5, 55, 'USA', 78.2);
What is the financial wellbeing percentage for different age groups in the US?
SELECT age, percentage FROM financial_wellbeing WHERE country = 'USA' ORDER BY age;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, domain TEXT, members INT); INSERT INTO unions (id, name, domain, members) VALUES (1, 'National Association of Government Employees', 'Government, Defense', 200000); INSERT INTO unions (id, name, domain, members) VALUES (2, 'Service Employees International Union', 'Government, Healthcare', 300000);
How many unions focus on 'Government' and have between 100,000 and 500,000 members?
SELECT COUNT(*) FROM unions WHERE domain = 'Government' AND members BETWEEN 100000 AND 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (ArtworkID INT, ArtistID INT, SellingPrice DECIMAL); INSERT INTO Artwork (ArtworkID, ArtistID, SellingPrice) VALUES (1, 2, 200000), (2, 2, 300000);
What is the average selling price of artwork for each artist in Asia?
SELECT ArtistID, AVG(SellingPrice) as AvgSellingPrice FROM Artwork WHERE Continent = 'Asia' GROUP BY ArtistID;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), address VARCHAR(255));
Delete records from the 'dispensaries' table where the address is '456 Elm St'
DELETE FROM dispensaries WHERE address = '456 Elm St';
gretelai_synthetic_text_to_sql
CREATE TABLE ProductInventory (product_id INT, category VARCHAR(20), vegan BOOLEAN, country VARCHAR(20), sale_date DATE); INSERT INTO ProductInventory (product_id, category, vegan, country, sale_date) VALUES (1, 'skincare', true, 'US', '2022-04-05'), (2, 'skincare', false, 'CA', '2022-04-10'), (3, 'skincare', true, 'US', '2022-06-20');
How many vegan skincare products were sold in the US in Q2 2022?
SELECT COUNT(*) as q2_sales FROM ProductInventory WHERE category = 'skincare' AND vegan = true AND country = 'US' AND sale_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (ProjectID INT, Country VARCHAR(100), Investment DECIMAL(10,2), InvestmentDate DATE); INSERT INTO RuralInfrastructure VALUES (1,'China',500000,'2021-05-15'),(2,'India',400000,'2022-06-30'),(3,'Indonesia',300000,'2021-03-28'),(4,'Philippines',200000,'2022-07-20'),(5,'Vietnam',100000,'2022-04-22');
Calculate the average investment in rural infrastructure projects per country over the past year.
SELECT Country, AVG(Investment) AS AvgInvestment FROM RuralInfrastructure WHERE InvestmentDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_id INT, name VARCHAR(100), capacity INT, technology VARCHAR(50)); INSERT INTO renewable_energy_projects (project_id, name, capacity, technology) VALUES (1, 'Wind Farm', 600, 'Wind');
Which renewable energy projects have a capacity of over 500 MW?
SELECT name, capacity FROM renewable_energy_projects WHERE capacity > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, half INT, annual_production INT); INSERT INTO mines (id, name, location, half, annual_production) VALUES (1, 'Mine A', 'Country X', 1, 800), (2, 'Mine B', 'Country Y', 1, 900), (3, 'Mine C', 'Country Z', 1, 750), (1, 'Mine A', 'Country X', 2, 700), (2, 'Mine B', 'Country Y', 2, 1000), (3, 'Mine C', 'Country Z', 2, 850);
What was the minimum REE production per mine in H1 2021?
SELECT name, MIN(annual_production) as min_production FROM mines WHERE YEAR(timestamp) = 2021 AND half = 1 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (ID INT PRIMARY KEY, Name VARCHAR(50)); CREATE TABLE Workouts (ID INT PRIMARY KEY, UserID INT, Steps INT, Duration DECIMAL(10,2), Date DATE);
What is the total number of steps taken and the total duration of workouts for each user in the past week?
SELECT Users.Name, SUM(Workouts.Steps) AS TotalSteps, SUM(Workouts.Duration) AS TotalDuration FROM Users JOIN Workouts ON Users.ID = Workouts.UserID WHERE Workouts.Date >= DATEADD(week, -1, GETDATE()) GROUP BY Users.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'Technology', 72.5), (2, 'Healthcare', 80.3), (3, 'Technology', 76.2);
What's the average ESG score of companies in the technology sector?
SELECT AVG(ESG_score) FROM companies WHERE sector = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, product_category TEXT, is_vegan BOOLEAN);
How many vegan products are there in each product category?
SELECT products.product_category, COUNT(products.product_id) as num_vegan_products FROM products WHERE products.is_vegan = TRUE GROUP BY products.product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50)); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, cost DECIMAL(5,2)); INSERT INTO athletes (athlete_id, athlete_name) VALUES (1, 'AthleteA'), (2, 'AthleteB'); INSERT INTO wellbeing_programs (program_id, athlete_id, cost) VALUES (1, 1, 100.00), (2, 1, 50.00), (3, 2, 75.00);
Which athletes participate in wellbeing programs and their total cost?
SELECT athletes.athlete_name, SUM(wellbeing_programs.cost) as total_cost FROM athletes JOIN wellbeing_programs ON athletes.athlete_id = wellbeing_programs.athlete_id GROUP BY athletes.athlete_name;
gretelai_synthetic_text_to_sql
CREATE TABLE stablecoins (coin_id INT, coin_name VARCHAR(50), coin_symbol VARCHAR(10), circulating_supply DECIMAL(20,2)); CREATE TABLE coin_transactions (transaction_id INT, coin_id INT, sender_address VARCHAR(50), receiver_address VARCHAR(50), amount DECIMAL(10,2), timestamp TIMESTAMP);
What is the maximum, minimum, and average transaction value for stablecoins?
SELECT coin_name, MAX(amount) as max_transaction, MIN(amount) as min_transaction, AVG(amount) as avg_transaction FROM stablecoins s JOIN coin_transactions t ON s.coin_id = t.coin_id GROUP BY coin_name;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, fan_name VARCHAR(50), gender VARCHAR(50), division VARCHAR(50)); INSERT INTO fan_demographics (fan_id, fan_name, gender, division) VALUES (1, 'Jane Doe', 'Female', 'Pacific Division'), (2, 'John Smith', 'Male', 'Atlantic Division'), (3, 'Alice Johnson', 'Female', 'Pacific Division'), (4, 'Bob Brown', 'Male', 'Central Division'), (5, 'Charlie Davis', 'Non-binary', 'Pacific Division'), (6, 'Sara Connor', 'Female', 'Pacific Division'), (7, 'Michael Lee', 'Male', 'Pacific Division'), (8, 'David Kim', 'Male', 'Pacific Division'), (9, 'James White', 'Male', 'Pacific Division'), (10, 'Daniel Hernandez', 'Male', 'Pacific Division');
How many male fans are there in the 'Pacific Division'?
SELECT COUNT(*) FROM fan_demographics WHERE gender = 'Male' AND division = 'Pacific Division';
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_safety_violations (violation_id INT, region TEXT); INSERT INTO maritime_safety_violations (violation_id, region) VALUES (1, 'Atlantic'), (2, 'Pacific'), (3, 'Indian Ocean'); CREATE TABLE vessels_detained (violation_id INT, vessel_name TEXT); INSERT INTO vessels_detained (violation_id, vessel_name) VALUES (1, 'Vessel A'), (1, 'Vessel B'), (2, 'Vessel C');
How many vessels were detained due to maritime safety violations in the Pacific region?
SELECT COUNT(vessel_name) FROM vessels_detained INNER JOIN maritime_safety_violations ON vessels_detained.violation_id = maritime_safety_violations.violation_id WHERE maritime_safety_violations.region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product VARCHAR(255), sale_date DATE, revenue NUMERIC(10, 2), product_type VARCHAR(255), country VARCHAR(255)); INSERT INTO sales (product, sale_date, revenue, product_type, country) VALUES ('Shampoo', '2023-01-01', 50, 'Refillable', 'United Kingdom'), ('Conditioner', '2023-01-03', 75, 'Refillable', 'United Kingdom'), ('Body Wash', '2023-02-05', 60, 'Refillable', 'United Kingdom');
What is the total revenue for refillable beauty products in the United Kingdom in Q1 2023?
SELECT SUM(revenue) as total_revenue FROM sales WHERE sale_date BETWEEN '2023-01-01' AND '2023-03-31' AND product_type = 'Refillable' AND country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(50)); INSERT INTO countries (country_id, country_name) VALUES (1, 'USA'); INSERT INTO countries (country_id, country_name) VALUES (2, 'Canada'); INSERT INTO countries (country_id, country_name) VALUES (3, 'Mexico'); CREATE TABLE user_interactions (user_id INT, article_id INT, interaction_date DATE, country_id INT); INSERT INTO user_interactions (user_id, article_id, interaction_date, country_id) VALUES (1, 101, '2021-01-01', 1); INSERT INTO user_interactions (user_id, article_id, interaction_date, country_id) VALUES (2, 102, '2021-01-02', 2); INSERT INTO user_interactions (user_id, article_id, interaction_date, country_id) VALUES (3, 103, '2021-01-03', 1); INSERT INTO user_interactions (user_id, article_id, interaction_date, country_id) VALUES (4, 104, '2021-01-04', 3);
What are the top 3 countries with the highest number of user interactions?
SELECT countries.country_name, COUNT(user_interactions.interaction_id) AS num_of_interactions FROM countries INNER JOIN user_interactions ON countries.country_id = user_interactions.country_id GROUP BY countries.country_name ORDER BY num_of_interactions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_electricity (country VARCHAR(20), production FLOAT); INSERT INTO renewable_electricity (country, production) VALUES ('United States', 500.0), ('United States', 700.0), ('Canada', 300.0), ('Canada', 400.0);
What is the maximum and minimum electricity production from renewable sources in each country?
SELECT country, MAX(production) AS max_production, MIN(production) AS min_production FROM renewable_electricity GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE player_sessions (id INT, player_id INT, playtime INT, uses_vr BOOLEAN); INSERT INTO player_sessions (id, player_id, playtime, uses_vr) VALUES (1, 1, 120, true), (2, 2, 90, false), (3, 3, 150, true), (4, 4, 300, true), (5, 5, 60, false), (6, 6, 700, true);
What is the maximum playtime for a single session among players who use VR technology?
SELECT MAX(playtime) FROM player_sessions WHERE uses_vr = true;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, app_id INT, timestamp TIMESTAMP); INSERT INTO transactions (id, app_id, timestamp) VALUES (1, 1, '2022-01-01 10:00:00'), (2, 1, '2022-01-01 12:00:00'), (3, 2, '2022-01-01 14:00:00'), (4, 3, '2022-01-01 16:00:00');
What is the average number of transactions performed by decentralized application 'App3'?
SELECT AVG(*) FROM transactions WHERE app_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, course VARCHAR(20), hours INT); INSERT INTO teacher_pd (teacher_id, course, hours) VALUES (1, 'technology integration', 12), (2, 'classroom_management', 10), (3, 'technology integration', 15), (4, 'diversity_equity_inclusion', 20);
How many teachers have participated in professional development courses in total?
SELECT COUNT(DISTINCT teacher_id) FROM teacher_pd;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_test_results (id INT, vehicle_make VARCHAR, safety_test_outcome VARCHAR);
Find the number of safety test failures in the 'safety_test_results' table, grouped by 'vehicle_make'.
SELECT vehicle_make, COUNT(*) FILTER (WHERE safety_test_outcome = 'Failed') AS failures FROM safety_test_results GROUP BY vehicle_make;
gretelai_synthetic_text_to_sql
CREATE TABLE water_temperature (id INT, location VARCHAR(50), temperature FLOAT, measurement_date DATE); INSERT INTO water_temperature (id, location, temperature, measurement_date) VALUES (1, 'Indian Ocean', 29.5, '2012-01-01'); INSERT INTO water_temperature (id, location, temperature, measurement_date) VALUES (2, 'Indian Ocean', 30.0, '2013-07-15');
What is the maximum water temperature in the Indian Ocean during the last 10 years?
SELECT MAX(temperature) FROM water_temperature WHERE location = 'Indian Ocean' AND measurement_date BETWEEN '2011-01-01' AND '2021-12-31' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (company_name VARCHAR(255), founder_gender VARCHAR(10), founder_minority VARCHAR(10)); INSERT INTO company_founding VALUES ('Acme Inc', 'Female', 'Yes'); INSERT INTO company_founding VALUES ('Beta Corp', 'Male', 'No'); INSERT INTO company_founding VALUES ('Charlie LLC', 'Female', 'Yes'); INSERT INTO company_founding VALUES ('Delta Co', 'Male', 'No'); CREATE TABLE funding (company_name VARCHAR(255), funding_amount INT); INSERT INTO funding VALUES ('Acme Inc', 500000); INSERT INTO funding VALUES ('Beta Corp', 750000); INSERT INTO funding VALUES ('Charlie LLC', 300000); INSERT INTO funding VALUES ('Delta Co', 600000);
Find the average funding for companies with diverse founding teams
SELECT AVG(funding.funding_amount) FROM company_founding INNER JOIN funding ON company_founding.company_name = funding.company_name WHERE company_founding.founder_gender != 'Male' AND company_founding.founder_minority = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism_asia (year INT, num_businesses INT); INSERT INTO sustainable_tourism_asia (year, num_businesses) VALUES (2018, 1000), (2019, 1200), (2020, 800), (2021, 1500);
Show the number of sustainable tourism businesses in Asia by year.
SELECT year, num_businesses FROM sustainable_tourism_asia;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (Id INT, Manufacturer VARCHAR(20), Age INT); INSERT INTO Aircraft VALUES (1, 'Airbus', 15), (2, 'Boeing', 20), (3, 'Airbus', 12);
What is the average age of aircrafts by manufacturer?
SELECT Manufacturer, AVG(Age) as AvgAge FROM Aircraft GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_database (id INT, name VARCHAR(50), type VARCHAR(50), orbit_type VARCHAR(50), country VARCHAR(50), launch_date DATE);
Return the earliest launch date in the satellite_database table
SELECT MIN(launch_date) as earliest_launch_date FROM satellite_database;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, crime_type VARCHAR(20), location VARCHAR(20)); INSERT INTO crimes (id, crime_type, location) VALUES (1, 'Theft', 'Eastside'), (2, 'Vandalism', 'Eastside');
What is the most common type of crime committed in 'Eastside'?
SELECT crime_type, COUNT(*) AS num_crimes FROM crimes WHERE location = 'Eastside' GROUP BY crime_type ORDER BY num_crimes DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE articles_by_day (day DATE, category TEXT, article_count INT); INSERT INTO articles_by_day (day, category, article_count) VALUES ('2022-02-01', 'Science', 2), ('2022-02-02', 'News', 3), ('2022-02-01', 'Science', 1);
What is the number of articles published per day in the 'Science' category?
SELECT day, category, SUM(article_count) as total FROM articles_by_day WHERE category = 'Science' GROUP BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE Authors (id INT, name TEXT, country TEXT); INSERT INTO Authors (id, name, country) VALUES (1, 'Author 1', 'United States'), (2, 'Author 2', 'Canada'), (3, 'Author 3', 'United States');
Which countries have the most diverse set of authors?
SELECT country, COUNT(DISTINCT name) as unique_authors FROM Authors GROUP BY country ORDER BY unique_authors DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_initiatives (initiative_id INT, region VARCHAR(20), category VARCHAR(30), description TEXT); INSERT INTO smart_city_initiatives (initiative_id, region, category, description) VALUES (1, 'SA', 'Transportation', 'Bike-sharing in Buenos Aires'), (2, 'SA', 'Energy Efficiency', 'Smart lighting in Santiago'), (3, 'SA', 'Transportation', 'Bus rapid transit in Rio de Janeiro'), (4, 'SA', 'Waste Management', 'Recycling programs in Lima');
Find the number of smart city initiatives in South America, and the number of initiatives related to transportation and energy efficiency in alphabetical order.
SELECT category AS initiative, COUNT(*) AS num_initiatives FROM smart_city_initiatives WHERE region = 'SA' AND category IN ('Transportation', 'Energy Efficiency') GROUP BY initiative ORDER BY initiative;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, chain TEXT, city TEXT, revenue FLOAT);
What is the market share of the top 3 hotel chains in 'Berlin'?
SELECT chain, 100.0 * SUM(revenue) / NULLIF(SUM(revenue) OVER (PARTITION BY city), 0) as market_share FROM hotels WHERE city = 'Berlin' GROUP BY chain ORDER BY market_share DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, country TEXT, year_founded INT, rating TEXT); INSERT INTO organizations (id, name, country, year_founded, rating) VALUES (1, 'African Childrens Fund', 'Kenya', 2005, 'Excellent');
What are the total donation amounts for organizations based in 'Africa' that were founded before 2010?
SELECT SUM(donation_amount) FROM donations JOIN organizations ON donations.org_id = organizations.id WHERE organizations.country LIKE 'Africa%' AND organizations.year_founded < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, has_loan BOOLEAN); INSERT INTO clients (client_id, has_loan) VALUES (1, true), (2, false), (3, true), (4, true), (5, false); CREATE TABLE loans (loan_id INT, client_id INT, loan_date DATE); INSERT INTO loans (loan_id, client_id, loan_date) VALUES (1001, 1, '2021-02-01'), (1002, 3, '2021-05-01'), (1003, 4, '2022-03-01'), (1004, 5, '2021-09-01');
List clients who have not taken out a loan in the past year but have previously had one?
SELECT client_id FROM clients INNER JOIN loans ON clients.client_id = loans.client_id WHERE clients.has_loan = false AND loans.loan_date < DATE_SUB(NOW(), INTERVAL 1 YEAR) AND loans.client_id IN (SELECT client_id FROM loans GROUP BY client_id HAVING COUNT(client_id) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, LawDegreeDate DATE);
How many cases were handled by attorneys who graduated from law school between 2000 and 2010?
SELECT COUNT(*) FROM Attorneys WHERE YEAR(LawDegreeDate) BETWEEN 2000 AND 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_projects (region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO ai_projects (region, budget) VALUES ('Asia', 500000.00), ('North America', 700000.00), ('Europe', 600000.00);
What is the average budget for AI projects in Asia?
SELECT AVG(budget) as avg_budget FROM ai_projects WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_productivity (id INT, region VARCHAR(20), productivity FLOAT); INSERT INTO labor_productivity (id, region, productivity) VALUES (1, 'Asia-Pacific', 2.5), (2, 'Americas', 3.2), (3, 'Europe', 2.8);
What is the average labor productivity in the Americas?
SELECT AVG(productivity) FROM labor_productivity WHERE region = 'Americas';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(50), LastLogin DATETIME); INSERT INTO Players (PlayerID, Age, Gender, Location, LastLogin) VALUES (2, 30, 'Male', 'Chicago', '2021-06-02 10:15:00');
What is the average age of players in each location?
SELECT Location, AVG(Age) FROM Players GROUP BY Location;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (project_id INT, state VARCHAR(2), year INT, hours INT); INSERT INTO labor_hours (project_id, state, year, hours) VALUES (1, 'OH', 2017, 5000);
What is the maximum number of construction labor hours worked in a single project in Ohio in 2017?
SELECT MAX(hours) FROM labor_hours WHERE state = 'OH' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE ABC_transaction (transaction_hash VARCHAR(255), block_number INT, transaction_index INT, from_address VARCHAR(255), to_address VARCHAR(255), value DECIMAL(18,2), timestamp TIMESTAMP, miner VARCHAR(255));
Find the total value of transactions between two specific addresses (A and B) in the ABC blockchain.
SELECT SUM(value) AS total_value FROM ABC_transaction WHERE (from_address = 'A' AND to_address = 'B') OR (from_address = 'B' AND to_address = 'A');
gretelai_synthetic_text_to_sql
CREATE TABLE WaterConservationEfforts (id INT, state TEXT, reduction_percentage FLOAT);
Find the maximum water consumption reduction in 'WaterConservationEfforts' table for each state.
SELECT state, MAX(reduction_percentage) FROM WaterConservationEfforts GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (spacecraft_id INT, name VARCHAR(100), country VARCHAR(100), launch_date DATE); INSERT INTO spacecraft (spacecraft_id, name, country, launch_date) VALUES (1, 'Shenzhou 1', 'China', '1999-11-20'), (2, 'Shenzhou 2', 'China', '2001-01-10'), (3, 'Shenzhou 3', 'China', '2002-03-25');
How many spacecraft has China launched?
SELECT COUNT(*) FROM spacecraft WHERE country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(50), region VARCHAR(20), year INT); INSERT INTO peacekeeping_operations (id, operation_name, region, year) VALUES (1, 'Operation United Nations Assistance Mission in Afghanistan (UNAMA)', 'Asia', 2001), (2, 'Operation United Nations Mission in the Central African Republic and Chad (MINURCAT)', 'Africa', 2008), (3, 'Operation United Nations Stabilization Mission in Haiti (MINUSTAH)', 'Americas', 2004), (4, 'Operation United Nations Mission in South Sudan (UNMISS)', 'Africa', 2011), (5, 'Operation United Nations Multidimensional Integrated Stabilization Mission in Mali (MINUSMA)', 'Africa', 2013);
Show the number of peacekeeping operations per region and year
SELECT region, year, COUNT(*) as num_operations FROM peacekeeping_operations GROUP BY region, year;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), start_date DATE, end_date DATE);
Insert a new restorative justice program in the 'programs' table
INSERT INTO programs (id, name, location, type, start_date, end_date) VALUES (1, 'Restorative Circles', 'Oakland, CA', 'Restorative Justice', '2020-01-01', '2023-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255), media_literacy_score INT);
Get the average media literacy score for articles published in the 'articles' table.
SELECT AVG(media_literacy_score) AS avg_score FROM articles;
gretelai_synthetic_text_to_sql
CREATE TABLE captain(captain_id INT, name VARCHAR(255), years_of_experience INT, nationality VARCHAR(255));CREATE TABLE captain_vessel(captain_id INT, vessel_id INT);CREATE TABLE vessel(vessel_id INT, name VARCHAR(255));
Find captains with the most experience, their respective nationalities, and the number of vessels commanded
SELECT c.name AS captain_name, c.nationality, COUNT(cv.vessel_id) AS number_of_vessels FROM captain c JOIN captain_vessel cv ON c.captain_id = cv.captain_id JOIN vessel v ON cv.vessel_id = v.vessel_id GROUP BY c.captain_id ORDER BY number_of_vessels DESC, c.years_of_experience DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_trenches (name TEXT, depth FLOAT); INSERT INTO marine_trenches (name, depth) VALUES ('Mariana Trench', 36000); INSERT INTO marine_trenches (name, depth) VALUES ('Tonga Trench', 35000); INSERT INTO marine_trenches (name, depth) VALUES ('Kermadec Trench', 32000); INSERT INTO marine_trenches (name, depth) VALUES ('Sunda Trench', 31000);
What is the second-deepest marine trench?
SELECT name, depth FROM (SELECT name, depth, ROW_NUMBER() OVER (ORDER BY depth DESC) AS rn FROM marine_trenches) AS sub WHERE rn = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE crime_incidents (id INT, district VARCHAR(255), crime_type VARCHAR(255), reported_date DATE);
What is the total number of crime incidents reported in each district of Sydney, Australia in the last year?
SELECT district, COUNT(*) as total_incidents FROM crime_incidents WHERE reported_date BETWEEN '2020-01-01' AND '2021-12-31' GROUP BY district;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, clothing_id INT, revenue DECIMAL(5,2)); INSERT INTO Sales VALUES (1, 1, 100.00), (2, 2, 75.00), (3, 3, 125.00), (4, 4, 90.00), (5, 5, 80.00); CREATE TABLE Clothing (id INT, sustainable BOOLEAN); INSERT INTO Clothing VALUES (1, true), (2, false), (3, true), (4, true), (5, false);
What is the total revenue generated by sales of clothing made from sustainable materials?
SELECT SUM(sales.revenue) FROM Sales INNER JOIN Clothing ON Sales.clothing_id = Clothing.id WHERE Clothing.sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(50), Location VARCHAR(50), CarbonEmissions INT); INSERT INTO MiningOperations (OperationID, MineName, Location, CarbonEmissions) VALUES (1, 'Crystal Mine', 'Canada', 100), (2, 'Diamond Mine', 'Australia', 120), (3, 'Gold Mine', 'South Africa', 150);
What is the average carbon emission for mining operations in Australia?
SELECT AVG(CarbonEmissions) FROM MiningOperations WHERE Location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Fleets (id INT, name VARCHAR(255)); INSERT INTO Fleets (id, name) VALUES (1, 'Tankers'); CREATE TABLE VesselSpeeds (id INT, fleet_id INT, speed INT, speed_date DATE); INSERT INTO VesselSpeeds (id, fleet_id, speed, speed_date) VALUES (1, 1, 20, '2021-08-01'), (2, 1, 25, '2021-08-02');
Calculate the average speed for each vessel in the 'Tankers' fleet in the past week.
SELECT fleet_id, AVG(speed) as avg_speed FROM VesselSpeeds WHERE fleet_id = 1 AND speed_date >= DATEADD(week, -1, GETDATE()) GROUP BY fleet_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (ID INT, Manufacturer VARCHAR(255), SafetyRating FLOAT); INSERT INTO Vehicles (ID, Manufacturer, SafetyRating) VALUES (1, 'Hyundai', 4.6), (2, 'Kia', 4.4), (3, 'Genesis', 4.7);
What is the maximum safety rating for vehicles manufactured in South Korea?
SELECT MAX(SafetyRating) FROM Vehicles WHERE Manufacturer = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE fans (id INT, name VARCHAR(50), city VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO fans (id, name, city, age, gender) VALUES (1, 'Alice', 'Los Angeles', 25, 'Female'); INSERT INTO fans (id, name, city, age, gender) VALUES (2, 'Bob', 'New York', 30, 'Male');
What is the average age of male fans from Los Angeles?
SELECT AVG(age) FROM fans WHERE city = 'Los Angeles' AND gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port A', 'USA'), (2, 'Port B', 'Canada'), (3, 'Port C', 'USA'), (4, 'Port D', 'Mexico'), (5, 'Port E', 'Brazil'), (6, 'Port F', 'Chile'), (7, 'Port G', 'Argentina'), (8, 'Port H', 'Peru'), (9, 'Port I', 'Colombia');
Which country has the most ports in the ocean shipping database?
SELECT country, COUNT(*) as port_count FROM ports GROUP BY country ORDER BY port_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovation (id INT, country VARCHAR(50), budget DECIMAL(10,2), year INT); INSERT INTO MilitaryInnovation (id, country, budget, year) VALUES (1, 'Brazil', 3000000, 2018), (2, 'Argentina', 2000000, 2018), (3, 'Colombia', 1500000, 2018);
What is the minimum budget allocated for military innovation by countries in South America in 2018?
SELECT MIN(budget) FROM MilitaryInnovation WHERE country IN ('Brazil', 'Argentina', 'Colombia') AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (strategy_name VARCHAR(50), implementation_year INT); INSERT INTO cybersecurity_strategies (strategy_name, implementation_year) VALUES ('Firewall', 2018), ('Intrusion Detection System', 2019), ('Multi-Factor Authentication', 2020), ('Zero Trust', 2021), ('Encryption', 2017);
What is the minimum implementation year of cybersecurity strategies in the 'cybersecurity_strategies' table for each strategy?
SELECT strategy_name, MIN(implementation_year) as min_year FROM cybersecurity_strategies GROUP BY strategy_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Clothing (id INT, name VARCHAR(255), material VARCHAR(255), price DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO Clothing (id, name, material, price, country) VALUES (1, 'T-Shirt', 'Organic Cotton', 15.99, 'USA'); INSERT INTO Clothing (id, name, material, price, country) VALUES (2, 'Pants', 'Recycled Polyester', 34.99, 'Germany');
What is the average price of sustainable materials used in clothing production across all countries?
SELECT AVG(price) FROM Clothing WHERE material IN ('Organic Cotton', 'Recycled Polyester')
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups(id INT, company_name TEXT, location TEXT, funding_amount DECIMAL(10,2), quarter INT, year INT);
Insert new biotech startup data for Q3 2022.
INSERT INTO biotech_startups (id, company_name, location, funding_amount, quarter, year) VALUES (1, 'Genetech', 'Canada', 350000, 3, 2022), (2, 'BioSolutions', 'Mexico', 200000, 3, 2022), (3, 'LifeTech', 'Brazil', 400000, 3, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (OrganizationID INT, OrganizationName TEXT); INSERT INTO Organizations (OrganizationID, OrganizationName) VALUES (1, 'UNICEF'), (2, 'Greenpeace'), (3, 'Doctors Without Borders'); CREATE TABLE Donations (DonationID INT, OrganizationID INT, DonationAmount INT, DonationYear INT); INSERT INTO Donations (DonationID, OrganizationID, DonationAmount, DonationYear) VALUES (1, 1, 1000, 2018), (2, 2, 2000, 2018), (3, 3, 3000, 2018);
What is the total amount donated to each organization in 2018?
SELECT OrganizationName, SUM(DonationAmount) as TotalDonation FROM Organizations INNER JOIN Donations ON Organizations.OrganizationID = Donations.OrganizationID WHERE DonationYear = 2018 GROUP BY OrganizationName;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), diagnosis_date DATE); INSERT INTO patients (id, name, diagnosis_date) VALUES (1, 'Ella Johnson', '2022-02-15'); INSERT INTO patients (id, name, diagnosis_date) VALUES (2, 'Fiona Chen', '2022-03-20'); CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(50), date DATE); INSERT INTO diagnoses (id, patient_id, condition, date) VALUES (1, 1, 'Anxiety', '2022-01-15'); INSERT INTO diagnoses (id, patient_id, condition, date) VALUES (2, 2, 'Depression', '2022-02-25');
How many patients were diagnosed with a mental health condition per month, in 2022?
SELECT DATE_FORMAT(date, '%Y-%m') as Month, COUNT(DISTINCT patient_id) as num_patients FROM diagnoses GROUP BY Month ORDER BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, state VARCHAR(255), age INT, diabetes BOOLEAN); INSERT INTO patients (patient_id, state, age, diabetes) VALUES (1, 'TX', 55, TRUE), (2, 'TX', 45, FALSE), (3, 'NY', 60, TRUE);
What is the average age of patients with diabetes in Texas?
SELECT AVG(age) FROM patients WHERE state = 'TX' AND diabetes = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, department VARCHAR(50), manager VARCHAR(50));
Update the manager of an existing department in the "departments" table
UPDATE departments SET manager = 'Daniel Lee' WHERE department = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, conservation_status) VALUES (1, 'Blue Whale', 'Endangered'); CREATE TABLE oceanography (id INT, species_name VARCHAR(255), location VARCHAR(255)); INSERT INTO oceanography (id, species_name, location) VALUES (1, 'Tiger Shark', 'Atlantic Ocean');
List all marine species that are critically endangered or extinct in the oceanography table.
SELECT species_name FROM oceanography WHERE species_name IN (SELECT name FROM marine_species WHERE conservation_status IN ('Critically Endangered', 'Extinct'));
gretelai_synthetic_text_to_sql
CREATE TABLE electric_taxis (taxi_id INT, city VARCHAR(50)); CREATE VIEW electric_taxis_by_city AS SELECT city, COUNT(taxi_id) FROM electric_taxis GROUP BY city;
How many electric taxis are there in Berlin?
SELECT count FROM electric_taxis_by_city WHERE city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE textile_sourcing (id INT PRIMARY KEY, material VARCHAR(25), country VARCHAR(20), fair_trade BOOLEAN);
Create table for textile sourcing
CREATE TABLE textile_sourcing (id INT PRIMARY KEY, material VARCHAR(25), country VARCHAR(20), fair_trade BOOLEAN);
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand VARCHAR(20), sustainability VARCHAR(10)); INSERT INTO brands (brand, sustainability) VALUES ('Brand A', 'Yes'), ('Brand B', 'No'), ('Brand C', 'Yes'); INSERT INTO sales (item, brand, date) VALUES ('T-Shirt', 'Brand A', '2022-01-01'), ('Pants', 'Brand B', '2022-02-01'), ('Shirt', 'Brand C', '2022-03-01');
What percentage of sales come from sustainable fashion brands?
SELECT (COUNT(*) FILTER (WHERE sustainability = 'Yes')) * 100.0 / COUNT(*) FROM brands INNER JOIN sales ON brands.brand = sales.brand;
gretelai_synthetic_text_to_sql