context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE projects (project_id INT, project_name VARCHAR(50), discipline VARCHAR(20), open_pedagogy BOOLEAN); INSERT INTO projects (project_id, project_name, discipline, open_pedagogy) VALUES (1, 'Project A', 'Math', TRUE), (2, 'Project B', 'English', FALSE), (3, 'Project C', 'Science', TRUE);
What is the distribution of open pedagogy projects by discipline?
SELECT discipline, COUNT(*) FROM projects WHERE open_pedagogy = TRUE GROUP BY discipline;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, region TEXT, climate_impact BOOLEAN); INSERT INTO marine_species (name, region, climate_impact) VALUES ('Green Sea Turtle', 'Atlantic', TRUE); INSERT INTO marine_species (name, region, climate_impact) VALUES ('Humpback Whale', 'Atlantic', FALSE);
List all the marine species in the 'Atlantic' region that have been impacted by climate change.
SELECT name FROM marine_species WHERE region = 'Atlantic' AND climate_impact = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE species_observations (id INT PRIMARY KEY, expedition_id INT, species VARCHAR(100), count INT); INSERT INTO species_observations (id, expedition_id, species, count) VALUES (1, 1, 'Snowy Owl', 6), (2, 2, 'Arctic Fox', 3);
Delete the records from the species_observations table where the species count is less than 5.
DELETE FROM species_observations WHERE count < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, country TEXT); INSERT INTO virtual_tours (tour_id, tour_name, country) VALUES (1, 'Virtual Tour 1', 'Russia'), (2, 'Virtual Tour 2', 'South Korea');
How many virtual tours are available in Russia and South Korea?
SELECT COUNT(*) FROM virtual_tours WHERE country IN ('Russia', 'South Korea');
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), LaunchDate DATETIME, Type VARCHAR(50), Lifespan INT); INSERT INTO Satellites (SatelliteID, Name, LaunchDate, Type, Lifespan) VALUES (1, 'Sat1', '2020-01-01', 'Communication', 10), (2, 'Sat2', '2019-05-15', 'Communication', 12);
What is the average lifespan of communication satellites?
SELECT AVG(Lifespan) FROM Satellites WHERE Type = 'Communication';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_types (id INT, type VARCHAR(255)); INSERT INTO waste_types (id, type) VALUES (1, 'Plastic'), (2, 'Paper'), (3, 'Glass'), (4, 'Metal'); CREATE TABLE landfill (id INT, waste_type_id INT, weight INT, recycled INT); INSERT INTO landfill (id, waste_type_id, weight, recycled) VALUES (1, 1, 1000, 200), (2, 1, 1500, 300), (3, 2, 800, 400), (4, 2, 1200, 500), (5, 3, 1300, 600), (6, 3, 1700, 800), (7, 4, 1100, 900), (8, 4, 1400, 1000);
What is the recycling rate for each waste type in the landfill?
SELECT waste_type_id, (SUM(recycled) OVER (PARTITION BY waste_type_id) * 100.0 / SUM(weight) OVER (PARTITION BY waste_type_id)) as recycling_rate FROM landfill;
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy (Country VARCHAR(20), Technology VARCHAR(20), Capacity INT); INSERT INTO Renewable_Energy VALUES ('China', 'Solar', 250000), ('USA', 'Wind', 120000), ('Germany', 'Solar', 60000), ('India', 'Wind', 50000), ('Spain', 'Solar', 35000);
What are the top 3 countries with the highest renewable energy capacity?
SELECT Country, SUM(Capacity) AS Total_Capacity FROM Renewable_Energy GROUP BY Country ORDER BY Total_Capacity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE packages (id INT, package_status VARCHAR(20), delivery_date DATE); INSERT INTO packages (id, package_status, delivery_date) VALUES (1, 'delayed', '2022-06-15'); INSERT INTO packages (id, package_status, delivery_date) VALUES (2, 'in transit', '2022-06-20'); INSERT INTO packages (id, package_status, delivery_date) VALUES (3, 'delayed', '2022-06-18');
Update the package status to "delivered" for records in the "packages" table where the package status is "in transit" and the delivery date is today
UPDATE packages SET package_status = 'delivered' WHERE package_status = 'in transit' AND delivery_date = CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE student_accommodations (student_id INT, accommodation_year INT, accommodation_type VARCHAR(255)); INSERT INTO student_accommodations (student_id, accommodation_year, accommodation_type) VALUES (1, 2021, 'Hearing'), (2, 2021, 'Visual'), (3, 2020, 'Mobility');
Update the accommodation type for student 1 to 'Visual'
UPDATE student_accommodations SET accommodation_type = 'Visual' WHERE student_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE california_legal_aid (id INT, location VARCHAR(255), count INT); INSERT INTO california_legal_aid (id, location, count) VALUES (1, 'Urban', 150), (2, 'Rural', 50);CREATE TABLE texas_legal_aid (id INT, location VARCHAR(255), count INT); INSERT INTO texas_legal_aid (id, location, count) VALUES (1, 'Urban', 200), (2, 'Rural', 100);
How many legal aid clinics are there in urban and rural areas of California and Texas?
SELECT 'California' AS state, location, SUM(count) AS total_clinics FROM california_legal_aid GROUP BY location UNION ALL SELECT 'Texas' AS state, location, SUM(count) AS total_clinics FROM texas_legal_aid GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE NeodymiumProduction (Company VARCHAR(50), Year INT, Production FLOAT); INSERT INTO NeodymiumProduction(Company, Year, Production) VALUES ('CompanyA', 2018, 120.5), ('CompanyA', 2019, 145.2), ('CompanyA', 2020, 162.3), ('CompanyB', 2018, 98.7), ('CompanyB', 2019, 112.9), ('CompanyB', 2020, 128.6);
What is the total production of Neodymium in 2020, for companies located in North America?
SELECT SUM(Production) FROM NeodymiumProduction WHERE Year = 2020 AND Company IN (SELECT DISTINCT Company FROM NeodymiumProduction WHERE Country IN ('USA', 'Canada', 'Mexico'));
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, first_name VARCHAR(20), last_name VARCHAR(20), country VARCHAR(20)); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2));
Which countries have the most individual donors?
SELECT d.country, COUNT(d.id) as donor_count FROM donors d JOIN donations don ON d.id = don.donor_id GROUP BY d.country ORDER BY donor_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (OrgID INT, OrgName TEXT, Country TEXT, Spending FLOAT, LastUpdate DATE); INSERT INTO Organizations (OrgID, OrgName, Country, Spending, LastUpdate) VALUES (1, 'Microsoft', 'USA', 800000, '2020-01-01'); INSERT INTO Organizations (OrgID, OrgName, Country, Spending, LastUpdate) VALUES (2, 'Google', 'USA', 900000, '2019-01-01'); INSERT INTO Organizations (OrgID, OrgName, Country, Spending, LastUpdate) VALUES (3, 'IBM', 'USA', 700000, '2021-01-01'); INSERT INTO Organizations (OrgID, OrgName, Country, Spending, LastUpdate) VALUES (4, 'TCS', 'India', 500000, '2020-01-01');
Find the top 3 organizations with the highest spending on accessibility features in technology in the last 5 years.
SELECT OrgName, Spending FROM (SELECT OrgName, Spending, ROW_NUMBER() OVER (ORDER BY Spending DESC) as rn FROM Organizations WHERE LastUpdate >= (SELECT DATEADD(year, -5, GETDATE())) AND Country = 'USA') t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor (id INT, region VARCHAR(255), type VARCHAR(255)); INSERT INTO sensor (id, region, type) VALUES (1, 'North', 'temperature'), (2, 'South', 'humidity'), (3, 'East', 'moisture'), (4, 'North', 'moisture'), (5, 'North', 'temperature'), (6, 'South', 'temperature');
Count the number of sensors in the North and South regions
SELECT region, COUNT(*) FROM sensor WHERE region IN ('North', 'South') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, equipment_type VARCHAR(50)); CREATE TABLE maintenance_records (record_id INT, equipment_id INT, maintenance_date DATE); INSERT INTO military_equipment (equipment_id, equipment_type) VALUES (1, 'Fighter Jet'), (2, 'Submarine'), (3, 'Tank'); INSERT INTO maintenance_records (record_id, equipment_id, maintenance_date) VALUES (1, 1, '2021-08-01'), (2, 2, '2021-12-15'), (3, 1, '2021-11-28');
List the military equipment types that have not required maintenance in the last 3 months, ordered by equipment_type
SELECT military_equipment.equipment_type FROM military_equipment LEFT JOIN maintenance_records ON military_equipment.equipment_id = maintenance_records.equipment_id WHERE maintenance_records.maintenance_date IS NULL OR maintenance_records.maintenance_date < DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY military_equipment.equipment_type ORDER BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_prices (id INT, product VARCHAR(255), organic BOOLEAN, price FLOAT, country VARCHAR(255)); INSERT INTO skincare_prices (id, product, organic, price, country) VALUES (1, 'Face Wash', true, 15.99, 'USA'), (2, 'Lotion', false, 10.99, 'USA'), (3, 'Sunscreen', true, 20.99, 'USA');
What is the maximum price of organic skincare products sold in the US?
SELECT MAX(price) FROM skincare_prices WHERE organic = true AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, page_name VARCHAR(255), content TEXT); CREATE TABLE likes (id INT, user_id INT, post_id INT); CREATE TABLE hashtags (id INT, post_id INT, tag VARCHAR(255));
Which users liked posts with hashtag #movies and interacted with posts from the 'movies' page, excluding users who have liked more than 50 posts?
SELECT DISTINCT users.id, users.name FROM users JOIN likes ON users.id = likes.user_id JOIN posts ON likes.post_id = posts.id JOIN hashtags ON posts.id = hashtags.post_id WHERE hashtags.tag = 'movies' AND posts.page_name = 'movies' AND users.id NOT IN (SELECT user_id FROM likes GROUP BY user_id HAVING COUNT(*) > 50);
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(20)); INSERT INTO factories VALUES (1, 'textiles'), (2, 'metalwork'), (3, 'textiles'), (4, 'electronics'), (5, 'textiles'); CREATE TABLE workers (worker_id INT, factory_id INT); INSERT INTO workers VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3), (7, 4), (8, 4), (9, 5), (10, 5), (11, 5);
How many workers are there in each factory?
SELECT factory_id, COUNT(*) FROM workers GROUP BY factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name TEXT, city TEXT, country TEXT);CREATE TABLE art_pieces (id INT, title TEXT, medium TEXT, artist_id INT, museum_id INT, value FLOAT);
Which museum in New York City has the highest average art piece value?
SELECT m.name, AVG(ap.value) as avg_value FROM museums m JOIN art_pieces ap ON m.id = ap.museum_id WHERE m.city = 'New York City' GROUP BY m.name ORDER BY avg_value DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vendor_data (vendor_id INT, vendor_location VARCHAR(20));
Delete all records from the 'vendor_data' table where 'vendor_location' is 'USA'
DELETE FROM vendor_data WHERE vendor_location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE books (id INT, title VARCHAR(255), genre VARCHAR(255), press_location VARCHAR(255)); INSERT INTO books (id, title, genre, press_location) VALUES (1, 'Book1', 'Fiction', 'Mexico'), (2, 'Book2', 'Non-fiction', 'Argentina'); CREATE TABLE presses (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO presses (id, name, location) VALUES (1, 'Press1', 'Mexico'), (2, 'Press2', 'Argentina');
List the genres and number of books published by presses in Mexico and Argentina.
SELECT genre, COUNT(*) as total FROM books JOIN presses ON books.press_location = presses.location WHERE presses.location IN ('Mexico', 'Argentina') GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, menu_item_id INT, sale_amount DECIMAL(10, 2), sale_date DATE); INSERT INTO sales VALUES (1, 1, 50.00, '2022-03-01'), (2, 2, 75.00, '2022-03-02'), (3, 3, 60.00, '2022-03-03'), (4, 4, 100.00, '2022-03-04'); CREATE TABLE menu_items (menu_item_id INT, menu_item_name VARCHAR(255), category VARCHAR(255), is_plant_based INT); INSERT INTO menu_items VALUES (1, 'Veggie Burger', 'Entrees', 1), (2, 'Tomato Soup', 'Soups', 0), (3, 'Caesar Salad', 'Salads', 0), (4, 'Vegan Chili', 'Entrees', 1);
What is the percentage of sales for each menu item that is plant-based?
SELECT m1.menu_item_id, m1.menu_item_name, (SUM(s1.sale_amount) / SUM(s2.sale_amount)) * 100 AS sales_percentage FROM sales s1 INNER JOIN menu_items m1 ON s1.menu_item_id = m1.menu_item_id INNER JOIN sales s2 ON m1.menu_item_id = s2.menu_item_id INNER JOIN menu_items m2 ON s2.menu_item_id = m2.menu_item_id WHERE m2.is_plant_based = 1 GROUP BY m1.menu_item_id, m1.menu_item_name;
gretelai_synthetic_text_to_sql
CREATE TABLE country_sales (id INT, genre TEXT, digital FLOAT, physical FLOAT, location TEXT); INSERT INTO country_sales (id, genre, digital, physical, location) VALUES (1, 'Country', 35000.0, 20000.0, 'USA'), (2, 'Country', 40000.0, 30000.0, 'Canada'), (3, 'Country', 50000.0, 15000.0, 'USA');
What is the total revenue for country music from digital sales in the USA?
SELECT SUM(digital) FROM country_sales WHERE genre = 'Country' AND location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_immigrant TEXT); INSERT INTO company (id, name, industry, founder_immigrant) VALUES (1, 'CureCo', 'Healthtech', 'Yes'); CREATE TABLE investment_round (id INT, company_id INT, amount_raised FLOAT); INSERT INTO investment_round (id, company_id, amount_raised) VALUES (1, 1, 1500000);
What is the total funding received by startups in the healthtech sector founded by immigrants?
SELECT SUM(ir.amount_raised) FROM company c JOIN investment_round ir ON c.id = ir.company_id WHERE c.industry = 'Healthtech' AND c.founder_immigrant = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, investment_amount FLOAT, area_type VARCHAR(255)); INSERT INTO network_investments (investment_id, investment_amount, area_type) VALUES (1, 1000000, 'Urban'), (2, 800000, 'Rural'), (3, 1200000, 'Urban'), (4, 700000, 'Rural');
What is the percentage of network infrastructure investments in urban areas compared to rural areas?
SELECT (SUM(CASE WHEN area_type = 'Urban' THEN investment_amount ELSE 0 END) / SUM(investment_amount)) * 100 AS urban_percentage, (SUM(CASE WHEN area_type = 'Rural' THEN investment_amount ELSE 0 END) / SUM(investment_amount)) * 100 AS rural_percentage FROM network_investments;
gretelai_synthetic_text_to_sql
CREATE TABLE FLAG_STATES (ID INT, NAME VARCHAR(50), CONTINENT VARCHAR(50)); INSERT INTO FLAG_STATES VALUES (1, 'Panama', 'Americas'); INSERT INTO FLAG_STATES VALUES (2, 'Singapore', 'Asia');
Display the number of unique ports visited by vessels, grouped by flag state.
SELECT F.NAME AS FLAG_STATE, COUNT(DISTINCT P.PORT) AS PORT_COUNT, RANK() OVER(ORDER BY COUNT(DISTINCT P.PORT) DESC) AS RANK FROM PORT_CALLS PC JOIN VESSELS V ON PC.VESSEL_ID = V.ID JOIN FLAG_STATES F ON V.FLAG_STATE = F.NAME GROUP BY F.ID, F.NAME
gretelai_synthetic_text_to_sql
CREATE TABLE building_efficiency (building_type VARCHAR(255), year INT, efficiency FLOAT); INSERT INTO building_efficiency (building_type, year, efficiency) VALUES ('Residential', 2020, 0.7), ('Residential', 2020, 0.75), ('Commercial', 2020, 0.6), ('Commercial', 2020, 0.65);
What was the energy efficiency of buildings by type in 2020?
SELECT building_type, AVG(efficiency) as avg_efficiency FROM building_efficiency WHERE year = 2020 GROUP BY building_type;
gretelai_synthetic_text_to_sql
CREATE TABLE CE_UK (initiative VARCHAR(100), location VARCHAR(50)); INSERT INTO CE_UK (initiative, location) VALUES ('Waste Electrical and Electronic Equipment Recycling', 'UK'), ('Textile Recycling', 'UK'), ('Food Waste Reduction', 'UK');
Identify the circular economy initiatives in the United Kingdom.
SELECT initiative FROM CE_UK;
gretelai_synthetic_text_to_sql
CREATE TABLE Mining_Operation (Operation_ID INT, Mine_Name VARCHAR(50), Location VARCHAR(50), Operation_Type VARCHAR(50), Start_Date DATE, End_Date DATE); CREATE TABLE Environmental_Impact (Impact_ID INT, Operation_ID INT, Date DATE, Carbon_Emissions INT, Water_Usage INT, Waste_Generation INT);
Find the daily change in water usage for the South African mining operations.
SELECT Operation_ID, Date, Water_Usage, LAG(Water_Usage, 1) OVER (PARTITION BY Operation_ID ORDER BY Date) AS Previous_Day_Water, (Water_Usage - LAG(Water_Usage, 1) OVER (PARTITION BY Operation_ID ORDER BY Date)) AS Daily_Change_Water FROM Environmental_Impact WHERE Location = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(255), Country VARCHAR(255), SustainabilityRating DECIMAL(3,2));
Rank suppliers by their sustainable sourcing rating, for suppliers from India.
SELECT SupplierName, Country, SustainabilityRating, RANK() OVER (ORDER BY SustainabilityRating DESC) as SustainabilityRank FROM Suppliers WHERE Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(255), organic_products INT); CREATE TABLE products (id INT, supplier_id INT, is_organic BOOLEAN); INSERT INTO suppliers (id, name, organic_products) VALUES (1, 'Supplier A', NULL), (2, 'Supplier B', NULL), (3, 'Supplier C', NULL); INSERT INTO products (id, supplier_id, is_organic) VALUES (1, 1, true), (2, 1, true), (3, 1, false), (4, 2, true), (5, 2, true), (6, 2, false), (7, 3, false), (8, 3, false), (9, 3, false);
List the suppliers and the number of non-organic products they offer
SELECT s.name, COUNT(p.id) AS total_non_organic_products FROM suppliers s JOIN products p ON s.id = p.supplier_id AND p.is_organic = false GROUP BY s.id;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (country VARCHAR(50), year INT, total_waste INT); INSERT INTO waste_generation (country, year, total_waste) VALUES ('USA', 2015, 250000), ('Canada', 2015, 150000), ('USA', 2016, 260000);
What is the total waste generation in North America for each year?
SELECT year, SUM(total_waste) FROM waste_generation WHERE country IN ('USA', 'Canada', 'Mexico') GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_dim (supplier_id INT, supplier_name VARCHAR, supplier_country VARCHAR);
Find the average inventory quantity for each menu category, from the inventory_fact table, grouped by menu_category.
SELECT m.menu_category, AVG(i.inventory_quantity) as avg_inventory_quantity FROM inventory_fact i JOIN menu_item_dim m ON i.menu_item_id = m.menu_item_id GROUP BY m.menu_category;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, vendor_name VARCHAR(255), contract_date DATE);
Find defense contractors who received contracts in the current year but not in the previous year
SELECT vendor_name FROM defense_contracts WHERE YEAR(contract_date) = YEAR(CURRENT_DATE) AND vendor_name NOT IN (SELECT vendor_name FROM defense_contracts WHERE YEAR(contract_date) = YEAR(DATEADD(year, -1, CURRENT_DATE)));
gretelai_synthetic_text_to_sql
CREATE TABLE military_weapon_systems (system_id INT PRIMARY KEY, system_name VARCHAR(100), system_type VARCHAR(50), manufacturer VARCHAR(100));
Add a new weapon system to the 'military_weapon_systems' table with 'system_name' 'Javelin', 'system_type' 'Anti-tank missile', 'manufacturer' 'Lockheed Martin'
INSERT INTO military_weapon_systems (system_name, system_type, manufacturer) VALUES ('Javelin', 'Anti-tank missile', 'Lockheed Martin');
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Region VARCHAR(255), MentalHealthScore INT); INSERT INTO CommunityHealthWorkers (WorkerID, Region, MentalHealthScore) VALUES (1, 'North', 80), (2, 'South', 85), (3, 'East', 70), (4, 'West', 90);
What is the average mental health score for community health workers by region, ordered by the highest average score?
SELECT Region, AVG(MentalHealthScore) as AvgScore FROM CommunityHealthWorkers GROUP BY Region ORDER BY AvgScore DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Articles (id INT, title VARCHAR(255), publish_date DATE); INSERT INTO Articles (id, title, publish_date) VALUES (1, 'Article 1', '2009-01-01');
Which articles were published before 2010?
SELECT * FROM Articles WHERE publish_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Funding_Records (company_name VARCHAR(50), funding_round VARCHAR(20), funding_amount INT, gender VARCHAR(10)); INSERT INTO Funding_Records (company_name, funding_round, funding_amount, gender) VALUES ('Waystar Royco', 'Series A', 20000000, 'Male'); INSERT INTO Funding_Records (company_name, funding_round, funding_amount, gender) VALUES ('Pied Piper', 'Seed', 500000, 'Female'); INSERT INTO Funding_Records (company_name, funding_round, funding_amount, gender) VALUES ('Austin Biotech', 'Seed', 800000, 'Male');
What is the total funding for startups in their seed round, categorized by gender diversity?
SELECT gender, SUM(funding_amount) FROM Funding_Records WHERE funding_round = 'Seed' GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), age INT, state VARCHAR(2)); INSERT INTO community_health_workers (id, name, age, state) VALUES (1, 'John Doe', 45, 'Texas'), (2, 'Jane Smith', 35, 'California');
What is the average age of community health workers in Texas and California?
SELECT AVG(age) FROM community_health_workers WHERE state IN ('Texas', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (id INT, region VARCHAR(20), data_usage INT, usage_date DATE);
List all mobile subscribers in the Middle East who have not used their data services in the last month.
SELECT m.id, m.region, m.data_usage, m.usage_date FROM mobile_subscribers m LEFT JOIN (SELECT subscriber_id FROM mobile_subscribers WHERE usage_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH)) d ON m.id = d.subscriber_id WHERE m.region = 'Middle East' AND d.subscriber_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, region TEXT, speed FLOAT); INSERT INTO vessels (id, name, region, speed) VALUES (1, 'VesselA', 'Pacific', 20.5); INSERT INTO vessels (id, name, region, speed) VALUES (2, 'VesselB', 'Pacific', 22.3);
What is the average speed of vessels in the 'Pacific' region?
SELECT AVG(speed) FROM vessels WHERE region = 'Pacific'
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSales (SaleID INT, EquipmentType VARCHAR(255), Quantity INT, Country VARCHAR(255)); INSERT INTO EquipmentSales (SaleID, EquipmentType, Quantity, Country) VALUES (1, 'Tank', 10, 'Country A');
Which military equipment types were sold to Country A?
SELECT EquipmentType FROM EquipmentSales WHERE Country = 'Country A';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(255), region VARCHAR(255)); INSERT INTO donors (donor_id, donor_name, region) VALUES (1001, 'John Smith', 'North America'), (1002, 'Marie Johnson', 'Europe'), (1003, 'Mario Rodriguez', 'South America'), (1004, 'Nguyen Tran', 'Asia');
Which region has the highest number of donors?
SELECT region, COUNT(*) as num_donors FROM donors GROUP BY region ORDER BY num_donors DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors_Mexico (id INT, year INT, country VARCHAR(50), expenditure FLOAT); INSERT INTO Visitors_Mexico (id, year, country, expenditure) VALUES (1, 2020, 'Mexico', 1000), (2, 2020, 'Mexico', 1100), (3, 2020, 'Mexico', 1200);
What is the number of international visitors to Mexico in 2020 and their average expenditures?
SELECT AVG(Visitors_Mexico.expenditure) FROM Visitors_Mexico WHERE Visitors_Mexico.country = 'Mexico' AND Visitors_Mexico.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE threats (id INT, threat_type VARCHAR(255), severity INT, threat_time TIMESTAMP);
What is the average severity of threats related to 'phishing' in the last year?
SELECT AVG(severity) as average_severity FROM threats WHERE threat_type = 'phishing' AND threat_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, project_name TEXT, location TEXT, installed_capacity INT, project_type TEXT);
What is the total installed capacity (in MW) of wind energy projects in Canada?
SELECT SUM(renewable_projects.installed_capacity) FROM renewable_projects WHERE renewable_projects.location = 'Canada' AND renewable_projects.project_type = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (MetricID INT, Country VARCHAR(255)); INSERT INTO HealthEquityMetrics (MetricID, Country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil'), (5, 'UK');
How many health equity metrics were collected in each country?
SELECT COUNT(*), Country FROM HealthEquityMetrics GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance (id INT, member_id INT, class_date DATE, class_type VARCHAR(20)); INSERT INTO attendance (id, member_id, class_date, class_type) VALUES (1, 101, '2022-06-05', 'yoga'), (2, 102, '2022-05-12', 'yoga'), (3, 103, '2022-07-18', 'cycling'), (4, 104, '2022-07-20', 'cycling'), (5, 105, '2022-07-15', 'yoga'), (6, 105, '2022-07-22', 'pilates');
How many times has a member with ID 105 attended a yoga or pilates class in the last month?
SELECT COUNT(*) FROM attendance WHERE member_id = 105 AND (class_type = 'yoga' OR class_type = 'pilates') AND class_date >= (CURRENT_DATE - INTERVAL '1 month');
gretelai_synthetic_text_to_sql
CREATE TABLE bus_fares (fare_id INT, vehicle_type VARCHAR(20), fare DECIMAL(10,2), city VARCHAR(50)); INSERT INTO bus_fares (fare_id, vehicle_type, fare, city) VALUES (1, 'Bus', 2.00, 'Paris'), (2, 'Wheelchair Accessible Bus', 2.50, 'Paris');
What is the maximum fare for a wheelchair accessible bus in Paris?
SELECT MAX(fare) FROM bus_fares WHERE vehicle_type = 'Wheelchair Accessible Bus' AND city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health (patient_id INT, race VARCHAR(25), condition VARCHAR(50)); INSERT INTO mental_health (patient_id, race, condition) VALUES (1, 'African American', 'Depression'), (2, 'Caucasian', 'Anxiety'), (3, 'Hispanic', 'Bipolar'), (4, 'Asian', 'PTSD');
What is the distribution of mental health conditions by race?
SELECT race, condition, COUNT(*) as count FROM mental_health GROUP BY race, condition;
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, ota_name TEXT); INSERT INTO otas (ota_id, ota_name) VALUES (1, 'Booking.com'), (2, 'Expedia'), (3, 'Agoda'); CREATE TABLE hotel_revenue (hotel_id INT, city TEXT, ota_id INT, revenue FLOAT); INSERT INTO hotel_revenue (hotel_id, city, ota_id, revenue) VALUES (1, 'London', 1, 5000), (2, 'London', 1, 6000), (3, 'Paris', 1, 7000);
What is the total revenue for 'London' hotels from 'Booking.com'?
SELECT SUM(revenue) FROM hotel_revenue JOIN otas ON hotel_revenue.ota_id = otas.ota_id JOIN hotels ON hotel_revenue.hotel_id = hotels.hotel_id WHERE hotels.city = 'London' AND otas.ota_name = 'Booking.com';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (id INT, type VARCHAR(20), year INT, sales INT); INSERT INTO vehicles (id, type, year, sales) VALUES (1, 'Sedan', 2018, 5000), (2, 'SUV', 2019, 7000), (3, 'Truck', 2020, 4000), (4, 'Electric', 2018, 3000), (5, 'Electric', 2019, 4000), (6, 'Electric', 2020, 6000);
What is the total number of electric vehicles sold in 2020?
SELECT SUM(sales) FROM vehicles WHERE type = 'Electric' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_number INT, permit_type TEXT, issuance_date DATE); CREATE TABLE project_timelines (project_id INT, permit_number INT, start_date DATE); INSERT INTO building_permits (permit_number, permit_type, issuance_date) VALUES (1, 'Residential', '2022-01-15'), (2, 'Commercial', '2022-02-20'), (3, 'Residential', '2021-12-10'), (4, 'Sustainable', '2022-03-05'); INSERT INTO project_timelines (project_id, permit_number, start_date) VALUES (1, 1, '2022-02-01'), (2, 2, '2022-03-10'), (3, 3, '2021-12-15'), (4, 4, '2022-03-15');
What are the building permit numbers, permit types, and permit issuance dates for projects that have started in Q1 2022?
SELECT building_permits.permit_number, building_permits.permit_type, building_permits.issuance_date FROM building_permits INNER JOIN project_timelines ON building_permits.permit_number = project_timelines.permit_number WHERE project_timelines.start_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance_data (finance_id INT, assets DECIMAL(15, 2), country VARCHAR(50)); INSERT INTO shariah_compliant_finance_data (finance_id, assets, country) VALUES (1, 2000000, 'Saudi Arabia'), (2, 3000000, 'Malaysia'), (3, 1500000, 'Indonesia'), (4, 4000000, 'UAE'); CREATE VIEW shariah_compliant_finance_view AS SELECT country, SUM(assets) as total_assets FROM shariah_compliant_finance_data GROUP BY country;
What is the total assets for Shariah-compliant finance in each country?
SELECT country, total_assets FROM shariah_compliant_finance_view;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (location TEXT, current_capacity INTEGER, total_capacity INTEGER); INSERT INTO landfill_capacity (location, current_capacity, total_capacity) VALUES ('site4', 45000, 80000), ('site5', 60000, 100000);
List all landfills with remaining capacity above 50% of their total capacity.
SELECT location FROM landfill_capacity WHERE current_capacity > (total_capacity * 0.5);
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory(item_id INT, item_name VARCHAR(50), is_organic BOOLEAN, calorie_count INT); INSERT INTO Inventory VALUES(1,'Apples',TRUE,80),(2,'Bananas',TRUE,105),(3,'Chips',FALSE,150);
What is the average calorie count for organic items in the inventory?
SELECT AVG(calorie_count) FROM Inventory WHERE is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyHistory (PolicyID INT, PolicyType VARCHAR(20), Renewal BOOLEAN);
What is the policy renewal rate by policy type?
SELECT PolicyType, COUNT(*) OVER (PARTITION BY PolicyType) AS TotalPolicies, COUNT(*) FILTER (WHERE Renewal = TRUE) OVER (PARTITION BY PolicyType) AS RenewedPolicies, ROUND(COUNT(*) FILTER (WHERE Renewal = TRUE) OVER (PARTITION BY PolicyType) * 100.0 / COUNT(*) OVER (PARTITION BY PolicyType), 2) AS RenewalRate FROM PolicyHistory WHERE Renewal IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT, country VARCHAR(50), waste_amount FLOAT, month INT, year INT); INSERT INTO waste_generation (id, country, waste_amount, month, year) VALUES (1, 'France', 120000, 1, 2020), (2, 'France', 125000, 2, 2020), (3, 'France', 130000, 3, 2020);
Determine the change in waste generation per month for France in 2020, compared to the previous month.
SELECT LAG(waste_amount) OVER (PARTITION BY country ORDER BY year, month) + LAG(waste_amount) OVER (PARTITION BY country ORDER BY year, month) - waste_amount as diff FROM waste_generation WHERE country = 'France' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT PRIMARY KEY, contracting_agency VARCHAR(255), contract_status VARCHAR(255), contract_amount DECIMAL(10,2));
Delete records from the 'defense_contracts' table where 'contract_amount' is greater than 1000000 and 'contract_status' is 'completed'
DELETE FROM defense_contracts WHERE contract_amount > 1000000 AND contract_status = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, category VARCHAR(20), likes INT); INSERT INTO posts (id, category, likes) VALUES (1, 'music', 10), (2, 'music', 15), (3, 'sports', 20);
What is the average number of likes for posts in the 'music' category?
SELECT AVG(likes) FROM posts WHERE category = 'music';
gretelai_synthetic_text_to_sql
CREATE SCHEMA trans schemas.trans; CREATE TABLE blue_line (route_id INT, fare FLOAT, date DATE); INSERT INTO blue_line (route_id, fare, date) VALUES (103, 2.75, '2021-01-01'), (103, 2.75, '2021-01-02'), (103, 2.75, '2021-01-03'), (103, 2.75, '2021-01-04'), (103, 2.75, '2021-01-05'), (103, 2.75, '2021-01-06'), (103, 2.75, '2021-01-07');
What was the daily fare collection trend for the 'Blue Line' in January 2021?
SELECT date, SUM(fare) OVER (ORDER BY date) FROM blue_line WHERE route_id = 103 AND EXTRACT(MONTH FROM date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE VEHICLE_MAINTENANCE (maintenance_center TEXT, service_date DATE, vehicle_id INT); INSERT INTO VEHICLE_MAINTENANCE (maintenance_center, service_date, vehicle_id) VALUES ('North', '2022-02-01', 123), ('North', '2022-02-03', 456), ('South', '2022-02-02', 789), ('East', '2022-02-04', 111), ('West', '2022-02-05', 999);
List the number of unique vehicles serviced by each maintenance center in the last month.
SELECT maintenance_center, COUNT(DISTINCT vehicle_id) FROM VEHICLE_MAINTENANCE WHERE service_date >= (CURRENT_DATE - INTERVAL '30 days') GROUP BY maintenance_center;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, release_year INT, lead_actor VARCHAR(255), production_country VARCHAR(255));
Find the number of movies, produced in India or Nigeria, with a female lead actor and released between 2015 and 2020.
SELECT release_year, COUNT(*) as num_movies FROM movies WHERE production_country IN ('India', 'Nigeria') AND lead_actor = 'female' AND release_year BETWEEN 2015 AND 2020 GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Vaccination_Rates (Population INT, Population_Fully_Vaccinated INT); INSERT INTO Vaccination_Rates (Population, Population_Fully_Vaccinated) VALUES (26000000, 20000000);
What is the percentage of the population that is fully vaccinated against COVID-19 in Australia?
SELECT (Population_Fully_Vaccinated/Population)*100 FROM Vaccination_Rates;
gretelai_synthetic_text_to_sql
CREATE TABLE donations(id INT, donor_name TEXT, donation_amount FLOAT, donation_date DATE, industry TEXT); INSERT INTO donations(id, donor_name, donation_amount, donation_date, industry) VALUES (1, 'James Lee', 50, '2022-11-29', 'Technology'), (2, 'Grace Kim', 100, '2022-12-01', 'Finance'), (3, 'Anthony Nguyen', 25, '2022-11-29', 'Health');
What is the minimum donation amount given on Giving Tuesday from donors in the Technology industry?
SELECT MIN(donation_amount) FROM donations WHERE donation_date = '2022-11-29' AND industry = 'Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, grade INT, score INT); INSERT INTO student_mental_health (student_id, grade, score) VALUES (1, 5, 80), (2, 5, 85), (3, 6, 70), (4, 6, 75), (5, 7, 80), (6, 7, 85);
What is the average mental health score by grade level?
SELECT grade, AVG(score) OVER (PARTITION BY grade) AS avg_score FROM student_mental_health;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_reports (report_id INT, manufacturer_id INT, violation_details TEXT, is_ethical BOOLEAN);
Get the number of ethical labor violation reports associated with each manufacturer in the 'EthicalFashion' database
SELECT manufacturer_id, COUNT(*) FROM labor_reports WHERE is_ethical = FALSE GROUP BY manufacturer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(100), category VARCHAR(50), publication_date DATE, views INT); INSERT INTO articles (article_id, title, category, publication_date, views) VALUES (1, 'News from the Capital', 'Politics', '2022-01-01', 1500), (2, 'Tech Innovations in 2022', 'Technology', '2022-01-02', 1200), (3, 'The Art of Persuasion', 'Psychology', '2022-01-03', 1800), (4, 'Education Reforms in Europe', 'Education', '2022-01-04', 1000);
What is the maximum number of views for articles in the "articles" table for each category?
SELECT category, MAX(views) FROM articles GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), TrainingCompletion DATE);
Insert new records into the Employees table
INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, TrainingCompletion) VALUES (1, 'John', 'Doe', 'HR', '2022-01-01'), (2, 'Jane', 'Smith', 'IT', '2022-02-15'), (3, 'Mike', 'Johnson', 'Finance', NULL), (4, 'Jamal', 'Jackson', 'IT', '2022-03-20'), (5, 'Sophia', 'Lee', 'Marketing', '2022-04-05'), (6, 'Liam', 'Garcia', 'IT', NULL), (7, 'Ava', 'Anderson', 'HR', '2022-02-10');
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, registration_date DATE, country VARCHAR(255)); INSERT INTO users (user_id, registration_date, country) VALUES (1, '2022-01-01', 'USA'), (2, '2022-01-02', 'Canada'), (3, '2022-01-03', 'USA');
How many users have registered from each country?
SELECT country, COUNT(DISTINCT user_id) FROM users GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat_depth FLOAT, ocean_basin VARCHAR(255)); INSERT INTO species (id, name, habitat_depth, ocean_basin) VALUES (1, 'Atlantic Salmon', 50.0, 'Atlantic'), (2, 'Blue Whale', 200.0, 'Pacific'), (3, 'Narwhal', 1500.0, 'Arctic');
What is the average depth of all marine species habitats that are found in the Arctic Ocean?
SELECT AVG(habitat_depth) FROM species WHERE ocean_basin = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE european_region_table (id INT, event_name VARCHAR(100), country VARCHAR(50), type VARCHAR(50)); INSERT INTO european_region_table (id, event_name, country, type) VALUES (1, 'Military Partnership Dialogue', 'Germany', 'defense diplomacy'); CREATE TABLE south_american_region_table (id INT, event_name VARCHAR(100), country VARCHAR(50), type VARCHAR(50)); INSERT INTO south_american_region_table (id, event_name, country, type) VALUES (1, 'Joint Military Exercise', 'Brazil', 'defense diplomacy');
What is the total number of defense diplomacy events in 'european_region_table' and 'south_american_region_table'?
SELECT COUNT(*) FROM (SELECT * FROM european_region_table WHERE type = 'defense diplomacy' UNION SELECT * FROM south_american_region_table WHERE type = 'defense diplomacy') AS region_table;
gretelai_synthetic_text_to_sql
CREATE TABLE event (id INT, year INT, type_id INT, name VARCHAR(50), revenue INT);CREATE TABLE event_type (id INT, name VARCHAR(50));
What is the total number of events in the 'event' table by type ('event_type' table) for each year?
SELECT et.name, e.year, COUNT(*) FROM event e JOIN event_type et ON e.type_id = et.id GROUP BY et.name, e.year;
gretelai_synthetic_text_to_sql
CREATE TABLE Water_Usage (state VARCHAR(20), sector VARCHAR(20), water_usage FLOAT); INSERT INTO Water_Usage (state, sector, water_usage) VALUES ('California', 'Agriculture', 20000000), ('Texas', 'Agriculture', 15000000), ('Florida', 'Agriculture', 12000000), ('California', 'Municipal', 5000000), ('Texas', 'Municipal', 6000000), ('Florida', 'Municipal', 4000000);
Identify the top 3 states with the highest water usage in the agriculture sector.
SELECT sector, state, SUM(water_usage) as total_water_usage FROM Water_Usage WHERE sector = 'Agriculture' GROUP BY state ORDER BY total_water_usage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE actors (id INT, name VARCHAR(255), genre VARCHAR(50)); INSERT INTO actors (id, name, genre) VALUES (1, 'Actor1', 'Action'), (2, 'Actor2', 'Drama'), (3, 'Actor1', 'Action'), (4, 'Actor3', 'Action');
Who are the top 3 actors with the highest number of movies in the action genre?
SELECT name, COUNT(*) as num_movies FROM actors WHERE genre = 'Action' GROUP BY name ORDER BY num_movies DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, type VARCHAR(20)); INSERT INTO programs (id, type) VALUES (1, 'Writing'), (2, 'Poetry'), (3, 'Exhibition'); CREATE TABLE donations (id INT, program_id INT, donor_id INT); INSERT INTO donations (id, program_id, donor_id) VALUES (1, 1, 101), (2, 1, 102), (3, 2, 103), (4, 3, 104), (5, 3, 105);
Find the number of unique donors supporting literary arts programs and exhibitions.
SELECT COUNT(DISTINCT d.donor_id) FROM donations d WHERE d.program_id IN (SELECT p.id FROM programs p WHERE p.type IN ('Literary Arts', 'Exhibition'));
gretelai_synthetic_text_to_sql
CREATE TABLE nurses (id INT, name VARCHAR(50), salary DECIMAL(10, 2)); INSERT INTO nurses (id, name, salary) VALUES (1, 'Grace', 80000.00), (2, 'Heidi', 85000.00), (3, 'Irene', 90000.00);
What is the maximum salary for nurses in the 'hospital_database' database?
SELECT MAX(salary) FROM nurses WHERE name = 'nurse';
gretelai_synthetic_text_to_sql
CREATE TABLE authors (id INT PRIMARY KEY, name VARCHAR(50), articles INT); INSERT INTO authors (id, name, articles) VALUES (1, 'John Doe', 10), (2, 'Jane Smith', 15), (3, 'Bob Johnson', 12);
What is the total number of articles published by each author in the authors table?
SELECT name, SUM(articles) AS total_articles FROM authors GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE union_details (id INT, union_name TEXT, members INT); INSERT INTO union_details (id, union_name, members) VALUES (1, 'Union X', 600), (2, 'Union Y', 300), (3, 'Union Z', 700);
Which unions have more than 500 members in New York?
SELECT union_name FROM union_details WHERE members > 500 AND state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(255), department VARCHAR(255), publications INT); INSERT INTO faculty (id, name, department, publications) VALUES (1, 'Alice', 'Mathematics', 20), (2, 'Bob', 'Physics', 15), (3, 'Charlie', 'Mathematics', 25);
List the top 3 most productive faculty members in the Mathematics department by total number of academic publications.
SELECT name, SUM(publications) AS total_publications FROM faculty WHERE department = 'Mathematics' GROUP BY name ORDER BY total_publications DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_well_A (date DATE, production_oil INT, production_gas INT); INSERT INTO oil_well_A (date, production_oil, production_gas) VALUES ('2022-01-01', 1500, 5000), ('2022-01-02', 1600, 5200), ('2022-01-03', 1450, 4800);
What are the production figures for the 'oil_well_A' in the 'Q1_2022'?
SELECT SUM(production_oil) as total_oil_production, SUM(production_gas) as total_gas_production FROM oil_well_A WHERE date BETWEEN '2022-01-01' AND '2022-03-31' AND date >= (SELECT MAX(date) - INTERVAL '3 month' FROM oil_well_A);
gretelai_synthetic_text_to_sql
CREATE TABLE farmer (id INT PRIMARY KEY, name VARCHAR(50), gender VARCHAR(10), area_in_hectares INT); INSERT INTO farmer (id, name, gender, area_in_hectares) VALUES (1, 'Jamal', 'Male', 3000), (2, 'Aisha', 'Female', 2500), (3, 'Samir', 'Male', 2000), (4, 'Fatima', 'Female', 4000);
What is the average area of land used for farming by each gender?
SELECT gender, AVG(area_in_hectares) FROM farmer GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE japanese_products (product_id INT, product_name TEXT, country TEXT, total_sales FLOAT, site_safety_score FLOAT); INSERT INTO japanese_products (product_id, product_name, country, total_sales, site_safety_score) VALUES (1, 'Product M', 'Japan', 65000, 91.2), (2, 'Product N', 'Japan', 70000, 88.5), (3, 'Product O', 'Japan', 55000, 94.1), (4, 'Product P', 'Japan', 60000, 89.7);
Find the chemical product with the highest sales in Japan and the safety score of its manufacturing site.
SELECT product_name, total_sales, site_safety_score FROM japanese_products WHERE country = 'Japan' AND total_sales = (SELECT MAX(total_sales) FROM japanese_products WHERE country = 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE market_prices (id INT, element TEXT, price FLOAT, month INT, year INT);
What was the average monthly price of Europium in the global market in 2017?
SELECT AVG(price) FROM market_prices WHERE element = 'Europium' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, name TEXT); INSERT INTO Artists (artist_id, name) VALUES (1, 'Pablo Picasso'), (2, 'Vincent Van Gogh'); CREATE TABLE Artworks (artwork_id INT, title TEXT, creation_year INT, art_movement TEXT, artist_id INT); INSERT INTO Artworks (artwork_id, title, creation_year, art_movement, artist_id) VALUES (1, 'Guernica', 1937, 'Cubism', 1), (2, 'Starry Night', 1889, 'Post-Impressionism', 2);
What are the names and art movements of all artists who have created more than 50 artworks?
SELECT Artists.name, Artworks.art_movement FROM Artists INNER JOIN Artworks ON Artists.artist_id = Artworks.artist_id GROUP BY Artists.name, Artworks.art_movement HAVING COUNT(*) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255), carbon_sequestration_tonnes INT); INSERT INTO Forests (id, name, hectares, country, carbon_sequestration_tonnes) VALUES (1, 'Amazon Rainforest', 55000000.0, 'Brazil', 120000000), (2, 'Congo Rainforest', 35000000.0, 'Congo', 90000000), (3, 'Boreal Forest', 60000000.0, 'Canada', 150000000);
What is the forest with the highest carbon sequestration per hectare and its corresponding carbon sequestration value?
SELECT Forests.name, (MAX(carbon_sequestration_tonnes/hectares)) as highest_carbon_sequestration_per_hectare, MAX(Forests.carbon_sequestration_tonnes) as corresponding_carbon_sequestration_value FROM Forests GROUP BY Forests.name HAVING highest_carbon_sequestration_per_hectare = (SELECT MAX(carbon_sequestration_tonnes/hectares) FROM Forests);
gretelai_synthetic_text_to_sql
CREATE TABLE CityEfficiency (building_id INT, rating FLOAT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO CityEfficiency (building_id, rating, city, state) VALUES (1, 92.5, 'SanFrancisco', 'CA'), (2, 88.3, 'Austin', 'TX'), (3, 93.1, 'Seattle', 'WA'), (4, 91.2, 'Portland', 'OR');
Identify the top 2 most energy efficient cities for residential buildings in the "CleanEnergy" schema.
SELECT city, AVG(rating) as avg_rating FROM CleanEnergy.CityEfficiency GROUP BY city ORDER BY avg_rating DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, name TEXT, state TEXT, community_service_hours INT); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (1, 'John Doe', 'Washington', 50); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (2, 'Jane Smith', 'Washington', 75); INSERT INTO offenders (id, name, state, community_service_hours) VALUES (3, 'Mike Brown', 'Washington', 100);
Who are the top 3 offenders with the most community service hours in Washington?
SELECT name, state, community_service_hours FROM offenders WHERE state = 'Washington' ORDER BY community_service_hours DESC LIMIT 3
gretelai_synthetic_text_to_sql
CREATE TABLE policy_violation_department(id INT, department VARCHAR(50), violation_count INT, violation_date DATE);
What is the total number of cybersecurity policy violations that have occurred in each department in the past year?
SELECT department, SUM(violation_count) as total_violations FROM policy_violation_department WHERE violation_date > DATE(NOW()) - INTERVAL 365 DAY GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (ingredient VARCHAR(255), local BOOLEAN); INSERT INTO menu (ingredient, local) VALUES ('Pizza', FALSE), ('Pasta', FALSE), ('Burger', FALSE), ('Salad', TRUE);
What is the percentage of locally sourced ingredients in the menu?
SELECT (COUNT(local) FILTER (WHERE local = TRUE)) * 100.0 / COUNT(local) AS percentage FROM menu;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthClinics (Area VARCHAR(50), Year INT, Number INT); INSERT INTO MentalHealthClinics (Area, Year, Number) VALUES ('Rural', 2019, 10), ('Urban', 2019, 20), ('Suburban', 2019, 15);
Number of mental health clinics in rural areas in 2019.
SELECT Number FROM MentalHealthClinics WHERE Area = 'Rural' AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE il_orgs (id INT, org_name VARCHAR(20)); CREATE TABLE il_funding (id INT, org_name VARCHAR(20), amount INT); INSERT INTO il_orgs (id, org_name) VALUES (1, 'OrgA'), (2, 'OrgB'); INSERT INTO il_funding (id, org_name, amount) VALUES (1, 'OrgA', 50000), (2, 'OrgB', 75000);
What is the total funding received by arts organizations in Illinois and how many unique organizations have there been?
SELECT SUM(if.amount), COUNT(DISTINCT iorg.org_name) FROM il_funding if INNER JOIN il_orgs iorg ON if.org_name = iorg.org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (project_id INT, project_name VARCHAR(255), carbon_offsets_tons INT); INSERT INTO smart_city_projects (project_id, project_name, carbon_offsets_tons) VALUES (1, 'Smart City 1', 1000); INSERT INTO smart_city_projects (project_id, project_name, carbon_offsets_tons) VALUES (2, 'Smart City 2', 2000); INSERT INTO smart_city_projects (project_id, project_name, carbon_offsets_tons) VALUES (3, 'Smart City 3', 3000);
What is the average carbon offset (in tons) per smart city project?
SELECT AVG(carbon_offsets_tons) as avg_carbon_offsets_tons FROM smart_city_projects;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.temperature (id INT, biosensor_name VARCHAR(255), temperature DECIMAL(10,2)); INSERT INTO biosensors.temperature (id, biosensor_name, temperature) VALUES (1, 'BioTherm', 37.5), (2, 'BioSense', 38.2), (3, 'BioTemp', 37.8);
Which biosensor technology has the highest average temperature?
SELECT biosensor_name, AVG(temperature) avg_temperature FROM biosensors.temperature GROUP BY biosensor_name ORDER BY avg_temperature DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ip_incidents (ip VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO ip_incidents (ip, incident_type) VALUES ('172.16.0.1', 'brute force'), ('172.16.0.1', 'phishing');
How many times has the IP address '172.16.0.1' been involved in any kind of security incident?
SELECT COUNT(*) FROM ip_incidents WHERE ip = '172.16.0.1';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, date DATE, severity VARCHAR(10), ip VARCHAR(15), country VARCHAR(30)); INSERT INTO vulnerabilities (id, date, severity, ip, country) VALUES (1, '2021-01-01', 'high', '192.168.1.100', 'United States');
What is the percentage of high severity vulnerabilities in each country, and what is the total number of high severity vulnerabilities?
SELECT country, severity, COUNT(*) as vulnerability_count, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM vulnerabilities WHERE severity = 'high') as percentage FROM vulnerabilities WHERE severity = 'high' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE events_log (event_name VARCHAR(50), event_year INT); INSERT INTO events_log (event_name, event_year) VALUES ('Charity Dinner', 2020); INSERT INTO events_log (event_name, event_year) VALUES ('Fundraiser', 2021);
What is the total number of events held in 'events_log' table for '2020' and '2021'?
SELECT COUNT(*) FROM events_log WHERE event_year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE BRAZIL_EV_ADOPTION (id INT, year INT, adoption_rate DECIMAL(5,2));
Create a table for electric vehicle adoption statistics in Brazil
CREATE TABLE BRAZIL_EV_ADOPTION (id INT, year INT, adoption_rate DECIMAL(5,2));
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, country VARCHAR(20), capacity FLOAT); INSERT INTO wind_farms (id, country, capacity) VALUES (1, 'Germany', 3000.0), (2, 'France', 2500.0);
What is the total installed capacity of wind farms in Germany and France?
SELECT SUM(capacity) FROM wind_farms WHERE country IN ('Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE health_facilities (facility_id INT, name VARCHAR(50), type VARCHAR(50), population INT, city VARCHAR(50), state VARCHAR(50));
What is the total number of health facilities in 'California'?
SELECT COUNT(*) FROM health_facilities WHERE state = 'California';
gretelai_synthetic_text_to_sql