context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE trees (id INT PRIMARY KEY, species VARCHAR(255), diameter FLOAT);
Update the species column for all entries in the trees table where the diameter is between 30 and 60 inches to 'Large Tree'
UPDATE trees SET species = 'Large Tree' WHERE diameter BETWEEN 30 AND 60;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, age INT, name VARCHAR(50)); INSERT INTO community_health_workers (worker_id, age, name) VALUES (1, 35, 'John Doe'); INSERT INTO community_health_workers (worker_id, age, name) VALUES (2, 45, 'Jane Smith');
What is the minimum age of community health workers in the health_equity schema?
SELECT MIN(age) FROM health_equity.community_health_workers;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (id INT, name VARCHAR(255), type VARCHAR(255), cost FLOAT); INSERT INTO missions (id, name, type, cost) VALUES (1, 'Hubble Servicing Mission 1', 'Servicing', 250000000.0), (2, 'Hubble Servicing Mission 2', 'Servicing', 400000000.0);
What is the total cost of all Hubble Space Telescope servicing missions?
SELECT SUM(cost) FROM missions WHERE type = 'Servicing' AND name LIKE '%Hubble%';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, application VARCHAR(255), severity FLOAT, discovered_at TIMESTAMP); INSERT INTO vulnerabilities (id, application, severity, discovered_at) VALUES (1, 'webapp1', 7.5, '2021-01-01 12:00:00'), (2, 'webapp2', 5.0, '2021-01-05 14:30:00');
What is the average severity of vulnerabilities for web applications in the last month?
SELECT AVG(severity) FROM vulnerabilities WHERE discovered_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH) AND application LIKE '%webapp%';
gretelai_synthetic_text_to_sql
CREATE TABLE FairLaborGarments (garment_id INT, factory_id INT); INSERT INTO FairLaborGarments (garment_id, factory_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 4); CREATE TABLE FairLaborFactories (factory_id INT, region VARCHAR(20)); INSERT INTO FairLaborFactories (factory_id, region) VALUES (1, 'South America'), (2, 'Europe'), (3, 'Asia'), (4, 'Africa');
What is the total number of garments produced using fair labor practices in South America?
SELECT COUNT(*) FROM FairLaborGarments INNER JOIN FairLaborFactories ON FairLaborGarments.factory_id = FairLaborFactories.factory_id WHERE FairLaborFactories.region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Country) VALUES (1, 'James Smith', 25, 'UK'); INSERT INTO Players (PlayerID, Name, Age, Country) VALUES (2, 'Emily Johnson', 30, 'Canada'); INSERT INTO Players (PlayerID, Name, Age, Country) VALUES (3, 'Oliver Brown', 22, 'UK'); CREATE TABLE VR_Games (GameID INT PRIMARY KEY, Name VARCHAR(50), Genre VARCHAR(50), Platform VARCHAR(50), PlayerID INT, Score INT); INSERT INTO VR_Games (GameID, Name, Genre, Platform, PlayerID, Score) VALUES (1, 'VR Game A', 'Action', 'Oculus', 1, 100); INSERT INTO VR_Games (GameID, Name, Genre, Platform, PlayerID, Score) VALUES (2, 'VR Game B', 'Adventure', 'HTC Vive', 2, 200); INSERT INTO VR_Games (GameID, Name, Genre, Platform, PlayerID, Score) VALUES (3, 'VR Game C', 'Simulation', 'Oculus', 3, 150);
What is the total score of players from the UK in VR games?
SELECT SUM(Score) FROM Players JOIN VR_Games ON Players.PlayerID = VR_Games.PlayerID WHERE Players.Country = 'UK' AND Platform = 'Oculus';
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, country VARCHAR(255), mineral VARCHAR(255), quantity INT, year INT); INSERT INTO mines (id, country, mineral, quantity, year) VALUES (1, 'Canada', 'Gold', 500, 2000), (2, 'Canada', 'Gold', 750, 2001), (3, 'Canada', 'Gold', 800, 2002);
What is the total quantity of gold mined in Canada by year?
SELECT year, SUM(quantity) FROM mines WHERE country = 'Canada' AND mineral = 'Gold' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Mammals (species VARCHAR(255), region VARCHAR(255), biomass FLOAT); INSERT INTO Mammals (species, region, biomass) VALUES ('Polar Bear', 'Arctic Ocean', 500), ('Reindeer', 'Greenland', 200), ('Polar Fox', 'Norway', 10), ('Musk Ox', 'Canada', 300), ('Walrus', 'Russia', 2000);
Delete a record for a given mammal in the Mammals table
DELETE FROM Mammals WHERE species = 'Polar Fox';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, name TEXT, job_title TEXT); INSERT INTO employees (employee_id, name, job_title) VALUES (1, 'Alice', 'HR Manager'), (2, 'Bob', 'Software Engineer'), (3, 'Charlie', 'Software Engineer'), (4, 'Dave', 'Sales Manager'), (5, 'Eve', 'Software Engineer');
What is the distribution of employees by job title?
SELECT job_title, COUNT(*) AS num_employees FROM employees GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorDemographics (DonorID INT, Age INT, Gender VARCHAR(10), Income DECIMAL(10,2), Education VARCHAR(50)); INSERT INTO DonorDemographics (DonorID, Age, Gender, Income, Education) VALUES (1, 35, 'Female', 80000.00, 'Master''s'); INSERT INTO DonorDemographics (DonorID, Age, Gender, Income, Education) VALUES (2, 42, 'Male', 100000.00, 'Doctorate'); INSERT INTO DonorDemographics (DonorID, Age, Gender, Income, Education) VALUES (3, 55, 'Female', 120000.00, 'Doctorate');
What is the total amount donated by female donors aged 50 or above?
SELECT SUM(Income) FROM DonorDemographics WHERE Gender = 'Female' AND Age >= 50;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name TEXT); INSERT INTO vessels VALUES (1, 'Vessel X'), (2, 'Vessel Y'), (3, 'Vessel Z'); CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports VALUES (7, 'Port of Long Beach', 'USA'), (8, 'Port of Tokyo', 'Japan'); CREATE TABLE shipments (shipment_id INT, vessel_id INT, port_id INT, cargo_tonnage INT, ship_date DATE); INSERT INTO shipments VALUES (1, 1, 8, 5000, '2021-01-01'), (2, 1, 7, 3000, '2021-02-01'), (3, 2, 8, 4000, '2021-03-01'), (4, 3, 8, 6000, '2021-04-01');
What is the total cargo tonnage exported from Japan to the Port of Long Beach in Q1 2021?
SELECT SUM(shipments.cargo_tonnage) FROM vessels JOIN shipments ON vessels.vessel_id = shipments.vessel_id JOIN ports ON shipments.port_id = ports.port_id WHERE ports.port_name = 'Port of Long Beach' AND ports.country = 'Japan' AND YEAR(shipments.ship_date) = 2021 AND QUARTER(shipments.ship_date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE UnitedDefense.NavalVesselSales (id INT, manufacturer VARCHAR(255), model VARCHAR(255), quantity INT, price DECIMAL(10,2), buyer_country VARCHAR(255), sale_date DATE);
What is the average price of naval vessels sold by UnitedDefense to the German government?
SELECT AVG(price) FROM UnitedDefense.NavalVesselSales WHERE buyer_country = 'Germany' AND manufacturer = 'UnitedDefense';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item_name VARCHAR(255), category VARCHAR(255), is_organic BOOLEAN); INSERT INTO inventory (id, item_name, category, is_organic) VALUES (1, 'Cotton Shirt', 'Tops', true), (2, 'Polyester Pants', 'Bottoms', false);
Delete all records of non-organic cotton items from the inventory.
DELETE FROM inventory WHERE is_organic = false;
gretelai_synthetic_text_to_sql
CREATE TABLE public.police_department (id SERIAL PRIMARY KEY, city VARCHAR(255), num_officers INTEGER); INSERT INTO public.police_department (city, num_officers) VALUES ('Chicago', 12000), ('New York', 35000), ('Los Angeles', 10000);
How many police officers are employed in the city of Chicago?
SELECT num_officers FROM public.police_department WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE Items (id INT, item_name VARCHAR(50), cost DECIMAL(5,2)); INSERT INTO Items VALUES (1, 'Organic Chicken', 3.50), (2, 'Tofu Stir Fry', 4.25), (3, 'Sweet Potato Fries', 1.75);
What is the total cost of 'Organic Chicken' and 'Tofu Stir Fry' dishes?
SELECT SUM(cost) FROM Items WHERE item_name IN ('Organic Chicken', 'Tofu Stir Fry');
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_name TEXT, game_category TEXT, game_purchase_price FLOAT); INSERT INTO games (game_id, game_name, game_category, game_purchase_price) VALUES (1, 'Game A', 'Role-playing', 49.99), (2, 'Game B', 'Action', 59.99), (3, 'Game C', 'Role-playing', 54.99), (4, 'Game D', 'Strategy', 39.99);
What is the average game purchase price for each game category?
SELECT game_category, AVG(game_purchase_price) as avg_price FROM games GROUP BY game_category;
gretelai_synthetic_text_to_sql
CREATE TABLE customers(id INT, region VARCHAR(10), compliant BOOLEAN);
How many mobile customers in the West region are in compliance with data privacy regulations?
SELECT COUNT(*) FROM customers WHERE customers.region = 'West' AND customers.compliant = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE exploit_attempts (id INT, product VARCHAR(50), ip VARCHAR(50));
What is the number of unique IP addresses that have attempted to exploit each software product's vulnerabilities, ordered by the count of unique IP addresses in descending order?
SELECT product, COUNT(DISTINCT ip) as num_unique_ips FROM exploit_attempts GROUP BY product ORDER BY num_unique_ips DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE silver_mine (site_id INT, country VARCHAR(50), num_employees INT, extraction_date DATE, quantity INT); INSERT INTO silver_mine (site_id, country, num_employees, extraction_date, quantity) VALUES (1, 'Australia', 40, '2015-01-02', 1000), (2, 'Australia', 35, '2014-12-31', 1500), (3, 'Australia', 60, '2016-03-04', 2000), (4, 'Australia', 50, '2015-06-10', 500);
What is the maximum quantity of silver extracted in a single day for mining sites in Australia, for sites having more than 30 employees?
SELECT country, MAX(quantity) as max_daily_silver FROM silver_mine WHERE num_employees > 30 AND country = 'Australia' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE parttime_workers (id INT, industry VARCHAR(20), salary FLOAT, union_member BOOLEAN); INSERT INTO parttime_workers (id, industry, salary, union_member) VALUES (1, 'healthcare', 30000.0, false), (2, 'healthcare', 32000.0, false), (3, 'manufacturing', 25000.0, false), (4, 'retail', 20000.0, false), (5, 'retail', 22000.0, true);
What is the minimum salary of part-time workers who are not union members in the 'manufacturing' industry?
SELECT MIN(salary) FROM parttime_workers WHERE industry = 'manufacturing' AND union_member = false;
gretelai_synthetic_text_to_sql
CREATE TABLE philanthropic_orgs ( id INT PRIMARY KEY, name VARCHAR(100), focus_area VARCHAR(100), headquarters VARCHAR(100), website VARCHAR(100));
Create a table named 'philanthropic_orgs'
CREATE TABLE philanthropic_orgs ( id INT PRIMARY KEY, name VARCHAR(100), focus_area VARCHAR(100), headquarters VARCHAR(100), website VARCHAR(100));
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyIncidents (incident_id INT, reported_by VARCHAR(255), incident_date DATE); INSERT INTO SafetyIncidents (incident_id, reported_by, incident_date) VALUES (1, 'Minority Group', '2021-10-01'), (2, 'LGBTQ+', '2021-11-01'), (3, 'Women in Tech', '2021-12-01');
How many AI safety incidents were reported by the underrepresented communities in Q4 2021?
SELECT COUNT(*) FROM SafetyIncidents WHERE reported_by IN ('Minority Group', 'LGBTQ+', 'Women in Tech') AND incident_date BETWEEN '2021-10-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID varchar(10), CargoWeight int, Region varchar(10)); INSERT INTO Vessels (VesselID, CargoWeight, Region) VALUES ('VesselA', 1000, 'Asia-Pacific'), ('VesselB', 1500, 'Caribbean'), ('VesselC', 1200, 'Atlantic');
What is the minimum cargo weight for vessels in the Caribbean?
SELECT MIN(CargoWeight) FROM Vessels WHERE Region = 'Caribbean';
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), GameID INT, EventDate DATE, PrizePool NUMERIC(18,2)); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (1, 'Fortnite World Cup', 1, '2019-07-26', 30000000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (2, 'Overwatch League Grand Finals', 2, '2018-07-28', 1500000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (3, 'League of Legends World Championship', 3, '2018-11-03', 24000000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (4, 'Dota 2 International', 4, '2018-08-20', 25500000);
How many esports events were held for each game in 2018, ranked by the number of events?
SELECT GameID, COUNT(*) as EventsIn2018, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM EsportsEvents WHERE EventDate BETWEEN '2018-01-01' AND '2018-12-31' GROUP BY GameID;
gretelai_synthetic_text_to_sql
CREATE TABLE blacklist (id INT, ip_address VARCHAR(50), blacklist_date DATE);
How many unique IP addresses have been blacklisted in the last week?
SELECT COUNT(DISTINCT ip_address) FROM blacklist WHERE blacklist_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (company_name VARCHAR(255), founder_country VARCHAR(50)); INSERT INTO company_founding (company_name, founder_country) VALUES ('Acme Inc', 'USA'), ('Beta Corp', 'Canada'), ('Charlie LLC', 'USA');
Identify the number of unique countries represented by founders
SELECT COUNT(DISTINCT founder_country) FROM company_founding;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(50), salary FLOAT, country VARCHAR(50), contribution_accessibility BOOLEAN); INSERT INTO developers (developer_id, name, salary, country, contribution_accessibility) VALUES (1, 'Alice', 75000.0, 'EU', true), (2, 'Bob', 80000.0, 'USA', false), (3, 'Charlie', 85000.0, 'EU', true);
What is the average salary of developers who have contributed to open-source projects focused on technology accessibility in the EU?
SELECT AVG(salary) FROM developers WHERE country = 'EU' AND contribution_accessibility = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), ProgramBudget DECIMAL(10,2)); INSERT INTO Programs (ProgramID, ProgramName, ProgramBudget) VALUES (1, 'Healthcare', 75000.00), (2, 'Housing', 60000.00), (3, 'Food Security', 45000.00);
Insert a new record for a program with ProgramID of 4 and ProgramName of 'Education and Literacy', and give it a ProgramBudget of $50,000.
INSERT INTO Programs (ProgramID, ProgramName, ProgramBudget) VALUES (4, 'Education and Literacy', 50000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE strains (id INT, name TEXT, dispensary_id INT); INSERT INTO dispensaries (id, name, state) VALUES (1, 'The Healing Center', 'Massachusetts'), (2, 'Remedy', 'Texas'); INSERT INTO strains (id, name, dispensary_id) VALUES (1, 'Jack Herer', 1), (2, 'Purple Kush', 1), (3, 'Green Crack', 2);
List the names of all dispensaries that have never sold a strain containing 'Kush' in its name.
SELECT d.name FROM dispensaries d WHERE d.id NOT IN (SELECT s.dispensary_id FROM strains s WHERE s.name LIKE '%Kush%');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, Name varchar(50), Age int, Country varchar(50)); INSERT INTO Donors (DonorID, Name, Age, Country) VALUES (1, 'John Doe', 30, 'USA'), (2, 'Jane Smith', 45, 'Canada'), (3, 'Pedro Martinez', 25, 'Mexico');
What is the name and age of the youngest donor from each country?
SELECT d1.Name, d1.Age, d1.Country FROM Donors d1 INNER JOIN (SELECT Country, MIN(Age) AS MinAge FROM Donors GROUP BY Country) d2 ON d1.Country = d2.Country AND d1.Age = d2.MinAge;
gretelai_synthetic_text_to_sql
CREATE TABLE fund_managers (manager_id INT, name VARCHAR(50), region VARCHAR(20), total_assets DECIMAL(10, 2)); CREATE TABLE managed_funds (fund_id INT, manager_id INT, total_assets DECIMAL(10, 2));
Find the total assets managed by each fund manager in the Western region, excluding those who manage less than $10 million.
SELECT fm.name, SUM(mf.total_assets) as total_assets_managed FROM fund_managers fm JOIN managed_funds mf ON fm.manager_id = mf.manager_id WHERE fm.region = 'Western' GROUP BY fm.name HAVING SUM(mf.total_assets) >= 10000000 ORDER BY total_assets_managed DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE europium_production (country VARCHAR(50), year INT, quantity INT); CREATE TABLE europium_market_trends (country VARCHAR(50), year INT, trend VARCHAR(50), value INT);
Find cross-table correlation between Europium production and market trends.
SELECT e.country, e.year, e.quantity, m.trend, m.value, CORR(e.quantity, m.value) AS correlation FROM europium_production e INNER JOIN europium_market_trends m ON e.country = m.country AND e.year = m.year GROUP BY e.country, e.year;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_services (service_id INT, subscription_fee FLOAT, one_time_fee FLOAT, state VARCHAR(20));
What are the top 3 broadband services with the highest revenue in the state of California, considering both subscription fees and one-time fees?
SELECT service_id, subscription_fee + one_time_fee as total_revenue FROM broadband_services WHERE state = 'California' GROUP BY service_id ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_trends (tech_id INT, tech_name TEXT, industry TEXT, description TEXT); INSERT INTO tech_trends (tech_id, tech_name, industry, description) VALUES (1, 'AI-powered chatbots', 'Hospitality', 'Automated customer service using AI technology'), (2, 'AI-powered housekeeping robots', 'Hospitality', 'Automated housekeeping using AI technology'), (3, 'Virtual Reality Tours', 'Real Estate', 'Virtual tours of properties using VR technology');
What are the unique AI trends mentioned in the tech_trends table for the hospitality industry?
SELECT DISTINCT tech_name FROM tech_trends WHERE industry = 'Hospitality';
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_response (response_id INT, ngo_id INT, disaster_id INT, funding DECIMAL(10,2), response_time INT); INSERT INTO disaster_response VALUES (1, 1, 1, 50000, 10); INSERT INTO disaster_response VALUES (2, 1, 2, 75000, 15); INSERT INTO disaster_response VALUES (3, 2, 3, 100000, 20); INSERT INTO disaster_response VALUES (4, 2, 4, 80000, 12);
What is the total amount of funding received by each organization for disaster response in Latin America, for the last 5 years, and the average response time?
SELECT ngo.name as organization, SUM(funding) as total_funding, AVG(response_time) as avg_response_time FROM disaster_response JOIN ngo ON disaster_response.ngo_id = ngo.ngo_id WHERE ngo.region = 'Latin America' AND disaster_response.response_time >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY ngo.name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_name VARCHAR(255), product_category VARCHAR(255), sale_date DATE, sales_amount DECIMAL(10, 2), country VARCHAR(255));
What is the monthly sales trend of cosmetic products in India, and which product categories have the highest and lowest sales?
SELECT DATE_TRUNC('month', sale_date) as month, product_category, AVG(sales_amount) as avg_sales FROM sales WHERE country = 'India' GROUP BY month, product_category ORDER BY month, avg_sales DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA agriculture; CREATE TABLE rice_farmers (farmer_id INT, rice_quantity INT); INSERT INTO rice_farmers (farmer_id, rice_quantity) VALUES (1, 800), (2, 900), (3, 700);
What is the average quantity of rice produced annually per farmer in the 'agriculture' schema?
SELECT AVG(rice_quantity) FROM agriculture.rice_farmers;
gretelai_synthetic_text_to_sql
CREATE TABLE Albums (album_id INT, release_year INT); INSERT INTO Albums (album_id, release_year) VALUES (1, 2010), (2, 2011), (3, 2012); CREATE TABLE Songs (song_id INT, album_id INT); INSERT INTO Songs (song_id, album_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3);
What is the total number of songs released per year?
SELECT release_year, COUNT(s.song_id) AS total_songs FROM Albums a JOIN Songs s ON a.album_id = s.album_id GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_awareness (id INT PRIMARY KEY, brand VARCHAR(255), region VARCHAR(255), score INT); INSERT INTO consumer_awareness (id, brand, region, score) VALUES (1, 'GreenFashions', 'Asia', 80), (2, 'GreenFashions', 'Europe', 85), (3, 'EcoFriendlyFashions', 'Asia', 75), (4, 'EcoFriendlyFashions', 'USA', 90); CREATE TABLE regions (id INT PRIMARY KEY, region VARCHAR(255)); INSERT INTO regions (id, region) VALUES (1, 'Asia'), (2, 'Europe'), (3, 'USA');
What is the average consumer awareness score for the ethical fashion brand 'GreenFashions' in the 'Asia' region, and how does it compare to the global average?
SELECT AVG(ca.score) as avg_score FROM consumer_awareness ca JOIN regions r ON ca.region = r.region WHERE ca.brand = 'GreenFashions' AND r.region = 'Asia'; SELECT AVG(score) as global_avg_score FROM consumer_awareness WHERE brand = 'GreenFashions';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_accidents (accident_date DATE, is_autonomous BOOLEAN);
What is the number of autonomous vehicle accidents per month?
SELECT DATE_TRUNC('month', accident_date) as month, COUNT(*) as num_accidents FROM autonomous_accidents WHERE is_autonomous = true GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Metrics (metric TEXT, year INTEGER, region TEXT); INSERT INTO Metrics (metric, year, region) VALUES ('Crop Yield', 2018, 'Himalayan'), ('Soil Fertility', 2019, 'Himalayan'), ('Irrigation Efficiency', 2020, 'Himalayan');
List the agricultural innovation metrics in the Himalayan region by year.
SELECT year, metric FROM Metrics WHERE region = 'Himalayan';
gretelai_synthetic_text_to_sql
CREATE TABLE transportation_modes (id INT, name VARCHAR(20)); CREATE TABLE electric_vehicles (id INT, mode_id INT, vehicle_count INT); CREATE TABLE conventional_vehicles (id INT, mode_id INT, vehicle_count INT); INSERT INTO transportation_modes (id, name) VALUES (1, 'Car'), (2, 'Truck'), (3, 'Bus'); INSERT INTO electric_vehicles (id, mode_id, vehicle_count) VALUES (1, 1, 1000), (2, 2, 500), (3, 3, 200); INSERT INTO conventional_vehicles (id, mode_id, vehicle_count) VALUES (4, 1, 3000), (5, 2, 2000), (6, 3, 1000);
What is the ratio of electric to conventional vehicles for each transportation mode?
SELECT tm.name, (SUM(ev.vehicle_count) / SUM(cv.vehicle_count)) AS ratio FROM transportation_modes tm JOIN electric_vehicles ev ON tm.id = ev.mode_id JOIN conventional_vehicles cv ON tm.id = cv.mode_id GROUP BY tm.name;
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_wellbeing (athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (2, 'Jane Smith', 28, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (3, 'Jim Brown', 30, 'Football'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (4, 'Lucy Davis', 22, 'Football'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (5, 'Mark Johnson', 20, 'Hockey'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (6, 'Sara Lee', 35, 'Tennis'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (7, 'Mike Johnson', 28, 'Tennis');
Create a view named 'top_athlete_sports' that displays the top 2 sports with the highest average age of athletes in the 'athlete_wellbeing' table
CREATE VIEW top_athlete_sports AS SELECT sport, AVG(age) as avg_age FROM athlete_wellbeing GROUP BY sport ORDER BY avg_age DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID int, CityName varchar(50)); CREATE TABLE GreenBuildings (BuildingID int, CityID int, FloorArea int, GreenBuilding int);
What is the total number of green buildings and their total floor area for each city?
SELECT Cities.CityName, GreenBuildings.GreenBuilding, COUNT(GreenBuildings.BuildingID) as TotalBuildings, SUM(GreenBuildings.FloorArea) as TotalFloorArea FROM Cities INNER JOIN GreenBuildings ON Cities.CityID = GreenBuildings.CityID GROUP BY Cities.CityName, GreenBuildings.GreenBuilding;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), is_cruelty_free BOOLEAN, region VARCHAR(50), sales INT); INSERT INTO products (product_id, product_name, is_cruelty_free, region, sales) VALUES (1, 'Lipstick', true, 'Canada', 500), (2, 'Mascara', false, 'Canada', 700), (3, 'Foundation', true, 'Canada', 800), (4, 'Eyeshadow', true, 'USA', 600), (5, 'Blush', false, 'Canada', 400);
What are the top 5 cruelty-free cosmetic products by sales in the Canadian region for 2021?
SELECT product_name, sales FROM products WHERE is_cruelty_free = true AND region = 'Canada' ORDER BY sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CityOfSustainability.GreenBuildings (id INT, price FLOAT); INSERT INTO CityOfSustainability.GreenBuildings (id, price) VALUES (1, 500000.0), (2, 700000.0);
What is the average property price for green-certified buildings in the CityOfSustainability schema?
SELECT AVG(price) FROM CityOfSustainability.GreenBuildings;
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (owner_id INT, property_id INT, name VARCHAR(255)); INSERT INTO co_ownership (owner_id, property_id, name) VALUES (1, 3, 'Alice Johnson'), (2, 3, 'Bob Smith'), (3, 4, 'Eva Brown');
List the co-owners and their respective properties in co_ownership table.
SELECT owner_id, name, property_id FROM co_ownership;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions(id INT, mission_name VARCHAR(50), leader_name VARCHAR(50), leader_country VARCHAR(50)); INSERT INTO space_missions VALUES(1, 'Mangalyaan', 'Kalpana Chawla', 'India'), (2, 'Aryabhata', 'Rakesh Sharma', 'India');
How many space missions were led by astronauts from India?
SELECT COUNT(*) FROM space_missions WHERE leader_country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, ota_id INT, date DATE, price FLOAT); CREATE TABLE otas (id INT, name TEXT, location TEXT); INSERT INTO bookings (id, ota_id, date, price) VALUES (1, 1, '2022-01-01', 200), (2, 2, '2022-01-02', 300), (3, 1, '2022-02-01', 400), (4, 3, '2022-02-02', 100), (5, 2, '2022-03-01', 500); INSERT INTO otas (id, name, location) VALUES (1, 'Expedia', 'USA'), (2, 'Booking.com', 'Netherlands'), (3, 'Agoda', 'Singapore');
What is the total revenue for online travel agencies in Asia?
SELECT SUM(price) FROM bookings INNER JOIN otas ON bookings.ota_id = otas.id WHERE otas.location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), depth FLOAT, region VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, depth, region) VALUES (1, 'Bermuda Park', 3000, 'Atlantic'); INSERT INTO marine_protected_areas (id, name, depth, region) VALUES (2, 'Azores Marine Park', 4000, 'Atlantic');
What is the maximum depth and corresponding marine protected area name in the Atlantic region?
SELECT name, depth FROM marine_protected_areas WHERE region = 'Atlantic' ORDER BY depth DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_cities (id INT, name VARCHAR(255), num_properties INT, total_area INT); INSERT INTO inclusive_cities (id, name, num_properties, total_area) VALUES (1, 'New York', 5000, 600000), (2, 'Los Angeles', 3000, 450000), (3, 'Chicago', 2500, 325000);
List the total number of properties and total area in square meters for each city in the 'inclusive_cities' table.
SELECT name, SUM(num_properties), SUM(total_area) FROM inclusive_cities GROUP BY name;
gretelai_synthetic_text_to_sql
INSERT INTO EndangeredLanguages (Language, NativeSpeakers, Name) VALUES ('Livonian', 2, 'Livonian Language'), ('Ona', 1, 'Ona Language'), ('Lemerig', 0, 'Lemerig Language'), ('Tsakhur', 5000, 'Tsakhur Language'), ('Ubykh', 1, 'Ubykh Language');
INSERT INTO EndangeredLanguages (Language, NativeSpeakers, Name) VALUES ('Livonian', 2, 'Livonian Language');
FROM EndangeredLanguages ORDER BY NativeSpeakers ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_trips (id INT PRIMARY KEY, trip_time TIMESTAMP, trip_duration INT);
Find the number of bike trips per hour for the month of January 2022
SELECT HOUR(trip_time) AS hour, COUNT(*) AS num_trips FROM bike_trips WHERE trip_time >= '2022-01-01 00:00:00' AND trip_time < '2022-02-01 00:00:00' GROUP BY hour;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (year INT, vehicle_type VARCHAR(10), vehicle_count INT); INSERT INTO sales VALUES (2018, 'electric', 1000), (2019, 'electric', 2000), (2020, 'electric', 3000), (2020, 'gasoline', 4000), (2021, 'electric', 4000);
What is the percentage of electric vehicles sold in '2020' and '2021' in the 'sales' table?
SELECT (COUNT(*) * 100.0 / (SELECT SUM(vehicle_count) FROM sales WHERE year IN (2020, 2021))) AS percentage FROM sales WHERE vehicle_type = 'electric' AND year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (HourID INT, VolunteerName TEXT, Region TEXT, HoursSpent DECIMAL, HourDate DATE); INSERT INTO VolunteerHours (HourID, VolunteerName, Region, HoursSpent, HourDate) VALUES (1, 'Isabella Nguyen', 'Chicago', 8.00, '2022-01-01'), (2, 'Ava Johnson', 'Chicago', 10.00, '2022-02-01');
What is the maximum number of volunteer hours spent in a single day in the Chicago region?
SELECT MAX(HoursSpent) FROM VolunteerHours WHERE Region = 'Chicago' GROUP BY HourDate;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (facility_id INT, location VARCHAR(255), health_equity_score INT); INSERT INTO mental_health_facilities (facility_id, location, health_equity_score) VALUES (1, 'Urban', 85), (2, 'Rural', 75), (3, 'Urban', 90), (4, 'Urban', 80), (5, 'Rural', 70), (6, 'Urban', 95);
What is the average health equity score for mental health facilities in urban areas?
SELECT AVG(health_equity_score) as avg_score FROM mental_health_facilities WHERE location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE fishing_vessels (id INT, vessel_name VARCHAR(50), caught_fish INT, ocean VARCHAR(50)); INSERT INTO fishing_vessels (id, vessel_name, caught_fish, ocean) VALUES (1, 'Vessel A', 5000, 'Indian Ocean'), (2, 'Vessel B', 7000, 'Indian Ocean'), (3, 'Vessel C', 3000, 'Atlantic Ocean');
Rank fishing vessels that caught the most fish in the Indian Ocean in descending order.
SELECT vessel_name, caught_fish, ROW_NUMBER() OVER (ORDER BY caught_fish DESC) as rank FROM fishing_vessels WHERE ocean = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_employees (id INT, employee_name VARCHAR(50), ethical_ai BOOLEAN);INSERT INTO ethical_ai_employees (id, employee_name, ethical_ai) VALUES (1, 'Jane Doe', true), (2, 'John Smith', false), (3, 'Alice Johnson', true);
What is the total number of employees working on ethical AI initiatives in the company?
SELECT COUNT(*) as total_employees FROM ethical_ai_employees WHERE ethical_ai = true;
gretelai_synthetic_text_to_sql
CREATE TABLE budget_allocation (year INT, state TEXT, category TEXT, amount FLOAT); INSERT INTO budget_allocation (year, state, category, amount) VALUES (2020, 'California', 'Transportation', 12000000), (2019, 'California', 'Transportation', 10000000), (2018, 'California', 'Transportation', 8000000);
What is the maximum budget allocated for transportation in the year 2019 in the state of "California"?
SELECT MAX(amount) FROM budget_allocation WHERE year = 2019 AND state = 'California' AND category = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (preference_id INT, consumer_id INT, product_id INT, shade VARCHAR(255)); INSERT INTO consumer_preferences (preference_id, consumer_id, product_id, shade) VALUES (1, 1, 1, 'Light Beige'), (2, 2, 1, 'Medium Beige'), (3, 3, 2, 'Dark Beige'), (4, 4, 3, 'Light Brown'), (5, 5, 3, 'Medium Brown');
What is the least preferred eyeshadow shade among consumers?
SELECT shade, COUNT(*) AS preference_count FROM consumer_preferences WHERE product_id = 1 GROUP BY shade ORDER BY preference_count ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W001', '2021-01-01', 150.5), ('W001', '2021-01-02', 160.3);
What is the total production of well 'W001' in the Oil_Production table?
SELECT SUM(quantity) FROM Oil_Production WHERE well = 'W001';
gretelai_synthetic_text_to_sql
CREATE TABLE project (project_id INT, name VARCHAR(50), location VARCHAR(50), spending FLOAT); CREATE TABLE continent (continent_id INT, name VARCHAR(50), description TEXT); CREATE TABLE location (location_id INT, name VARCHAR(50), continent_id INT);
What is the total spending on rural infrastructure projects in each continent?
SELECT c.name, SUM(p.spending) FROM project p JOIN location l ON p.location = l.name JOIN continent c ON l.continent_id = c.continent_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Germany'); CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-01-01 12:00:00'), (2, 1, '2022-01-02 14:00:00'), (3, 2, '2022-01-03 10:00:00'), (4, 2, '2022-01-04 16:00:00'), (5, 2, '2022-01-05 18:00:00');
How many users have posted more than 10 times in the last week from Germany?
SELECT COUNT(DISTINCT users.id) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE users.country = 'Germany' AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK) GROUP BY users.id HAVING COUNT(posts.id) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_count (id INT, subscriber_type VARCHAR(20), name VARCHAR(50)); INSERT INTO subscriber_count (id, subscriber_type, name) VALUES (1, 'Broadband', 'Jim Brown');
What is the total number of subscribers?
SELECT COUNT(*) FROM subscriber_count;
gretelai_synthetic_text_to_sql
CREATE TABLE InclusiveHousing (area TEXT, num_units INT, wheelchair_accessible BOOLEAN, pets_allowed BOOLEAN); INSERT INTO InclusiveHousing (area, num_units, wheelchair_accessible, pets_allowed) VALUES ('Eastside', 10, TRUE, FALSE), ('Westside', 15, TRUE, TRUE), ('Downtown', 20, TRUE, TRUE);
Update the number of units in the Downtown area of the InclusiveHousing table.
UPDATE InclusiveHousing SET num_units = 25 WHERE area = 'Downtown';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Africa'), (2, 'CompanyB', 'Europe'), (3, 'CompanyC', 'Asia-Pacific'); CREATE TABLE CircularEconomy (id INT, company_id INT, initiative VARCHAR(255)); INSERT INTO CircularEconomy (id, company_id, initiative) VALUES (1, 1, 'Recycling program'), (2, 1, 'Product repair services'), (3, 2, 'Recyclable packaging'), (4, 3, 'Product remanufacturing');
List all companies and their circular economy initiatives in the 'Africa' region.
SELECT Companies.name, GROUP_CONCAT(CircularEconomy.initiative) FROM Companies JOIN CircularEconomy ON Companies.id = CircularEconomy.company_id WHERE Companies.region = 'Africa' GROUP BY Companies.name;
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (id INT PRIMARY KEY, name VARCHAR(50), topic VARCHAR(50)); CREATE TABLE researchers (id INT PRIMARY KEY, name VARCHAR(50), project_id INT, FOREIGN KEY (project_id) REFERENCES research_projects(id)); CREATE TABLE leader_roles (id INT PRIMARY KEY, researcher_id INT, project_id INT, FOREIGN KEY (researcher_id) REFERENCES researchers(id), FOREIGN KEY (project_id) REFERENCES research_projects(id));
Identify research projects and their respective leaders, if any, working on climate change mitigation strategies.
SELECT research_projects.name, researchers.name FROM research_projects LEFT JOIN leaders_roles ON research_projects.id = leaders_roles.project_id LEFT JOIN researchers ON leaders_roles.researcher_id = researchers.id WHERE research_projects.topic LIKE '%climate change mitigation%';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryDonations (donor VARCHAR(255), recipient VARCHAR(255), equipment VARCHAR(255), donation_date DATE); INSERT INTO MilitaryDonations (donor, recipient, equipment, donation_date) VALUES ('USA', 'Kenya', 'tanks', '2011-04-02'); INSERT INTO MilitaryDonations (donor, recipient, equipment, donation_date) VALUES ('China', 'Nigeria', 'radars', '2015-08-17');
What is the total number of military equipment donated by the USA and China to African countries since 2010, ordered by the most recent donors?
SELECT SUM(equipment_count) as total_donations FROM (SELECT CASE WHEN donor IN ('USA', 'China') THEN donor END AS donor, COUNT(equipment) as equipment_count FROM MilitaryDonations WHERE recipient LIKE 'Africa%' AND donation_date >= '2010-01-01' GROUP BY donor, YEAR(donation_date), MONTH(donation_date), DAY(donation_date) ORDER BY MAX(donation_date)) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, price FLOAT); INSERT INTO virtual_tours (tour_id, tour_name, price) VALUES (1, 'Louvre Museum Tour', 12.50), (2, 'Eiffel Tower Tour', 10.00);
Update the price of the virtual tour of the Louvre Museum to 15 euros.
UPDATE virtual_tours SET price = 15.00 WHERE tour_name = 'Louvre Museum Tour';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, user_id INT, country VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, user_id, country, amount, donation_date) VALUES (1, 1001, 'USA', 50.00, '2021-01-05'); INSERT INTO Donations (id, user_id, country, amount, donation_date) VALUES (2, 1002, 'Canada', 75.00, '2021-01-10');
What was the total amount donated by users from the USA in Q1 2021?
SELECT SUM(amount) FROM Donations WHERE country = 'USA' AND donation_date >= '2021-01-01' AND donation_date < '2021-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255)); INSERT INTO farmers (farmer_id, name, age, location) VALUES (1, 'John Doe', 35, 'Springfield'); CREATE VIEW young_farmers AS SELECT * FROM farmers WHERE age < 30;
What is the average age of farmers in the view 'young_farmers'?
SELECT AVG(age) FROM young_farmers;
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections (restaurant_id INT, inspection_date DATE, violation_count INT);
Insert a new record in the food_safety_inspections table with a restaurant_id of 100, an inspection_date of '2023-01-19', and a violation_count of 2
INSERT INTO food_safety_inspections (restaurant_id, inspection_date, violation_count) VALUES (100, '2023-01-19', 2);
gretelai_synthetic_text_to_sql
CREATE TABLE ExhibitionAttendance (exhibition_id INT, country VARCHAR(20), visitor_count INT); INSERT INTO ExhibitionAttendance (exhibition_id, country, visitor_count) VALUES (1, 'India', 50), (2, 'India', 75), (3, 'India', 100), (4, 'Brazil', 120);
What is the minimum number of visitors for an exhibition in India?
SELECT MIN(visitor_count) FROM ExhibitionAttendance WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (id INT, warehouse_id VARCHAR(5), departure_date DATE); INSERT INTO routes VALUES (1, 'ASIA', '2021-10-01'), (2, 'ASIA-SIN', '2021-10-05'), (3, 'ASIA', '2021-10-10');
What is the earliest route departure date for warehouse 'ASIA-SIN'?
SELECT MIN(departure_date) FROM routes WHERE warehouse_id = (SELECT id FROM warehouses WHERE name = 'ASIA-SIN');
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID int, Age int, MembershipType varchar(10)); INSERT INTO Members (MemberID, Age, MembershipType) VALUES (1, 35, 'Gold'); CREATE TABLE Classes (ClassID int, ClassType varchar(10), MemberID int); INSERT INTO Classes (ClassID, ClassType, MemberID) VALUES (1, 'Cycling', 1);
What is the average age of members who have a gold membership and have used the cycling class more than 5 times in the last month?
SELECT AVG(Age) FROM Members m JOIN Classes c ON m.MemberID = c.MemberID WHERE m.MembershipType = 'Gold' AND c.ClassType = 'Cycling' GROUP BY m.MemberID HAVING COUNT(c.ClassID) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE student_attendance (student_id INT, event_id INT, attended BOOLEAN); INSERT INTO student_attendance (student_id, event_id, attended) VALUES (1, 1, true); CREATE TABLE students (id INT, name VARCHAR(255)); INSERT INTO students (id, name) VALUES (1, 'Jane Doe'); CREATE TABLE lifelong_learning_events (id INT, name VARCHAR(255)); INSERT INTO lifelong_learning_events (id, name) VALUES (1, 'Python Programming Workshop');
List the names of all students who have attended a lifelong learning event and the name of the event they attended.
SELECT students.name, lifelong_learning_events.name FROM student_attendance INNER JOIN students ON student_attendance.student_id = students.id INNER JOIN lifelong_learning_events ON student_attendance.event_id = lifelong_learning_events.id WHERE attended = true;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_w(item_id INT, item_type VARCHAR(10), quantity INT);CREATE TABLE warehouse_x(item_id INT, item_type VARCHAR(10), quantity INT);INSERT INTO warehouse_w(item_id, item_type, quantity) VALUES (1, 'K', 200), (2, 'L', 300), (3, 'K', 50), (4, 'L', 400);INSERT INTO warehouse_x(item_id, item_type, quantity) VALUES (1, 'K', 150), (2, 'L', 250), (3, 'K', 40), (4, 'L', 350);
What is the total quantity of items with type 'K' or type 'L' in warehouse W and warehouse X?
SELECT quantity FROM warehouse_w WHERE item_type IN ('K', 'L') UNION ALL SELECT quantity FROM warehouse_x WHERE item_type IN ('K', 'L');
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT, sector VARCHAR(20), location VARCHAR(20), amount DECIMAL(10,2), date DATE);
What is the difference in waste generation between the residential and commercial sectors in Sydney since 2020?
SELECT residential.location, residential.amount - commercial.amount FROM waste_generation AS residential INNER JOIN waste_generation AS commercial ON residential.location = commercial.location AND residential.date = commercial.date WHERE residential.sector = 'residential' AND commercial.sector = 'commercial' AND residential.date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (song_id INT, artist VARCHAR(50), country VARCHAR(50), date DATE, streams INT, revenue FLOAT);
Find the number of streams and revenue for songs by artist 'Taylor Swift' in the United States, grouped by month.
SELECT DATE_FORMAT(date, '%Y-%m') AS month, SUM(streams), SUM(revenue) FROM Streams WHERE artist = 'Taylor Swift' AND country = 'United States' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE LifePolicies (PolicyholderID int); CREATE TABLE Policyholders (PolicyholderID int, Age int); INSERT INTO LifePolicies (PolicyholderID) VALUES (1); INSERT INTO LifePolicies (PolicyholderID) VALUES (2); INSERT INTO Policyholders (PolicyholderID, Age) VALUES (1, 40); INSERT INTO Policyholders (PolicyholderID, Age) VALUES (2, 50);
What is the minimum age of policyholders who have a life insurance policy?
SELECT MIN(Age) FROM Policyholders INNER JOIN LifePolicies ON Policyholders.PolicyholderID = LifePolicies.PolicyholderID;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), rating FLOAT);
Update the rating of all lipsticks with the name 'Ruby Red' to 4.8.
UPDATE products SET rating = 4.8 WHERE name = 'Ruby Red' AND category = 'lipstick';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (Spacecraft_ID INT, Name VARCHAR(255), Manufacturer VARCHAR(255), Mass FLOAT);
Insert a new spacecraft 'Comet Cruiser' with a mass of 3000 kg manufactured by 'AstroTech'.
INSERT INTO Spacecrafts (Name, Manufacturer, Mass) VALUES ('Comet Cruiser', 'AstroTech', 3000);
gretelai_synthetic_text_to_sql
CREATE TABLE ArtCollection (id INT, name VARCHAR(50), country VARCHAR(50), year INT); CREATE TABLE MuseumAttendance (id INT, year INT, attendance INT);
Show the number of art pieces from each country and total museum attendance from the 'ArtCollection' and 'MuseumAttendance' tables, grouped by year.
SELECT year, country, COUNT(name) as art_pieces, SUM(attendance) as total_attendance FROM ArtCollection JOIN MuseumAttendance ON ArtCollection.year = MuseumAttendance.year GROUP BY year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_name TEXT, location TEXT, num_concerts INTEGER); INSERT INTO Artists (artist_name, location, num_concerts) VALUES ('Artist A', 'New York', 300), ('Artist B', 'New York', 400), ('Artist A', 'Los Angeles', 500);
What are the names of the artists who have performed in both New York and Los Angeles and the total number of concerts they have held in these two cities?
SELECT artist_name, SUM(num_concerts) as total_concerts FROM Artists WHERE location IN ('New York', 'Los Angeles') GROUP BY artist_name HAVING COUNT(DISTINCT location) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ads (ad_id INT, user_id INT, device_type TEXT, content TEXT, revenue DECIMAL(10,2), show_date DATE);
What is the total revenue generated from ads promoting plant-based diets, shown to users in Canada on mobile devices, in the last week?
SELECT SUM(revenue) FROM ads WHERE content LIKE '%plant-based diet%' AND country = 'Canada' AND device_type = 'mobile' AND show_date >= DATEADD(day, -7, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_operations (operation_id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE);
Insert a new record into the humanitarian_operations table for an operation named 'Medical Assistance in Africa' that started on '2022-06-01'
INSERT INTO humanitarian_operations (name, location, start_date, end_date) VALUES ('Medical Assistance in Africa', 'Africa', '2022-06-01', NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (FarmID int, FarmType varchar(20), Country varchar(50), Yield int); INSERT INTO Farm (FarmID, FarmType, Country, Yield) VALUES (1, 'Organic', 'USA', 150), (2, 'Conventional', 'Canada', 200), (3, 'Urban', 'Mexico', 100), (4, 'Organic', 'USA', 180), (5, 'Organic', 'Mexico', 120);
Find the number of farms in each country and the average yield for each country.
SELECT Country, COUNT(*) as NumFarms, AVG(Yield) as AvgYield FROM Farm GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE biodiversity (species_id INT, species_name TEXT, other_data TEXT);
How many unique species are registered in the 'biodiversity' table, and what are their names?
SELECT COUNT(DISTINCT species_name) as unique_species_count, species_name FROM biodiversity GROUP BY species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE analysts (analyst_id INT, name VARCHAR(50), start_date DATE); INSERT INTO analysts (analyst_id, name, start_date) VALUES (1, 'John Doe', '2020-01-01'); CREATE TABLE artifact_analysis (analysis_id INT, artifact_id INT, analyst_id INT, analysis_date DATE, weight DECIMAL(5,2));
What was the total weight of artifacts excavated per analyst each year?
SELECT a.name, EXTRACT(YEAR FROM aa.analysis_date) as analysis_year, SUM(aa.weight) as total_weight FROM analysts a JOIN artifact_analysis aa ON a.analyst_id = aa.analyst_id GROUP BY a.analyst_id, a.name, analysis_year ORDER BY analysis_year, total_weight DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (country VARCHAR(20), crop VARCHAR(20)); INSERT INTO crops VALUES ('Mexico', 'Corn'), ('Mexico', 'Beans'), ('Canada', 'Wheat'), ('Canada', 'Canola');
Identify the common crops grown in Mexico and Canada.
SELECT crop FROM crops WHERE country = 'Mexico' INTERSECT SELECT crop FROM crops WHERE country = 'Canada'
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(255), investment_amount DECIMAL(10,2), sector VARCHAR(255), country VARCHAR(255), project_start_date DATE); CREATE VIEW social_impact_projects AS SELECT * FROM projects WHERE sector IN ('Renewable Energy', 'Affordable Housing', 'Education', 'Healthcare');
What is the total investment amount in social impact projects for each quarter since Q1 2020?
SELECT QUARTER(project_start_date) AS quarter, SUM(investment_amount) FROM social_impact_projects GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (OperationID INT, OperationType VARCHAR(20), OperationCountry VARCHAR(30)); INSERT INTO IntelligenceOperations (OperationID, OperationType, OperationCountry) VALUES (1, 'Surveillance', 'USA'), (2, 'Infiltration', 'Russia'), (3, 'Surveillance', 'China');
What is the total number of intelligence operations and their types for each country?
SELECT OperationCountry, OperationType, COUNT(*) as Total FROM IntelligenceOperations GROUP BY OperationCountry, OperationType;
gretelai_synthetic_text_to_sql
CREATE TABLE ResidentialBuildings (id INT, state VARCHAR(20), energy_efficiency_score INT); INSERT INTO ResidentialBuildings (id, state, energy_efficiency_score) VALUES (1, 'California', 75), (2, 'California', 85), (3, 'California', 90);
What is the average energy efficiency score for residential buildings in the state of California, considering only buildings with a score above 80?
SELECT AVG(energy_efficiency_score) FROM ResidentialBuildings WHERE state = 'California' AND energy_efficiency_score > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (song_id INT, song_name TEXT, artist_name TEXT, plays INT);
What is the total number of plays for a specific song in the 'music_streaming' table?
SELECT SUM(plays) FROM music_streaming WHERE song_name = 'Work';
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (station_id INT, station_name VARCHAR(50), location VARCHAR(50), quantity INT); CREATE TABLE electric_vehicles (vehicle_id INT, model VARCHAR(20), manufacture VARCHAR(20), vehicle_type VARCHAR(20), state VARCHAR(20));
What is the total number of charging stations for electric vehicles in California and New York?
SELECT SUM(quantity) FROM charging_stations cs JOIN electric_vehicles ev ON cs.location = ev.state WHERE ev.state IN ('California', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), Gender VARCHAR(10), Nationality VARCHAR(20), BirthYear INT); INSERT INTO Artists (ArtistID, ArtistName, Gender, Nationality, BirthYear) VALUES (1, 'Kusama Yayoi', 'Female', 'Japanese', 1929); CREATE TABLE Artworks (ArtworkID INT, ArtistID INT, ArtworkName VARCHAR(50), ArtworkType VARCHAR(20), Size FLOAT); INSERT INTO Artworks (ArtworkID, ArtistID, ArtworkName, ArtworkType, Size) VALUES (1, 1, 'Pumpkin', 'Sculpture', 250.0);
Identify the number of sculptures created by female artists from Japan and their average size.
SELECT COUNT(Artworks.ArtworkID), AVG(Artworks.Size) FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID WHERE Artists.Gender = 'Female' AND Artists.Nationality = 'Japanese' AND Artworks.ArtworkType = 'Sculpture';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (employer_id INT, employer_name VARCHAR(255), num_veterans INT, city VARCHAR(255), state VARCHAR(255));
What is the average number of veterans employed by each employer, and what is the total number of veterans employed by all employers?
SELECT AVG(num_veterans) AS avg_veterans_per_employer, SUM(num_veterans) AS total_veterans FROM veteran_employment;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareBudget (state VARCHAR(20), year INT, program VARCHAR(30), budget INT); INSERT INTO HealthcareBudget (state, year, program, budget) VALUES ('New York', 2022, 'Primary Care', 1000000), ('New York', 2022, 'Mental Health', 2000000), ('New York', 2022, 'Preventive Care', 1500000);
What is the total budget allocated to healthcare programs in New York state in 2022?
SELECT SUM(budget) FROM HealthcareBudget WHERE state = 'New York' AND year = 2022 AND program LIKE 'Healthcare%';
gretelai_synthetic_text_to_sql
CREATE TABLE aircrafts (aircraft_id INT, model VARCHAR(50), region VARCHAR(50)); INSERT INTO aircrafts (aircraft_id, model, region) VALUES (1, 'Boeing 747', 'North America'), (2, 'Airbus A320', 'Europe'), (3, 'Boeing 737', 'Asia'); CREATE TABLE accidents (accident_id INT, aircraft_id INT, date DATE); INSERT INTO accidents (accident_id, aircraft_id) VALUES (1, 1), (2, 1), (3, 3), (4, 2), (5, 2);
Which aircraft has the most accidents in a specific region?
SELECT a.model, COUNT(*) as num_accidents FROM aircrafts a JOIN accidents b ON a.aircraft_id = b.aircraft_id WHERE a.region = 'North America' GROUP BY a.model ORDER BY num_accidents DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (call_id INT, did INT, response_time INT); INSERT INTO emergency_calls (call_id, did, response_time) VALUES (1, 1, 45), (2, 2, 62), (3, 3, 55);
Delete records of emergency calls with a response time greater than 60 minutes
DELETE FROM emergency_calls WHERE response_time > 60;
gretelai_synthetic_text_to_sql