context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE signup_data (platform VARCHAR(20), user_count INT);INSERT INTO signup_data VALUES ('FB',10000),('IG',20000),('TW',30000),('SN',40000),('LI',50000);
How many users signed up for each social media platform?
SELECT platform, SUM(user_count) FROM signup_data GROUP BY platform;
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentMaintenance (MaintenanceID INT, EquipmentID INT, Branch VARCHAR(50), Year INT, Requests INT); INSERT INTO EquipmentMaintenance (MaintenanceID, EquipmentID, Branch, Year, Requests) VALUES (1, 1, 'Navy', 2019, 25), (2, 2, 'Army', 2019, 30), (3, 3, 'Navy', 2018, 20), (4, 4, 'Air Force', 2019, 35), (5, 5, 'Coast Guard', 2019, 15), (6, 6, 'Marines', 2019, 20);
How many military equipment maintenance requests were there in 2019 for each branch of the military?
SELECT Branch, SUM(Requests) as Total_Requests FROM EquipmentMaintenance WHERE Year = 2019 GROUP BY Branch;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicMeetings ( MeetingId INT, MeetingDate DATE, Department VARCHAR(255), State VARCHAR(255) ); INSERT INTO PublicMeetings (MeetingId, MeetingDate, Department, State) VALUES (1, '2021-01-01', 'Transportation', 'California'), (2, '2021-02-01', 'Education', 'California'), (3, '2021-03-01', 'Healthcare', 'California');
What is the percentage of public meetings for each department in the state of California?
SELECT Department, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM PublicMeetings WHERE State = 'California') as Percentage FROM PublicMeetings WHERE State = 'California' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_projects ( id INT, name VARCHAR(255), location VARCHAR(255), year INT ); INSERT INTO climate_finance_projects (id, name, location, year) VALUES (1, 'Project H', 'India', 2019); INSERT INTO climate_finance_projects (id, name, location, year) VALUES (2, 'Project I', 'China', 2021);
What are the names and locations of climate finance projects that were implemented after 2018 but before 2021?
SELECT name, location FROM climate_finance_projects WHERE year > 2018 AND year < 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, name VARCHAR(100), location VARCHAR(50), building_type VARCHAR(50), carbon_offset FLOAT); INSERT INTO green_buildings (building_id, name, location, building_type, carbon_offset) VALUES (1, 'GreenHQ', 'Urban', 'Office', 500), (2, 'EcoTower', 'Rural', 'Residential', 300), (3, 'SolarSpire', 'Urban', 'Office', 700); CREATE TABLE carbon_offset_initiatives (initiative_id INT, name VARCHAR(100), location VARCHAR(50), carbon_offset FLOAT); INSERT INTO carbon_offset_initiatives (initiative_id, name, location, carbon_offset) VALUES (1, 'TreePlanting', 'CityA', 5000), (2, 'Recycling', 'CityB', 3000), (3, 'Composting', 'CityC', 7000);
What is the average carbon offset (in metric tons) achieved per green building in the green_buildings and carbon_offset_initiatives tables, grouped by building type?
SELECT g.building_type, AVG(g.carbon_offset + c.carbon_offset) as avg_carbon_offset FROM green_buildings g INNER JOIN carbon_offset_initiatives c ON g.location = c.location GROUP BY g.building_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (Id INT, Name VARCHAR(50), Age INT, Nationality VARCHAR(50)); INSERT INTO Members (Id, Name, Age, Nationality) VALUES (1, 'John Doe', 30, 'UK'), (2, 'Jane Smith', 25, 'Canada'), (5, 'Alexander Johnson', 40, 'USA'); CREATE TABLE Workouts (Id INT, MemberId INT, WorkoutType VARCHAR(50), Duration INT, Date DATE); INSERT INTO Workouts (Id, MemberId, WorkoutType, Duration, Date) VALUES (1, 1, 'Running', 30, '2022-01-01'), (2, 2, 'Swimming', 60, '2022-01-02'), (6, 5, 'Cycling', 95, '2022-01-06');
List all the members who have done a workout longer than 90 minutes?
SELECT m.Id, m.Name, m.Age, m.Nationality FROM Members m JOIN Workouts w ON m.Id = w.MemberId WHERE w.Duration > 90;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, mental_health_score INT); INSERT INTO students (student_id, mental_health_score) VALUES (1, 80), (2, 60), (3, 90), (4, 55), (5, 50);
Delete the record of the student with the lowest mental health score.
DELETE FROM students WHERE student_id = (SELECT MIN(student_id) FROM students);
gretelai_synthetic_text_to_sql
CREATE TABLE pacific_marine_life (species VARCHAR(255), count INT); INSERT INTO pacific_marine_life (species, count) VALUES ('Dolphin', 300), ('Seal', 250), ('Whale', 200);
List all the distinct marine mammals and their observation counts in the Pacific Ocean, excluding whales.
SELECT species, count FROM pacific_marine_life WHERE species != 'Whale';
gretelai_synthetic_text_to_sql
CREATE TABLE loans (id INT, employee_id INT, amount INT, is_shariah_compliant BOOLEAN, financial_wellbeing_score INT, loan_type TEXT); INSERT INTO loans (id, employee_id, amount, is_shariah_compliant, financial_wellbeing_score, loan_type) VALUES (1, 2, 25000, FALSE, 7, 'Socially responsible'), (2, 2, 40000, FALSE, 9, 'Socially responsible'), (3, 3, 50000, TRUE, 8, 'Shariah-compliant');
Find the average financial wellbeing score for socially responsible loans in New York?
SELECT AVG(loans.financial_wellbeing_score) FROM loans WHERE loans.loan_type = 'Socially responsible' AND loans.id IN (SELECT loan_id FROM customers WHERE customers.city = 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO restaurants (id, name, location) VALUES (1, 'Restaurant E', 'New York'); INSERT INTO restaurants (id, name, location) VALUES (2, 'Restaurant F', 'Chicago');CREATE TABLE orders (id INT, restaurant_id INT, supplier_id INT); INSERT INTO orders (id, restaurant_id, supplier_id) VALUES (1, 1, 1); INSERT INTO orders (id, restaurant_id, supplier_id) VALUES (2, 2, 2);CREATE TABLE suppliers (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO suppliers (id, name, location) VALUES (1, 'Supplier G', 'New York'); INSERT INTO suppliers (id, name, location) VALUES (2, 'Supplier H', 'Los Angeles');
Which restaurants have placed orders with suppliers located in 'New York' or 'Los Angeles'?
SELECT DISTINCT r.name AS restaurant_name FROM restaurants r INNER JOIN orders o ON r.id = o.restaurant_id INNER JOIN suppliers s ON o.supplier_id = s.id WHERE r.location IN ('New York', 'Los Angeles');
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), location VARCHAR(50), ethical_rating FLOAT); INSERT INTO suppliers (id, name, location, ethical_rating) VALUES (1, 'Supplier A', 'Germany', 4.5); INSERT INTO suppliers (id, name, location, ethical_rating) VALUES (2, 'Supplier B', 'France', 4.7);
What is the average ethical rating of suppliers in Germany and France?
SELECT AVG(ethical_rating) FROM suppliers WHERE location IN ('Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (event_id INT, event_name VARCHAR(50), location VARCHAR(50), date DATE, ticket_price DECIMAL(5,2), num_tickets INT, city VARCHAR(50)); CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), age INT, city VARCHAR(50), state VARCHAR(50), country VARCHAR(50));
Which events have more than 500 fans attending from New York in the 'concerts' and 'fans' tables?
SELECT c.event_name FROM concerts c JOIN fans f ON c.city = f.city WHERE f.state = 'New York' GROUP BY c.event_name HAVING COUNT(*) > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE auto_shows (show_name VARCHAR(100), location VARCHAR(100), start_date DATE, end_date DATE);
How many auto shows are taking place in each location in the second half of 2022?
SELECT location, COUNT(*) FROM auto_show_summary INNER JOIN auto_shows ON auto_shows.location = auto_show_summary.location WHERE start_date BETWEEN '2022-07-01' AND '2022-12-31' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE buses (bus_id INT, route_id INT, num_seats INT, num_available_seats INT);
Display the number of available seats on each bus for the longest route
SELECT route_id, num_available_seats FROM buses ORDER BY route_length DESC, num_available_seats DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO defense_projects (project_name, start_date, end_date) VALUES ('Project A', '2021-01-01', '2023-12-31'), ('Project B', '2019-01-01', '2022-12-31'), ('Project C', '2020-01-01', '2024-12-31');
List all defense projects with timelines starting in 2020 or later.
SELECT project_name FROM defense_projects WHERE start_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (id INT, name VARCHAR(50), travel_advisory_count INT); INSERT INTO destinations (id, name, travel_advisory_count) VALUES (1, 'Paris', 2), (2, 'Rome', 1), (3, 'Tokyo', 0), (4, 'New York', 3); CREATE TABLE travel_advisories (id INT, destination_id INT, year INT); INSERT INTO travel_advisories (id, destination_id, year) VALUES (1, 1, 2018), (2, 1, 2018), (3, 4, 2018), (4, 4, 2018), (5, 4, 2018);
Show the number of travel advisories issued for each destination in 2018
SELECT d.name, COUNT(*) AS travel_advisories_count FROM destinations d INNER JOIN travel_advisories ta ON d.id = ta.destination_id WHERE ta.year = 2018 GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE country (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE humanitarian_assistance (mission_id INT, country_id INT, year INT, FOREIGN KEY (country_id) REFERENCES country(id)); INSERT INTO country (id, name) VALUES (1, 'Canada'), (2, 'US'); INSERT INTO humanitarian_assistance (mission_id, country_id, year) VALUES (1, 1, 2020), (2, 2, 2020);
What is the total number of humanitarian assistance missions performed by each country in 2020?
SELECT c.name, COUNT(h.mission_id) as total_missions FROM country c INNER JOIN humanitarian_assistance h ON c.id = h.country_id WHERE h.year = 2020 GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE TeamTicketSales (Team VARCHAR(255), TotalSales INT); INSERT INTO TeamTicketSales (Team, TotalSales) VALUES ('TeamA', 1200), ('TeamB', 1500), ('TeamC', 1800);
What is the total number of tickets sold for each team, and how are they ranked by sales?
SELECT Team, TotalSales, RANK() OVER (ORDER BY TotalSales DESC) AS SalesRank FROM TeamTicketSales;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population (animal_id, animal_name, population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 5000), (3, 'Lion', 3000);
How many animals of each species are there in the 'animal_population' table?
SELECT animal_name, SUM(population) FROM animal_population GROUP BY animal_name;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (site_id INT, name TEXT, location TEXT, country TEXT); INSERT INTO heritage_sites (site_id, name, location, country) VALUES (1, 'Belém Tower', 'Lisbon', 'Portugal'); CREATE TABLE economic_impact (site_id INT, jobs_supported INT, annual_revenue INT); INSERT INTO economic_impact (site_id, jobs_supported, annual_revenue) VALUES (1, 500, 1000000);
Show the local economic impact of cultural heritage sites in Lisbon.
SELECT heritage_sites.name, economic_impact.jobs_supported, economic_impact.annual_revenue FROM heritage_sites JOIN economic_impact ON heritage_sites.site_id = economic_impact.site_id WHERE heritage_sites.location = 'Lisbon';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (dept_id INT, dept_name VARCHAR(255));CREATE TABLE employees (emp_id INT, emp_name VARCHAR(255), dept_id INT, gender VARCHAR(10)); INSERT INTO departments (dept_id, dept_name) VALUES (1, 'HR'), (2, 'IT'); INSERT INTO employees (emp_id, emp_name, dept_id, gender) VALUES (1, 'John Doe', 1, 'Male'), (2, 'Jane Smith', 1, 'Female'), (3, 'Alice Johnson', 2, 'Female'), (4, 'Bob Brown', 2, 'Male');
Determine the percentage of female employees in each department.
SELECT dept_name, (COUNT(*) FILTER (WHERE gender = 'Female') * 100.0 / COUNT(*)) as pct_female FROM departments d JOIN employees e ON d.dept_id = e.dept_id GROUP BY dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_savings (id INT, green_building_id INT, savings FLOAT, year INT); CREATE VIEW green_buildings_africa AS SELECT * FROM green_buildings WHERE country = 'Africa';
What is the sum of energy savings from green buildings in Africa since 2010?
SELECT SUM(savings) FROM energy_savings JOIN green_buildings_africa ON energy_savings.green_building_id = green_buildings_africa.id WHERE year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives(location VARCHAR(20), launch_date DATE); INSERT INTO circular_economy_initiatives VALUES('Tokyo', '2020-01-01'), ('Tokyo', '2020-03-15'), ('Osaka', '2019-12-31');
How many circular economy initiatives were launched in Tokyo in 2020?
SELECT COUNT(*) as initiatives FROM circular_economy_initiatives WHERE location = 'Tokyo' AND YEAR(launch_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_applications (app_id INT, app_name VARCHAR(50), network VARCHAR(10)); INSERT INTO decentralized_applications (app_id, app_name, network) VALUES (1, 'Uniswap', 'Solana'); CREATE TABLE app_assets (app_id INT, asset_id INT); INSERT INTO app_assets (app_id, asset_id) VALUES (1, 1); INSERT INTO app_assets (app_id, asset_id) VALUES (1, 2);
Find the top 5 decentralized applications with the most unique digital assets on the 'Solana' network?
SELECT d.app_name, COUNT(DISTINCT a.asset_id) as unique_assets FROM decentralized_applications d JOIN app_assets a ON d.app_id = a.app_id WHERE d.network = 'Solana' GROUP BY d.app_name ORDER BY unique_assets DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists bioprocess; CREATE TABLE if not exists bioprocess.investments (id INT, company VARCHAR(100), location VARCHAR(50), rnd_investment FLOAT); INSERT INTO bioprocess.investments (id, company, location, rnd_investment) VALUES (1, 'Bioprocess GmbH', 'Germany', 5000000.00); INSERT INTO bioprocess.investments (id, company, location, rnd_investment) VALUES (2, 'CleanTech Germany', 'Germany', 3000000.00);
What is the total investment in bioprocess engineering R&D for companies in Germany?
SELECT SUM(rnd_investment) FROM bioprocess.investments WHERE location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Training (TrainingID INT, Community VARCHAR(255), Cost DECIMAL(10,2), TrainingDate DATE); INSERT INTO Training (TrainingID, Community, Cost, TrainingDate) VALUES (1, 'Women in Tech', 5000.00, '2021-05-01'), (2, 'LGBTQ+', 6000.00, '2021-07-10'), (3, 'Minorities in STEM', 7000.00, '2020-12-15');
What is the total training cost for underrepresented communities in the past year?
SELECT SUM(Cost) FROM Training WHERE TrainingDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND Community IN ('Women in Tech', 'LGBTQ+', 'Minorities in STEM');
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, project_name VARCHAR(255), budget FLOAT, start_date DATE, country VARCHAR(50)); INSERT INTO economic_diversification (id, project_name, budget, start_date, country) VALUES (1, 'Technology Hub', 350000.00, '2018-05-01', 'Canada'), (2, 'Sustainable Fashion', 250000.00, '2018-11-30', 'Canada'), (3, 'Biofuel Research', 400000.00, '2018-07-14', 'Canada');
What is the maximum budget for economic diversification projects in Canada that started in 2018?
SELECT MAX(budget) FROM economic_diversification WHERE country = 'Canada' AND EXTRACT(YEAR FROM start_date) = 2018
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArts (ArtID INT PRIMARY KEY, ArtName VARCHAR(50), Location VARCHAR(50), Type VARCHAR(50)); INSERT INTO TraditionalArts (ArtID, ArtName, Location, Type) VALUES (1, 'Tango', 'Argentina', 'Dance'), (2, 'Aymara Textiles', 'Bolivia', 'Textiles');
How many traditional art forms are present in 'South America'?
SELECT COUNT(*) FROM TraditionalArts WHERE Location LIKE '%South America%';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, sale_quantity INT, sale_price FLOAT, country VARCHAR(50), store VARCHAR(100)); CREATE TABLE products (product_id INT, product_name VARCHAR(100), product_type VARCHAR(50), mineral_based BOOLEAN);
What is the total revenue generated by mineral-based foundation sales in the US in Q3 2022, excluding sales from Sephora?
SELECT SUM(sale_quantity * sale_price) AS total_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.product_type = 'foundation' AND mineral_based = TRUE AND country = 'US' AND store != 'Sephora' AND sale_date BETWEEN '2022-07-01' AND '2022-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Students (student_id INT, department VARCHAR(255)); CREATE TABLE Accommodations (accommodation_id INT, student_id INT, accommodation_type VARCHAR(255));
What is the average number of accommodations per student?
SELECT AVG(accommodation_count) as average_accommodations FROM ( SELECT student_id, COUNT(accommodation_id) as accommodation_count FROM Accommodations GROUP BY student_id ) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE expenditures (id INT, category TEXT, amount FLOAT, country TEXT); INSERT INTO expenditures (id, category, amount, country) VALUES (1, 'infrastructure', 5000000, 'United States');
What is the total budget allocated for infrastructure in each country?
SELECT expenditures.country, SUM(expenditures.amount) FROM expenditures WHERE expenditures.category = 'infrastructure' GROUP BY expenditures.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name TEXT, region TEXT); INSERT INTO Warehouse (id, name, region) VALUES (1, 'Bangkok Warehouse', 'Southeast Asia'), (2, 'Singapore Warehouse', 'Southeast Asia'), (3, 'Kuala Lumpur Warehouse', 'Southeast Asia'); CREATE TABLE Shipment (id INT, warehouse_id INT, package_count INT, cargo_weight INT, return_status TEXT); INSERT INTO Shipment (id, warehouse_id, package_count, cargo_weight, return_status) VALUES (1, 1, 5, 1000, 'Refunded'), (2, 1, 3, 800, 'On Time'), (3, 2, 4, 900, 'Refunded'), (4, 3, 7, 1200, 'On Time');
What is the total number of packages and their weight in the 'Southeast Asia' region that have been returned for a refund?
SELECT Warehouse.region, SUM(Shipment.package_count) as total_packages, SUM(Shipment.cargo_weight) as total_cargo_weight FROM Warehouse INNER JOIN Shipment ON Warehouse.id = Shipment.warehouse_id WHERE Warehouse.region = 'Southeast Asia' AND Shipment.return_status = 'Refunded' GROUP BY Warehouse.region;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales_2 (supplier VARCHAR(255), buyer VARCHAR(255), equipment VARCHAR(255), year INTEGER, cost DECIMAL(10,2)); INSERT INTO military_sales_2 (supplier, buyer, equipment, year, cost) VALUES ('Raytheon', 'US Government', 'Patriot Missile System', 2020, 3000000), ('Raytheon', 'US Government', 'Tomahawk Cruise Missile', 2020, 1500000);
What is the average cost of military equipment sold by Raytheon to the US government?
SELECT AVG(cost) FROM military_sales_2 WHERE supplier = 'Raytheon' AND buyer = 'US Government';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents (incident_id INT, incident_year INT, incident_month INT, ai_application_area VARCHAR(50));
List the AI safety incidents in the 'AI for finance' application area that occurred in the second half of 2021.
SELECT * FROM ai_safety_incidents WHERE ai_application_area = 'AI for finance' AND incident_year = 2021 AND incident_month > 6;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployment(id INT, organization VARCHAR(255), satellite VARCHAR(255), cost FLOAT); INSERT INTO SatelliteDeployment(id, organization, satellite, cost) VALUES (1, 'ISRO', 'Satellite 1', 1200000), (2, 'NASA', 'Satellite 2', 1500000), (3, 'JAXA', 'Satellite 3', 800000), (4, 'ISRO', 'Satellite 4', 1000000);
What is the average cost of satellites deployed by JAXA?
SELECT AVG(cost) FROM SatelliteDeployment WHERE organization = 'JAXA';
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_type TEXT, city TEXT, cost INTEGER, year INTEGER);INSERT INTO building_permits (permit_type, city, cost, year) VALUES ('Residential', 'Seattle', 200000, 2020), ('Commercial', 'Seattle', 500000, 2020), ('Industrial', 'Seattle', 300000, 2020);
What are the total construction costs for each type of building permit in the city of Seattle for the year 2020?
SELECT permit_type, SUM(cost) FROM building_permits WHERE city = 'Seattle' AND year = 2020 GROUP BY permit_type;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (initiative_id INT, initiative_name VARCHAR(50), state VARCHAR(50), investment FLOAT); INSERT INTO initiative VALUES (1, 'Rural Roads', 'Chihuahua', 500000), (2, 'Clean Water', 'Chihuahua', 750000), (3, 'Irrigation', 'Sinaloa', 600000), (4, 'Education', 'Sinaloa', 800000), (5, 'Renewable Energy', 'Yucatan', 900000);
Display the number of community development initiatives and their total investment for each state in Mexico, ordered by the highest total investment.
SELECT state, COUNT(initiative_name) as num_initiatives, SUM(investment) as total_investment FROM initiative GROUP BY state ORDER BY total_investment DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (strain_id INT, name TEXT, state TEXT); INSERT INTO strains (strain_id, name, state) VALUES (1, 'Strain X', 'Oregon'), (2, 'Strain Y', 'Oregon'), (3, 'Strain Z', 'California');
How many unique strains of cannabis are available for sale in Oregon?
SELECT COUNT(DISTINCT name) AS unique_strains FROM strains WHERE state = 'Oregon';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism (destination VARCHAR(50), continent VARCHAR(50), is_sustainable BOOLEAN, number_of_tourists INT); INSERT INTO tourism (destination, continent, is_sustainable, number_of_tourists) VALUES ('Galapagos', 'South America', true, 80000), ('Torres del Paine', 'South America', true, 60000), ('Banff', 'North America', true, 100000);
What is the most popular sustainable destination for tourists from Canada in South America?
SELECT destination, MAX(number_of_tourists) as max_tourists FROM tourism WHERE is_sustainable = true AND continent = 'South America' AND number_of_tourists = (SELECT MAX(number_of_tourists) FROM tourism WHERE is_sustainable = true AND continent = 'South America' GROUP BY visitor_country) GROUP BY destination;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO satellites (satellite_id, name, launch_date) VALUES (1, 'Sputnik 1', '1957-10-04'); INSERT INTO satellites (satellite_id, name, launch_date) VALUES (2, 'Explorer 1', '1958-01-31'); INSERT INTO satellites (satellite_id, name, launch_date) VALUES (3, 'Vanguard 1', '1958-03-17'); INSERT INTO satellites (satellite_id, name, launch_date) VALUES (4, 'Beep 1 (Explorer 3)', '1958-03-26'); INSERT INTO satellites (satellite_id, name, launch_date) VALUES (5, 'Sputnik 2', '1957-11-03');
Delete the satellite 'Sputnik 1' from the satellites table.
DELETE FROM satellites WHERE name = 'Sputnik 1';
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (HotelID INT, HotelName VARCHAR(50), Continent VARCHAR(20), CO2EmissionsReduction INT); INSERT INTO Hotels (HotelID, HotelName, Continent, CO2EmissionsReduction) VALUES (1, 'GreenPalace', 'Asia', 30), (2, 'EcoLodge', 'Africa', 25), (3, 'SustainableResort', 'Europe', 20);
List the top 2 continents with the highest average carbon emissions reduction for hotels, and the number of hotels in each.
SELECT Continent, AVG(CO2EmissionsReduction) as AvgReduction, COUNT(*) as HotelCount FROM Hotels GROUP BY Continent ORDER BY AvgReduction DESC, HotelCount DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), city VARCHAR(50));CREATE TABLE tickets (ticket_id INT, team_id INT, price DECIMAL(5,2)); INSERT INTO teams (team_id, team_name, city) VALUES (1, 'Atlanta Hawks', 'Atlanta'); INSERT INTO tickets (ticket_id, team_id, price) VALUES (1, 1, 70.50);
What is the average ticket price for each city where our teams play?
SELECT city, AVG(price) FROM tickets t JOIN teams te ON t.team_id = te.team_id GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (PatientID int, MentalHealthVisits int); INSERT INTO MentalHealthParity (PatientID, MentalHealthVisits) VALUES (1, 5), (2, 3), (3, 6), (4, 4), (5, 8), (6, 7), (7, 6);
Calculate the percentage of mental health visits per patient, ordered by the percentage in descending order.
SELECT PatientID, MentalHealthVisits, 100.0 * MentalHealthVisits / SUM(MentalHealthVisits) OVER () AS Percentage, ROW_NUMBER() OVER (ORDER BY 100.0 * MentalHealthVisits / SUM(MentalHealthVisits) OVER () DESC) AS Rank FROM MentalHealthParity;
gretelai_synthetic_text_to_sql
CREATE TABLE product_sales (product_type VARCHAR(20), quarter VARCHAR(2), year INT, units_sold INT); INSERT INTO product_sales (product_type, quarter, year, units_sold) VALUES ('tops', 'Q1', 2022, 800), ('tops', 'Q1', 2022, 900), ('tops', 'Q1', 2022, 850), ('bottoms', 'Q1', 2022, 700), ('bottoms', 'Q1', 2022, 750), ('bottoms', 'Q1', 2022, 800);
How many units of each product type were sold in Q1 2022?
SELECT product_type, SUM(units_sold) FROM product_sales WHERE quarter = 'Q1' AND year = 2022 GROUP BY product_type;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (funding_source_id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), funding_type VARCHAR(255));
Delete all records from the "funding_sources" table where the "region" is "Africa" and the "funding_type" is "grant".
DELETE FROM funding_sources WHERE region = 'Africa' AND funding_type = 'grant';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_threats (id INT, quarter INT, severity VARCHAR(255));
What is the total number of cybersecurity threats and their corresponding severity level for each quarter in the 'cybersecurity_threats' table, sorted by the severity level in ascending order.
SELECT quarter, severity, COUNT(*) as total_threats FROM cybersecurity_threats GROUP BY quarter, severity ORDER BY severity ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name TEXT, country TEXT, launch_date DATE); INSERT INTO satellites (id, name, country, launch_date) VALUES (1, 'Sentinel-1B', 'France', '2016-04-25'); INSERT INTO satellites (id, name, country, launch_date) VALUES (2, 'Sentinel-2B', 'European Space Agency', '2017-03-07'); INSERT INTO satellites (id, name, country, launch_date) VALUES (3, 'TerraSAR-X', 'Germany', '2007-06-15');
Display the names of all satellites launched after 2015
SELECT name FROM satellites WHERE launch_date > '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO farmers (id, name, age, location) VALUES (1, 'James Brown', 45, 'Atlanta'); INSERT INTO farmers (id, name, age, location) VALUES (2, 'Sara Johnson', 50, 'Miami'); INSERT INTO farmers (id, name, age, location) VALUES (3, 'Maria Garcia', 55, 'Houston'); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT, farmer_id INT, PRIMARY KEY (id), FOREIGN KEY (farmer_id) REFERENCES farmers(id)); INSERT INTO crops (id, name, yield, farmer_id) VALUES (1, 'Corn', 200, 1); INSERT INTO crops (id, name, yield, farmer_id) VALUES (2, 'Wheat', 150, 2); INSERT INTO crops (id, name, yield, farmer_id) VALUES (3, 'Rice', 100, 1); INSERT INTO crops (id, name, yield, farmer_id) VALUES (4, 'Soybean', 120, 3); INSERT INTO crops (id, name, yield, farmer_id) VALUES (5, 'Cotton', 80, 3);
Which farmers in the South have more than 5 types of crops?
SELECT farmers.name FROM farmers INNER JOIN crops ON farmers.id = crops.farmer_id GROUP BY farmers.name HAVING COUNT(DISTINCT crops.name) > 5 AND farmers.location LIKE 'Atlanta%';
gretelai_synthetic_text_to_sql
CREATE TABLE SkincareProducts (product_id INT, product_name VARCHAR(255), is_vegan BOOLEAN, sales_date DATE, country VARCHAR(50));
How many vegan skincare products were sold in Canada in the last quarter?
SELECT COUNT(*) FROM SkincareProducts WHERE is_vegan = TRUE AND sales_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), DonationAmount DECIMAL(10,2), DonationDate DATE); CREATE TABLE DonationEvents (EventID INT PRIMARY KEY, EventName VARCHAR(100), EventType VARCHAR(100), DonationID INT, FOREIGN KEY (DonationID) REFERENCES Donors(DonorID)); CREATE TABLE Organizations (OrganizationID INT PRIMARY KEY, OrganizationName VARCHAR(100), VolunteerID INT, FOREIGN KEY (VolunteerID) REFERENCES Donors(DonorID));
What is the average donation amount for 'Sponsorship' events organized by 'Humanity First' and 'Mercy Corps'?
SELECT AVG(DonationAmount) as AverageDonation FROM Donors d JOIN DonationEvents e ON d.DonorID = e.DonationID JOIN Organizations o ON d.DonorID = o.VolunteerID WHERE e.EventType = 'Sponsorship' AND o.OrganizationName IN ('Humanity First', 'Mercy Corps');
gretelai_synthetic_text_to_sql
CREATE TABLE production_line (id INT, line_name VARCHAR(50), energy_consumption INT); INSERT INTO production_line (id, line_name, energy_consumption) VALUES (1, 'Line A', 10000), (2, 'Line B', 12000), (3, 'Line C', 15000), (4, 'Line D', 18000);
What is the average energy consumption of each production line, sorted by the highest consumption?
SELECT line_name, AVG(energy_consumption) as avg_consumption FROM production_line GROUP BY line_name ORDER BY avg_consumption DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyIncidents(id INT, incident_date DATE, incident_type VARCHAR(50), department VARCHAR(50));
What is the average number of safety incidents, grouped by the type of incident, in the past 12 months, for the 'Underground Mining' department, where the number of incidents is greater than 5?
SELECT incident_type, AVG(COUNT(*)) as avg_incidents FROM SafetyIncidents WHERE department = 'Underground Mining' AND incident_date >= DATE(NOW()) - INTERVAL 12 MONTH GROUP BY incident_type HAVING COUNT(*) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (BridgeID INT, Name VARCHAR(255), State VARCHAR(255), MaintenanceSchedule VARCHAR(255), MaintenanceCost FLOAT); INSERT INTO Bridges VALUES (1, 'Bridge A', 'California', 'Quarterly', 5000); INSERT INTO Bridges VALUES (2, 'Bridge B', 'Texas', 'Semi-Annually', 7500); INSERT INTO Bridges VALUES (3, 'Bridge C', 'Florida', 'Annually', 3000);
What is the number of bridges and their respective maintenance schedules for each state, along with the total maintenance cost?
SELECT State, COUNT(*) as BridgeCount, MaintenanceSchedule, SUM(MaintenanceCost) as TotalCost FROM Bridges GROUP BY State, MaintenanceSchedule;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sightings (id INTEGER, species TEXT, location TEXT, year INTEGER); INSERT INTO whale_sightings (id, species, location, year) VALUES (1, 'Gray Whale', 'Washington', 2021), (2, 'Orca', 'British Columbia', 2021), (3, 'Humpback Whale', 'Oregon', 2021);
How many whale sightings were recorded in the Pacific Northwest in 2021?
SELECT COUNT(*) FROM whale_sightings WHERE species IN ('Gray Whale', 'Orca', 'Humpback Whale') AND year = 2021 AND location LIKE '%Pacific Northwest%';
gretelai_synthetic_text_to_sql
CREATE TABLE instructors (id INT, name VARCHAR(50), country VARCHAR(50), expertise VARCHAR(50)); INSERT INTO instructors (id, name, country, expertise) VALUES (1, 'John Doe', 'Canada', 'AI'), (2, 'Jane Smith', 'USA', 'Data Science'), (3, 'Alice Johnson', 'UK', 'Machine Learning');
Update the 'expertise' of instructor 'Jane Smith' to 'Ethical AI'
UPDATE instructors SET expertise = 'Ethical AI' WHERE name = 'Jane Smith';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255), population INT, ocean VARCHAR(255)); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (1, 'Blue Whale', 'Endangered', 1000, 'Atlantic'); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (2, 'Dolphin', 'Least Concern', 50000, 'Pacific'); INSERT INTO species (id, name, conservation_status, population, ocean) VALUES (3, 'Clownfish', 'Vulnerable', 30000, 'Indian');
What is the average population of marine species in the Indian Ocean with a conservation status of 'Vulnerable'?
SELECT ocean, AVG(population) as avg_population FROM species WHERE conservation_status = 'Vulnerable' AND ocean = 'Indian' GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE EuropiumShipments (id INT PRIMARY KEY, mine_id INT, export_year INT, quantity INT, FOREIGN KEY (mine_id) REFERENCES EuropiumMines(id)); CREATE TABLE EuropiumMines (id INT PRIMARY KEY, name VARCHAR(100), production_capacity INT);
What is the total quantity of Europium exported by India from mines with a production capacity between 500 and 1000 tons in the last 3 years?
SELECT SUM(quantity) FROM EuropiumShipments INNER JOIN EuropiumMines ON EuropiumShipments.mine_id = EuropiumMines.id WHERE EuropiumShipments.country = 'India' AND EuropiumMines.production_capacity BETWEEN 500 AND 1000 AND EuropiumShipments.export_year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_date DATE, salesperson_id INT, amount DECIMAL(10, 2)); INSERT INTO transactions (id, transaction_date, salesperson_id, amount) VALUES (1, '2022-01-01', 1, 1500.00), (2, '2022-02-01', 2, 700.00), (3, '2022-03-01', 1, 800.00);
List all transactions with a value greater than $1000 in the East region
SELECT * FROM transactions t JOIN salesperson s ON t.salesperson_id = s.id WHERE s.region = 'East' AND t.amount > 1000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO renewable_energy (id, project_name, location, cost) VALUES (1, 'Solar Farm', 'Miami', 10000000); INSERT INTO renewable_energy (id, project_name, location, cost) VALUES (2, 'Wind Farm', 'Seattle', 6000000);
What is the total cost of projects with 'Wind' as project_name in the 'renewable_energy' table?
SELECT SUM(cost) FROM renewable_energy WHERE project_name LIKE '%Wind%';
gretelai_synthetic_text_to_sql
CREATE TABLE europium_production (id INT, name VARCHAR(255), element VARCHAR(10), country VARCHAR(100), production_date DATE, quantity FLOAT); INSERT INTO europium_production (id, name, element, country, production_date, quantity) VALUES (1, 'Company A', 'Eu', 'China', '2020-01-01', 15.0), (2, 'Company B', 'Eu', 'Australia', '2020-01-15', 20.0), (3, 'Company C', 'Eu', 'Malaysia', '2020-02-01', 25.0), (4, 'Company X', 'Eu', 'China', '2019-01-01', 30.0), (5, 'Company X', 'Eu', 'China', '2020-02-15', 35.0);
Delete all Europium production records for 'Company X' before 2021.
DELETE FROM europium_production WHERE name = 'Company X' AND production_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (clinic_id INT, state VARCHAR(2)); INSERT INTO rural_clinics (clinic_id, state) VALUES (1, 'Texas'), (2, 'Texas'), (3, 'Texas'); CREATE TABLE dental_care (patient_id INT, clinic_id INT, age INT); INSERT INTO dental_care (patient_id, clinic_id, age) VALUES (101, 1, 35), (102, 1, 42), (103, 2, 50), (104, 3, 45);
What is the average age of patients who received dental care in rural clinics located in Texas?
SELECT AVG(age) FROM dental_care d JOIN rural_clinics r ON d.clinic_id = r.clinic_id WHERE r.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE employee (id INT, name VARCHAR(50), gender VARCHAR(50), department_id INT);
Calculate the percentage of male and female employees from the 'employee' table
SELECT (COUNT(CASE WHEN gender = 'male' THEN 1 END) / COUNT(*) * 100) AS male_percentage, (COUNT(CASE WHEN gender = 'female' THEN 1 END) / COUNT(*) * 100) AS female_percentage FROM employee;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, location VARCHAR(50)); INSERT INTO wells VALUES (1, 'Well A', 1000, 'Gulf of Mexico'); INSERT INTO wells VALUES (2, 'Well B', 1500, 'Alaska North Slope'); INSERT INTO wells VALUES (3, 'Well C', 1200, 'Gulf of Mexico'); INSERT INTO wells VALUES (4, 'Well D', 800, 'Gulf of Mexico');
Identify the well with the lowest production volume in the Gulf of Mexico
SELECT well_name, production_volume FROM wells WHERE location = 'Gulf of Mexico' ORDER BY production_volume LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE news_stories (id INT, published_date DATE); INSERT INTO news_stories (id, published_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2022-03-31'), (4, '2022-01-03')
How many news stories were published in January and March 2022?
SELECT COUNT(*) FROM news_stories WHERE MONTH(published_date) IN (1, 3) AND YEAR(published_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing (ID INT, Manufacturer VARCHAR(255), Mass INT, Year INT); INSERT INTO SpacecraftManufacturing (ID, Manufacturer, Mass, Year) VALUES (1, 'SpaceCorp', 3000, 2022), (2, 'SpaceCorp', 4000, 2022), (3, 'Galactic', 5000, 2022);
What is the average mass of spacecraft manufactured by SpaceCorp in 2022?
SELECT AVG(Mass) FROM SpacecraftManufacturing WHERE Manufacturer = 'SpaceCorp' AND Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_us (state VARCHAR(20), sector VARCHAR(20), usage FLOAT); INSERT INTO water_usage_us (state, sector, usage) VALUES ('California', 'Industrial', 1200), ('California', 'Agriculture', 3500), ('California', 'Domestic', 800), ('Texas', 'Industrial', 1100), ('Texas', 'Agriculture', 4000), ('Texas', 'Domestic', 900), ('Florida', 'Industrial', 900), ('Florida', 'Agriculture', 3000), ('Florida', 'Domestic', 700);
List the top 3 states with the highest water consumption in the agricultural sector
SELECT state, usage FROM water_usage_us WHERE sector = 'Agriculture' ORDER BY usage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE facility_city (facility_id INT, name VARCHAR(50), city VARCHAR(20)); INSERT INTO facility_city (facility_id, name, city) VALUES (1, 'Happy Minds', 'New York City'); INSERT INTO facility_city (facility_id, name, city) VALUES (2, 'California Care', 'Los Angeles');
What is the total number of mental health facilities in each city?
SELECT city, COUNT(*) FROM facility_city GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, city VARCHAR(50), visit_year INT, gender VARCHAR(10));
How many visitors identified as female attended exhibitions in New York in the last 3 years?
SELECT COUNT(*) FROM Visitors WHERE city = 'New York' AND gender = 'Female' AND visit_year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_residents (id INT, state VARCHAR(2), has_primary_care BOOLEAN); INSERT INTO rural_residents (id, state, has_primary_care) VALUES (1, 'AR', TRUE); CREATE TABLE states (state_abbr VARCHAR(2), state_name VARCHAR(20), pop_rural INT); INSERT INTO states (state_abbr, state_name, pop_rural) VALUES ('AR', 'Arkansas', 750000);
Find the state with the lowest percentage of rural residents without access to primary care.
SELECT r.state, (COUNT(*)::FLOAT / s.pop_rural::FLOAT) * 100 AS pct_primary_care FROM rural_residents r JOIN states s ON r.state = s.state_abbr WHERE r.has_primary_care GROUP BY r.state ORDER BY pct_primary_care ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID int, FirstName varchar(20), LastName varchar(20), Age int, Gender varchar(10), Grade int);
Delete a student record from the 'Students' table
DELETE FROM Students WHERE StudentID = 1234;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, grade INT, mental_health_score INT, participated_open_pedagogy BOOLEAN); INSERT INTO students (student_id, grade, mental_health_score, participated_open_pedagogy) VALUES (1, 6, 80, true), (2, 7, 70, false), (3, 8, 90, true);
What is the average mental health score of students who have participated in open pedagogy programs, grouped by their grade level?
SELECT grade, AVG(mental_health_score) as avg_score FROM students WHERE participated_open_pedagogy = true GROUP BY grade;
gretelai_synthetic_text_to_sql
CREATE TABLE PhishingAttacks (attack_id INT, attack_date DATE, attack_target_sector VARCHAR(50), attack_threat_actor_group VARCHAR(50));
What are the threat actor groups involved in phishing attacks targeting the education sector in the last 6 months?
SELECT attack_threat_actor_group FROM PhishingAttacks WHERE attack_target_sector = 'education' AND attack_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, line TEXT);CREATE TABLE trip_distance (distance INT, trip_id INT, route_id INT);
What is the total distance traveled by each route?
SELECT r.line, SUM(td.distance) FROM route r INNER JOIN trip_distance td ON r.route_id = td.route_id GROUP BY r.line;
gretelai_synthetic_text_to_sql
CREATE TABLE staff(id INT, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO staff VALUES (1, 'Alex', 'Research Assistant', 'Engineering', 40000.0); INSERT INTO staff VALUES (2, 'Beth', 'Lab Technician', 'Engineering', 45000.0); INSERT INTO staff VALUES (3, 'Carl', 'Research Assistant', 'Engineering', 42000.0);
What is the maximum salary of any research assistant in the College of Engineering?
SELECT MAX(salary) FROM staff WHERE position = 'Research Assistant' AND department = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE baseball_games (game_date DATE, home_team VARCHAR(255), away_team VARCHAR(255)); INSERT INTO baseball_games (game_date, home_team, away_team) VALUES ('2022-01-01', 'Yankees', 'Red Sox'); INSERT INTO baseball_games (game_date, home_team, away_team) VALUES ('2022-01-02', 'Dodgers', 'Giants');
Get the number of baseball games played in 2022
SELECT COUNT(*) FROM baseball_games WHERE YEAR(game_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (state TEXT, type TEXT, number INT); INSERT INTO plants (state, type, number) VALUES ('California', 'WWTP', 300), ('California', 'STP', 500), ('Texas', 'WWTP', 400), ('Texas', 'STP', 600);
Show the number of wastewater treatment plants in California and Texas.
SELECT state, SUM(number) FROM plants WHERE state IN ('California', 'Texas') AND type = 'WWTP' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, industry TEXT); CREATE TABLE members (id INT, union_id INT, age INT, salary INT); CREATE TABLE union_memberships (member_id INT, union_id INT);
Calculate the total number of members in the 'healthcare' union with a salary above the average.
SELECT COUNT(*) FROM members JOIN union_memberships ON members.id = union_memberships.member_id WHERE members.union_id IN (SELECT id FROM unions WHERE industry = 'healthcare') AND members.salary > (SELECT AVG(salary) FROM members WHERE union_id IN (SELECT id FROM unions WHERE industry = 'healthcare'));
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Infrastructure_Projects (id INT, project_name TEXT, budget FLOAT, country TEXT); INSERT INTO Rural_Infrastructure_Projects (id, project_name, budget, country) VALUES (1, 'Smart Irrigation', 100000.00, 'Indonesia'), (2, 'Rural Road Upgrade', 120000.00, 'Indonesia');
What is the maximum budget (in USD) for rural infrastructure projects in Indonesia?
SELECT MAX(budget) FROM Rural_Infrastructure_Projects WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, industry VARCHAR(10), safety_issues INT); INSERT INTO workplaces (id, industry, safety_issues) VALUES (1, 'Manufacturing', 10), (2, 'Construction', 5), (3, 'Manufacturing', 15), (4, 'Retail', 8);
What is the total number of workplaces with safety issues in each industry?
SELECT industry, SUM(safety_issues) OVER (PARTITION BY industry) AS total_safety_issues FROM workplaces;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_class TEXT, sales_amount INTEGER);
What was the maximum sales amount for cardiovascular drugs?
SELECT MAX(sales_amount) FROM sales WHERE drug_class = 'cardiovascular';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, location VARCHAR(255), revenue INT); INSERT INTO Concerts (id, location, revenue) VALUES (1, 'Asia', 2000000), (2, 'Europe', 1500000), (3, 'North America', 1800000);
What is the total revenue for concerts in Asia?
SELECT SUM(revenue) FROM Concerts WHERE location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investing (country VARCHAR(50), avg_donation DECIMAL(10,2)); INSERT INTO impact_investing (country, avg_donation) VALUES ('United States', 5000.00), ('Germany', 4000.00), ('Canada', 3500.00), ('Australia', 3000.00), ('United Kingdom', 2500.00);
What are the top 5 countries with the highest average donation amounts in the impact investing sector?
SELECT country, AVG(avg_donation) FROM impact_investing GROUP BY country ORDER BY AVG(avg_donation) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT, policyholder_id INT, amount DECIMAL(10, 2)); INSERT INTO claims (claim_id, policyholder_id, amount) VALUES (1, 1, 500), (2, 3, 100), (3, 2, 300), (4, 1, 700); CREATE TABLE policyholders (policyholder_id INT, location VARCHAR(10)); INSERT INTO policyholders (policyholder_id, location) VALUES (1, 'Rural'), (2, 'Urban'), (3, 'Suburban'), (4, 'Rural');
What is the total claim amount for policyholders living in rural areas?
SELECT SUM(c.amount) as total_claim_amount FROM claims c JOIN policyholders ph ON c.policyholder_id = ph.policyholder_id WHERE ph.location IN ('Rural', 'rural');
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTest (Id INT, VehicleType VARCHAR(50), TestYear INT, TestResult VARCHAR(50)); CREATE VIEW Sedans AS SELECT * FROM Vehicles WHERE VehicleType = 'Sedan';
How many safety tests were conducted on sedans in the 'SafetyTest' database between 2018 and 2020?
SELECT COUNT(*) FROM SafetyTest JOIN Sedans ON SafetyTest.VehicleType = Sedans.VehicleType WHERE TestYear BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists policies (policy_id INT, policy_name VARCHAR, last_access DATE); INSERT INTO policies (policy_id, policy_name, last_access) VALUES (1, 'Acceptable Use Policy', '2021-06-01'), (2, 'Incident Response Plan', '2021-05-15'), (3, 'Password Policy', '2021-06-10');
How many times has each security policy been accessed in the past month?
SELECT policy_id, policy_name, COUNT(*) as access_count FROM policies WHERE last_access >= DATEADD(month, -1, GETDATE()) GROUP BY policy_id, policy_name;
gretelai_synthetic_text_to_sql
CREATE TABLE social_media(user_id INT, user_name VARCHAR(50), region VARCHAR(50), post_date DATE, hashtags BOOLEAN, likes INT);
What is the percentage of posts with hashtags in the 'social_media' table, for users in 'North America'?
SELECT 100.0 * SUM(hashtags) / COUNT(*) as hashtag_percentage FROM social_media WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, Age INT, Gender VARCHAR(20), State VARCHAR(20)); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (1, 45, 'Female', 'Florida'); INSERT INTO CommunityHealthWorker (WorkerID, Age, Gender, State) VALUES (2, 35, 'Male', 'Florida');
What is the maximum age of a community health worker in Florida?
SELECT MAX(Age) FROM CommunityHealthWorker WHERE State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (id INT, city VARCHAR(50), type VARCHAR(50)); INSERT INTO vehicles (id, city, type) VALUES (1, 'Paris', 'bus'), (2, 'Paris', 'subway'), (3, 'Paris', 'tram'), (4, 'Tokyo', 'train');
What is the total number of vehicles in Paris?
SELECT COUNT(*) FROM vehicles WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO movies (id, title, release_year, views, country, genre) VALUES (1, 'Movie1', 2010, 10000, 'Canada', 'Comedy'), (2, 'Movie2', 2015, 15000, 'Canada', 'Drama'); CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO tv_shows (id, title, release_year, views, country, genre) VALUES (1, 'TVShow1', 2005, 20000, 'Canada', 'Action'), (2, 'TVShow2', 2018, 25000, 'Canada', 'Comedy');
How many unique genres are there for movies and TV shows in Canada?
SELECT DISTINCT genre FROM movies WHERE country = 'Canada' UNION SELECT DISTINCT genre FROM tv_shows WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE SCHEMA FoodService;CREATE TABLE Inspections (inspection_id INT, restaurant_id INT, inspection_date DATE, violations INT); INSERT INTO Inspections (inspection_id, restaurant_id, inspection_date, violations) VALUES (1, 1, '2021-01-01', 3), (2, 1, '2021-04-01', 0), (3, 2, '2021-02-01', 2), (4, 2, '2021-05-01', 1);CREATE SCHEMA FoodService;CREATE TABLE Restaurants (restaurant_id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO Restaurants (restaurant_id, name, category) VALUES (1, 'Cafe Azure', 'dining'), (2, 'Bistro Blanc', 'takeout');
What is the percentage of food safety violations for each restaurant in the past year?
SELECT restaurant_id, (COUNT(violations) * 100.00 / (SELECT COUNT(*) FROM Inspections WHERE inspection_date >= '2020-01-01')) as violation_percentage FROM Inspections WHERE inspection_date >= '2020-01-01' GROUP BY restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, actor VARCHAR(50), timestamp TIMESTAMP, resolution_timestamp TIMESTAMP);
What is the average time to resolution for security incidents caused by each threat actor, ordered by the average time to resolution in ascending order?
SELECT actor, AVG(UNIX_TIMESTAMP(resolution_timestamp) - UNIX_TIMESTAMP(timestamp)) as avg_resolution_time FROM security_incidents GROUP BY actor ORDER BY avg_resolution_time ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE mediators (id INT, name VARCHAR(255), cases_mediated INT, year INT); INSERT INTO mediators (id, name, cases_mediated, year) VALUES (1, 'Alex', 22, 2021), (2, 'Taylor', 28, 2021), (3, 'Jamie', 35, 2021);
List the names and number of cases for the top 3 most active mediators in 2021?
SELECT name, cases_mediated FROM (SELECT name, cases_mediated, ROW_NUMBER() OVER (ORDER BY cases_mediated DESC) as rn FROM mediators WHERE year = 2021) tmp WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE RecycledPolyesterGarments (id INT, co2_emission DECIMAL); INSERT INTO RecycledPolyesterGarments (id, co2_emission) VALUES (1, 5.6), (2, 6.2), (3, 5.9), (4, 6.8), (5, 6.3);
What is the total CO2 emission of garments made from recycled polyester?
SELECT SUM(co2_emission) FROM RecycledPolyesterGarments;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption (factory_id INT, industry VARCHAR(50), region VARCHAR(50), energy_consumption INT);
What is the total energy consumption of the top 2 most energy-intensive manufacturing industries in North America?
SELECT industry, SUM(energy_consumption) FROM energy_consumption e JOIN (SELECT factory_id, MIN(row_number) FROM (SELECT factory_id, ROW_NUMBER() OVER (PARTITION BY industry ORDER BY energy_consumption DESC) row_number FROM energy_consumption) t GROUP BY industry) x ON e.factory_id = x.factory_id GROUP BY industry HAVING COUNT(*) <= 2 AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE ResidentialWaterUse (household_id INT, consumption FLOAT, month DATE);
Count the number of households in 'ResidentialWaterUse' table that have a water consumption between 150 and 250 liters per month
SELECT COUNT(*) FROM ResidentialWaterUse WHERE consumption BETWEEN 150 AND 250;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy ( id INT PRIMARY KEY, source VARCHAR(50), capacity_mw INT ); INSERT INTO renewable_energy (id, source, capacity_mw) VALUES (1, 'hydro', 600), (2, 'solar', 300), (3, 'wind', 400);
Update the "capacity_mw" column in the "renewable_energy" table to 450 for records where the "source" is 'wind'
UPDATE renewable_energy SET capacity_mw = 450 WHERE source = 'wind';
gretelai_synthetic_text_to_sql
CREATE TABLE FishFarming (id INT, species VARCHAR(20), weight FLOAT, farm_location VARCHAR(30));
Calculate the total weight of 'Cod' and 'Tuna' in the 'FishFarming' table, grouped by farm location
SELECT farm_location, SUM(CASE WHEN species = 'Cod' THEN weight ELSE 0 END) + SUM(CASE WHEN species = 'Tuna' THEN weight ELSE 0 END) AS total_weight FROM FishFarming GROUP BY farm_location;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (dish_id INT, dish_name VARCHAR(100), dish_type VARCHAR(20)); CREATE TABLE Revenue (revenue_id INT, revenue_date DATE, revenue_amount DECIMAL(10,2), dish_id INT); INSERT INTO Menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'); INSERT INTO Menu (dish_id, dish_name, dish_type) VALUES (2, 'Grilled Chicken', 'Non-Vegetarian'); INSERT INTO Revenue (revenue_id, revenue_date, revenue_amount, dish_id) VALUES (1, '2022-03-01', 150, 1); INSERT INTO Revenue (revenue_id, revenue_date, revenue_amount, dish_id) VALUES (2, '2022-03-02', 200, 2);
Identify the dish type with the highest revenue in the month of March 2022
SELECT dish_type, SUM(revenue_amount) AS revenue FROM Revenue JOIN Menu ON Revenue.dish_id = Menu.dish_id WHERE revenue_date BETWEEN '2022-03-01' AND '2022-03-31' GROUP BY dish_type ORDER BY revenue DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (campaign VARCHAR(20), location VARCHAR(20), year INT); INSERT INTO climate_communication (campaign, location, year) VALUES ('Campaign J', 'South America', 2019), ('Campaign K', 'Europe', 2018), ('Campaign L', 'Asia', 2019);
List the climate communication campaigns that were conducted in South America in 2019.
SELECT campaign FROM climate_communication WHERE location = 'South America' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE contract_negotiations (company VARCHAR(255), region VARCHAR(255), year INT, num_negotiations INT); INSERT INTO contract_negotiations (company, region, year, num_negotiations) VALUES ('Boeing', 'Asia', 2020, 40), ('Boeing', 'Asia', 2021, 45);
What is the total number of contract negotiations conducted by Boeing with Asia in 2020 and 2021?
SELECT SUM(num_negotiations) FROM contract_negotiations WHERE company = 'Boeing' AND region = 'Asia' AND year IN (2020, 2021);
gretelai_synthetic_text_to_sql