context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE MovieData (id INT, title VARCHAR(100), budget FLOAT, marketing FLOAT);
Which movies had a production budget higher than the average marketing cost?
SELECT title FROM MovieData WHERE budget > (SELECT AVG(marketing) FROM MovieData);
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT PRIMARY KEY, team VARCHAR(50), opponent VARCHAR(50), date DATE, result VARCHAR(10));
get the number of games won by the basketball team
SELECT COUNT(*) FROM games WHERE team = 'Chicago Bulls' AND result = 'Win';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (maker TEXT, model TEXT, altitude INTEGER); INSERT INTO aircraft (maker, model, altitude) VALUES ('Boeing', '747', 35000), ('Boeing', '777', 37000), ('Airbus', 'A320', 33000), ('Airbus', 'A350', 35000);
What is the average altitude of Boeing and Airbus aircrafts?
SELECT AVG(altitude) FROM aircraft WHERE maker IN ('Boeing', 'Airbus');
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50), production_rate FLOAT); INSERT INTO wells (well_id, well_name, region, production_rate) VALUES (9, 'Well I', 'Baltic Sea', 5000), (10, 'Well J', 'North Sea', 6000), (11, 'Well K', 'Baltic Sea', 8000), (12, 'Well L', 'North Sea', 9000);
Find the average production rate of wells in the 'Baltic Sea' and the 'North Sea'.
SELECT AVG(production_rate) FROM wells WHERE region IN ('Baltic Sea', 'North Sea');
gretelai_synthetic_text_to_sql
CREATE TABLE grant (id INT, title VARCHAR(100)); CREATE TABLE publication (id INT, title VARCHAR(100), grant_id INT);
What are the research grant titles that do not have a corresponding publication?
SELECT g.title FROM grant g LEFT JOIN publication p ON g.title = p.title WHERE p.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Stadiums(id INT, name TEXT, location TEXT, sport TEXT, capacity INT); INSERT INTO Stadiums(id, name, location, sport, capacity) VALUES (1, 'Fenway Park', 'Boston', 'Baseball', 37755), (2, 'MetLife Stadium', 'East Rutherford', 'Football', 82500);
What is the average ticket price for football matches in the EastCoast region?
SELECT AVG(price) FROM TicketSales WHERE stadium_id IN (SELECT id FROM Stadiums WHERE location = 'EastCoast' AND sport = 'Football')
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, name VARCHAR(50), sector VARCHAR(50)); INSERT INTO teams (team_id, name, sector) VALUES (1, 'Tech4Good', 'technology for social good'); INSERT INTO teams (team_id, name, sector) VALUES (2, 'Equalize', 'digital divide'); INSERT INTO teams (team_id, name, sector) VALUES (3, 'Ethical AI', 'ethical AI');
Who are the developers working on projects in the 'technology for social good' sector?
SELECT developers.name FROM developers INNER JOIN teams ON developers.team_id = teams.team_id WHERE teams.sector = 'technology for social good';
gretelai_synthetic_text_to_sql
CREATE TABLE State (id INT, name VARCHAR(50), avg_income FLOAT); INSERT INTO State (id, name, avg_income) VALUES (1, 'StateA', 40000); INSERT INTO State (id, name, avg_income) VALUES (2, 'StateB', 45000); INSERT INTO State (id, name, avg_income) VALUES (3, 'StateC', 35000);
Who is the governor in the state with the lowest average income?
SELECT State.name, GovernmentEmployee.name FROM State INNER JOIN GovernmentEmployee ON State.name = GovernmentEmployee.state_name WHERE State.avg_income = (SELECT MIN(avg_income) FROM State);
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, location TEXT, founder_gender TEXT, funding_amount INT); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (1, 'Startup A', 'USA', 'female', 5000000); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (2, 'Startup B', 'Canada', 'female', 7000000);
Which country has the highest average funding amount for women-led startups?
SELECT location, AVG(funding_amount) as avg_funding FROM startups WHERE founder_gender = 'female' GROUP BY location ORDER BY avg_funding DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_plans (plan_name TEXT, data_allowance INT);
What is the minimum and maximum data allowance for broadband plans?
SELECT MIN(data_allowance), MAX(data_allowance) FROM broadband_plans;
gretelai_synthetic_text_to_sql
CREATE TABLE Attendees (id INT PRIMARY KEY, city VARCHAR(30), event VARCHAR(30), year INT); INSERT INTO Attendees (id, city, event, year) VALUES (1, 'New York', 'International Arts Festival', 2023); INSERT INTO Attendees (id, city, event, year) VALUES (2, 'Toronto', 'International Arts Festival', 2022);
How many unique cities are represented in the International Arts Festival in 2023?
SELECT COUNT(DISTINCT city) FROM Attendees WHERE event = 'International Arts Festival' AND year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, country VARCHAR(20)); INSERT INTO factories VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'USA'); CREATE TABLE countries (country_id INT, country VARCHAR(20)); INSERT INTO countries VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico');
How many factories are in each country?
SELECT f.country, COUNT(DISTINCT f.factory_id) FROM factories f INNER JOIN countries c ON f.country = c.country GROUP BY f.country;
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (id INT, name VARCHAR(50), country VARCHAR(50), partnership BOOLEAN);
How many local vendors have partnered with our virtual tourism platform in Latin America?
SELECT COUNT(*) FROM vendors WHERE vendors.partnership = TRUE AND vendors.country LIKE '%Latin America%';
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageDance (id INT, name VARCHAR(255), country VARCHAR(255), UNIQUE (id)); CREATE TABLE Events (id INT, name VARCHAR(255), heritage_dance_id INT, year INT, UNIQUE (id), FOREIGN KEY (heritage_dance_id) REFERENCES HeritageDance(id)); CREATE TABLE Attendance (id INT, event_id INT, attendees INT, UNIQUE (id), FOREIGN KEY (event_id) REFERENCES Events(id));
What are the names of heritage dance programs in Indonesia with more than 1 associated event in the last year and an average attendance greater than 25?
SELECT hd.name FROM HeritageDance hd JOIN Events e ON hd.id = e.heritage_dance_id JOIN Attendance a ON e.id = a.event_id WHERE hd.country = 'Indonesia' GROUP BY hd.name HAVING COUNT(DISTINCT e.id) > 1 AND AVG(a.attendees) > 25 AND e.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE blockchain (id INT, network VARCHAR(20), tx_type VARCHAR(20), contract_count INT); INSERT INTO blockchain (id, network, tx_type, contract_count) VALUES (1, 'solana', 'smart_contract', 4000);
What is the total number of smart contracts deployed on the 'solana' network?
SELECT SUM(contract_count) FROM blockchain WHERE network = 'solana' AND tx_type = 'smart_contract';
gretelai_synthetic_text_to_sql
CREATE TABLE Country (Code TEXT, Name TEXT, Continent TEXT); INSERT INTO Country (Code, Name, Continent) VALUES ('CN', 'China', 'Asia'), ('AU', 'Australia', 'Australia'), ('KR', 'South Korea', 'Asia'), ('IN', 'India', 'Asia'); CREATE TABLE ProductionYearly (Year INT, Country TEXT, Element TEXT, Quantity INT); INSERT INTO ProductionYearly (Year, Country, Element, Quantity) VALUES (2021, 'CN', 'Gadolinium', 2000), (2021, 'AU', 'Gadolinium', 1800), (2021, 'KR', 'Gadolinium', 1500), (2021, 'IN', 'Gadolinium', 1900);
Identify the top 3 countries with the highest total production of Gadolinium in 2021, and rank them.
SELECT Country, SUM(Quantity) AS TotalProduction FROM ProductionYearly WHERE Element = 'Gadolinium' AND Year = 2021 GROUP BY Country ORDER BY TotalProduction DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, player_id INT, game_date DATE);CREATE TABLE players (player_id INT, player_country VARCHAR(255));
What is the average number of matches won by players from the United States, for games that started in the last 30 days?
SELECT AVG(wins) FROM (SELECT COUNT(games.game_id) AS wins FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'United States' AND games.game_date >= (CURRENT_DATE - INTERVAL '30' DAY) GROUP BY games.player_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment (id INT, name VARCHAR(100), manufacturer_id INT, repair_time DECIMAL(10,2));CREATE TABLE Manufacturers (id INT, name VARCHAR(100)); INSERT INTO Equipment (id, name, manufacturer_id, repair_time) VALUES (1, 'Tank', 1, 10), (2, 'Fighter Jet', 2, 15), (3, 'Helicopter', 2, 20); INSERT INTO Manufacturers (id, name) VALUES (1, 'Boeing'), (2, 'Airbus');
What is the average time to repair military equipment, grouped by equipment type and manufacturer?
SELECT m.name AS manufacturer, e.name AS equipment_type, AVG(e.repair_time) AS avg_repair_time FROM Equipment e JOIN Manufacturers m ON e.manufacturer_id = m.id GROUP BY m.name, e.name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2)); CREATE TABLE broadband_plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2)); CREATE TABLE subscribers (id INT, name VARCHAR(255), plan_id INT, region VARCHAR(255)); CREATE TABLE regions (id INT, name VARCHAR(255));
What is the total revenue for mobile and broadband plans combined in each region?
SELECT regions.name AS region, SUM(mobile_plans.price + broadband_plans.price) FROM subscribers JOIN mobile_plans ON subscribers.plan_id = mobile_plans.id JOIN broadband_plans ON subscribers.plan_id = broadband_plans.id JOIN regions ON subscribers.region = regions.id GROUP BY regions.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), position VARCHAR(50), left_company BOOLEAN);
Count the number of employees who are still working
SELECT COUNT(*) FROM Employees WHERE left_company = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(50), category VARCHAR(50), made_from_recycled_materials BOOLEAN, region VARCHAR(50));
Identify the top 3 product categories with the highest percentage of products made from recycled materials, for each region.
SELECT region, category, 100.0 * COUNT(*) / SUM(COUNT(*)) OVER (PARTITION BY region) as percentage FROM products WHERE made_from_recycled_materials = TRUE GROUP BY region, category ORDER BY region, percentage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_water_usage (state TEXT, year INT, month INT, water_usage FLOAT); INSERT INTO monthly_water_usage (state, year, month, water_usage) VALUES ('CA', 2020, 1, 500000), ('TX', 2020, 1, 700000), ('FL', 2020, 1, 300000), ('CA', 2020, 2, 550000), ('TX', 2020, 2, 750000), ('FL', 2020, 2, 350000);
Show the monthly water consumption trend for the top 3 water consumers.
SELECT state, EXTRACT(MONTH FROM DATE '2020-01-01' + INTERVAL month MONTH) AS month, AVG(water_usage) AS avg_usage FROM monthly_water_usage WHERE state IN (SELECT state FROM monthly_water_usage GROUP BY state ORDER BY SUM(water_usage) DESC LIMIT 3) GROUP BY state, month ORDER BY state, month;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policy_type VARCHAR(10), state VARCHAR(2)); INSERT INTO policies (id, policy_type, state) VALUES (1, 'car', 'NY'), (2, 'home', 'CA'), (3, 'car', 'TX');
How many car insurance policies were sold in 'TX'?
SELECT COUNT(*) FROM policies WHERE policy_type = 'car' AND state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE sales(product_name TEXT, is_vegan BOOLEAN, sale_date DATE); INSERT INTO sales VALUES ('Cleanser', true, '2022-03-01'); INSERT INTO sales VALUES ('Toner', false, '2022-03-05'); INSERT INTO sales VALUES ('Moisturizer', true, '2022-03-07');
How many sales of vegan skincare products were made in the last month in the UK?
SELECT COUNT(*) FROM sales WHERE is_vegan = true AND sale_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW() AND country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, VRHeadset VARCHAR(20)); INSERT INTO EsportsEvents (EventID, VRHeadset) VALUES (1, 'Oculus Rift');
Which virtual reality headset is most commonly used in esports events?
SELECT VRHeadset, COUNT(*) FROM EsportsEvents GROUP BY VRHeadset ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (meal VARCHAR(255), diet VARCHAR(255)); INSERT INTO menu (meal, diet) VALUES ('Spaghetti Bolognese', 'Non-vegetarian'), ('Vegetable Stir Fry', 'Vegetarian'), ('Grilled Chicken Salad', 'Non-vegetarian'), ('Tofu Scramble', 'Vegan');
What is the total number of 'vegan' and 'vegetarian' meals in the 'menu' table?
SELECT COUNT(*) as total_vegan_vegetarian_meals FROM menu WHERE diet IN ('Vegan', 'Vegetarian');
gretelai_synthetic_text_to_sql
CREATE TABLE railroads (id INT, country VARCHAR(255), total_length FLOAT); INSERT INTO railroads (id, country, total_length) VALUES (1, 'Canada', 48000), (2, 'United States', 246000);
What is the total length of all railroads in Canada and the United States?
SELECT SUM(total_length) FROM railroads WHERE country IN ('Canada', 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets (id INT, name VARCHAR(255), discovery_date DATE, discovery_method VARCHAR(255));
How many exoplanets have been discovered using the transit method?
SELECT COUNT(*) FROM exoplanets WHERE exoplanets.discovery_method = 'Transit';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_health (id INT, facility_name VARCHAR(255), country VARCHAR(255), sector VARCHAR(255));
Insert new records into the 'rural_health' table for a new health center in Bangladesh
INSERT INTO rural_health (id, facility_name, country, sector) VALUES (1, 'Health Center', 'Bangladesh', 'Health');
gretelai_synthetic_text_to_sql
CREATE TABLE Astronaut_Medical_Data (id INT, astronaut_name VARCHAR(50), nationality VARCHAR(50), data_size INT); INSERT INTO Astronaut_Medical_Data (id, astronaut_name, nationality, data_size) VALUES (1, 'Taylor Wang', 'China', 1000);
What is the average medical data record size for Chinese astronauts?
SELECT AVG(data_size) FROM Astronaut_Medical_Data WHERE nationality = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE states (state_id INT, state VARCHAR(255)); CREATE TABLE energy_efficiency (efficiency_id INT, state VARCHAR(255), region_id INT, energy_efficiency_score INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'West'); INSERT INTO states (state_id, state) VALUES (1, 'California'); INSERT INTO energy_efficiency (efficiency_id, state, region_id, energy_efficiency_score) VALUES (1, 'California', 1, 90);
What are the energy efficiency stats for each state and region?
SELECT s.state, r.region_name, ee.energy_efficiency_score FROM states s INNER JOIN energy_efficiency ee ON s.state = ee.state INNER JOIN regions r ON ee.region_id = r.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (Year INT, Country VARCHAR(50), Operations INT); INSERT INTO PeacekeepingOperations (Year, Country, Operations) VALUES (2015, 'France', 12), (2015, 'Germany', 16), (2016, 'France', 14), (2016, 'Germany', 17);
What is the percentage of peacekeeping operations led by countries in the European Union between 2015 and 2020?
SELECT Country, SUM(Operations) as Total_Operations, SUM(Operations)/(SELECT SUM(Operations) FROM PeacekeepingOperations WHERE Year BETWEEN 2015 AND 2020 AND Country IN ('France', 'Germany', 'Italy', 'Poland', 'Spain'))*100 as EU_Percentage FROM PeacekeepingOperations WHERE Year BETWEEN 2015 AND 2020 AND Country IN ('France', 'Germany', 'Italy', 'Poland', 'Spain') GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE education_projects (funding_agency VARCHAR(255), country VARCHAR(255), project_type VARCHAR(255), year INT);
List the number of education projects funded by Oxfam in each country in 2013.
SELECT country, COUNT(*) FROM education_projects WHERE funding_agency = 'Oxfam' AND project_type = 'education' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(255), role VARCHAR(255), followers INT, created_at TIMESTAMP, category VARCHAR(255));
Who are the top 10 users with the most followers in the "beauty" category as of January 1, 2023?
SELECT username FROM users WHERE category = 'beauty' ORDER BY followers DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech (code INT, name VARCHAR(50), type VARCHAR(50), manufacturer VARCHAR(50), last_updated TIMESTAMP); CREATE TABLE cybersecurity (strategy_id INT, strategy_name VARCHAR(50), description TEXT, last_updated TIMESTAMP); CREATE TABLE intelligence_ops (operation_id INT, name VARCHAR(50), description TEXT, start_date DATE, end_date DATE, last_updated TIMESTAMP);
What is the total number of military technologies, cybersecurity strategies, and intelligence operations in the 'military_tech', 'cybersecurity', and 'intelligence_ops' tables?
SELECT COUNT(*) FROM military_tech; SELECT COUNT(*) FROM cybersecurity; SELECT COUNT(*) FROM intelligence_ops;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjects (id INT, state VARCHAR(50), carbon_offsets INT); INSERT INTO RenewableEnergyProjects (id, state, carbon_offsets) VALUES (1, 'California', 10000), (2, 'Texas', 15000), (3, 'California', 12000);
What is the total carbon offset of renewable energy projects in the state of California?
SELECT SUM(carbon_offsets) as total_carbon_offsets FROM RenewableEnergyProjects WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE instrument_makers (id INT PRIMARY KEY, name TEXT, instrument TEXT, country TEXT);
Who are the traditional instrument makers in Senegal?
SELECT name FROM instrument_makers WHERE country = 'Senegal';
gretelai_synthetic_text_to_sql
CREATE TABLE CoOwnership (id INT, state VARCHAR(20), year INT, size INT, agreement TEXT);
List all co-ownership agreements in the state of New York from 2015 that have a size greater than 2000 square feet.
SELECT agreement FROM CoOwnership WHERE state = 'New York' AND year = 2015 AND size > 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'Marketing', 50000.00), (2, 'Jane Smith', 'Marketing', 55000.00), (3, 'Mike Johnson', 'IT', 60000.00);
What is the average salary of employees working in the marketing department?
SELECT AVG(salary) FROM employees WHERE department = 'Marketing';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), institution_id INT, mental_health_score INT); INSERT INTO students (id, name, institution_id, mental_health_score) VALUES (1, 'Jane Smith', 1, 80), (2, 'Jim Brown', 2, 70), (3, 'Ava Johnson', 1, 85), (4, 'Ben Wilson', 2, 75); CREATE TABLE institutions (id INT, name VARCHAR(50), type VARCHAR(20)) INSERT INTO institutions (id, name, type) VALUES (1, 'Uni A', 'Public'), (2, 'College B', 'Private');
What is the average mental health score for students in each institution?
SELECT i.name AS institution, AVG(s.mental_health_score) AS avg_score FROM students s JOIN institutions i ON s.institution_id = i.id GROUP BY i.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Rovers (RoverID INT, Name VARCHAR(50), LaunchDate DATE, Destination VARCHAR(50)); INSERT INTO Rovers VALUES (1, 'Perseverance', '2020-07-30', 'Mars'); INSERT INTO Rovers VALUES (2, 'Curiosity', '2011-11-26', 'Mars');
What is the latest launch date for a Mars rover mission, and which mission was it?
SELECT * FROM Rovers WHERE Destination = 'Mars' AND ROW_NUMBER() OVER (ORDER BY LaunchDate DESC) = 1
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (id INT, name VARCHAR(255), network VARCHAR(255), market_cap DECIMAL(10, 2)); INSERT INTO digital_assets (id, name, network, market_cap) VALUES (1, 'Asset1', 'network1', 500), (2, 'Asset2', 'network2', 600);
What's the name and network of the digital asset with the highest market capitalization?
SELECT name, network FROM digital_assets WHERE market_cap = (SELECT MAX(market_cap) FROM digital_assets);
gretelai_synthetic_text_to_sql
CREATE TABLE employee (id INT, name VARCHAR(50), gender VARCHAR(50), department_id INT, position_id INT, salary INT); CREATE TABLE position (id INT, title VARCHAR(50), department_id INT); CREATE TABLE department (id INT, name VARCHAR(50));
List all employees with their corresponding job position, salary, and department from the 'employee', 'position', and 'department' tables
SELECT employee.name, position.title, employee.salary, department.name AS department_name FROM employee INNER JOIN position ON employee.position_id = position.id INNER JOIN department ON position.department_id = department.id;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO renewable_energy (id, project_name, location, investment) VALUES (1, 'Solar Farm', 'Arizona', 12000000), (2, 'Wind Turbines', 'Texas', 8000000);
Count the number of renewable energy projects in the 'renewable_energy' schema.
SELECT COUNT(*) FROM renewable_energy;
gretelai_synthetic_text_to_sql
CREATE TABLE makeup_products (product_refillable BOOLEAN, sale_date DATE, quantity INT, manufacturing_country VARCHAR(20)); INSERT INTO makeup_products (product_refillable, sale_date, quantity, manufacturing_country) VALUES (TRUE, '2021-07-01', 75, 'Germany'), (FALSE, '2021-07-02', 100, 'Spain');
What was the number of sales of refillable makeup products in Germany in H2 2021?
SELECT SUM(quantity) FROM makeup_products WHERE product_refillable = TRUE AND manufacturing_country = 'Germany' AND sale_date BETWEEN '2021-07-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(50), union_id INT); INSERT INTO regions (id, name, union_id) VALUES (1, 'Northern', 1), (2, 'Southern', 2), (3, 'Eastern', 3);
How many labor rights advocacy unions are there in the northern region?
SELECT COUNT(*) FROM unions u INNER JOIN regions r ON u.id = r.union_id WHERE u.focus_area = 'labor rights' AND r.name = 'Northern';
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
Calculate the average price of all menu items in the Vegan category
SELECT AVG(price) FROM Menu WHERE category = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE orders(order_id INT, order_date DATE, menu_item_id INT, quantity INT); CREATE TABLE menu_items(menu_item_id INT, name TEXT, cuisine TEXT, price DECIMAL);
What are the top 3 selling items for each cuisine type?
SELECT menu_items.cuisine, menu_items.name, SUM(orders.quantity) as total_sold FROM menu_items JOIN orders ON menu_items.menu_item_id = orders.menu_item_id GROUP BY menu_items.cuisine, menu_items.menu_item_id ORDER BY total_sold DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houston'), (5, 'Phoenix'); CREATE TABLE mayor (id INT, city_id INT, name VARCHAR(255), community VARCHAR(255)); INSERT INTO mayor (id, city_id, name, community) VALUES (1, 1, 'John Smith', 'White'), (2, 1, 'James Johnson', 'African American'), (3, 2, 'Maria Rodriguez', 'Hispanic'), (4, 3, 'William Lee', 'Asian'), (5, 4, 'Robert Brown', 'White'), (6, 5, 'David Garcia', 'Hispanic');
List the names of all cities that have never had a mayor from a historically underrepresented community?
SELECT c.name FROM city c WHERE c.id NOT IN (SELECT m.city_id FROM mayor m WHERE m.community != 'White')
gretelai_synthetic_text_to_sql
CREATE TABLE labor_disputes (id INT, union_name VARCHAR(50), dispute_date DATE, dispute_reason VARCHAR(50)); INSERT INTO labor_disputes (id, union_name, dispute_date, dispute_reason) VALUES (1, 'United Steelworkers', '2019-12-01', 'Wages'), (2, 'Teamsters', '2020-06-15', 'Benefits'), (3, 'Service Employees International Union', '2018-03-03', 'Working conditions');
Show number of labor disputes by union name
SELECT union_name, COUNT(*) as total_disputes FROM labor_disputes GROUP BY union_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel (id INT, type VARCHAR(50), name VARCHAR(50));CREATE TABLE fuel_consumption (vessel_id INT, consumption DECIMAL(10,2), consumption_date DATE);
What is the average fuel consumption of bulk carriers in the past year?
SELECT AVG(fc.consumption) as avg_consumption FROM vessel v INNER JOIN fuel_consumption fc ON v.id = fc.vessel_id WHERE v.type = 'bulk carrier' AND fc.consumption_date >= DATE(NOW(), INTERVAL -1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE revenue(category VARCHAR(50), amount FLOAT); INSERT INTO revenue(category, amount) VALUES('TrendA', 1250.5), ('TrendB', 1500.7), ('TrendC', 1800.3);
What is the total revenue (in USD) generated from each fashion trend category?
SELECT category, SUM(amount) FROM revenue GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (ID INT, Gender VARCHAR(10), Disease VARCHAR(20), State VARCHAR(20)); INSERT INTO Patients (ID, Gender, Disease, State) VALUES (1, 'Female', 'Tuberculosis', 'California'); INSERT INTO Patients (ID, Gender, Disease, State) VALUES (2, 'Male', 'Hepatitis B', 'Texas');
How many males in Texas have been diagnosed with Hepatitis B?
SELECT COUNT(*) FROM Patients WHERE Gender = 'Male' AND Disease = 'Hepatitis B' AND State = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (id INT PRIMARY KEY, country VARCHAR(50), year INT, emissions FLOAT); INSERT INTO emissions (id, country, year, emissions) VALUES (1, 'US', 2015, 5500000.0); INSERT INTO emissions (id, country, year, emissions) VALUES (2, 'China', 2016, 10000000.0);
Which countries have emissions greater than 5 million in any year?
SELECT country FROM emissions WHERE emissions > 5000000 GROUP BY country HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, name, category) VALUES (7, 'CBD Gummies', 'Edibles'); CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (7, 'Heavenly Hash'); CREATE TABLE sales (sale_id INT, product_id INT, dispensary_id INT, quantity INT, sale_date DATE); INSERT INTO sales (sale_id, product_id, dispensary_id, quantity, sale_date) VALUES (500, 7, 7, 100, '2022-01-15');
How many units of 'CBD Gummies' product were sold in 'Heavenly Hash' dispensary in January 2022?
SELECT SUM(quantity) FROM sales WHERE product_id = (SELECT product_id FROM products WHERE name = 'CBD Gummies') AND dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Heavenly Hash') AND sale_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE provinces (province_name VARCHAR(50), budget_allocation INT); INSERT INTO provinces VALUES ('Ontario', 12000000); INSERT INTO provinces VALUES ('Quebec', 10000000); INSERT INTO provinces VALUES ('British Columbia', 9000000);
What is the total budget allocation for transportation for each province, in descending order?
SELECT province_name, SUM(budget_allocation) OVER (PARTITION BY province_name) as total_budget_allocation FROM provinces ORDER BY total_budget_allocation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (name VARCHAR(50), type VARCHAR(50), beds INT, location VARCHAR(50)); INSERT INTO hospitals (name, type, beds, location) VALUES ('Hospital A', 'Public', 300, 'City'); INSERT INTO hospitals (name, type, beds, location) VALUES ('Hospital B', 'Private', 200, 'Suburban'); INSERT INTO hospitals (name, type, beds, location) VALUES ('Hospital C', 'Public', 400, 'Rural');
How many public hospitals are there in each location type?
SELECT location, COUNT(*) as NumPublicHospitals FROM hospitals WHERE type = 'Public' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(50), Size VARCHAR(10), Region VARCHAR(50)); INSERT INTO Customers (CustomerID, CustomerName, Size, Region) VALUES (1, 'CustomerA', 'XS', 'Northeast'), (2, 'CustomerB', 'M', 'Northeast'), (3, 'CustomerC', 'XL', 'Midwest'), (4, 'CustomerD', 'S', 'South'), (5, 'CustomerE', 'XXL', 'West');
How many unique customers have purchased size-diverse clothing in each region?
SELECT Region, COUNT(DISTINCT CustomerID) as UniqueCustomers FROM Customers WHERE Size IN ('XS', 'S', 'M', 'L', 'XL', 'XXL') GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_registration TEXT);CREATE TABLE fares (fare_id INT, vehicle_id INT, fare_amount DECIMAL, fare_collection_date DATE); INSERT INTO vehicles (vehicle_id, vehicle_registration) VALUES (1001, 'ABC-123'), (1002, 'DEF-456'), (2001, 'GHI-789'); INSERT INTO fares (fare_id, vehicle_id, fare_amount, fare_collection_date) VALUES (1, 1001, 5.00, '2022-04-20'), (2, 1001, 5.00, '2022-04-20'), (3, 1002, 3.50, '2022-04-20'), (4, 1002, 3.50, '2022-04-20'), (5, 2001, 7.00, '2022-04-20');
What is the total fare collected for each vehicle on April 20, 2022?
SELECT v.vehicle_registration, SUM(f.fare_amount) as total_fare FROM vehicles v JOIN fares f ON v.vehicle_id = f.vehicle_id WHERE f.fare_collection_date = '2022-04-20' GROUP BY v.vehicle_registration;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id TEXT, country TEXT); INSERT INTO clinical_trials (trial_id, country) VALUES ('ClinicalTrial123', 'USA'), ('ClinicalTrial123', 'Canada'), ('ClinicalTrial456', 'Mexico'), ('ClinicalTrial789', 'India'), ('ClinicalTrial789', 'Nepal');
Which countries participated in 'ClinicalTrial789'?
SELECT DISTINCT country FROM clinical_trials WHERE trial_id = 'ClinicalTrial789';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contractors(contractor_id INT, contractor_name VARCHAR(50), num_veterans INT, total_employees INT); INSERT INTO defense_contractors(contractor_id, contractor_name, num_veterans, total_employees) VALUES (1, 'Lockheed Martin', 35000, 100000), (2, 'Boeing', 28000, 120000), (3, 'Raytheon', 22000, 80000);
Identify the top 3 defense contractors with the highest veteran employment ratio and their respective ratios.
SELECT contractor_id, contractor_name, num_veterans * 1.0 / total_employees as veteran_ratio FROM defense_contractors ORDER BY veteran_ratio DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableTourism (TourismID int, Location varchar(50), JobsCreated int); INSERT INTO SustainableTourism (TourismID, Location, JobsCreated) VALUES (1, 'Canada', 2000); INSERT INTO SustainableTourism (TourismID, Location, JobsCreated) VALUES (2, 'Australia', 3000);
Identify the number of local jobs created by sustainable tourism in Canada and Australia.
SELECT SUM(JobsCreated) FROM SustainableTourism WHERE Location IN ('Canada', 'Australia')
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ConcertID INT, Artist VARCHAR(50), City VARCHAR(50), Revenue DECIMAL(10,2)); INSERT INTO Concerts (ConcertID, Artist, City, Revenue) VALUES (1, 'Taylor Swift', 'Los Angeles', 500000.00), (2, 'BTS', 'New York', 750000.00), (3, 'Adele', 'London', 600000.00), (4, 'Taylor Swift', 'New York', 350000.00);
Display the concerts with a revenue greater than the average revenue of concerts in 'New York'.
SELECT * FROM Concerts WHERE City = 'New York' GROUP BY City; SELECT * FROM Concerts WHERE Revenue > (SELECT AVG(Revenue) FROM (SELECT Revenue FROM Concerts WHERE City = 'New York' GROUP BY City));
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (collection VARCHAR(10), co2_emissions FLOAT, units INT); INSERT INTO emissions (collection, co2_emissions, units) VALUES ('Spring_2022', 10.5, 1200), ('Spring_2022', 11.3, 1300), ('Spring_2022', 12.1, 1400);
What is the total CO2 emissions for the 'Spring_2022' collection?
SELECT SUM(co2_emissions) FROM emissions WHERE collection = 'Spring_2022';
gretelai_synthetic_text_to_sql
CREATE TABLE source_countries_2021 (id INT, country VARCHAR(50), num_ecotourists INT, total_eco_rating INT, avg_eco_rating FLOAT); INSERT INTO source_countries_2021 (id, country, num_ecotourists, total_eco_rating, avg_eco_rating) VALUES (1, 'United States', 1800, 13000, 7.22), (2, 'Australia', 1200, 9000, 7.5), (3, 'Canada', 900, 7500, 8.33), (4, 'United Kingdom', 1500, 13500, 9); CREATE TABLE source_countries_2022 (id INT, country VARCHAR(50), num_ecotourists INT, total_eco_rating INT, avg_eco_rating FLOAT); INSERT INTO source_countries_2022 (id, country, num_ecotourists, total_eco_rating, avg_eco_rating) VALUES (1, 'United States', 2000, 15000, 7.5), (2, 'Australia', 1500, 12000, 8), (3, 'Canada', 1200, 10000, 8.33), (4, 'United Kingdom', 1800, 18000, 10); CREATE TABLE eco_ratings_history (id INT, source_country VARCHAR(50), eco_rating INT, year INT); INSERT INTO eco_ratings_history (id, source_country, eco_rating, year) VALUES (1, 'United States', 15, 2021), (2, 'United States', 16, 2022), (3, 'Australia', 13, 2021), (4, 'Australia', 14, 2022), (5, 'Canada', 10, 2021), (6, 'Canada', 12, 2022), (7, 'United Kingdom', 16, 2021), (8, 'United Kingdom', 18, 2022);
Determine the change in eco-rating for each source country between 2021 and 2022.
SELECT s2022.country, (s2022.avg_eco_rating - s2021.avg_eco_rating) AS eco_rating_change FROM source_countries_2022 s2022 JOIN source_countries_2021 s2021 ON s2022.country = s2021.country;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL, donation_year INT); INSERT INTO donors (id, name, country, donation_amount, donation_year) VALUES (1, 'Hiroshi Tanaka', 'Japan', 150.00, 2022), (2, 'Miyuki Sato', 'Japan', 250.00, 2021);
What is the average donation amount from donors in Japan in 2022?
SELECT AVG(donation_amount) FROM donors WHERE country = 'Japan' AND donation_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, Plan VARCHAR(20)); INSERT INTO Customers (CustomerID, Plan) VALUES (1, 'Residential'), (2, 'Business'); CREATE TABLE DataUsage (CustomerID INT, Usage INT); INSERT INTO DataUsage (CustomerID, Usage) VALUES (1, 5000), (2, 8000);
What is the average data usage for each customer in the 'Residential' plan?
SELECT c.Plan, AVG(du.Usage) as AvgDataUsage FROM Customers c JOIN DataUsage du ON c.CustomerID = du.CustomerID WHERE c.Plan = 'Residential' GROUP BY c.Plan;
gretelai_synthetic_text_to_sql
CREATE TABLE Designers (DesignerID INT, DesignerName VARCHAR(50), IsSustainableFabric BOOLEAN); INSERT INTO Designers (DesignerID, DesignerName, IsSustainableFabric) VALUES (1, 'DesignerA', TRUE), (2, 'DesignerB', FALSE); CREATE TABLE FabricUsage (DesignerID INT, Fabric VARCHAR(50), Quantity INT); INSERT INTO FabricUsage (DesignerID, Fabric, Quantity) VALUES (1, 'Organic Cotton', 500), (1, 'Recycled Polyester', 300), (2, 'Conventional Cotton', 700), (2, 'Viscose', 400);
What is the total quantity of sustainable fabrics used by each designer?
SELECT d.DesignerName, SUM(fu.Quantity) as TotalSustainableQuantity FROM Designers d JOIN FabricUsage fu ON d.DesignerID = fu.DesignerID WHERE d.IsSustainableFabric = TRUE GROUP BY d.DesignerName;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, TotalDonation DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, TotalDonation) VALUES (1, 'James Doe', 50.00), (2, 'Jane Smith', 350.00), (3, 'Mike Johnson', 120.00), (4, 'Sara Connor', 75.00);
Delete donors who have not donated more than $100 in total.
DELETE FROM Donors WHERE TotalDonation < 100;
gretelai_synthetic_text_to_sql
CREATE TABLE client (client_id INT, name TEXT, country TEXT, financial_wellbeing_score INT); INSERT INTO client (client_id, name, country, financial_wellbeing_score) VALUES (1, 'John Doe', 'USA', 70); INSERT INTO client (client_id, name, country, financial_wellbeing_score) VALUES (2, 'Jane Smith', 'USA', 75); INSERT INTO client (client_id, name, country, financial_wellbeing_score) VALUES (3, 'Mohammad Ahmad', 'Pakistan', NULL); CREATE VIEW clients_with_null_scores AS SELECT * FROM client WHERE financial_wellbeing_score IS NULL;
Delete clients from Pakistan with a financial wellbeing score of NULL.
DELETE FROM client WHERE client_id IN (SELECT client_id FROM clients_with_null_scores WHERE country = 'Pakistan');
gretelai_synthetic_text_to_sql
CREATE TABLE Instagram_Ads(id INT, user_id INT, ad_id INT, age INT, gender TEXT); CREATE TABLE Snapchat_Ads(id INT, user_id INT, ad_id INT, age INT, gender TEXT);
What are the demographics of users who clicked on 'Instagram' or 'Snapchat' ads in the last week?
SELECT 'Instagram' AS platform, age, gender, COUNT(*) AS clicks FROM Instagram_Ads WHERE post_time >= NOW() - INTERVAL '1 week' GROUP BY age, gender UNION ALL SELECT 'Snapchat' AS platform, age, gender, COUNT(*) AS clicks FROM Snapchat_Ads WHERE post_time >= NOW() - INTERVAL '1 week' GROUP BY age, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE islamic_financial_education (client_id INT, program_name VARCHAR(30), credit_score INT, program_status VARCHAR(20)); INSERT INTO islamic_financial_education (client_id, program_name, credit_score, program_status) VALUES (201, 'Islamic Financial Education', 700, 'Completed'), (202, 'Financial Wellbeing', 650, 'Enrolled'), (203, 'Islamic Financial Education', 720, 'Completed'), (204, 'Financial Capability', 680, 'Dropped Out');
What is the average credit score of clients who have completed the Islamic Financial Education program?
SELECT AVG(credit_score) FROM islamic_financial_education WHERE program_name = 'Islamic Financial Education' AND program_status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (id INT, country VARCHAR(50), application VARCHAR(50), satisfaction FLOAT); INSERT INTO creative_ai (id, country, application, satisfaction) VALUES (1, 'USA', 'Text Generation', 4.3), (2, 'Canada', 'Image Recognition', 4.5);
What is the average satisfaction score for creative AI applications in the USA?
SELECT AVG(satisfaction) FROM creative_ai WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, household_id INT, city TEXT, state TEXT, usage REAL, timestamp DATETIME); INSERT INTO water_usage (id, household_id, city, state, usage, timestamp) VALUES (1, 1, 'Austin', 'Texas', 1500, '2022-06-01 00:00:00'), (2, 2, 'Austin', 'Texas', 1200, '2022-06-15 12:00:00'), (3, 3, 'Austin', 'Texas', 1800, '2022-06-30 23:59:59');
What is the average water usage per household in the city of Austin, Texas, for the month of June?
SELECT AVG(usage) FROM water_usage WHERE city = 'Austin' AND state = 'Texas' AND MONTH(timestamp) = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (region VARCHAR(255), sector VARCHAR(255), year INT, ghg_emissions FLOAT); INSERT INTO emissions (region, sector, year, ghg_emissions) VALUES ('Africa', 'Energy', 2012, 600), ('Africa', 'Industry', 2012, 500), ('Africa', 'Energy', 2013, 650), ('Africa', 'Industry', 2013, 550);
Which sectors have the highest greenhouse gas emissions in Africa in the last 10 years?
SELECT sector, SUM(ghg_emissions) AS total_emissions FROM emissions WHERE region = 'Africa' GROUP BY sector ORDER BY total_emissions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, region VARCHAR(20), amount DECIMAL(10,2), donation_year INT); INSERT INTO Donors (donor_id, region, amount, donation_year) VALUES (1, 'Southeast', 7000.00, 2020), (2, 'Southeast', 6000.00, 2020);
Who was the top donor in the 'Southeast' region in the year 2020?
SELECT donor_id, MAX(amount) FROM Donors WHERE region = 'Southeast' AND donation_year = 2020 GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE esg_scores_3 (investment_id INT, region VARCHAR(20), esg_score FLOAT); INSERT INTO esg_scores_3 (investment_id, region, esg_score) VALUES (1, 'Africa', 75.5), (2, 'Oceania', 87.6), (3, 'Africa', 78.2), (4, 'South America', 82.1);
What is the maximum ESG score for investments in 'Oceania'?
SELECT MAX(esg_score) FROM esg_scores_3 WHERE region = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, year INT, region VARCHAR(20), project_name VARCHAR(30), delayed BOOLEAN); INSERT INTO defense_projects (id, year, region, project_name, delayed) VALUES (1, 2019, 'Asia-Pacific', 'Project A', true); INSERT INTO defense_projects (id, year, region, project_name, delayed) VALUES (2, 2019, 'Asia-Pacific', 'Project B', false);
How many defense projects were delayed in the Asia-Pacific region in 2019?
SELECT COUNT(*) FROM defense_projects WHERE year = 2019 AND region = 'Asia-Pacific' AND delayed = true;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(30)); CREATE TABLE properties (id INT, city VARCHAR(20), year_built INT); INSERT INTO cities (id, name) VALUES (1, 'Vancouver'), (2, 'Seattle'), (3, 'Portland'); INSERT INTO properties (id, city, year_built) VALUES (101, 'Vancouver', 1995), (102, 'Vancouver', 2010), (103, 'Seattle', 1985), (104, 'Seattle', 2005), (105, 'Portland', 1999), (106, 'Portland', 2002);
Find the number of properties in each city that were built before 2000.
SELECT cities.name, COUNT(properties.id) FROM cities INNER JOIN properties ON cities.name = properties.city WHERE properties.year_built < 2000 GROUP BY cities.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory(item_id INT, item_name VARCHAR(50), is_vegan BOOLEAN, calorie_count INT); INSERT INTO Inventory VALUES(1,'Apples',TRUE,80),(2,'Bananas',TRUE,105),(3,'Chips',FALSE,150);
Find the minimum and maximum calorie count for vegan items in the inventory.
SELECT MIN(calorie_count), MAX(calorie_count) FROM Inventory WHERE is_vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name VARCHAR(50), location VARCHAR(50), size FLOAT);
Delete the 'Antarctica' habitat record from the 'habitats' table
DELETE FROM habitats WHERE location = 'Antarctica';
gretelai_synthetic_text_to_sql
CREATE TABLE savings_acct (acct_number INT, name VARCHAR(50), balance DECIMAL(10,2), is_shariah BOOLEAN); INSERT INTO savings_acct (acct_number, name, balance, is_shariah) VALUES (1001, 'Ahmed', 15000.00, true), (1002, 'Sara', 20000.00, false), (1003, 'Mohammed', 12000.00, true);
Find the customer with the highest balance in the Shariah-compliant savings accounts, and display their account number, name, and balance.
SELECT acct_number, name, balance FROM (SELECT acct_number, name, balance, ROW_NUMBER() OVER (PARTITION BY is_shariah ORDER BY balance DESC) as rn FROM savings_acct WHERE is_shariah = true) t WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_activity (id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50), activity_date DATE); INSERT INTO vessel_activity (id, vessel_name, flag_state, activity_date) VALUES (1, 'Panama Titan', 'Panama', '2022-03-20'), (2, 'Panama Titan', 'Panama', '2022-03-23');
How many vessels with flag_state 'Panama' were active in the last month?
SELECT COUNT(DISTINCT vessel_name) FROM vessel_activity WHERE flag_state = 'Panama' AND activity_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), region VARCHAR(255), organic BOOLEAN, rating FLOAT); INSERT INTO products (product_id, product_name, region, organic, rating) VALUES (1, 'Nourishing Cream', 'Asia Pacific', false, 4.5), (2, 'Revitalizing Serum', 'Europe', false, 4.7), (3, 'Gentle Cleanser', 'Asia Pacific', true, 4.8), (4, 'Hydrating Lotion', 'North America', true, 4.6), (5, 'Soothing Toner', 'Asia Pacific', true, 4.9), (6, 'Brightening Essence', 'Europe', false, 4.4);
What is the average rating of organic skincare products in the North American market?
SELECT AVG(rating) AS average_rating FROM products WHERE region = 'North America' AND organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT PRIMARY KEY, campaign_name VARCHAR(50), campaign_start_date DATE, campaign_end_date DATE); INSERT INTO campaigns (id, campaign_name, campaign_start_date, campaign_end_date) VALUES (1, 'Food Drive', '2022-01-01', '2022-01-15'); INSERT INTO campaigns (id, campaign_name, campaign_start_date, campaign_end_date) VALUES (2, 'Clothing Drive', '2022-02-01', '2022-02-28');
Find the average donation amount for each campaign in 2022.
SELECT campaign_name, AVG(donation_amount) FROM donations d JOIN campaigns c ON d.donation_date BETWEEN c.campaign_start_date AND c.campaign_end_date GROUP BY campaign_name;
gretelai_synthetic_text_to_sql
CREATE TABLE mars_rovers (id INT, name VARCHAR(50), status VARCHAR(50)); INSERT INTO mars_rovers (id, name, status) VALUES (1, 'Rover1', 'Operational'), (2, 'Rover2', 'Operational'), (3, 'Rover3', 'Decommissioned'), (4, 'Rover4', 'Operational'), (5, 'Rover5', 'Not Operational');
How many rovers have been deployed on the surface of Mars and are not operational?
SELECT COUNT(*) FROM mars_rovers WHERE status != 'Operational';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT PRIMARY KEY, artist_name VARCHAR(100), genre VARCHAR(50), total_streams INT); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (1, 'Taylor Swift', 'Pop', 15000000); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (2, 'BTS', 'K-Pop', 20000000); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (3, 'Drake', 'Hip-Hop', 12000000);
List all artists who have more than 10 million total streams
SELECT artist_name FROM artists WHERE total_streams > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE course_ratings (course_id INT, teacher_id INT, mental_health_rating FLOAT); INSERT INTO course_ratings (course_id, teacher_id, mental_health_rating) VALUES (1, 1, 4.5), (2, 1, 3.8), (3, 2, 4.7), (4, 2, 4.2), (5, 3, 5.0);
What is the average mental health rating of courses for each teacher?
SELECT teacher_id, AVG(mental_health_rating) FROM course_ratings GROUP BY teacher_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Skincare_Products (ProductID int, ProductName varchar(100), Country varchar(50), IsOrganic bit); INSERT INTO Skincare_Products (ProductID, ProductName, Country, IsOrganic) VALUES (1, 'Organic Moisturizer', 'USA', 1); INSERT INTO Skincare_Products (ProductID, ProductName, Country, IsOrganic) VALUES (2, 'Natural Toner', 'France', 0); INSERT INTO Skincare_Products (ProductID, ProductName, Country, IsOrganic) VALUES (3, 'Certified Organic Serum', 'USA', 1);
What is the number of skincare products made in the USA that are certified organic?
SELECT COUNT(*) FROM Skincare_Products WHERE Country = 'USA' AND IsOrganic = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE login_attempts (ip_address VARCHAR(15), login_status VARCHAR(10)); INSERT INTO login_attempts (ip_address, login_status) VALUES ('192.168.1.1', 'successful'), ('192.168.1.2', 'unsuccessful'), ('192.168.1.3', 'successful'), ('192.168.1.2', 'successful'), ('10.0.0.1', 'unsuccessful');
What are the unique IP addresses that have attempted both unsuccessful and successful SSH logins, excluding any IP addresses with only unsuccessful attempts?
SELECT ip_address FROM login_attempts WHERE login_status = 'successful' INTERSECT SELECT ip_address FROM login_attempts WHERE login_status = 'unsuccessful';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (DispensaryID INT, DispensaryName VARCHAR(50)); CREATE TABLE Sales (SaleID INT, DispensaryID INT, QuantitySold INT, SaleDate DATE);
List dispensaries that have not had sales in the last 14 days, along with the number of days since their last sale.
SELECT D.DispensaryID, D.DispensaryName, DATEDIFF(day, MAX(S.SaleDate), GETDATE()) AS DaysSinceLastSale FROM Dispensaries D LEFT JOIN Sales S ON D.DispensaryID = S.DispensaryID WHERE S.SaleDate IS NULL OR S.SaleDate < DATEADD(day, -14, GETDATE()) GROUP BY D.DispensaryID, D.DispensaryName;
gretelai_synthetic_text_to_sql
CREATE TABLE Solar_Power_Plants (project_id INT, location VARCHAR(50), energy_production_cost FLOAT); INSERT INTO Solar_Power_Plants (project_id, location, energy_production_cost) VALUES (1, 'Japan', 0.08), (2, 'Japan', 0.07), (3, 'Japan', 0.06), (4, 'Japan', 0.09);
What is the lowest energy production cost for Solar Power Plants in Japan?
SELECT MIN(energy_production_cost) FROM Solar_Power_Plants WHERE location = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (project_name TEXT, project_type TEXT, allocation INTEGER, year INTEGER); INSERT INTO climate_finance (project_name, project_type, allocation, year) VALUES ('GreenTech Innovations', 'Mitigation', 5000000, 2020);
What is the total funding allocated for climate mitigation projects in 2020?
SELECT SUM(allocation) FROM climate_finance WHERE project_type = 'Mitigation' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE tour_attendees (id INT, location TEXT, attendees INT, tour_date DATE); INSERT INTO tour_attendees (id, location, attendees, tour_date) VALUES (1, 'Dubai', 25, '2022-01-01'), (2, 'Abu Dhabi', 30, '2022-02-10');
Find the maximum number of virtual tour attendees in the Middle East in any month.
SELECT MAX(attendees) AS max_attendees FROM tour_attendees WHERE location LIKE '%Middle East%';
gretelai_synthetic_text_to_sql
CREATE TABLE FreightForwarding (id INT, route VARCHAR(50), cost INT); INSERT INTO FreightForwarding (id, route, cost) VALUES (1, 'Route 2', 300), (2, 'Route 6', 800);
What are the freight forwarding costs for Route 2 and Route 6?
SELECT route, cost FROM FreightForwarding WHERE route IN ('Route 2', 'Route 6');
gretelai_synthetic_text_to_sql
CREATE TABLE donations(id INT, donor_name TEXT, donation_amount FLOAT, donation_date DATE); INSERT INTO donations(id, donor_name, donation_amount, donation_date) VALUES (1, 'James Lee', 50, '2022-11-29'), (2, 'Grace Kim', 100, '2022-12-01'), (3, 'Anthony Nguyen', 25, '2022-11-29');
What is the minimum donation amount given on Giving Tuesday?
SELECT MIN(donation_amount) FROM donations WHERE donation_date = '2022-11-29';
gretelai_synthetic_text_to_sql
CREATE TABLE communities (community_id INT, community_name VARCHAR(50), region VARCHAR(50));CREATE TABLE erosion_data (measurement_id INT, measurement_date DATE, erosion_rate FLOAT, community_id INT);
Identify the indigenous communities in the Arctic region that are most affected by coastal erosion and their corresponding coastal erosion rates.
SELECT c.community_name, AVG(ed.erosion_rate) AS avg_erosion_rate FROM communities c JOIN erosion_data ed ON c.community_id = ed.community_id WHERE c.region LIKE '%Arctic%' GROUP BY c.community_name ORDER BY avg_erosion_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR(255), sector VARCHAR(255), liabilities DECIMAL(10, 2)); INSERT INTO clients (id, name, sector, liabilities) VALUES (1, 'Emma White', 'Healthcare', 120000.00), (2, 'Liam Black', 'Healthcare', 180000.00), (3, 'Noah Gray', 'Healthcare', 220000.00), (4, 'Olivia Brown', 'Healthcare', 280000.00), (5, 'Ethan Green', 'Technology', 50000.00), (6, 'Harper Blue', 'Retail', 90000.00);
What is the total liabilities value for clients in the healthcare sector who have liabilities greater than 200000?
SELECT SUM(liabilities) FROM clients WHERE sector = 'Healthcare' AND liabilities > 200000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT PRIMARY KEY, name VARCHAR(255), origin VARCHAR(255), recyclability_rating FLOAT); INSERT INTO materials (id, name, origin, recyclability_rating) VALUES (1, 'Recycled Plastic', 'UK', 4.6), (2, 'Reused Metal', 'Ireland', 4.5), (3, 'Eco-Friendly Paper', 'UK', 4.7);
What is the total recyclability rating of materials from the United Kingdom and Ireland?
SELECT SUM(recyclability_rating) FROM materials WHERE origin IN ('UK', 'Ireland');
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitats (id INT, name VARCHAR(50), forest_id INT); INSERT INTO wildlife_habitats (id, name, forest_id) VALUES (1, 'Wetlands', 1), (2, 'Grasslands', 3), (3, 'Forest', 2), (4, 'Scrublands', 2);
Determine the number of wildlife habitats in boreal forests with timber harvesting
SELECT COUNT(*) FROM wildlife_habitats wh JOIN forests f ON wh.forest_id = f.id WHERE f.type = 'boreal' AND EXISTS (SELECT 1 FROM harvests h WHERE h.forest_id = f.id);
gretelai_synthetic_text_to_sql