context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE FactoryWaterUsage (factory_id INT, uses_water_efficient_methods BOOLEAN); INSERT INTO FactoryWaterUsage (factory_id, uses_water_efficient_methods) VALUES (1, true), (2, false), (3, true); CREATE TABLE Factories (factory_id INT, region VARCHAR(50)); INSERT INTO Factories (factory_id, region) VALUES (1, 'Oceania'), (2, 'Africa'), (3, 'Oceania');
List all factories that use water-efficient methods in Oceania.
SELECT factory_id, region FROM FactoryWaterUsage INNER JOIN Factories ON FactoryWaterUsage.factory_id = Factories.factory_id WHERE Factories.region = 'Oceania' AND FactoryWaterUsage.uses_water_efficient_methods = true;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending_sa (id INT, country VARCHAR(255), loan_amount DECIMAL(10,2)); INSERT INTO socially_responsible_lending_sa (id, country, loan_amount) VALUES (1, 'Brazil', 6000.00), (2, 'Argentina', 8000.00), (3, 'Colombia', 5000.00);
What is the minimum and maximum loan amount for socially responsible lending in South America?
SELECT MIN(loan_amount) as "Min Loan Amount", MAX(loan_amount) as "Max Loan Amount" FROM socially_responsible_lending_sa WHERE country IN ('Brazil', 'Argentina', 'Colombia');
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT PRIMARY KEY, incident_date DATE, location VARCHAR(50), crime_type VARCHAR(50), description TEXT, FOREIGN KEY (incident_date) REFERENCES dates(date));
What is the total number of crimes committed by type in 2021?
SELECT crime_type, COUNT(*) as total_crimes FROM crimes JOIN dates ON crimes.incident_date = dates.date WHERE dates.date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY crime_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID INT, State VARCHAR(20), Region VARCHAR(20), BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, State, Region, BillingAmount) VALUES (1, 'California', 'West', 5000.00), (2, 'Texas', 'South', 3500.00), (3, 'California', 'West', 4000.00), (4, 'New York', 'Northeast', 6000.00);
What is the number of cases in each state, grouped by region?
SELECT Region, State, COUNT(*) AS NumberOfCases FROM Cases GROUP BY Region, State;
gretelai_synthetic_text_to_sql
CREATE TABLE loans (loan_id INT, client_id INT, country VARCHAR(50), loan_amount DECIMAL(10,2)); INSERT INTO loans (loan_id, client_id, country, loan_amount) VALUES (1, 3, 'Indonesia', 25000);
What is the maximum loan amount for clients in Indonesia?
SELECT MAX(loan_amount) FROM loans WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE urban_solar_installations (installation_id INT, city VARCHAR(50), state VARCHAR(50), installation_type VARCHAR(50));
What is the total number of solar panel installations in urban areas, grouped by city and state, where the installation count is greater than 500?
SELECT city, state, COUNT(installation_id) FROM urban_solar_installations GROUP BY city, state HAVING COUNT(installation_id) > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_violations (id INT, date DATE, industry VARCHAR(255), violation_count INT); INSERT INTO safety_violations (id, date, industry, violation_count) VALUES (1, '2022-07-01', 'construction', 10), (2, '2022-08-01', 'construction', 15), (3, '2022-09-01', 'construction', 12);
What is the total number of workplace safety violations in the 'construction' schema for the months of 'July' and 'August' in '2022'?
SELECT SUM(violation_count) FROM safety_violations WHERE industry = 'construction' AND date BETWEEN '2022-07-01' AND '2022-08-31';
gretelai_synthetic_text_to_sql
CREATE TABLE InternationalConferences (ConferenceID INT, ConferenceName VARCHAR(50), NumberOfAttendees INT);
List the conferences that have more than 100 attendees.
SELECT ConferenceName FROM InternationalConferences WHERE NumberOfAttendees > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, age INT, name VARCHAR(255)); INSERT INTO donors (id, age, name) VALUES (1, 19, 'Global Health Donor'); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, organization_id, amount, donation_date) VALUES (1, 1, 3, 5000, '2021-06-15'); CREATE TABLE organizations (id INT, name VARCHAR(255), focus VARCHAR(255)); INSERT INTO organizations (id, name, focus) VALUES (3, 'Global Health Initiative', 'Global Health');
What is the average donation amount for donors aged 18-24 who have donated to organizations focused on global health?
SELECT AVG(amount) FROM donations JOIN donors ON donations.donor_id = donors.id JOIN organizations ON donations.organization_id = organizations.id WHERE donors.age BETWEEN 18 AND 24 AND organizations.focus = 'Global Health';
gretelai_synthetic_text_to_sql
CREATE TABLE Drivers (id INT, name VARCHAR(255), vehicle_type VARCHAR(50), vehicle_year INT, total_rides INT, total_revenue FLOAT); INSERT INTO Drivers (id, name, vehicle_type, vehicle_year, total_rides, total_revenue) VALUES (1, 'Hana', 'Nissan Leaf', 2020, 260, 3800.00), (2, 'Liam', 'Tesla', 2021, 300, 5000.00);
What is the total revenue earned by drivers driving Tesla or Nissan Leaf vehicles with more than 250 rides?
SELECT SUM(total_revenue) FROM (SELECT total_revenue FROM Drivers WHERE vehicle_type = 'Tesla' AND total_rides > 250 UNION ALL SELECT total_revenue FROM Drivers WHERE vehicle_type = 'Nissan Leaf' AND total_rides > 250) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE factories_location (id INT, name VARCHAR(50), location VARCHAR(50), accidents INT); INSERT INTO factories_location (id, name, location, accidents) VALUES (1, 'Factory A', 'urban', 2), (2, 'Factory B', 'rural', 0), (3, 'Factory C', 'urban', 3), (4, 'Factory D', 'rural', 1);
Display the total number of accidents in factories located in urban areas
SELECT SUM(accidents) FROM factories_location WHERE location = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(255)); CREATE TABLE RegulatoryViolations (id INT, company_id INT, violation_date DATE); INSERT INTO Companies (id, name) VALUES (1, 'CompanyA'), (2, 'CompanyB'), (3, 'CompanyC'); INSERT INTO RegulatoryViolations (id, company_id, violation_date) VALUES (1, 1, '2021-08-01'), (2, 1, '2021-09-01'), (3, 2, '2021-07-01'), (4, 3, '2021-06-01');
What is the total number of regulatory violations by the company with the id 2 up to and including 2021-09-30?
SELECT COUNT(*) FROM RegulatoryViolations JOIN Companies ON RegulatoryViolations.company_id = Companies.id WHERE Companies.id = 2 AND RegulatoryViolations.violation_date <= '2021-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Animals (name VARCHAR(50), species VARCHAR(50), location VARCHAR(50)); INSERT INTO Animals (name, species, location) VALUES ('Seal 1', 'Seal', 'Arctic Ocean'), ('Seal 2', 'Seal', 'Arctic Ocean'), ('Walrus 1', 'Walrus', 'Arctic Ocean');
How many seals are in the Arctic Ocean?
SELECT COUNT(*) FROM Animals WHERE species = 'Seal' AND location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, ProjectValue DECIMAL(10,2), IsSustainable BOOLEAN, State CHAR(2));
What is the total value of all sustainable building projects in California?
SELECT SUM(ProjectValue) FROM Projects WHERE State='CA' AND IsSustainable=TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE PolarSeasConservation (id INT, species TEXT, status TEXT); INSERT INTO PolarSeasConservation (id, species, status) VALUES (1, 'Polar Bear', 'Vulnerable'); INSERT INTO PolarSeasConservation (id, species, status) VALUES (2, 'Walrus', 'Protected');
List all marine species and their status under maritime law in the Polar Seas Conservation database.
SELECT species, status FROM PolarSeasConservation;
gretelai_synthetic_text_to_sql
CREATE TABLE Salaries (id INT, company_id INT, job_role VARCHAR(50), salary INT); INSERT INTO Salaries (id, company_id, job_role, salary) VALUES (1, 1, 'Engineer', 90000), (2, 1, 'Manager', 120000), (3, 2, 'Engineer', 95000);
What is the average salary by company and job role?
SELECT company_id, job_role, AVG(salary) as avg_salary, RANK() OVER (PARTITION BY AVG(salary) ORDER BY AVG(salary) DESC) as salary_rank FROM Salaries GROUP BY company_id, job_role;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name TEXT, type TEXT); INSERT INTO strains (id, name, type) VALUES (12, 'Blue Dream', 'Hybrid'), (13, 'OG Kush', 'Indica'), (14, 'Jack Herer', 'Sativa'); CREATE TABLE sales (id INT, strain_id INT, retail_price DECIMAL, sale_date DATE, state TEXT); INSERT INTO sales (id, strain_id, retail_price, sale_date, state) VALUES (33, 12, 38.00, '2022-07-01', 'Massachusetts'), (34, 13, 40.00, '2022-08-15', 'Massachusetts'), (35, 14, 42.00, '2022-09-30', 'Massachusetts');
Identify the top 5 strains with the highest average retail price in Massachusetts dispensaries during Q3 2022.
SELECT name, AVG(retail_price) FROM (SELECT name, retail_price, ROW_NUMBER() OVER (PARTITION BY name ORDER BY retail_price DESC) rn FROM sales WHERE state = 'Massachusetts' AND sale_date >= '2022-07-01' AND sale_date < '2022-10-01') tmp WHERE rn <= 5 GROUP BY name ORDER BY AVG(retail_price) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_projects (id INT, country VARCHAR(50), capacity FLOAT);
What is the total capacity of wind energy projects in Germany?
SELECT SUM(capacity) FROM wind_projects WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_methods (method VARCHAR(50), location VARCHAR(50), mineral VARCHAR(50), year INT); INSERT INTO mining_methods (method, location, mineral, year) VALUES ('Open-pit', 'US', 'Copper', 2020), ('Underground', 'US', 'Copper', 2020), ('In-situ leaching', 'US', 'Uranium', 2020);
Which mining methods were used in the US for Copper extraction in 2020?
SELECT DISTINCT method FROM mining_methods WHERE location = 'US' AND mineral = 'Copper' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE donor_donations (donor_id INT, donation_amount DECIMAL(10, 2), cause_category VARCHAR(255)); INSERT INTO donor_donations (donor_id, donation_amount, cause_category) VALUES (1, 5000.00, 'Education'), (2, 3000.00, 'Health'), (3, 7000.00, 'Environment'), (1, 6000.00, 'Health');
What is the average donation amount per donor for each cause category?
SELECT cause_category, AVG(donation_amount) AS avg_donation, MIN(donation_amount) AS min_donation, MAX(donation_amount) AS max_donation FROM donor_donations GROUP BY cause_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Geopolitical_Risk_Assessments (assessment_id INT, assessment_date DATE, country VARCHAR(50)); INSERT INTO Geopolitical_Risk_Assessments (assessment_id, assessment_date, country) VALUES (1, '2021-05-12', 'France'), (2, '2021-07-03', 'Germany'), (3, '2021-11-28', 'Italy');
How many geopolitical risk assessments were conducted in 2021 for any country?
SELECT COUNT(assessment_id) FROM Geopolitical_Risk_Assessments WHERE YEAR(assessment_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE permit (permit_id INT, state VARCHAR(50), project_type VARCHAR(50), issue_date DATE); INSERT INTO permit (permit_id, state, project_type, issue_date) VALUES (1, 'Texas', 'Residential', '2015-01-01');
How many permits were issued in Texas for residential construction projects between 2015 and 2017?
SELECT COUNT(*) FROM permit WHERE state = 'Texas' AND project_type = 'Residential' AND issue_date BETWEEN '2015-01-01' AND '2017-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, subscribe_date DATE, city VARCHAR(255)); INSERT INTO broadband_subscribers (subscriber_id, subscribe_date, city) VALUES (1, '2021-03-01', 'Los Angeles'), (2, '2021-05-15', 'Toronto'), (3, '2021-03-04', 'Mexico City'), (4, '2021-10-20', 'São Paulo'), (5, '2022-07-03', 'New York'), (6, '2022-11-18', 'London');
How many broadband subscribers have been added monthly, by city, for the past year?
SELECT YEAR(subscribe_date) AS year, MONTH(subscribe_date) AS month, city, COUNT(subscriber_id) AS new_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY year, month, city;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation(region VARCHAR(10), year INT, amount INT); INSERT INTO waste_generation VALUES('urban', 2019, 1500), ('urban', 2020, 1800), ('rural', 2019, 800), ('rural', 2020, 1000);
Which region has the highest waste generation in 2020?
SELECT region, MAX(amount) FROM waste_generation WHERE year = 2020 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT);CREATE TABLE emergencies (id INT, district_id INT, category_id INT, response_time INT, date DATE);CREATE TABLE emergency_categories (id INT, name TEXT);
What is the average response time for emergency calls in the 'fire' category in each district over the last month?
SELECT d.name, AVG(e.response_time) FROM districts d JOIN emergencies e ON d.id = e.district_id JOIN emergency_categories ec ON e.category_id = ec.id WHERE ec.name = 'fire' AND e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_reports (incident_id INT, department VARCHAR(255), incident_type VARCHAR(255), reported_date TIMESTAMP);
Insert a new security incident report for a phishing attack on the HR department from yesterday.
INSERT INTO incident_reports (incident_id, department, incident_type, reported_date) VALUES (1, 'HR', 'Phishing', NOW() - INTERVAL '1 day');
gretelai_synthetic_text_to_sql
CREATE TABLE grades (id INT, level TEXT); CREATE TABLE projects (id INT, student_id INT, hours INT, open_pedagogy BOOLEAN);
What is the total number of hours spent on open pedagogy projects by students in each grade level?
SELECT g.level, SUM(p.hours) FROM projects p JOIN grades g ON p.student_id = g.id WHERE p.open_pedagogy = TRUE GROUP BY g.id;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_arts (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), region VARCHAR(255));
Update the region of a traditional art in the 'traditional_arts' table
UPDATE traditional_arts SET region = 'Central Asia' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_vendors (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255));
Update the country for Green Waves vendor in the sustainable_vendors table
UPDATE sustainable_vendors SET country = 'USA' WHERE name = 'Green Waves';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, quantity INT, sale_date DATE); CREATE TABLE products (id INT, name TEXT, is_cruelty_free BOOLEAN, category TEXT);
What's the most popular cruelty-free skincare product?
SELECT products.name, SUM(sales.quantity) as total_sold FROM sales JOIN products ON sales.product_id = products.id WHERE products.is_cruelty_free = true GROUP BY products.name ORDER BY total_sold DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, AgeGroup varchar(50), AmountDonated numeric(10,2)); INSERT INTO Donors (DonorID, AgeGroup, AmountDonated) VALUES (1, '18-24', 200.00), (2, '25-34', 300.00);
What was the total amount donated by each age group in Q3 2021?
SELECT AgeGroup, SUM(AmountDonated) as TotalDonated FROM Donors WHERE AmountDonated >= 0 AND AmountDonated < 9999.99 GROUP BY AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE hockey_games (id INT, team_id INT, game_date DATE); INSERT INTO hockey_games (id, team_id, game_date) VALUES (1, 1, '2021-10-01'), (2, 2, '2021-10-05'), (3, 1, '2021-11-03');
Show the total number of games played by each team in the hockey_games table
SELECT team_id, COUNT(*) as games_played FROM hockey_games GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_sources (id INT, name VARCHAR(255), region VARCHAR(255), pollution_amount INT); INSERT INTO pollution_sources (id, name, region, pollution_amount) VALUES (1, 'Oceanic Chemical Pollution', 'Atlantic Ocean', 60000); INSERT INTO pollution_sources (id, name, region, pollution_amount) VALUES (2, 'Marine Debris', 'Indian Ocean', 30000);
Display the name and region for pollution sources in the pollution_sources table, ordered by pollution amount in descending order.
SELECT name, region FROM pollution_sources ORDER BY pollution_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE locations (id INT, name VARCHAR(255)); CREATE TABLE community_policing (id INT, location_id INT, year INT, events INT); INSERT INTO locations (id, name) VALUES (1, 'Uptown'); INSERT INTO community_policing (id, location_id, year, events) VALUES (1, 1, 2020, 3), (2, 1, 2021, 5);
How many community policing events were held in 'Uptown' in 2020 and 2021?
SELECT SUM(events) FROM (SELECT year, events FROM community_policing WHERE location_id = (SELECT id FROM locations WHERE name = 'Uptown') AND year IN (2020, 2021)) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE ride_hailing (ride_id INT, user_id INT, start_time TIMESTAMP, end_time TIMESTAMP, city VARCHAR(255));
How many users have used ride-hailing services in Paris more than 10 times?
SELECT COUNT(DISTINCT user_id) FROM ride_hailing WHERE city = 'Paris' GROUP BY user_id HAVING COUNT(ride_id) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, name VARCHAR(50));
Insert a new game into the games table
INSERT INTO games (game_id, name) VALUES (3, 'GameX');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date, IsReturningDonor bit); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate, IsReturningDonor) VALUES (1, 'Individual', 'Brazil', 3000, '2023-01-02', 1), (2, 'Organization', 'Argentina', 8000, '2023-01-03', 0);
What is the average donation amount in Q1 2023 from returning donors in Latin America?
SELECT AVG(AmountDonated) FROM Donors WHERE DonorType = 'Individual' AND Country LIKE 'Latin America%' AND IsReturningDonor = 1 AND QUARTER(DonationDate) = 1 AND YEAR(DonationDate) = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_id INT, policyholder_state VARCHAR(20)); INSERT INTO policies (policy_id, policyholder_state) VALUES (1, 'Texas'), (2, 'California'), (3, 'Texas');
How many policies were issued to policyholders in 'Texas'?
SELECT COUNT(*) FROM policies WHERE policyholder_state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE movie (id INT, title VARCHAR(100), genre VARCHAR(20), release_year INT, IMDb_rating DECIMAL(3,1), marketing_spend INT); INSERT INTO movie (id, title, genre, release_year, IMDb_rating, marketing_spend) VALUES (1, 'Silver Linings Playbook', 'Romantic Comedy', 2012, 7.7, 20000000);
What is the total marketing spend for all romantic-comedy movies released between 2015 and 2020, and their respective IMDb ratings?
SELECT SUM(marketing_spend), AVG(IMDb_rating) FROM movie WHERE genre = 'Romantic Comedy' AND release_year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT, status VARCHAR(50)); INSERT INTO spacecraft (id, name, manufacturer, mass, status) VALUES (5, 'Atlas V', 'United Launch Alliance', 587000.0, 'Active'); INSERT INTO spacecraft (id, name, manufacturer, mass, status) VALUES (6, 'Titan IV', 'Lockheed Martin', 756000.0, 'Retired');
What is the average mass (in kg) of all spacecraft that have been used in space missions, excluding any spacecraft that have been decommissioned?
SELECT AVG(mass) FROM spacecraft WHERE status = 'Active';
gretelai_synthetic_text_to_sql
CREATE TABLE materials_sourcing_2 (id INT, industry VARCHAR(50), supplier_location VARCHAR(50), value DECIMAL(10,2), fiscal_year INT); INSERT INTO materials_sourcing_2 (id, industry, supplier_location, value, fiscal_year) VALUES (1, 'Construction', 'Local', 120000.00, 2022), (2, 'Fashion', 'International', 200000.00, 2022), (3, 'Construction', 'International', 180000.00, 2022), (4, 'Fashion', 'Local', 60000.00, 2022), (5, 'Construction', 'Local', 250000.00, 2021);
What is the total value of materials sourced from local suppliers for the construction industry in the last fiscal year?
SELECT SUM(value) FROM materials_sourcing_2 WHERE industry = 'Construction' AND supplier_location = 'Local' AND fiscal_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(50), region VARCHAR(50));
List all countries and their regions from the countries table
SELECT name, region FROM countries;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, food_safety_violations INT, corrective_actions INT); INSERT INTO suppliers (id, name, food_safety_violations, corrective_actions) VALUES (1, 'Supplier A', 2, 1), (2, 'Supplier B', 3, 0), (3, 'Supplier C', 0, 0), (4, 'Supplier D', 1, 1);
List suppliers with food safety violations in the last year, excluding those with corrective actions taken.
SELECT name FROM suppliers WHERE food_safety_violations > 0 AND corrective_actions = 0 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, name TEXT, country TEXT, safety_score FLOAT); INSERT INTO ai_models (model_id, name, country, safety_score) VALUES (1, 'ModelA', 'Germany', 0.85), (2, 'ModelB', 'France', 0.90), (3, 'ModelC', 'US', 0.75), (4, 'ModelD', 'Germany', 0.95), (5, 'ModelE', 'France', 0.92);
What is the maximum safety score achieved by a model developed in the EU?
SELECT MAX(safety_score) FROM ai_models WHERE country IN ('Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO graduate_students (student_id, name, country) VALUES (1, 'Alice', 'India'), (2, 'Bob', 'Canada'), (3, 'Carlos', 'Mexico'); CREATE TABLE research_grants (grant_id INT, student_id INT, amount INT); INSERT INTO research_grants (grant_id, student_id, amount) VALUES (1, 1, 10000), (2, 2, 15000), (3, 3, 20000), (4, 1, 30000);
What is the maximum amount of research grants awarded to graduate students from India?
SELECT MAX(rg.amount) FROM research_grants rg JOIN graduate_students gs ON rg.student_id = gs.student_id WHERE gs.country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage(sector VARCHAR(20), year INT, consumption INT); INSERT INTO water_usage VALUES ('Industrial', 2015, 3000), ('Industrial', 2016, 3200), ('Industrial', 2017, 3400), ('Industrial', 2018, 3600), ('Agricultural', 2015, 8000), ('Agricultural', 2016, 8400), ('Agricultural', 2017, 8800), ('Agricultural', 2018, 9200);
What is the difference in water consumption between industrial and agricultural sectors from 2015 to 2018?
SELECT a.sector, (a.consumption - b.consumption) AS difference FROM water_usage AS a, water_usage AS b WHERE a.sector = 'Industrial' AND b.sector = 'Agricultural' AND a.year = b.year AND a.year BETWEEN 2015 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (id INT, city VARCHAR(20), year INT, type VARCHAR(10)); INSERT INTO exhibitions (id, city, year, type) VALUES (1, 'Paris', 2020, 'visual art'), (2, 'London', 2019, 'visual art'), (3, 'Paris', 2020, 'performing art'), (4, 'London', 2020, 'visual art'), (5, 'New York', 2020, 'visual art');
How many visual art exhibitions were held in Paris and London in 2020?
SELECT COUNT(*) FROM exhibitions WHERE city IN ('Paris', 'London') AND year = 2020 AND type = 'visual art';
gretelai_synthetic_text_to_sql
CREATE TABLE agencies (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), budget DECIMAL(10, 2));
Add a new agency to the 'agencies' table
INSERT INTO agencies (id, name, type, budget) VALUES (1, 'Parks Department', 'Public Works', 500000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (maintenance_id INT, equipment_type VARCHAR(50), maintenance_activity VARCHAR(100), maintenance_date DATE);
List military equipment types with no maintenance activities in the 'equipment_maintenance' table
SELECT equipment_type FROM equipment_maintenance GROUP BY equipment_type HAVING COUNT(*) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (post_id INT, user_id INT, like_count INT, post_date DATE); INSERT INTO posts (post_id, user_id, like_count, post_date) VALUES (1, 1, 6000, '2022-02-01'), (2, 2, 2000, '2022-02-03'), (3, 3, 8000, '2022-02-05');
What is the average number of likes on posts from users in the 'celebrity' category who have more than 100000 followers, for posts made in the last 30 days?
SELECT AVG(like_count) FROM posts JOIN users ON posts.user_id = users.user_id WHERE users.category = 'celebrity' AND users.follower_count > 100000 AND posts.post_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide (region VARCHAR(255), year INT, gender VARCHAR(50), internet_accessibility FLOAT, mobile_accessibility FLOAT); INSERT INTO digital_divide (region, year, gender, internet_accessibility, mobile_accessibility) VALUES ('North America', 2015, 'Male', 0.85, 0.93), ('South America', 2016, 'Female', 0.68, 0.82), ('Asia', 2017, 'Non-binary', 0.48, 0.76);
Show all records in digital_divide table with 'Non-binary' gender
SELECT * FROM digital_divide WHERE gender = 'Non-binary';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, CEO_gender TEXT); INSERT INTO company (id, name, CEO_gender) VALUES (1, 'Acme Inc', 'female'); INSERT INTO company (id, name, CEO_gender) VALUES (2, 'Beta Corp', 'male'); CREATE TABLE funding_round (company_id INT, round_amount INT); INSERT INTO funding_round (company_id, round_amount) VALUES (1, 5000000); INSERT INTO funding_round (company_id, round_amount) VALUES (2, 8000000);
What is the total funding raised by startups with a female CEO?
SELECT SUM(funding_round.round_amount) FROM company JOIN funding_round ON company.id = funding_round.company_id WHERE company.CEO_gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(50), monthly_cost DECIMAL(5,2)); INSERT INTO mobile_plans (plan_id, plan_name, monthly_cost) VALUES (1, 'Basic', 30.00), (2, 'Premium', 50.00), (3, 'Family', 70.00);
What is the total revenue for each mobile plan in the past month?
SELECT plan_name, SUM(monthly_cost) as total_revenue FROM mobile_plans WHERE MONTH(current_date) = MONTH(date_sub(current_date, INTERVAL 1 MONTH)) GROUP BY plan_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicleStats (id INT, make VARCHAR(20), model VARCHAR(20), range INT, autonomy_level INT); INSERT INTO ElectricVehicleStats (id, make, model, range, autonomy_level) VALUES (1, 'Tesla', 'Model S', 373, 5), (2, 'Tesla', 'Model 3', 263, 4), (3, 'Rivian', 'R1T', 314, 4), (4, 'Lucid', 'Air', 517, 5), (5, 'Volvo', 'XC40 Recharge', 208, 2), (6, 'Nissan', 'Leaf', 150, 0);
What is the average range of electric vehicles, partitioned by manufacturer, for vehicles with a range greater than 200 miles?
SELECT make, AVG(range) AS avg_range FROM ElectricVehicleStats WHERE range > 200 GROUP BY make;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (id INT, initiative VARCHAR(255), country VARCHAR(255), offset_type VARCHAR(255), amount INT); INSERT INTO carbon_offsets (id, initiative, country, offset_type, amount) VALUES (1, 'Tree Planting', 'Canada', 'Trees', 5000);
How many trees have been planted for each carbon offset initiative in Canada?
SELECT initiative, SUM(amount) as total_trees FROM carbon_offsets WHERE country = 'Canada' AND offset_type = 'Trees' GROUP BY initiative;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, company VARCHAR(255), year INT, quantity INT); INSERT INTO satellites (id, company, year, quantity) VALUES (1, 'SatelliteCo', 2010, 5), (2, 'SatelliteCo', 2011, 8), (3, 'SpaceComm', 2010, 3), (4, 'SatelliteCo', 2012, 6);
List the number of satellites deployed by 'SatelliteCo' each year, sorted by the number of satellites deployed in descending order?
SELECT year, SUM(quantity) as total_deployed FROM satellites WHERE company = 'SatelliteCo' GROUP BY year ORDER BY total_deployed DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE football_matches (match_id INT, home_team VARCHAR(50), away_team VARCHAR(50), home_team_score INT, away_team_score INT);
What is the maximum number of goals scored in a match by a single team in the 'football_matches' table?
SELECT MAX(GREATEST(home_team_score, away_team_score)) FROM football_matches;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, vessel_id INT, type VARCHAR(50), date DATE); INSERT INTO incidents (id, vessel_id, type, date) VALUES (1, 1, 'Collision', '2019-03-15'); INSERT INTO incidents (id, vessel_id, type, date) VALUES (2, 1, 'Grounding', '2021-08-22'); INSERT INTO incidents (id, vessel_id, type, date) VALUES (3, 2, 'Fire', '2020-02-03'); INSERT INTO incidents (id, vessel_id, type, date) VALUES (4, 2, 'Collision', '2018-11-09');
Delete all safety incidents that occurred before 2020.
DELETE FROM incidents WHERE date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists Manufacturers (id int, name text); INSERT INTO Manufacturers (id, name) VALUES (1, 'Tesla'), (2, 'Waymo'), (3, 'Uber'), (4, 'NVIDIA'); CREATE TABLE if not exists Vehicles (id int, type text, manufacturer_id int, is_autonomous boolean); INSERT INTO Vehicles (id, type, manufacturer_id, is_autonomous) VALUES (1, 'Taxi', 1, true), (2, 'Bus', 2, false), (3, 'Taxi', 3, true), (4, 'Truck', 4, false); CREATE TABLE if not exists Cities (id int, name text); INSERT INTO Cities (id, name) VALUES (1, 'Toronto'), (2, 'Montreal'), (3, 'New York'); CREATE TABLE if not exists ManufacturingDates (id int, vehicle_id int, year int); INSERT INTO ManufacturingDates (id, vehicle_id, year) VALUES (1, 1, 2017), (2, 1, 2018), (3, 2, 2015), (4, 3, 2019), (5, 4, 2016);
Count the number of autonomous taxis in 'Toronto' and 'Montreal' that were manufactured before 2018?
SELECT COUNT(*) FROM Vehicles JOIN ManufacturingDates ON Vehicles.id = ManufacturingDates.vehicle_id JOIN Cities ON Vehicles.id = Cities.id WHERE is_autonomous = true AND year < 2018 AND Cities.name IN ('Toronto', 'Montreal');
gretelai_synthetic_text_to_sql
CREATE VIEW Transportation_Types AS SELECT project_id, project_name, project_type FROM Transportation WHERE year >= 2015; CREATE TABLE Transportation_Type_Descriptions (project_type VARCHAR(255), type_description VARCHAR(255));
List the total cost and number of projects for each type of transportation infrastructure
SELECT project_type, SUM(cost), COUNT(*) FROM (SELECT project_id, project_name, project_type, cost FROM Transportation_Types JOIN Transportation_Costs ON Transportation_Types.project_id = Transportation_Costs.project_id) AS transportation_data JOIN Transportation_Type_Descriptions ON transportation_data.project_type = Transportation_Type_Descriptions.project_type GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (product_id INT, product_name VARCHAR(255), quantity_on_hand INT, last_updated TIMESTAMP);
Delete all records in the 'inventory' table with a 'quantity_on_hand' value less than 10
DELETE FROM inventory WHERE quantity_on_hand < 10;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name VARCHAR(255), species_count INT); INSERT INTO marine_protected_areas (area_name, species_count) VALUES ('Galapagos Islands', 500), ('Great Barrier Reef', 1500), ('Palau National Marine Sanctuary', 1000);
Find the maximum number of species found in a single marine protected area
SELECT MAX(species_count) FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(100), code VARCHAR(1000), creation_date DATE); INSERT INTO smart_contracts (id, name, code, creation_date) VALUES (1, 'SC_123', '0x123...', '2017-01-01'); INSERT INTO smart_contracts (id, name, code, creation_date) VALUES (2, 'OtherSC', '0x456...', '2018-05-05');
Delete all records of smart contracts with a creation date before 2018-01-01 from the smart_contracts table.
DELETE FROM smart_contracts WHERE creation_date < '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthWorkers (Location VARCHAR(20), WorkerType VARCHAR(20), Count INT); INSERT INTO HealthWorkers (Location, WorkerType, Count) VALUES ('Urban', 'MentalHealthProfessional', 1200), ('Urban', 'CommunityHealthWorker', 800), ('Rural', 'MentalHealthProfessional', 600), ('Rural', 'CommunityHealthWorker', 400);
Find the ratio of community health workers to mental health professionals in urban areas.
SELECT AVG(CommunityHealthWorkerCount / MentalHealthProfessionalCount) AS Ratio FROM (SELECT SUM(CASE WHEN Location = 'Urban' AND WorkerType = 'MentalHealthProfessional' THEN Count ELSE 0 END) AS MentalHealthProfessionalCount, SUM(CASE WHEN Location = 'Urban' AND WorkerType = 'CommunityHealthWorker' THEN Count ELSE 0 END) AS CommunityHealthWorkerCount FROM HealthWorkers);
gretelai_synthetic_text_to_sql
CREATE TABLE min_transaction_values (industry_sector VARCHAR(10), asset_name VARCHAR(10), quarter INT, min_transaction_value INT); INSERT INTO min_transaction_values (industry_sector, asset_name, quarter, min_transaction_value) VALUES ('Education', 'BTC', 1, 500), ('Education', 'BTC', 2, 700), ('Education', 'BTC', 3, 1000), ('Education', 'LINK', 1, 1200), ('Education', 'LINK', 2, 1500), ('Education', 'LINK', 3, 1800);
What is the minimum transaction value for the 'Education' industry sector in the 'LINK' digital asset in Q1 2022?
SELECT min_transaction_value FROM min_transaction_values WHERE industry_sector = 'Education' AND asset_name = 'LINK' AND quarter = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, dysprosium_production FLOAT, timestamp DATE); INSERT INTO mines (id, name, location, dysprosium_production, timestamp) VALUES (1, 'Mine A', 'Canada', 120.5, '2019-01-01'), (2, 'Mine B', 'Canada', 150.7, '2020-01-01'), (3, 'Mine C', 'USA', 200.3, '2019-01-01');
What is the total Dysprosium production in 2019 and 2020 from all mines?
SELECT SUM(dysprosium_production) FROM mines WHERE YEAR(timestamp) IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (id INT, consumer_id INT, product_id INT, preference TEXT); INSERT INTO consumer_preferences (id, consumer_id, product_id, preference) VALUES (1, 1, 1, 'moisturizing'), (2, 1, 2, 'lightweight'), (3, 2, 1, 'organic'), (4, 2, 3, 'matte finish'); CREATE TABLE ingredient_sourcing (id INT, product_id INT, country TEXT); INSERT INTO ingredient_sourcing (id, product_id, country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 3, 'Mexico'), (4, 4, 'France');
Find the IDs of products that are both moisturizing and lightweight, and are sourced from the USA or Canada.
SELECT product_id FROM consumer_preferences WHERE preference IN ('moisturizing', 'lightweight') INTERSECT SELECT product_id FROM ingredient_sourcing WHERE country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism (visitor_continent VARCHAR(50), host_country VARCHAR(50), number_of_tourists INT); INSERT INTO tourism (visitor_continent, host_country, number_of_tourists) VALUES ('Asia', 'France', 500000), ('Asia', 'Spain', 400000), ('Asia', 'Italy', 450000);
What is the rank of France in terms of the number of tourists visiting from Asia?
SELECT host_country, RANK() OVER (ORDER BY number_of_tourists DESC) as rank FROM tourism WHERE visitor_continent = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (property_id INT, city VARCHAR(20), units INT); INSERT INTO inclusive_housing (property_id, city, units) VALUES (1, 'Oakland', 20), (2, 'Berkeley', 15), (3, 'Seattle', 10);
How many inclusive housing units are in Seattle?
SELECT SUM(units) FROM inclusive_housing WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (hotel_id INT, category TEXT, revenue FLOAT, quarter INT, year INT); INSERT INTO hotel_revenue (hotel_id, category, revenue, quarter, year) VALUES (1, 'business', 5000, 1, 2022), (2, 'leisure', 3000, 1, 2022), (3, 'business', 7000, 2, 2022);
What is the total revenue for the 'business' category in Q1 of 2022?
SELECT SUM(revenue) FROM hotel_revenue WHERE category = 'business' AND quarter = 1 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_population (state TEXT, veterans INT, total_population INT); INSERT INTO veteran_population (state, veterans, total_population) VALUES ('Texas', 1500000, 30000000), ('California', 2000000, 40000000), ('New York', 1000000, 20000000), ('Florida', 1200000, 25000000); CREATE TABLE unemployment (state TEXT, rate FLOAT); INSERT INTO unemployment (state, rate) VALUES ('Texas', 5.0), ('California', 4.5), ('New York', 6.0), ('Florida', 4.8);
Show veteran unemployment rates by state
SELECT v.state, u.rate FROM veteran_population v INNER JOIN unemployment u ON v.state = u.state;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(50), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 150.3), (2, 'Habitat2', 250.8), (3, 'Habitat3', 175.5);
Update the name of Habitat1 to 'New Habitat Name' in the wildlife habitat table.
UPDATE wildlife_habitat SET name = 'New Habitat Name' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), chatbot VARCHAR(50), rating FLOAT); INSERT INTO hotels (hotel_id, name, chatbot, rating) VALUES (1, 'Hotel X', 'Model A', 4.5), (2, 'Hotel Y', 'Model B', 4.2), (3, 'Hotel Z', 'Model A', 4.7);
List the unique AI chatbot models used by the hotels in the hotels table and the number of hotels using each model.
SELECT chatbot, COUNT(DISTINCT hotel_id) as hotels_count FROM hotels GROUP BY chatbot;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (company_id INT, investor_country TEXT); INSERT INTO investment_rounds (company_id, investor_country) VALUES (1, 'India'); INSERT INTO investment_rounds (company_id, investor_country) VALUES (2, 'USA'); INSERT INTO investment_rounds (company_id, investor_country) VALUES (3, 'Canada'); INSERT INTO investment_rounds (company_id, investor_country) VALUES (4, 'UK');
List all companies that have received funding from investors in India
SELECT c.id, c.name FROM company c INNER JOIN investment_rounds ir ON c.id = ir.company_id WHERE ir.investor_country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy (state VARCHAR(20), generator_type VARCHAR(20), capacity FLOAT); INSERT INTO wind_energy (state, generator_type, capacity) VALUES ('Texas', 'Wind', 2000.0), ('Texas', 'Wind', 3000.0), ('California', 'Wind', 1500.0), ('California', 'Wind', 2500.0);
What is the total capacity (in MW) of installed wind energy generators in Texas and California?
SELECT SUM(capacity) FROM wind_energy WHERE state IN ('Texas', 'California') AND generator_type = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, equipment_name VARCHAR(100), type VARCHAR(50)); CREATE TABLE marine_corps_equipment (equipment_id INT, base_location VARCHAR(100)); CREATE TABLE equipment_maintenance (equipment_id INT, maintenance_schedule DATE); INSERT INTO military_equipment (equipment_id, equipment_name, type) VALUES (1, 'M1 Abrams', 'Tank'), (2, 'UH-1Y Venom', 'Helicopter'); INSERT INTO marine_corps_equipment (equipment_id, base_location) VALUES (1, 'Camp Pendleton, CA'), (2, 'Marine Corps Air Station Camp Pendleton, CA'); INSERT INTO equipment_maintenance (equipment_id, maintenance_schedule) VALUES (1, '2022-06-01'), (2, '2022-07-15');
List of military equipment and their maintenance schedules for the Marine Corps in California?
SELECT me.equipment_name, em.maintenance_schedule FROM military_equipment me INNER JOIN marine_corps_equipment mce ON me.equipment_id = mce.equipment_id INNER JOIN equipment_maintenance em ON me.equipment_id = em.equipment_id WHERE mce.base_location LIKE '%CA%';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (country VARCHAR(255), population INT); INSERT INTO climate_adaptation VALUES ('Nigeria', 200000000); INSERT INTO climate_adaptation VALUES ('Kenya', 53000000);
List all countries involved in climate adaptation projects in Africa, excluding those with a population under 10 million.
SELECT country FROM climate_adaptation WHERE population >= 10000000 AND continent = 'Africa'
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), country VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, country) VALUES (21, 'São Paulo-Guarulhos International Airport', 'Airport', 'Brazil'), (22, 'Rio de Janeiro-Galeão International Airport', 'Airport', 'Brazil');
Show the airports in Brazil
SELECT name FROM Infrastructure WHERE type = 'Airport' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityBudget (id INT, heritage_site VARCHAR(255), budget FLOAT); INSERT INTO CommunityBudget (id, heritage_site, budget) VALUES (1, 'Uluru', 100000), (2, 'Te Papa', 150000), (3, 'Sydney Opera House', 200000);
What is the total budget allocated for community engagement in Pacific heritage sites?
SELECT SUM(budget) FROM CommunityBudget WHERE heritage_site IN (SELECT name FROM Heritagesites WHERE continent = 'Pacific');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, gender VARCHAR(6), sector VARCHAR(255), esg_rating FLOAT); INSERT INTO employees (id, gender, sector, esg_rating) VALUES (1, 'male', 'finance', 6.5), (2, 'female', 'finance', 7.1), (3, 'non-binary', 'technology', 8.0);
Which gender has the lowest average ESG rating in the finance sector?
SELECT gender, AVG(esg_rating) FROM employees WHERE sector = 'finance' GROUP BY gender ORDER BY AVG(esg_rating) LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE auto_show (id INT PRIMARY KEY, show_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);
Create a table for auto show information
CREATE TABLE auto_show (id INT PRIMARY KEY, show_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, name VARCHAR(255), category VARCHAR(255), material_id INT); INSERT INTO Products (product_id, name, category, material_id) VALUES (1, 'Recycled Polyester T-Shirt', 'Clothing', 1), (2, 'Bamboo Socks', 'Clothing', 2), (3, 'Recycled Plastic Water Bottle', 'Accessories', 3); CREATE TABLE Materials (material_id INT, name VARCHAR(255), is_recycled BOOLEAN); INSERT INTO Materials (material_id, name, is_recycled) VALUES (1, 'Recycled Polyester', TRUE), (2, 'Bamboo', FALSE), (3, 'Recycled Plastic', TRUE); CREATE TABLE Factories (factory_id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO Factories (factory_id, name, country) VALUES (1, 'GreenFactory', 'USA'), (2, 'EcoFriendlyFactory', 'India'), (3, 'SustainableFactory', 'Brazil'); CREATE TABLE ProductFactories (product_id INT, factory_id INT); INSERT INTO ProductFactories (product_id, factory_id) VALUES (1, 1), (2, 2), (3, 3);
List all products that use recycled materials and their respective factories.
SELECT Products.name, Factories.name FROM Products INNER JOIN Materials ON Products.material_id = Materials.material_id INNER JOIN ProductFactories ON Products.product_id = ProductFactories.product_id INNER JOIN Factories ON ProductFactories.factory_id = Factories.factory_id WHERE Materials.is_recycled = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Species_Feed (Species_Name TEXT, Year INT, Feed_Conversion_Ratio FLOAT); INSERT INTO Species_Feed (Species_Name, Year, Feed_Conversion_Ratio) VALUES ('Salmon', 2019, 1.2), ('Trout', 2019, 1.3), ('Shrimp', 2019, 1.5), ('Salmon', 2020, 1.1), ('Trout', 2020, 1.2), ('Shrimp', 2020, 1.4);
What is the feed conversion ratio for each species in 2020?
SELECT Species_Name, Feed_Conversion_Ratio FROM Species_Feed WHERE Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping_projects (id INT PRIMARY KEY, project_name VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT);
Update the budget of the Sonar Mapping Project in the 'ocean_floor_mapping_projects' table
UPDATE ocean_floor_mapping_projects SET budget = 500000 WHERE project_name = 'Sonar Mapping Project';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, item_name VARCHAR(255), category VARCHAR(255), price INT); INSERT INTO menu_items (menu_item_id, item_name, category, price) VALUES (1, 'Steak', 'Entree', 25), (2, 'Fries', 'Side', 5), (3, 'Burger', 'Entree', 15), (4, 'Salad', 'Side', 8);
Which menu items have the highest cost?
SELECT item_name, price FROM menu_items ORDER BY price DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (metric_id INT, region VARCHAR(255), score INT); INSERT INTO health_equity_metrics (metric_id, region, score) VALUES (1, 'Northeast', 75), (2, 'Southeast', 80), (3, 'Northeast', 85);
What is the average health equity metric score for each region?
SELECT region, AVG(score) FROM health_equity_metrics GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonationAmount DECIMAL(10,2), DonorState VARCHAR(2));
What is the average donation amount from donors located in California?
SELECT AVG(DonationAmount) FROM Donors WHERE DonorState = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), status VARCHAR(50));
Remove the record for machine "Machine 1" from the "machines" table
DELETE FROM machines WHERE name = 'Machine 1';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(50), location VARCHAR(50)); INSERT INTO peacekeeping_operations (id, country, location) VALUES (1, 'Ethiopia', 'Somalia'), (2, 'Kenya', 'Somalia'), (3, 'Burundi', 'South Sudan'), (4, 'Senegal', 'Mali');
Which countries are involved in peacekeeping operations in Africa?
SELECT DISTINCT country FROM peacekeeping_operations WHERE location = 'Somalia' OR location = 'South Sudan' OR location = 'Mali';
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteID int, SiteName text, Country text); INSERT INTO HeritageSites (SiteID, SiteName, Country) VALUES (1, 'Eiffel Tower', 'France'), (2, 'Mont Saint-Michel', 'France'), (3, 'Alhambra', 'Spain');
Which heritage sites are located in France and Spain?
SELECT SiteName FROM HeritageSites WHERE Country = 'France' INTERSECT SELECT SiteName FROM HeritageSites WHERE Country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists bike_stations (station_id serial primary key,name varchar(255),region varchar(255));CREATE TABLE if not exists bike_trips (trip_id serial primary key,start_station_id int,end_station_id int,start_date date,end_date date);CREATE TABLE if not exists calendar (calendar_id serial primary key,date date,service_id int);CREATE TABLE if not exists calendar_dates (calendar_date_id serial primary key,date date,exception_type int);
What is the total number of bike share trips taken in the month of June?
SELECT COUNT(*) FROM bike_trips bt JOIN calendar c ON bt.start_date = c.date WHERE c.date BETWEEN '2022-06-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_conservation_organizations (id INT PRIMARY KEY, organization VARCHAR(255), location VARCHAR(255), budget INT); INSERT INTO marine_conservation_organizations (id, organization, location, budget) VALUES (1, 'Coastal Preservation Alliance', 'Florida', 7000000);
What is the current budget for 'Coastal Preservation Alliance'?
SELECT budget FROM marine_conservation_organizations WHERE organization = 'Coastal Preservation Alliance';
gretelai_synthetic_text_to_sql
CREATE TABLE underwriting (id INT, group VARCHAR(10), name VARCHAR(20), claim_amount DECIMAL(10,2)); INSERT INTO underwriting (id, group, name, claim_amount) VALUES (1, 'High Risk', 'John Doe', 5000.00), (2, 'Low Risk', 'Jane Smith', 2000.00), (3, 'High Risk', 'Mike Johnson', 7000.00);
What is the total claim amount paid to policyholders from 'High Risk' underwriting group?
SELECT SUM(claim_amount) FROM underwriting WHERE group = 'High Risk';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(20), trip_duration INT); INSERT INTO tourism_stats (country, trip_duration) VALUES ('Indonesia', 14);
What is the average trip duration for tourists visiting Indonesia?
SELECT AVG(trip_duration) FROM tourism_stats WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE Nature_s_Guardians (Animal_ID INT, Animal_Name VARCHAR(50), Species VARCHAR(50), Age INT); INSERT INTO Nature_s_Guardians VALUES (1, 'Bambi', 'Deer', 3); INSERT INTO Nature_s_Guardians VALUES (2, 'Fiona', 'Turtle', 10); INSERT INTO Nature_s_Guardians VALUES (3, 'Chirpy', 'Eagle', 5); INSERT INTO Nature_s_Guardians VALUES (4, 'Whiskers', 'Raccoon', 2); INSERT INTO Nature_s_Guardians VALUES (5, 'Bella', 'Deer', 4);
How many animals of each species are there in 'Nature's Guardians'?
SELECT Species, COUNT(*) AS Number_of_Animals FROM Nature_s_Guardians GROUP BY Species
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (id INT, vessel_name VARCHAR(50), date DATE, region VARCHAR(50)); INSERT INTO accidents (id, vessel_name, date, region) VALUES (1, 'Vessel A', '2018-01-01', 'Mediterranean Sea'), (2, 'Vessel B', '2018-04-01', 'Mediterranean Sea');
How many accidents occurred in the Mediterranean Sea in the last 5 years, broken down by the quarter they happened in?
SELECT COUNT(*), DATE_FORMAT(date, '%Y-%m') AS quarter FROM accidents WHERE region = 'Mediterranean Sea' AND date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE grad_students (id INT, name VARCHAR(50), continent VARCHAR(50));CREATE TABLE papers (id INT, paper_id INT, title VARCHAR(100), year INT, author_id INT);
What is the total number of academic papers published by graduate students from each continent, in the last 4 years?
SELECT gs.continent, COUNT(DISTINCT p.id) AS num_papers FROM grad_students gs JOIN papers p ON gs.id = p.author_id WHERE p.year BETWEEN YEAR(CURRENT_DATE) - 4 AND YEAR(CURRENT_DATE) GROUP BY gs.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_policies (id INT, name VARCHAR, last_updated DATE); INSERT INTO cybersecurity_policies (id, name, last_updated) VALUES (1, 'Incident Response Plan', '2021-01-01'), (2, 'Access Control Policy', '2021-02-01'), (3, 'Data Protection Policy', '2021-03-01'), (4, 'Network Security Policy', '2021-04-01'), (5, 'Acceptable Use Policy', '2021-05-01');
What are the names and policies of all cybersecurity policies that have been updated in the past month?
SELECT name, last_updated FROM cybersecurity_policies WHERE last_updated >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT, name VARCHAR(50), span_length FLOAT, material VARCHAR(20)); INSERT INTO bridges (id, name, span_length, material) VALUES (1, 'Golden Gate', 2737.4, 'Steel');
What is the name and material of the bridge with the longest span length in the 'infrastructure' schema?
SELECT name, material FROM bridges WHERE span_length = (SELECT MAX(span_length) FROM bridges);
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, country VARCHAR(50));
What is the total number of male and female news reporters in the "reporters" table?
SELECT gender, COUNT(*) FROM reporters GROUP BY gender;
gretelai_synthetic_text_to_sql