context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE farms (id INT, name TEXT, location TEXT, is_indigenous BOOLEAN); INSERT INTO farms (id, name, location, is_indigenous) VALUES (1, 'Farm A', 'North America', TRUE); INSERT INTO farms (id, name, location, is_indigenous) VALUES (2, 'Farm B', 'North America', FALSE); CREATE TABLE crops (id INT, name TEXT, type...
What are the 'Crop Types' and their respective total production for 'Indigenous Farms' in 'North America' in 2022?
SELECT c.type, SUM(c.production) as total_production FROM crops c INNER JOIN farms f ON c.farm_id = f.id WHERE f.location = 'North America' AND f.is_indigenous = TRUE AND c.production > 0 AND c.year = 2022 GROUP BY c.type;
gretelai_synthetic_text_to_sql
CREATE TABLE game_W_sales (sale_id INT, sale_date DATE, revenue INT);
What is the total revenue of game W in year 2021?
SELECT SUM(revenue) FROM game_W_sales WHERE YEAR(sale_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (id INT PRIMARY KEY, game_id INT, number_of_tickets INT, date DATE);
get the total number of tickets sold for a specific game
SELECT SUM(number_of_tickets) FROM ticket_sales WHERE game_id = 123 AND date = '2022-05-01';
gretelai_synthetic_text_to_sql
CREATE TABLE seafood_sales (id INT, supplier_id INT, species_id INT, quantity INT, date DATE); CREATE TABLE seafood_species (id INT, name VARCHAR(255), is_sustainable BOOLEAN); INSERT INTO seafood_sales (id, supplier_id, species_id, quantity, date) VALUES (1, 1, 1, 50, '2022-01-01'), (2, 1, 2, 80, '2022-01-01'), (3, 2,...
What is the percentage of sustainable seafood sold by each supplier, for each month, for the past year?
SELECT s.name as supplier, DATE_TRUNC('month', ss.date) as month, 100.0 * SUM(CASE WHEN ss.species_id = ss.species_id AND s.is_sustainable THEN ss.quantity ELSE 0 END) / (SELECT SUM(quantity) FROM seafood_sales WHERE supplier_id = ss.supplier_id AND DATE_TRUNC('month', date) = DATE_TRUNC('month', ss.date)) as pct_susta...
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (incident_id INT, incident_type VARCHAR(50), department VARCHAR(50), country VARCHAR(50)); INSERT INTO safety_incidents (incident_id, incident_type, department, country) VALUES (1, 'Incident A', 'Manufacturing', 'Nigeria'), (2, 'Incident B', 'Research', 'Nigeria'), (3, 'Incident C', 'Manuf...
Determine the percentage of safety incidents in Nigeria that occurred in the manufacturing department.
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM safety_incidents WHERE country = 'Nigeria' AND department = 'Manufacturing') FROM safety_incidents WHERE country = 'Nigeria';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, department VARCHAR(50), incident_date DATE, incident_category VARCHAR(50), is_false_positive BOOLEAN);
What is the distribution of security incidents by category for each department in the last month, excluding false positives?
SELECT department, incident_category, COUNT(*) as incident_count FROM security_incidents WHERE incident_date >= DATEADD(month, -1, GETDATE()) AND is_false_positive = FALSE GROUP BY department, incident_category;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_tourists (id INT, country VARCHAR(20), days INT); INSERT INTO eco_tourists (id, country, days) VALUES (1, 'Costa Rica', 7), (2, 'Costa Rica', 10), (3, 'Costa Rica', 5);
What is the average length of stay for eco-tourists in Costa Rica?
SELECT AVG(days) FROM eco_tourists WHERE country = 'Costa Rica';
gretelai_synthetic_text_to_sql
CREATE TABLE Garments(id INT, category VARCHAR(20), retail_price DECIMAL(5,2)); INSERT INTO Garments(id, category, retail_price) VALUES (1, 'Sustainable_Materials', 50.00), (2, 'Conventional_Materials', 30.00);
What is the average retail price of garments in the 'Sustainable_Materials' category?
SELECT AVG(retail_price) FROM Garments WHERE category = 'Sustainable_Materials';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), size_km FLOAT); INSERT INTO marine_protected_areas (id, name, location, size_km) VALUES (1, 'Bouillante Underwater Nature Reserve', 'Guadeloupe, Caribbean', 18.0), (2, 'Medes Islands', 'Mediterranean Sea', 80.0);
List all marine protected areas in the Mediterranean.
SELECT name FROM marine_protected_areas WHERE location = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE asia_sustainable_tourism (id INT, country VARCHAR(20), certifications INT); INSERT INTO asia_sustainable_tourism (id, country, certifications) VALUES (1, 'India', 25), (2, 'Indonesia', 30), (3, 'Thailand', 35), (4, 'Vietnam', 40), (5, 'Malaysia', 45);
What is the average number of sustainable tourism certifications for countries in Asia?
SELECT AVG(certifications) FROM asia_sustainable_tourism;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, incident_date DATE, incident_description TEXT, location TEXT, resolved BOOLEAN); CREATE VIEW regions AS SELECT location AS region FROM mental_health_parity GROUP BY location;
What is the total number of mental health parity violations that have been reported in each region in the last year?
SELECT region, COUNT(*) FROM mental_health_parity WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel (id INT, type VARCHAR(50), name VARCHAR(50));CREATE TABLE speed_data (vessel_id INT, speed DECIMAL(10,2), speed_date DATE);
What is the average speed of container vessels in the past year?
SELECT AVG(sd.speed) as avg_speed FROM vessel v INNER JOIN speed_data sd ON v.id = sd.vessel_id WHERE v.type = 'container' AND sd.speed_date >= DATE(NOW(), INTERVAL -1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (name TEXT, sport TEXT); INSERT INTO athletes (name, sport) VALUES ('John Doe', 'Baseball'), ('Jane Doe', 'Soccer'), ('Jim Smith', 'Baseball'), ('Jill Smith', 'Soccer');
Find the names of athletes who have participated in both baseball and soccer.
SELECT name FROM athletes WHERE sport IN ('Baseball', 'Soccer') GROUP BY name HAVING COUNT(DISTINCT sport) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_arts (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), region VARCHAR(255));
Insert a new traditional art in Asia into the 'traditional_arts' table
INSERT INTO traditional_arts (id, name, type, region) VALUES (2, 'Kasuri Textiles', 'Textile', 'East Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerPrograms (ProgramID INT, ProgramName VARCHAR(50), VolunteerID INT);
List all volunteers who have volunteered for more than one program in the 'VolunteerPrograms' table.
SELECT V.FirstName, V.LastName, COUNT(DISTINCT ProgramID) AS ProgramCount FROM VolunteerPrograms VP INNER JOIN Volunteers V ON VP.VolunteerID = V.VolunteerID GROUP BY V.VolunteerID HAVING COUNT(DISTINCT ProgramID) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sessions (session_id INT, type VARCHAR(20), therapist_id INT, patient_id INT, sessions INT); INSERT INTO sessions (session_id, type, therapist_id, patient_id, sessions) VALUES (1, 'Group Therapy', 1, 1, 2); INSERT INTO sessions (session_id, type, therapist_id, patient_id, sessions) VALUES (2, 'Individual T...
What is the total number of patients who have attended group therapy sessions?
SELECT COUNT(DISTINCT patient_id) FROM sessions WHERE type = 'Group Therapy';
gretelai_synthetic_text_to_sql
CREATE TABLE Machines (MachineID INT, ManufacturingCountry VARCHAR(50)); INSERT INTO Machines (MachineID, ManufacturingCountry) VALUES (1, 'Germany'); INSERT INTO Machines (MachineID, ManufacturingCountry) VALUES (2, 'France');
Which machines were manufactured in Germany?
SELECT MachineID FROM Machines WHERE ManufacturingCountry = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE crime_categories (category_id INT, category_name TEXT); INSERT INTO crime_categories (category_id, category_name) VALUES (1, 'Theft'), (2, 'Vandalism'), (3, 'Assault'), (4, 'Drug Offense'); CREATE TABLE crimes (crime_id INT, category_id INT, date DATE, neighborhood TEXT); INSERT INTO crimes (crime_id, cate...
How many crimes were committed in each category during the last month in the park neighborhood?
SELECT category_name, COUNT(*) FROM crimes WHERE neighborhood = 'Park' AND date >= '2022-03-01' AND date < '2022-04-01' GROUP BY category_name;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, launch_company VARCHAR(50), destination VARCHAR(50)); INSERT INTO space_missions (id, mission_name, launch_date, launch_company, destination) VALUES (1, 'Apollo 11', '1969-07-16', 'NASA', 'Moon'); INSERT INTO space_missions (id, mission_na...
Which private companies have launched space missions that reached the Moon?
SELECT launch_company FROM space_missions WHERE destination = 'Moon' AND launch_company NOT IN ('NASA', 'ESA', 'Roscosmos', 'ISRO');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_production (company_id INT, country VARCHAR(255), co2_emissions INT); CREATE TABLE companies (company_id INT, company_name VARCHAR(255)); INSERT INTO cosmetics_production (company_id, country, co2_emissions) VALUES (1, 'China', 5000), (2, 'USA', 4000), (3, 'Germany', 3000); INSERT INTO companies ...
What are the top 3 countries with the highest CO2 emissions in cosmetics production?
SELECT country, SUM(co2_emissions) AS total_emissions FROM cosmetics_production INNER JOIN companies ON cosmetics_production.company_id = companies.company_id GROUP BY country ORDER BY total_emissions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE matter_composition (date DATE, region VARCHAR(50), organic_matter FLOAT, inorganic_matter FLOAT); INSERT INTO matter_composition (date, region, organic_matter, inorganic_matter) VALUES ('2021-10-01', 'Africa', 1200, 800);
What is the total organic matter and inorganic matter for each region in Q4 2021?
SELECT EXTRACT(QUARTER FROM date) as quarter, region, SUM(organic_matter) as total_organic_matter, SUM(inorganic_matter) as total_inorganic_matter FROM matter_composition WHERE date >= '2021-10-01' AND date <= '2021-12-31' GROUP BY quarter, region;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(50), max_cargo_weight INT); INSERT INTO vessels (id, name, type, max_cargo_weight) VALUES (1, 'VesselA', 'Cargo', 10000), (2, 'VesselB', 'Tanker', 8000), (3, 'VesselC', 'Passenger', 0); CREATE TABLE voyages (id INT, vessel_id INT, region VARCHAR(50), distance...
What is the total cargo weight carried by vessels to the Indian Ocean?
SELECT SUM(cargo_weight) FROM voyages WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Project_Timeline (project_id INT, project_type VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE); INSERT INTO Project_Timeline (project_id, project_type, location, start_date, completion_date) VALUES (1, 'Commercial', 'Florida', '2020-01-01', '2021-01-01'); INSERT INTO Project_Timel...
Identify the average duration of construction projects in Florida that were initiated in 2020 and completed in 2021.
SELECT AVG(DATEDIFF(completion_date, start_date)) FROM Project_Timeline WHERE location = 'Florida' AND start_date BETWEEN '2020-01-01' AND '2020-12-31' AND completion_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), tenure VARCHAR(50), community VARCHAR(50), department VARCHAR(50));
Identify the top 5 departments with the highest percentage of tenured faculty members from underrepresented communities.
SELECT department, ROUND(COUNT(*) * 100.0 / NULLIF(SUM(CASE WHEN tenure = 'Tenured' THEN 1 ELSE 0 END), 0), 2) AS tenured_percentage FROM faculty WHERE community IN ('underrepresented_1', 'underrepresented_2') AND tenure = 'Tenured' GROUP BY department ORDER BY tenured_percentage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, investment_type VARCHAR(50), location VARCHAR(50), investment_amount DECIMAL(10,2));
Insert a new record in the network_investments table for a new fiber optic investment in Dallas, TX in the amount of 2,000,000.00
INSERT INTO network_investments (investment_id, investment_type, location, investment_amount) VALUES ((SELECT MAX(investment_id) FROM network_investments) + 1, 'fiber optic', 'Dallas, TX', 2000000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_smart_contracts (id INT, gas_fees DECIMAL(10, 2), deFi_involvement BOOLEAN); INSERT INTO ethereum_smart_contracts (id, gas_fees, deFi_involvement) VALUES (1, 100, TRUE);
What is the maximum gas fee for Ethereum smart contracts involved in DeFi?
SELECT MAX(gas_fees) FROM ethereum_smart_contracts WHERE deFi_involvement = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policy_type VARCHAR(20), coverage_level INT, price FLOAT); INSERT INTO policies (id, policy_type, coverage_level, price) VALUES (1, 'Comprehensive', 3, 1200.00), (2, 'Third-Party', 2, 800.00), (3, 'Third-Party', 3, 1000.00); CREATE TABLE policyholders (id INT, age INT, gender VARCHAR(10),...
List all policies with their total claim amounts for policyholders from Texas, grouped by policy type and coverage level.
SELECT policy_type, coverage_level, SUM(claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id JOIN policies ON policyholders.policy_type = policies.policy_type WHERE policyholders.state = 'Texas' GROUP BY policy_type, coverage_level;
gretelai_synthetic_text_to_sql
CREATE TABLE product (product_id INT, product_name TEXT, price FLOAT, rating INT); INSERT INTO product VALUES (1, 'Lipstick', 10.0, 4), (2, 'Moisturizer', 20.0, 5), (3, 'Foundation', 30.0, 3);
What is the average rating of products in a certain price range?
SELECT AVG(rating) FROM product WHERE price >= 10.0 AND price <= 30.0;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policy_number INT, policyholder_name VARCHAR(50), car_make VARCHAR(20), policyholder_state VARCHAR(20));
Retrieve the policy numbers and policyholder names for policyholders who have a car make of 'Honda' or 'Hyundai' and live in 'California'
SELECT policy_number, policyholder_name FROM policyholders WHERE (car_make = 'Honda' OR car_make = 'Hyundai') AND policyholder_state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE donor_data (id INT, donation DECIMAL(10,2), sector TEXT); INSERT INTO donor_data (id, donation, sector) VALUES (1, 250.00, 'education'), (2, 300.00, 'health'), (3, 150.00, 'education'), (1, 100.00, 'health'); CREATE TABLE volunteer_data (id INT, sector TEXT, volunteer_hours INT); INSERT INTO volunteer_data...
What is the total number of unique donors and volunteers who have contributed to programs in the health sector?
SELECT COUNT(DISTINCT donor_data.id) as total_donors, COUNT(DISTINCT volunteer_data.id) as total_volunteers FROM donor_data INNER JOIN volunteer_data ON donor_data.sector = volunteer_data.sector WHERE donor_data.sector = 'health';
gretelai_synthetic_text_to_sql
CREATE TABLE media_ethics (article_id INT, author VARCHAR(50), title VARCHAR(100), published_date DATE, category VARCHAR(30), author_region VARCHAR(30)); INSERT INTO media_ethics (article_id, author, title, published_date, category, author_region) VALUES (3, 'Ali Khan', 'Article 7', '2021-01-07', 'Ethics', 'Asia');
What is the total number of articles published by authors from Asia in the 'media_ethics' table?
SELECT author_region, COUNT(article_id) AS total_articles FROM media_ethics WHERE author_region = 'Asia' GROUP BY author_region;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(255), network VARCHAR(255), profile_picture VARCHAR(255)); INSERT INTO users (id, username, network, profile_picture) VALUES (1, 'user1', 'social', 'old_url'), (2, 'user2', 'professional', 'new_url');
Update the profile picture URL for user 'user1' in the 'social' network.
UPDATE users SET profile_picture = 'new_url' WHERE username = 'user1' AND network = 'social';
gretelai_synthetic_text_to_sql
CREATE TABLE Gadolinium_Production (Year INT, Quantity INT); INSERT INTO Gadolinium_Production (Year, Quantity) VALUES (2015, 600), (2016, 650), (2017, 700), (2018, 750); CREATE TABLE Samarium_Production (Year INT, Quantity INT); INSERT INTO Samarium_Production (Year, Quantity) VALUES (2015, 550), (2016, 600), (2017, 6...
What is the difference in total production between Gadolinium and Samarium for all years?
SELECT (SELECT SUM(Quantity) FROM Gadolinium_Production) - (SELECT SUM(Quantity) FROM Samarium_Production);
gretelai_synthetic_text_to_sql
CREATE TABLE attractions (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, category VARCHAR(255), city VARCHAR(255), country VARCHAR(255));
Update the description field in the attractions table for the attraction with id 3
UPDATE attractions SET description = 'A stunning temple in Kyoto, Japan' WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT, country TEXT, year INT, improvement FLOAT);
What is the total energy efficiency improvement in India from 2017 to 2020?
SELECT SUM(improvement) FROM energy_efficiency WHERE country = 'India' AND year BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2)); INSERT INTO clients (client_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO transactions (transaction_id, client_id, amount) VALUES (1, 1, 1000.00), (2, 1, 2000....
What is the total value of transactions for each client?
SELECT c.client_id, c.name, SUM(t.amount) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id GROUP BY c.client_id, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (life_id INT, life_name VARCHAR(50), region VARCHAR(50)); INSERT INTO marine_life (life_id, life_name, region) VALUES (1, 'Polar Bear', 'Arctic'), (2, 'Walrus', 'Arctic');
What is the total number of marine species in the Arctic region?
SELECT COUNT(*) FROM marine_life WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Price (id INT, vehicle_model VARCHAR(255), price FLOAT); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (1, 'Polestar 2', 59900.0); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (2, 'Volvo XC40', 53900.0); INSERT INTO EV_Price (id, vehicle_model, price) VALUES (3, 'Volvo XC60', 58400.0)...
What is the average price of electric vehicles manufactured in Sweden?
SELECT AVG(price) FROM EV_Price WHERE vehicle_model IN (SELECT vehicle_model FROM EV_Manufacturers WHERE manufacturing_country = 'Sweden');
gretelai_synthetic_text_to_sql
CREATE TABLE sales_by_manufacturer (manufacturer VARCHAR(255), revenue FLOAT); INSERT INTO sales_by_manufacturer (manufacturer, revenue) VALUES ('Manufacturer A', 6000), ('Manufacturer B', 5000), ('Manufacturer C', 4000);
Get the total sales for each garment manufacturer in the month of March 2022?
SELECT manufacturer, SUM(revenue) FROM sales_by_manufacturer WHERE revenue IS NOT NULL AND manufacturer IS NOT NULL AND STR_TO_DATE(CONCAT('03-', MONTH(NOW())), '%d-%m-%Y') = STR_TO_DATE('03-2022', '%d-%m-%Y') GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, Gender varchar(10), Department varchar(20), Salary numeric(10,2)); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'IT', 75000.00), (2, 'Female', 'IT', 70000.00), (3, 'Non-binary', 'HR', 60000.00), (4, 'Female', 'HR', 65000.00);
What is the average salary of female employees in the HR department?
SELECT AVG(Salary) FROM Employees WHERE Gender = 'Female' AND Department = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE media_content (id INT, genre VARCHAR(50), frequency INT); INSERT INTO media_content (id, genre, frequency) VALUES (1, 'Movie', 100), (2, 'TV Show', 30), (3, 'Documentary', 40);
What is the minimum frequency of content for each genre in the media_content table?
SELECT genre, MIN(frequency) FROM media_content GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tourism (country TEXT, revenue FLOAT, date DATE); INSERT INTO virtual_tourism (country, revenue, date) VALUES ('Spain', 25000.0, '2022-03-01'), ('Spain', 28000.0, '2022-04-01'), ('Italy', 18000.0, '2022-03-01'), ('Italy', 20000.0, '2022-04-01');
Virtual tourism revenue generated in Spain and Italy in the last 3 months?
SELECT country, SUM(revenue) FROM virtual_tourism WHERE date >= '2022-01-01' AND date <= '2022-04-01' AND country IN ('Spain', 'Italy') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE foia_requests (request_id INT, requester_name VARCHAR(100), request_date DATE, request_type VARCHAR(50), status VARCHAR(50));
Insert a new FOIA request with the following details: ID '65432', Requester Name 'Jane Smith', Request Date '2022-01-02', Request Type 'Legal Documents', Status 'Pending'.
INSERT INTO foia_requests (request_id, requester_name, request_date, request_type, status) VALUES (65432, 'Jane Smith', '2022-01-02', 'Legal Documents', 'Pending');
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(255), incident_date DATE, incident_source VARCHAR(255)); INSERT INTO incidents (incident_id, incident_type, incident_date, incident_source) VALUES (1, 'Phishing', '2022-01-01', 'External'), (2, 'Malware', '2022-01-05', 'External'), (3, 'SQL Injection', '202...
What is the percentage of security incidents caused by insiders in the last year?
SELECT PERCENTAGE(SUM(CASE WHEN incident_source = 'Internal' THEN 1 ELSE 0 END) OVER (), SUM(CASE WHEN incident_source IS NOT NULL THEN 1 ELSE 0 END) OVER ()) as insider_percentage FROM incidents WHERE incident_date >= DATEADD(year, -1, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperatures (ocean TEXT, temperature FLOAT); INSERT INTO ocean_temperatures (ocean, temperature) VALUES ('Indian Ocean', 27.0), ('Indian Ocean', 28.0);
What is the average temperature in the Indian Ocean?
SELECT AVG(temperature) FROM ocean_temperatures WHERE ocean = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, industry VARCHAR(20), num_employees INT); INSERT INTO unions (id, industry, num_employees) VALUES (1, 'manufacturing', 1000), (2, 'technology', 200), (3, 'healthcare', 3000), (4, 'retail', 500), (5, 'education', 800);
What is the number of employees who are members of unions in each industry?
SELECT industry, num_employees FROM unions;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (region VARCHAR(50), recycling_rate INT); INSERT INTO recycling_rates (region, recycling_rate) VALUES ('Asia', 45), ('EU', 50), ('NA', 55), ('Africa', 30), ('South America', 40);
Update recycling_rates table, setting the recycling_rate to 60 where the region is 'NA'
UPDATE recycling_rates SET recycling_rate = 60 WHERE region = 'NA';
gretelai_synthetic_text_to_sql
CREATE TABLE museum_visitors (id INT, exhibition_date DATE, is_bipoc BOOLEAN); INSERT INTO museum_visitors (id, exhibition_date, is_bipoc) VALUES (1, '2022-05-01', TRUE), (2, '2022-05-01', FALSE), (3, '2022-05-02', TRUE);
How many visitors identified as BIPOC attended the last three exhibitions at the local museum?
SELECT COUNT(*) FROM (SELECT * FROM museum_visitors WHERE exhibition_date IN ('2022-04-30', '2022-05-01', '2022-05-02') AND is_bipoc = TRUE) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Personnel (region TEXT, personnel INTEGER); INSERT INTO Military_Personnel (region, personnel) VALUES ('Middle East', 1000), ('Europe', 500), ('Asia', 750), ('Africa', 250), ('US', 1500), ('Canada', 300), ('South America', 100);
How many military personnel are stationed in each region?
SELECT region, personnel FROM Military_Personnel;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, category VARCHAR(50), cruelty_free BOOLEAN, preference_rating INT); INSERT INTO products (product_id, category, cruelty_free, preference_rating) VALUES (1, 'Eyeliner', true, 8), (2, 'Lipstick', false, 9), (3, 'Eyeshadow', true, 7);
What is the average preference rating for cruelty-free eyeliners?
SELECT AVG(products.preference_rating) FROM products WHERE products.category = 'Eyeliner' AND products.cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (site_id INT, site_name TEXT, period TEXT); INSERT INTO ExcavationSites (site_id, site_name, period) VALUES (1, 'SiteA', 'Iron Age'), (2, 'SiteB', 'Bronze Age'), (3, 'SiteC', 'Classic'), (4, 'SiteD', 'Post-Classic');
Update the period to 'Post-Classic' for all excavation sites with an ID greater than 2.
UPDATE ExcavationSites SET period = 'Post-Classic' WHERE site_id > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, name VARCHAR(255), type VARCHAR(255), manufacturer VARCHAR(255), quantity INT);
Insert data into 'military_equipment' for equipment_id 1, 'M1 Abrams', 'Tank', 'General Dynamics', 2000
INSERT INTO military_equipment (equipment_id, name, type, manufacturer, quantity) VALUES (1, 'M1 Abrams', 'Tank', 'General Dynamics', 2000);
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), menu_type VARCHAR(20), price DECIMAL(5,2), is_organic BOOLEAN); INSERT INTO menus (menu_id, menu_name, menu_type, price, is_organic) VALUES (1, 'Quinoa Salad', 'Vegetarian', 9.99, true), (2, 'Margherita Pizza', 'Non-vegetarian', 12.99, false), (3, 'Tofu Stir Fry',...
What is the minimum price of vegetarian menu items sourced from organic farms?
SELECT MIN(price) FROM menus WHERE menu_type = 'Vegetarian' AND is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (year INT, region TEXT, plastic_rate FLOAT, paper_rate FLOAT); INSERT INTO recycling_rates (year, region, plastic_rate, paper_rate) VALUES (2018, 'Asia', 0.35, 0.60), (2018, 'Europe', 0.55, 0.75), (2019, 'Asia', 0.40, 0.65), (2019, 'Europe', 0.60, 0.80), (2019, 'Oceania', NULL, NULL);
What is the plastic recycling rate in Oceania in 2019?
SELECT AVG(plastic_rate) FROM recycling_rates WHERE region = 'Oceania' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), source_country VARCHAR(50), publication_date DATE); INSERT INTO articles (id, title, source_country, publication_date) VALUES (1, 'Article1', 'USA', '2020-01-01'), (2, 'Article2', 'Canada', '2019-12-31'), (3, 'Article3', 'USA', '2020-02-01');
List the number of articles published in 2020, by each source country, in descending order of article count.
SELECT source_country, COUNT(*) as article_count FROM articles WHERE publication_date >= '2020-01-01' AND publication_date < '2021-01-01' GROUP BY source_country ORDER BY article_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), asset_value FLOAT, country VARCHAR(50)); INSERT INTO customers (id, name, asset_value, country) VALUES (1, 'Ravi Kumar', 50000.00, 'India'), (2, 'Sophia Lee', 75000.00, 'South Korea'), (3, 'Kenji Nakamura', 60000.00, 'Japan'), (4, 'Priya Gupta', 80000.00, 'India'), (5, ...
Identify the top 5 customers by total assets, ordered by the country they are from
SELECT id, name, asset_value, country FROM customers ORDER BY asset_value DESC, country;
gretelai_synthetic_text_to_sql
CREATE TABLE office (office_id INT, office_name VARCHAR(20)); INSERT INTO office (office_id, office_name) VALUES (1, 'boston'), (2, 'new_york');
What is the total number of cases handled by attorneys in the 'boston' office?
SELECT COUNT(*) FROM cases JOIN attorney ON cases.attorney_id = attorney.attorney_id WHERE attorney.office_id = (SELECT office_id FROM office WHERE office_name = 'boston');
gretelai_synthetic_text_to_sql
CREATE TABLE mines (mine_id INT, name TEXT, location TEXT, productivity FLOAT); INSERT INTO mines (mine_id, name, location, productivity) VALUES (1, 'ABC Mine', 'USA', 1200), (2, 'DEF Mine', 'Canada', 1500);
What is the total labor productivity for all mines?
SELECT SUM(productivity) FROM mines;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerGameType (PlayerID int, PlayerName varchar(50), Country varchar(50), GameType varchar(50), Wins int); INSERT INTO PlayerGameType (PlayerID, PlayerName, Country, GameType, Wins) VALUES (1, 'Mohamed Ahmed', 'Egypt', 'FPS', 10), (2, 'Aisha Mohamed', 'Kenya', 'Strategy', 15), (3, 'Kofi Ansah', 'Ghana', '...
What is the total number of wins in FPS games for players from Africa?
SELECT SUM(Wins) FROM PlayerGameType WHERE Country IN ('Egypt', 'Kenya', 'Ghana') AND GameType = 'FPS';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_weights (make VARCHAR(255), model VARCHAR(255), weight INT); INSERT INTO vehicle_weights (make, model, weight) VALUES ('Ford', 'Mustang', 3600), ('Ford', 'Explorer', 4400);
What is the total weight of the Ford Mustang?
SELECT weight FROM vehicle_weights WHERE make = 'Ford' AND model = 'Mustang';
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_materials (id INT, material VARCHAR(255), description VARCHAR(255), sourced_from VARCHAR(255), certified BOOLEAN); INSERT INTO green_building_materials (id, material, description, sourced_from, certified) VALUES (1, 'Recycled Steel', 'Strong and durable construction material made from recycl...
What are the names and descriptions of all certified green building materials sourced from Africa?
SELECT material, description FROM green_building_materials WHERE certified = true AND sourced_from = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionData (ID INT, Location VARCHAR(50), Pollutant VARCHAR(50), Level INT, MeasurementDate DATE); INSERT INTO PollutionData (ID, Location, Pollutant, Level, MeasurementDate) VALUES (1, 'NewYork', 'Mercury', 5, '2020-01-01'), (2, 'California', 'Lead', 10, '2020-01-02'), (3, 'Texas', 'CarbonMonoxide', 12...
List the locations with increasing pollution levels over time.
SELECT Location, Pollutant, Level, LEAD(Level) OVER (PARTITION BY Location ORDER BY MeasurementDate) as NextLevel FROM PollutionData;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID int, CaseType varchar(50), TotalBillingAmount numeric); INSERT INTO Cases VALUES (1, 'Civil', 7000), (2, 'Labor', 9000), (3, 'Civil', 8000), (4, 'Labor', 6000), (5, 'Civil', 10000), (6, 'Labor', 11000);
What is the total billing amount for cases in civil law, compared to those in labor law?
SELECT SUM(CASE WHEN CaseType = 'Civil' THEN TotalBillingAmount ELSE 0 END) AS CivilTotalBillingAmount, SUM(CASE WHEN CaseType = 'Labor' THEN TotalBillingAmount ELSE 0 END) AS LaborTotalBillingAmount FROM Cases;
gretelai_synthetic_text_to_sql
CREATE TABLE farmland (farmland_id INT, country VARCHAR(255), precipitation INT, light_intensity INT); INSERT INTO farmland (farmland_id, country, precipitation, light_intensity) VALUES (1, 'India', 50, 1000), (2, 'Nepal', 100, 800), (3, 'Bangladesh', 75, 1200), (4, 'Pakistan', 60, 900);
What's the average precipitation and light intensity for each farm in the farmland table?
SELECT AVG(farmland.precipitation) AS avg_precipitation, AVG(farmland.light_intensity) AS avg_light_intensity, farmland.country FROM farmland GROUP BY farmland.country;
gretelai_synthetic_text_to_sql
CREATE TABLE bioprocess_engineering (name VARCHAR(255), year INT, budget FLOAT); INSERT INTO bioprocess_engineering (name, year, budget) VALUES ('ProjectA', 2019, 8000000), ('ProjectB', 2020, 9000000), ('ProjectC', 2019, 10000000);
What is the total budget for bioprocess engineering projects in 2019?
SELECT SUM(budget) FROM bioprocess_engineering WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, is_upcycled BOOLEAN, country TEXT); INSERT INTO products (product_id, name, is_upcycled, country) VALUES (1, 'Vintage Denim Jacket', true, 'Italy');
Which country has the highest number of upcycled products?
SELECT country, COUNT(*) as count FROM products WHERE is_upcycled = true GROUP BY country ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_stations (station_id INT, station_name VARCHAR(255)); CREATE TABLE bike_inventory (inventory_id INT, station_id INT, bike_count INT); INSERT INTO bike_stations VALUES (1, 'Station 1'); INSERT INTO bike_stations VALUES (2, 'Station 2'); INSERT INTO bike_inventory VALUES (1, 1, 20); INSERT INTO bike_inv...
What is the total number of bikes available for each station in the bike sharing system?
SELECT station_name, SUM(bike_count) as total_bikes FROM bike_stations s JOIN bike_inventory i ON s.station_id = i.station_id GROUP BY s.station_name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(255), age INT, state VARCHAR(2));
Insert a new record into the 'community_health_workers' table with the following information: ID 123, Name 'Sandra Lee', Age 35, State 'NY'
INSERT INTO community_health_workers (id, name, age, state) VALUES (123, 'Sandra Lee', 35, 'NY');
gretelai_synthetic_text_to_sql
CREATE TABLE education_union (employee_id INT, department VARCHAR(20)); INSERT INTO education_union (employee_id, department) VALUES (1, 'Education'), (2, 'Education'), (3, 'Education'), (4, 'Admin'), (5, 'Admin');
What is the count of 'Education' department in the 'education_union' table?
SELECT COUNT(*) FROM education_union WHERE department = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE precipitation_data (id INT, farm_id INT, precipitation_level INT, time_stamp DATETIME); INSERT INTO precipitation_data (id, farm_id, precipitation_level, time_stamp) VALUES (1, 1, 10, '2022-03-15 12:00:00'), (2, 2, 15, '2022-03-15 13:00:00'), (3, 3, 8, '2022-03-15 14:00:00');
Delete all records in the precipitation_data table for farms in 'Kansas'.
DELETE FROM precipitation_data WHERE farm_id IN (SELECT id FROM farm_locations WHERE state = 'Kansas');
gretelai_synthetic_text_to_sql
CREATE TABLE FactoryRatings (factory_id INT, rating DECIMAL(2,1), fair_labor ENUM('yes','no'));
What is the average rating of factories that have implemented fair labor practices?
SELECT AVG(rating) FROM FactoryRatings WHERE fair_labor = 'yes';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50));CREATE TABLE artworks (id INT, title VARCHAR(50), artist_id INT); INSERT INTO artists (id, name) VALUES (1, 'Pablo Picasso');
Insert a new artwork of an artist.
INSERT INTO artworks (id, title, artist_id) VALUES (1, 'Guernica', 1);
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjects (id INT, project_name VARCHAR(100), project_type VARCHAR(50), city VARCHAR(50), country VARCHAR(50), capacity INT);
List the number of renewable energy projects for each type in 'Canada'
SELECT project_type, COUNT(*) FROM RenewableEnergyProjects WHERE country = 'Canada' GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE barents_sea_biomass (species VARCHAR(50), year INT, biomass FLOAT);
What is the total biomass of cod and herring in the Barents Sea in 2020?
SELECT SUM(CASE WHEN species IN ('cod', 'herring') THEN biomass ELSE 0 END) FROM barents_sea_biomass WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, origin VARCHAR(50), destination VARCHAR(50), distance INT, eta DATE); INSERT INTO routes (route_id, origin, destination, distance, eta) VALUES (1, 'Los Angeles', 'Chicago', 2000, '2022-06-25'); INSERT INTO routes (route_id, origin, destination, distance, eta) VALUES (2, 'Miami', 'Dall...
Delete records in the "routes" table where the eta is older than the current date
DELETE FROM routes WHERE eta < CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, username VARCHAR(20), email VARCHAR(50), follower_count INT); CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_time TIMESTAMP); CREATE TABLE comments (comment_id INT, post_id INT, user_id INT, comment TEXT, comment_time TIMESTAMP); CREATE TABLE reactions (reaction_id INT...
Create a table named moderation_actions with columns action_id, user_id, post_id, action_type, and action_time.
CREATE TABLE moderation_actions (action_id INT, user_id INT, post_id INT, action_type ENUM('delete', 'report', 'ban'), action_time TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_initiatives (initiative_id INT, launch_date DATE); INSERT INTO financial_wellbeing_initiatives (initiative_id, launch_date) VALUES (1, '2021-01-15'), (2, '2021-03-30');
How many financial wellbeing initiatives were launched in Q1 2021?
SELECT COUNT(*) FROM financial_wellbeing_initiatives WHERE launch_date BETWEEN '2021-01-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE region (region_id INT, name VARCHAR(255)); INSERT INTO region (region_id, name) VALUES (1, 'Sahel'); CREATE TABLE camp (camp_id INT, name VARCHAR(255), region_id INT, capacity INT); INSERT INTO camp (camp_id, name, region_id, capacity) VALUES (1, 'Camp1', 1, 500), (2, 'Camp2', 1, 700);
Which refugee camps in the Sahel region have a capacity greater than 500?
SELECT name FROM camp WHERE region_id = (SELECT region_id FROM region WHERE name = 'Sahel') AND capacity > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityIncidents (country VARCHAR(50), incidents INT, year INT); INSERT INTO CybersecurityIncidents (country, incidents, year) VALUES ('USA', 5632, 2021); INSERT INTO CybersecurityIncidents (country, incidents, year) VALUES ('China', 2156, 2021); INSERT INTO CybersecurityIncidents (country, incidents...
Who are the top 5 countries with the highest number of cybersecurity incidents in the 'CybersecurityIncidents' table?
SELECT country, incidents FROM CybersecurityIncidents WHERE year = 2021 ORDER BY incidents DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, program VARCHAR(50), attendee INT); INSERT INTO Events (id, program, attendee) VALUES (1, 'Art Exhibition', 123), (2, 'Music Concert', 234), (3, 'Art Exhibition', 345);
How many times has each program been attended by a unique attendee?
SELECT program, COUNT(DISTINCT attendee) as unique_attendees FROM Events GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonationDate date);
How many new donors made their first donation in Q3 2021?
SELECT COUNT(DISTINCT DonorID) FROM Donors WHERE DonationDate BETWEEN '2021-10-01' AND '2021-12-31' AND DonorID NOT IN (SELECT DonorID FROM Donors WHERE DonationDate < '2021-10-01');
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, subject_area TEXT, course_type TEXT); INSERT INTO courses VALUES (1, 'Math', 'Open Pedagogy'); INSERT INTO courses VALUES (2, 'English', 'Traditional'); INSERT INTO courses VALUES (3, 'Science', 'Open Pedagogy'); INSERT INTO courses VALUES (4, 'History', 'Traditional');
What is the number of open pedagogy courses offered per subject area?
SELECT subject_area, COUNT(*) as num_courses FROM courses WHERE course_type = 'Open Pedagogy' GROUP BY subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), carbon_sequestration FLOAT, habitat_id INT); INSERT INTO species (id, name, carbon_sequestration, habitat_id) VALUES (1, 'Species1', 123.45, 1); INSERT INTO species (id, name, carbon_sequestration, habitat_id) VALUES (2, 'Species2', 234.56, 2); CREATE TABLE habitat (id I...
Which species have a higher carbon sequestration than the habitat average?
SELECT s.name, s.carbon_sequestration FROM species s JOIN habitat h ON s.habitat_id = h.id WHERE s.carbon_sequestration > h.carbon_sequestration_avg;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cargo (id INT, vessel_id INT, port_id INT, cargo_type VARCHAR(255), weight INT); INSERT INTO cargo (id, vessel_id, port_id, cargo_type, weight) VALUES (1, 1, 1, 'Containers', 10000); INSERT INTO cargo (id, vessel_id, port_id, cargo_type, weight) VALUES (2, 2, 2, 'Coal', 20000); CREATE VIEW ca...
What is the total number of cargo by type?
SELECT * FROM cargo_by_type;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, founded_year INT, industry TEXT, total_funding DECIMAL(10,2)); INSERT INTO startups (id, name, founded_year, industry, total_funding) VALUES (1, 'Acme Inc', 2010, 'Tech', 1500000.00); INSERT INTO startups (id, name, founded_year, industry, total_funding) VALUES (2, 'Beta Corp', ...
What is the maximum funding round for startups in the 'Healthcare' sector founded after 2017?
SELECT MAX(total_funding) FROM startups WHERE industry = 'Healthcare' AND founded_year > 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Negotiations (Id INT, UnionId INT, Duration INT); INSERT INTO Negotiations (Id, UnionId, Duration) VALUES (1, 2, 120), (2, 2, 180), (3, 3, 90), (4, 3, 210), (5, 3, 150), (6, 3, 130);
What is the maximum and minimum duration of collective bargaining negotiations for Union C?
SELECT MIN(Duration) as MinDuration, MAX(Duration) as MaxDuration FROM Negotiations WHERE UnionId = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryMilitary (Country VARCHAR(50) PRIMARY KEY, Technology VARCHAR(50));
Show countries involved in more than 5 military technologies
SELECT Country FROM CountryMilitary GROUP BY Country HAVING COUNT(*) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Community VARCHAR(255)); INSERT INTO Employees (EmployeeID, Department, Community) VALUES (1, 'Mining Operations', 'Underrepresented Community A'), (2, 'Mining Operations', 'Underrepresented Community B'), (3, 'Mining Operations', 'Represented Community')...
What is the total number of employees in the Mining Operations department from all underrepresented communities?
SELECT Department, SUM(CASE WHEN Community IN ('Underrepresented Community A', 'Underrepresented Community B') THEN 1 ELSE 0 END) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (id INT, country VARCHAR(255), year INT, success BOOLEAN); INSERT INTO SatelliteDeployments VALUES (1, 'Nigeria', 2007, true), (2, 'Egypt', 2009, true), (3, 'South Africa', 2012, false), (4, 'Algeria', 2015, true);
How many successful satellite deployments occurred in Africa before 2010?
SELECT COUNT(*) FROM SatelliteDeployments WHERE country IN ('Nigeria', 'Egypt', 'South Africa', 'Algeria') AND success = true AND year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, employment_status VARCHAR(50)); INSERT INTO Employees (id, name, department, salary, employment_status) VALUES (1, 'John Doe', 'Mining', 75000.00, 'Full-time'), (2, 'Jane Smith', 'HR', 60000.00, 'Full-time'), (3, 'Mike Johnson', 'Mi...
How many employees work in the Mining department compared to the HR department and IT department?
SELECT department, COUNT(*) FROM Employees GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE research (id INT PRIMARY KEY, company_id INT, title VARCHAR(255), lead_researcher VARCHAR(255), start_date DATE); CREATE TABLE gene (id INT PRIMARY KEY, name VARCHAR(255), function VARCHAR(255), company_id INT, research_id INT); INSERT INTO research (id, company_id, title, lead_researcher, start_date) VALU...
Who is the lead researcher for the project with the most genes involved?
SELECT lead_researcher FROM research r JOIN gene g ON r.id = g.research_id GROUP BY r.id HAVING COUNT(g.id) = (SELECT MAX(research_gene_count) FROM (SELECT research_id, COUNT(*) AS research_gene_count FROM gene GROUP BY research_id) research_genes);
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_impact (city VARCHAR(100), year INT, local_economic_impact INT); INSERT INTO tourism_impact (city, year, local_economic_impact) VALUES ('Paris', 2020, 12000000); INSERT INTO tourism_impact (city, year, local_economic_impact) VALUES ('London', 2020, 10000000); INSERT INTO tourism_impact (city, year,...
What is the local economic impact of tourism in New Delhi in 2020?
SELECT local_economic_impact FROM tourism_impact WHERE city = 'New Delhi' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE marcellus_shale_gas_production (well VARCHAR(255), year INT, production FLOAT);
What is the average gas production per well in the Marcellus Shale for 2020?
SELECT AVG(production) FROM marcellus_shale_gas_production WHERE well LIKE '%Marcellus Shale%' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE game_sessions (user_id INT, game_name VARCHAR(10), login_date DATE); INSERT INTO game_sessions (user_id, game_name, login_date) VALUES (1, 'A', '2021-01-01'), (2, 'B', '2021-01-02'), (3, 'B', '2021-01-03'), (4, 'C', '2021-01-04'), (5, 'A', '2021-01-05'), (6, 'D', '2021-01-06'), (7, 'D', '2021-01-07');
List all unique users who played any game in the first week of January 2021
SELECT DISTINCT user_id FROM game_sessions WHERE login_date BETWEEN '2021-01-01' AND '2021-01-07';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesByMaterial (SaleID INT, Material VARCHAR(50), Sales DECIMAL(5,2)); INSERT INTO SalesByMaterial (SaleID, Material, Sales) VALUES (1, 'Organic Cotton', 1200.50), (2, 'Hemp', 752.20), (3, 'Recycled Polyester', 986.60), (4, 'Tencel', 310.10);
What is the percentage of sales by ethical material?
SELECT Material, ROUND(SUM(Sales) / (SELECT SUM(Sales) FROM SalesByMaterial) * 100, 2) AS Percentage FROM SalesByMaterial GROUP BY Material;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production(year INT, volume INT); INSERT INTO timber_production(year, volume) VALUES (2018, 5000), (2019, 5500), (2020, 6000);
What is the total volume of timber production for each year?
SELECT year, SUM(volume) FROM timber_production GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (id INT, name VARCHAR, location VARCHAR); INSERT INTO mental_health_facilities (id, name, location) VALUES (1, 'Facility One', 'Urban'); INSERT INTO mental_health_facilities (id, name, location) VALUES (2, 'Facility Two', 'Rural');
What is the total number of mental health facilities in urban areas?
SELECT COUNT(*) as total_facilities FROM mental_health_facilities WHERE location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT, program_id INT, source VARCHAR(255), amount DECIMAL(10, 2), date DATE);
Which art programs received funding from the 'NEA' source since 2018?
SELECT f.program_id, p.name, f.source, f.amount FROM funding f INNER JOIN programs p ON f.program_id = p.id WHERE f.source = 'NEA' AND f.date >= '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE budgets_program (budget_id INT, program TEXT, allocated_amount DECIMAL); INSERT INTO budgets_program (budget_id, program, allocated_amount) VALUES (1, 'Program B', 10000.00), (2, 'Program C', 7500.00), (3, 'Program B', 2500.00), (4, 'Program C', 1500.00);
What is the total budget allocated to program B and program C?
SELECT SUM(allocated_amount) FROM budgets_program WHERE program IN ('Program B', 'Program C');
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, name TEXT, safety_violation BOOLEAN, union_affiliation TEXT); INSERT INTO workplaces (id, name, safety_violation, union_affiliation) VALUES (1, 'ABC Company', TRUE, 'Union A'), (2, 'XYZ Corporation', FALSE, 'Union B'), (3, 'LMN Industries', TRUE, 'Union A');
Delete all records of workplaces with a specific union affiliation.
DELETE FROM workplaces WHERE union_affiliation = 'Union A';
gretelai_synthetic_text_to_sql